@tonyclaw/agent-inspector 3.0.45 → 3.0.46

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 (338) hide show
  1. package/.output/{nitro.json → backend/nitro.json} +3 -3
  2. package/.output/backend-public/assets/index-D4LX-sw-.js +11 -0
  3. package/.output/cli.js +2326 -516
  4. package/.output/server/_libs/extend.mjs +4 -8
  5. package/.output/server/_libs/jszip.mjs +9 -35
  6. package/.output/server/_libs/react-dom.mjs +2 -3
  7. package/.output/server/_libs/react.mjs +1 -27
  8. package/.output/server/_libs/tanstack__react-router.mjs +1 -329
  9. package/.output/server/_libs/tanstack__router-core.mjs +42 -100
  10. package/.output/server/_libs/use-sync-external-store.mjs +1 -64
  11. package/.output/server/_libs/ws.mjs +1 -1
  12. package/.output/server/_ssr/index.mjs +4 -4
  13. package/.output/server/_ssr/{publicBasePathContext-5264L3rX.mjs → publicBasePathContext-IH2ilOfu.mjs} +52 -24
  14. package/.output/server/_ssr/{router-BJ_ltLim.mjs → router-D18yUq36.mjs} +19770 -19447
  15. package/.output/server/_ssr/{start-C6MjPjxp.mjs → start-COQu_AgD.mjs} +1 -1
  16. package/.output/server/_tanstack-start-manifest_v-DnbdNeun.mjs +4 -0
  17. package/.output/server/index.mjs +5 -145
  18. package/.output/{public/assets/CompareDrawer-B3_TLTJh.js → ui/assets/CompareDrawer-DAUuIJ6G.js} +1 -1
  19. package/.output/{public/assets/InspectorPet-Cpn6hv4P.js → ui/assets/InspectorPet-BRBVjOWI.js} +1 -1
  20. package/.output/ui/assets/ProxyViewerContainer-D7Sq0ctc.js +59 -0
  21. package/.output/{public/assets/ReplayDialog-B3EKVdJk.js → ui/assets/ReplayDialog-nDLsjOhs.js} +1 -1
  22. package/.output/{public/assets/RequestAnatomy-COOQjyUC.js → ui/assets/RequestAnatomy-zd4BDgL0.js} +1 -1
  23. package/.output/ui/assets/ResponseView-AdIXGcSn.js +2 -0
  24. package/.output/ui/assets/StreamingChunkSequence-CesTz8He.js +1 -0
  25. package/.output/{public/assets/_sessionId-zbgYl7ZJ.js → ui/assets/_sessionId-BAfzrhSU.js} +1 -1
  26. package/.output/{public/assets/_sessionId-BJlM3nmt.js → ui/assets/_sessionId-QnBomgPD.js} +1 -1
  27. package/.output/ui/assets/favicon-DYEkHSNl.svg +21 -0
  28. package/.output/{public/assets/index-BIK4bPTv.js → ui/assets/index-BcsdxBAd.js} +1 -1
  29. package/.output/ui/assets/index-BvXp42al.css +1 -0
  30. package/.output/{public/assets/index-D2Qw6Ri2.js → ui/assets/index-D0rtCN9V.js} +1 -1
  31. package/.output/ui/assets/index-DHpwr08Z.js +73 -0
  32. package/.output/{public/assets/index-xF_NY8Yb.js → ui/assets/index-dNuk2dsU.js} +5 -5
  33. package/.output/ui/assets/json-viewer-BvFHglMb.js +1 -0
  34. package/.output/{public/assets/jszip.min-B_rfAUCe.js → ui/assets/jszip.min-B5Z7gNZB.js} +1 -1
  35. package/.output/ui/index.html +229 -0
  36. package/.output/ui/runtime-config.js +2 -0
  37. package/.output/workers/logFinalizer.worker.js +979 -414
  38. package/.output/workers/sessionWorkerEntry.js +979 -414
  39. package/README.md +175 -43
  40. package/docs/instance-control.openapi.yaml +59 -4
  41. package/package.json +25 -5
  42. package/scripts/generate-theme-scales.mjs +3 -3
  43. package/src/{router.tsx → backend/router.tsx} +3 -15
  44. package/src/backend/routes/$.ts +26 -0
  45. package/src/backend/routes/__root.ts +4 -0
  46. package/src/{routes → backend/routes}/api/-instances.ts +3 -3
  47. package/src/{routes → backend/routes}/api/alerts.summary.ts +3 -3
  48. package/src/{routes → backend/routes}/api/alerts.ts +4 -4
  49. package/src/{routes → backend/routes}/api/config.paths.ts +1 -1
  50. package/src/{routes → backend/routes}/api/config.ts +11 -2
  51. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.help.ts +1 -1
  52. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.install.ts +1 -1
  53. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.runner-presets.ts +1 -1
  54. package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.upgrade.ts +1 -1
  55. package/src/{routes → backend/routes}/api/ecosystem.packages.ts +5 -1
  56. package/src/{routes → backend/routes}/api/ecosystem.recipes.$recipeId.run.ts +1 -1
  57. package/src/{routes → backend/routes}/api/ecosystem.tasks.$taskId.ts +1 -1
  58. package/src/{routes → backend/routes}/api/ecosystem.tasks.ts +1 -1
  59. package/src/{routes → backend/routes}/api/groups.$groupId.evidence.ts +2 -2
  60. package/src/{routes → backend/routes}/api/groups.$groupId.sessions.ts +2 -2
  61. package/src/{routes → backend/routes}/api/groups.$groupId.ts +2 -2
  62. package/src/{routes → backend/routes}/api/groups.ts +2 -2
  63. package/src/{routes → backend/routes}/api/health.ts +3 -3
  64. package/src/{routes → backend/routes}/api/instances.$name.connection.ts +1 -1
  65. package/src/{routes → backend/routes}/api/instances.$name.restart.ts +2 -2
  66. package/src/{routes → backend/routes}/api/instances.$name.start.ts +2 -2
  67. package/src/{routes → backend/routes}/api/instances.$name.stop.ts +2 -2
  68. package/src/{routes → backend/routes}/api/instances.$name.ts +1 -1
  69. package/src/{routes → backend/routes}/api/instances.ts +1 -1
  70. package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.promote.ts +2 -2
  71. package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.ts +2 -2
  72. package/src/{routes → backend/routes}/api/knowledge.candidates.ts +1 -1
  73. package/src/{routes → backend/routes}/api/knowledge.project-context.ts +2 -2
  74. package/src/{routes → backend/routes}/api/knowledge.search.ts +2 -2
  75. package/src/{routes → backend/routes}/api/knowledge.sessions.$sessionId.candidates.ts +3 -3
  76. package/src/{routes → backend/routes}/api/logs.$id.body.ts +6 -6
  77. package/src/{routes → backend/routes}/api/logs.$id.chunks.ts +5 -4
  78. package/src/{routes → backend/routes}/api/logs.$id.replay.ts +12 -11
  79. package/src/{routes → backend/routes}/api/logs.$id.ts +4 -3
  80. package/src/{routes → backend/routes}/api/logs.import.ts +3 -3
  81. package/src/{routes → backend/routes}/api/logs.stream.ts +11 -7
  82. package/src/{routes → backend/routes}/api/logs.ts +17 -9
  83. package/src/{routes → backend/routes}/api/mcp.ts +1 -1
  84. package/src/{routes → backend/routes}/api/models.ts +1 -1
  85. package/src/{routes → backend/routes}/api/pi-agent.ts +2 -2
  86. package/src/{routes → backend/routes}/api/providers.$providerId.model-metadata.ts +5 -5
  87. package/src/{routes → backend/routes}/api/providers.$providerId.test.log.ts +7 -7
  88. package/src/{routes → backend/routes}/api/providers.$providerId.ts +4 -4
  89. package/src/{routes → backend/routes}/api/providers.export.ts +1 -1
  90. package/src/{routes → backend/routes}/api/providers.import.ts +3 -3
  91. package/src/{routes → backend/routes}/api/providers.scan.ts +2 -2
  92. package/src/{routes → backend/routes}/api/providers.ts +9 -4
  93. package/src/{routes → backend/routes}/api/runs.$runId.evidence.ts +2 -2
  94. package/src/{routes → backend/routes}/api/runs.$runId.ts +2 -2
  95. package/src/{routes → backend/routes}/api/runs.ts +4 -4
  96. package/src/backend/routes/api/runtime.ts +46 -0
  97. package/src/{routes → backend/routes}/api/sessions.ts +3 -3
  98. package/src/{routes → backend/routes}/proxy/$.ts +1 -1
  99. package/src/{routes → backend/routes}/readyz.ts +1 -1
  100. package/src/{start.ts → backend/start.ts} +1 -1
  101. package/src/cli/alias.ts +2 -11
  102. package/src/cli/doctor.ts +32 -9
  103. package/src/cli/instance.ts +26 -13
  104. package/src/cli/instanceArgs.ts +30 -11
  105. package/src/cli/instanceControl.ts +0 -2
  106. package/src/cli/instanceModel.ts +9 -17
  107. package/src/cli/instanceRegistry.ts +0 -9
  108. package/src/cli/networkHints.ts +27 -14
  109. package/src/cli/onboard.ts +69 -2
  110. package/src/cli/onboardTarget.ts +89 -40
  111. package/src/cli/templates/codex-skill-onboard.ts +44 -14
  112. package/src/cli/templates/skill-onboard.ts +64 -28
  113. package/src/cli.ts +184 -61
  114. package/src/components/ProxyViewer.tsx +11 -9
  115. package/src/components/ProxyViewerContainer.tsx +12 -11
  116. package/src/components/pi-agent/PiAgentPanel.tsx +2 -2
  117. package/src/components/providers/ProviderCard.tsx +1 -1
  118. package/src/components/providers/ProviderTestResultsView.tsx +1 -1
  119. package/src/components/providers/SettingsDialog.tsx +159 -144
  120. package/src/components/proxy-viewer/ApplicationBar.tsx +2 -1
  121. package/src/components/proxy-viewer/LogEntry.tsx +1 -1
  122. package/src/components/proxy-viewer/log-formats/index.ts +1 -1
  123. package/src/contracts/index.ts +5 -0
  124. package/src/contracts/log.ts +33 -3
  125. package/src/knowledge/types.ts +3 -2
  126. package/src/lib/alertContract.ts +2 -2
  127. package/src/lib/apiClient.ts +30 -7
  128. package/src/lib/apiFormat.ts +29 -0
  129. package/src/lib/basePath.ts +29 -11
  130. package/src/lib/browserRuntimeContract.ts +124 -0
  131. package/src/lib/browserRuntimeResolver.ts +244 -0
  132. package/src/{proxy → lib}/claudeCodeStrip.ts +6 -7
  133. package/src/lib/codingAgentEndpoints.ts +38 -0
  134. package/src/lib/instanceContract.ts +27 -11
  135. package/src/lib/piAgentContract.ts +3 -2
  136. package/src/lib/publicBasePathContext.ts +40 -10
  137. package/src/lib/resourceLimits.ts +2 -0
  138. package/src/lib/runContract.ts +3 -3
  139. package/src/lib/sessionInfoContract.ts +3 -2
  140. package/src/mcp/instanceHandlers.ts +1 -0
  141. package/src/mcp/server.ts +19 -24
  142. package/src/proxy/config.ts +25 -30
  143. package/src/proxy/dataDir.ts +43 -7
  144. package/src/proxy/ecosystemTasks.ts +161 -70
  145. package/src/proxy/formats/registry.ts +6 -21
  146. package/src/proxy/handler.ts +129 -29
  147. package/src/proxy/identityProxy.ts +419 -39
  148. package/src/proxy/jsonlRecovery.ts +554 -0
  149. package/src/proxy/logFinalizer.ts +25 -10
  150. package/src/proxy/logImporter.ts +2 -1
  151. package/src/proxy/logIndex.ts +191 -95
  152. package/src/proxy/logger.ts +77 -14
  153. package/src/proxy/platformCommands.ts +41 -0
  154. package/src/proxy/privateDataPath.ts +310 -88
  155. package/src/proxy/rawStreamCapture.ts +194 -13
  156. package/src/proxy/runtimeAdmission.ts +5 -2
  157. package/src/proxy/runtimeHealth.ts +14 -1
  158. package/src/proxy/runtimeShutdown.ts +11 -1
  159. package/src/proxy/schemas.ts +7 -1
  160. package/src/proxy/sessionArchive.ts +78 -14
  161. package/src/proxy/sqliteLogIndex.ts +65 -2
  162. package/src/proxy/store.ts +141 -34
  163. package/src/proxy/uiAssetServer.ts +106 -0
  164. package/src/proxy/upstream.ts +29 -2
  165. package/src/ui/bootstrap.ts +167 -0
  166. package/src/ui/index.html +38 -0
  167. package/src/ui/logsStreamClient.ts +20 -0
  168. package/src/ui/main.tsx +13 -0
  169. package/src/ui/public/runtime-config.js +2 -0
  170. package/src/ui/router.tsx +13 -0
  171. package/src/ui/routes/__root.tsx +69 -0
  172. package/src/{routes → ui/routes}/index.tsx +2 -3
  173. package/src/{routes → ui/routes}/session/$sessionId.tsx +5 -11
  174. package/src/ui/runtimeDiscovery.ts +50 -0
  175. package/styles/globals.css +1 -0
  176. package/.output/public/assets/ProxyViewerContainer-BEAhuGOJ.js +0 -126
  177. package/.output/public/assets/ResponseView-DBCjkwye.js +0 -2
  178. package/.output/public/assets/StreamingChunkSequence-CuXhDgMo.js +0 -1
  179. package/.output/public/assets/index-BZo_8koU.js +0 -70
  180. package/.output/public/assets/index-ZWschkCh.css +0 -1
  181. package/.output/public/assets/json-viewer-B-Ao6pwW.js +0 -1
  182. package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +0 -1
  183. package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +0 -344
  184. package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +0 -2
  185. package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +0 -2
  186. package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +0 -2
  187. package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +0 -11
  188. package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +0 -69
  189. package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +0 -1
  190. package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +0 -28
  191. package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +0 -6
  192. package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +0 -34
  193. package/.output/server/_libs/aria-hidden.mjs +0 -122
  194. package/.output/server/_libs/bail.mjs +0 -8
  195. package/.output/server/_libs/character-entities.mjs +0 -2130
  196. package/.output/server/_libs/class-variance-authority.mjs +0 -44
  197. package/.output/server/_libs/clsx.mjs +0 -16
  198. package/.output/server/_libs/comma-separated-tokens.mjs +0 -10
  199. package/.output/server/_libs/decode-named-character-reference+[...].mjs +0 -8
  200. package/.output/server/_libs/dequal.mjs +0 -27
  201. package/.output/server/_libs/detect-node-es.mjs +0 -1
  202. package/.output/server/_libs/devlop.mjs +0 -8
  203. package/.output/server/_libs/diff.mjs +0 -320
  204. package/.output/server/_libs/estree-util-is-identifier-name.mjs +0 -11
  205. package/.output/server/_libs/floating-ui__core.mjs +0 -725
  206. package/.output/server/_libs/floating-ui__dom.mjs +0 -622
  207. package/.output/server/_libs/floating-ui__react-dom.mjs +0 -292
  208. package/.output/server/_libs/floating-ui__utils.mjs +0 -320
  209. package/.output/server/_libs/get-nonce.mjs +0 -9
  210. package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  211. package/.output/server/_libs/hast-util-whitespace.mjs +0 -10
  212. package/.output/server/_libs/html-url-attributes.mjs +0 -26
  213. package/.output/server/_libs/inline-style-parser.mjs +0 -142
  214. package/.output/server/_libs/is-plain-obj.mjs +0 -10
  215. package/.output/server/_libs/lucide-react.mjs +0 -1027
  216. package/.output/server/_libs/mdast-util-from-markdown.mjs +0 -717
  217. package/.output/server/_libs/mdast-util-to-hast.mjs +0 -710
  218. package/.output/server/_libs/mdast-util-to-string.mjs +0 -38
  219. package/.output/server/_libs/micromark-core-commonmark.mjs +0 -2259
  220. package/.output/server/_libs/micromark-factory-destination.mjs +0 -94
  221. package/.output/server/_libs/micromark-factory-label.mjs +0 -63
  222. package/.output/server/_libs/micromark-factory-space.mjs +0 -24
  223. package/.output/server/_libs/micromark-factory-title.mjs +0 -65
  224. package/.output/server/_libs/micromark-factory-whitespace.mjs +0 -22
  225. package/.output/server/_libs/micromark-util-character.mjs +0 -44
  226. package/.output/server/_libs/micromark-util-chunked.mjs +0 -36
  227. package/.output/server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  228. package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  229. package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  230. package/.output/server/_libs/micromark-util-decode-string.mjs +0 -21
  231. package/.output/server/_libs/micromark-util-encode.mjs +0 -1
  232. package/.output/server/_libs/micromark-util-html-tag-name.mjs +0 -69
  233. package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  234. package/.output/server/_libs/micromark-util-resolve-all.mjs +0 -15
  235. package/.output/server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  236. package/.output/server/_libs/micromark-util-subtokenize.mjs +0 -346
  237. package/.output/server/_libs/micromark.mjs +0 -906
  238. package/.output/server/_libs/property-information.mjs +0 -1209
  239. package/.output/server/_libs/radix-ui.mjs +0 -1
  240. package/.output/server/_libs/radix-ui__number.mjs +0 -6
  241. package/.output/server/_libs/radix-ui__primitive.mjs +0 -11
  242. package/.output/server/_libs/radix-ui__react-accordion.mjs +0 -1
  243. package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +0 -1
  244. package/.output/server/_libs/radix-ui__react-arrow.mjs +0 -23
  245. package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +0 -1
  246. package/.output/server/_libs/radix-ui__react-avatar.mjs +0 -1
  247. package/.output/server/_libs/radix-ui__react-checkbox.mjs +0 -1
  248. package/.output/server/_libs/radix-ui__react-collapsible.mjs +0 -144
  249. package/.output/server/_libs/radix-ui__react-collection.mjs +0 -69
  250. package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -38
  251. package/.output/server/_libs/radix-ui__react-context-menu.mjs +0 -1
  252. package/.output/server/_libs/radix-ui__react-context.mjs +0 -64
  253. package/.output/server/_libs/radix-ui__react-dialog.mjs +0 -280
  254. package/.output/server/_libs/radix-ui__react-direction.mjs +0 -9
  255. package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +0 -1
  256. package/.output/server/_libs/radix-ui__react-focus-guards.mjs +0 -39
  257. package/.output/server/_libs/radix-ui__react-focus-scope.mjs +0 -210
  258. package/.output/server/_libs/radix-ui__react-form.mjs +0 -1
  259. package/.output/server/_libs/radix-ui__react-hover-card.mjs +0 -1
  260. package/.output/server/_libs/radix-ui__react-id.mjs +0 -14
  261. package/.output/server/_libs/radix-ui__react-label.mjs +0 -1
  262. package/.output/server/_libs/radix-ui__react-menu.mjs +0 -1
  263. package/.output/server/_libs/radix-ui__react-menubar.mjs +0 -1
  264. package/.output/server/_libs/radix-ui__react-popover.mjs +0 -1
  265. package/.output/server/_libs/radix-ui__react-popper.mjs +0 -340
  266. package/.output/server/_libs/radix-ui__react-portal.mjs +0 -16
  267. package/.output/server/_libs/radix-ui__react-presence.mjs +0 -173
  268. package/.output/server/_libs/radix-ui__react-primitive.mjs +0 -42
  269. package/.output/server/_libs/radix-ui__react-progress.mjs +0 -1
  270. package/.output/server/_libs/radix-ui__react-radio-group.mjs +0 -1
  271. package/.output/server/_libs/radix-ui__react-roving-focus.mjs +0 -235
  272. package/.output/server/_libs/radix-ui__react-scroll-area.mjs +0 -731
  273. package/.output/server/_libs/radix-ui__react-select.mjs +0 -1207
  274. package/.output/server/_libs/radix-ui__react-separator.mjs +0 -28
  275. package/.output/server/_libs/radix-ui__react-slider.mjs +0 -1
  276. package/.output/server/_libs/radix-ui__react-slot.mjs +0 -132
  277. package/.output/server/_libs/radix-ui__react-switch.mjs +0 -1
  278. package/.output/server/_libs/radix-ui__react-tabs.mjs +0 -194
  279. package/.output/server/_libs/radix-ui__react-toast.mjs +0 -2
  280. package/.output/server/_libs/radix-ui__react-toggle-group.mjs +0 -1
  281. package/.output/server/_libs/radix-ui__react-toggle.mjs +0 -1
  282. package/.output/server/_libs/radix-ui__react-toolbar.mjs +0 -1
  283. package/.output/server/_libs/radix-ui__react-tooltip.mjs +0 -498
  284. package/.output/server/_libs/radix-ui__react-use-previous.mjs +0 -14
  285. package/.output/server/_libs/radix-ui__react-use-size.mjs +0 -39
  286. package/.output/server/_libs/react-markdown.mjs +0 -235
  287. package/.output/server/_libs/react-remove-scroll-bar.mjs +0 -82
  288. package/.output/server/_libs/react-remove-scroll.mjs +0 -328
  289. package/.output/server/_libs/react-style-singleton.mjs +0 -69
  290. package/.output/server/_libs/remark-parse.mjs +0 -19
  291. package/.output/server/_libs/remark-rehype.mjs +0 -21
  292. package/.output/server/_libs/space-separated-tokens.mjs +0 -6
  293. package/.output/server/_libs/style-to-js.mjs +0 -72
  294. package/.output/server/_libs/style-to-object.mjs +0 -38
  295. package/.output/server/_libs/swr.mjs +0 -947
  296. package/.output/server/_libs/tailwind-merge.mjs +0 -3255
  297. package/.output/server/_libs/tanstack__react-virtual.mjs +0 -130
  298. package/.output/server/_libs/tanstack__virtual-core.mjs +0 -1319
  299. package/.output/server/_libs/three.mjs +0 -26016
  300. package/.output/server/_libs/trim-lines.mjs +0 -41
  301. package/.output/server/_libs/trough.mjs +0 -85
  302. package/.output/server/_libs/tslib.mjs +0 -1
  303. package/.output/server/_libs/ungap__structured-clone.mjs +0 -212
  304. package/.output/server/_libs/unified.mjs +0 -661
  305. package/.output/server/_libs/unist-util-is.mjs +0 -100
  306. package/.output/server/_libs/unist-util-position.mjs +0 -27
  307. package/.output/server/_libs/unist-util-stringify-position.mjs +0 -27
  308. package/.output/server/_libs/unist-util-visit-parents.mjs +0 -82
  309. package/.output/server/_libs/unist-util-visit.mjs +0 -24
  310. package/.output/server/_libs/use-callback-ref.mjs +0 -66
  311. package/.output/server/_libs/use-sidecar.mjs +0 -106
  312. package/.output/server/_libs/vfile-message.mjs +0 -138
  313. package/.output/server/_libs/vfile.mjs +0 -467
  314. package/.output/server/_sessionId-CJ99gZFV.mjs +0 -84
  315. package/.output/server/_sessionId-DEjScBpK.mjs +0 -146
  316. package/.output/server/_ssr/CompareDrawer-DtOIMeQB.mjs +0 -1060
  317. package/.output/server/_ssr/InspectorPet-CXc4oCBQ.mjs +0 -938
  318. package/.output/server/_ssr/ProxyViewerContainer-DVPlwfkt.mjs +0 -17632
  319. package/.output/server/_ssr/ReplayDialog-BQEA95qC.mjs +0 -725
  320. package/.output/server/_ssr/RequestAnatomy-BMyd8B7Q.mjs +0 -837
  321. package/.output/server/_ssr/ResponseView-qrTaEIM8.mjs +0 -757
  322. package/.output/server/_ssr/StreamingChunkSequence-BFTL8mIy.mjs +0 -274
  323. package/.output/server/_ssr/index-Bcj1Hcy4.mjs +0 -135
  324. package/.output/server/_ssr/index-DW-M7XUG.mjs +0 -84
  325. package/.output/server/_ssr/json-viewer-DiI0Yjsn.mjs +0 -483
  326. package/.output/server/_tanstack-start-manifest_v-C6pXXX9R.mjs +0 -4
  327. package/.output/server/node_modules/tslib/modules/index.js +0 -70
  328. package/.output/server/node_modules/tslib/modules/package.json +0 -3
  329. package/.output/server/node_modules/tslib/package.json +0 -47
  330. package/.output/server/node_modules/tslib/tslib.js +0 -484
  331. package/.output/server/package.json +0 -9
  332. package/src/routes/__root.tsx +0 -170
  333. /package/.output/{public → ui}/assets/agent-inspector-58K1_MsC.ico +0 -0
  334. /package/.output/{public → ui}/assets/alibaba-TTwafVwX.svg +0 -0
  335. /package/.output/{public → ui}/assets/minimax-BPMzvuL-.jpeg +0 -0
  336. /package/.output/{public → ui}/assets/qwen-mMn3f5ul.webp +0 -0
  337. /package/.output/{public → ui}/assets/zhipuai-BPNAnxo-.svg +0 -0
  338. /package/src/{routes → backend/routes}/livez.ts +0 -0
@@ -1,126 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-B_rfAUCe.js","assets/index-BZo_8koU.js","assets/CompareDrawer-B3_TLTJh.js","assets/InspectorPet-Cpn6hv4P.js","assets/ReplayDialog-B3EKVdJk.js","assets/ResponseView-DBCjkwye.js","assets/RequestAnatomy-COOQjyUC.js","assets/StreamingChunkSequence-CuXhDgMo.js","assets/json-viewer-B-Ao6pwW.js","assets/index-xF_NY8Yb.js"])))=>i.map(i=>d[i]);
2
- import{w as Jo,u as Bt,a as lf,r as c,j as s,_ as Kt,b as Li,c as qx,d as $i,p as Hx,T as Vx,n as Wx,e as Zx,f as Kx,g as Di,U as Gx,h as cf,i as Yo,k as Os,l as L,B as ee,m as Jn,o as uf,q as Pe,s as df,t as It,v as Jx,L as go,x as ff,y as Yx,z as xo,A as pf,C as mf,D as Xx}from"./index-BZo_8koU.js";var Bc;function O(e,t,n){function r(l,u){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:u,constr:a,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,u);const d=a.prototype,f=Object.keys(d);for(let p=0;p<f.length;p++){const m=f[p];m in l||(l[m]=d[m].bind(l))}}const o=n?.Parent??Object;class i extends o{}Object.defineProperty(i,"name",{value:e});function a(l){var u;const d=n?.Parent?new i:this;r(d,l),(u=d._zod).deferred??(u.deferred=[]);for(const f of d._zod.deferred)f();return d}return Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:l=>n?.Parent&&l instanceof n.Parent?!0:l?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class bs extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class hf extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Bc=globalThis).__zod_globalConfig??(Bc.__zod_globalConfig={});const yl=globalThis.__zod_globalConfig;function rn(e){return yl}function gf(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Ra(e,t){return typeof t=="bigint"?t.toString():t}function Xo(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function wl(e){return e==null}function jl(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Qx(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}const qc=Symbol("evaluating");function Ee(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==qc)return r===void 0&&(r=qc,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Yn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _n(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Hc(e){return JSON.stringify(e)}function e0(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const xf="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const t0=Xo(()=>{if(yl.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function _s(e){if(rr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(rr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function bf(e){return _s(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const n0=new Set(["string","number","symbol"]);function Ns(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nn(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function oe(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function s0(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const r0={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function o0(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=_n(e._zod.def,{get shape(){const a={};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&(a[l]=n.shape[l])}return Yn(this,"shape",a),a},checks:[]});return Nn(e,i)}function i0(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=_n(e._zod.def,{get shape(){const a={...e._zod.def.shape};for(const l in t){if(!(l in n.shape))throw new Error(`Unrecognized key: "${l}"`);t[l]&&delete a[l]}return Yn(this,"shape",a),a},checks:[]});return Nn(e,i)}function a0(e,t){if(!_s(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const a in t)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=_n(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Yn(this,"shape",i),i}});return Nn(e,o)}function l0(e,t){if(!_s(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=_n(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Yn(this,"shape",r),r}});return Nn(e,n)}function c0(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=_n(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Yn(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Nn(e,n)}function u0(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const a=_n(t._zod.def,{get shape(){const l=t._zod.def.shape,u={...l};if(n)for(const d in n){if(!(d in l))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(u[d]=e?new e({type:"optional",innerType:l[d]}):l[d])}else for(const d in l)u[d]=e?new e({type:"optional",innerType:l[d]}):l[d];return Yn(this,"shape",u),u},checks:[]});return Nn(t,a)}function d0(e,t,n){const r=_n(t._zod.def,{get shape(){const o=t._zod.def.shape,i={...o};if(n)for(const a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new e({type:"nonoptional",innerType:o[a]}))}else for(const a in o)i[a]=new e({type:"nonoptional",innerType:o[a]});return Yn(this,"shape",i),i}});return Nn(t,r)}function ms(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function f0(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function hs(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Ir(e){return typeof e=="string"?e:e?.message}function on(e,t,n){const r=e.message?e.message:Ir(e.inst?._zod.def?.error?.(e))??Ir(t?.error?.(e))??Ir(n.customError?.(e))??Ir(n.localeError?.(e))??"Invalid input",{inst:o,continue:i,input:a,...l}=e;return l.path??(l.path=[]),l.message=r,t?.reportInput&&(l.input=a),l}function kl(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function or(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const vf=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ra,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},yf=O("$ZodError",vf),wf=O("$ZodError",vf,{Parent:Error});function p0(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function m0(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(l=>r({issues:l},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{const l=[...i,...a.path];if(l.length===0)n._errors.push(t(a));else{let u=n,d=0;for(;d<l.length;){const f=l[d];d===l.length-1?(u[f]=u[f]||{_errors:[]},u[f]._errors.push(t(a))):u[f]=u[f]||{_errors:[]},u=u[f],d++}}}};return r(e),n}const Sl=e=>(t,n,r,o)=>{const i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new bs;if(a.issues.length){const l=new(o?.Err??e)(a.issues.map(u=>on(u,i,rn())));throw xf(l,o?.callee),l}return a.value},_l=e=>async(t,n,r,o)=>{const i=r?{...r,async:!0}:{async:!0};let a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const l=new(o?.Err??e)(a.issues.map(u=>on(u,i,rn())));throw xf(l,o?.callee),l}return a.value},Qo=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new bs;return i.issues.length?{success:!1,error:new(e??yf)(i.issues.map(a=>on(a,o,rn())))}:{success:!0,data:i.value}},h0=Qo(wf),ei=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>on(a,o,rn())))}:{success:!0,data:i.value}},g0=ei(wf),x0=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Sl(e)(t,n,o)},b0=e=>(t,n,r)=>Sl(e)(t,n,r),v0=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return _l(e)(t,n,o)},y0=e=>async(t,n,r)=>_l(e)(t,n,r),w0=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Qo(e)(t,n,o)},j0=e=>(t,n,r)=>Qo(e)(t,n,r),k0=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ei(e)(t,n,o)},S0=e=>async(t,n,r)=>ei(e)(t,n,r),_0=/^[cC][0-9a-z]{6,}$/,N0=/^[0-9a-z]+$/,C0=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,T0=/^[0-9a-vA-V]{20}$/,E0=/^[A-Za-z0-9]{27}$/,R0=/^[a-zA-Z0-9_-]{21}$/,I0=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,P0=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Vc=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,M0=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,A0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function O0(){return new RegExp(A0,"u")}const z0=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,L0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,$0=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,D0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,F0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jf=/^[A-Za-z0-9_-]*$/,U0=/^https?$/,B0=/^\+[1-9]\d{6,14}$/,kf="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",q0=new RegExp(`^${kf}$`);function Sf(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function H0(e){return new RegExp(`^${Sf(e)}$`)}function V0(e){const t=Sf({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${kf}T(?:${r})$`)}const W0=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Z0=/^-?\d+$/,_f=/^-?\d+(?:\.\d+)?$/,K0=/^(?:true|false)$/i,G0=/^null$/i,J0=/^[^A-Z]*$/,Y0=/^[^a-z]*$/,ct=O("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Nf={number:"number",bigint:"bigint",object:"date"},Cf=O("$ZodCheckLessThan",(e,t)=>{ct.init(e,t);const n=Nf[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Tf=O("$ZodCheckGreaterThan",(e,t)=>{ct.init(e,t);const n=Nf[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),X0=O("$ZodCheckMultipleOf",(e,t)=>{ct.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Qx(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Q0=O("$ZodCheckNumberFormat",(e,t)=>{ct.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=r0[t.format];e._zod.onattach.push(a=>{const l=a._zod.bag;l.format=t.format,l.minimum=o,l.maximum=i,n&&(l.pattern=Z0)}),e._zod.check=a=>{const l=a.value;if(n){if(!Number.isInteger(l)){a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:l,inst:e});return}if(!Number.isSafeInteger(l)){l>0?a.issues.push({input:l,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:l,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}l<o&&a.issues.push({origin:"number",input:l,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),l>i&&a.issues.push({origin:"number",input:l,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),e1=O("$ZodCheckMaxLength",(e,t)=>{var n;ct.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!wl(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const a=kl(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),t1=O("$ZodCheckMinLength",(e,t)=>{var n;ct.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!wl(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const a=kl(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),n1=O("$ZodCheckLengthEquals",(e,t)=>{var n;ct.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!wl(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,i=o.length;if(i===t.length)return;const a=kl(o),l=i>t.length;r.issues.push({origin:a,...l?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ti=O("$ZodCheckStringFormat",(e,t)=>{var n,r;ct.init(e,t),e._zod.onattach.push(o=>{const i=o._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),s1=O("$ZodCheckRegex",(e,t)=>{ti.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),r1=O("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=J0),ti.init(e,t)}),o1=O("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Y0),ti.init(e,t)}),i1=O("$ZodCheckIncludes",(e,t)=>{ct.init(e,t);const n=Ns(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),a1=O("$ZodCheckStartsWith",(e,t)=>{ct.init(e,t);const n=new RegExp(`^${Ns(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),l1=O("$ZodCheckEndsWith",(e,t)=>{ct.init(e,t);const n=new RegExp(`.*${Ns(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),c1=O("$ZodCheckOverwrite",(e,t)=>{ct.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class u1{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
3
- `).filter(a=>a),o=Math.min(...r.map(a=>a.length-a.trimStart().length)),i=r.map(a=>a.slice(o)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,o.join(`
4
- `))}}const d1={major:4,minor:4,patch:3},Oe=O("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=d1;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const i of o._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,l,u)=>{let d=ms(a),f;for(const p of l){if(p._zod.def.when){if(f0(a)||!p._zod.def.when(a))continue}else if(d)continue;const m=a.issues.length,h=p._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new bs;if(f||h instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await h,a.issues.length!==m&&(d||(d=ms(a,m)))});else{if(a.issues.length===m)continue;d||(d=ms(a,m))}}return f?f.then(()=>a):a},i=(a,l,u)=>{if(ms(a))return a.aborted=!0,a;const d=o(l,r,u);if(d instanceof Promise){if(u.async===!1)throw new bs;return d.then(f=>e._zod.parse(f,u))}return e._zod.parse(d,u)};e._zod.run=(a,l)=>{if(l.skipChecks)return e._zod.parse(a,l);if(l.direction==="backward"){const d=e._zod.parse({value:a.value,issues:[]},{...l,skipChecks:!0});return d instanceof Promise?d.then(f=>i(f,a,l)):i(d,a,l)}const u=e._zod.parse(a,l);if(u instanceof Promise){if(l.async===!1)throw new bs;return u.then(d=>o(d,r,l))}return o(u,r,l)}}Ee(e,"~standard",()=>({validate:o=>{try{const i=h0(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return g0(e,o).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),Nl=O("$ZodString",(e,t)=>{Oe.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??W0(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Le=O("$ZodStringFormat",(e,t)=>{ti.init(e,t),Nl.init(e,t)}),f1=O("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=P0),Le.init(e,t)}),p1=O("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Vc(r))}else t.pattern??(t.pattern=Vc());Le.init(e,t)}),m1=O("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=M0),Le.init(e,t)}),h1=O("$ZodURL",(e,t)=>{Le.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===U0.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),g1=O("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=O0()),Le.init(e,t)}),x1=O("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=R0),Le.init(e,t)}),b1=O("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=_0),Le.init(e,t)}),v1=O("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=N0),Le.init(e,t)}),y1=O("$ZodULID",(e,t)=>{t.pattern??(t.pattern=C0),Le.init(e,t)}),w1=O("$ZodXID",(e,t)=>{t.pattern??(t.pattern=T0),Le.init(e,t)}),j1=O("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=E0),Le.init(e,t)}),k1=O("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=V0(t)),Le.init(e,t)}),S1=O("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=q0),Le.init(e,t)}),_1=O("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=H0(t)),Le.init(e,t)}),N1=O("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=I0),Le.init(e,t)}),C1=O("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=z0),Le.init(e,t),e._zod.bag.format="ipv4"}),T1=O("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=L0),Le.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),E1=O("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=$0),Le.init(e,t)}),R1=O("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=D0),Le.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,i]=r;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ef(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const I1=O("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=F0),Le.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ef(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function P1(e){if(!jf.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ef(n)}const M1=O("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=jf),Le.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{P1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),A1=O("$ZodE164",(e,t)=>{t.pattern??(t.pattern=B0),Le.init(e,t)});function O1(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const z1=O("$ZodJWT",(e,t)=>{Le.init(e,t),e._zod.check=n=>{O1(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Rf=O("$ZodNumber",(e,t)=>{Oe.init(e,t),e._zod.pattern=e._zod.bag.pattern??_f,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),L1=O("$ZodNumberFormat",(e,t)=>{Q0.init(e,t),Rf.init(e,t)}),$1=O("$ZodBoolean",(e,t)=>{Oe.init(e,t),e._zod.pattern=K0,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),D1=O("$ZodNull",(e,t)=>{Oe.init(e,t),e._zod.pattern=G0,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),F1=O("$ZodUnknown",(e,t)=>{Oe.init(e,t),e._zod.parse=n=>n}),U1=O("$ZodNever",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Wc(e,t,n){e.issues.length&&t.issues.push(...hs(n,e.issues)),t.value[n]=e.value}const B1=O("$ZodArray",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let a=0;a<o.length;a++){const l=o[a],u=t.element._zod.run({value:l,issues:[]},r);u instanceof Promise?i.push(u.then(d=>Wc(d,n,a))):Wc(u,n,a)}return i.length?Promise.all(i).then(()=>n):n}});function bo(e,t,n,r,o,i){const a=n in r;if(e.issues.length){if(o&&i&&!a)return;t.issues.push(...hs(n,e.issues))}if(!a&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?a&&(t.value[n]=void 0):t.value[n]=e.value}function If(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=s0(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Pf(e,t,n,r,o,i){const a=[],l=o.keySet,u=o.catchall._zod,d=u.def.type,f=u.optin==="optional",p=u.optout==="optional";for(const m in t){if(m==="__proto__"||l.has(m))continue;if(d==="never"){a.push(m);continue}const h=u.run({value:t[m],issues:[]},r);h instanceof Promise?e.push(h.then(g=>bo(g,n,m,t,f,p))):bo(h,n,m,t,f,p)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const q1=O("$ZodObject",(e,t)=>{if(Oe.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const l=t.shape;Object.defineProperty(t,"shape",{get:()=>{const u={...l};return Object.defineProperty(t,"shape",{value:u}),u}})}const r=Xo(()=>If(t));Ee(e._zod,"propValues",()=>{const l=t.shape,u={};for(const d in l){const f=l[d]._zod;if(f.values){u[d]??(u[d]=new Set);for(const p of f.values)u[d].add(p)}}return u});const o=rr,i=t.catchall;let a;e._zod.parse=(l,u)=>{a??(a=r.value);const d=l.value;if(!o(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value={};const f=[],p=a.shape;for(const m of a.keys){const h=p[m],g=h._zod.optin==="optional",y=h._zod.optout==="optional",b=h._zod.run({value:d[m],issues:[]},u);b instanceof Promise?f.push(b.then(w=>bo(w,l,m,d,g,y))):bo(b,l,m,d,g,y)}return i?Pf(f,d,l,u,r.value,e):f.length?Promise.all(f).then(()=>l):l}}),H1=O("$ZodObjectJIT",(e,t)=>{q1.init(e,t);const n=e._zod.parse,r=Xo(()=>If(t)),o=m=>{const h=new u1(["shape","payload","ctx"]),g=r.value,y=j=>{const k=Hc(j);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};h.write("const input = payload.value;");const b=Object.create(null);let w=0;for(const j of g.keys)b[j]=`key_${w++}`;h.write("const newResult = {};");for(const j of g.keys){const k=b[j],S=Hc(j),_=m[j],C=_?._zod?.optin==="optional",M=_?._zod?.optout==="optional";h.write(`const ${k} = ${y(j)};`),C&&M?h.write(`
5
- if (${k}.issues.length) {
6
- if (${S} in input) {
7
- payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
8
- ...iss,
9
- path: iss.path ? [${S}, ...iss.path] : [${S}]
10
- })));
11
- }
12
- }
13
-
14
- if (${k}.value === undefined) {
15
- if (${S} in input) {
16
- newResult[${S}] = undefined;
17
- }
18
- } else {
19
- newResult[${S}] = ${k}.value;
20
- }
21
-
22
- `):C?h.write(`
23
- if (${k}.issues.length) {
24
- payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
25
- ...iss,
26
- path: iss.path ? [${S}, ...iss.path] : [${S}]
27
- })));
28
- }
29
-
30
- if (${k}.value === undefined) {
31
- if (${S} in input) {
32
- newResult[${S}] = undefined;
33
- }
34
- } else {
35
- newResult[${S}] = ${k}.value;
36
- }
37
-
38
- `):h.write(`
39
- const ${k}_present = ${S} in input;
40
- if (${k}.issues.length) {
41
- payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
42
- ...iss,
43
- path: iss.path ? [${S}, ...iss.path] : [${S}]
44
- })));
45
- }
46
- if (!${k}_present && !${k}.issues.length) {
47
- payload.issues.push({
48
- code: "invalid_type",
49
- expected: "nonoptional",
50
- input: undefined,
51
- path: [${S}]
52
- });
53
- }
54
-
55
- if (${k}_present) {
56
- if (${k}.value === undefined) {
57
- newResult[${S}] = undefined;
58
- } else {
59
- newResult[${S}] = ${k}.value;
60
- }
61
- }
62
-
63
- `)}h.write("payload.value = newResult;"),h.write("return payload;");const v=h.compile();return(j,k)=>v(m,j,k)};let i;const a=rr,l=!yl.jitless,d=l&&t0.value,f=t.catchall;let p;e._zod.parse=(m,h)=>{p??(p=r.value);const g=m.value;return a(g)?l&&d&&h?.async===!1&&h.jitless!==!0?(i||(i=o(t.shape)),m=i(m,h),f?Pf([],g,m,h,p,e):m):n(m,h):(m.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),m)}});function Zc(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!ms(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(a=>on(a,r,rn())))}),t)}const Mf=O("$ZodUnion",(e,t)=>{Oe.init(e,t),Ee(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Ee(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Ee(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Ee(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>jl(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const a=[];for(const l of t.options){const u=l._zod.run({value:r.value,issues:[]},o);if(u instanceof Promise)a.push(u),i=!0;else{if(u.issues.length===0)return u;a.push(u)}}return i?Promise.all(a).then(l=>Zc(l,r,e,o)):Zc(a,r,e,o)}}),V1=O("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Mf.init(e,t);const n=e._zod.parse;Ee(e._zod,"propValues",()=>{const o={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[l,u]of Object.entries(a)){o[l]||(o[l]=new Set);for(const d of u)o[l].add(d)}}return o});const r=Xo(()=>{const o=t.options,i=new Map;for(const a of o){const l=a._zod.propValues?.[t.discriminator];if(!l||l.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const u of l){if(i.has(u))throw new Error(`Duplicate discriminator value "${String(u)}"`);i.set(u,a)}}return i});e._zod.parse=(o,i)=>{const a=o.value;if(!rr(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const l=r.value.get(a?.[t.discriminator]);return l?l._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:a,path:[t.discriminator],inst:e}),o)}}),W1=O("$ZodIntersection",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),a=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([u,d])=>Kc(n,u,d)):Kc(n,i,a)}});function Ia(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(_s(e)&&_s(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};for(const i of r){const a=Ia(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};o[i]=a.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],a=Ia(o,i);if(!a.valid)return{valid:!1,mergeErrorPath:[r,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Kc(e,t,n){const r=new Map;let o;for(const l of t.issues)if(l.code==="unrecognized_keys"){o??(o=l);for(const u of l.keys)r.has(u)||r.set(u,{}),r.get(u).l=!0}else e.issues.push(l);for(const l of n.issues)if(l.code==="unrecognized_keys")for(const u of l.keys)r.has(u)||r.set(u,{}),r.get(u).r=!0;else e.issues.push(l);const i=[...r].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(i.length&&o&&e.issues.push({...o,keys:i}),ms(e))return e;const a=Ia(t.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}const Z1=O("$ZodRecord",(e,t)=>{Oe.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!_s(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const i=[],a=t.keyType._zod.values;if(a){n.value={};const l=new Set;for(const d of a)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){l.add(typeof d=="number"?d.toString():d);const f=t.keyType._zod.run({value:d,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(h=>on(h,r,rn())),input:d,path:[d],inst:e});continue}const p=f.value,m=t.valueType._zod.run({value:o[d],issues:[]},r);m instanceof Promise?i.push(m.then(h=>{h.issues.length&&n.issues.push(...hs(d,h.issues)),n.value[p]=h.value})):(m.issues.length&&n.issues.push(...hs(d,m.issues)),n.value[p]=m.value)}let u;for(const d in o)l.has(d)||(u=u??[],u.push(d));u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u})}else{n.value={};for(const l of Reflect.ownKeys(o)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&_f.test(l)&&u.issues.length){const p=t.keyType._zod.run({value:Number(l),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){t.mode==="loose"?n.value[l]=o[l]:n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>on(p,r,rn())),input:l,path:[l],inst:e});continue}const f=t.valueType._zod.run({value:o[l],issues:[]},r);f instanceof Promise?i.push(f.then(p=>{p.issues.length&&n.issues.push(...hs(l,p.issues)),n.value[u.value]=p.value})):(f.issues.length&&n.issues.push(...hs(l,f.issues)),n.value[u.value]=f.value)}}return i.length?Promise.all(i).then(()=>n):n}}),K1=O("$ZodEnum",(e,t)=>{Oe.init(e,t);const n=gf(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>n0.has(typeof o)).map(o=>typeof o=="string"?Ns(o):o.toString()).join("|")})$`),e._zod.parse=(o,i)=>{const a=o.value;return r.has(a)||o.issues.push({code:"invalid_value",values:n,input:a,inst:e}),o}}),G1=O("$ZodLiteral",(e,t)=>{if(Oe.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ns(r):r?Ns(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),J1=O("$ZodTransform",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new hf(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(a=>(n.value=a,n.fallback=!0,n));if(o instanceof Promise)throw new bs;return n.value=o,n.fallback=!0,n}});function Gc(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Af=O("$ZodOptional",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Ee(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${jl(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(a=>Gc(a,o)):Gc(i,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Y1=O("$ZodExactOptional",(e,t)=>{Af.init(e,t),Ee(e._zod,"values",()=>t.innerType._zod.values),Ee(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),X1=O("$ZodNullable",(e,t)=>{Oe.init(e,t),Ee(e._zod,"optin",()=>t.innerType._zod.optin),Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${jl(n.source)}|null)$`):void 0}),Ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Q1=O("$ZodDefault",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Jc(i,t)):Jc(o,t)}});function Jc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const eb=O("$ZodPrefault",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),tb=O("$ZodNonOptional",(e,t)=>{Oe.init(e,t),Ee(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Yc(i,e)):Yc(o,e)}});function Yc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const nb=O("$ZodCatch",(e,t)=>{Oe.init(e,t),e._zod.optin="optional",Ee(e._zod,"optout",()=>t.innerType._zod.optout),Ee(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(a=>on(a,r,rn()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(i=>on(i,r,rn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),sb=O("$ZodPipe",(e,t)=>{Oe.init(e,t),Ee(e._zod,"values",()=>t.in._zod.values),Ee(e._zod,"optin",()=>t.in._zod.optin),Ee(e._zod,"optout",()=>t.out._zod.optout),Ee(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(a=>Pr(a,t.in,r)):Pr(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Pr(i,t.out,r)):Pr(o,t.out,r)}});function Pr(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const rb=O("$ZodReadonly",(e,t)=>{Oe.init(e,t),Ee(e._zod,"propValues",()=>t.innerType._zod.propValues),Ee(e._zod,"values",()=>t.innerType._zod.values),Ee(e._zod,"optin",()=>t.innerType?._zod?.optin),Ee(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Xc):Xc(o)}});function Xc(e){return e.value=Object.freeze(e.value),e}const ob=O("$ZodLazy",(e,t)=>{Oe.init(e,t),Ee(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Ee(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),Ee(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),Ee(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),Ee(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),ib=O("$ZodCustom",(e,t)=>{ct.init(e,t),Oe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Qc(i,n,r,e));Qc(o,n,r,e)}});function Qc(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(or(o))}}var eu;class ab{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function lb(){return new ab}(eu=globalThis).__zod_globalRegistry??(eu.__zod_globalRegistry=lb());const Ys=globalThis.__zod_globalRegistry;function cb(e,t){return new e({type:"string",...oe(t)})}function ub(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...oe(t)})}function tu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...oe(t)})}function db(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...oe(t)})}function fb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...oe(t)})}function pb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...oe(t)})}function mb(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...oe(t)})}function hb(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...oe(t)})}function gb(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...oe(t)})}function xb(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...oe(t)})}function bb(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...oe(t)})}function vb(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...oe(t)})}function yb(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...oe(t)})}function wb(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...oe(t)})}function jb(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...oe(t)})}function kb(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...oe(t)})}function Sb(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...oe(t)})}function _b(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...oe(t)})}function Nb(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...oe(t)})}function Cb(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...oe(t)})}function Tb(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...oe(t)})}function Eb(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...oe(t)})}function Rb(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...oe(t)})}function Ib(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...oe(t)})}function Pb(e,t){return new e({type:"string",format:"date",check:"string_format",...oe(t)})}function Mb(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...oe(t)})}function Ab(e,t){return new e({type:"string",format:"duration",check:"string_format",...oe(t)})}function Ob(e,t){return new e({type:"number",checks:[],...oe(t)})}function zb(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...oe(t)})}function Lb(e,t){return new e({type:"boolean",...oe(t)})}function $b(e,t){return new e({type:"null",...oe(t)})}function Db(e){return new e({type:"unknown"})}function Fb(e,t){return new e({type:"never",...oe(t)})}function nu(e,t){return new Cf({check:"less_than",...oe(t),value:e,inclusive:!1})}function Fi(e,t){return new Cf({check:"less_than",...oe(t),value:e,inclusive:!0})}function su(e,t){return new Tf({check:"greater_than",...oe(t),value:e,inclusive:!1})}function Ui(e,t){return new Tf({check:"greater_than",...oe(t),value:e,inclusive:!0})}function ru(e,t){return new X0({check:"multiple_of",...oe(t),value:e})}function Of(e,t){return new e1({check:"max_length",...oe(t),maximum:e})}function vo(e,t){return new t1({check:"min_length",...oe(t),minimum:e})}function zf(e,t){return new n1({check:"length_equals",...oe(t),length:e})}function Ub(e,t){return new s1({check:"string_format",format:"regex",...oe(t),pattern:e})}function Bb(e){return new r1({check:"string_format",format:"lowercase",...oe(e)})}function qb(e){return new o1({check:"string_format",format:"uppercase",...oe(e)})}function Hb(e,t){return new i1({check:"string_format",format:"includes",...oe(t),includes:e})}function Vb(e,t){return new a1({check:"string_format",format:"starts_with",...oe(t),prefix:e})}function Wb(e,t){return new l1({check:"string_format",format:"ends_with",...oe(t),suffix:e})}function zs(e){return new c1({check:"overwrite",tx:e})}function Zb(e){return zs(t=>t.normalize(e))}function Kb(){return zs(e=>e.trim())}function Gb(){return zs(e=>e.toLowerCase())}function Jb(){return zs(e=>e.toUpperCase())}function Yb(){return zs(e=>e0(e))}function Xb(e,t,n){return new e({type:"array",element:t,...oe(n)})}function Qb(e,t,n){return new e({type:"custom",check:"custom",fn:t,...oe(n)})}function ev(e,t){const n=tv(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(or(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(or(i))}},e(r.value,r)),t);return n}function tv(e,t){const n=new ct({check:"custom",...oe(t)});return n._zod.check=e,n}function Lf(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ys,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function Ve(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a);const l=e._zod.toJSONSchema?.();if(l)a.schema=l;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,f);else{const m=a.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,m,f)}const p=e._zod.parent;p&&(a.ref||(a.ref=p),Ve(p,t,f),t.seen.get(p).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),t.io==="input"&&ot(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function $f(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const a of e.seen.entries()){const l=e.metadataRegistry.get(a[0])?.id;if(l){const u=r.get(l);if(u&&u!==a[0])throw new Error(`Duplicate schema id "${l}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(l,a[0])}}const o=a=>{const l=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(a[0])?.id,m=e.external.uri??(g=>g);if(p)return{ref:m(p)};const h=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=h,{defId:h,ref:`${m("__shared")}#/${l}/${h}`}}if(a[1]===n)return{ref:"#"};const d=`#/${l}/`,f=a[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:d+f}},i=a=>{if(a[1].schema.$ref)return;const l=a[1],{ref:u,defId:d}=o(a);l.def={...l.schema},d&&(l.defId=d);const f=l.schema;for(const p in f)delete f[p];f.$ref=u};if(e.cycles==="throw")for(const a of e.seen.entries()){const l=a[1];if(l.cycle)throw new Error(`Cycle detected: #/${l.cycle?.join("/")}/<root>
64
-
65
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const a of e.seen.entries()){const l=a[1];if(t===a[0]){i(a);continue}if(e.external){const d=e.external.registry.get(a[0])?.id;if(t!==a[0]&&d){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(l.cycle){i(a);continue}if(l.count>1&&e.reused==="ref"){i(a);continue}}}function Df(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=l=>{const u=e.seen.get(l);if(u.ref===null)return;const d=u.def??u.schema,f={...d},p=u.ref;if(u.ref=null,p){r(p);const h=e.seen.get(p),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(g)):Object.assign(d,g),Object.assign(d,f),l._zod.parent===p)for(const b in d)b==="$ref"||b==="allOf"||b in f||delete d[b];if(g.$ref&&h.def)for(const b in d)b==="$ref"||b==="allOf"||b in h.def&&JSON.stringify(d[b])===JSON.stringify(h.def[b])&&delete d[b]}const m=l._zod.parent;if(m&&m!==p){r(m);const h=e.seen.get(m);if(h?.schema.$ref&&(d.$ref=h.schema.$ref,h.def))for(const g in d)g==="$ref"||g==="allOf"||g in h.def&&JSON.stringify(d[g])===JSON.stringify(h.def[g])&&delete d[g]}e.override({zodSchema:l,jsonSchema:d,path:u.path??[]})};for(const l of[...e.seen.entries()].reverse())r(l[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const l=e.external.registry.get(t)?.id;if(!l)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(l)}Object.assign(o,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const a=e.external?.defs??{};for(const l of e.seen.entries()){const u=l[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,a[u.defId]=u.def)}e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?o.$defs=a:o.definitions=a);try{const l=JSON.parse(JSON.stringify(o));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:yo(t,"input",e.processors),output:yo(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function ot(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ot(r.element,n);if(r.type==="set")return ot(r.valueType,n);if(r.type==="lazy")return ot(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ot(r.innerType,n);if(r.type==="intersection")return ot(r.left,n)||ot(r.right,n);if(r.type==="record"||r.type==="map")return ot(r.keyType,n)||ot(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ot(r.in,n)||ot(r.out,n);if(r.type==="object"){for(const o in r.shape)if(ot(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(ot(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(ot(o,n))return!0;return!!(r.rest&&ot(r.rest,n))}return!1}const nv=(e,t={})=>n=>{const r=Lf({...n,processors:t});return Ve(e,r),$f(r,e),Df(r,e)},yo=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},a=Lf({...o??{},target:i,io:t,processors:n});return Ve(e,a),$f(a,e),Df(a,e)},sv={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},rv=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:a,format:l,patterns:u,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(o.minLength=i),typeof a=="number"&&(o.maxLength=a),l&&(o.format=sv[l]??l,o.format===""&&delete o.format,l==="time"&&delete o.format),d&&(o.contentEncoding=d),u&&u.size>0){const f=[...u];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},ov=(e,t,n,r)=>{const o=n,{minimum:i,maximum:a,format:l,multipleOf:u,exclusiveMaximum:d,exclusiveMinimum:f}=e._zod.bag;typeof l=="string"&&l.includes("int")?o.type="integer":o.type="number";const p=typeof f=="number"&&f>=(i??Number.NEGATIVE_INFINITY),m=typeof d=="number"&&d<=(a??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";p?h?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof i=="number"&&(o.minimum=i),m?h?(o.maximum=d,o.exclusiveMaximum=!0):o.exclusiveMaximum=d:typeof a=="number"&&(o.maximum=a),typeof u=="number"&&(o.multipleOf=u)},iv=(e,t,n,r)=>{n.type="boolean"},av=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},lv=(e,t,n,r)=>{n.not={}},cv=(e,t,n,r)=>{},uv=(e,t,n,r)=>{const o=e._zod.def,i=gf(o.entries);i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),n.enum=i},dv=(e,t,n,r)=>{const o=e._zod.def,i=[];for(const a of o.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else i.every(a=>typeof a=="number")&&(n.type="number"),i.every(a=>typeof a=="string")&&(n.type="string"),i.every(a=>typeof a=="boolean")&&(n.type="boolean"),i.every(a=>a===null)&&(n.type="null"),n.enum=i},fv=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},pv=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},mv=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:a,maximum:l}=e._zod.bag;typeof a=="number"&&(o.minItems=a),typeof l=="number"&&(o.maxItems=l),o.type="array",o.items=Ve(i.element,t,{...r,path:[...r.path,"items"]})},hv=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object",o.properties={};const a=i.shape;for(const d in a)o.properties[d]=Ve(a[d],t,{...r,path:[...r.path,"properties",d]});const l=new Set(Object.keys(a)),u=new Set([...l].filter(d=>{const f=i.shape[d]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));u.size>0&&(o.required=Array.from(u)),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=Ve(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},gv=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,a=o.options.map((l,u)=>Ve(l,t,{...r,path:[...r.path,i?"oneOf":"anyOf",u]}));i?n.oneOf=a:n.anyOf=a},xv=(e,t,n,r)=>{const o=e._zod.def,i=Ve(o.left,t,{...r,path:[...r.path,"allOf",0]}),a=Ve(o.right,t,{...r,path:[...r.path,"allOf",1]}),l=d=>"allOf"in d&&Object.keys(d).length===1,u=[...l(i)?i.allOf:[i],...l(a)?a.allOf:[a]];n.allOf=u},bv=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const a=i.keyType,u=a._zod.bag?.patterns;if(i.mode==="loose"&&u&&u.size>0){const f=Ve(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const p of u)o.patternProperties[p.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Ve(i.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Ve(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const d=a._zod.values;if(d){const f=[...d].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(o.required=f)}},vv=(e,t,n,r)=>{const o=e._zod.def,i=Ve(o.innerType,t,r),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},yv=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},wv=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},jv=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},kv=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let a;try{a=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=a},Sv=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?o.out:o.in:o.out;Ve(a,t,r);const l=t.seen.get(e);l.ref=a},_v=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Ff=(e,t,n,r)=>{const o=e._zod.def;Ve(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Nv=(e,t,n,r)=>{const o=e._zod.innerType;Ve(o,t,r);const i=t.seen.get(e);i.ref=o},Cv=O("ZodISODateTime",(e,t)=>{k1.init(e,t),$e.init(e,t)});function Tv(e){return Ib(Cv,e)}const Ev=O("ZodISODate",(e,t)=>{S1.init(e,t),$e.init(e,t)});function Rv(e){return Pb(Ev,e)}const Iv=O("ZodISOTime",(e,t)=>{_1.init(e,t),$e.init(e,t)});function Pv(e){return Mb(Iv,e)}const Mv=O("ZodISODuration",(e,t)=>{N1.init(e,t),$e.init(e,t)});function Av(e){return Ab(Mv,e)}const Ov=(e,t)=>{yf.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>m0(e,n)},flatten:{value:n=>p0(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ra,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ra,2)}},isEmpty:{get(){return e.issues.length===0}}})},St=O("ZodError",Ov,{Parent:Error}),zv=Sl(St),Lv=_l(St),$v=Qo(St),Dv=ei(St),Fv=x0(St),Uv=b0(St),Bv=v0(St),qv=y0(St),Hv=w0(St),Vv=j0(St),Wv=k0(St),Zv=S0(St),ou=new WeakMap;function xr(e,t,n){const r=Object.getPrototypeOf(e);let o=ou.get(r);if(o||(o=new Set,ou.set(r,o)),!o.has(t)){o.add(t);for(const i in n){const a=n[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){const l=a.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l}),l},set(l){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:l})}})}}}const ze=O("ZodType",(e,t)=>(Oe.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:yo(e,"input"),output:yo(e,"output")}}),e.toJSONSchema=nv(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>zv(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>$v(e,n,r),e.parseAsync=async(n,r)=>Lv(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Dv(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Fv(e,n,r),e.decode=(n,r)=>Uv(e,n,r),e.encodeAsync=async(n,r)=>Bv(e,n,r),e.decodeAsync=async(n,r)=>qv(e,n,r),e.safeEncode=(n,r)=>Hv(e,n,r),e.safeDecode=(n,r)=>Vv(e,n,r),e.safeEncodeAsync=async(n,r)=>Wv(e,n,r),e.safeDecodeAsync=async(n,r)=>Zv(e,n,r),xr(e,"ZodType",{check(...n){const r=this.def;return this.clone(_n(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return Nn(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(B2(n,r))},superRefine(n,r){return this.check(q2(n,r))},overwrite(n){return this.check(zs(n))},optional(){return cu(this)},exactOptional(){return C2(this)},nullable(){return uu(this)},nullish(){return cu(uu(this))},nonoptional(n){return M2(this,n)},array(){return K(this)},or(n){return Ot([this,n])},and(n){return j2(this,n)},transform(n){return du(this,_2(n))},default(n){return R2(this,n)},prefault(n){return P2(this,n)},catch(n){return O2(this,n)},pipe(n){return du(this,n)},readonly(){return $2(this)},describe(n){const r=this.clone();return Ys.add(r,{description:n}),r},meta(...n){if(n.length===0)return Ys.get(this);const r=this.clone();return Ys.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return Ys.get(e)?.description},configurable:!0}),e)),Uf=O("_ZodString",(e,t)=>{Nl.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,o,i)=>rv(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,xr(e,"_ZodString",{regex(...r){return this.check(Ub(...r))},includes(...r){return this.check(Hb(...r))},startsWith(...r){return this.check(Vb(...r))},endsWith(...r){return this.check(Wb(...r))},min(...r){return this.check(vo(...r))},max(...r){return this.check(Of(...r))},length(...r){return this.check(zf(...r))},nonempty(...r){return this.check(vo(1,...r))},lowercase(r){return this.check(Bb(r))},uppercase(r){return this.check(qb(r))},trim(){return this.check(Kb())},normalize(...r){return this.check(Zb(...r))},toLowerCase(){return this.check(Gb())},toUpperCase(){return this.check(Jb())},slugify(){return this.check(Yb())}})}),Kv=O("ZodString",(e,t)=>{Nl.init(e,t),Uf.init(e,t),e.email=n=>e.check(ub(Gv,n)),e.url=n=>e.check(hb(Jv,n)),e.jwt=n=>e.check(Rb(d2,n)),e.emoji=n=>e.check(gb(Yv,n)),e.guid=n=>e.check(tu(iu,n)),e.uuid=n=>e.check(db(Mr,n)),e.uuidv4=n=>e.check(fb(Mr,n)),e.uuidv6=n=>e.check(pb(Mr,n)),e.uuidv7=n=>e.check(mb(Mr,n)),e.nanoid=n=>e.check(xb(Xv,n)),e.guid=n=>e.check(tu(iu,n)),e.cuid=n=>e.check(bb(Qv,n)),e.cuid2=n=>e.check(vb(e2,n)),e.ulid=n=>e.check(yb(t2,n)),e.base64=n=>e.check(Cb(l2,n)),e.base64url=n=>e.check(Tb(c2,n)),e.xid=n=>e.check(wb(n2,n)),e.ksuid=n=>e.check(jb(s2,n)),e.ipv4=n=>e.check(kb(r2,n)),e.ipv6=n=>e.check(Sb(o2,n)),e.cidrv4=n=>e.check(_b(i2,n)),e.cidrv6=n=>e.check(Nb(a2,n)),e.e164=n=>e.check(Eb(u2,n)),e.datetime=n=>e.check(Tv(n)),e.date=n=>e.check(Rv(n)),e.time=n=>e.check(Pv(n)),e.duration=n=>e.check(Av(n))});function x(e){return cb(Kv,e)}const $e=O("ZodStringFormat",(e,t)=>{Le.init(e,t),Uf.init(e,t)}),Gv=O("ZodEmail",(e,t)=>{m1.init(e,t),$e.init(e,t)}),iu=O("ZodGUID",(e,t)=>{f1.init(e,t),$e.init(e,t)}),Mr=O("ZodUUID",(e,t)=>{p1.init(e,t),$e.init(e,t)}),Jv=O("ZodURL",(e,t)=>{h1.init(e,t),$e.init(e,t)}),Yv=O("ZodEmoji",(e,t)=>{g1.init(e,t),$e.init(e,t)}),Xv=O("ZodNanoID",(e,t)=>{x1.init(e,t),$e.init(e,t)}),Qv=O("ZodCUID",(e,t)=>{b1.init(e,t),$e.init(e,t)}),e2=O("ZodCUID2",(e,t)=>{v1.init(e,t),$e.init(e,t)}),t2=O("ZodULID",(e,t)=>{y1.init(e,t),$e.init(e,t)}),n2=O("ZodXID",(e,t)=>{w1.init(e,t),$e.init(e,t)}),s2=O("ZodKSUID",(e,t)=>{j1.init(e,t),$e.init(e,t)}),r2=O("ZodIPv4",(e,t)=>{C1.init(e,t),$e.init(e,t)}),o2=O("ZodIPv6",(e,t)=>{T1.init(e,t),$e.init(e,t)}),i2=O("ZodCIDRv4",(e,t)=>{E1.init(e,t),$e.init(e,t)}),a2=O("ZodCIDRv6",(e,t)=>{R1.init(e,t),$e.init(e,t)}),l2=O("ZodBase64",(e,t)=>{I1.init(e,t),$e.init(e,t)}),c2=O("ZodBase64URL",(e,t)=>{M1.init(e,t),$e.init(e,t)}),u2=O("ZodE164",(e,t)=>{A1.init(e,t),$e.init(e,t)}),d2=O("ZodJWT",(e,t)=>{z1.init(e,t),$e.init(e,t)}),Bf=O("ZodNumber",(e,t)=>{Rf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,o,i)=>ov(e,r,o),xr(e,"ZodNumber",{gt(r,o){return this.check(su(r,o))},gte(r,o){return this.check(Ui(r,o))},min(r,o){return this.check(Ui(r,o))},lt(r,o){return this.check(nu(r,o))},lte(r,o){return this.check(Fi(r,o))},max(r,o){return this.check(Fi(r,o))},int(r){return this.check(au(r))},safe(r){return this.check(au(r))},positive(r){return this.check(su(0,r))},nonnegative(r){return this.check(Ui(0,r))},negative(r){return this.check(nu(0,r))},nonpositive(r){return this.check(Fi(0,r))},multipleOf(r,o){return this.check(ru(r,o))},step(r,o){return this.check(ru(r,o))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function R(e){return Ob(Bf,e)}const f2=O("ZodNumberFormat",(e,t)=>{L1.init(e,t),Bf.init(e,t)});function au(e){return zb(f2,e)}const p2=O("ZodBoolean",(e,t)=>{$1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>iv(e,n,r)});function Re(e){return Lb(p2,e)}const m2=O("ZodNull",(e,t)=>{D1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>av(e,n,r)});function wo(e){return $b(m2,e)}const h2=O("ZodUnknown",(e,t)=>{F1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cv()});function qn(){return Db(h2)}const g2=O("ZodNever",(e,t)=>{U1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lv(e,n,r)});function x2(e){return Fb(g2,e)}const b2=O("ZodArray",(e,t)=>{B1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mv(e,n,r,o),e.element=t.element,xr(e,"ZodArray",{min(n,r){return this.check(vo(n,r))},nonempty(n){return this.check(vo(1,n))},max(n,r){return this.check(Of(n,r))},length(n,r){return this.check(zf(n,r))},unwrap(){return this.element}})});function K(e,t){return Xb(b2,e,t)}const v2=O("ZodObject",(e,t)=>{H1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hv(e,n,r,o),Ee(e,"shape",()=>t.shape),xr(e,"ZodObject",{keyof(){return pe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:qn()})},loose(){return this.clone({...this._zod.def,catchall:qn()})},strict(){return this.clone({...this._zod.def,catchall:x2()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return a0(this,n)},safeExtend(n){return l0(this,n)},merge(n){return c0(this,n)},pick(n){return o0(this,n)},omit(n){return i0(this,n)},partial(...n){return u0(Hf,this,n[0])},required(...n){return d0(Vf,this,n[0])}})});function E(e,t){const n={type:"object",shape:e??{},...oe(t)};return new v2(n)}const qf=O("ZodUnion",(e,t)=>{Mf.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gv(e,n,r,o),e.options=t.options});function Ot(e,t){return new qf({type:"union",options:e,...oe(t)})}const y2=O("ZodDiscriminatedUnion",(e,t)=>{qf.init(e,t),V1.init(e,t)});function Cn(e,t,n){return new y2({type:"union",options:t,discriminator:e,...oe(n)})}const w2=O("ZodIntersection",(e,t)=>{W1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xv(e,n,r,o)});function j2(e,t){return new w2({type:"intersection",left:e,right:t})}const lu=O("ZodRecord",(e,t)=>{Z1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bv(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function We(e,t,n){return!t||!t._zod?new lu({type:"record",keyType:x(),valueType:e,...oe(t)}):new lu({type:"record",keyType:e,valueType:t,...oe(n)})}const Pa=O("ZodEnum",(e,t)=>{K1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(r,o,i)=>uv(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const a of r)if(n.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Pa({...t,checks:[],...oe(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const a of r)if(n.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Pa({...t,checks:[],...oe(o),entries:i})}});function pe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Pa({type:"enum",entries:n,...oe(t)})}const k2=O("ZodLiteral",(e,t)=>{G1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dv(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function le(e,t){return new k2({type:"literal",values:Array.isArray(e)?e:[e],...oe(t)})}const S2=O("ZodTransform",(e,t)=>{J1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pv(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new hf(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(or(i,n.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=n.value),a.inst??(a.inst=e),n.issues.push(or(a))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function _2(e){return new S2({type:"transform",transform:e})}const Hf=O("ZodOptional",(e,t)=>{Af.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ff(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function cu(e){return new Hf({type:"optional",innerType:e})}const N2=O("ZodExactOptional",(e,t)=>{Y1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ff(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function C2(e){return new N2({type:"optional",innerType:e})}const T2=O("ZodNullable",(e,t)=>{X1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vv(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function uu(e){return new T2({type:"nullable",innerType:e})}const E2=O("ZodDefault",(e,t)=>{Q1.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wv(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function R2(e,t){return new E2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():bf(t)}})}const I2=O("ZodPrefault",(e,t)=>{eb.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jv(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function P2(e,t){return new I2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():bf(t)}})}const Vf=O("ZodNonOptional",(e,t)=>{tb.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yv(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function M2(e,t){return new Vf({type:"nonoptional",innerType:e,...oe(t)})}const A2=O("ZodCatch",(e,t)=>{nb.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kv(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function O2(e,t){return new A2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const z2=O("ZodPipe",(e,t)=>{sb.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sv(e,n,r,o),e.in=t.in,e.out=t.out});function du(e,t){return new z2({type:"pipe",in:e,out:t})}const L2=O("ZodReadonly",(e,t)=>{rb.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_v(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function $2(e){return new L2({type:"readonly",innerType:e})}const D2=O("ZodLazy",(e,t)=>{ob.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nv(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function F2(e){return new D2({type:"lazy",getter:e})}const U2=O("ZodCustom",(e,t)=>{ib.init(e,t),ze.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fv(e,n)});function B2(e,t={}){return Qb(U2,e,t)}function q2(e,t){return ev(e,t)}const Qe=F2(()=>Ot([x(),R(),Re(),wo(),K(Qe),We(x(),Qe)]));function Wf(e){return e===void 0||typeof e=="bigint"||typeof e=="function"?null:e}const Zf=E({index:R(),timestamp:R(),type:x(),data:Qe}),H2=E({chunks:K(Zf),truncated:Re().optional().default(!1)}),V2=pe(["request","response"]),W2=E({logId:R().int().positive(),part:V2,text:x(),offset:R().int().nonnegative(),limit:R().int().positive(),totalBytes:R().int().nonnegative(),textBytes:R().int().nonnegative(),nextOffset:R().int().nonnegative().nullable(),hasMore:Re(),contentMode:pe(["empty","partial","full"])}),ir=E({id:R(),timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:R().nullable(),responseText:x().nullable(),inputTokens:R().nullable(),outputTokens:R().nullable(),cacheCreationInputTokens:R().nullable(),cacheReadInputTokens:R().nullable(),elapsedMs:R().nullable(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),streaming:Re(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:We(x(),x()).optional(),headers:We(x(),x()).optional(),apiFormat:pe(["anthropic","openai","unknown"]).default("unknown"),isTest:Re().optional().default(!1),replayOfLogId:R().nullable().optional(),providerName:x().nullable().optional(),clientPort:R().nullable().optional(),clientPid:R().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:H2.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:R().int().nonnegative().nullable().optional(),responseTextBytes:R().int().nonnegative().nullable().optional(),bodyContentMode:pe(["full","compact","truncated"]).optional(),warnings:K(x()).optional(),error:x().nullable().optional()}),Cl=E({type:x(),ttl:x().optional(),scope:x().optional()}),Tl=E({type:le("text"),text:x(),cache_control:Cl.optional()}),Kf=E({type:le("thinking"),thinking:x(),signature:x().optional()}),Z2=E({type:le("think"),thinking:x(),signature:x().optional()}),K2=E({type:le("base64"),media_type:x(),data:x()}),Gf=E({type:le("image"),source:K2}),Jf=E({type:le("tool_use"),id:x(),name:x(),input:We(x(),Qe)}),G2=Cn("type",[Tl,Gf]),J2=E({type:le("tool_result"),tool_use_id:x().optional(),content:Ot([x(),K(G2)]),is_error:Re().optional()}),Y2=Cn("type",[Tl,Kf,Gf,Jf,J2]),X2=Ot([x(),K(Y2)]),Q2=E({role:pe(["user","assistant"]),content:X2}),ey=E({type:le("text"),text:x(),cache_control:Cl.optional()}),ty=E({type:x(),properties:We(x(),We(x(),Qe)).optional(),required:K(x()).optional(),additionalProperties:Re().optional(),$schema:x().optional()}),ny=E({name:x(),description:x().optional(),input_schema:ty.optional(),cache_control:Cl.optional()}),sy=Cn("type",[E({type:le("enabled"),budget_tokens:R()}),E({type:le("disabled")}),E({type:le("adaptive")})]),Yf=E({model:x(),messages:K(Q2),system:K(ey).optional(),tools:K(ny).optional(),max_tokens:R().optional(),temperature:R().optional(),stream:Re().optional(),thinking:sy.optional(),metadata:E({user_id:x().optional()}).optional()}),El=Cn("type",[Tl,Kf,Z2,Jf]),ry=E({input_tokens:R().nullable().optional(),output_tokens:R().nullable().optional(),cache_creation_input_tokens:R().nullable().optional(),cache_read_input_tokens:R().nullable().optional()}).passthrough(),Xf=E({id:x(),type:le("message"),model:x(),role:le("assistant"),content:K(El),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:ry}).passthrough(),oy=E({type:le("message_start"),message:E({id:x(),type:le("message"),model:x(),role:le("assistant"),content:K(El),stop_reason:wo(),stop_sequence:wo(),usage:E({input_tokens:R(),cache_creation_input_tokens:R().optional(),cache_read_input_tokens:R().optional()}).passthrough()})}),iy=E({type:le("content_block_start"),index:R(),content_block:El}),ay=Cn("type",[E({type:le("text_delta"),text:x()}),E({type:le("input_json_delta"),partial_json:x()}),E({type:le("thinking_delta"),thinking:x()}),E({type:le("signature_delta"),signature:x()})]),ly=E({type:le("content_block_delta"),index:R(),delta:ay}),cy=E({type:le("content_block_stop"),index:R()}),uy=E({type:le("message_delta"),delta:E({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:E({output_tokens:R(),input_tokens:R().optional(),cache_creation_input_tokens:R().optional(),cache_read_input_tokens:R().optional()}).passthrough()}),dy=E({type:le("message_stop")}),fy=E({type:le("ping")}),py=E({type:le("error"),error:E({type:x(),message:x()})}),my=Cn("type",[oy,iy,ly,cy,uy,dy,fy,py]),hy=Ot([x(),K(Cn("type",[E({type:le("text"),text:x()}),E({type:le("image_url"),image_url:E({url:x(),detail:x().optional()})})]))]),Qf=E({role:pe(["system","user","assistant","tool"]),content:hy,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),gy=E({name:x(),arguments:x()}),ep=E({index:R().optional(),id:x().optional(),type:le("function").optional(),function:E({name:x().optional(),arguments:x().optional()})});Qf.extend({content:Ot([x(),K(E({type:le("text"),text:x()}))]).optional(),function_call:gy.optional(),tool_calls:K(ep).optional()});const xy=E({type:le("function"),function:E({name:x(),description:x().optional(),parameters:We(x(),Qe)})}),tp=E({model:x(),messages:K(Qf),temperature:R().optional(),max_tokens:R().optional(),stream:Re().optional(),tools:K(xy).optional(),tool_choice:Ot([pe(["auto","none","required"]),E({type:le("auto")}),E({type:le("none")}),E({type:le("function"),function:E({name:x()})})]).optional(),user:x().optional()}),by=E({type:x(),name:x().optional(),description:x().optional(),parameters:Qe.optional(),function:E({name:x().optional(),description:x().optional(),parameters:Qe.optional()}).optional()}).passthrough(),np=E({model:x(),input:qn().optional(),instructions:Ot([x(),wo()]).optional(),stream:Re().optional(),tools:K(by).optional(),tool_choice:qn().optional(),max_output_tokens:R().optional(),temperature:R().optional(),user:x().optional(),metadata:We(x(),qn()).optional()}).passthrough(),sp=E({role:pe(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:E({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:K(E({index:R(),id:x().optional(),type:le("function").optional(),function:E({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),vy=E({index:R(),message:E({role:pe(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:E({name:x(),arguments:x()}).nullable().optional(),tool_calls:K(ep).optional()}).optional(),delta:sp.optional(),finish_reason:x().nullable()}),yy=E({id:x(),object:le("chat.completion"),created:R(),model:x(),choices:K(vy),usage:E({prompt_tokens:R().nullable().optional(),completion_tokens:R().nullable().optional(),total_tokens:R().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough(),wy=E({id:x(),object:le("chat.completion.chunk"),created:R(),model:x(),choices:K(E({index:R(),delta:sp,finish_reason:x().nullable().optional()})),usage:E({prompt_tokens:R().nullable().optional(),completion_tokens:R().nullable().optional(),total_tokens:R().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),jy=E({input_tokens:R().nullable().optional(),output_tokens:R().nullable().optional(),total_tokens:R().nullable().optional(),input_tokens_details:E({cached_tokens:R().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:E({reasoning_tokens:R().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),ky=E({type:x()}).passthrough(),jo=E({id:x(),object:le("response").optional(),created_at:R().optional(),status:x().nullable().optional(),model:x().optional(),output:K(ky).optional(),output_text:x().optional(),usage:jy.nullable().optional(),error:qn().optional()}).passthrough(),Sy=E({type:x()}).passthrough();function rp(e){try{const t=JSON.parse(e),n=yy.safeParse(t);return n.success?n.data:null}catch{return null}}function op(e){try{const t=JSON.parse(e),n=jo.safeParse(t);return n.success?n.data:null}catch{return null}}const _y=E({error:x()}),Ny=new Set(["POST","PUT","PATCH","DELETE"]);function ip(e){return typeof e!="string"||!e.startsWith("/")||e.startsWith("//")?e:Jo(e)}function ap(e){const t=e?.method?.toUpperCase();if(t===void 0||!Ny.has(t))return e;const n=new Headers(e?.headers);return n.has("x-agent-inspector-csrf")||n.set("x-agent-inspector-csrf","1"),{...e,headers:n}}async function Rl(e,t){const n=await e.json();return t.parse(n)}async function Il(e,t){try{const n=await e.json(),r=_y.safeParse(n);return r.success?r.data.error:t}catch{return t}}async function st(e,t,n,r){const o=await fetch(ip(e),ap(n));if(!o.ok){const i=r?.(o)??`Request failed with status ${o.status}`;throw new Error(await Il(o,i))}return Rl(o,t)}function Cy(e){return e<1e3?`${String(e)}ms`:`${String(Math.round(e/1e3))}s`}class ni extends Error{constructor(t){super(`Request timed out after ${Cy(t)}`),this.name="ApiTimeoutError"}}async function Hn(e,t,n){const r=new AbortController;let o=!1;const i=setTimeout(()=>{o=!0,r.abort()},t),a=n?.signal??void 0,l=()=>r.abort();a!==void 0&&(a.aborted?r.abort():a.addEventListener("abort",l,{once:!0}));try{return await fetch(ip(e),{...ap(n),signal:r.signal})}catch(u){throw o&&u instanceof DOMException&&u.name==="AbortError"?new ni(t):u}finally{clearTimeout(i),a?.removeEventListener("abort",l)}}async function He(e,t,n,r,o){const i=await Hn(e,n,r);if(!i.ok){const a=o?.(i)??`Request failed with status ${i.status}`;throw new Error(await Il(i,a))}return Rl(i,t)}const lp=E({input:R().int().nonnegative(),output:R().int().nonnegative(),cacheCreate:R().int().nonnegative(),cacheRead:R().int().nonnegative(),total:R().int().nonnegative()}),Ty=E({id:R().int().positive(),sessionLogNumber:R().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:pe(["anthropic","openai","unknown"]),method:x(),path:x(),status:R().nullable(),isStreaming:Re(),hasError:Re(),error:x().nullable(),latencyMs:R().nullable(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),tokens:E({input:R().nullable(),output:R().nullable(),cacheCreate:R().nullable(),cacheRead:R().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:R().nullable().optional(),clientProjectFolder:x().nullable().optional()}),cp=E({id:x(),status:pe(["active","failed","completed","empty"]),logCoverage:pe(["recent","history"]),source:pe(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:pe(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:R().int().nonnegative(),activeRequests:R().int().nonnegative(),completedRequests:R().int().nonnegative(),failedRequests:R().int().nonnegative(),queuedTasks:R().int().nonnegative(),runningTasks:R().int().nonnegative(),lastTaskError:x().nullable(),logCount:R().int().nonnegative(),errorCount:R().int().nonnegative(),models:K(x()),providers:K(x()),tokenUsage:lp,lastLogId:R().nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:R().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:R().int().positive(),latestLogs:K(Ty)}),br=pe(["created","running","completed","failed","cancelled"]),Pl=E({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Ey=pe(["run-created","session-started","request","session-finished","evidence-exported"]),Ry=pe(["info","success","warning","error"]),Iy=E({timestamp:x(),kind:Ey,severity:Ry,title:x(),details:x(),logId:R().int().positive().nullable(),status:R().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:R().nullable(),isStreaming:Re().nullable()}),Py=pe(["none","active","provider-timeout","provider-http-error","provider-auth-error","provider-rate-limit","network-or-container","streaming-mismatch","context-pressure","runtime-task-error","model-output-error","unknown-failure","no-session-data"]),up=E({outcome:pe(["success","failure","active","unknown"]),severity:pe(["none","low","medium","high"]),category:Py,summary:x(),evidenceLogIds:K(R().int().positive()),hints:K(x())}),Ml=E({status:pe(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),dp=Ml,Al=E({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:br,tags:K(x()),metadata:We(x(),Qe),evidence:Pl.nullable(),createdAt:x(),updatedAt:x()});E({runId:x().min(1).optional(),sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:br.optional(),tags:K(x()).optional(),metadata:We(x(),Qe).optional()}).optional();E({sessionId:x().min(1).optional(),groupId:x().min(1).nullable().optional(),title:x().min(1).optional(),task:x().nullable().optional(),project:x().nullable().optional(),agent:x().nullable().optional(),status:br.optional(),tags:K(x()).optional(),metadata:We(x(),Qe).optional()});E({includeHistory:Re().optional(),latestLogLimit:R().int().positive().max(50).optional()}).optional();E({run:Al,evidence:Pl,session:cp.nullable(),timeline:K(Iy),classification:up,jenkinsReport:Ml});const My=E({run:Al,classification:up,evidence:Pl.nullable(),jenkinsReport:Ml.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});E({failures:K(My),total:R().int().nonnegative(),limit:R().int().positive()});const Ol=pe(["created","running","completed","failed","cancelled"]),zl=pe(["evaluation","batch","manual"]),Ll=E({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),fp=E({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:br.nullable(),metadata:We(x(),Qe),addedAt:x(),updatedAt:x()}),$l=E({id:x(),title:x(),kind:zl,task:x().nullable(),project:x().nullable(),status:Ol,tags:K(x()),metadata:We(x(),Qe),evidence:Ll.nullable(),members:K(fp),createdAt:x(),updatedAt:x()});E({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:zl.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ol.optional(),tags:K(x()).optional(),metadata:We(x(),Qe).optional()}).optional();E({title:x().min(1).optional(),kind:zl.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ol.optional(),tags:K(x()).optional(),metadata:We(x(),Qe).optional()});E({memberId:x().min(1).optional(),sessionId:x().min(1),runId:x().min(1).nullable().optional(),label:x().min(1).nullable().optional(),agent:x().min(1).nullable().optional(),provider:x().min(1).nullable().optional(),model:x().min(1).nullable().optional(),status:br.nullable().optional(),metadata:We(x(),Qe).optional()});E({includeHistory:Re().optional(),latestLogLimit:R().int().positive().max(50).optional()}).optional();E({deleteEvidence:Re().optional()});const pp=E({groupId:x(),deleted:Re(),evidenceDeleted:Re(),evidencePath:x().nullable()}),mp=E({deleted:R().int().nonnegative(),groups:K(pp)}),hp=E({member:fp,run:Al.nullable(),session:cp.nullable()}),gp=E({memberCount:R().int().nonnegative(),sessionsWithData:R().int().nonnegative(),missingSessions:R().int().nonnegative(),requestCount:R().int().nonnegative(),errorCount:R().int().nonnegative(),tokenUsage:lp,models:K(x()),providers:K(x()),completedMembers:R().int().nonnegative(),failedMembers:R().int().nonnegative(),runningMembers:R().int().nonnegative()}),Ay=E({group:$l,evidence:Ll,members:K(hp).nullable(),markdown:x(),summary:gp.nullable(),report:dp.nullable()}),Oy=E({group:$l,evidence:Ll,members:K(hp),summary:gp,jenkinsReport:dp}),xp=E({groups:K($l)}),zy=E({sessionId:x(),imported:R().int().nonnegative(),skipped:R().int().nonnegative(),warnings:K(x()),logs:K(ir)}),ko=10,Ma=600,So=60,Aa=600,_o="time",Dl="simple",bp=pe(["time","full"]),Ly=pe(["simple","full"]),si=E({stripClaudeCodeBillingHeader:Re(),hasSeenOnboarding:Re().default(!1),slowResponseThresholdSeconds:R().int().min(0).max(Ma).default(ko),providerTestTimeoutSeconds:R().int().min(1).max(Aa).default(So),timeDisplayFormat:bp.default(_o),captureMode:Ly.default(Dl)}),ps="/api/config";async function $y(e){return st(e,si,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function Ar(e){return st(ps,si,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function Fl(){const e=Bt(ps,$y,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=lf(),n=e.data?.stripClaudeCodeBillingHeader??!1,r=e.data?.captureMode??Dl,o=e.data?.slowResponseThresholdSeconds??ko,i=e.data?.providerTestTimeoutSeconds??So,a=e.data?.timeDisplayFormat??_o,l=m=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??ko,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??So,timeDisplayFormat:e.data?.timeDisplayFormat??_o,captureMode:r,...m}),u=async m=>{await t(ps,Ar({stripClaudeCodeBillingHeader:m}),{optimisticData:l({stripClaudeCodeBillingHeader:m}),rollbackOnError:!0,revalidate:!1})},d=async m=>{await t(ps,Ar({slowResponseThresholdSeconds:m}),{optimisticData:l({slowResponseThresholdSeconds:m}),rollbackOnError:!0,revalidate:!1})},f=async m=>{await t(ps,Ar({timeDisplayFormat:m}),{optimisticData:l({timeDisplayFormat:m}),rollbackOnError:!0,revalidate:!1})},p=async m=>{await t(ps,Ar({providerTestTimeoutSeconds:m}),{optimisticData:l({providerTestTimeoutSeconds:m}),rollbackOnError:!0,revalidate:!1})};return{strip:n,captureMode:r,slowResponseThresholdSeconds:o,providerTestTimeoutSeconds:i,timeDisplayFormat:a,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:u,setSlowResponseThresholdSeconds:d,setProviderTestTimeoutSeconds:p,setTimeDisplayFormat:f}}const vp=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const Dy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Fy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const fu=e=>{const t=Fy(e);return t.charAt(0).toUpperCase()+t.slice(1)};var Uy={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const By=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};const qy=c.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:a,...l},u)=>c.createElement("svg",{ref:u,...Uy,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:vp("lucide",o),...!i&&!By(l)&&{"aria-hidden":"true"},...l},[...a.map(([d,f])=>c.createElement(d,f)),...Array.isArray(i)?i:[i]]));const H=(e,t)=>{const n=c.forwardRef(({className:r,...o},i)=>c.createElement(qy,{ref:i,iconNode:t,className:vp(`lucide-${Dy(fu(e))}`,`lucide-${e}`,r),...o}));return n.displayName=fu(e),n};const Hy=[["path",{d:"m15 16 2.536-7.328a1.02 1.02 1 0 1 1.928 0L22 16",key:"xik6mr"}],["path",{d:"M15.697 14h5.606",key:"1stdlc"}],["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}]],Vy=H("a-large-small",Hy);const Wy=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Zy=H("activity",Wy);const Ky=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],Gy=H("arrow-down-right",Ky);const Jy=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Yy=H("arrow-down",Jy);const Xy=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Qy=H("arrow-left",Xy);const ew=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],tw=H("arrow-up-right",ew);const nw=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],sw=H("arrow-up",nw);const rw=[["path",{d:"M4.5 3h15",key:"c7n0jr"}],["path",{d:"M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3",key:"m1uhx7"}],["path",{d:"M6 14h12",key:"4cwo0f"}]],Ul=H("beaker",rw);const ow=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],iw=H("bell",ow);const aw=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]],lw=H("blocks",aw);const cw=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],uw=H("brain-circuit",cw);const dw=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],yp=H("brain",dw);const fw=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],qe=H("check",fw);const pw=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],et=H("chevron-down",pw);const mw=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],hw=H("chevron-left",mw);const gw=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],bt=H("chevron-right",gw);const xw=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Bl=H("chevron-up",xw);const bw=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],vw=H("chevrons-down",bw);const yw=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],ww=H("chevrons-left",yw);const jw=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],kw=H("chevrons-right",jw);const Sw=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],_w=H("chevrons-up",Sw);const Nw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Cs=H("circle-alert",Nw);const Cw=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],vr=H("circle-check-big",Cw);const Tw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Oa=H("circle-check",Tw);const Ew=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Rw=H("circle-question-mark",Ew);const Iw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Pw=H("circle-stop",Iw);const Mw=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],wp=H("circle-x",Mw);const Aw=[["path",{d:"M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3Z",key:"1tn4o7"}],["path",{d:"m6.2 5.3 3.1 3.9",key:"iuk76l"}],["path",{d:"m12.4 3.4 3.1 4",key:"6hsd6n"}],["path",{d:"M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Z",key:"ltgou9"}]],Ow=H("clapperboard",Aw);const zw=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Lw=H("clock-3",zw);const $w=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],sn=H("clock",$w);const Dw=[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]],Fw=H("cloud-upload",Dw);const Uw=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],jp=H("code-xml",Uw);const Bw=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],qw=H("columns-2",Bw);const Hw=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],zt=H("copy",Hw);const Vw=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Ww=H("cpu",Vw);const Zw=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],yr=H("download",Zw);const Kw=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Gw=H("ellipsis",Kw);const Jw=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ql=H("external-link",Jw);const Yw=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Xw=H("eye-off",Yw);const Qw=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],kp=H("eye",Qw);const ej=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],tj=H("file-braces",ej);const nj=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],sj=H("file-diff",nj);const rj=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"11.5",cy:"14.5",r:"2.5",key:"1bq0ko"}],["path",{d:"M13.3 16.3 15 18",key:"2quom7"}]],oj=H("file-search",rj);const ij=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m8 16 2-2-2-2",key:"10vzyd"}],["path",{d:"M12 18h4",key:"1wd2n7"}]],aj=H("file-terminal",ij);const lj=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],cj=H("file-text",lj);const uj=[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]],dj=H("flag",uj);const fj=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],Sp=H("flask-conical",fj);const pj=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],mj=H("folder-open",pj);const hj=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Hl=H("gauge",hj);const gj=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M12 6h5a2 2 0 0 1 2 2v7",key:"1yj91y"}],["path",{d:"m15 9-3-3 3-3",key:"1lwv8l"}],["circle",{cx:"19",cy:"18",r:"3",key:"1qljk2"}],["path",{d:"M12 18H7a2 2 0 0 1-2-2V9",key:"16sdep"}],["path",{d:"m9 15 3 3-3 3",key:"1m3kbl"}]],xj=H("git-compare-arrows",gj);const bj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],_p=H("globe",bj);const vj=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Np=H("history",vj);const yj=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],wj=H("info",yj);const jj=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],pu=H("layers",jj);const kj=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],De=H("loader-circle",kj);const Sj=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],_j=H("lock",Sj);const Nj=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Cj=H("maximize-2",Nj);const Tj=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],ri=H("message-square",Tj);const Ej=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Rj=H("minimize-2",Ej);const Ij=[["path",{d:"M5 12h14",key:"1ays0h"}]],Cp=H("minus",Ij);const Pj=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],Mj=H("monitor",Pj);const Aj=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Oj=H("moon",Aj);const zj=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],Lj=H("mouse-pointer-click",zj);const $j=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],Dj=H("network",$j);const Fj=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],Uj=H("octagon-alert",Fj);const Bj=[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]],qj=H("package-check",Bj);const Hj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Vj=H("panel-right-close",Hj);const Wj=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],Zj=H("panel-right-open",Wj);const Kj=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Tp=H("pencil",Kj);const Gj=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],mu=H("plus",Gj);const Jj=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],hu=H("radio",Jj);const Yj=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Pt=H("refresh-cw",Yj);const Xj=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],Ep=H("rocket",Xj);const Qj=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Rp=H("rotate-ccw",Qj);const ek=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],No=H("rotate-cw",ek);const tk=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],nk=H("rows-3",tk);const sk=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],rk=H("save",sk);const ok=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]],ik=H("scan",ok);const ak=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],lk=H("search",ak);const ck=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],uk=H("send",ck);const dk=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],fk=H("server",dk);const pk=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],mk=H("settings",pk);const hk=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],gk=H("shield-alert",hk);const xk=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],gu=H("shield-check",xk);const bk=[["path",{d:"M7 18v-6a5 5 0 1 1 10 0v6",key:"pcx96s"}],["path",{d:"M5 21a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-1a2 2 0 0 0-2-2H7a2 2 0 0 0-2 2z",key:"1b4s83"}],["path",{d:"M21 12h1",key:"jtio3y"}],["path",{d:"M18.5 4.5 18 5",key:"g5sp9y"}],["path",{d:"M2 12h1",key:"1uaihz"}],["path",{d:"M12 2v1",key:"11qlp1"}],["path",{d:"m4.929 4.929.707.707",key:"1i51kw"}],["path",{d:"M12 12v6",key:"3ahymv"}]],Co=H("siren",bk);const vk=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],za=H("sparkles",vk);const yk=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],wk=H("sun",yk);const jk=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],Xn=H("terminal",jk);const kk=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Ip=H("timer",kk);const Sk=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],wn=H("trash-2",Sk);const _k=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],yn=H("triangle-alert",_k);const Nk=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Pp=H("upload",Nk);const Ck=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Tk=H("wifi-off",Ck);const Ek=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Rk=H("wifi",Ek);const Ik=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],wr=H("wrench",Ik);const Pk=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],jr=H("x",Pk);const Mk=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],ar=H("zap",Mk),La="/api/config";async function Ak(e){return st(e,si,void 0,t=>`Failed to fetch ${e}: ${t.status}`)}async function Ok(e){return st(La,si,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},t=>`PATCH failed with status ${t.status}`)}function zk(){const e=Bt(La,Ak,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:t}=lf(),n=e.data?.hasSeenOnboarding??!1,r=e.data?.captureMode??Dl,o=async()=>{await t(La,Ok({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??ko,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??So,timeDisplayFormat:e.data?.timeDisplayFormat??_o,captureMode:r},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:n,captureMode:r,isLoading:e.isLoading,markSeen:o}}function Lk({expanded:e,onToggle:t,onDismiss:n}){const r=e?"grid":"hidden sm:grid";return s.jsx("div",{role:"note","aria-label":"Onboarding tip",className:"mx-3 mt-2 mb-1 rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-sm shadow-sm sm:mx-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(wj,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),s.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),s.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),s.jsxs("div",{className:`${r} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),s.jsxs("div",{children:[s.jsx("strong",{children:"Network"}),": replace ",s.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),s.jsx("button",{type:"button",onClick:t,className:"inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-warning/35 px-2 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:hidden","aria-expanded":e,"aria-label":e?"Hide onboarding details":"Show onboarding details",children:s.jsx(et,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),s.jsxs("button",{type:"button",onClick:n,className:"hidden h-8 shrink-0 items-center gap-1.5 rounded-md border border-warning/40 px-3 text-xs font-medium text-foreground transition-colors hover:bg-warning/15 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:inline-flex","aria-label":"Dismiss onboarding tip",children:[s.jsx(qe,{className:"size-3.5"}),"Got it"]}),s.jsx("button",{type:"button",onClick:n,className:"-m-1 shrink-0 rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Dismiss",children:s.jsx(jr,{className:"size-3.5"})})]})})}function $k(){const{hasSeenOnboarding:e,isLoading:t,markSeen:n}=zk(),[r,o]=c.useState(!1);return t||e?null:s.jsx(Lk,{expanded:r,onToggle:()=>o(i=>!i),onDismiss:()=>{n()}})}const Dk="3.0.45",Mp={version:Dk};function Xs(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ap="[REDACTED]",Fk=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,Uk=[/Bearer\s+[A-Za-z0-9._~+/=-]{12,}/gi,/\bsk-[A-Za-z0-9_-]{12,}\b/g,/\bsk-ant-[A-Za-z0-9_-]{12,}\b/g,/\bghp_[A-Za-z0-9_]{12,}\b/g,/\bglpat-[A-Za-z0-9_-]{12,}\b/g],xu=200,Bk=25e6,Op=50,qk=1e4;function Hk(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function Vk(e){let t=0;for(const n of e)t+=n.rawRequestBody?.length??0,t+=n.responseText?.length??0;return t}function Wk(e){if(e.length>xu)return`Export is limited to ${xu} logs at once. Narrow the filter and try again.`;const t=Vk(e);return t>Bk?`Export is too large (${Hk(t)} of text). Narrow the filter and try again.`:null}function Or(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function Zk(e,t){try{const n=await Hn(`/api/logs/${e}/chunks`,qk,{signal:t});if(!n.ok)return null;const r=await n.json();return JSON.stringify(r,null,2)}catch{return null}}function $a(e){if(Array.isArray(e))return e.map(n=>$a(n));if(!Xs(e))return e;const t={};for(const[n,r]of Object.entries(e))t[n]=Fk.test(n)?Ap:$a(r);return t}function Kk(e){const t=n=>{let r=n;for(const o of Uk)r=r.replace(o,Ap);return r};try{const n=JSON.parse(e);return t(JSON.stringify($a(n),null,2))}catch{return t(e)}}function Bi(e,t){return t==="redacted"?Kk(e):e}function Gk(e,t){return{...e,rawRequestBody:null,responseText:null,rawHeaders:t==="raw"?e.rawHeaders:void 0,headers:t==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function Jk(e,t,n,r=new Date().toISOString()){return{version:Mp.version,exportedAt:r,mode:t,redacted:t==="redacted",logCount:e.length,logIds:e.map(o=>o.id),streamingChunkExportLimit:Op,streamingChunkLogIds:n.map(o=>o.id)}}async function Yk(e,t="redacted",n={}){const r=Or(n.signal);if(r!==null)return r;const o=Wk(e);if(o!==null)return{ok:!1,message:o};const{default:i}=await Kt(async()=>{const{default:h}=await import("./jszip.min-B_rfAUCe.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1])),a=new i,l=t==="redacted"?"redacted":"raw",u=e.filter(h=>h.streaming).slice(0,Op);a.file("manifest.json",JSON.stringify(Jk(e,t,u),null,2)),a.file("logs.json",JSON.stringify(e.map(h=>Gk(h,t)),null,2));for(const h of e){const g=Or(n.signal);if(g!==null)return g;h.rawRequestBody!==null&&a.file(`#${h.id}.Request.json`,Bi(h.rawRequestBody,t)),h.responseText!==null&&a.file(`#${h.id}.Response.json`,Bi(h.responseText,t))}for(const h of u){const g=Or(n.signal);if(g!==null)return g;const y=await Zk(h.id,n.signal);y!==null&&a.file(`#${h.id}.SSE.Response.json`,Bi(y,t))}const d=await a.generateAsync({type:"blob"}),f=Or(n.signal);if(f!==null)return f;const p=URL.createObjectURL(d),m=document.createElement("a");return m.href=p,m.download=`agent-inspector-export-${l}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(p),{ok:!0}}function zp(e,t){return{proxy:Li(e,"/proxy",t),openAiV1:Li(e,"/proxy/v1",t),mcp:Li(e,"/api/mcp",t)}}function Da(e,t){switch(t){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function oi(e,t,n){return`${Da(e,n)} - ${Da(t,n)}`}function Xk(){const[e,t]=c.useState(qx),n=c.useCallback(r=>{t(r),$i(r),Hx(r)},[]);return c.useEffect(()=>{$i(e)},[e]),c.useEffect(()=>{function r(o){if(o.key!==Vx)return;const i=Wx(o.newValue);t(i),$i(i)}return window.addEventListener("storage",r),()=>window.removeEventListener("storage",r)},[]),{themeMode:e,setThemeMode:n}}function Qk(){const[e,t]=c.useState(Zx),[n,r]=c.useState(1),o=c.useCallback(i=>{t(i),Kx(i),r(Di(i))},[]);return c.useEffect(()=>{const i=()=>{r(Di(e))};if(i(),e==="auto")return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[e]),c.useEffect(()=>{const i=a=>{if(a.key!==Gx)return;const l=cf(a.newValue);t(l),r(Di(l))};return window.addEventListener("storage",i),()=>window.removeEventListener("storage",i)},[]),{uiScalePreference:e,resolvedUiScale:n,setUiScalePreference:o}}const Vn=64,Fa=256,eS=64,tS=pe(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded"]),nS=Ot([le(400),le(413),le(429),le(503)]);E({error:x().min(1).max(300),code:tS,status:nS,resource:x().min(1).max(80),limit:R().int().positive(),retryable:Re()});function zr(){return x().refine(e=>{if(e.length===0)return!0;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const Vl=x().max(Fa),sS=K(Vl).max(Vn),rS=E({model:Vl.min(1),contextWindow:R().int().positive().optional(),outputLimit:R().int().positive().optional(),source:pe(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),oS=K(rS).max(eS),iS=E({id:x(),name:x(),apiKey:x(),model:Vl.optional(),models:sS.optional().default([]),format:pe(["anthropic","openai"]).optional(),baseUrl:zr().optional(),anthropicBaseUrl:zr().optional(),openaiBaseUrl:zr().optional(),openaiResponsesBaseUrl:zr().optional(),authHeader:pe(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:oS.optional(),source:pe(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),aS="configured",To=iS.extend({apiKey:le(aS)});async function lS(e){return st(e,To.array(),void 0,t=>`Failed to fetch ${e}: ${t.status}`)}function Wl(){const e=Bt("/api/providers",lS,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function bu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function cS(...e){return t=>{let n=!1;const r=e.map(o=>{const i=bu(o,t);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let o=0;o<r.length;o++){const i=r[o];typeof i=="function"?i():bu(e[o],null)}}}}function Ie(...e){return c.useCallback(cS(...e),e)}function Ts(e){const t=c.forwardRef((n,r)=>{let{children:o,...i}=n,a=null,l=!1;const u=[];vu(o)&&typeof Lr=="function"&&(o=Lr(o._payload)),c.Children.forEach(o,m=>{if(hS(m)){l=!0;const h=m;let g="child"in h.props?h.props.child:h.props.children;vu(g)&&typeof Lr=="function"&&(g=Lr(g._payload)),a=fS(h,g),u.push(a?.props?.children)}else u.push(m)}),a?a=c.cloneElement(a,void 0,u):!l&&c.Children.count(o)===1&&c.isValidElement(o)&&(a=o);const d=a?mS(a):void 0,f=Ie(r,d);if(!a){if(o||o===0)throw new Error(l?vS(e):bS(e));return o}const p=pS(i,a.props??{});return a.type!==c.Fragment&&(p.ref=r?f:d),c.cloneElement(a,p)});return t.displayName=`${e}.Slot`,t}var uS=Ts("Slot"),Lp=Symbol.for("radix.slottable");function dS(e){const t=n=>"child"in n?n.children(n.child):n.children;return t.displayName=`${e}.Slottable`,t.__radixId=Lp,t}var fS=(e,t)=>{if("child"in e.props){const n=e.props.child;return c.isValidElement(n)?c.cloneElement(n,void 0,e.props.children(n.props.children)):null}return c.isValidElement(t)?t:null};function pS(e,t){const n={...t};for(const r in t){const o=e[r],i=t[r];/^on[A-Z]/.test(r)?o&&i?n[r]=(...l)=>{const u=i(...l);return o(...l),u}:o&&(n[r]=o):r==="style"?n[r]={...o,...i}:r==="className"&&(n[r]=[o,i].filter(Boolean).join(" "))}return{...e,...n}}function mS(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function hS(e){return c.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Lp}var gS=Symbol.for("react.lazy");function vu(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===gS&&"_payload"in e&&xS(e._payload)}function xS(e){return typeof e=="object"&&e!==null&&"then"in e}var bS=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,vS=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Lr=Yo[" use ".trim().toString()],yS=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xe=yS.reduce((e,t)=>{const n=Ts(`Primitive.${t}`),r=c.forwardRef((o,i)=>{const{asChild:a,...l}=o,u=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...l,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function wS(e,t){e&&Os.flushSync(()=>e.dispatchEvent(t))}var $p=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),jS="VisuallyHidden",Dp=c.forwardRef((e,t)=>s.jsx(xe.span,{...e,ref:t,style:{...$p,...e.style}}));Dp.displayName=jS;var kS=Dp;function un(e,t=[]){let n=[];function r(i,a){const l=c.createContext(a);l.displayName=i+"Context";const u=n.length;n=[...n,a];const d=p=>{const{scope:m,children:h,...g}=p,y=m?.[e]?.[u]||l,b=c.useMemo(()=>g,Object.values(g));return s.jsx(y.Provider,{value:b,children:h})};d.displayName=i+"Provider";function f(p,m,h={}){const{optional:g=!1}=h,y=m?.[e]?.[u]||l,b=c.useContext(y);if(b)return b;if(a!==void 0)return a;if(!g)throw new Error(`\`${p}\` must be used within \`${i}\``)}return[d,f]}const o=()=>{const i=n.map(a=>c.createContext(a));return function(l){const u=l?.[e]||i;return c.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[r,SS(o,...t)]}function SS(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){const a=r.reduce((l,{useScope:u,scopeName:d})=>{const p=u(i)[`__scope${d}`];return{...l,...p}},{});return c.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function Fp(e){const t=e+"CollectionProvider",[n,r]=un(t),[o,i]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=y=>{const{scope:b,children:w}=y,v=c.useRef(null),j=c.useRef(new Map).current;return s.jsx(o,{scope:b,itemMap:j,collectionRef:v,children:w})};a.displayName=t;const l=e+"CollectionSlot",u=Ts(l),d=c.forwardRef((y,b)=>{const{scope:w,children:v}=y,j=i(l,w),k=Ie(b,j.collectionRef);return s.jsx(u,{ref:k,children:v})});d.displayName=l;const f=e+"CollectionItemSlot",p="data-radix-collection-item",m=Ts(f),h=c.forwardRef((y,b)=>{const{scope:w,children:v,...j}=y,k=c.useRef(null),S=Ie(b,k),_=i(f,w);return c.useEffect(()=>(_.itemMap.set(k,{ref:k,...j}),()=>{_.itemMap.delete(k)})),s.jsx(m,{[p]:"",ref:S,children:v})});h.displayName=f;function g(y){const b=i(e+"CollectionConsumer",y);return c.useCallback(()=>{const v=b.collectionRef.current;if(!v)return[];const j=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(b.itemMap.values()).sort((_,C)=>j.indexOf(_.ref.current)-j.indexOf(C.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:d,ItemSlot:h},g,r]}function fe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e?.(o),n===!1||!o||!o.defaultPrevented)return t?.(o)}}var Ge=globalThis?.document?c.useLayoutEffect:()=>{},_S=Yo[" useInsertionEffect ".trim().toString()]||Ge;function Zn({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,i,a]=NS({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:o;{const f=c.useRef(e!==void 0);c.useEffect(()=>{const p=f.current;p!==l&&console.warn(`${r} is changing from ${p?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=l},[l,r])}const d=c.useCallback(f=>{if(l){const p=CS(f)?f(e):f;p!==e&&a.current?.(p)}else i(f)},[l,e,i,a]);return[u,d]}function NS({defaultProp:e,onChange:t}){const[n,r]=c.useState(e),o=c.useRef(n),i=c.useRef(t);return _S(()=>{i.current=t},[t]),c.useEffect(()=>{o.current!==n&&(i.current?.(n),o.current=n)},[n,o]),[n,r,i]}function CS(e){return typeof e=="function"}function TS(e,t){return c.useReducer((n,r)=>t[n][r]??n,e)}var vt=e=>{const{present:t,children:n}=e,r=ES(t),o=typeof n=="function"?n({present:r.isPresent}):c.Children.only(n),i=RS(r.ref,IS(o));return typeof n=="function"||r.isPresent?c.cloneElement(o,{ref:i}):null};vt.displayName="Presence";function ES(e){const[t,n]=c.useState(),r=c.useRef(null),o=c.useRef(e),i=c.useRef("none"),a=c.useRef(void 0),l=e?"mounted":"unmounted",[u,d]=TS(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{u==="mounted"?(i.current=a.current??qs(r.current),a.current=void 0):i.current="none"},[u]),Ge(()=>{const f=r.current,p=o.current;if(p!==e){const h=i.current,g=qs(f);e?(a.current=g,d("MOUNT")):g==="none"||f?.display==="none"?d("UNMOUNT"):d(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),Ge(()=>{if(t){let f;const p=t.ownerDocument.defaultView??window,m=g=>{const b=qs(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&b&&(d("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",f=p.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},h=g=>{g.target===t&&(i.current=qs(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",m),t.addEventListener("animationend",m),()=>{p.clearTimeout(f),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",m),t.removeEventListener("animationend",m)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:c.useCallback(f=>{if(f){const p=getComputedStyle(f);r.current=p,a.current=qs(p)}else r.current=null;n(f)},[])}}function yu(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function RS(...e){const t=c.useRef(e);return t.current=e,c.useCallback(n=>{const r=t.current;let o=!1;const i=r.map(a=>{const l=yu(a,n);return!o&&typeof l=="function"&&(o=!0),l});if(o)return()=>{for(let a=0;a<i.length;a++){const l=i[a];typeof l=="function"?l():yu(r[a],null)}}},[])}function qs(e){return e?.animationName||"none"}function IS(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var PS=Yo[" useId ".trim().toString()]||(()=>{}),MS=0;function qt(e){const[t,n]=c.useState(PS());return Ge(()=>{n(r=>r??String(MS++))},[e]),e||(t?`radix-${t}`:"")}var ii="Collapsible",[AS]=un(ii),[OS,Zl]=AS(ii),Up=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:i,onOpenChange:a,...l}=e,[u,d]=Zn({prop:r,defaultProp:o??!1,onChange:a,caller:ii});return s.jsx(OS,{scope:n,disabled:i,contentId:qt(),open:u,onOpenToggle:c.useCallback(()=>d(f=>!f),[d]),children:s.jsx(xe.div,{"data-state":Gl(u),"data-disabled":i?"":void 0,...l,ref:t})})});Up.displayName=ii;var Bp="CollapsibleTrigger",qp=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=Zl(Bp,n);return s.jsx(xe.button,{type:"button","aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open||!1,"data-state":Gl(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:fe(e.onClick,o.onOpenToggle)})});qp.displayName=Bp;var Kl="CollapsibleContent",Hp=c.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zl(Kl,e.__scopeCollapsible);return s.jsx(vt,{present:n||o.open,children:({present:i})=>s.jsx(zS,{...r,ref:t,present:i})})});Hp.displayName=Kl;var zS=c.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...i}=e,a=Zl(Kl,n),[l,u]=c.useState(r),d=c.useRef(null),f=Ie(t,d),p=c.useRef(0),m=p.current,h=c.useRef(0),g=h.current,y=a.open||l,b=c.useRef(y),w=c.useRef(void 0);return c.useEffect(()=>{const v=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(v)},[]),Ge(()=>{const v=d.current;if(v){w.current=w.current||{transitionDuration:v.style.transitionDuration,animationName:v.style.animationName},v.style.transitionDuration="0s",v.style.animationName="none";const j=v.getBoundingClientRect();p.current=j.height,h.current=j.width,b.current||(v.style.transitionDuration=w.current.transitionDuration,v.style.animationName=w.current.animationName),u(r)}},[a.open,r]),s.jsx(xe.div,{"data-state":Gl(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!y,...i,ref:f,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:y&&o})});function Gl(e){return e?"open":"closed"}var LS=Up,$S=c.createContext(void 0);function ai(e){const t=c.useContext($S);return e||t||"ltr"}function Xe(e){const t=c.useRef(e);return c.useEffect(()=>{t.current=e}),c.useMemo(()=>((...n)=>t.current?.(...n)),[])}var DS="DismissableLayer",Ua="dismissableLayer.update",FS="dismissableLayer.pointerDownOutside",US="dismissableLayer.focusOutside",wu,Jl=c.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),li=c.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:l,onDismiss:u,...d}=e,f=c.useContext(Jl),[p,m]=c.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=c.useState({}),y=Ie(t,m),b=Array.from(f.layers),[w]=[...f.layersWithOutsidePointerEventsDisabled].slice(-1),v=w?b.indexOf(w):-1,j=p?b.indexOf(p):-1,k=f.layersWithOutsidePointerEventsDisabled.size>0,S=j>=v,_=c.useRef(!1),C=WS(N=>{i?.(N),l?.(N),N.defaultPrevented||u?.()},{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:f.dismissableSurfaces,shouldHandlePointerDownOutside:c.useCallback(N=>{if(!(N instanceof Node))return!1;const P=[...f.branches].some($=>$.contains(N));return S&&!P},[f.branches,S])}),M=ZS(N=>{if(r&&_.current)return;const P=N.target;[...f.branches].some(F=>F.contains(P))||(a?.(N),l?.(N),N.defaultPrevented||u?.())},h),A=p?j===b.length-1:!1,I=Xe(N=>{N.key==="Escape"&&(o?.(N),!N.defaultPrevented&&u&&(N.preventDefault(),u()))});return c.useEffect(()=>{if(A)return h.addEventListener("keydown",I,{capture:!0}),()=>h.removeEventListener("keydown",I,{capture:!0})},[h,A,I]),c.useEffect(()=>{if(p)return n&&(f.layersWithOutsidePointerEventsDisabled.size===0&&(wu=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),f.layersWithOutsidePointerEventsDisabled.add(p)),f.layers.add(p),ju(),()=>{n&&(f.layersWithOutsidePointerEventsDisabled.delete(p),f.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=wu))}},[p,h,n,f]),c.useEffect(()=>()=>{p&&(f.layers.delete(p),f.layersWithOutsidePointerEventsDisabled.delete(p),ju())},[p,f]),c.useEffect(()=>{const N=()=>g({});return document.addEventListener(Ua,N),()=>document.removeEventListener(Ua,N)},[]),s.jsx(xe.div,{...d,ref:y,style:{pointerEvents:k?S?"auto":"none":void 0,...e.style},onFocusCapture:fe(e.onFocusCapture,M.onFocusCapture),onBlurCapture:fe(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:fe(e.onPointerDownCapture,C.onPointerDownCapture)})});li.displayName=DS;var BS="DismissableLayerBranch",qS=c.forwardRef((e,t)=>{const n=c.useContext(Jl),r=c.useRef(null),o=Ie(t,r);return c.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),s.jsx(xe.div,{...e,ref:o})});qS.displayName=BS;function HS(){const e=c.useContext(Jl),[t,n]=c.useState(null);return c.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}var VS=()=>!0;function WS(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:o,dismissableSurfaces:i,shouldHandlePointerDownOutside:a=VS}=t,l=Xe(e),u=c.useRef(!1),d=c.useRef(!1),f=c.useRef(new Map),p=c.useRef(()=>{});return c.useEffect(()=>{function m(){d.current=!1,o.current=!1,f.current.clear()}function h(){return Array.from(f.current.values()).some(Boolean)}function g(j){if(!d.current)return;const k=j.target;k instanceof Node&&[...i].some(_=>_.contains(k))||f.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{d.current&&p.current()},0)}function y(j){d.current&&f.current.set(j.type,!1)}const b=j=>{if(j.target&&!u.current){let k=function(){n.removeEventListener("click",p.current);const _=h();m(),_||Vp(FS,l,S,{discrete:!0})};if(!a(j.target)){n.removeEventListener("click",p.current),m(),u.current=!1;return}const S={originalEvent:j};d.current=!0,o.current=r&&j.button===0,f.current.clear(),!r||j.button!==0?k():(n.removeEventListener("click",p.current),p.current=k,n.addEventListener("click",p.current,{once:!0}))}else n.removeEventListener("click",p.current),m();u.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)n.addEventListener(j,g,!0),n.addEventListener(j,y);const v=window.setTimeout(()=>{n.addEventListener("pointerdown",b)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",b),n.removeEventListener("click",p.current);for(const j of w)n.removeEventListener(j,g,!0),n.removeEventListener(j,y)}},[n,l,r,o,i,a]),{onPointerDownCapture:()=>u.current=!0}}function ZS(e,t=globalThis?.document){const n=Xe(e),r=c.useRef(!1);return c.useEffect(()=>{const o=i=>{i.target&&!r.current&&Vp(US,n,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function ju(){const e=new CustomEvent(Ua);document.dispatchEvent(e)}function Vp(e,t,n,{discrete:r}){const o=n.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?wS(o,i):o.dispatchEvent(i)}var qi="focusScope.autoFocusOnMount",Hi="focusScope.autoFocusOnUnmount",ku={bubbles:!1,cancelable:!0},KS="FocusScope",Yl=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...a}=e,[l,u]=c.useState(null),d=Xe(o),f=Xe(i),p=c.useRef(null),m=Ie(t,u),h=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let y=function(j){if(h.paused||!l)return;const k=j.target;l.contains(k)?p.current=k:hn(p.current,{select:!0})},b=function(j){if(h.paused||!l)return;const k=j.relatedTarget;k!==null&&(l.contains(k)||hn(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const S of j)S.removedNodes.length>0&&hn(l)};document.addEventListener("focusin",y),document.addEventListener("focusout",b);const v=new MutationObserver(w);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",y),document.removeEventListener("focusout",b),v.disconnect()}}},[r,l,h.paused]),c.useEffect(()=>{if(l){_u.add(h);const y=document.activeElement;if(!l.contains(y)){const w=new CustomEvent(qi,ku);l.addEventListener(qi,d),l.dispatchEvent(w),w.defaultPrevented||(GS(e5(Wp(l)),{select:!0}),document.activeElement===y&&hn(l))}return()=>{l.removeEventListener(qi,d),setTimeout(()=>{const w=new CustomEvent(Hi,ku);l.addEventListener(Hi,f),l.dispatchEvent(w),w.defaultPrevented||hn(y??document.body,{select:!0}),l.removeEventListener(Hi,f),_u.remove(h)},0)}}},[l,d,f,h]);const g=c.useCallback(y=>{if(!n&&!r||h.paused)return;const b=y.key==="Tab"&&!y.altKey&&!y.ctrlKey&&!y.metaKey,w=document.activeElement;if(b&&w){const v=y.currentTarget,[j,k]=JS(v);j&&k?!y.shiftKey&&w===k?(y.preventDefault(),n&&hn(j,{select:!0})):y.shiftKey&&w===j&&(y.preventDefault(),n&&hn(k,{select:!0})):w===v&&y.preventDefault()}},[n,r,h.paused]);return s.jsx(xe.div,{tabIndex:-1,...a,ref:m,onKeyDown:g})});Yl.displayName=KS;function GS(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(hn(r,{select:t}),document.activeElement!==n)return}function JS(e){const t=Wp(e),n=Su(t,e),r=Su(t.reverse(),e);return[n,r]}function Wp(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Su(e,t){const n=typeof t.checkVisibility=="function"&&t.checkVisibility({checkVisibilityCSS:!0});for(const r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):YS(r,{upTo:t})))return r}function YS(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function XS(e){return e instanceof HTMLInputElement&&"select"in e}function hn(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&XS(e)&&t&&e.select()}}var _u=QS();function QS(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=Nu(e,t),e.unshift(t)},remove(t){e=Nu(e,t),e[0]?.resume()}}}function Nu(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function e5(e){return e.filter(t=>t.tagName!=="A")}var t5="Portal",ci=c.forwardRef((e,t)=>{const{container:n,...r}=e,[o,i]=c.useState(!1);Ge(()=>i(!0),[]);const a=n||o&&globalThis?.document?.body;return a?Os.createPortal(s.jsx(xe.div,{...r,ref:t}),a):null});ci.displayName=t5;var $r=0,ns=null;function Zp(){c.useEffect(()=>{ns||(ns={start:Cu(),end:Cu()});const{start:e,end:t}=ns;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),$r++,()=>{$r===1&&(ns?.start.remove(),ns?.end.remove(),ns=null),$r=Math.max(0,$r-1)}},[])}function Cu(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Ft=function(){return Ft=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},Ft.apply(this,arguments)};function Kp(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function n5(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,i;r<o;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))}var lo="right-scroll-bar-position",co="width-before-scroll-bar",s5="with-scroll-bars-hidden",r5="--removed-body-scroll-bar-size";function Vi(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function o5(e,t){var n=c.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var i5=typeof window<"u"?c.useLayoutEffect:c.useEffect,Tu=new WeakMap;function a5(e,t){var n=o5(null,function(r){return e.forEach(function(o){return Vi(o,r)})});return i5(function(){var r=Tu.get(n);if(r){var o=new Set(r),i=new Set(e),a=n.current;o.forEach(function(l){i.has(l)||Vi(l,null)}),i.forEach(function(l){o.has(l)||Vi(l,a)})}Tu.set(n,e)},[e]),n}function l5(e){return e}function c5(e,t){t===void 0&&(t=l5);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(i){var a=t(i,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(i){for(r=!0;n.length;){var a=n;n=[],a.forEach(i)}n={push:function(l){return i(l)},filter:function(){return n}}},assignMedium:function(i){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(i),a=n}var u=function(){var f=a;a=[],f.forEach(i)},d=function(){return Promise.resolve().then(u)};d(),n={push:function(f){a.push(f),d()},filter:function(f){return a=a.filter(f),n}}}};return o}function u5(e){e===void 0&&(e={});var t=c5(null);return t.options=Ft({async:!0,ssr:!1},e),t}var Gp=function(e){var t=e.sideCar,n=Kp(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return c.createElement(r,Ft({},n))};Gp.isSideCarExport=!0;function d5(e,t){return e.useMedium(t),Gp}var Jp=u5(),Wi=function(){},ui=c.forwardRef(function(e,t){var n=c.useRef(null),r=c.useState({onScrollCapture:Wi,onWheelCapture:Wi,onTouchMoveCapture:Wi}),o=r[0],i=r[1],a=e.forwardProps,l=e.children,u=e.className,d=e.removeScrollBar,f=e.enabled,p=e.shards,m=e.sideCar,h=e.noRelative,g=e.noIsolation,y=e.inert,b=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,j=e.gapMode,k=Kp(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=m,_=a5([n,t]),C=Ft(Ft({},k),o);return c.createElement(c.Fragment,null,f&&c.createElement(S,{sideCar:Jp,removeScrollBar:d,shards:p,noRelative:h,noIsolation:g,inert:y,setCallbacks:i,allowPinchZoom:!!b,lockRef:n,gapMode:j}),a?c.cloneElement(c.Children.only(l),Ft(Ft({},C),{ref:_})):c.createElement(v,Ft({},C,{className:u,ref:_}),l))});ui.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};ui.classNames={fullWidth:co,zeroRight:lo};var f5=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function p5(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=f5();return t&&e.setAttribute("nonce",t),e}function m5(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function h5(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var g5=function(){var e=0,t=null;return{add:function(n){e==0&&(t=p5())&&(m5(t,n),h5(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},x5=function(){var e=g5();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Yp=function(){var e=x5(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},b5={left:0,top:0,right:0,gap:0},Zi=function(e){return parseInt(e||"",10)||0},v5=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[Zi(n),Zi(r),Zi(o)]},y5=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return b5;var t=v5(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},w5=Yp(),vs="data-scroll-locked",j5=function(e,t,n,r){var o=e.left,i=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
66
- .`.concat(s5,` {
67
- overflow: hidden `).concat(r,`;
68
- padding-right: `).concat(l,"px ").concat(r,`;
69
- }
70
- body[`).concat(vs,`] {
71
- overflow: hidden `).concat(r,`;
72
- overscroll-behavior: contain;
73
- `).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
74
- padding-left: `.concat(o,`px;
75
- padding-top: `).concat(i,`px;
76
- padding-right: `).concat(a,`px;
77
- margin-left:0;
78
- margin-top:0;
79
- margin-right: `).concat(l,"px ").concat(r,`;
80
- `),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
81
- }
82
-
83
- .`).concat(lo,` {
84
- right: `).concat(l,"px ").concat(r,`;
85
- }
86
-
87
- .`).concat(co,` {
88
- margin-right: `).concat(l,"px ").concat(r,`;
89
- }
90
-
91
- .`).concat(lo," .").concat(lo,` {
92
- right: 0 `).concat(r,`;
93
- }
94
-
95
- .`).concat(co," .").concat(co,` {
96
- margin-right: 0 `).concat(r,`;
97
- }
98
-
99
- body[`).concat(vs,`] {
100
- `).concat(r5,": ").concat(l,`px;
101
- }
102
- `)},Eu=function(){var e=parseInt(document.body.getAttribute(vs)||"0",10);return isFinite(e)?e:0},k5=function(){c.useEffect(function(){return document.body.setAttribute(vs,(Eu()+1).toString()),function(){var e=Eu()-1;e<=0?document.body.removeAttribute(vs):document.body.setAttribute(vs,e.toString())}},[])},S5=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,o=r===void 0?"margin":r;k5();var i=c.useMemo(function(){return y5(o)},[o]);return c.createElement(w5,{styles:j5(i,!t,o,n?"":"!important")})},Ba=!1;if(typeof window<"u")try{var Dr=Object.defineProperty({},"passive",{get:function(){return Ba=!0,!0}});window.addEventListener("test",Dr,Dr),window.removeEventListener("test",Dr,Dr)}catch{Ba=!1}var ss=Ba?{passive:!1}:!1,_5=function(e){return e.tagName==="TEXTAREA"},Xp=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!_5(e)&&n[t]==="visible")},N5=function(e){return Xp(e,"overflowY")},C5=function(e){return Xp(e,"overflowX")},Ru=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=Qp(e,r);if(o){var i=em(e,r),a=i[1],l=i[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},T5=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},E5=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},Qp=function(e,t){return e==="v"?N5(t):C5(t)},em=function(e,t){return e==="v"?T5(t):E5(t)},R5=function(e,t){return e==="h"&&t==="rtl"?-1:1},I5=function(e,t,n,r,o){var i=R5(e,window.getComputedStyle(t).direction),a=i*r,l=n.target,u=t.contains(l),d=!1,f=a>0,p=0,m=0;do{if(!l)break;var h=em(e,l),g=h[0],y=h[1],b=h[2],w=y-b-i*g;(g||w)&&Qp(e,l)&&(p+=w,m+=g);var v=l.parentNode;l=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(f&&Math.abs(p)<1||!f&&Math.abs(m)<1)&&(d=!0),d},Fr=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Iu=function(e){return[e.deltaX,e.deltaY]},Pu=function(e){return e&&"current"in e?e.current:e},P5=function(e,t){return e[0]===t[0]&&e[1]===t[1]},M5=function(e){return`
103
- .block-interactivity-`.concat(e,` {pointer-events: none;}
104
- .allow-interactivity-`).concat(e,` {pointer-events: all;}
105
- `)},A5=0,rs=[];function O5(e){var t=c.useRef([]),n=c.useRef([0,0]),r=c.useRef(),o=c.useState(A5++)[0],i=c.useState(Yp)[0],a=c.useRef(e);c.useEffect(function(){a.current=e},[e]),c.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var y=n5([e.lockRef.current],(e.shards||[]).map(Pu),!0).filter(Boolean);return y.forEach(function(b){return b.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),y.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var l=c.useCallback(function(y,b){if("touches"in y&&y.touches.length===2||y.type==="wheel"&&y.ctrlKey)return!a.current.allowPinchZoom;var w=Fr(y),v=n.current,j="deltaX"in y?y.deltaX:v[0]-w[0],k="deltaY"in y?y.deltaY:v[1]-w[1],S,_=y.target,C=Math.abs(j)>Math.abs(k)?"h":"v";if("touches"in y&&C==="h"&&_.type==="range")return!1;var M=window.getSelection(),A=M&&M.anchorNode,I=A?A===_||A.contains(_):!1;if(I)return!1;var N=Ru(C,_);if(!N)return!0;if(N?S=C:(S=C==="v"?"h":"v",N=Ru(C,_)),!N)return!1;if(!r.current&&"changedTouches"in y&&(j||k)&&(r.current=S),!S)return!0;var P=r.current||S;return I5(P,b,y,P==="h"?j:k)},[]),u=c.useCallback(function(y){var b=y;if(!(!rs.length||rs[rs.length-1]!==i)){var w="deltaY"in b?Iu(b):Fr(b),v=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&P5(S.delta,w)})[0];if(v&&v.should){b.cancelable&&b.preventDefault();return}if(!v){var j=(a.current.shards||[]).map(Pu).filter(Boolean).filter(function(S){return S.contains(b.target)}),k=j.length>0?l(b,j[0]):!a.current.noIsolation;k&&b.cancelable&&b.preventDefault()}}},[]),d=c.useCallback(function(y,b,w,v){var j={name:y,delta:b,target:w,should:v,shadowParent:z5(w)};t.current.push(j),setTimeout(function(){t.current=t.current.filter(function(k){return k!==j})},1)},[]),f=c.useCallback(function(y){n.current=Fr(y),r.current=void 0},[]),p=c.useCallback(function(y){d(y.type,Iu(y),y.target,l(y,e.lockRef.current))},[]),m=c.useCallback(function(y){d(y.type,Fr(y),y.target,l(y,e.lockRef.current))},[]);c.useEffect(function(){return rs.push(i),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:m}),document.addEventListener("wheel",u,ss),document.addEventListener("touchmove",u,ss),document.addEventListener("touchstart",f,ss),function(){rs=rs.filter(function(y){return y!==i}),document.removeEventListener("wheel",u,ss),document.removeEventListener("touchmove",u,ss),document.removeEventListener("touchstart",f,ss)}},[]);var h=e.removeScrollBar,g=e.inert;return c.createElement(c.Fragment,null,g?c.createElement(i,{styles:M5(o)}):null,h?c.createElement(S5,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function z5(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const L5=d5(Jp,O5);var Xl=c.forwardRef(function(e,t){return c.createElement(ui,Ft({},e,{ref:t,sideCar:L5}))});Xl.classNames=ui.classNames;var $5=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},os=new WeakMap,Ur=new WeakMap,Br={},Ki=0,tm=function(e){return e&&(e.host||tm(e.parentNode))},D5=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=tm(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},F5=function(e,t,n,r){var o=D5(t,Array.isArray(e)?e:[e]);Br[n]||(Br[n]=new WeakMap);var i=Br[n],a=[],l=new Set,u=new Set(o),d=function(p){!p||l.has(p)||(l.add(p),d(p.parentNode))};o.forEach(d);var f=function(p){!p||u.has(p)||Array.prototype.forEach.call(p.children,function(m){if(l.has(m))f(m);else try{var h=m.getAttribute(r),g=h!==null&&h!=="false",y=(os.get(m)||0)+1,b=(i.get(m)||0)+1;os.set(m,y),i.set(m,b),a.push(m),y===1&&g&&Ur.set(m,!0),b===1&&m.setAttribute(n,"true"),g||m.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",m,w)}})};return f(t),l.clear(),Ki++,function(){a.forEach(function(p){var m=os.get(p)-1,h=i.get(p)-1;os.set(p,m),i.set(p,h),m||(Ur.has(p)||p.removeAttribute(r),Ur.delete(p)),h||p.removeAttribute(n)}),Ki--,Ki||(os=new WeakMap,os=new WeakMap,Ur=new WeakMap,Br={})}},nm=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=$5(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),F5(r,o,n,"aria-hidden")):function(){return null}},di="Dialog",[sm]=un(di),[U5,Lt]=sm(di),rm=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:o,onOpenChange:i,modal:a=!0}=e,l=c.useRef(null),u=c.useRef(null),[d,f]=Zn({prop:r,defaultProp:o??!1,onChange:i,caller:di});return s.jsx(U5,{scope:t,triggerRef:l,contentRef:u,contentId:qt(),titleId:qt(),descriptionId:qt(),open:d,onOpenChange:f,onOpenToggle:c.useCallback(()=>f(p=>!p),[f]),modal:a,children:n})};rm.displayName=di;var om="DialogTrigger",im=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Lt(om,n),i=Ie(t,o.triggerRef);return s.jsx(xe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":ec(o.open),...r,ref:i,onClick:fe(e.onClick,o.onOpenToggle)})});im.displayName=om;var Ql="DialogPortal",[B5,am]=sm(Ql,{forceMount:void 0}),lm=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:o}=e,i=Lt(Ql,t);return s.jsx(B5,{scope:t,forceMount:n,children:c.Children.map(r,a=>s.jsx(vt,{present:n||i.open,children:s.jsx(ci,{asChild:!0,container:o,children:a})}))})};lm.displayName=Ql;var Eo="DialogOverlay",cm=c.forwardRef((e,t)=>{const n=am(Eo,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Lt(Eo,e.__scopeDialog);return i.modal?s.jsx(vt,{present:r||i.open,children:s.jsx(H5,{...o,ref:t})}):null});cm.displayName=Eo;var q5=Ts("DialogOverlay.RemoveScroll"),H5=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Lt(Eo,n),i=HS(),a=Ie(t,i);return s.jsx(Xl,{as:q5,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(xe.div,{"data-state":ec(o.open),...r,ref:a,style:{pointerEvents:"auto",...r.style}})})}),Es="DialogContent",um=c.forwardRef((e,t)=>{const n=am(Es,e.__scopeDialog),{forceMount:r=n.forceMount,...o}=e,i=Lt(Es,e.__scopeDialog);return s.jsx(vt,{present:r||i.open,children:i.modal?s.jsx(V5,{...o,ref:t}):s.jsx(W5,{...o,ref:t})})});um.displayName=Es;var V5=c.forwardRef((e,t)=>{const n=Lt(Es,e.__scopeDialog),r=c.useRef(null),o=Ie(t,n.contentRef,r);return c.useEffect(()=>{const i=r.current;if(i)return nm(i)},[]),s.jsx(dm,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:fe(e.onCloseAutoFocus,i=>{i.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:fe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&i.preventDefault()}),onFocusOutside:fe(e.onFocusOutside,i=>i.preventDefault())})}),W5=c.forwardRef((e,t)=>{const n=Lt(Es,e.__scopeDialog),r=c.useRef(!1),o=c.useRef(!1);return s.jsx(dm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=i.target;n.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),dm=c.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:i,...a}=e,l=Lt(Es,n);return Zp(),s.jsx(s.Fragment,{children:s.jsx(Yl,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:i,children:s.jsx(li,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":ec(l.open),...a,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),fm="DialogTitle",pm=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Lt(fm,n);return s.jsx(xe.h2,{id:o.titleId,...r,ref:t})});pm.displayName=fm;var mm="DialogDescription",hm=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Lt(mm,n);return s.jsx(xe.p,{id:o.descriptionId,...r,ref:t})});hm.displayName=mm;var gm="DialogClose",xm=c.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,o=Lt(gm,n);return s.jsx(xe.button,{type:"button",...r,ref:t,onClick:fe(e.onClick,()=>o.onOpenChange(!1))})});xm.displayName=gm;function ec(e){return e?"open":"closed"}function Z5(e){const t=c.useRef({value:e,previous:e});return c.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function K5(e){const[t,n]=c.useState(void 0);return Ge(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const i=o[0];let a,l;if("borderBoxSize"in i){const u=i.borderBoxSize,d=Array.isArray(u)?u[0]:u;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}const G5=["top","right","bottom","left"],jn=Math.min,mt=Math.max,Ro=Math.round,qr=Math.floor,Ht=e=>({x:e,y:e}),J5={left:"right",right:"left",bottom:"top",top:"bottom"},Y5={start:"end",end:"start"};function qa(e,t,n){return mt(e,jn(t,n))}function an(e,t){return typeof e=="function"?e(t):e}function ln(e){return e.split("-")[0]}function Ls(e){return e.split("-")[1]}function tc(e){return e==="x"?"y":"x"}function nc(e){return e==="y"?"height":"width"}const X5=new Set(["top","bottom"]);function Ut(e){return X5.has(ln(e))?"y":"x"}function sc(e){return tc(Ut(e))}function Q5(e,t,n){n===void 0&&(n=!1);const r=Ls(e),o=sc(e),i=nc(o);let a=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Io(a)),[a,Io(a)]}function e_(e){const t=Io(e);return[Ha(e),t,Ha(t)]}function Ha(e){return e.replace(/start|end/g,t=>Y5[t])}const Mu=["left","right"],Au=["right","left"],t_=["top","bottom"],n_=["bottom","top"];function s_(e,t,n){switch(e){case"top":case"bottom":return n?t?Au:Mu:t?Mu:Au;case"left":case"right":return t?t_:n_;default:return[]}}function r_(e,t,n,r){const o=Ls(e);let i=s_(ln(e),n==="start",r);return o&&(i=i.map(a=>a+"-"+o),t&&(i=i.concat(i.map(Ha)))),i}function Io(e){return e.replace(/left|right|bottom|top/g,t=>J5[t])}function o_(e){return{top:0,right:0,bottom:0,left:0,...e}}function bm(e){return typeof e!="number"?o_(e):{top:e,right:e,bottom:e,left:e}}function Po(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function Ou(e,t,n){let{reference:r,floating:o}=e;const i=Ut(t),a=sc(t),l=nc(a),u=ln(t),d=i==="y",f=r.x+r.width/2-o.width/2,p=r.y+r.height/2-o.height/2,m=r[l]/2-o[l]/2;let h;switch(u){case"top":h={x:f,y:r.y-o.height};break;case"bottom":h={x:f,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:p};break;case"left":h={x:r.x-o.width,y:p};break;default:h={x:r.x,y:r.y}}switch(Ls(t)){case"start":h[a]-=m*(n&&d?-1:1);break;case"end":h[a]+=m*(n&&d?-1:1);break}return h}async function i_(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:i,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:m=!1,padding:h=0}=an(t,e),g=bm(h),b=l[m?p==="floating"?"reference":"floating":p],w=Po(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(b)))==null||n?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:u})),v=p==="floating"?{x:r,y:o,width:a.floating.width,height:a.floating.height}:a.reference,j=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),k=await(i.isElement==null?void 0:i.isElement(j))?await(i.getScale==null?void 0:i.getScale(j))||{x:1,y:1}:{x:1,y:1},S=Po(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:j,strategy:u}):v);return{top:(w.top-S.top+g.top)/k.y,bottom:(S.bottom-w.bottom+g.bottom)/k.y,left:(w.left-S.left+g.left)/k.x,right:(S.right-w.right+g.right)/k.x}}const a_=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:i=[],platform:a}=n,l=i.filter(Boolean),u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:o}),{x:f,y:p}=Ou(d,r,u),m=r,h={},g=0;for(let b=0;b<l.length;b++){var y;const{name:w,fn:v}=l[b],{x:j,y:k,data:S,reset:_}=await v({x:f,y:p,initialPlacement:r,placement:m,strategy:o,middlewareData:h,rects:d,platform:{...a,detectOverflow:(y=a.detectOverflow)!=null?y:i_},elements:{reference:e,floating:t}});f=j??f,p=k??p,h={...h,[w]:{...h[w],...S}},_&&g<=50&&(g++,typeof _=="object"&&(_.placement&&(m=_.placement),_.rects&&(d=_.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:o}):_.rects),{x:f,y:p}=Ou(d,m,u)),b=-1)}return{x:f,y:p,placement:m,strategy:o,middlewareData:h}},l_=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:i,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=an(e,t)||{};if(d==null)return{};const p=bm(f),m={x:n,y:r},h=sc(o),g=nc(h),y=await a.getDimensions(d),b=h==="y",w=b?"top":"left",v=b?"bottom":"right",j=b?"clientHeight":"clientWidth",k=i.reference[g]+i.reference[h]-m[h]-i.floating[g],S=m[h]-i.reference[h],_=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let C=_?_[j]:0;(!C||!await(a.isElement==null?void 0:a.isElement(_)))&&(C=l.floating[j]||i.floating[g]);const M=k/2-S/2,A=C/2-y[g]/2-1,I=jn(p[w],A),N=jn(p[v],A),P=I,$=C-y[g]-N,F=C/2-y[g]/2+M,G=qa(P,F,$),X=!u.arrow&&Ls(o)!=null&&F!==G&&i.reference[g]/2-(F<P?I:N)-y[g]/2<0,U=X?F<P?F-P:F-$:0;return{[h]:m[h]+U,data:{[h]:G,centerOffset:F-G-U,...X&&{alignmentOffset:U}},reset:X}}}),c_=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:i,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...b}=an(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=ln(o),v=Ut(l),j=ln(l)===l,k=await(u.isRTL==null?void 0:u.isRTL(d.floating)),S=m||(j||!y?[Io(l)]:e_(l)),_=g!=="none";!m&&_&&S.push(...r_(l,y,g,k));const C=[l,...S],M=await u.detectOverflow(t,b),A=[];let I=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&A.push(M[w]),p){const F=Q5(o,a,k);A.push(M[F[0]],M[F[1]])}if(I=[...I,{placement:o,overflows:A}],!A.every(F=>F<=0)){var N,P;const F=(((N=i.flip)==null?void 0:N.index)||0)+1,G=C[F];if(G&&(!(p==="alignment"?v!==Ut(G):!1)||I.every(V=>Ut(V.placement)===v?V.overflows[0]>0:!0)))return{data:{index:F,overflows:I},reset:{placement:G}};let X=(P=I.filter(U=>U.overflows[0]<=0).sort((U,V)=>U.overflows[1]-V.overflows[1])[0])==null?void 0:P.placement;if(!X)switch(h){case"bestFit":{var $;const U=($=I.filter(V=>{if(_){const Y=Ut(V.placement);return Y===v||Y==="y"}return!0}).map(V=>[V.placement,V.overflows.filter(Y=>Y>0).reduce((Y,B)=>Y+B,0)]).sort((V,Y)=>V[1]-Y[1])[0])==null?void 0:$[0];U&&(X=U);break}case"initialPlacement":X=l;break}if(o!==X)return{reset:{placement:X}}}return{}}}};function zu(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Lu(e){return G5.some(t=>e[t]>=0)}const u_=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...i}=an(e,t);switch(o){case"referenceHidden":{const a=await r.detectOverflow(t,{...i,elementContext:"reference"}),l=zu(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Lu(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...i,altBoundary:!0}),l=zu(a,n.floating);return{data:{escapedOffsets:l,escaped:Lu(l)}}}default:return{}}}}},vm=new Set(["left","top"]);async function d_(e,t){const{placement:n,platform:r,elements:o}=e,i=await(r.isRTL==null?void 0:r.isRTL(o.floating)),a=ln(n),l=Ls(n),u=Ut(n)==="y",d=vm.has(a)?-1:1,f=i&&u?-1:1,p=an(t,e);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof g=="number"&&(h=l==="end"?g*-1:g),u?{x:h*f,y:m*d}:{x:m*d,y:h*f}}const f_=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:i,placement:a,middlewareData:l}=t,u=await d_(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:o+u.x,y:i+u.y,data:{...u,placement:a}}}}},p_=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:w=>{let{x:v,y:j}=w;return{x:v,y:j}}},...d}=an(e,t),f={x:n,y:r},p=await i.detectOverflow(t,d),m=Ut(ln(o)),h=tc(m);let g=f[h],y=f[m];if(a){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",j=g+p[w],k=g-p[v];g=qa(j,g,k)}if(l){const w=m==="y"?"top":"left",v=m==="y"?"bottom":"right",j=y+p[w],k=y-p[v];y=qa(j,y,k)}const b=u.fn({...t,[h]:g,[m]:y});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[h]:a,[m]:l}}}}}},m_=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:i,middlewareData:a}=t,{offset:l=0,mainAxis:u=!0,crossAxis:d=!0}=an(e,t),f={x:n,y:r},p=Ut(o),m=tc(p);let h=f[m],g=f[p];const y=an(l,t),b=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(u){const j=m==="y"?"height":"width",k=i.reference[m]-i.floating[j]+b.mainAxis,S=i.reference[m]+i.reference[j]-b.mainAxis;h<k?h=k:h>S&&(h=S)}if(d){var w,v;const j=m==="y"?"width":"height",k=vm.has(ln(o)),S=i.reference[p]-i.floating[j]+(k&&((w=a.offset)==null?void 0:w[p])||0)+(k?0:b.crossAxis),_=i.reference[p]+i.reference[j]+(k?0:((v=a.offset)==null?void 0:v[p])||0)-(k?b.crossAxis:0);g<S?g=S:g>_&&(g=_)}return{[m]:h,[p]:g}}}},h_=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:i,platform:a,elements:l}=t,{apply:u=()=>{},...d}=an(e,t),f=await a.detectOverflow(t,d),p=ln(o),m=Ls(o),h=Ut(o)==="y",{width:g,height:y}=i.floating;let b,w;p==="top"||p==="bottom"?(b=p,w=m===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(w=p,b=m==="end"?"top":"bottom");const v=y-f.top-f.bottom,j=g-f.left-f.right,k=jn(y-f[b],v),S=jn(g-f[w],j),_=!t.middlewareData.shift;let C=k,M=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(M=j),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),_&&!m){const I=mt(f.left,0),N=mt(f.right,0),P=mt(f.top,0),$=mt(f.bottom,0);h?M=g-2*(I!==0||N!==0?I+N:mt(f.left,f.right)):C=y-2*(P!==0||$!==0?P+$:mt(f.top,f.bottom))}await u({...t,availableWidth:M,availableHeight:C});const A=await a.getDimensions(l.floating);return g!==A.width||y!==A.height?{reset:{rects:!0}}:{}}}};function fi(){return typeof window<"u"}function $s(e){return ym(e)?(e.nodeName||"").toLowerCase():"#document"}function xt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Gt(e){var t;return(t=(ym(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ym(e){return fi()?e instanceof Node||e instanceof xt(e).Node:!1}function Mt(e){return fi()?e instanceof Element||e instanceof xt(e).Element:!1}function Vt(e){return fi()?e instanceof HTMLElement||e instanceof xt(e).HTMLElement:!1}function $u(e){return!fi()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof xt(e).ShadowRoot}const g_=new Set(["inline","contents"]);function kr(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=At(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!g_.has(o)}const x_=new Set(["table","td","th"]);function b_(e){return x_.has($s(e))}const v_=[":popover-open",":modal"];function pi(e){return v_.some(t=>{try{return e.matches(t)}catch{return!1}})}const y_=["transform","translate","scale","rotate","perspective"],w_=["transform","translate","scale","rotate","perspective","filter"],j_=["paint","layout","strict","content"];function rc(e){const t=oc(),n=Mt(e)?At(e):e;return y_.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||w_.some(r=>(n.willChange||"").includes(r))||j_.some(r=>(n.contain||"").includes(r))}function k_(e){let t=kn(e);for(;Vt(t)&&!Rs(t);){if(rc(t))return t;if(pi(t))return null;t=kn(t)}return null}function oc(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const S_=new Set(["html","body","#document"]);function Rs(e){return S_.has($s(e))}function At(e){return xt(e).getComputedStyle(e)}function mi(e){return Mt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function kn(e){if($s(e)==="html")return e;const t=e.assignedSlot||e.parentNode||$u(e)&&e.host||Gt(e);return $u(t)?t.host:t}function wm(e){const t=kn(e);return Rs(t)?e.ownerDocument?e.ownerDocument.body:e.body:Vt(t)&&kr(t)?t:wm(t)}function lr(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=wm(e),i=o===((r=e.ownerDocument)==null?void 0:r.body),a=xt(o);if(i){const l=Va(a);return t.concat(a,a.visualViewport||[],kr(o)?o:[],l&&n?lr(l):[])}return t.concat(o,lr(o,[],n))}function Va(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function jm(e){const t=At(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Vt(e),i=o?e.offsetWidth:n,a=o?e.offsetHeight:r,l=Ro(n)!==i||Ro(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function ic(e){return Mt(e)?e:e.contextElement}function ys(e){const t=ic(e);if(!Vt(t))return Ht(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:i}=jm(t);let a=(i?Ro(n.width):n.width)/r,l=(i?Ro(n.height):n.height)/o;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const __=Ht(0);function km(e){const t=xt(e);return!oc()||!t.visualViewport?__:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function N_(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==xt(e)?!1:t}function Kn(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),i=ic(e);let a=Ht(1);t&&(r?Mt(r)&&(a=ys(r)):a=ys(e));const l=N_(i,n,r)?km(i):Ht(0);let u=(o.left+l.x)/a.x,d=(o.top+l.y)/a.y,f=o.width/a.x,p=o.height/a.y;if(i){const m=xt(i),h=r&&Mt(r)?xt(r):r;let g=m,y=Va(g);for(;y&&r&&h!==g;){const b=ys(y),w=y.getBoundingClientRect(),v=At(y),j=w.left+(y.clientLeft+parseFloat(v.paddingLeft))*b.x,k=w.top+(y.clientTop+parseFloat(v.paddingTop))*b.y;u*=b.x,d*=b.y,f*=b.x,p*=b.y,u+=j,d+=k,g=xt(y),y=Va(g)}}return Po({width:f,height:p,x:u,y:d})}function hi(e,t){const n=mi(e).scrollLeft;return t?t.left+n:Kn(Gt(e)).left+n}function Sm(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-hi(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function C_(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const i=o==="fixed",a=Gt(r),l=t?pi(t.floating):!1;if(r===a||l&&i)return n;let u={scrollLeft:0,scrollTop:0},d=Ht(1);const f=Ht(0),p=Vt(r);if((p||!p&&!i)&&(($s(r)!=="body"||kr(a))&&(u=mi(r)),Vt(r))){const h=Kn(r);d=ys(r),f.x=h.x+r.clientLeft,f.y=h.y+r.clientTop}const m=a&&!p&&!i?Sm(a,u):Ht(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+m.x,y:n.y*d.y-u.scrollTop*d.y+f.y+m.y}}function T_(e){return Array.from(e.getClientRects())}function E_(e){const t=Gt(e),n=mi(e),r=e.ownerDocument.body,o=mt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=mt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+hi(e);const l=-n.scrollTop;return At(r).direction==="rtl"&&(a+=mt(t.clientWidth,r.clientWidth)-o),{width:o,height:i,x:a,y:l}}const Du=25;function R_(e,t){const n=xt(e),r=Gt(e),o=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,u=0;if(o){i=o.width,a=o.height;const f=oc();(!f||f&&t==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const d=hi(r);if(d<=0){const f=r.ownerDocument,p=f.body,m=getComputedStyle(p),h=f.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,g=Math.abs(r.clientWidth-p.clientWidth-h);g<=Du&&(i-=g)}else d<=Du&&(i+=d);return{width:i,height:a,x:l,y:u}}const I_=new Set(["absolute","fixed"]);function P_(e,t){const n=Kn(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,i=Vt(e)?ys(e):Ht(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,u=o*i.x,d=r*i.y;return{width:a,height:l,x:u,y:d}}function Fu(e,t,n){let r;if(t==="viewport")r=R_(e,n);else if(t==="document")r=E_(Gt(e));else if(Mt(t))r=P_(t,n);else{const o=km(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Po(r)}function _m(e,t){const n=kn(e);return n===t||!Mt(n)||Rs(n)?!1:At(n).position==="fixed"||_m(n,t)}function M_(e,t){const n=t.get(e);if(n)return n;let r=lr(e,[],!1).filter(l=>Mt(l)&&$s(l)!=="body"),o=null;const i=At(e).position==="fixed";let a=i?kn(e):e;for(;Mt(a)&&!Rs(a);){const l=At(a),u=rc(a);!u&&l.position==="fixed"&&(o=null),(i?!u&&!o:!u&&l.position==="static"&&!!o&&I_.has(o.position)||kr(a)&&!u&&_m(e,a))?r=r.filter(f=>f!==a):o=l,a=kn(a)}return t.set(e,r),r}function A_(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const a=[...n==="clippingAncestors"?pi(t)?[]:M_(t,this._c):[].concat(n),r],l=a[0],u=a.reduce((d,f)=>{const p=Fu(t,f,o);return d.top=mt(p.top,d.top),d.right=jn(p.right,d.right),d.bottom=jn(p.bottom,d.bottom),d.left=mt(p.left,d.left),d},Fu(t,l,o));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function O_(e){const{width:t,height:n}=jm(e);return{width:t,height:n}}function z_(e,t,n){const r=Vt(t),o=Gt(t),i=n==="fixed",a=Kn(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const u=Ht(0);function d(){u.x=hi(o)}if(r||!r&&!i)if(($s(t)!=="body"||kr(o))&&(l=mi(t)),r){const h=Kn(t,!0,i,t);u.x=h.x+t.clientLeft,u.y=h.y+t.clientTop}else o&&d();i&&!r&&o&&d();const f=o&&!r&&!i?Sm(o,l):Ht(0),p=a.left+l.scrollLeft-u.x-f.x,m=a.top+l.scrollTop-u.y-f.y;return{x:p,y:m,width:a.width,height:a.height}}function Gi(e){return At(e).position==="static"}function Uu(e,t){if(!Vt(e)||At(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Gt(e)===n&&(n=n.ownerDocument.body),n}function Nm(e,t){const n=xt(e);if(pi(e))return n;if(!Vt(e)){let o=kn(e);for(;o&&!Rs(o);){if(Mt(o)&&!Gi(o))return o;o=kn(o)}return n}let r=Uu(e,t);for(;r&&b_(r)&&Gi(r);)r=Uu(r,t);return r&&Rs(r)&&Gi(r)&&!rc(r)?n:r||k_(e)||n}const L_=async function(e){const t=this.getOffsetParent||Nm,n=this.getDimensions,r=await n(e.floating);return{reference:z_(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function $_(e){return At(e).direction==="rtl"}const D_={convertOffsetParentRelativeRectToViewportRelativeRect:C_,getDocumentElement:Gt,getClippingRect:A_,getOffsetParent:Nm,getElementRects:L_,getClientRects:T_,getDimensions:O_,getScale:ys,isElement:Mt,isRTL:$_};function Cm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function F_(e,t){let n=null,r;const o=Gt(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const d=e.getBoundingClientRect(),{left:f,top:p,width:m,height:h}=d;if(l||t(),!m||!h)return;const g=qr(p),y=qr(o.clientWidth-(f+m)),b=qr(o.clientHeight-(p+h)),w=qr(f),j={rootMargin:-g+"px "+-y+"px "+-b+"px "+-w+"px",threshold:mt(0,jn(1,u))||1};let k=!0;function S(_){const C=_[0].intersectionRatio;if(C!==u){if(!k)return a();C?a(!1,C):r=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!Cm(d,e.getBoundingClientRect())&&a(),k=!1}try{n=new IntersectionObserver(S,{...j,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,j)}n.observe(e)}return a(!0),i}function U_(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=ic(e),f=o||i?[...d?lr(d):[],...lr(t)]:[];f.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const p=d&&l?F_(d,n):null;let m=-1,h=null;a&&(h=new ResizeObserver(w=>{let[v]=w;v&&v.target===d&&h&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(t)})),n()}),d&&!u&&h.observe(d),h.observe(t));let g,y=u?Kn(e):null;u&&b();function b(){const w=Kn(e);y&&!Cm(y,w)&&n(),y=w,g=requestAnimationFrame(b)}return n(),()=>{var w;f.forEach(v=>{o&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),p?.(),(w=h)==null||w.disconnect(),h=null,u&&cancelAnimationFrame(g)}}const B_=f_,q_=p_,H_=c_,V_=h_,W_=u_,Bu=l_,Z_=m_,K_=(e,t,n)=>{const r=new Map,o={platform:D_,...n},i={...o.platform,_c:r};return a_(e,t,{...o,platform:i})};var G_=typeof document<"u",J_=function(){},uo=G_?c.useLayoutEffect:J_;function Mo(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Mo(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const i=o[r];if(!(i==="_owner"&&e.$$typeof)&&!Mo(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function Tm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function qu(e,t){const n=Tm(e);return Math.round(t*n)/n}function Ji(e){const t=c.useRef(e);return uo(()=>{t.current=e}),t}function Y_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,p]=c.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[m,h]=c.useState(r);Mo(m,r)||h(r);const[g,y]=c.useState(null),[b,w]=c.useState(null),v=c.useCallback(V=>{V!==_.current&&(_.current=V,y(V))},[]),j=c.useCallback(V=>{V!==C.current&&(C.current=V,w(V))},[]),k=i||g,S=a||b,_=c.useRef(null),C=c.useRef(null),M=c.useRef(f),A=u!=null,I=Ji(u),N=Ji(o),P=Ji(d),$=c.useCallback(()=>{if(!_.current||!C.current)return;const V={placement:t,strategy:n,middleware:m};N.current&&(V.platform=N.current),K_(_.current,C.current,V).then(Y=>{const B={...Y,isPositioned:P.current!==!1};F.current&&!Mo(M.current,B)&&(M.current=B,Os.flushSync(()=>{p(B)}))})},[m,t,n,N,P]);uo(()=>{d===!1&&M.current.isPositioned&&(M.current.isPositioned=!1,p(V=>({...V,isPositioned:!1})))},[d]);const F=c.useRef(!1);uo(()=>(F.current=!0,()=>{F.current=!1}),[]),uo(()=>{if(k&&(_.current=k),S&&(C.current=S),k&&S){if(I.current)return I.current(k,S,$);$()}},[k,S,$,I,A]);const G=c.useMemo(()=>({reference:_,floating:C,setReference:v,setFloating:j}),[v,j]),X=c.useMemo(()=>({reference:k,floating:S}),[k,S]),U=c.useMemo(()=>{const V={position:n,left:0,top:0};if(!X.floating)return V;const Y=qu(X.floating,f.x),B=qu(X.floating,f.y);return l?{...V,transform:"translate("+Y+"px, "+B+"px)",...Tm(X.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:Y,top:B}},[n,l,X.floating,f.x,f.y]);return c.useMemo(()=>({...f,update:$,refs:G,elements:X,floatingStyles:U}),[f,$,G,X,U])}const X_=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Bu({element:r.current,padding:o}).fn(n):{}:r?Bu({element:r,padding:o}).fn(n):{}}}},Q_=(e,t)=>({...B_(e),options:[e,t]}),eN=(e,t)=>({...q_(e),options:[e,t]}),tN=(e,t)=>({...Z_(e),options:[e,t]}),nN=(e,t)=>({...H_(e),options:[e,t]}),sN=(e,t)=>({...V_(e),options:[e,t]}),rN=(e,t)=>({...W_(e),options:[e,t]}),oN=(e,t)=>({...X_(e),options:[e,t]});var iN="Arrow",Em=c.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...i}=e;return s.jsx(xe.svg,{...i,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});Em.displayName=iN;var aN=Em,ac="Popper",[Rm,gi]=un(ac),[lN,Im]=Rm(ac),Pm=e=>{const{__scopePopper:t,children:n}=e,[r,o]=c.useState(null),[i,a]=c.useState(void 0);return s.jsx(lN,{scope:t,anchor:r,onAnchorChange:o,placementState:i,setPlacementState:a,children:n})};Pm.displayName=ac;var Mm="PopperAnchor",Am=c.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,i=Im(Mm,n),a=c.useRef(null),l=i.onAnchorChange,u=c.useCallback(g=>{a.current=g,g&&l(g)},[l]),d=Ie(t,u),f=c.useRef(null);c.useEffect(()=>{if(!r)return;const g=f.current;f.current=r.current,g!==f.current&&l(f.current)});const p=i.placementState&&cc(i.placementState),m=p?.[0],h=p?.[1];return r?null:s.jsx(xe.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...o,ref:d})});Am.displayName=Mm;var lc="PopperContent",[cN,uN]=Rm(lc),Om=c.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:i="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:d=[],collisionPadding:f=0,sticky:p="partial",hideWhenDetached:m=!1,updatePositionStrategy:h="optimized",onPlaced:g,...y}=e,b=Im(lc,n),[w,v]=c.useState(null),j=Ie(t,v),[k,S]=c.useState(null),_=K5(k),C=_?.width??0,M=_?.height??0,A=r+(i!=="center"?"-"+i:""),I=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},N=Array.isArray(d)?d:[d],P=N.length>0,$={padding:I,boundary:N.filter(fN),altBoundary:P},{refs:F,floatingStyles:G,placement:X,isPositioned:U,middlewareData:V}=Y_({strategy:"fixed",placement:A,whileElementsMounted:(..._e)=>U_(..._e,{animationFrame:h==="always"}),elements:{reference:b.anchor},middleware:[Q_({mainAxis:o+M,alignmentAxis:a}),u&&eN({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?tN():void 0,...$}),u&&nN({...$}),sN({...$,apply:({elements:_e,rects:Ne,availableWidth:ce,availableHeight:de})=>{const{width:he,height:je}=Ne.reference,Ce=_e.floating.style;Ce.setProperty("--radix-popper-available-width",`${ce}px`),Ce.setProperty("--radix-popper-available-height",`${de}px`),Ce.setProperty("--radix-popper-anchor-width",`${he}px`),Ce.setProperty("--radix-popper-anchor-height",`${je}px`)}}),k&&oN({element:k,padding:l}),pN({arrowWidth:C,arrowHeight:M}),m&&rN({strategy:"referenceHidden",...$,boundary:P?$.boundary:void 0})]}),Y=b.setPlacementState;Ge(()=>(Y(X),()=>{Y(void 0)}),[X,Y]);const[B,W]=cc(X),me=Xe(g);Ge(()=>{U&&me?.()},[U,me]);const ve=V.arrow?.x,we=V.arrow?.y,D=V.arrow?.centerOffset!==0,[ie,te]=c.useState();return Ge(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),s.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:U?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ie,"--radix-popper-transform-origin":[V.transformOrigin?.x,V.transformOrigin?.y].join(" "),...V.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(cN,{scope:n,placedSide:B,placedAlign:W,onArrowChange:S,arrowX:ve,arrowY:we,shouldHideArrow:D,children:s.jsx(xe.div,{"data-side":B,"data-align":W,...y,ref:j,style:{...y.style,animation:U?void 0:"none"}})})})});Om.displayName=lc;var zm="PopperArrow",dN={top:"bottom",right:"left",bottom:"top",left:"right"},Lm=c.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,i=uN(zm,r),a=dN[i.placedSide];return s.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:s.jsx(aN,{...o,ref:n,style:{...o.style,display:"block"}})})});Lm.displayName=zm;function fN(e){return e!==null}var pN=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:r,middlewareData:o}=t,a=o.arrow?.centerOffset!==0,l=a?0:e.arrowWidth,u=a?0:e.arrowHeight,[d,f]=cc(n),p={start:"0%",center:"50%",end:"100%"}[f],m=(o.arrow?.x??0)+l/2,h=(o.arrow?.y??0)+u/2;let g="",y="";return d==="bottom"?(g=a?p:`${m}px`,y=`${-u}px`):d==="top"?(g=a?p:`${m}px`,y=`${r.floating.height+u}px`):d==="right"?(g=`${-u}px`,y=a?p:`${h}px`):d==="left"&&(g=`${r.floating.width+u}px`,y=a?p:`${h}px`),{data:{x:g,y}}}});function cc(e){const[t,n="center"]=e.split("-");return[t,n]}var $m=Pm,Dm=Am,Fm=Om,Um=Lm,Yi=!1;function mN(){const[e,t]=c.useState(Yi);return c.useEffect(()=>{Yi||(Yi=!0,t(!0))},[]),e}var Bm=Yo[" useSyncExternalStore ".trim().toString()];function hN(){return()=>{}}function gN(){return Bm(hN,()=>!0,()=>!1)}var xN=typeof Bm=="function"?gN:mN,Xi="rovingFocusGroup.onEntryFocus",bN={bubbles:!1,cancelable:!0},Sr="RovingFocusGroup",[Wa,qm,vN]=Fp(Sr),[yN,Hm]=un(Sr,[vN]),[wN,jN]=yN(Sr),Vm=c.forwardRef((e,t)=>s.jsx(Wa.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Wa.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(kN,{...e,ref:t})})}));Vm.displayName=Sr;var kN=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:i,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:d,preventScrollOnEntryFocus:f=!1,...p}=e,m=c.useRef(null),h=Ie(t,m),g=ai(i),[y,b]=Zn({prop:a,defaultProp:l??null,onChange:u,caller:Sr}),[w,v]=c.useState(!1),j=Xe(d),k=qm(n),S=c.useRef(!1),[_,C]=c.useState(0);return c.useEffect(()=>{const M=m.current;if(M)return M.addEventListener(Xi,j),()=>M.removeEventListener(Xi,j)},[j]),s.jsx(wN,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:c.useCallback(M=>b(M),[b]),onItemShiftTab:c.useCallback(()=>v(!0),[]),onFocusableItemAdd:c.useCallback(()=>C(M=>M+1),[]),onFocusableItemRemove:c.useCallback(()=>C(M=>M-1),[]),children:s.jsx(xe.div,{tabIndex:w||_===0?-1:0,"data-orientation":r,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{S.current=!0}),onFocus:fe(e.onFocus,M=>{const A=!S.current;if(M.target===M.currentTarget&&A&&!w){const I=new CustomEvent(Xi,bN);if(M.currentTarget.dispatchEvent(I),!I.defaultPrevented){const N=k().filter(X=>X.focusable),P=N.find(X=>X.active),$=N.find(X=>X.id===y),G=[P,$,...N].filter(Boolean).map(X=>X.ref.current);Km(G,f)}}S.current=!1}),onBlur:fe(e.onBlur,()=>v(!1))})})}),Wm="RovingFocusGroupItem",Zm=c.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:i,children:a,...l}=e,u=qt(),d=i||u,f=jN(Wm,n),p=f.currentTabStopId===d,m=qm(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:y}=f,b=xN();return Ge(()=>{if(!(!b||!r))return h(),()=>g()},[b,r,h,g]),c.useEffect(()=>{if(!(b||!r))return h(),()=>g()},[b,r,h,g]),s.jsx(Wa.ItemSlot,{scope:n,id:d,focusable:r,active:o,children:s.jsx(xe.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...l,ref:t,onMouseDown:fe(e.onMouseDown,w=>{r?f.onItemFocus(d):w.preventDefault()}),onFocus:fe(e.onFocus,()=>f.onItemFocus(d)),onKeyDown:fe(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=NN(w,f.orientation,f.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let k=m().filter(S=>S.focusable).map(S=>S.ref.current);if(v==="last")k.reverse();else if(v==="prev"||v==="next"){v==="prev"&&k.reverse();const S=k.indexOf(w.currentTarget);k=f.loop?CN(k,S+1):k.slice(S+1)}setTimeout(()=>Km(k))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:y!=null}):a})})});Zm.displayName=Wm;var SN={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _N(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function NN(e,t,n){const r=_N(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return SN[r]}function Km(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function CN(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var TN=Vm,EN=Zm;function Za(e,[t,n]){return Math.min(n,Math.max(t,e))}function RN(e,t){return c.useReducer((n,r)=>t[n][r]??n,e)}var uc="ScrollArea",[Gm]=un(uc),[IN,_t]=Gm(uc),Jm=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:i=600,...a}=e,[l,u]=c.useState(null),[d,f]=c.useState(null),[p,m]=c.useState(null),[h,g]=c.useState(null),[y,b]=c.useState(null),[w,v]=c.useState(0),[j,k]=c.useState(0),[S,_]=c.useState(!1),[C,M]=c.useState(!1),A=Ie(t,u),I=ai(o);return s.jsx(IN,{scope:n,type:r,dir:I,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:f,content:p,onContentChange:m,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:S,onScrollbarXEnabledChange:_,scrollbarY:y,onScrollbarYChange:b,scrollbarYEnabled:C,onScrollbarYEnabledChange:M,onCornerWidthChange:v,onCornerHeightChange:k,children:s.jsx(xe.div,{dir:I,...a,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});Jm.displayName=uc;var Ym="ScrollAreaViewport",Xm=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...i}=e,a=_t(Ym,n),l=c.useRef(null),u=Ie(t,l,a.onViewportChange);return s.jsxs(s.Fragment,{children:[s.jsx(PN,{nonce:o}),s.jsx(xe.div,{"data-radix-scroll-area-viewport":"",...i,ref:u,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Xm.displayName=Ym;var PN=c.memo(({nonce:e})=>s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e}),(e,t)=>e.nonce===t.nonce),Jt="ScrollAreaScrollbar",Qm=c.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=_t(Jt,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:a}=o,l=e.orientation==="horizontal";return c.useEffect(()=>(l?i(!0):a(!0),()=>{l?i(!1):a(!1)}),[l,i,a]),o.type==="hover"?s.jsx(MN,{...r,ref:t,forceMount:n}):o.type==="scroll"?s.jsx(AN,{...r,ref:t,forceMount:n}):o.type==="auto"?s.jsx(eh,{...r,ref:t,forceMount:n}):o.type==="always"?s.jsx(dc,{...r,ref:t,"data-state":"visible"}):null});Qm.displayName=Jt;var MN=c.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=_t(Jt,e.__scopeScrollArea),[i,a]=c.useState(!1);return c.useEffect(()=>{const l=o.scrollArea;let u=0;if(l){const d=()=>{window.clearTimeout(u),a(!0)},f=()=>{u=window.setTimeout(()=>a(!1),o.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",f),()=>{window.clearTimeout(u),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",f)}}},[o.scrollArea,o.scrollHideDelay]),s.jsx(vt,{present:n||i,children:s.jsx(eh,{"data-state":i?"visible":"hidden",...r,ref:t})})}),AN=c.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=_t(Jt,e.__scopeScrollArea),i=e.orientation==="horizontal",a=bi(()=>u("SCROLL_END"),100),[l,u]=RN("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return c.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>u("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,o.scrollHideDelay,u]),c.useEffect(()=>{const d=o.viewport,f=i?"scrollLeft":"scrollTop";if(d){let p=d[f];const m=()=>{const h=d[f];p!==h&&(u("SCROLL"),a()),p=h};return d.addEventListener("scroll",m),()=>d.removeEventListener("scroll",m)}},[o.viewport,i,u,a]),s.jsx(vt,{present:n||l!=="hidden",children:s.jsx(dc,{"data-state":l==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),eh=c.forwardRef((e,t)=>{const n=_t(Jt,e.__scopeScrollArea),{forceMount:r,...o}=e,[i,a]=c.useState(!1),l=e.orientation==="horizontal",u=bi(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,f=n.viewport.offsetHeight<n.viewport.scrollHeight;a(l?d:f)}},10);return Is(n.viewport,u),Is(n.content,u),s.jsx(vt,{present:r||i,children:s.jsx(dc,{"data-state":i?"visible":"hidden",...o,ref:t})})}),dc=c.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=_t(Jt,e.__scopeScrollArea),i=c.useRef(null),a=c.useRef(0),[l,u]=c.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=oh(l.viewport,l.content),f={...r,sizes:l,onSizesChange:u,hasThumb:d>0&&d<1,onThumbChange:m=>i.current=m,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:m=>a.current=m};function p(m,h){return FN(m,a.current,l,h)}return n==="horizontal"?s.jsx(ON,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollLeft,h=Hu(m,l,o.dir);i.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollLeft=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollLeft=p(m,o.dir))}}):n==="vertical"?s.jsx(zN,{...f,ref:t,onThumbPositionChange:()=>{if(o.viewport&&i.current){const m=o.viewport.scrollTop,h=Hu(m,l);i.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:m=>{o.viewport&&(o.viewport.scrollTop=m)},onDragScroll:m=>{o.viewport&&(o.viewport.scrollTop=p(m))}}):null}),ON=c.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=_t(Jt,e.__scopeScrollArea),[a,l]=c.useState(),u=c.useRef(null),d=Ie(t,u,i.onScrollbarXChange);return c.useEffect(()=>{u.current&&l(getComputedStyle(u.current))},[u]),s.jsx(nh,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":xi(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.x),onDragScroll:f=>e.onDragScroll(f.x),onWheelScroll:(f,p)=>{if(i.viewport){const m=i.viewport.scrollLeft+f.deltaX;e.onWheelScroll(m),ah(m,p)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&a&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:Oo(a.paddingLeft),paddingEnd:Oo(a.paddingRight)}})}})}),zN=c.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,i=_t(Jt,e.__scopeScrollArea),[a,l]=c.useState(),u=c.useRef(null),d=Ie(t,u,i.onScrollbarYChange);return c.useEffect(()=>{u.current&&l(getComputedStyle(u.current))},[u]),s.jsx(nh,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":xi(n)+"px",...e.style},onThumbPointerDown:f=>e.onThumbPointerDown(f.y),onDragScroll:f=>e.onDragScroll(f.y),onWheelScroll:(f,p)=>{if(i.viewport){const m=i.viewport.scrollTop+f.deltaY;e.onWheelScroll(m),ah(m,p)&&f.preventDefault()}},onResize:()=>{u.current&&i.viewport&&a&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:Oo(a.paddingTop),paddingEnd:Oo(a.paddingBottom)}})}})}),[LN,th]=Gm(Jt),nh=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:i,onThumbPointerUp:a,onThumbPointerDown:l,onThumbPositionChange:u,onDragScroll:d,onWheelScroll:f,onResize:p,...m}=e,h=_t(Jt,n),[g,y]=c.useState(null),b=Ie(t,y),w=c.useRef(null),v=c.useRef(""),j=h.viewport,k=r.content-r.viewport,S=Xe(f),_=Xe(u),C=bi(p,10);function M(A){if(w.current){const I=A.clientX-w.current.left,N=A.clientY-w.current.top;d({x:I,y:N})}}return c.useEffect(()=>{const A=I=>{const N=I.target;g?.contains(N)&&S(I,k)};return document.addEventListener("wheel",A,{passive:!1}),()=>document.removeEventListener("wheel",A,{passive:!1})},[j,g,k,S]),c.useEffect(_,[r,_]),Is(g,C),Is(h.content,C),s.jsx(LN,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:Xe(i),onThumbPointerUp:Xe(a),onThumbPositionChange:_,onThumbPointerDown:Xe(l),children:s.jsx(xe.div,{...m,ref:b,style:{position:"absolute",...m.style},onPointerDown:fe(e.onPointerDown,A=>{A.button===0&&(A.target.setPointerCapture(A.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),M(A))}),onPointerMove:fe(e.onPointerMove,M),onPointerUp:fe(e.onPointerUp,A=>{const I=A.target;I.hasPointerCapture(A.pointerId)&&I.releasePointerCapture(A.pointerId),document.body.style.webkitUserSelect=v.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),Ao="ScrollAreaThumb",sh=c.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=th(Ao,e.__scopeScrollArea);return s.jsx(vt,{present:n||o.hasThumb,children:s.jsx($N,{ref:t,...r})})}),$N=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,i=_t(Ao,n),a=th(Ao,n),{onThumbPositionChange:l}=a,u=Ie(t,a.onThumbChange),d=c.useRef(void 0),f=bi(()=>{d.current&&(d.current(),d.current=void 0)},100);return c.useEffect(()=>{const p=i.viewport;if(p){const m=()=>{if(f(),!d.current){const h=UN(p,l);d.current=h,l()}};return l(),p.addEventListener("scroll",m),()=>p.removeEventListener("scroll",m)}},[i.viewport,f,l]),s.jsx(xe.div,{"data-state":a.hasThumb?"visible":"hidden",...o,ref:u,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:fe(e.onPointerDownCapture,p=>{const h=p.target.getBoundingClientRect(),g=p.clientX-h.left,y=p.clientY-h.top;a.onThumbPointerDown({x:g,y})}),onPointerUp:fe(e.onPointerUp,a.onThumbPointerUp)})});sh.displayName=Ao;var fc="ScrollAreaCorner",rh=c.forwardRef((e,t)=>{const n=_t(fc,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(DN,{...e,ref:t}):null});rh.displayName=fc;var DN=c.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=_t(fc,n),[i,a]=c.useState(0),[l,u]=c.useState(0),d=!!(i&&l),{onCornerWidthChange:f,onCornerHeightChange:p}=o;return Is(o.scrollbarX,()=>{const m=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(m),u(m)}),Is(o.scrollbarY,()=>{const m=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(m),a(m)}),c.useEffect(()=>()=>{f(0),p(0)},[f,p]),d?s.jsx(xe.div,{...r,ref:t,style:{width:i,height:l,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Oo(e){return e?parseInt(e,10):0}function oh(e,t){const n=e/t;return isNaN(n)?0:n}function xi(e){const t=oh(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function FN(e,t,n,r="ltr"){const o=xi(n),i=o/2,a=t||i,l=o-a,u=n.scrollbar.paddingStart+a,d=n.scrollbar.size-n.scrollbar.paddingEnd-l,f=n.content-n.viewport,p=r==="ltr"?[0,f]:[f*-1,0];return ih([u,d],p)(e)}function Hu(e,t,n="ltr"){const r=xi(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-o,a=t.content-t.viewport,l=i-r,u=n==="ltr"?[0,a]:[a*-1,0],d=Za(e,u);return ih([0,a],[0,l])(d)}function ih(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function ah(e,t){return e>0&&e<t}var UN=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function o(){const i={left:e.scrollLeft,top:e.scrollTop},a=n.left!==i.left,l=n.top!==i.top;(a||l)&&t(),n=i,r=window.requestAnimationFrame(o)})(),()=>window.cancelAnimationFrame(r)};function bi(e,t){const n=Xe(e),r=c.useRef(0);return c.useEffect(()=>()=>window.clearTimeout(r.current),[]),c.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Is(e,t){const n=Xe(t);Ge(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var BN=Jm,qN=Xm,HN=rh,VN=[" ","Enter","ArrowUp","ArrowDown"],WN=[" ","Enter"],Gn="Select",[vi,yi,ZN]=Fp(Gn),[Qn]=un(Gn,[ZN,gi]),wi=gi(),[KN,Tn]=Qn(Gn),[GN,JN]=Qn(Gn),YN="SelectProvider";function lh(e){const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:i,value:a,defaultValue:l,onValueChange:u,dir:d,name:f,autoComplete:p,disabled:m,required:h,form:g,internal_do_not_use_render:y}=e,b=wi(t),[w,v]=c.useState(null),[j,k]=c.useState(null),[S,_]=c.useState(!1),C=ai(d),[M,A]=Zn({prop:r,defaultProp:o??!1,onChange:i,caller:Gn}),[I,N]=Zn({prop:a,defaultProp:l,onChange:u,caller:Gn}),P=c.useRef(null),$=c.useRef(I);c.useEffect(()=>{const me=g?w?.ownerDocument.getElementById(g):w?.form;if(me instanceof HTMLFormElement){const ve=()=>N($.current);return me.addEventListener("reset",ve),()=>me.removeEventListener("reset",ve)}},[g,w,N]);const F=w?!!g||!!w.closest("form"):!0,[G,X]=c.useState(new Set),U=qt(),V=Array.from(G).map(me=>me.props.value).join(";"),Y=c.useCallback(me=>{X(ve=>new Set(ve).add(me))},[]),B=c.useCallback(me=>{X(ve=>{const we=new Set(ve);return we.delete(me),we})},[]),W={required:h,trigger:w,onTriggerChange:v,valueNode:j,onValueNodeChange:k,valueNodeHasChildren:S,onValueNodeHasChildrenChange:_,contentId:U,value:I,onValueChange:N,open:M,onOpenChange:A,dir:C,triggerPointerDownPosRef:P,disabled:m,name:f,autoComplete:p,form:g,nativeOptions:G,nativeSelectKey:V,isFormControl:F};return s.jsx($m,{...b,children:s.jsx(KN,{scope:t,...W,children:s.jsx(vi.Provider,{scope:t,children:s.jsx(GN,{scope:t,onNativeOptionAdd:Y,onNativeOptionRemove:B,children:mC(y)?y(W):n})})})})}lh.displayName=YN;var ch=e=>{const{__scopeSelect:t,children:n,...r}=e;return s.jsx(lh,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:o})=>s.jsxs(s.Fragment,{children:[n,o?s.jsx(Oh,{__scopeSelect:t}):null]})})};ch.displayName=Gn;var uh="SelectTrigger",dh=c.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,i=wi(n),a=Tn(uh,n),l=a.disabled||r,u=Ie(t,a.onTriggerChange),d=yi(n),f=c.useRef("touch"),[p,m,h]=zh(y=>{const b=d().filter(j=>!j.disabled),w=b.find(j=>j.value===a.value),v=Lh(b,y,w);v!==void 0&&a.onValueChange(v.value)}),g=y=>{l||(a.onOpenChange(!0),h()),y&&(a.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return s.jsx(Dm,{asChild:!0,...i,children:s.jsx(xe.button,{type:"button",role:"combobox","aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":ji(a.value)?"":void 0,...o,ref:u,onClick:fe(o.onClick,y=>{y.currentTarget.focus(),f.current!=="mouse"&&g(y)}),onPointerDown:fe(o.onPointerDown,y=>{f.current=y.pointerType;const b=y.target;b.hasPointerCapture(y.pointerId)&&b.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(g(y),y.preventDefault())}),onKeyDown:fe(o.onKeyDown,y=>{const b=p.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&m(y.key),!(b&&y.key===" ")&&VN.includes(y.key)&&(g(),y.preventDefault())})})})});dh.displayName=uh;var fh="SelectValue",ph=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:i,placeholder:a="",...l}=e,u=Tn(fh,n),{onValueNodeHasChildrenChange:d}=u,f=i!==void 0,p=Ie(t,u.onValueNodeChange);Ge(()=>{d(f)},[d,f]);const m=ji(u.value);return s.jsx(xe.span,{...l,asChild:m?!1:l.asChild,ref:p,style:{pointerEvents:"none"},children:s.jsx(c.Fragment,{children:m?a:i},m?"placeholder":"value")})});ph.displayName=fh;var XN="SelectIcon",mh=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return s.jsx(xe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});mh.displayName=XN;var hh="SelectPortal",[QN,eC]=Qn(hh,{forceMount:void 0}),gh=e=>{const{__scopeSelect:t,forceMount:n,...r}=e;return s.jsx(QN,{scope:e.__scopeSelect,forceMount:n,children:s.jsx(ci,{asChild:!0,...r})})};gh.displayName=hh;var Sn="SelectContent",xh=c.forwardRef((e,t)=>{const n=eC(Sn,e.__scopeSelect),{forceMount:r=n.forceMount,...o}=e,i=Tn(Sn,e.__scopeSelect),[a,l]=c.useState();return Ge(()=>{l(new DocumentFragment)},[]),s.jsx(vt,{present:r||i.open,children:({present:u})=>u?s.jsx(yh,{...o,ref:t}):s.jsx(bh,{...o,fragment:a})})});xh.displayName=Sn;var bh=c.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,fragment:o}=e;return o?Os.createPortal(s.jsx(vh,{scope:n,children:s.jsx(vi.Slot,{scope:n,children:s.jsx("div",{ref:t,children:r})})}),o):null});bh.displayName="SelectContentFragment";var Rt=10,[vh,En]=Qn(Sn),tC="SelectContentImpl",nC=Ts("SelectContent.RemoveScroll"),yh=c.forwardRef((e,t)=>{const{__scopeSelect:n}=e,{position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:i,onPointerDownOutside:a,side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b,...w}=e,v=Tn(Sn,n),[j,k]=c.useState(null),[S,_]=c.useState(null),C=Ie(t,k),[M,A]=c.useState(null),[I,N]=c.useState(null),P=yi(n),[$,F]=c.useState(!1),G=c.useRef(!1);c.useEffect(()=>{if(j)return nm(j)},[j]),Zp();const X=c.useCallback(te=>{const[_e,...Ne]=P().map(he=>he.ref.current),[ce]=Ne.slice(-1),de=document.activeElement;for(const he of te)if(he===de||(he?.scrollIntoView({block:"nearest"}),he===_e&&S&&(S.scrollTop=0),he===ce&&S&&(S.scrollTop=S.scrollHeight),he?.focus(),document.activeElement!==de))return},[P,S]),U=c.useCallback(()=>X([M,j]),[X,M,j]);c.useEffect(()=>{$&&U()},[$,U]);const{onOpenChange:V,triggerPointerDownPosRef:Y}=v;c.useEffect(()=>{if(j){let te={x:0,y:0};const _e=ce=>{te={x:Math.abs(Math.round(ce.pageX)-(Y.current?.x??0)),y:Math.abs(Math.round(ce.pageY)-(Y.current?.y??0))}},Ne=ce=>{te.x<=10&&te.y<=10?ce.preventDefault():ce.composedPath().includes(j)||V(!1),document.removeEventListener("pointermove",_e),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",_e),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",_e),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[j,V,Y]),c.useEffect(()=>{const te=()=>V(!1);return window.addEventListener("blur",te),window.addEventListener("resize",te),()=>{window.removeEventListener("blur",te),window.removeEventListener("resize",te)}},[V]);const[B,W]=zh(te=>{const _e=P().filter(de=>!de.disabled),Ne=_e.find(de=>de.ref.current===document.activeElement),ce=Lh(_e,te,Ne);ce&&setTimeout(()=>ce.ref.current?.focus())}),me=c.useCallback((te,_e,Ne)=>{const ce=!G.current&&!Ne;(v.value!==void 0&&v.value===_e||ce)&&(A(te),ce&&(G.current=!0))},[v.value]),ve=c.useCallback(()=>j?.focus(),[j]),we=c.useCallback((te,_e,Ne)=>{const ce=!G.current&&!Ne;(v.value!==void 0&&v.value===_e||ce)&&N(te)},[v.value]),D=r==="popper"?Ka:wh,ie=D===Ka?{side:l,sideOffset:u,align:d,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:g,hideWhenDetached:y,avoidCollisions:b}:{};return s.jsx(vh,{scope:n,content:j,viewport:S,onViewportChange:_,itemRefCallback:me,selectedItem:M,onItemLeave:ve,itemTextRefCallback:we,focusSelectedItem:U,selectedItemText:I,position:r,isPositioned:$,searchRef:B,children:s.jsx(Xl,{as:nC,allowPinchZoom:!0,children:s.jsx(Yl,{asChild:!0,trapped:v.open,onMountAutoFocus:te=>{te.preventDefault()},onUnmountAutoFocus:fe(o,te=>{v.trigger?.focus({preventScroll:!0}),te.preventDefault()}),children:s.jsx(li,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:te=>te.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:s.jsx(D,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:te=>te.preventDefault(),...w,...ie,onPlaced:()=>F(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:fe(w.onKeyDown,te=>{const _e=te.ctrlKey||te.altKey||te.metaKey;if(te.key==="Tab"&&te.preventDefault(),!_e&&te.key.length===1&&W(te.key),["ArrowUp","ArrowDown","Home","End"].includes(te.key)){let ce=P().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(te.key)&&(ce=ce.slice().reverse()),["ArrowUp","ArrowDown"].includes(te.key)){const de=te.target,he=ce.indexOf(de);ce=ce.slice(he+1)}setTimeout(()=>X(ce)),te.preventDefault()}})})})})})})});yh.displayName=tC;var sC="SelectItemAlignedPosition",wh=c.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,i=Tn(Sn,n),a=En(Sn,n),[l,u]=c.useState(null),[d,f]=c.useState(null),p=Ie(t,f),m=yi(n),h=c.useRef(!1),g=c.useRef(!0),{viewport:y,selectedItem:b,selectedItemText:w,focusSelectedItem:v}=a,j=c.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&y&&b&&w){const C=i.trigger.getBoundingClientRect(),M=d.getBoundingClientRect(),A=i.valueNode.getBoundingClientRect(),I=w.getBoundingClientRect();if(i.dir!=="rtl"){const de=I.left-M.left,he=A.left-de,je=C.left-he,Ce=C.width+je,Fe=Math.max(Ce,M.width),Ze=window.innerWidth-Rt,Ue=Za(he,[Rt,Math.max(Rt,Ze-Fe)]);l.style.minWidth=Ce+"px",l.style.left=Ue+"px"}else{const de=M.right-I.right,he=window.innerWidth-A.right-de,je=window.innerWidth-C.right-he,Ce=C.width+je,Fe=Math.max(Ce,M.width),Ze=window.innerWidth-Rt,Ue=Za(he,[Rt,Math.max(Rt,Ze-Fe)]);l.style.minWidth=Ce+"px",l.style.right=Ue+"px"}const N=m(),P=window.innerHeight-Rt*2,$=y.scrollHeight,F=window.getComputedStyle(d),G=parseInt(F.borderTopWidth,10),X=parseInt(F.paddingTop,10),U=parseInt(F.borderBottomWidth,10),V=parseInt(F.paddingBottom,10),Y=G+X+$+V+U,B=Math.min(b.offsetHeight*5,Y),W=window.getComputedStyle(y),me=parseInt(W.paddingTop,10),ve=parseInt(W.paddingBottom,10),we=C.top+C.height/2-Rt,D=P-we,ie=b.offsetHeight/2,te=b.offsetTop+ie,_e=G+X+te,Ne=Y-_e;if(_e<=we){const de=N.length>0&&b===N[N.length-1].ref.current;l.style.bottom="0px";const he=d.clientHeight-y.offsetTop-y.offsetHeight,je=Math.max(D,ie+(de?ve:0)+he+U),Ce=_e+je;l.style.height=Ce+"px"}else{const de=N.length>0&&b===N[0].ref.current;l.style.top="0px";const je=Math.max(we,G+y.offsetTop+(de?me:0)+ie)+Ne;l.style.height=je+"px",y.scrollTop=_e-we+y.offsetTop}l.style.margin=`${Rt}px 0`,l.style.minHeight=B+"px",l.style.maxHeight=P+"px",r?.(),requestAnimationFrame(()=>h.current=!0)}},[m,i.trigger,i.valueNode,l,d,y,b,w,i.dir,r]);Ge(()=>j(),[j]);const[k,S]=c.useState();Ge(()=>{d&&S(window.getComputedStyle(d).zIndex)},[d]);const _=c.useCallback(C=>{C&&g.current===!0&&(j(),v?.(),g.current=!1)},[j,v]);return s.jsx(oC,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:h,onScrollButtonChange:_,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:k},children:s.jsx(xe.div,{...o,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});wh.displayName=sC;var rC="SelectPopperPosition",Ka=c.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Rt,...i}=e,a=wi(n);return s.jsx(Fm,{...a,...i,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ka.displayName=rC;var[oC,pc]=Qn(Sn,{}),Ga="SelectViewport",jh=c.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,i=En(Ga,n),a=pc(Ga,n),l=Ie(t,i.onViewportChange),u=c.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(vi.Slot,{scope:n,children:s.jsx(xe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,d=>{const f=d.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:m}=a;if(m?.current&&p){const h=Math.abs(u.current-f.scrollTop);if(h>0){const g=window.innerHeight-Rt*2,y=parseFloat(p.style.minHeight),b=parseFloat(p.style.height),w=Math.max(y,b);if(w<g){const v=w+h,j=Math.min(g,v),k=v-j;p.style.height=j+"px",p.style.bottom==="0px"&&(f.scrollTop=k>0?k:0,p.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});jh.displayName=Ga;var kh="SelectGroup",[iC,aC]=Qn(kh),lC=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=qt();return s.jsx(iC,{scope:n,id:o,children:s.jsx(xe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});lC.displayName=kh;var Sh="SelectLabel",cC=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=aC(Sh,n);return s.jsx(xe.div,{id:o.id,...r,ref:t})});cC.displayName=Sh;var zo="SelectItem",[uC,_h]=Qn(zo),Nh=c.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:i,...a}=e,l=Tn(zo,n),u=En(zo,n),d=l.value===r,[f,p]=c.useState(i??""),[m,h]=c.useState(!1),g=Xe(j=>u.itemRefCallback?.(j,r,o)),y=Ie(t,g),b=qt(),w=c.useRef("touch"),v=()=>{o||(l.onValueChange(r),l.onOpenChange(!1))};return s.jsx(uC,{scope:n,value:r,disabled:o,textId:b,isSelected:d,onItemTextChange:c.useCallback(j=>{p(k=>k||(j?.textContent??"").trim())},[]),children:s.jsx(vi.ItemSlot,{scope:n,value:r,disabled:o,textValue:f,children:s.jsx(xe.div,{role:"option","aria-labelledby":b,"data-highlighted":m?"":void 0,"aria-selected":d&&m,"data-state":d?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...a,ref:y,onFocus:fe(a.onFocus,()=>h(!0)),onBlur:fe(a.onBlur,()=>h(!1)),onClick:fe(a.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:fe(a.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:fe(a.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:fe(a.onPointerMove,j=>{w.current=j.pointerType,o?u.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(a.onPointerLeave,j=>{j.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:fe(a.onKeyDown,j=>{o||j.target!==j.currentTarget||u.searchRef?.current!==""&&j.key===" "||(WN.includes(j.key)&&v(),j.key===" "&&j.preventDefault())})})})})});Nh.displayName=zo;var Qs="SelectItemText",Ch=c.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...i}=e,a=Tn(Qs,n),l=En(Qs,n),u=_h(Qs,n),d=JN(Qs,n),[f,p]=c.useState(null),m=Xe(v=>l.itemTextRefCallback?.(v,u.value,u.disabled)),h=Ie(t,p,u.onItemTextChange,m),g=f?.textContent,y=c.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:g},u.value),[u.disabled,u.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:w}=d;return Ge(()=>(b(y),()=>w(y)),[b,w,y]),s.jsxs(s.Fragment,{children:[s.jsx(xe.span,{id:u.textId,...i,ref:h}),u.isSelected&&a.valueNode&&!a.valueNodeHasChildren&&!ji(a.value)?Os.createPortal(i.children,a.valueNode):null]})});Ch.displayName=Qs;var Th="SelectItemIndicator",Eh=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return _h(Th,n).isSelected?s.jsx(xe.span,{"aria-hidden":!0,...r,ref:t}):null});Eh.displayName=Th;var Ja="SelectScrollUpButton",Rh=c.forwardRef((e,t)=>{const n=En(Ja,e.__scopeSelect),r=pc(Ja,e.__scopeSelect),[o,i]=c.useState(!1),a=Ie(t,r.onScrollButtonChange);return Ge(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollTop>0;i(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(Ph,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});Rh.displayName=Ja;var Ya="SelectScrollDownButton",Ih=c.forwardRef((e,t)=>{const n=En(Ya,e.__scopeSelect),r=pc(Ya,e.__scopeSelect),[o,i]=c.useState(!1),a=Ie(t,r.onScrollButtonChange);return Ge(()=>{if(n.viewport&&n.isPositioned){let l=function(){const d=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)<d;i(f)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),o?s.jsx(Ph,{...e,ref:a,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});Ih.displayName=Ya;var Ph=c.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,i=En("SelectScrollButton",n),a=c.useRef(null),l=yi(n),u=c.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return c.useEffect(()=>()=>u(),[u]),Ge(()=>{l().find(f=>f.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[l]),s.jsx(xe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{i.onItemLeave?.(),a.current===null&&(a.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{u()})})}),dC="SelectSeparator",fC=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(xe.div,{"aria-hidden":!0,...r,ref:t})});fC.displayName=dC;var Mh="SelectArrow",pC=c.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=wi(n);return En(Mh,n).position==="popper"?s.jsx(Um,{...o,...r,ref:t}):null});pC.displayName=Mh;var Ah="SelectBubbleInput",Oh=c.forwardRef(({__scopeSelect:e,...t},n)=>{const r=Tn(Ah,e),{value:o,onValueChange:i,required:a,disabled:l,name:u,autoComplete:d,form:f}=r,{nativeOptions:p,nativeSelectKey:m}=r,h=c.useRef(null),g=Ie(n,h),y=o??"",b=Z5(y),w=Array.from(p).some(v=>(v.props.value??"")==="");return c.useEffect(()=>{const v=h.current;if(!v)return;const j=window.HTMLSelectElement.prototype,S=Object.getOwnPropertyDescriptor(j,"value").set;if(b!==y&&S){const _=new Event("change",{bubbles:!0});S.call(v,y),v.dispatchEvent(_)}},[b,y]),s.jsxs(xe.select,{"aria-hidden":!0,required:a,tabIndex:-1,name:u,autoComplete:d,disabled:l,form:f,onChange:v=>i(v.target.value),...t,style:{...$p,...t.style},ref:g,defaultValue:y,children:[ji(o)&&!w?s.jsx("option",{value:""}):null,Array.from(p)]},m)});Oh.displayName=Ah;function mC(e){return typeof e=="function"}function ji(e){return e===""||e===void 0}function zh(e){const t=Xe(e),n=c.useRef(""),r=c.useRef(0),o=c.useCallback(a=>{const l=n.current+a;t(l),(function u(d){n.current=d,window.clearTimeout(r.current),d!==""&&(r.current=window.setTimeout(()=>u(""),1e3))})(l)},[t]),i=c.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return c.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,i]}function Lh(e,t,n){const o=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let a=hC(e,Math.max(i,0));o.length===1&&(a=a.filter(d=>d!==n));const u=a.find(d=>d.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==n?u:void 0}function hC(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ki="Tabs",[gC]=un(ki,[Hm]),$h=Hm(),[xC,mc]=gC(ki),Dh=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:i,orientation:a="horizontal",dir:l,activationMode:u="automatic",...d}=e,f=ai(l),[p,m]=Zn({prop:r,onChange:o,defaultProp:i??"",caller:ki});return s.jsx(xC,{scope:n,baseId:qt(),value:p,onValueChange:m,orientation:a,dir:f,activationMode:u,children:s.jsx(xe.div,{dir:f,"data-orientation":a,...d,ref:t})})});Dh.displayName=ki;var Fh="TabsList",Uh=c.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...o}=e,i=mc(Fh,n),a=$h(n);return s.jsx(TN,{asChild:!0,...a,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(xe.div,{role:"tablist","aria-orientation":i.orientation,...o,ref:t})})});Uh.displayName=Fh;var Bh="TabsTrigger",qh=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...i}=e,a=mc(Bh,n),l=$h(n),u=Wh(a.baseId,r),d=Zh(a.baseId,r),f=r===a.value;return s.jsx(EN,{asChild:!0,...l,focusable:!o,active:f,children:s.jsx(xe.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":d,"data-state":f?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:u,...i,ref:t,onMouseDown:fe(e.onMouseDown,p=>{!o&&p.button===0&&p.ctrlKey===!1?a.onValueChange(r):p.preventDefault()}),onKeyDown:fe(e.onKeyDown,p=>{o||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&a.onValueChange(r)}),onFocus:fe(e.onFocus,()=>{const p=a.activationMode!=="manual";!f&&!o&&p&&a.onValueChange(r)})})})});qh.displayName=Bh;var Hh="TabsContent",Vh=c.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:o,children:i,...a}=e,l=mc(Hh,n),u=Wh(l.baseId,r),d=Zh(l.baseId,r),f=r===l.value,p=c.useRef(f);return c.useEffect(()=>{const m=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(m)},[]),s.jsx(vt,{present:o||f,children:({present:m})=>s.jsx(xe.div,{"data-state":f?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":u,hidden:!m,id:d,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:m&&i})})});Vh.displayName=Hh;function Wh(e,t){return`${e}-trigger-${t}`}function Zh(e,t){return`${e}-content-${t}`}var bC=Dh,vC=Uh,yC=qh,wC=Vh,[Si]=un("Tooltip",[gi]),_i=gi(),Kh="TooltipProvider",jC=700,Xa="tooltip.open",[kC,hc]=Si(Kh),Gh=e=>{const{__scopeTooltip:t,delayDuration:n=jC,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:i}=e,a=c.useRef(!0),l=c.useRef(!1),u=c.useRef(0);return c.useEffect(()=>{const d=u.current;return()=>window.clearTimeout(d)},[]),s.jsx(kC,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:c.useCallback(()=>{r<=0||(window.clearTimeout(u.current),a.current=!1)},[r]),onClose:c.useCallback(()=>{r<=0||(window.clearTimeout(u.current),u.current=window.setTimeout(()=>a.current=!0,r))},[r]),isPointerInTransitRef:l,onPointerInTransitChange:c.useCallback(d=>{l.current=d},[]),disableHoverableContent:o,children:i})};Gh.displayName=Kh;var cr="Tooltip",[SC,_r]=Si(cr),Jh=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:o,onOpenChange:i,disableHoverableContent:a,delayDuration:l}=e,u=hc(cr,e.__scopeTooltip),d=_i(t),[f,p]=c.useState(null),m=qt(),h=c.useRef(0),g=a??u.disableHoverableContent,y=l??u.delayDuration,b=c.useRef(!1),[w,v]=Zn({prop:r,defaultProp:o??!1,onChange:C=>{C?(u.onOpen(),document.dispatchEvent(new CustomEvent(Xa))):u.onClose(),i?.(C)},caller:cr}),j=c.useMemo(()=>w?b.current?"delayed-open":"instant-open":"closed",[w]),k=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b.current=!1,v(!0)},[v]),S=c.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v(!1)},[v]),_=c.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{b.current=!0,v(!0),h.current=0},y)},[y,v]);return c.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),s.jsx($m,{...d,children:s.jsx(SC,{scope:t,contentId:m,open:w,stateAttribute:j,trigger:f,onTriggerChange:p,onTriggerEnter:c.useCallback(()=>{u.isOpenDelayedRef.current?_():k()},[u.isOpenDelayedRef,_,k]),onTriggerLeave:c.useCallback(()=>{g?S():(window.clearTimeout(h.current),h.current=0)},[S,g]),onOpen:k,onClose:S,disableHoverableContent:g,children:n})})};Jh.displayName=cr;var Qa="TooltipTrigger",Yh=c.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=_r(Qa,n),i=hc(Qa,n),a=_i(n),l=c.useRef(null),u=Ie(t,l,o.onTriggerChange),d=c.useRef(!1),f=c.useRef(!1),p=c.useCallback(()=>d.current=!1,[]);return c.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),s.jsx(Dm,{asChild:!0,...a,children:s.jsx(xe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:u,onPointerMove:fe(e.onPointerMove,m=>{m.pointerType!=="touch"&&!f.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:fe(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:fe(e.onPointerDown,()=>{o.open&&o.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:fe(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:fe(e.onBlur,o.onClose),onClick:fe(e.onClick,o.onClose)})})});Yh.displayName=Qa;var gc="TooltipPortal",[_C,NC]=Si(gc,{forceMount:void 0}),Xh=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=_r(gc,t);return s.jsx(_C,{scope:t,forceMount:n,children:s.jsx(vt,{present:n||i.open,children:s.jsx(ci,{asChild:!0,container:o,children:r})})})};Xh.displayName=gc;var Ps="TooltipContent",Qh=c.forwardRef((e,t)=>{const n=NC(Ps,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=_r(Ps,e.__scopeTooltip);return s.jsx(vt,{present:r||a.open,children:a.disableHoverableContent?s.jsx(eg,{side:o,...i,ref:t}):s.jsx(CC,{side:o,...i,ref:t})})}),CC=c.forwardRef((e,t)=>{const n=_r(Ps,e.__scopeTooltip),r=hc(Ps,e.__scopeTooltip),o=c.useRef(null),i=Ie(t,o),[a,l]=c.useState(null),{trigger:u,onClose:d}=n,f=o.current,{onPointerInTransitChange:p}=r,m=c.useCallback(()=>{l(null),p(!1)},[p]),h=c.useCallback((g,y)=>{const b=g.currentTarget,w={x:g.clientX,y:g.clientY},v=IC(w,b.getBoundingClientRect()),j=PC(w,v),k=MC(y.getBoundingClientRect()),S=OC([...j,...k]);l(S),p(!0)},[p]);return c.useEffect(()=>()=>m(),[m]),c.useEffect(()=>{if(u&&f){const g=b=>h(b,f),y=b=>h(b,u);return u.addEventListener("pointerleave",g),f.addEventListener("pointerleave",y),()=>{u.removeEventListener("pointerleave",g),f.removeEventListener("pointerleave",y)}}},[u,f,h,m]),c.useEffect(()=>{if(a){const g=y=>{const b=y.target,w={x:y.clientX,y:y.clientY},v=u?.contains(b)||f?.contains(b),j=!AC(w,a);v?m():j&&(m(),d())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[u,f,a,d,m]),s.jsx(eg,{...e,ref:i})}),[TC,EC]=Si(cr,{isInside:!1}),RC=dS("TooltipContent"),eg=c.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...l}=e,u=_r(Ps,n),d=_i(n),{onClose:f}=u;return c.useEffect(()=>(document.addEventListener(Xa,f),()=>document.removeEventListener(Xa,f)),[f]),c.useEffect(()=>{if(u.trigger){const p=m=>{m.target instanceof Node&&m.target.contains(u.trigger)&&f()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[u.trigger,f]),s.jsx(li,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:f,children:s.jsxs(Fm,{"data-state":u.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(RC,{children:r}),s.jsx(TC,{scope:n,isInside:!0,children:s.jsx(kS,{id:u.contentId,role:"tooltip",children:o||r})})]})})});Qh.displayName=Ps;var tg="TooltipArrow",ng=c.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=_i(n);return EC(tg,n).isInside?null:s.jsx(Um,{...o,...r,ref:t})});ng.displayName=tg;function IC(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function PC(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function MC(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}function AC(e,t){const{x:n,y:r}=e;let o=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const l=t[i],u=t[a],d=l.x,f=l.y,p=u.x,m=u.y;f>r!=m>r&&n<(p-d)*(r-f)/(m-f)+d&&(o=!o)}return o}function OC(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),zC(t)}function zC(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const o=e[r];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;n.length>=2;){const i=n[n.length-1],a=n[n.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))n.pop();else break}n.push(o)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var LC=Gh,$C=Jh,DC=Yh,FC=Xh,UC=Qh,BC=ng;function Wt({...e}){return s.jsx(rm,{"data-slot":"dialog",...e})}function Nr({...e}){return s.jsx(im,{"data-slot":"dialog-trigger",...e})}function qC({...e}){return s.jsx(lm,{"data-slot":"dialog-portal",...e})}function HC({className:e,...t}){return s.jsx(cm,{"data-slot":"dialog-overlay",className:L("fixed inset-0 z-40 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t})}function Zt({className:e,children:t,...n}){return s.jsxs(qC,{children:[s.jsx(HC,{}),s.jsxs(um,{"data-slot":"dialog-content",className:L("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-lg",e),...n,children:[t,s.jsxs(xm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[s.jsx(jr,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Yt({className:e,...t}){return s.jsx("div",{"data-slot":"dialog-header",className:L("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}function Xt({className:e,...t}){return s.jsx(pm,{"data-slot":"dialog-title",className:L("text-lg font-semibold leading-none tracking-tight",e),...t})}function Cr({className:e,...t}){return s.jsx(hm,{"data-slot":"dialog-description",className:L("text-sm text-muted-foreground",e),...t})}function sg({open:e,onOpenChange:t,title:n,description:r,confirmLabel:o="Confirm",variant:i="default",onConfirm:a}){return s.jsx(Wt,{open:e,onOpenChange:t,children:s.jsxs(Zt,{children:[s.jsx(Yt,{children:s.jsx(Xt,{children:n})}),s.jsx("p",{className:"text-sm text-muted-foreground",children:r}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(ee,{variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),s.jsx(ee,{variant:i,size:"sm",onClick:()=>{a(),t(!1)},children:o})]})]})})}const VC="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'%3e%3c/path%3e%3c/svg%3e",WC="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'%3e%3c/path%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23lobe-icons-codex-_R_0_)'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-codex-_R_0_'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'%3e%3c/stop%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%233941FF'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",ZC="data:image/svg+xml,%3csvg%20fill='%237dd3fc'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenCode%3c/title%3e%3cpath%20d='M16%206H8v12h8V6zm4%2016H4V2h16v20z'%3e%3c/path%3e%3c/svg%3e",KC="data:image/svg+xml,%3csvg%20fill='%23ff6900'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMiMo%20Code%3c/title%3e%3cpath%20d='M.958%2015.936a.459.459%200%2001.459.44v2.729a.46.46%200%2001-.918%200v-2.729a.459.459%200%2001.459-.44zm4.814-2.035a.46.46%200%2001.553.45v4.754a.458.458%200%2011-.918%200V15.48L3.74%2017.202a.462.462%200%2001-.655.016.462.462%200%2001-.065-.082L.628%2014.67a.459.459%200%2001.658-.637l2.124%202.187%202.127-2.188a.46.46%200%2001.235-.13zm2.068.004a.46.46%200%2001.458.445v4.755a.46.46%200%2001-.458.458.459.459%200%2001-.458-.458V14.35a.459.459%200%2001.458-.445zm1.973%202.014a.46.46%200%2001.46.457v2.729a.46.46%200%2001-.784.324.46.46%200%2001-.134-.324v-2.729a.46.46%200%2001.458-.458zm.002-2.045a.458.458%200%2001.328.157l2.127%202.19%202.125-2.19a.459.459%200%2001.784.318v4.756a.46.46%200%2001-.455.458.46.46%200%2001-.458-.458V15.48l-1.667%201.723a.46.46%200%2001-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46%200%2001-.008-.667.461.461%200%2001.338-.128zm6.797%201.206a.46.46%200%2001.53.651A1.966%201.966%200%200019.81%2018.4a.462.462%200%2001.623.18.46.46%200%2001-.181.624%202.863%202.863%200%2001-1.38.353l-.142-.004a2.88%202.88%200%2001-2.393-4.263.461.461%200%2001.274-.21zm.864-.931a2.884%202.884%200%20013.915%203.914.46.46%200%2001-.402.24l-.057-.004a.458.458%200%2001-.164-.055.46.46%200%2001-.182-.622%201.967%201.967%200%2000-2.669-2.67.459.459%200%2011-.441-.803zM9.59%206.368c1.481%200%201.696%201.202%201.696%201.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133%200-1.289-.03-1.384-1.136-.082-.932.675-1.61%202.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379%201.012-.567%201.764-.567zm4.427.1c1.263%200%202.082.97%202.083%202.15%200%201.181-.824%202.154-2.083%202.154-1.26%200-2.084-.972-2.084-2.152%200-1.18.82-2.153%202.084-2.153zm6.801.015c.68%200%201.202.465%201.197%201.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628%200-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22%201.22%200%2001.947-.516c.398%200%20.76.193.982.686a1.321%201.321%200%20011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311%208.07l2.14%202.602H4.24L2.725%208.796%201.21%2010.672H0L2.138%208.07.13%205.583h1.138l1.458%201.772zm4.149%203.317h-.916V6.644h.916v4.028zm16.99%200h-.916V6.644h.916v4.028zM9.925%208.71c-1.055%200-1.359.412-1.326.742.032.329.324.537.757.537a1.013%201.013%200%20001.014-.968l.002-.31h-.447zM14.018%207.3c-.663%200-1.184.487-1.184%201.32%200%20.832.52%201.32%201.184%201.32.662%200%201.182-.49%201.182-1.32%200-.832-.52-1.32-1.182-1.32zM6.417%205.001a.568.568%200%2001.587.582.588.588%200%2001-1.175%200A.57.57%200%20016.417%205zm16.991%200a.57.57%200%2001.592.582.588.588%200%2001-1.174%200%20.57.57%200%2001.357-.542.572.572%200%2001.225-.04z'%3e%3c/path%3e%3c/svg%3e",GC="/assets/agent-inspector-58K1_MsC.ico",JC={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function Hr(e){return e?.toLowerCase()??""}function is(e,t){for(const n of t)if(e.includes(n))return!0;return!1}function xc(e){const t=[Hr(e.userAgent),Hr(e.conversationId),Hr(e.clientProjectFolder)].join(" ");return is(t,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":is(t,["mimocode","mimo-code","mimo code"])?"mimo-code":is(t,["opencode","open-code","open code"])?"opencode":is(t,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":is(t,["codex desktop","codex-cli","openai-codex","codex"])?"codex":is(Hr(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function Ni(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return JC[e];case"unknown":return null}}function YC(e){switch(e){case"codex":case"opencode":case"mimo-code":case"claude-code":return"IDE";case"agent-inspector":case"ai-sdk":case"unknown":return"CLIENT"}}const XC={"agent-inspector":GC,codex:WC,opencode:ZC,"mimo-code":KC,"claude-code":VC},QC={"agent-inspector":"border-orange-700/15 bg-orange-500/[0.08] dark:border-orange-200/25 dark:bg-orange-300/[0.12]",codex:"border-cyan-700/15 bg-cyan-500/[0.08] dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",opencode:"border-sky-700/15 bg-sky-500/[0.09] dark:border-sky-200/25 dark:bg-sky-300/[0.12]","mimo-code":"border-orange-700/15 bg-orange-500/[0.09] dark:border-orange-200/25 dark:bg-orange-400/[0.12]","claude-code":"border-amber-700/15 bg-amber-500/[0.08] dark:border-amber-100/20 dark:bg-amber-300/[0.09]"},e3={"agent-inspector":"p-0.5 drop-shadow-[0_0_8px_rgba(251,146,60,0.35)]",codex:"p-0.5",opencode:"p-1 drop-shadow-[0_0_8px_rgba(125,211,252,0.35)]","mimo-code":"p-0.5 drop-shadow-[0_0_8px_rgba(255,105,0,0.35)]","claude-code":"p-0.5"};function Ci({client:e,className:t,decorative:n=!1}){if(e==="unknown")return null;const r=Ni(e);if(r===null)return null;if(e==="ai-sdk")return s.jsx("span",{className:L("inline-flex size-6 shrink-0 items-center justify-center rounded-md border border-cyan-700/15 bg-cyan-500/[0.08] text-[var(--inspector-status-cool)] shadow-sm dark:border-cyan-200/20 dark:bg-cyan-300/[0.08]",t),"aria-label":n?void 0:r,"aria-hidden":n?!0:void 0,title:r,children:s.jsx(jp,{className:"size-1/2","aria-hidden":"true"})});const o=XC[e];return s.jsx("span",{className:L("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",QC[e],t),"aria-label":n?void 0:r,"aria-hidden":n?!0:void 0,title:r,children:s.jsx("img",{src:o,alt:"",className:L("size-full object-contain",e3[e]),"aria-hidden":"true"})})}const t3="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='0%206.603%201192.672%201193.397'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m233.96%20800.215%20234.684-131.678%203.947-11.436-3.947-6.363h-11.436l-39.221-2.416-134.094-3.624-116.296-4.832-112.67-6.04-28.35-6.04-26.577-35.035%202.738-17.477%2023.84-16.027%2034.147%202.98%2075.463%205.155%20113.235%207.812%2082.147%204.832%20121.692%2012.644h19.329l2.738-7.812-6.604-4.832-5.154-4.832-117.182-79.41-126.845-83.92-66.443-48.321-35.92-24.484-18.12-22.953-7.813-50.093%2032.618-35.92%2043.812%202.98%2011.195%202.98%2044.375%2034.147%2094.792%2073.37%20123.786%2091.167%2018.12%2015.06%207.249-5.154.886-3.624-8.135-13.61-67.329-121.692-71.838-123.785-31.974-51.302-8.456-30.765c-2.98-12.645-5.154-23.275-5.154-36.242l37.127-50.416%2020.537-6.604%2049.53%206.604%2020.86%2018.121%2030.765%2070.39%2049.852%20110.818%2077.315%20150.684%2022.631%2044.698%2012.08%2041.396%204.51%2012.645h7.813v-7.248l6.362-84.886%2011.759-104.215%2011.436-134.094%203.946-37.772%2018.685-45.262%2037.127-24.482%2028.994%2013.852%2023.839%2034.148-3.303%2022.067-14.174%2092.134-27.785%20144.323-18.121%2096.644h10.55l12.08-12.08%2048.887-64.913%2082.147-102.685%2036.242-40.752%2042.282-45.02%2027.14-21.423h51.303l37.772%2056.135-16.913%2057.986-52.832%2067.007-43.812%2056.779-62.82%2084.563-39.22%2067.651%203.623%205.396%209.343-.886%20141.906-30.201%2076.671-13.852%2091.49-15.705%2041.396%2019.329%204.51%2019.65-16.269%2040.189-97.852%2024.16-114.764%2022.954-170.9%2040.43-2.093%201.53%202.416%202.98%2076.993%207.248%2032.94%201.771h80.617l150.12%2011.195%2039.222%2025.933%2023.517%2031.732-3.946%2024.16-60.403%2030.766-81.503-19.33-190.228-45.26-65.235-16.27h-9.02v5.397l54.362%2053.154%2099.624%2089.96%20124.752%20115.973%206.362%2028.671-16.027%2022.63-16.912-2.415-109.611-82.47-42.282-37.127-95.758-80.618h-6.363v8.456l22.067%2032.296%20116.537%20175.167%206.04%2053.719-8.456%2017.476-30.201%2010.55-33.181-6.04-68.215-95.758-70.39-107.84-56.778-96.644-6.926%203.947-33.503%20360.886-15.705%2018.443-36.243%2013.852-30.201-22.953-16.027-37.127%2016.027-73.37%2019.329-95.758%2015.704-76.107%2014.175-94.55%208.456-31.41-.563-2.094-6.927.886-71.275%2097.852-108.402%20146.497-85.772%2091.812-20.537%208.134-35.597-18.443%203.301-32.94%2019.893-29.315%20118.712-151.007%2071.597-93.583%2046.228-54.04-.322-7.813h-2.738l-315.302%20204.725-56.135%207.248-24.16-22.63%202.98-37.128%2011.435-12.08%2094.792-65.236-.322.323z'%20fill='%23d97757'/%3e%3c/svg%3e",n3="data:image/svg+xml,%3csvg%20height='2500'%20viewBox='-1%20-.1%20949.1%20959.8'%20width='2474'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m925.8%20456.3c10.4%2023.2%2017%2048%2019.7%2073.3%202.6%2025.3%201.3%2050.9-4.1%2075.8-5.3%2024.9-14.5%2048.8-27.3%2070.8-8.4%2014.7-18.3%2028.5-29.7%2041.2-11.3%2012.6-23.9%2024-37.6%2034-13.8%2010-28.5%2018.4-44.1%2025.3-15.5%206.8-31.7%2012-48.3%2015.4-7.8%2024.2-19.4%2047.1-34.4%2067.7-14.9%2020.6-33%2038.7-53.6%2053.6-20.6%2015-43.4%2026.6-67.6%2034.4-24.2%207.9-49.5%2011.8-75%2011.8-16.9.1-33.9-1.7-50.5-5.1-16.5-3.5-32.7-8.8-48.2-15.7s-30.2-15.5-43.9-25.5c-13.6-10-26.2-21.5-37.4-34.2-25%205.4-50.6%206.7-75.9%204.1-25.3-2.7-50.1-9.3-73.4-19.7-23.2-10.3-44.7-24.3-63.6-41.4s-35-37.1-47.7-59.1c-8.5-14.7-15.5-30.2-20.8-46.3s-8.8-32.7-10.6-49.6c-1.8-16.8-1.7-33.8.1-50.7%201.8-16.8%205.5-33.4%2010.8-49.5-17-18.9-31-40.4-41.4-63.6-10.3-23.3-17-48-19.6-73.3-2.7-25.3-1.3-50.9%204-75.8s14.5-48.8%2027.3-70.8c8.4-14.7%2018.3-28.6%2029.6-41.2s24-24%2037.7-34%2028.5-18.5%2044-25.3c15.6-6.9%2031.8-12%2048.4-15.4%207.8-24.3%2019.4-47.1%2034.3-67.7%2015-20.6%2033.1-38.7%2053.7-53.7%2020.6-14.9%2043.4-26.5%2067.6-34.4%2024.2-7.8%2049.5-11.8%2075-11.7%2016.9-.1%2033.9%201.6%2050.5%205.1s32.8%208.7%2048.3%2015.6c15.5%207%2030.2%2015.5%2043.9%2025.5%2013.7%2010.1%2026.3%2021.5%2037.5%2034.2%2024.9-5.3%2050.5-6.6%2075.8-4s50%209.3%2073.3%2019.6c23.2%2010.4%2044.7%2024.3%2063.6%2041.4%2018.9%2017%2035%2036.9%2047.7%2059%208.5%2014.6%2015.5%2030.1%2020.8%2046.3%205.3%2016.1%208.9%2032.7%2010.6%2049.6%201.8%2016.9%201.8%2033.9-.1%2050.8-1.8%2016.9-5.5%2033.5-10.8%2049.6%2017.1%2018.9%2031%2040.3%2041.4%2063.6zm-333.2%20426.9c21.8-9%2041.6-22.3%2058.3-39s30-36.5%2039-58.4c9-21.8%2013.7-45.2%2013.7-68.8v-223q-.1-.3-.2-.7-.1-.3-.3-.6-.2-.3-.5-.5-.3-.3-.6-.4l-80.7-46.6v269.4c0%202.7-.4%205.5-1.1%208.1-.7%202.7-1.7%205.2-3.1%207.6s-3%204.6-5%206.5a32.1%2032.1%200%200%201%20-6.5%205l-191.1%20110.3c-1.6%201-4.3%202.4-5.7%203.2%207.9%206.7%2016.5%2012.6%2025.5%2017.8%209.1%205.2%2018.5%209.6%2028.3%2013.2%209.8%203.5%2019.9%206.2%2030.1%208%2010.3%201.8%2020.7%202.7%2031.1%202.7%2023.6%200%2047-4.7%2068.8-13.8zm-455.1-151.4c11.9%2020.5%2027.6%2038.3%2046.3%2052.7%2018.8%2014.4%2040.1%2024.9%2062.9%2031s46.6%207.7%2070%204.6%2045.9-10.7%2066.4-22.5l193.2-111.5.5-.5q.2-.2.3-.6.2-.3.3-.6v-94l-233.2%20134.9c-2.4%201.4-4.9%202.4-7.5%203.2-2.7.7-5.4%201-8.2%201-2.7%200-5.4-.3-8.1-1-2.6-.8-5.2-1.8-7.6-3.2l-191.1-110.4c-1.7-1-4.2-2.5-5.6-3.4-1.8%2010.3-2.7%2020.7-2.7%2031.1s1%2020.8%202.8%2031.1c1.8%2010.2%204.6%2020.3%208.1%2030.1%203.6%209.8%208%2019.2%2013.2%2028.2zm-50.2-417c-11.8%2020.5-19.4%2043.1-22.5%2066.5s-1.5%2047.1%204.6%2070c6.1%2022.8%2016.6%2044.1%2031%2062.9%2014.4%2018.7%2032.3%2034.4%2052.7%2046.2l193.1%20111.6q.3.1.7.2h.7q.4%200%20.7-.2.3-.1.6-.3l81-46.8-233.2-134.6c-2.3-1.4-4.5-3.1-6.5-5a32.1%2032.1%200%200%201%20-5-6.5c-1.3-2.4-2.4-4.9-3.1-7.6-.7-2.6-1.1-5.3-1-8.1v-227.1c-9.8%203.6-19.3%208-28.3%2013.2-9%205.3-17.5%2011.3-25.5%2018-7.9%206.7-15.3%2014.1-22%2022.1-6.7%207.9-12.6%2016.5-17.8%2025.5zm663.3%20154.4c2.4%201.4%204.6%203%206.6%205%201.9%201.9%203.6%204.1%205%206.5%201.3%202.4%202.4%205%203.1%207.6.6%202.7%201%205.4.9%208.2v227.1c32.1-11.8%2060.1-32.5%2080.8-59.7%2020.8-27.2%2033.3-59.7%2036.2-93.7s-3.9-68.2-19.7-98.5-39.9-55.5-69.5-72.5l-193.1-111.6q-.3-.1-.7-.2h-.7q-.3.1-.7.2-.3.1-.6.3l-80.6%2046.6%20233.2%20134.7zm80.5-121h-.1v.1zm-.1-.1c5.8-33.6%201.9-68.2-11.3-99.7-13.1-31.5-35-58.6-63-78.2-28-19.5-61-30.7-95.1-32.2-34.2-1.4-68%206.9-97.6%2023.9l-193.1%20111.5q-.3.2-.5.5l-.4.6q-.1.3-.2.7-.1.3-.1.7v93.2l233.2-134.7c2.4-1.4%205-2.4%207.6-3.2%202.7-.7%205.4-1%208.1-1%202.8%200%205.5.3%208.2%201%202.6.8%205.1%201.8%207.5%203.2l191.1%20110.4c1.7%201%204.2%202.4%205.6%203.3zm-505.3-103.2c0-2.7.4-5.4%201.1-8.1.7-2.6%201.7-5.2%203.1-7.6%201.4-2.3%203-4.5%205-6.5%201.9-1.9%204.1-3.6%206.5-4.9l191.1-110.3c1.8-1.1%204.3-2.5%205.7-3.2-26.2-21.9-58.2-35.9-92.1-40.2-33.9-4.4-68.3%201-99.2%2015.5-31%2014.5-57.2%2037.6-75.5%2066.4-18.3%2028.9-28%2062.3-28%2096.5v223q.1.4.2.7.1.3.3.6.2.3.5.6.2.2.6.4l80.7%2046.6zm43.8%20294.7%20103.9%2060%20103.9-60v-119.9l-103.8-60-103.9%2060z'/%3e%3c/svg%3e",s3="data:image/svg+xml,%3csvg%20fill='none'%20height='1320'%20viewBox='3.771%206.973%2023.993%2017.652'%20width='2500'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='m27.501%208.469c-.252-.123-.36.111-.508.23-.05.04-.093.09-.135.135-.368.395-.797.652-1.358.621-.821-.045-1.521.213-2.14.842-.132-.776-.57-1.238-1.235-1.535-.349-.155-.701-.309-.944-.645-.171-.238-.217-.504-.303-.765-.054-.159-.108-.32-.29-.348-.197-.031-.274.135-.352.273-.31.567-.43%201.192-.419%201.825.028%201.421.628%202.554%201.82%203.36.136.093.17.186.128.321-.081.278-.178.547-.264.824-.054.178-.135.217-.324.14a5.448%205.448%200%200%201%20-1.719-1.169c-.848-.82-1.614-1.726-2.57-2.435-.225-.166-.449-.32-.681-.467-.976-.95.128-1.729.383-1.82.267-.096.093-.428-.77-.424s-1.653.293-2.659.677a2.782%202.782%200%200%201%20-.46.135%209.554%209.554%200%200%200%20-2.853-.1c-1.866.21-3.356%201.092-4.452%202.6-1.315%201.81-1.625%203.87-1.246%206.018.399%202.261%201.552%204.136%203.326%205.601%201.837%201.518%203.955%202.262%206.37%202.12%201.466-.085%203.1-.282%204.942-1.842.465.23.952.322%201.762.392.623.059%201.223-.031%201.687-.127.728-.154.677-.828.414-.953-2.132-.994-1.665-.59-2.09-.916%201.084-1.285%202.717-2.619%203.356-6.94.05-.343.007-.558%200-.837-.004-.168.034-.235.228-.254a4.084%204.084%200%200%200%201.529-.47c1.382-.757%201.938-1.997%202.07-3.485.02-.227-.004-.463-.243-.582zm-12.041%2013.391c-2.067-1.627-3.07-2.162-3.483-2.138-.387.021-.318.465-.233.754.089.285.205.482.368.732.113.166.19.414-.112.598-.666.414-1.823-.139-1.878-.166-1.347-.793-2.473-1.842-3.267-3.276-.765-1.38-1.21-2.861-1.284-4.441-.02-.383.093-.518.472-.586a4.692%204.692%200%200%201%201.514-.04c2.109.31%203.905%201.255%205.41%202.749.86.853%201.51%201.871%202.18%202.865.711%201.057%201.478%202.063%202.454%202.887.343.289.619.51.881.672-.792.088-2.117.107-3.022-.61zm.99-6.38a.304.304%200%201%201%20.609%200c0%20.17-.136.304-.306.304a.3.3%200%200%201%20-.303-.305zm3.077%201.581c-.197.08-.394.15-.584.159a1.246%201.246%200%200%201%20-.79-.252c-.27-.227-.463-.354-.546-.752a1.752%201.752%200%200%201%20.016-.582c.07-.324-.008-.531-.235-.72-.187-.155-.422-.196-.682-.196a.551.551%200%200%201%20-.252-.078c-.108-.055-.197-.19-.112-.356.027-.053.159-.183.19-.207.352-.201.758-.135%201.134.016.349.142.611.404.99.773.388.448.457.573.678.906.174.264.333.534.441.842.066.192-.02.35-.248.448z'%20fill='%234d6bfe'/%3e%3c/svg%3e",r3="/assets/minimax-BPMzvuL-.jpeg",o3="/assets/alibaba-TTwafVwX.svg",i3="/assets/qwen-mMn3f5ul.webp",a3="/assets/zhipuai-BPNAnxo-.svg",l3={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function c3(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(n=>n.startsWith("glm-"))}function u3(e){if(e===null)return"unknown";const t=e.toLowerCase();if(c3(t))return"zhipuai";for(const[n,r]of Object.entries(l3))if(t.startsWith(n.toLowerCase()))return r;return"unknown"}const es={width:24,height:24,objectFit:"contain"},d3=Jn.memo(({className:e})=>s.jsx("img",{src:t3,alt:"Anthropic",className:e,style:es})),f3=Jn.memo(({className:e})=>s.jsx("img",{src:n3,alt:"OpenAI",className:e,style:{...es,background:"white",borderRadius:"4px"}})),p3=Jn.memo(({className:e})=>s.jsx("img",{src:s3,alt:"DeepSeek",className:e,style:es})),m3=Jn.memo(({className:e})=>s.jsx("img",{src:r3,alt:"MiniMax",className:e,style:es})),h3=Jn.memo(({className:e})=>s.jsx("img",{src:o3,alt:"Alibaba",className:e,style:es})),g3=Jn.memo(({className:e})=>s.jsx("img",{src:i3,alt:"Qwen",className:e,style:es})),x3=Jn.memo(({className:e})=>s.jsx("img",{src:a3,alt:"ZhipuAI",className:e,style:es}));function b3({provider:e,className:t}){switch(e){case"anthropic":return s.jsx(d3,{className:t});case"openai":return s.jsx(f3,{className:t});case"deepseek":return s.jsx(p3,{className:t});case"minimax":return s.jsx(m3,{className:t});case"alibaba":return s.jsx(h3,{className:t});case"qwen":return s.jsx(g3,{className:t});case"zhipuai":return s.jsx(x3,{className:t});case"unknown":return null}}function Ds({delayDuration:e=600,...t}){return s.jsx(LC,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function dt({...e}){return s.jsx($C,{"data-slot":"tooltip",...e})}function ft({...e}){return s.jsx(DC,{"data-slot":"tooltip-trigger",...e})}function pt({className:e,sideOffset:t=0,children:n,...r}){return s.jsx(FC,{children:s.jsxs(UC,{"data-slot":"tooltip-content",sideOffset:t,className:L("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...r,children:[n,s.jsx(BC,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const v3=3;function y3({items:e,ariaLabel:t,className:n}){if(e.length===0)return s.jsx("span",{className:L("flex h-8 w-12 shrink-0 items-center",n),"aria-hidden":"true"});const r=e.slice(0,v3),o=e.length-r.length;return s.jsx(Ds,{delayDuration:150,children:s.jsxs("span",{className:L("flex h-8 w-12 shrink-0 items-center",n),"aria-label":t,children:[r.map((i,a)=>s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsx("span",{className:L("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",a>0&&"-ml-2"),children:s.jsx(b3,{provider:i.provider,className:"size-4"})})}),s.jsx(pt,{children:i.tooltip})]},`${i.provider}-${String(a)}`)),o>0&&s.jsxs("span",{className:"border border-border bg-muted/40 -ml-2 inline-flex h-6 min-w-6 shrink-0 items-center justify-center rounded-md px-1 font-mono text-[10px] text-muted-foreground",children:["+",o]})]})})}const w3="/v1/chat/completions",j3="/chat/completions",k3="/v1/responses",S3="/responses",_3="/v1/messages";class N3{handlers=new Map;pathMap=new Map;register(t){this.handlers.set(t.format,t)}registerPath(t,n){this.pathMap.set(t,n)}get(t){return this.handlers.get(t)}getByPath(t){const n=t.split("?")[0]??"",r=this.pathMap.get(n);return r===void 0?void 0:this.handlers.get(r)}getApiFormatByPath(t){const n=t.split("?")[0]??"";return this.pathMap.get(n)}detectFormat(t){if(t===null)return"unknown";for(const n of this.handlers.values())if(n.detectFormat(t))return n.format;return"unknown"}}const Rn=new N3;function C3(e){return Rn.getApiFormatByPath(e)??"unknown"}Rn.registerPath(_3,"anthropic");Rn.registerPath(w3,"openai");Rn.registerPath(j3,"openai");Rn.registerPath(k3,"openai");Rn.registerPath(S3,"openai");function T3(e){if(e==="")return{};try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}catch{return{}}}function E3(e){switch(e.type){case"text":return{type:"text",text:e.text};case"thinking":{const t={type:"thinking",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"think":{const t={type:"think",thinking:e.thinking};return e.signature!==""&&(t.signature=e.signature),t}case"tool_use":return{type:"tool_use",id:e.id,name:e.name,input:T3(e.inputJson)}}}function rg(e,t,n,r){const o=new Map;let i="",a="",l=null,u=null,d=0,f=0;const p=1e3;let m=0,h=0;const g=[];for(const b of e.split(`
106
- `)){const w=b.trim();if(w.startsWith("data: "))try{const v=JSON.parse(w.slice(6)),j=my.safeParse(v);if(!j.success)continue;const k=j.data;switch(m===0&&(h=Date.now()),r===!0&&g.length<p&&g.push({index:m,timestamp:Date.now()-h,type:k.type,data:Wf(k)}),m++,k.type){case"message_start":i=k.message.id,a=k.message.model,d=k.message.usage.input_tokens,t.inputTokens=d,t.cacheCreationInputTokens=k.message.usage.cache_creation_input_tokens??null,t.cacheReadInputTokens=k.message.usage.cache_read_input_tokens??null,t.model===null&&(t.model=a);break;case"content_block_start":{const S=k.content_block;switch(S.type){case"text":o.set(k.index,{type:"text",text:S.text??""});break;case"thinking":o.set(k.index,{type:"thinking",thinking:S.thinking??"",signature:S.signature??""});break;case"think":o.set(k.index,{type:"think",thinking:S.thinking??"",signature:S.signature??""});break;case"tool_use":o.set(k.index,{type:"tool_use",id:S.id,name:S.name,inputJson:""});break}break}case"content_block_delta":{const S=o.get(k.index);if(S===void 0)break;const _=k.delta;_.type==="text_delta"&&S.type==="text"?S.text+=_.text:_.type==="thinking_delta"&&(S.type==="thinking"||S.type==="think")?S.thinking+=_.thinking:_.type==="signature_delta"&&(S.type==="thinking"||S.type==="think")?S.signature+=_.signature:_.type==="input_json_delta"&&S.type==="tool_use"&&(S.inputJson+=_.partial_json);break}case"message_delta":l=k.delta.stop_reason,u=k.delta.stop_sequence??null,f=k.usage.output_tokens,t.outputTokens=f,k.usage.cache_creation_input_tokens!==void 0&&(t.cacheCreationInputTokens=k.usage.cache_creation_input_tokens),k.usage.cache_read_input_tokens!==void 0&&(t.cacheReadInputTokens=k.usage.cache_read_input_tokens);break;case"error":t.error=k.error.message;break;case"content_block_stop":case"message_stop":case"ping":break}}catch{}}r===!0&&(t.streamingChunks={chunks:g,truncated:m>p});const y=[...o.entries()].sort(([b],[w])=>b-w).map(([,b])=>E3(b));return JSON.stringify({id:i,type:"message",model:a!==""?a:n??"",role:"assistant",content:y,stop_reason:l,stop_sequence:u,usage:{input_tokens:d,output_tokens:f}})}const R3={format:"anthropic",parseRequest(e,t){try{const n=JSON.parse(e),r=Yf.safeParse(n);return r.success?{model:r.data.model,sessionId:r.data.metadata?.user_id??t?.get("x-agent-inspector-session-id")??t?.get("x-session-affinity")??null}:null}catch{return null}},extractTokens(e){try{const t=JSON.parse(e),n=Xf.safeParse(t);if(n.success)return{inputTokens:n.data.usage.input_tokens??null,outputTokens:n.data.usage.output_tokens??null,cacheCreationInputTokens:n.data.usage.cache_creation_input_tokens??null,cacheReadInputTokens:n.data.usage.cache_read_input_tokens??null}}catch{}return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}},extractStream(e,t,n,r){return rg(e,t,n,r)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&n.includes("messages")&&n.includes("system")}return!1}catch{return!1}}};Rn.register(R3);class I3{providers=[];register(t){this.providers.push(t)}findProvider(t){let n=null;for(const r of this.providers)if(r.matches(t)){if(r.name!=="anthropic")return r;n=r}return n}getAll(){return[...this.providers]}}const Ti=new I3,P3="https://api.anthropic.com",M3={MiniMax:"https://api.minimaxi.com/anthropic"},A3={name:"anthropic",matches(e){const t=e.toLowerCase();if(t.startsWith("openai-"))return!1;if(t.includes("claude")||t.includes("anthropic"))return!0;for(const n of Object.keys(M3))if(t.startsWith(n.toLowerCase()))return!0;return!0},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:P3},extractStream(e,t,n,r){return rg(e,t,n,r)}};Ti.register(A3);const bc=1e3;function Tr(e,t){if(!(e===null||typeof e!="object"||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function nt(e,t){const n=Tr(e,t);return typeof n=="string"?n:null}function og(e,t){const n=Tr(e,t);return typeof n=="number"&&Number.isFinite(n)?n:null}function Lo(e,t){const n=Tr(e,t);return n!==null&&typeof n=="object"&&!Array.isArray(n)?n:null}function O3(e,t){const n=Tr(e,t);return Array.isArray(n)?n:[]}function z3(e){const t=[];let n=null,r=[];const o=()=>{n===null&&r.length===0||(t.push({event:n,data:r.join(`
107
- `)}),n=null,r=[])};for(const i of e.split(`
108
- `)){const a=i.endsWith("\r")?i.slice(0,-1):i;if(a===""){o();continue}if(a.startsWith(":"))continue;const l=a.indexOf(":"),u=l===-1?a:a.slice(0,l),d=l===-1?"":a.slice(l+1),f=d.startsWith(" ")?d.slice(1):d;switch(u){case"event":n=f;break;case"data":n===null&&r.length>0&&(f.startsWith("{")||f==="[DONE]")&&o(),r.push(f);break}}return o(),t}function vc(e){try{return JSON.parse(e)}catch{return null}}function ig(e,t){if(e.event!==null&&e.event!=="")return e.event;const n=Sy.safeParse(t);return n.success?n.data.type:""}function L3(e){if(e.data==="[DONE]")return!1;const t=vc(e.data),n=ig(e,t);return n.startsWith("response.")||n==="error"}function ag(e,t,n,r,o){e.length>=bc||e.push({index:t,timestamp:Date.now()-n,type:r,data:Wf(o)})}function el(e,t){const n=Lo(t,"error"),r=nt(n,"message")??nt(t,"message")??nt(t,"error");r!==null&&r.length>0&&(e.error=r)}function $3(e,t,n,r){let o="",i="",a="",l="",u=null,d=0,f=0,p=!1,m=!1;const h=new Map;let g=0,y=0;const b=[];for(const v of e){if(v.data==="[DONE]")break;const j=vc(v.data);if(j===null)continue;el(t,j);const k=wy.safeParse(j);if(!k.success)continue;const S=k.data;if(g===0&&(y=Date.now()),r&&ag(b,g,y,"chat.completion.chunk",S),g++,m||(o=S.id,i=S.model,m=!0),!p&&S.usage!==void 0&&S.usage!==null){d=S.usage.prompt_tokens??0,f=S.usage.completion_tokens??0,t.inputTokens=d;const _=Lo(j,"usage"),C=Lo(_,"prompt_tokens_details"),M=og(C,"cached_tokens");M!==null&&(t.cacheReadInputTokens=M),p=!0}for(const _ of S.choices){const C=_.delta;C.content!==void 0&&C.content!==null&&(a+=C.content),C.reasoning_content!==void 0&&C.reasoning_content!==null&&(l+=C.reasoning_content),C.thinking!==void 0&&C.thinking!==null&&(l+=C.thinking);const M=C.think;if(M!=null&&(l+=M),_.finish_reason!==void 0&&_.finish_reason!==null&&(u=_.finish_reason),C.tool_calls!==void 0&&C.tool_calls!==null)for(const A of C.tool_calls){let I=h.get(A.index);I===void 0&&(I={index:A.index,type:"function",function:{name:"",arguments:""}},h.set(A.index,I)),A.id!==void 0&&(I.id=A.id),A.function?.name!==void 0&&(I.function.name+=A.function.name),A.function?.arguments!==void 0&&(I.function.arguments+=A.function.arguments)}}}r&&(t.streamingChunks={chunks:b,truncated:g>bc}),p||(f=Math.ceil(a.length/4)),t.outputTokens=f;const w={role:"assistant",content:a};return l.length>0&&(w.reasoning_content=l),h.size>0&&(w.tool_calls=[...h.values()]),JSON.stringify({id:o,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:i!==""?i:n??"",choices:[{index:0,message:w,finish_reason:u}],usage:{prompt_tokens:d,completion_tokens:f,total_tokens:d+f}})}function D3(e){const t=jo.safeParse(Tr(e,"response"));if(t.success)return t.data;const n=jo.safeParse(e);return n.success?n.data:null}function lg(e){if(e.output_text!==void 0&&e.output_text.length>0)return e.output_text;const t=[];for(const n of e.output??[]){const r=O3(n,"content");for(const o of r){const i=nt(o,"type"),a=nt(o,"text");(i==="output_text"||i==="text")&&a!==null&&a.length>0&&t.push(a)}}return t.join(`
109
- `)}function Vu(e,t){const n=e.usage,r=n?.input_tokens??null,o=n?.output_tokens??null;r!==null&&(t.inputTokens=r),o!==null&&(t.outputTokens=o);const i=n?.input_tokens_details?.cached_tokens??null;return i!==null&&(t.cacheReadInputTokens=i),{inputTokens:r,outputTokens:o}}function Qi(e,t){const n=nt(e,"item_id");if(n!==null&&n.length>0)return n;const r=og(e,"output_index");return r!==null?String(r):`function-${String(t)}`}function tl(e,t){const n=e.get(t);if(n!==void 0)return n;const r={type:"function_call",arguments:""};return e.set(t,r),r}function F3(e,t,n){if(nt(n,"type")!=="function_call")return;const r=tl(e,t),o=nt(n,"id"),i=nt(n,"call_id"),a=nt(n,"name"),l=nt(n,"arguments"),u=nt(n,"status");o!==null&&(r.id=o),i!==null&&(r.call_id=i),a!==null&&(r.name=a),l!==null&&(r.arguments=l),u!==null&&(r.status=u)}function U3(e,t){const n=[];e.length>0&&n.push({type:"message",role:"assistant",content:[{type:"output_text",text:e,annotations:[]}]});for(const r of t.values())n.push(r);return n}function B3(e,t,n){const r=t??Math.ceil(n.length/4);return{input_tokens:e,output_tokens:r,total_tokens:e===null?r:e+r}}function q3(e){const t=e.completedResponse===null?"":lg(e.completedResponse),n=t.length>0?t:e.outputText,r=e.completedResponse?.output,o=r!==void 0&&r.length>0?r:U3(n,e.calls),i=e.completedResponse?.usage??B3(e.inputTokens,e.outputTokens,n);return{...e.completedResponse??{},id:e.completedResponse?.id??e.responseId,object:"response",created_at:e.completedResponse?.created_at??Math.floor(Date.now()/1e3),status:e.completedResponse?.status??e.status??"completed",model:e.completedResponse?.model??e.model,output:o,output_text:n,usage:i}}function H3(e,t,n,r){let o=null,i="",a=n??"",l=null,u="",d=null,f=null,p=0,m=0;const h=[],g=new Map;for(const w of e){if(w.data==="[DONE]")break;const v=vc(w.data);if(v===null)continue;const j=ig(w,v);if(p===0&&(m=Date.now()),r&&ag(h,p,m,j===""?"response.event":j,v),p++,el(t,v),j==="error")continue;const k=D3(v);if(k!==null){o=k,i=k.id,a=k.model??a,l=k.status??l;const _=Vu(k,t);d=_.inputTokens??d,f=_.outputTokens??f,el(t,k)}const S=nt(v,"delta");switch(j){case"response.output_text.delta":S!==null&&(u+=S);break;case"response.output_text.done":{const _=nt(v,"text");u.length===0&&_!==null&&(u=_);break}case"response.function_call_arguments.delta":{if(S!==null){const _=tl(g,Qi(v,g.size));_.arguments+=S}break}case"response.function_call_arguments.done":{const _=nt(v,"arguments");if(_!==null){const C=tl(g,Qi(v,g.size));C.arguments=_}break}case"response.output_item.added":case"response.output_item.done":{const _=Lo(v,"item");F3(g,Qi(v,g.size),_);break}case"response.failed":case"response.incomplete":l=j.slice(9);break;case"response.completed":l="completed";break}}r&&(t.streamingChunks={chunks:h,truncated:p>bc});const y=q3({completedResponse:o,responseId:i,model:a,status:l,outputText:u,calls:g,inputTokens:d,outputTokens:f}),b=jo.safeParse(y);if(b.success){if(Vu(b.data,t).outputTokens===null){const v=lg(b.data),j=Math.ceil(v.length/4);t.outputTokens=j}return JSON.stringify(b.data)}if(t.outputTokens===null){const w=nt(y,"output_text")??u,v=Math.ceil(w.length/4);t.outputTokens=v}return JSON.stringify(y)}function Ei(e,t,n,r=!0){const o=z3(e);return o.some(L3)?H3(o,t,n,r):$3(o,t,n,r)}const V3={sessionId:null,threadId:null,turnId:null,installationId:null,windowId:null};function nl(e,t){if(!(typeof e!="object"||e===null||Array.isArray(e)))return Object.getOwnPropertyDescriptor(e,t)?.value}function Dt(e,t){const n=nl(e,t);return typeof n=="string"&&n.length>0?n:null}function W3(e){if(typeof e!="string"||e.length===0)return null;try{return JSON.parse(e)}catch{return null}}function Z3(e){const t=nl(e,"client_metadata");if(t===void 0)return V3;const n=W3(nl(t,"x-codex-turn-metadata"));return{sessionId:Dt(t,"session_id")??Dt(n,"session_id"),threadId:Dt(t,"thread_id")??Dt(n,"thread_id"),turnId:Dt(t,"turn_id")??Dt(n,"turn_id"),installationId:Dt(t,"x-codex-installation-id")??Dt(n,"installation_id"),windowId:Dt(t,"x-codex-window-id")??Dt(n,"window_id")}}function Wu(e){return Z3(e).sessionId}function K3(){return{inputTokens:null,outputTokens:null,cacheCreationInputTokens:null,cacheReadInputTokens:null}}function Zu(e){return e===void 0?null:e.get("x-agent-inspector-session-id")??e.get("x-session-affinity")}const G3={format:"openai",parseRequest(e,t){try{const n=JSON.parse(e),r=tp.safeParse(n);if(r.success)return{model:r.data.model,sessionId:Wu(n)??Zu(t)};const o=np.safeParse(n);return o.success?{model:o.data.model,sessionId:Wu(n)??Zu(t)}:null}catch{return null}},extractTokens(e){const t=rp(e);if(t){let r=null;try{const o=JSON.parse(e);if(o!==null&&typeof o=="object"&&!Array.isArray(o)){const i=Object.getOwnPropertyDescriptor(o,"usage");if(i!==void 0&&typeof i.value=="object"&&i.value!==null){const a=Object.getOwnPropertyDescriptor(i.value,"prompt_tokens_details");if(a!==void 0&&typeof a.value=="object"&&a.value!==null){const l=Object.getOwnPropertyDescriptor(a.value,"cached_tokens");l!==void 0&&typeof l.value=="number"&&(r=l.value)}}}}catch{}return{inputTokens:t.usage.prompt_tokens??null,outputTokens:t.usage.completion_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r}}const n=op(e);if(n!==null){const r=n.usage;return{inputTokens:r?.input_tokens??null,outputTokens:r?.output_tokens??null,cacheCreationInputTokens:null,cacheReadInputTokens:r?.input_tokens_details?.cached_tokens??null}}return K3()},extractStream(e,t,n,r){return Ei(e,t,n,r)},detectFormat(e){if(e===null)return!1;try{const t=JSON.parse(e);if(typeof t=="object"&&t!==null&&!Array.isArray(t)){const n=Object.keys(t);return n.includes("model")&&(n.includes("messages")||n.includes("input"))&&!n.includes("system")}return!1}catch{return!1}}};Rn.register(G3);const J3="https://api.openai.com/v1",Y3={name:"openai",matches(e){const t=e.toLowerCase();return!!(t.startsWith("openai-")||t.includes("gpt-")||t.includes("o1")||t.includes("o2")||t.includes("o3"))},getUpstreamBase(e,t){return t?.baseUrl!==void 0?t.baseUrl:J3},extractStream(e,t,n,r){return Ei(e,t,n,r)}};Ti.register(Y3);const X3="https://open.bigmodel.cn/api/paas/v4",Q3=["glm-","charglm-","cogview-","embedding-","rerank-"],eT={name:"zhipu",matches(e){const t=e.toLowerCase().replace(/\s+/g,"-");return Q3.some(n=>t.startsWith(n))},getUpstreamBase(e,t){return t?.baseUrl??X3},extractStream(e,t,n,r){return Ei(e,t,n,r)}};Ti.register(eT);const tT="https://dashscope.aliyuncs.com/compatible-mode/v1",nT={name:"alibaba",matches(e){return!!e.toLowerCase().replace(/\s+/g,"-").startsWith("qwen")},getUpstreamBase(e,t){return tT},extractStream(e,t,n){return Ei(e,t,n)}};Ti.register(nT);function cg(e,t){for(const n of Array.from(e))t(n)}const sT=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function yc(e){if(e.length===0)return 0;let t=0,n=0;return cg(e,r=>{sT.test(r)?t+=1:n+=1}),Math.ceil(t*1)+Math.ceil(n/4)}function wc(e){if(e.length===0)return 0;let t=0;return cg(e,()=>{t+=1}),t}function jc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Q(e,t){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,t)?.value}const rT=["file","shell","browser","web","mcp","code","other"];function sl(e){const t=e.replace(/\s+/g," ").trim();return t.length<=120?t:`${t.slice(0,119)}...`}function ug(e){if(e===null)return null;const t=e.replace(/\s+/g," ").trim();if(t.length===0)return null;const n=t.search(/[.!?。!?]/);return n>=24?sl(t.slice(0,n+1)):sl(t)}function oT(e,t){return`${e} ${t??""}`.toLowerCase()}function as(e,t){return t.some(n=>e.includes(n))}function dg(e,t){const n=oT(e,t);return e.startsWith("mcp__")||e.startsWith("inspector_")||as(n,[" mcp","model context protocol"])?"mcp":as(n,["bash","shell","terminal","command","powershell","exec","process"])?"shell":as(n,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":as(n,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":as(n,["web","search","http","url","fetch"])?"web":as(n,["code","typescript","javascript","python","repl"])?"code":"other"}function fg(e){const t=Q(e,"properties");return t===null||typeof t!="object"||Array.isArray(t)?[]:Object.keys(t).sort((n,r)=>n.localeCompare(r))}function pg(e){const t=Q(e,"required");if(!Array.isArray(t))return[];const n=[];for(const r of t)typeof r=="string"&&r.length>0&&n.push(r);return n.sort((r,o)=>r.localeCompare(o))}function iT(e){const t=Q(e,"name");if(typeof t!="string"||t.length===0)return null;const n=Q(e,"description"),r=Q(e,"input_schema")??null,o=typeof n=="string"?n:null;return{name:t,description:o,descriptionPreview:ug(o),category:dg(t,o),parameterCount:fg(r).length,requiredParameters:pg(r),schema:r}}function aT(e){const t=Q(e,"function"),n=Q(e,"type");if(t===void 0&&typeof n!="string")return null;const r=Q(t,"name")??Q(e,"name")??(typeof n=="string"?n:void 0);if(typeof r!="string"||r.length===0)return null;const o=Q(t,"description")??Q(e,"description"),i=Q(t,"parameters")??Q(e,"parameters")??null,a=typeof o=="string"?o:null;return{name:r,description:a,descriptionPreview:ug(a),category:dg(r,a),parameterCount:fg(i).length,requiredParameters:pg(i),schema:i}}function lT(e){const t=aT(e);return t!==null?t:iT(e)}function cT(e){if(e==null)return null;if(typeof e=="string")return e;const t=Q(e,"type"),n=Q(e,"name"),r=Q(Q(e,"function"),"name");if(typeof t=="string"&&typeof r=="string"&&r.length>0)return`${t}: ${r}`;if(typeof t=="string"&&typeof n=="string"&&n.length>0)return`${t}: ${n}`;if(typeof t=="string")return t;const o=JSON.stringify(e);return o===void 0?null:sl(o)}function uT(e){const t=new Map;for(const n of e)t.set(n.category,(t.get(n.category)??0)+1);return rT.flatMap(n=>{const r=t.get(n)??0;return r>0?[{category:n,count:r}]:[]})}function kc(e){const t=Q(e,"tools");if(!Array.isArray(t)||t.length===0)return null;const n=[];for(const r of t){const o=lT(r);o!==null&&n.push(o)}return n.length===0?null:{tools:n,toolChoiceLabel:cT(Q(e,"tool_choice")),categories:uT(n)}}function Wn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const ws={parsed:null,toolNames:null};function dT(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n;switch(r.type){case"text":typeof r.text=="string"&&t.push(r.text);break;case"thinking":case"think":typeof r.thinking=="string"&&t.push(r.thinking);break;case"tool_use":{const i=typeof r.name=="string"?r.name:"",a=r.input!==void 0?JSON.stringify(r.input):"";t.push(`${i} ${a}`.trim());break}case"tool_result":{const i=r.content;if(typeof i=="string")t.push(i);else if(Array.isArray(i)){for(const a of i)if(a!==null&&typeof a=="object"){const l=a.text;typeof l=="string"&&t.push(l)}}break}case"image":t.push("[image]");break}}return t.join(`
110
- `)}function fT(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e)if(n!==null&&typeof n=="object"){const r=n.text;n.type==="text"&&typeof r=="string"&&t.push(r)}return t.join(`
111
- `)}function pT(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n;typeof r.name=="string"&&t.push(r.name),typeof r.description=="string"&&t.push(r.description),r.input_schema!==void 0&&t.push(JSON.stringify(r.input_schema))}return t.join(`
112
- `)}function ea(e,t,n,r){return{role:e,label:t,text:n,size:yc(n),characters:wc(n),path:r}}const mT={format:"anthropic",analyzeRequest(e){if(e===null)return Wn(e);try{const t=JSON.parse(e),n=kc(t)?.tools.length??null,r=Yf.safeParse(t);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:n}:Wn(e)}catch{return Wn(e)}},analyzeResponse(e){if(e===null)return ws;try{let t=JSON.parse(e);typeof t=="string"&&(t=JSON.parse(t));const n=Xf.safeParse(t);if(!n.success)return ws;const r=n.data.content.filter(o=>o.type==="tool_use").map(o=>o.name);return{parsed:n.data,toolNames:r.length>0?r:null}}catch{return ws}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(t.system!==void 0){const r=fT(t.system);r.length>0&&n.push(ea("system","system",r,"/system"))}if(Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"?i.role:"user",l=dT(i.content);n.push(ea(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.tools)&&t.tools.length>0){const r=pT(t.tools);n.push(ea("tools","tools",r,"/tools"))}return n.length>0?n:null}};function rl(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=n,o=r.type;(o==="text"||o==="input_text"||o==="output_text")&&typeof r.text=="string"?t.push(r.text):(o==="image_url"||o==="input_image")&&t.push("[image]")}return t.join(`
113
- `)}function hT(e){const t=[],n=rl(e.content);n.length>0&&t.push(n);const r=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";r.length>0&&t.push(r);const o=e.tool_calls;if(Array.isArray(o))for(const i of o){if(i===null||typeof i!="object")continue;const a=i.function;if(a===void 0)continue;const l=typeof a.name=="string"?a.name:"",u=typeof a.arguments=="string"?a.arguments:"";t.push(`${l} ${u}`.trim())}return t.join(`
114
- `)}function gT(e){if(!Array.isArray(e))return"";const t=[];for(const n of e){if(n===null||typeof n!="object")continue;const r=Q(n,"function"),o=Q(r,"name")??Q(n,"name"),i=Q(r,"description")??Q(n,"description"),a=Q(r,"parameters")??Q(n,"parameters");typeof o=="string"&&t.push(o),typeof i=="string"&&t.push(i),a!==void 0&&t.push(JSON.stringify(a))}return t.join(`
115
- `)}function xT(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function bT(e){if(typeof e=="string")return e;const t=Q(e,"text");if(typeof t=="string")return t;const n=rl(Q(e,"content"));if(n.length>0)return n;const r=rl(Q(e,"output"));if(r.length>0)return r;const o=Q(e,"arguments");return typeof o=="string"?o:""}function vT(e){const t=Q(e,"role");if(t==="system"||t==="user"||t==="assistant"||t==="tool")return t;const n=Q(e,"type");return n==="function_call_output"?"tool":"user"}function yT(e){const t=Q(e,"output");if(!Array.isArray(t))return[];const n=[];for(const r of t){if(Q(r,"type")!=="function_call")continue;const o=Q(r,"name");typeof o=="string"&&o.length>0&&n.push(o)}return n}function Hs(e,t,n,r){return{role:e,label:t,text:n,size:yc(n),characters:wc(n),path:r}}const wT={format:"openai",analyzeRequest(e){if(e===null)return Wn(e);try{const t=JSON.parse(e),n=kc(t)?.tools.length??null,r=tp.safeParse(t);if(!r.success){const o=np.safeParse(t);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:xT(o.data.input),toolCount:n}:Wn(e)}return{parsed:r.data,comparisonValue:r.data,messageCount:r.data.messages.length,toolCount:n}}catch{return Wn(e)}},analyzeResponse(e){if(e===null)return ws;const t=rp(e);if(t===null){const r=op(e);if(r===null)return ws;const o=yT(r);return{parsed:r,toolNames:o.length>0?o:null}}const n=t.choices[0]?.message?.tool_calls?.map(r=>r.function?.name??"").filter(r=>r!=="")??[];return{parsed:t,toolNames:n.length>0?n:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const t=e,n=[];if(typeof t.instructions=="string"&&t.instructions.length>0&&n.push(Hs("system","instructions",t.instructions,"/instructions")),Array.isArray(t.messages)&&t.messages.forEach((r,o)=>{if(r===null||typeof r!="object")return;const i=r,a=i.role==="user"||i.role==="assistant"||i.role==="system"||i.role==="tool"?i.role:"user",l=hT(i);n.push(Hs(a,`[${o}] ${a}`,l,`/messages/${o}`))}),Array.isArray(t.messages)||(typeof t.input=="string"&&t.input.length>0?n.push(Hs("user","input",t.input,"/input")):Array.isArray(t.input)&&t.input.forEach((r,o)=>{const i=vT(r),a=bT(r);n.push(Hs(i,`[${o}] ${i}`,a,`/input/${o}`))})),Array.isArray(t.tools)&&t.tools.length>0){const r=gT(t.tools);n.push(Hs("tools","tools",r,"/tools"))}return n.length>0?n:null}},jT={format:"unknown",analyzeRequest(e){return Wn(e)},analyzeResponse(){return ws},anatomySegments(){return null}},kT={anthropic:mT,openai:wT,unknown:jT};function mg(e){return kT[e]}function ur(e){const t=C3(e.path);return t==="unknown"?e.apiFormat:t}const Ku="inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground";function hg(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function ST(e){return hg(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function ta({icon:e,children:t,title:n,className:r}){return s.jsxs("span",{className:L("inline-flex h-7 min-w-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",r),title:n,children:[e,s.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:t})]})}function _T(){return s.jsxs("span",{className:"inline-flex h-6 shrink-0 items-center gap-1.5 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 font-mono text-[10px] uppercase text-[var(--inspector-status-watch)] ring-1 ring-border/50",title:"This session has a turn that has not finished yet",children:[s.jsx(De,{className:"size-3 animate-spin"}),"Turn open"]})}function NT({conversationId:e,startTime:t,endTime:n,totalCalls:r,totalInputTokens:o,totalOutputTokens:i,expanded:a,onToggle:l,providers:u,isLoading:d=!1,userAgent:f,clientPid:p,clientProjectFolder:m,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:y,onClear:b}){const[w,v]=c.useState(!1),j=G=>{G.stopPropagation(),b!==void 0&&v(!0)},k=c.useCallback(G=>{G.stopPropagation(),window.open(uf(e),"_blank","noopener,noreferrer")},[e]),S=u?.map(({provider:G,models:X})=>({provider:G,tooltip:X.length===1?X[0]??G:X.join(", ")}))??[],_=xc({userAgent:f,conversationId:e,clientProjectFolder:m}),C=Ni(_),M=f!=null&&f!=="",A=C??f??null,I=C!==null&&M?`${C} - ${f}`:null,N=hg(e),P=ST(e),$=oi(t,n,y),F=`${r} call${r!==1?"s":""}`;return s.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":a?"collapse":"expand",className:L("relative flex cursor-pointer items-start gap-2.5 overflow-hidden rounded-md bg-[var(--inspector-surface-low)] px-3 py-2.5 transition-colors","hover:bg-[var(--inspector-surface-medium)]","select-none","sticky top-0 z-10 mb-2","focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none"),onClick:l,onKeyDown:G=>{G.target===G.currentTarget&&(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),l())},children:[s.jsx(y3,{items:S,ariaLabel:"Models used in this session",className:"mt-0.5"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:"Session"}),N&&g?p!=null?s.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${p}`,children:["PID ",p]}):s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):s.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:P}),!N&&g&&p!==null&&p!==void 0&&s.jsxs("span",{className:"shrink-0 rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-xs tabular-nums text-muted-foreground",title:`Client process ID ${p}`,children:["PID ",p]}),N&&g&&m!==null&&m!==void 0&&m!==""&&s.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:m,children:m}),h&&A!==null&&A!==""&&s.jsxs("span",{className:"inline-flex min-h-6 shrink-0 flex-wrap items-center gap-1 rounded-md bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 text-xs text-muted-foreground",title:I??A,children:[s.jsx(Ci,{client:_,className:"size-4 shrink-0",decorative:!0}),s.jsx("span",{className:"font-mono leading-snug tabular-nums",children:A})]}),d&&s.jsx(_T,{})]}),s.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx(ta,{icon:s.jsx(sn,{className:"size-3 shrink-0"}),title:$,children:$}),s.jsx(ta,{icon:s.jsx(ri,{className:"size-3 shrink-0"}),children:F}),s.jsxs(ta,{icon:s.jsx(ar,{className:"size-3 shrink-0"}),className:"max-w-full",children:[s.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Pe(o)})," / ",s.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Pe(i)})]})]})]}),s.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[s.jsx("button",{type:"button",onClick:k,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&k(G)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:Ku,children:s.jsx(ql,{className:"size-3.5"})}),b!==void 0&&s.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${r} request${r!==1?"s":""})`,title:"Clear this group from the current view",className:Ku,children:s.jsx(wn,{className:"size-3.5"})}),s.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)] hover:text-foreground","aria-hidden":"true",children:a?s.jsx(et,{className:"size-4 shrink-0"}):d?s.jsx(De,{className:"size-4 shrink-0 animate-spin"}):s.jsx(bt,{className:"size-4 shrink-0"})})]}),d&&s.jsx("span",{className:"pointer-events-none absolute inset-x-3 bottom-0 h-px overflow-hidden rounded-full bg-[var(--inspector-surface-medium)]","aria-hidden":"true",children:s.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),s.jsx(sg,{open:w,onOpenChange:v,title:"Clear this group from the current view?",description:`This will hide ${r} request${r!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{b?.()}})]})}function CT(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const t=e.clientPid!==null&&e.clientPid!==void 0,n=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!t&&!n)return"default";const r=t?`PID:${e.clientPid}`:"unknown",o=n?e.clientProjectFolder:"no-folder";return`${r}|${o}`}function TT(e){const t=new Map;for(const r of e){const o=CT(r),i=t.get(o);i!==void 0?i.push(r):t.set(o,[r])}const n=[];for(const[r,o]of t){const i=[...o].sort((a,l)=>a.timestamp.localeCompare(l.timestamp));n.push({id:r,conversationId:r,logs:i})}return n.sort((r,o)=>(r.logs[0]?.timestamp??"").localeCompare(o.logs[0]?.timestamp??"")),n}function ET(e,t,n){const r=new Array(e);return new Proxy(r,{get(o,i,a){if(typeof i=="string"){const l=i.charCodeAt(0);if(l>=48&&l<=57){const u=+i;if(Number.isInteger(u)&&u>=0&&u<e){let d=o[u];if(!d){const f=t[u*2];d=o[u]={index:u,key:n(u),start:f,size:t[u*2+1],end:f+t[u*2+1],lane:0}}return d}}if(i==="length")return e}return Reflect.get(o,i,a)}})}function ls(e,t,n){let r=n.initialDeps??[],o,i=!0;function a(){const l=e();return(l.length!==r.length||l.some((d,f)=>r[f]!==d))&&(r=l,o=t(...l),n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(o),i=!1),o}return a.updateDeps=l=>{r=l},a}function Gu(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const RT=(e,t)=>Math.abs(e-t)<1.01,IT=(e,t,n)=>{let r;return function(...o){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,o),n)}};let Vs;const na=()=>{if(Vs!==void 0)return Vs;if(typeof navigator>"u")return Vs=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Vs=!0;const e=navigator.maxTouchPoints;return Vs=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Ju=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},PT=e=>e,MT=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,o=new Array(r);for(let i=0;i<r;i++)o[i]=t+i;return o},AT=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const o=a=>{const{width:l,height:u}=a;t({width:Math.round(l),height:Math.round(u)})};if(o(Ju(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(a=>{const l=()=>{const u=a[0];if(u?.borderBoxSize){const d=u.borderBoxSize[0];if(d){o({width:d.inlineSize,height:d.blockSize});return}}o(Ju(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},dr={passive:!0},OT=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=()=>{t({width:n.innerWidth,height:n.innerHeight})};return r(),n.addEventListener("resize",r,dr),()=>{n.removeEventListener("resize",r)}},zT=typeof window>"u"?!0:"onscrollend"in window,gg=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const o=e.targetWindow;if(!o)return;const i=e.options.useScrollendEvent&&zT;let a=0;const l=i?null:IT(o,()=>t(a,!1),e.options.isScrollingResetDelay),u=p=>()=>{a=n(r),l?.(),t(a,p)},d=u(!0),f=u(!1);return r.addEventListener("scroll",d,dr),i&&r.addEventListener("scrollend",f,dr),()=>{r.removeEventListener("scroll",d),i&&r.removeEventListener("scrollend",f)}},LT=(e,t)=>gg(e,t,n=>{const{horizontal:r,isRtl:o}=e.options;return r?n.scrollLeft*(o&&-1||1):n.scrollTop}),$T=(e,t)=>gg(e,t,n=>e.options.horizontal?n.scrollX:n.scrollY),DT=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),o=n.options.getItemKey(r);return n.itemSizeCache.get(o)??n.options.estimateSize(r)}if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),o=n.options.getItemKey(r),i=n.itemSizeCache.get(o);if(i!==void 0)return i}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},xg=(e,{adjustments:t=0,behavior:n},r)=>{var o,i;(i=(o=r.scrollElement)==null?void 0:o.scrollTo)==null||i.call(o,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},FT=xg,UT=xg;class BT{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,o;return((o=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:o.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(o=>{o.forEach(i=>{const a=()=>{const l=i.target,u=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[d,f]of this.elementsCache)if(f===l){this.elementsCache.delete(d);break}return}this.shouldMeasureDuringScroll(u)&&this.resizeItem(u,this.options.measureElement(l,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var o;(o=r())==null||o.disconnect(),n=null},observe:o=>{var i;return(i=r())==null?void 0:i.observe(o,{box:"border-box"})},unobserve:o=>{var i;return(i=r())==null?void 0:i.unobserve(o)}}})(),this.range=null,this.setOptions=n=>{var r,o;const i={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:PT,rangeExtractor:MT,onChange:()=>{},measureElement:DT,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const m in n){const h=n[m];h!==void 0&&(i[m]=h)}const a=this.options;let l=null,u=null,d=!1;if(a!==void 0&&a.enabled&&i.enabled&&i.anchorTo==="end"&&this.scrollElement!==null){const m=a.count,h=i.count,g=this.getMeasurements(),y=m>0?((r=g[0])==null?void 0:r.key)??a.getItemKey(0):null,b=m>0?((o=g[m-1])==null?void 0:o.key)??a.getItemKey(m-1):null;if(h!==m||m>0&&h>0&&(i.getItemKey(0)!==y||i.getItemKey(h-1)!==b)){d=!0;const j=m>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;j&&(l=[j.key,this.getScrollOffset()-j.start]);const k=i.followOnAppend===!0?"auto":i.followOnAppend||null;k&&h>m&&this.isAtEnd(a.scrollEndThreshold)&&(m===0||i.getItemKey(h-1)!==b)&&(u=k)}}this.options=i,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,p=0;if(l&&this.scrollOffset!==null){const[m,h]=l,g=this.getMeasurements(),{count:y,getItemKey:b}=this.options;let w=0;for(;w<y&&b(w)!==m;)w++;if(w<y){const v=g[w];if(v){const j=v.start+h;j!==this.scrollOffset&&(p=j-this.scrollOffset,this.scrollOffset=j,f=!0)}}}(f||u)&&(this.pendingScrollAnchor=[f?l[0]:null,f?l[1]:0,u,p])},this.notify=n=>{var r,o;(o=(r=this.options).onChange)==null||o.call(r,this,n)},this.maybeNotify=ls(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,a)=>{if(a&&this._intendedScrollOffset===null&&i===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(i-this._intendedScrollOffset)<1.5&&(i=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const l=this.getScrollOffset();this.scrollDirection=a?l===i?this.scrollDirection:l<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=a,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const i=this.scrollElement,a=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},l=()=>{this._iosTouching=!1,!(!na()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};i.addEventListener("touchstart",a,dr),i.addEventListener("touchend",l,dr),this.unsubs.push(()=>{i.removeEventListener("touchstart",a),i.removeEventListener("touchend",l),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const o=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,o&&this.scrollElement&&this.options.enabled){const[i,a,l,u]=o;i!==null&&!l&&(na()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?u!==0&&(this._iosDeferredAdjustment+=u):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),l&&this.scrollToEnd({behavior:l})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;const o=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=o,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=ls(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,r,o,i,a,l,u,d)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:u,gap:d}),{key:!1}),this.getMeasurements=ls(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:o,getItemKey:i,enabled:a,lanes:l,laneAssignmentMode:u,gap:d},f)=>{const p=this.itemSizeCache;if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const w of this.laneAssignments.keys())w>=n&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const w=n*2;let v=this._flatMeasurements;if(!v||v.length<w){const S=new Float64Array(w);v&&m>0&&S.set(v.subarray(0,m*2)),v=S,this._flatMeasurements=v}let j;if(m===0)j=r+o;else{const S=m-1;j=v[S*2]+v[S*2+1]+d}for(let S=m;S<n;S++){const _=i(S),C=p.get(_),M=typeof C=="number"?C:this.options.estimateSize(S);v[S*2]=j,v[S*2+1]=M,j+=M+d}const k=ET(n,v,i);return this.measurementsCache=k,k}const h=this.measurementsCache.slice(0,m),g=new Array(l).fill(void 0),y=new Float64Array(l);let b=0;for(let w=0;w<m;w++){const v=h[w];v&&(g[v.lane]===void 0&&b++,g[v.lane]=w,y[v.lane]=v.end)}for(let w=m;w<n;w++){const v=i(w),j=this.laneAssignments.get(w);let k,S;const _=u==="estimate"||p.has(v);if(j!==void 0&&this.options.lanes>1){k=j;const I=g[k],N=I!==void 0?h[I]:void 0;S=N?N.end+d:r+o}else if(b===l){let I=0,N=y[0],P=g[0];for(let $=1;$<l;$++){const F=y[$];(F<N||F===N&&g[$]<P)&&(I=$,N=F,P=g[$])}k=I,S=N+d,_&&this.laneAssignments.set(w,k)}else k=w%this.options.lanes,S=r+o,_&&this.laneAssignments.set(w,k);const C=p.get(v),M=typeof C=="number"?C:this.options.estimateSize(w),A=S+M;h[w]={index:w,start:S,size:M,end:A,key:v,lane:k},g[k]===void 0&&b++,g[k]=w,y[k]=A}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ls(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,o,i)=>n.length===0||r===0?(this.range=null,null):(this.range=HT(n,r,o,i,i===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ls(()=>{let n=null,r=null;const o=this.calculateRange();return o&&(n=o.startIndex,r=o.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,o,i,a)=>i===null||a===null?[]:n({startIndex:i,endIndex:a,overscan:r,count:o}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,o=n.getAttribute(r);return o?parseInt(o,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const o=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(o!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,o-i),l=Math.min(this.options.count-1,o+i);return n>=a&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((a,l)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(l))});return}const r=this.indexFromElement(n),o=this.options.getItemKey(r),i=this.elementsCache.get(o);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(o,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var o,i;if(n<0||n>=this.options.count)return;let a,l,u;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)u=this.options.getItemKey(n),l=d[n*2],a=d[n*2+1];else{const m=this.measurementsCache[n];if(!m)return;u=m.key,l=m.start,a=m.size}const f=this.itemSizeCache.get(u)??a,p=r-f;if(p!==0){const m=this.options.anchorTo==="end"&&((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=m?this.getTotalSize():0,g=((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:u,start:l,size:a,end:l+a,lane:0},p,this):l<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(u)||this.scrollDirection!=="backward"));(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(u,r),this.itemSizeCacheVersion++,m?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=ls(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const o=[];for(let i=0,a=n.length;i<a;i++){const l=n[i],u=r[l];o.push(u)}return o},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const o=this._flatMeasurements,i=this.options.lanes===1&&o!=null,a=bg(0,r.length-1,i?l=>o[l*2]:l=>Gu(r[l]).start,n);return Gu(r[a])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,o=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=n>=a+i?"end":"start"),r==="center"?n+=(o-i)/2:r==="end"&&(n-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getSize(),i=this.getScrollOffset(),a=this.measurementsCache[n];if(!a)return;if(r==="auto")if(a.end>=i+o-this.options.scrollPaddingEnd)r="end";else if(a.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const l=r==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,a.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:o="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),a=this.now();this.scrollState={index:null,align:r,behavior:o,startedAt:a,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:o="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);if(!i)return;const[a,l]=i,u=this.now();this.scrollState={index:n,align:l,behavior:o,startedAt:u,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const o=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let o;if(r.length===0)o=this.options.paddingStart;else if(this.options.lanes===1){const i=r.length-1,a=this._flatMeasurements;a!=null?o=a[i*2]+a[i*2+1]:o=((n=r[i])==null?void 0:n.end)??0}else{const i=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&i.some(l=>l===null);){const l=r[a];i[l.lane]===null&&(i[l.lane]=l.end),a--}o=Math.max(...i.filter(l=>l!==null))}return Math.max(o-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const o of r)o&&this.itemSizeCache.has(o.key)&&n.push({index:o.index,key:o.key,start:o.start,size:o.size,end:o.end,lane:o.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:o})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:o,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){t!==0&&(na()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=t:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,o=r?r[0]:this.scrollState.lastTargetOffset,i=1,a=o!==this.scrollState.lastTargetOffset;if(!a&&RT(o,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.getScrollOffset()!==o&&this._scrollToOffset(o,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,a){const l=this.getSize()||600,u=Math.abs(o-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&u>l;this.scrollState.lastTargetOffset=o,d||(this.scrollState.behavior="auto"),this._scrollToOffset(o,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const bg=(e,t,n,r)=>{for(;e<=t;){const o=(e+t)/2|0,i=n(o);if(i<r)e=o+1;else if(i>r)t=o-1;else return o}return e>0?e-1:0};function qT(e,t,n){let r=0;for(;r<=t;){const o=(r+t)/2|0,i=e[o*2];if(i<n)r=o+1;else if(i>n)t=o-1;else return o}return r>0?r-1:0}function HT(e,t,n,r,o){const i=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:i};if(r===1&&o!==null){const d=qT(o,i,n);let f=d;const p=n+t;for(;f<i&&o[f*2]+o[f*2+1]<p;)f++;return{startIndex:d,endIndex:f}}let l=bg(0,i,d=>e[d].start,n),u=l;if(r===1)for(;u<i&&e[u].end<n+t;)u++;else if(r>1){const d=Array(r).fill(0);for(;u<i&&d.some(p=>p<n+t);){const p=e[u];d[p.lane]=p.end,u++}const f=Array(r).fill(n+t);for(;l>=0&&f.some(p=>p>=n);){const p=e[l];f[p.lane]=p.start,l--}l=Math.max(0,l-l%r),u=Math.min(i,u+(r-1-u%r))}return{startIndex:l,endIndex:u}}const sa=typeof document<"u"?c.useLayoutEffect:c.useEffect;function vg({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const o=c.useReducer(d=>d+1,0)[1],i=c.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});i.current.enabled=t,i.current.mode=n;const a=d=>{const f=i.current;if(!f.enabled||!f.container)return;const p=d.getTotalSize();if(p!==f.lastSize){f.lastSize=p;const w=d.options.horizontal?"width":"height";f.container.style[w]=`${p}px`}const m=!!d.options.horizontal,h=f.mode==="transform",g=m?"left":"top",y=d.options.scrollMargin,b=d.getVirtualItems();for(const w of b){const v=w.start-y,j=d.elementsCache.get(w.key);j&&f.lastPositions.get(j)!==v&&(f.lastPositions.set(j,v),h?j.style.transform=m?`translate3d(${v}px, 0, 0)`:`translate3d(0, ${v}px, 0)`:j.style[g]=`${v}px`)}},l={...r,onChange:(d,f)=>{var p;const m=i.current;let h=!0;if(m.enabled){a(d);const g=d.range,y=m.prevRange;h=!y||y.isScrolling!==d.isScrolling||y.startIndex!==g?.startIndex||y.endIndex!==g?.endIndex,h&&(m.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:d.isScrolling}:null)}h&&(e&&f?Os.flushSync(o):o()),(p=r.onChange)==null||p.call(r,d,f)}},[u]=c.useState(()=>{const d=new BT(l);return Object.assign(d,{containerRef:f=>{const p=i.current;if(p.container=f,p.lastSize=null,f&&p.enabled){const m=d.getTotalSize();p.lastSize=m;const h=d.options.horizontal?"width":"height";f.style[h]=`${m}px`}}})});return u.setOptions(l),sa(()=>u._didMount(),[]),sa(()=>u._willUpdate()),sa(()=>{a(u)}),u}function VT(e){return vg({observeElementRect:AT,observeElementOffset:LT,scrollToFn:UT,...e})}function WT(e){return vg({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:OT,observeElementOffset:$T,scrollToFn:FT,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const cn="agent-inspector:focus-log";function Ms(e){window.dispatchEvent(new CustomEvent(cn,{detail:e}))}function Ri(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const t=e.detail,n=Q(t,"logId");if(typeof n!="number"||!Number.isInteger(n)||n<0)return null;const r=Q(t,"tab");switch(r){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const o=Q(t,"source"),i=Q(t,"toolCallIndex"),a=typeof i=="number"&&Number.isInteger(i)&&i>=0?{logId:n,tab:r??"request",toolCallIndex:i}:{logId:n,tab:r??"request"};switch(o){case"virtualizer":return{...a,source:o};case void 0:return a;default:return null}}function ZT(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function KT(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function GT(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function yg(e){if(e.responseText===null)return null;try{let t=JSON.parse(e.responseText);if(typeof t=="string"&&(t=JSON.parse(t)),!Xs(t))return null;if(typeof t.stop_reason=="string")return ZT(t.stop_reason);if(Array.isArray(t.choices))for(const n of t.choices){if(!Xs(n)||typeof n.finish_reason!="string")continue;const r=KT(n.finish_reason);if(r!==null)return r}if(Array.isArray(t.output)){for(const n of t.output)if(Xs(n)&&n.type==="function_call")return"tool_use";if(t.status==="completed")return"stop"}if(t.status==="incomplete"&&Xs(t.incomplete_details)){const n=t.incomplete_details.reason;if(typeof n=="string"&&GT(n))return"length"}return null}catch{return null}}function Sc(e){return e==="end_turn"||e==="stop"||e==="length"}function Nt({className:e,style:t,d:n,eyeStalks:r,eyes:o,legs:i,extras:a}){return s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:t,className:L("inline-block size-5",e),children:[s.jsx("path",{d:n}),r,o,i,a]})}const In=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),s.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),s.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),s.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),wg=s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),s.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),s.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),s.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function jg({className:e}){return s.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function JT({className:e}){return s.jsx(Nt,{className:e,d:"M4 13 C4 7 7.5 5.5 12 5.5 C16.5 5.5 20 7 20 13 C20 17.5 16.5 19 12 19 C7.5 19 4 17.5 4 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),s.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:wg,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),s.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function YT({className:e}){return s.jsx(Nt,{className:e,d:"M3 13.5 C3 8 7 6 12 6 C17 6 21 8 21 13.5 C21 17 17 19 12 19 C7 19 3 17 3 13.5 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),s.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),s.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function XT({className:e}){return s.jsx(Nt,{className:e,d:"M6 14 C6 8 9 5.5 12 5.5 C15 5.5 18 8 18 14 C18 18 15 20 12 20 C9 20 6 18 6 14 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),s.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),s.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),s.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),s.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),s.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function QT({className:e}){return s.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 L13 4 L14 7 C16 7 19 9 19 13 C19 16 16 18 13 18 L12 21 L11 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function e4({className:e}){return s.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),s.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"})]})})}function t4({className:e}){return s.jsx(Nt,{className:e,d:"M5.5 13.5 C5.5 10 8.5 8 12 8 C15.5 8 18.5 10 18.5 13.5 C18.5 16 15.5 17.5 12 17.5 C8.5 17.5 5.5 16 5.5 13.5 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),s.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),s.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:wg,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M6 11.5 C4.5 10.5 3 11 3.5 12.5 C4 13.5 5 13 5.5 12.5"}),s.jsx("path",{d:"M18 11.5 C19.5 10.5 21 11 20.5 12.5 C20 13.5 19 13 18.5 12.5"})]})})}function n4({className:e}){return s.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),s.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),s.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function s4({className:e}){return s.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),s.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function r4({className:e}){return s.jsx(Nt,{className:e,d:"M4.5 13 C4.5 8 7.5 6 12 6 C16.5 6 19.5 8 19.5 13 C19.5 17 16.5 18.5 12 18.5 C7.5 18.5 4.5 17 4.5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),s.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),s.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),s.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),s.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),s.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function o4({className:e}){return s.jsx(Nt,{className:e,d:"M5 13 C5 9 8 7 12 7 C16 7 19 9 19 13 C19 16 16 18 12 18 C8 18 5 16 5 13 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),s.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),s.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),s.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:In,extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),s.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),s.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function i4({className:e}){return s.jsx(Nt,{className:e,d:"M7 13.5 C7 10.5 9.5 9 12 9 C14.5 9 17 10.5 17 13.5 C17 16 14.5 17.5 12 17.5 C9.5 17.5 7 16 7 13.5 Z",eyeStalks:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),s.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),s.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),s.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),s.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),s.jsx("path",{d:"M16.5 12 C17.5 11 18.5 11.5 18 13 C17.5 14 17 13.5 16.5 13"})]})})}const ol=[jg,JT,YT,XT,QT,e4,t4,n4,s4,r4,o4,i4];function _c(e){return ol[Math.abs(e)%ol.length]??jg}function a4(e){const t=ol.length-2;return t<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%t+t)%t}function l4(e){return _c(a4(e))}const c4="x-anthropic-billing-header:";function u4(e){return e.trimStart().toLowerCase().startsWith(c4)}function d4(e){return jc(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function f4(e){if(!jc(e))return!1;const t=Q(e,"type"),n=Q(e,"text");return typeof t!="string"||t!=="text"||typeof n!="string"?!1:u4(n)}function p4(e){let t;try{t=JSON.parse(e)}catch{return{body:e,removed:0}}if(!d4(t))return{body:e,removed:0};const n=t.system;if(!Array.isArray(n)||n.length===0)return{body:e,removed:0};const r=[];let o=0;for(const i of n){if(f4(i)){o+=1;continue}r.push(i)}return o===0?{body:e,removed:0}:(r.length===0?delete t.system:t.system=r,{body:JSON.stringify(t),removed:o})}const m4=400,Yu=2e3;function h4(e){return Array.isArray(e)}function g4(e,t){const n=[e];let r=0;for(;n.length>0;){const o=n.pop();if(o!==void 0){if(r+=1,r>t)return r;if(!(o===null||typeof o!="object")){if(h4(o)){for(const i of o)n.push(i);continue}for(const i of Object.keys(o)){const a=o[i];a!==void 0&&n.push(a)}}}}return r}function x4(e){const t=g4(e,Yu+1);return t<=m4?{depth:Number.POSITIVE_INFINITY}:t<=Yu?{depth:3}:{depth:2}}function b4(e){try{const t=JSON.parse(e);return{kind:"json",data:$o(t)}}catch{return{kind:"text"}}}function ra(e){const t=c.useMemo(()=>e===null?null:b4(e),[e]),n=t?.kind==="json"?t.data:null,r=c.useMemo(()=>n===null?null:x4(n),[n]),[o,i]=c.useState(!1),[a,l]=c.useState(0),[u,d]=c.useState(0),[f,p]=c.useTransition(),m=c.useCallback(()=>{const h=!o,g=h&&r!==null?r.depth:0;p(()=>{i(h),l(g),d(y=>y+1)})},[o,r]);return{parsedData:n,policy:r,isExpanded:o,toggle:m,isPending:f,bulkDepth:a,bulkRevision:u}}function $o(e){if(e==null)return null;switch(typeof e){case"string":return e;case"number":return e;case"boolean":return e;case"object":{if(Array.isArray(e))return e.map(n=>$o(n));const t={};for(const n of Object.keys(e)){const r=Object.getOwnPropertyDescriptor(e,n);t[n]=$o(r?.value)}return t}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function kg({className:e,orientation:t="horizontal",...n}){return s.jsx(bC,{"data-slot":"tabs","data-orientation":t,orientation:t,className:L("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...n})}const v4=df("rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function Sg({className:e,variant:t="default",...n}){return s.jsx(vC,{"data-slot":"tabs-list","data-variant":t,className:L(v4({variant:t}),e),...n})}function gn({className:e,...t}){return s.jsx(yC,{"data-slot":"tabs-trigger",className:L("focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-muted-foreground hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent","data-[state=active]:border-border data-[state=active]:bg-background data-[state=active]:text-foreground","after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100",e),...t})}function jt({className:e,...t}){return s.jsx(wC,{"data-slot":"tabs-content",className:L("flex-1 outline-none",e),...t})}function bn(e){const[t,n]=c.useState(!1),r=c.useRef(null);c.useEffect(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);const o=c.useCallback(i=>{i.stopPropagation(),e!==null&&It(e).then(a=>{a&&(n(!0),r.current!==null&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),2e3))})},[e]);return{copied:t,copy:o}}const y4=c.lazy(()=>Kt(()=>import("./CompareDrawer-B3_TLTJh.js"),__vite__mapDeps([2,1])).then(e=>({default:e.CompareDrawer}))),w4=c.lazy(()=>Kt(()=>import("./InspectorPet-Cpn6hv4P.js"),__vite__mapDeps([3,1])).then(e=>({default:e.InspectorPet}))),j4=c.lazy(()=>Kt(()=>import("./ReplayDialog-B3EKVdJk.js"),__vite__mapDeps([4,1,5])).then(e=>({default:e.ReplayDialog}))),k4=c.lazy(()=>Kt(()=>import("./RequestAnatomy-COOQjyUC.js"),__vite__mapDeps([6,1])).then(e=>({default:e.RequestAnatomy}))),S4=c.lazy(()=>Kt(()=>import("./ResponseView-DBCjkwye.js"),__vite__mapDeps([5,1])).then(e=>({default:e.ResponseView}))),_4=c.lazy(()=>Kt(()=>import("./StreamingChunkSequence-CuXhDgMo.js"),__vite__mapDeps([7,1])).then(e=>({default:e.StreamingChunkSequence}))),il=c.lazy(()=>Kt(()=>import("./json-viewer-B-Ao6pwW.js"),__vite__mapDeps([8,1])).then(e=>({default:e.JsonViewer}))),N4=c.lazy(()=>Kt(()=>import("./json-viewer-B-Ao6pwW.js"),__vite__mapDeps([8,1])).then(e=>({default:e.JsonViewerFromString}))),C4=1200,T4=12;function E4(e){const{containerRef:t,setExpandToPath:n,ensureTabActive:r,highlightMs:o}=e,i=c.useRef(null);return c.useCallback(a=>{r?.(),n(a.path);const l=p=>{p.scrollIntoView({behavior:"smooth",block:"center"}),p.classList.add("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),i.current!==null&&clearTimeout(i.current),i.current=setTimeout(()=>{p.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),n(null)},o??C4)},d=`[data-anatomy-path="${(p=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(p):p.replace(/(["'\\[\](){}])/g,"\\$1"))(a.path)}"]`,f=p=>{const m=t.current;if(m!==null){const h=m.querySelector(d);if(h!==null){l(h);return}}p>0?window.requestAnimationFrame(()=>f(p-1)):n(null)};window.requestAnimationFrame(()=>f(T4))},[t,r,o,n])}const Xu="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function gs(e){return e<1024?`${e.toLocaleString()} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function R4(e,t){const n=[];return e!=null&&n.push(`Request ${gs(e)}`),t!=null&&n.push(`Response ${gs(t)}`),n.length===0?null:n.join(" · ")}function I4(e){if(e instanceof ni)return{title:"Full bodies timed out",detail:"The log store did not answer before the UI timeout. Compact metadata is still available; retry loading the bodies."};if(e instanceof Error){const t=e.message.trim();return{title:"Full bodies could not be loaded",detail:t===""?Xu:t}}return{title:"Full bodies could not be loaded",detail:Xu}}class _g{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const i=this.castInput(t,r),a=this.castInput(n,r),l=this.removeEmpty(this.tokenize(i,r)),u=this.removeEmpty(this.tokenize(a,r));return this.diffWithOptionsObj(l,u,r,o)}diffWithOptionsObj(t,n,r,o){var i;const a=v=>{if(v=this.postProcess(v,r),o){setTimeout(function(){o(v)},0);return}else return v},l=n.length,u=t.length;let d=1,f=l+u;r.maxEditLength!=null&&(f=Math.min(f,r.maxEditLength));const p=(i=r.timeout)!==null&&i!==void 0?i:1/0,m=Date.now()+p,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],n,t,0,r);if(h[0].oldPos+1>=u&&g+1>=l)return a(this.buildValues(h[0].lastComponent,n,t));let y=-1/0,b=1/0;const w=()=>{for(let v=Math.max(y,-d);v<=Math.min(b,d);v+=2){let j;const k=h[v-1],S=h[v+1];k&&(h[v-1]=void 0);let _=!1;if(S){const M=S.oldPos-v;_=S&&0<=M&&M<l}const C=k&&k.oldPos+1<u;if(!_&&!C){h[v]=void 0;continue}if(!C||_&&k.oldPos<S.oldPos?j=this.addToPath(S,!0,!1,0,r):j=this.addToPath(k,!1,!0,1,r),g=this.extractCommon(j,n,t,v,r),j.oldPos+1>=u&&g+1>=l)return a(this.buildValues(j.lastComponent,n,t))||!0;h[v]=j,j.oldPos+1>=u&&(b=Math.min(b,v-1)),g+1>=l&&(y=Math.max(y,v+1))}d++};if(o)(function v(){setTimeout(function(){if(d>f||Date.now()>m)return o(void 0);w()||v()},0)})();else for(;d<=f&&Date.now()<=m;){const v=w();if(v)return v}}addToPath(t,n,r,o,i){const a=t.lastComponent;return a&&!i.oneChangePerToken&&a.added===n&&a.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:a.count+1,added:n,removed:r,previousComponent:a.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:a}}}extractCommon(t,n,r,o,i){const a=n.length,l=r.length;let u=t.oldPos,d=u-o,f=0;for(;d+1<a&&u+1<l&&this.equals(r[u+1],n[d+1],i);)d++,u++,f++,i.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return f&&!i.oneChangePerToken&&(t.lastComponent={count:f,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=u,d}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const o=[];let i;for(;t;)o.push(t),i=t.previousComponent,delete t.previousComponent,t=i;o.reverse();const a=o.length;let l=0,u=0,d=0;for(;l<a;l++){const f=o[l];if(f.removed)f.value=this.join(r.slice(d,d+f.count)),d+=f.count;else{if(!f.added&&this.useLongestToken){let p=n.slice(u,u+f.count);p=p.map(function(m,h){const g=r[d+h];return g.length>m.length?g:m}),f.value=this.join(p)}else f.value=this.join(n.slice(u,u+f.count));u+=f.count,f.added||(d+=f.count)}}return o}}class P4 extends _g{constructor(){super(...arguments),this.tokenize=Cg}equals(t,n,r){return r.ignoreWhitespace?((!r.newlineIsToken||!t.includes(`
116
- `))&&(t=t.trim()),(!r.newlineIsToken||!n.includes(`
117
- `))&&(n=n.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(t.endsWith(`
118
- `)&&(t=t.slice(0,-1)),n.endsWith(`
119
- `)&&(n=n.slice(0,-1))),super.equals(t,n,r)}}const M4=new P4;function Ng(e,t,n){return M4.diff(e,t,n)}function Cg(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
120
- `));const n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const i=r[o];o%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}class A4 extends _g{constructor(){super(...arguments),this.tokenize=Cg}get useLongestToken(){return!0}castInput(t,n){const{undefinedReplacement:r,stringifyReplacer:o=(i,a)=>typeof a>"u"?r:a}=n;return typeof t=="string"?t:JSON.stringify(al(t,null,null,o),null," ")}equals(t,n,r){return super.equals(t.replace(/,([\r\n])/g,"$1"),n.replace(/,([\r\n])/g,"$1"),r)}}const O4=new A4;function z4(e,t,n){return O4.diff(e,t,n)}function al(e,t,n,r,o){t=t||[],n=n||[],r&&(e=r(o===void 0?"":o,e));let i;for(i=0;i<t.length;i+=1)if(t[i]===e)return n[i];let a;if(Object.prototype.toString.call(e)==="[object Array]"){for(t.push(e),a=new Array(e.length),n.push(a),i=0;i<e.length;i+=1)a[i]=al(e[i],t,n,r,String(i));return t.pop(),n.pop(),a}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){t.push(e),a={},n.push(a);const l=[];let u;for(u in e)Object.prototype.hasOwnProperty.call(e,u)&&l.push(u);for(l.sort(),i=0;i<l.length;i+=1)u=l[i],a[u]=al(e[u],t,n,r,u);t.pop(),n.pop()}else a=e;return a}function Qu(e){return e===void 0?[]:Object.entries(e).map(t=>[t[0].toLowerCase(),t[1]]).sort(([t],[n])=>t.localeCompare(n))}function ed([e,t]){return`${e}: ${t}`}function ll(e){const t=[];let n=0,r=0;for(const o of e){const i=o.value.split(`
121
- `);i.length>0&&i[i.length-1]===""&&i.pop();for(const a of i)o.added?(r+=1,t.push({kind:"added",text:a,oldLineNumber:null,newLineNumber:r})):o.removed?(n+=1,t.push({kind:"removed",text:a,oldLineNumber:n,newLineNumber:null})):(n+=1,r+=1,t.push({kind:"context",text:a,oldLineNumber:n,newLineNumber:r}))}return t}function L4(e,t){const n=Qu(e).map(ed).join(`
122
- `),r=Qu(t).map(ed).join(`
123
- `);if(n===r)return{lines:[],isEmpty:!0};const o=Ng(n,r);return{lines:ll(o),isEmpty:!1}}function td(e){try{const t=JSON.parse(e);return t===null||typeof t=="string"||typeof t=="object"?t:null}catch{return null}}function $4(e,t){const n=e??"",r=t??"";if(n===r)return{lines:[],isEmpty:!0};const o=td(n),i=td(r);if(o!==null&&i!==null){const l=z4(o,i)??[];if(l.length===1){const u=l[0];if(u!==void 0&&!u.added&&!u.removed)return{lines:[],isEmpty:!0}}return{lines:ll(l),isEmpty:!1}}const a=Ng(n,r);return{lines:ll(a),isEmpty:!1}}const D4=22,oa=1e4;function F4(e){return e==="added"?"+":e==="removed"?"-":" "}function U4(e){return e==="added"?"bg-green-500/10 text-green-700 dark:text-green-300":e==="removed"?"bg-red-500/10 text-red-700 dark:text-red-300":"text-foreground/80"}const B4=function({result:t,emptyLabel:n}){const[r,o]=c.useState("unified"),i=c.useRef(null),a=VT({count:t.lines.length,getScrollElement:()=>i.current,estimateSize:()=>D4,overscan:10});if(t.isEmpty)return s.jsx("div",{className:"rounded border border-dashed border-border bg-muted/30 px-4 py-6 text-center text-xs text-muted-foreground","data-testid":"diff-empty",children:n??"No transformation applied — raw and processed are identical."});const l=t.lines.length,u=l>oa,d=u?t.lines.slice(0,oa):t.lines;return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[l.toLocaleString()," line",l===1?"":"s",u&&` (showing first ${oa.toLocaleString()})`]}),s.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[s.jsxs("button",{type:"button",onClick:()=>o("unified"),"aria-pressed":r==="unified",className:L("flex items-center gap-1 px-2 py-1 transition-colors",r==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[s.jsx(nk,{className:"size-3"}),"Unified"]}),s.jsxs("button",{type:"button",onClick:()=>o("split"),"aria-pressed":r==="split",className:L("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",r==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[s.jsx(qw,{className:"size-3"}),"Split"]})]})]}),s.jsx("div",{ref:i,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:r==="unified"?s.jsx(q4,{virtualizer:a,lines:d}):s.jsx(W4,{lines:d})})]})};function q4({virtualizer:e,lines:t}){return s.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(n=>{const r=t[n.index];return r===void 0?null:s.jsxs("div",{"data-index":n.index,ref:e.measureElement,className:L("flex items-start gap-3 px-2",U4(r.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${n.start}px)`},children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.oldLineNumber??""}),s.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:r.newLineNumber??""}),s.jsx("span",{className:L("select-none w-3 text-right font-bold",r.kind==="added"&&"text-green-600 dark:text-green-400",r.kind==="removed"&&"text-red-600 dark:text-red-400"),children:F4(r.kind)}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:r.text})]},n.key)})})}function H4(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(r===void 0)break;if(r.kind==="context"){t.push({left:{text:r.text,lineNumber:r.oldLineNumber},right:{text:r.text,lineNumber:r.newLineNumber},kind:"equal"}),n+=1;continue}const o=[],i=[];for(;n<e.length&&e[n]?.kind==="removed";){const l=e[n];l!==void 0&&o.push(l),n+=1}for(;n<e.length&&e[n]?.kind==="added";){const l=e[n];l!==void 0&&i.push(l),n+=1}const a=Math.max(o.length,i.length);for(let l=0;l<a;l+=1){const u=o[l],d=i[l];u!==void 0&&d!==void 0?t.push({left:{text:u.text,lineNumber:u.oldLineNumber},right:{text:d.text,lineNumber:d.newLineNumber},kind:"changed"}):u!==void 0?t.push({left:{text:u.text,lineNumber:u.oldLineNumber},right:null,kind:"removed"}):d!==void 0&&t.push({left:null,right:{text:d.text,lineNumber:d.newLineNumber},kind:"added"})}}return t}function V4(e){switch(e){case"changed":return"bg-amber-500/10";case"removed":return"bg-red-500/10";case"added":return"bg-green-500/10";case"equal":return""}}function W4({lines:e}){const t=H4(e);return s.jsx("div",{"data-testid":"diff-split",children:t.map((n,r)=>s.jsxs("div",{className:L("grid grid-cols-2 font-mono text-xs",V4(n.kind)),children:[s.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.left?.lineNumber??""}),s.jsx("span",{className:L("select-none w-3 text-right font-bold",(n.kind==="removed"||n.kind==="changed")&&"text-red-600 dark:text-red-400"),children:n.left!==null?"-":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.left?.text??""})]}),s.jsxs("div",{className:"flex items-start gap-2 px-2",children:[s.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:n.right?.lineNumber??""}),s.jsx("span",{className:L("select-none w-3 text-right font-bold",(n.kind==="added"||n.kind==="changed")&&"text-green-600 dark:text-green-400"),children:n.right!==null?"+":" "}),s.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:n.right?.text??""})]})]},r))})}const Tg=c.memo(B4),Z4=df("inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function Te({className:e,variant:t="default",asChild:n=!1,...r}){const o=n?uS:"span";return s.jsx(o,{"data-slot":"badge","data-variant":t,className:L(Z4({variant:t}),e),...r})}const K4=3;function G4({event:e}){const t=n=>{n.stopPropagation(),Ms({logId:e.logId,tab:"response",toolCallIndex:e.index})};return s.jsx("button",{type:"button",className:"inline-flex h-5 min-w-0 max-w-[8.5rem] items-center rounded px-1.5 text-[10px] text-muted-foreground transition-colors hover:bg-background/65 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:t,onKeyDown:n=>n.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:s.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function J4({events:e}){if(e.length===0)return null;const t=e.slice(0,K4),n=Math.max(0,e.length-t.length);return s.jsxs("span",{className:"inline-flex h-7 min-w-0 max-w-full items-center gap-1 overflow-hidden rounded-md border border-cyan-300/10 bg-cyan-300/[0.055] px-1 sm:max-w-[26rem]",role:"group","aria-label":`${e.length} response tool ${e.length===1?"call":"calls"}`,onClick:r=>r.stopPropagation(),onKeyDown:r=>r.stopPropagation(),children:[s.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center gap-1 px-1 font-mono text-[9px] font-semibold uppercase text-cyan-300",children:[s.jsx(wr,{className:"size-3"}),"Call ",e.length]}),s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[t.map(r=>s.jsx(G4,{event:r},r.id)),n>0&&s.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center rounded px-1 font-mono text-[10px] font-semibold text-muted-foreground",children:["+",n]})]})]})}const Y4={success:"bg-slate-300/[0.08] text-slate-100 border-transparent",client_error:"bg-amber-300/[0.10] text-amber-100 border-transparent",server_error:"bg-rose-400/[0.10] text-rose-100 border-transparent",pending:"bg-cyan-300/[0.08] text-cyan-100 border-transparent"},X4={success:{frame:"border-cyan-200/15 bg-white/[0.04] text-text-strong"},client_error:{frame:"border-amber-300/25 bg-amber-300/[0.08] text-amber-100"},server_error:{frame:"border-rose-300/25 bg-rose-300/[0.08] text-rose-100"},pending:{frame:"border-cyan-300/25 bg-cyan-300/[0.08] text-cyan-100"}},Ws="border border-transparent bg-white/[0.045] hover:bg-white/[0.075] size-8 text-muted-foreground shadow-none hover:text-cyan-100",Et="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function Zs(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Q4(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function eE(e,t){switch(e){case"success":return t===null?"OK":String(t);case"client_error":return t===null?"WARN":String(t);case"server_error":return t===null?"FAIL":String(t);case"pending":return"ROLL"}}function nd({trend:e}){if(e===null)return null;const t=e.direction==="up",n=t?sw:Yy,r=t?"+":"-";return s.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[s.jsx(n,{className:t?"size-3 text-cyan-300":"size-3 text-rose-400"}),s.jsxs("span",{className:"font-mono",children:[r,Pe(e.delta)]})]})}const tE=c.memo(function({log:e,displayNumber:t,messageCount:n=null,toolCount:r=null,toolEvents:o=[],expanded:i,onToggle:a,cacheTrend:l=null,activeTab:u,tabActions:d,onReplay:f,slowResponseThresholdSeconds:p=0,showClientMetadata:m=!0,timeDisplayFormat:h}){const g=Jx(e.responseStatus),y=e.elapsedMs!==null&&p>0&&e.elapsedMs>p*1e3,b=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,v=e.tokensPerSecond??null,j=w===null?null:Zs(w),k=v===null||v<=0?null:Q4(v),S=e.warnings?.length??0,_=e.clientPid!==null&&e.clientPid!==void 0,C=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const M=X4[g],A=eE(g,e.responseStatus),I=g!=="success"||e.responseStatus!==200,N=e.streaming&&j===null&&k===null;return s.jsx(Ds,{children:s.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":i?"collapse":"expand",className:L("group/header relative isolate flex min-w-0 cursor-pointer items-start gap-2 overflow-hidden px-3 py-2 transition-[background-color,border-color,box-shadow]",i?"bg-white/[0.04]":"bg-transparent hover:bg-white/[0.035]","select-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),onClick:a,onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),a())},children:[s.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:L("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",M.frame),children:s.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",t]})}),s.jsxs("span",{className:"bg-white/[0.045] flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-xs text-muted-foreground",children:[s.jsx(sn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Da(e.timestamp,h)})]}),I&&s.jsxs(Te,{variant:"outline",className:L("h-6 gap-1 rounded-md px-2 py-0 font-mono text-[10px] font-semibold uppercase tabular-nums shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]",Y4[g]),children:[g==="success"?s.jsx(qe,{className:"size-3","aria-label":"Success"}):g==="server_error"?s.jsx(Uj,{className:"size-3","aria-label":"Server error"}):g==="client_error"?s.jsx(yn,{className:"size-3","aria-label":"Client error"}):s.jsx(De,{className:"size-3 animate-spin","aria-label":"Pending"}),A]}),S>0&&s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsxs(Te,{variant:"outline",className:"h-6 gap-1 rounded-md border-amber-300/30 bg-amber-300/[0.10] px-2 py-0 font-mono text-[10px] tabular-nums text-amber-100",children:[s.jsx(yn,{className:"size-3","aria-label":"Tool schema warnings"}),S]})}),s.jsx(pt,{children:S===1?"1 tool schema warning":`${S} tool schema warnings`})]}),e.elapsedMs!==null&&(y?s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsxs("span",{className:L(Et,"shrink-0 border-amber-300/25 text-amber-200"),children:[s.jsx(sn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:Zs(e.elapsedMs)}),s.jsx(yn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsxs(pt,{children:["Slow response: ",Zs(e.elapsedMs)," exceeds"," ",Zs(p*1e3)]})]}):s.jsxs("span",{className:L(Et,"shrink-0 text-muted-foreground"),children:[s.jsx(sn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:Zs(e.elapsedMs)})]})),e.streaming&&j!==null&&s.jsxs("span",{className:L(Et,"shrink-0 text-cyan-300"),children:[s.jsx(hu,{className:"size-3"}),s.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&k!==null&&s.jsxs("span",{className:L(Et,"shrink-0 text-cyan-300"),children:[s.jsx(Hl,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:k})]}),b&&s.jsxs("span",{className:L(Et,"min-w-0 sm:shrink-0"),children:[s.jsx(ar,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[s.jsxs("span",{className:L("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Pe(e.inputTokens):"n/a"]}),s.jsx("span",{className:"text-muted-foreground",children:"/"}),s.jsxs("span",{className:L("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Pe(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&s.jsxs("span",{className:L(Et,"shrink-0"),children:[s.jsx(nd,{trend:l?.creation??null}),s.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Pe(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&s.jsxs("span",{className:L(Et,"shrink-0"),children:[s.jsx(nd,{trend:l?.read??null}),s.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Pe(e.cacheReadInputTokens)]})]}),n!==null&&s.jsxs("span",{className:L(Et,"shrink-0 text-muted-foreground"),children:[s.jsx(ri,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:n})]}),r!==null&&s.jsxs("span",{className:L(Et,"shrink-0 text-muted-foreground"),children:[s.jsx(wr,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:r})]}),s.jsx(J4,{events:o}),e.origin!==null&&s.jsxs("span",{className:L(Et,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[s.jsx(_p,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),m&&(_||C)&&s.jsxs("span",{className:L(Et,"hidden shrink-0 text-purple-300 xl:flex"),children:[s.jsx(aj,{className:"size-3"}),C?s.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):s.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),N&&s.jsx(hu,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),s.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[i&&s.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:P=>P.stopPropagation(),onKeyDown:P=>P.stopPropagation(),children:[d!==void 0&&u!==void 0&&(()=>{const P=d[u];return P===void 0?null:s.jsxs(s.Fragment,{children:[P.expansion!==null&&s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsx(ee,{variant:"outline",size:"icon",className:Ws,onClick:P.expansion.onToggle,disabled:P.expansion.isPending,"aria-pressed":P.expansion.isExpanded,"aria-label":P.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:P.expansion.isExpanded?s.jsx(_w,{className:"size-3.5"}):s.jsx(vw,{className:"size-3.5"})})}),s.jsx(pt,{children:P.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),P.diffWithRaw!==void 0&&s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsx(ee,{variant:"outline",size:"icon",className:L(Ws,P.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:P.diffWithRaw.onToggle,"aria-pressed":P.diffWithRaw.active,"aria-label":P.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:s.jsx(sj,{className:"size-3.5"})})}),s.jsx(pt,{children:P.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),P.diffWithPrevious!==void 0&&s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsx(ee,{variant:"outline",size:"icon",className:Ws,onClick:P.diffWithPrevious,"aria-label":"Diff with previous",children:s.jsx(Np,{className:"size-3.5"})})}),s.jsx(pt,{children:"Compare this request with the immediately preceding one"})]}),P.copyText!==null&&s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsx(ee,{variant:"outline",size:"icon",className:Ws,onClick:P.onCopy,"aria-label":P.copyCopied?"Copied":P.copyLabel,children:P.copyCopied?s.jsx(qe,{className:"size-3.5 text-cyan-300"}):s.jsx(zt,{className:"size-3.5"})})}),s.jsx(pt,{children:P.copyCopied?"Copied to clipboard":P.copyLabel})]})]})})(),f!==void 0&&s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsx(ee,{variant:"outline",size:"icon",className:Ws,onClick:f,"aria-label":"Replay request",children:s.jsx(Rp,{className:"size-3.5"})})}),s.jsx(pt,{children:"Re-send this request to the provider"})]})]}),s.jsx("span",{className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:i?s.jsx(et,{className:"size-4 shrink-0"}):s.jsx(bt,{className:"size-4 shrink-0"})})]})]})})});function nE({...e}){return s.jsx(LS,{"data-slot":"collapsible",...e})}function T6({...e}){return s.jsx(qp,{"data-slot":"collapsible-trigger",...e})}function sE({...e}){return s.jsx(Hp,{"data-slot":"collapsible-content",...e})}function rE({className:e,children:t,...n}){return s.jsxs(BN,{"data-slot":"scroll-area",className:L("relative overflow-hidden",e),...n,children:[s.jsx(qN,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full max-h-[inherit] rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:t}),s.jsx(oE,{}),s.jsx(HN,{})]})}function oE({className:e,orientation:t="vertical",...n}){return s.jsx(Qm,{"data-slot":"scroll-area-scrollbar",orientation:t,className:L("flex touch-none p-px transition-colors select-none",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...n,children:s.jsx(sh,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const Eg={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},iE={file:"border-transparent bg-blue-400/5 text-blue-300",shell:"border-transparent bg-teal-400/5 text-teal-300",browser:"border-transparent bg-cyan-400/5 text-cyan-300",web:"border-transparent bg-sky-400/5 text-sky-300",mcp:"border-transparent bg-violet-400/5 text-violet-300",code:"border-transparent bg-emerald-400/5 text-emerald-300",other:"border-transparent bg-muted/30 text-muted-foreground"};function aE({category:e}){switch(e){case"file":return s.jsx(cj,{className:"size-3.5"});case"shell":return s.jsx(Xn,{className:"size-3.5"});case"browser":return s.jsx(Lj,{className:"size-3.5"});case"web":return s.jsx(_p,{className:"size-3.5"});case"mcp":return s.jsx(lw,{className:"size-3.5"});case"code":return s.jsx(jp,{className:"size-3.5"});case"other":return s.jsx(Gw,{className:"size-3.5"})}}function lE({names:e}){return e.length===0?null:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(t=>s.jsx(Te,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:t},t)),e.length>4&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function cE({tool:e,called:t}){const[n,r]=c.useState(!1),o=bn(e.name),i=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return s.jsx(nE,{open:n,onOpenChange:r,children:s.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[s.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>r(a=>!a),"aria-expanded":n,disabled:!i,children:[s.jsx(aE,{category:e.category}),s.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),t&&s.jsx(Te,{variant:"outline",className:"h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300",children:"called"}),s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&s.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),s.jsx("span",{className:"flex-1"}),i&&(n?s.jsx(et,{className:"size-3.5 shrink-0 text-muted-foreground"}):s.jsx(bt,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),s.jsx("button",{type:"button",className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:o.copy,"aria-label":o.copied?"Copied tool name":"Copy tool name",children:o.copied?s.jsx(qe,{className:"size-3.5 text-emerald-400"}):s.jsx(zt,{className:"size-3.5"})})]}),s.jsx(sE,{children:n&&s.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&s.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),s.jsx(lE,{names:e.requiredParameters}),e.schema!==null&&s.jsx(rE,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:s.jsx(c.Suspense,{fallback:s.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:s.jsx(il,{data:$o(e.schema),defaultExpandDepth:0})})})]})})]})})}function uE(e,t){return t.length===0?!0:`${e.name} ${e.description??""} ${Eg[e.category]}`.toLowerCase().trim().includes(t)}const dE=c.memo(function({summary:t,calledToolNames:n}){const[r,o]=c.useState(!1),[i,a]=c.useState(""),l=c.useMemo(()=>new Set(n),[n]),u=i.trim().toLowerCase(),d=c.useMemo(()=>t===null?[]:t.tools.filter(m=>uE(m,u)),[u,t]);if(t===null)return null;const f=t.tools.slice(0,6),p=t.tools.length-f.length;return s.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx(wr,{className:"size-4 shrink-0 text-sky-300/80"}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),s.jsx(Te,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:t.tools.length}),t.toolChoiceLabel!==null&&s.jsxs(Te,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",t.toolChoiceLabel]})]}),s.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:t.categories.map(m=>s.jsxs(Te,{variant:"outline",className:L("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",iE[m.category]),children:[m.count," ",Eg[m.category]]},m.category))})]})]}),s.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>o(m=>!m),"aria-expanded":r,children:[r?s.jsx(et,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"}),r?"Hide":"Show"]})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[f.map(m=>s.jsx(Te,{variant:"outline",className:L("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",l.has(m.name)&&"border-emerald-400/20 text-emerald-300"),children:m.name},m.name)),p>0&&s.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",p]})]}),r&&s.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[s.jsxs("label",{className:"bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs",children:[s.jsx(lk,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("input",{value:i,onChange:m=>a(m.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),s.jsx("div",{className:"grid gap-1.5",children:d.length>0?d.map(m=>s.jsx(cE,{tool:m,called:l.has(m.name)},m.name)):s.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function sd(e,t,n){return e==="anthropic"&&t==="full"&&n}function fE(e,t){return e==="full"&&t}function ia(e,t){return e==="full"&&t}function aa(e,t){return e==="full"&&t}function pE(e,t,n,r){return e==="anthropic"&&t==="full"&&n&&r}function cs(){return s.jsx("div",{className:"h-1","aria-hidden":"true"})}function mE(e,t){switch(e){case"anatomy":return t===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const hE=15e3,gE=15e3,xE=256*1024,Do=1024*1024,On="h-9 flex-none rounded-md border border-transparent bg-transparent px-3 text-xs font-semibold text-muted-foreground shadow-none transition-colors hover:bg-white/[0.045] hover:text-foreground data-[state=active]:bg-cyan-300/[0.08] data-[state=active]:text-cyan-100 data-[state=active]:shadow-none";function Vr(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function Fo(e){return e??0}function Rg(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function Ig(e){return Rg(e)?Fo(e.rawRequestBodyBytes)>Do||Fo(e.responseTextBytes)>Do:!1}function bE(e){return Rg(e)&&!Ig(e)}function vE(e){return e instanceof ni?"Body preview timed out. The log is still available on disk; try loading again.":e instanceof Error?e.message:"Body preview could not be loaded."}function Wr({status:e,error:t,footprint:n,onRetry:r}){switch(e){case"idle":return null;case"loading":return s.jsx(fr,{tone:"loading",title:"Loading full bodies",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(De,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),s.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),n!==null&&s.jsx("span",{className:"rounded border border-cyan-300/15 bg-cyan-300/[0.06] px-2 py-0.5 font-mono text-[11px] text-cyan-100",children:n})]})});case"failed":return s.jsx(fr,{tone:"warning",title:t?.title??"Full bodies could not be loaded",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("span",{children:t?.detail??"Compact metadata is still available."}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 gap-1.5 text-xs text-amber-100",onClick:r,children:[s.jsx(Pt,{className:"size-3"}),"Retry"]})]})})}}function rd(e,t){return e?t.text!==""?t.text:t.status==="success"?"":null:null}function zn({children:e,className:t}){return s.jsx("div",{className:L("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",t),children:e})}function fo({children:e}){return s.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function Zr({children:e}){return s.jsx("pre",{className:"bg-black/[0.18] inspector-scrollbar max-h-[64vh] overflow-auto whitespace-pre-wrap break-words rounded-[8px] p-3 font-mono text-xs leading-relaxed text-muted-foreground",children:e})}const yE={loading:"border-transparent bg-cyan-400/[0.06] text-cyan-100",warning:"border-transparent bg-amber-400/[0.08] text-amber-100",danger:"border-transparent bg-rose-400/[0.08] text-rose-100"};function fr({tone:e,title:t,children:n}){return s.jsxs("div",{className:L("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",yE[e]),children:[t!==void 0&&s.jsx("div",{className:"mb-1 font-semibold",children:t}),s.jsx("div",{className:"leading-relaxed text-muted-foreground",children:n})]})}function Kr({label:e,state:t,expectedBytes:n,onLoadMore:r}){const o=t.totalBytes??n,i=o===null?gs(t.offset):`${gs(t.offset)} / ${gs(o)}`,a=t.status!=="loading"&&t.hasMore,l=t.status==="failed"?"Retry":"Load more";return s.jsx(fr,{tone:t.status==="failed"?"warning":"loading",title:`${e} body preview`,children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("span",{children:[t.status==="idle"&&o!==null?`${e} body is ${gs(o)}. Loading the first preview chunk.`:`Loaded ${i}.`,t.status==="failed"&&t.error!==null&&` ${t.error}`]}),a&&s.jsx(ee,{type:"button",variant:"outline",size:"sm",className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 text-xs text-cyan-100",onClick:r,children:l})]})})}function od({headers:e,emptyLabel:t}){const n=e===void 0?[]:Object.entries(e).sort(([r],[o])=>r.localeCompare(o));return n.length===0?s.jsx(fo,{children:t}):s.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:n.map(([r,o])=>s.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(140px,0.32fr)_minmax(0,1fr)] border-b border-white/[0.055] last:border-b-0",children:[s.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:r}),s.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:o,children:o})]},r))})}function wE({active:e,onClick:t}){return s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsxs(ee,{variant:e?"default":"outline",size:"sm",className:L("h-8 border-white/10 text-xs shadow-none",e?"bg-cyan-300 text-black hover:bg-cyan-200":"border border-input bg-background hover:bg-accent hover:text-accent-foreground text-muted-foreground hover:text-cyan-100"),onClick:t,"aria-pressed":e,children:[s.jsx(xj,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),s.jsx(pt,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const jE=c.memo(function({rawBody:e,displayedBody:t,emptyLabel:n}){const r=c.useMemo(()=>$4(e,t),[e,t]);return s.jsx(Tg,{result:r,emptyLabel:n})}),kE=c.memo(function({rawHeaders:e,headers:t,emptyLabel:n}){const r=c.useMemo(()=>L4(e,t),[e,t]);return s.jsx(Tg,{result:r,emptyLabel:n})}),SE=c.memo(function({log:e,displayNumber:t,viewMode:n="simple",strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:i,cacheTrend:a=null,onCompareWithPrevious:l,showClientMetadata:u=!0,toolEvents:d=[]}){const[f,p]=c.useState(!1),[m,h]=c.useState(!1),[g,y]=c.useState(!1),[b,w]=c.useState(!1),[v,j]=c.useState("request"),[k,S]=c.useState(null),[_,C]=c.useState(0),[M,A]=c.useState(null),[I,N]=c.useState(null),[P,$]=c.useState("idle"),[F,G]=c.useState(null),[X,U]=c.useState(0),[V,Y]=c.useState(()=>Vr(e.rawRequestBodyBytes??null)),[B,W]=c.useState(()=>Vr(e.responseTextBytes??null)),me=c.useRef(null),ve=c.useRef(e.id),we=c.useRef(!1),D=I??e,ie=I===null&&Ig(e),te=c.useMemo(()=>R4(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),_e=rd(ie,V),Ne=rd(ie,B),ce=D.rawRequestBody??_e,de=D.responseText??Ne,he=D.rawRequestBody===null&&_e!==null,je=D.responseText===null&&Ne!==null,Ce=!he||V.hasMore===!1&&Fo(V.totalBytes)<=Do,Fe=!je||B.hasMore===!1&&Fo(B.totalBytes)<=Do,Ze=ur(D),Ue=mg(Ze),ut=c.useMemo(()=>Ue.analyzeRequest(D.rawRequestBody),[Ue,D.rawRequestBody]),Qt=c.useMemo(()=>Ue.analyzeResponse(D.responseText),[Ue,D.responseText]),Ke=c.useMemo(()=>!r||Ze!=="anthropic"||D.rawRequestBody===null?null:p4(D.rawRequestBody).body,[D.rawRequestBody,Ze,r])??ce,Ae=ra(Ce?Ke:null),Be=ra(v==="raw-request"&&Ce?ce:null),q=ra(v==="raw"&&Fe?de:null),ne=c.useMemo(()=>D.headers&&Object.keys(D.headers).length>0?JSON.stringify(D.headers,null,2):null,[D.headers]),ke=c.useMemo(()=>D.rawHeaders&&Object.keys(D.rawHeaders).length>0?JSON.stringify(D.rawHeaders,null,2):null,[D.rawHeaders]),ge=bn(Ke),Se=bn(ce),Je=bn(ne),J=bn(ke),T=bn(de),z=c.useMemo(()=>({request:{copyLabel:he?"Copy loaded request preview":"Copy request body",copyText:Ke,copyCopied:ge.copied,onCopy:ge.copy,expansion:Ce?{isExpanded:Ae.isExpanded,isPending:Ae.isPending,onToggle:Ae.toggle}:null,diffWithRaw:pE(Ze,n,r,D.rawRequestBody!==null)?{active:b,onToggle:()=>w(!b)}:void 0,diffWithPrevious:l===void 0?void 0:()=>{l(D)}},"raw-request":{copyLabel:he?"Copy loaded raw request preview":"Copy raw request",copyText:ce,copyCopied:Se.copied,onCopy:Se.copy,expansion:Ce?{isExpanded:Be.isExpanded,isPending:Be.isPending,onToggle:Be.toggle}:null},...aa(n,D.headers!==void 0&&Object.keys(D.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:ne,copyCopied:Je.copied,onCopy:Je.copy,expansion:null}}:{},...ia(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:ke,copyCopied:J.copied,onCopy:J.copy,expansion:null}}:{},raw:{copyLabel:je?"Copy loaded response preview":"Copy response",copyText:de,copyCopied:T.copied,onCopy:T.copy,expansion:Fe?{isExpanded:q.isExpanded,isPending:q.isPending,onToggle:q.toggle}:null}}),[Ke,he,Ce,ge,Ae,b,D,D.rawRequestBody,ce,Se,Be,ne,Je,ke,J,D.responseText,je,Fe,de,T,q,Ze,n,r,l]),Z=c.useMemo(()=>Ae.parsedData!==null?Ue.anatomySegments(Ae.parsedData):null,[Ue,Ae.parsedData]),re=c.useMemo(()=>kc(Ae.parsedData),[Ae.parsedData]),ae=D.warnings??[],se=c.useMemo(()=>{if(Z!==null)return new Set(Z.map(Me=>Me.path))},[Z]),be=E4({containerRef:me,setExpandToPath:A,ensureTabActive:()=>{v!=="request"&&j("request")}}),ue=c.useCallback((Me,en)=>{const wt=Me==="request"?Y:W;wt(rt=>({...rt,status:"loading",error:null}));const Fs=new URLSearchParams({part:Me,offset:String(en),limit:String(xE)});He(`/api/logs/${String(e.id)}/body?${Fs.toString()}`,W2,gE).then(rt=>{ve.current===e.id&&wt(Us=>({status:"success",text:rt.offset===0?rt.text:`${Us.text}${rt.text}`,offset:rt.nextOffset??rt.totalBytes,totalBytes:rt.totalBytes,hasMore:rt.hasMore,error:null}))}).catch(rt=>{ve.current===e.id&&wt(Us=>({...Us,status:"failed",error:vE(rt)}))})},[e.id]),Ct=c.useCallback(()=>{we.current||(N(null),$("idle"),G(null),U(Me=>Me+1))},[]),Pn=c.useCallback(()=>{const Me=!f;Me&&j(Z!==null?"anatomy":"request"),p(Me)},[Z,f]);return c.useEffect(()=>{ve.current=e.id,we.current=!1,N(null),$("idle"),G(null),U(0),Y(Vr(e.rawRequestBodyBytes??null)),W(Vr(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),c.useEffect(()=>{if(!f||!bE(e)||I!==null||we.current)return;let Me=!1;return we.current=!0,$("loading"),G(null),He(`/api/logs/${String(e.id)}`,ir,hE).then(en=>{Me||(we.current=!1,N(en),$("idle"),G(null))}).catch(en=>{Me||(we.current=!1,$("failed"),G(I4(en)))}),()=>{Me=!0,we.current=!1}},[f,I,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,X]),c.useEffect(()=>{f&&ie&&V.status==="idle"&&(v!=="request"&&v!=="raw-request"&&v!=="anatomy"||ue("request",0))},[v,f,ue,V.status,ie]),c.useEffect(()=>{f&&ie&&B.status==="idle"&&(v!=="parsed"&&v!=="raw"||ue("response",0))},[v,f,ue,B.status,ie]),c.useEffect(()=>{const Me=en=>{const wt=Ri(en);wt!==null&&wt.logId===e.id&&(p(!0),j(mE(wt.tab,Z)),wt.tab==="response"&&wt.toolCallIndex!==void 0&&(S(wt.toolCallIndex),C(Fs=>Fs+1)))};return window.addEventListener(cn,Me),()=>{window.removeEventListener(cn,Me)}},[Z,e.id]),s.jsxs(Ds,{children:[s.jsxs("div",{className:L("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",f?"bg-card shadow-[0_18px_60px_rgba(0,0,0,0.30),0_0_0_1px_rgba(103,232,249,0.08)]":"hover:bg-card"),children:[s.jsx(tE,{log:D,displayNumber:t,messageCount:ut.messageCount,toolCount:ut.toolCount,toolEvents:d,expanded:f,onToggle:Pn,cacheTrend:a,slowResponseThresholdSeconds:o,showClientMetadata:u,timeDisplayFormat:i,activeTab:v,tabActions:z,onReplay:l===void 0?void 0:()=>{h(!0)}}),f&&s.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Me=>Me.stopPropagation(),onKeyDown:Me=>Me.stopPropagation(),children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-12 bg-gradient-to-b from-white/[0.05] to-transparent","aria-hidden":"true"}),s.jsx(go,{feature:"Log details",children:s.jsxs(kg,{value:v,onValueChange:j,className:"gap-2",children:[s.jsxs(Sg,{variant:"line",className:"bg-white/[0.04] inspector-scrollbar relative mx-3 h-auto w-[calc(100%-1.5rem)] justify-start overflow-x-auto rounded-[8px] p-1",children:[ia(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&s.jsx(gn,{className:On,value:"raw-headers",children:"Raw Headers"}),aa(n,D.headers!==void 0&&Object.keys(D.headers).length>0)&&s.jsx(gn,{className:On,value:"headers",children:"Headers"}),Z!==null&&s.jsx(gn,{className:On,value:"anatomy",children:"Context"}),sd(Ze,n,r)&&s.jsx(gn,{className:On,value:"raw-request",children:"Raw Request"}),s.jsx(gn,{className:On,value:"request",children:"Request"}),n==="full"&&s.jsx(gn,{className:On,value:"raw",children:"Raw Response"}),s.jsx(gn,{className:On,value:"parsed",children:"Response"})]}),sd(Ze,n,r)&&s.jsx(jt,{value:"raw-request",children:v==="raw-request"&&s.jsxs(zn,{children:[s.jsx(Wr,{status:P,error:F,footprint:te,onRetry:Ct}),ie&&s.jsx(Kr,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ue("request",V.offset)}),ce===null?s.jsx(fo,{children:ie?"Request preview is loading":"No request body"}):Be.parsedData!==null?s.jsx(c.Suspense,{fallback:s.jsx(cs,{}),children:s.jsx(il,{data:Be.parsedData,bulkDepth:Be.bulkDepth,bulkRevision:Be.bulkRevision})}):s.jsx(Zr,{children:ce})]})}),s.jsx(jt,{value:"request",children:v==="request"&&s.jsxs(zn,{children:[s.jsx(Wr,{status:P,error:F,footprint:te,onRetry:Ct}),ie&&s.jsx(Kr,{label:"Request",state:V,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ue("request",V.offset)}),ae.length>0&&s.jsxs(fr,{tone:"warning",children:[s.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[s.jsx(yn,{className:"size-3.5"}),"Tool schema warnings"]}),s.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:ae.map(Me=>s.jsx("li",{children:Me},Me))})]}),s.jsx(dE,{summary:re,calledToolNames:Qt.toolNames??[]}),b?s.jsx(jE,{rawBody:D.rawRequestBody,displayedBody:Ke,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):s.jsx("div",{ref:me,children:Ke===null?s.jsx(fo,{children:ie?"Request preview is loading":"No request body"}):Ae.parsedData!==null?s.jsx(c.Suspense,{fallback:s.jsx(cs,{}),children:s.jsx(il,{data:Ae.parsedData,bulkDepth:Ae.bulkDepth,bulkRevision:Ae.bulkRevision,anatomyPaths:se,expandToPath:M})}):s.jsx(Zr,{children:Ke})})]})}),Z!==null&&s.jsx(jt,{value:"anatomy",children:v==="anatomy"&&s.jsx(zn,{className:"p-0",children:s.jsx(c.Suspense,{fallback:s.jsx(cs,{}),children:s.jsx(k4,{parsed:Ae.parsedData,inputTokens:D.inputTokens??null,model:D.model,segments:Z,onSegmentActivate:be})})})}),aa(n,D.headers!==void 0&&Object.keys(D.headers).length>0)&&s.jsx(jt,{value:"headers",children:v==="headers"&&s.jsxs(zn,{children:[s.jsx("div",{className:"flex justify-end gap-2 mb-2",children:fE(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&s.jsx(wE,{active:g,onClick:Me=>{Me.stopPropagation(),y(!g)}})}),g?s.jsx(kE,{rawHeaders:D.rawHeaders,headers:D.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):s.jsx(od,{headers:D.headers,emptyLabel:"No headers captured"})]})}),ia(n,D.rawHeaders!==void 0&&Object.keys(D.rawHeaders).length>0)&&s.jsx(jt,{value:"raw-headers",children:v==="raw-headers"&&s.jsx(zn,{children:s.jsx(od,{headers:D.rawHeaders,emptyLabel:"No raw headers captured"})})}),s.jsx(jt,{value:"raw",children:v==="raw"&&s.jsxs(zn,{className:"space-y-3",children:[s.jsx(Wr,{status:P,error:F,footprint:te,onRetry:Ct}),ie&&s.jsx(Kr,{label:"Response",state:B,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ue("response",B.offset)}),D.error!==void 0&&D.error!==null&&s.jsx(fr,{tone:"danger",title:"SSE Error",children:s.jsx("span",{className:"font-mono",children:D.error})}),de!==null&&Fe?s.jsx(c.Suspense,{fallback:s.jsx(cs,{}),children:s.jsx(N4,{text:de,defaultExpandDepth:0,bulkDepth:q.bulkDepth,bulkRevision:q.bulkRevision})}):de!==null?s.jsx(Zr,{children:de}):s.jsx(fo,{children:ie?"Response preview is loading":"No response"}),D.streaming===!0&&s.jsx(c.Suspense,{fallback:s.jsx(cs,{}),children:s.jsx(_4,{logId:D.id,truncated:D.streamingChunksPath!==null})})]})}),s.jsx(jt,{value:"parsed",children:v==="parsed"&&s.jsxs(zn,{children:[s.jsx(Wr,{status:P,error:F,footprint:te,onRetry:Ct}),ie&&s.jsx(Kr,{label:"Response",state:B,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ue("response",B.offset)}),je&&!Fe?s.jsx(Zr,{children:de}):s.jsx(c.Suspense,{fallback:s.jsx(cs,{}),children:s.jsx(S4,{responseText:de,responseStatus:D.responseStatus,streaming:D.streaming,inputTokens:D.inputTokens,outputTokens:D.outputTokens,cacheCreationInputTokens:D.cacheCreationInputTokens,cacheReadInputTokens:D.cacheReadInputTokens,apiFormat:Ze,error:D.error,focusedToolIndex:k,toolFocusNonce:_})})]})})]})})]})]}),s.jsx(go,{feature:"Replay",children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(j4,{log:D,displayNumber:t,open:m,onOpenChange:h})})})]})});function _E(e){switch(e){case"end_turn":return"End of Turn (Anthropic)";case"stop":return"End of Turn (OpenAI)";case"length":return"End of Turn (length limit)";case"tool_use":case null:return"End of Turn"}}function la(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function NE({stopReason:e,isPending:t,isFirst:n,isTurnStart:r,isOnlyEntry:o=!1,isOpenTurnTail:i=!1,crabIndex:a=0,collapsible:l=!1,onToggle:u}){const d=Sc(e),f=o&&r&&d,p=t&&!d,m=l&&u!==void 0,h=c.useMemo(()=>_c(a),[a]),g=c.useMemo(()=>l4(a),[a]),y=w=>{!m||u===void 0||(w.stopPropagation(),u())},b=w=>{!m||u===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),u())};return s.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!n&&s.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),f?s.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:"Single-request turn",className:la(m),onClick:y,onKeyDown:b,children:s.jsx(g,{className:L("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):d?s.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:_E(e),className:la(m),onClick:y,onKeyDown:b,children:s.jsx(h,{className:L("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):r?s.jsx("span",{role:m?"button":void 0,tabIndex:m?0:void 0,title:"Start of turn",className:la(m),onClick:y,onKeyDown:b,children:s.jsx(h,{className:L("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):i?s.jsx("span",{title:t?"Current end of open turn (processing)":"Current end of open turn",children:s.jsx(h,{className:L("size-3.5 text-cyan-300/85",p?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})}):p?s.jsx("span",{title:"Processing",children:s.jsx(h,{className:L("size-3.5 text-amber-300/80","animate-crab-crawl")})}):s.jsx("span",{title:"Request in turn",children:s.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!d&&!i&&s.jsx("div",{className:L("w-0.5 h-full",t?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const id=180,ca=new WeakMap;function CE(e,t){const n=e.responseText;if(n===null)return!1;switch(t){case"anthropic":return n.includes("tool_use");case"openai":return n.includes("tool_calls")||n.includes("function_call");case"unknown":return!1}}function TE(e){return e>1}function cl(e){const t=[];let n=[],r=0;for(let o=0;o<e.length;o+=1){const i=e[o];if(i===void 0)continue;n.push({log:i,stopReason:yg(i),sessionLogNumber:o+1});const a=n[n.length-1];a!==void 0&&Sc(a.stopReason)&&(t.push({entries:n,turnIndex:r}),n=[],r+=1)}return n.length>0&&t.push({entries:n,turnIndex:r}),t}function EE(e){const t=new Map;for(const n of e)for(let r=1;r<n.logs.length;r+=1){const o=n.logs[r],i=n.logs[r-1];if(o===void 0||i===void 0)continue;const a=ur(o),l=ur(i);a==="unknown"||a!==l||t.set(o.id,i)}return t}function Pg(e){if(e===null)return null;try{const t=JSON.parse(e);return typeof t=="string"?JSON.parse(t):t}catch{return null}}function po(e){if(e==null)return null;const t=typeof e=="string"?e:JSON.stringify(e);if(t===void 0)return null;const n=t.replace(/\s+/g," ").trim();return n.length===0?null:n.length>id?`${n.slice(0,id-1)}...`:n}function mo(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const t=JSON.stringify(e,null,2);return t===void 0||t.length===0?null:t}function RE(e){const t=Pg(e.responseText),n=Q(t,"content");if(!Array.isArray(n))return[];const r=[];for(const o of n){if(Q(o,"type")!=="tool_use")continue;const a=Q(o,"name");if(typeof a!="string"||a.length===0)continue;const l=Q(o,"input");r.push({id:`${String(e.id)}-anthropic-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"anthropic",name:a,argumentsText:mo(l),argumentsPreview:po(l)})}return r}function IE(e){const t=Pg(e.responseText),n=Q(t,"choices");if(!Array.isArray(n))return[];const r=[];for(const i of n){const a=Q(i,"message"),l=Q(a,"tool_calls");if(Array.isArray(l))for(const f of l){const p=Q(f,"function"),m=Q(p,"name");if(typeof m!="string"||m.length===0)continue;const h=Q(p,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:m,argumentsText:mo(h),argumentsPreview:po(h)})}const u=Q(a,"function_call"),d=Q(u,"name");if(typeof d=="string"&&d.length>0){const f=Q(u,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:d,argumentsText:mo(f),argumentsPreview:po(f)})}}const o=Q(t,"output");if(Array.isArray(o))for(const i of o){if(Q(i,"type")!=="function_call")continue;const a=Q(i,"name");if(typeof a!="string"||a.length===0)continue;const l=Q(i,"arguments");r.push({id:`${String(e.id)}-openai-tool-${String(r.length)}`,logId:e.id,index:r.length,provider:"openai",name:a,argumentsText:mo(l),argumentsPreview:po(l)})}return r}function Nc(e){const t=ca.get(e);if(t!==void 0&&t.apiFormat===e.apiFormat&&t.responseText===e.responseText)return t.events;const n=ur(e);if(!CE(e,n)){const o=[];return ca.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}let r;switch(n){case"anthropic":r=RE(e);break;case"openai":r=IE(e);break;case"unknown":r=[];break}return ca.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}function PE(e,t,n=0){let r=0,o=0,i=0,a=0,l=0,u=0,d=0,f=0,p=null,m=0;for(const h of e)h.responseStatus===null?o+=1:h.responseStatus>=400&&(r+=1),h.elapsedMs!==null&&t>0&&h.elapsedMs>t*1e3&&(i+=1),h.inputTokens!==null&&(a+=h.inputTokens),h.outputTokens!==null&&(l+=h.outputTokens),h.cacheCreationInputTokens!==null&&(u+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(d+=h.cacheReadInputTokens),h.elapsedMs!==null&&(f+=h.elapsedMs,p=p===null?h.elapsedMs:Math.max(p,h.elapsedMs)),m+=Nc(h).length;return{llmCallCount:e.length,toolCallCount:m,failedCallCount:r,pendingCallCount:o,slowCallCount:i,totalInputTokens:a,totalOutputTokens:l,totalCacheCreationInputTokens:u,totalCacheReadInputTokens:d,totalElapsedMs:f,maxElapsedMs:p,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:n}}function ua(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const ME=c.memo(function({entries:t,viewMode:n,strip:r,slowResponseThresholdSeconds:o,cacheTrends:i,onCompareWithPrevious:a,comparisonPredecessors:l,turnIndex:u=0,timeDisplayFormat:d,pendingFocusRequest:f,showLogClientMetadata:p=!0}){const m=t.length-1,h=t[m]?.stopReason??null,g=h!==null?Sc(h):!1,y=t[m]?.log.responseStatus===null,b=t.length===1,w=TE(t.length),[v,j]=c.useState(!1),k=c.useRef(!1);c.useEffect(()=>{w?g&&!k.current&&j(!0):j(!1),k.current=g},[w,g]),c.useEffect(()=>{const U=V=>{const Y=Ri(V);Y!==null&&t.some(B=>B.log.id===Y.logId)&&w&&j(!1)};return window.addEventListener(cn,U),()=>{window.removeEventListener(cn,U)}},[w,t]),c.useEffect(()=>{if(f===void 0||!t.some(V=>V.log.id===f.logId))return;w&&j(!1);const U=window.setTimeout(()=>{Ms({logId:f.logId,tab:f.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(U)},[w,t,f]);const S=c.useCallback(()=>{w&&j(U=>!U)},[w]),_=c.useMemo(()=>{let U=0,V=0,Y=null,B=!1;for(const W of t)W.log.inputTokens!==null&&(U+=W.log.inputTokens,B=!0),W.log.outputTokens!==null&&(V+=W.log.outputTokens,B=!0),W.log.elapsedMs!==null&&(Y=Y===null?W.log.elapsedMs:Math.max(Y,W.log.elapsedMs));return{totalInput:U,totalOutput:V,hasTokens:B,maxElapsed:Y}},[t,m]),C=u%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",M=_.maxElapsed!==null&&o>0&&_.maxElapsed>o*1e3,A=c.useMemo(()=>{const U=new Map;for(const V of t){const Y=Nc(V.log);Y.length>0&&U.set(V.log.id,Y)}return U},[t]),[I,N]=c.useState(0),P=c.useRef(null);c.useEffect(()=>{const U=P.current;if(!U)return;let V=0;const Y=new ResizeObserver(()=>{window.cancelAnimationFrame(V),V=window.requestAnimationFrame(()=>N(B=>B+1))});return Y.observe(U),()=>{Y.disconnect(),window.cancelAnimationFrame(V)}},[]);const $=t[0]?.log.id??u,F=`Turn ${String(u+1)}`,G=c.useMemo(()=>_c($%12),[$]),X=c.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:v?"48px":"160px"}),[v]);return s.jsx("div",{ref:P,style:X,tabIndex:v?void 0:0,role:v?void 0:"group","aria-label":v?void 0:F,"data-nav-id":v?void 0:`turn-${String($)}`,className:L("rounded-[8px] transition-[background-color,box-shadow]",y?"bg-amber-300/[0.018] shadow-[0_0_0_1px_rgba(252,211,77,0.035)]":"",!v&&"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none"),children:v?s.jsxs("div",{"data-nav-id":`turn-collapsed-${String($)}`,"data-nav-action":"expand",role:"button",tabIndex:0,className:"flex items-stretch cursor-pointer focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none rounded-lg",onClick:S,onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),S())},children:[s.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[s.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),s.jsx(G,{className:L("size-3.5",y?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",y?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),s.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:s.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?s.jsx(G,{className:L("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):s.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:s.jsx(G,{className:L("size-3.5 text-cyan-300/85",y?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),t.length>1&&s.jsxs("div",{className:L("flex-1 min-w-0 mb-0.5 rounded-[8px] py-1.5 px-3 flex items-center gap-3 text-xs","bg-card/80 transition-colors hover:bg-card",C),children:[s.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:F}),s.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(t[0]?.log.id??"?")} ~ ${String(t[m]?.log.id??"?")}`,children:["#",t[0]?.sessionLogNumber??"?"," ~ #",t[m]?.sessionLogNumber??"?"]}),s.jsxs("span",{className:"text-muted-foreground shrink-0",children:[t.length," request",t.length>1?"s":""]}),_.maxElapsed!==null&&s.jsx(Ds,{children:s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsxs("span",{className:L("flex items-center gap-1 shrink-0",M?"text-amber-400":"text-muted-foreground"),children:[s.jsx(sn,{className:"size-3"}),s.jsx("span",{className:"font-mono tabular-nums",children:ua(_.maxElapsed)}),M&&s.jsx(yn,{className:"size-3","aria-label":"Slow response"})]})}),s.jsx(pt,{children:M?`Slow response: ${ua(_.maxElapsed)} exceeds ${ua(o*1e3)}`:"Slowest request in this turn"})]})}),_.hasTokens&&s.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(ar,{className:"size-3 text-muted-foreground"}),s.jsxs("span",{className:"font-mono tabular-nums",children:[s.jsxs("span",{className:"text-blue-400",children:["IN ",Pe(_.totalInput)]})," / ",s.jsxs("span",{className:"text-amber-400",children:["OUT ",Pe(_.totalOutput)]})]})]}),s.jsx("span",{className:"flex-1 min-w-0"}),s.jsx("span",{className:"bg-white/[0.045] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-text-strong","aria-hidden":"true",children:s.jsx(bt,{className:"size-4 shrink-0"})})]})]}):t.map((U,V)=>{const{log:Y,stopReason:B}=U,W=V===0;return s.jsxs("div",{className:"flex items-stretch",children:[s.jsx(NE,{stopReason:B,isPending:Y.responseStatus===null,isFirst:V===0,isTurnStart:W,isOnlyEntry:b,isOpenTurnTail:V===m&&!g,crabIndex:Y.id%12,collapsible:w&&W,onToggle:S}),s.jsx("div",{className:L("flex-1 min-w-0 mb-0.5 rounded-[8px]",C),children:s.jsx(SE,{log:Y,displayNumber:U.sessionLogNumber,viewMode:n,strip:r,slowResponseThresholdSeconds:o,timeDisplayFormat:d,cacheTrend:i?.get(Y.id)??null,showClientMetadata:p,toolEvents:A.get(Y.id),onCompareWithPrevious:l.has(Y.id)?a:void 0})})]},Y.id)})})}),AE=24,OE=132,zE=8;function LE(e){return e>AE}function $E(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];if(r!==void 0)for(const o of r.entries)t.set(o.log.id,n)}return t}function Mg(e,t,n){return s.jsx(ME,{entries:e.entries,viewMode:t.viewMode,strip:t.strip,slowResponseThresholdSeconds:t.slowResponseThresholdSeconds,timeDisplayFormat:t.timeDisplayFormat,cacheTrends:t.cacheTrends,onCompareWithPrevious:t.onCompareWithPrevious,comparisonPredecessors:t.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:n,showLogClientMetadata:t.showLogClientMetadata},e.turnIndex)}function DE(e){return LE(e.turnGroups.length)?s.jsx(FE,{...e}):s.jsx(s.Fragment,{children:e.turnGroups.map(t=>Mg(t,e))})}function FE(e){const{turnGroups:t}=e,[n,r]=c.useState(null),o=WT({count:t.length,estimateSize:()=>OE,overscan:zE,getItemKey:a=>t[a]?.turnIndex??a}),i=c.useMemo(()=>$E(t),[t]);return c.useEffect(()=>{const a=l=>{const u=Ri(l);if(u===null||u.source==="virtualizer")return;const d=i.get(u.logId);d!==void 0&&(o.scrollToIndex(d,{align:"center"}),r(f=>({...u,turnIndex:d,nonce:f===null?1:f.nonce+1})))};return window.addEventListener(cn,a),()=>{window.removeEventListener(cn,a)}},[i,o]),s.jsx("div",{className:"relative w-full",style:{height:`${o.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:o.getVirtualItems().map(a=>{const l=t[a.index];if(l===void 0)return null;const u=n!==null&&n.turnIndex===a.index?n:void 0;return s.jsx("div",{"data-index":a.index,ref:o.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${a.start}px)`},children:Mg(l,e,u)},a.key)})})}const Cc=pe(["episode","procedure","preference","project-fact"]),UE=pe(["draft","promoted","failed"]),Ag=E({source:le("agent-inspector"),sessionId:x(),logIds:K(R().int().positive()),project:x().nullable(),models:K(x())}),BE=E({redacted:Re(),patterns:K(x())}),Er=E({id:x(),type:Cc,title:x(),content:x(),tags:K(x()),source:le("agent-inspector"),sessionId:x(),logIds:K(R().int().positive()),evidence:Ag,status:UE,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:BE});E({idempotencyKey:x(),type:Cc,title:x(),content:x(),tags:K(x()),source:le("agent-inspector"),project:x().nullable(),evidence:Ag});const qE=E({id:x(),type:Cc.or(x()),title:x(),content:x(),score:R().nullable(),source:x().nullable(),project:x().nullable(),evidence:qn().optional()});E({results:K(qE),warning:x().nullable()});const HE=E({candidates:K(Er)}),VE=E({candidate:Er}),WE=E({error:x().optional(),candidate:Er.optional()}),ZE=E({candidate:Er}),KE=3e4,GE=15e3,JE=15e3,YE={draft:"border-amber-500/30 bg-amber-500/10 text-amber-500",promoted:"border-emerald-500/30 bg-emerald-500/10 text-emerald-500",failed:"border-destructive/30 bg-destructive/10 text-destructive"};function ul(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function XE(e,t,n){return e===null||t===null?null:oi(e,t,n)}function QE(e){return`${String(e)} candidate${e===1?"":"s"}`}function Og(e){return`log-${String(e)}`}function zg(e){const t=Og(e),n=document.getElementById(t);window.history.replaceState(null,"",`#${t}`),n instanceof HTMLElement&&(n.scrollIntoView({block:"center",behavior:"smooth"}),n.focus({preventScroll:!0}))}function eR(e){for(const t of e)if(t.responseStatus!==null&&t.responseStatus>=400)return t;return null}function tR(e){let t=null,n=-1;for(const r of e)r.elapsedMs!==null&&r.elapsedMs>n&&(t=r,n=r.elapsedMs);return t}function nR(e){for(const t of e)if(Nc(t).length>0)return t;return null}function sR(e){const t=new Map;for(let n=0;n<e.length;n+=1){const r=e[n];r!==void 0&&t.set(r.id,n+1)}return t}function js(e,t){return String(t.get(e)??e)}function rR(e){const t=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],n=nR(e.logs);e.summary.toolCallCount>0&&n!==null&&t.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${js(n.id,e.displayNumberByLogId)}`,logId:n.id});const r=eR(e.logs);r!==null&&t.push({kind:"failure",title:`Failure #${String(r.responseStatus)}`,detail:`First failed request is #${js(r.id,e.displayNumberByLogId)}`,logId:r.id});const o=tR(e.logs);if(o!==null&&e.summary.maxElapsedMs!==null&&t.push({kind:"slow",title:`Slowest ${ul(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${js(o.id,e.displayNumberByLogId)}`,logId:o.id}),e.candidates.length>0){const i=e.candidates.filter(l=>l.status==="draft").length,a=e.candidates.filter(l=>l.status==="promoted").length;t.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(i)} draft / ${String(a)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return t}function oR(e){switch(e){case"session":return s.jsx(ri,{className:"size-3.5 text-blue-400"});case"tool":return s.jsx(wr,{className:"size-3.5 text-sky-400/70"});case"slow":return s.jsx(sn,{className:"size-3.5 text-amber-400"});case"failure":return s.jsx(wp,{className:"size-3.5 text-destructive"});case"candidate":return s.jsx(yp,{className:"size-3.5 text-emerald-400"})}}function iR({insights:e}){return e.length===0?null:s.jsx("div",{className:"mt-2 grid gap-1.5 border-t border-border/70 pt-2 md:grid-cols-2 xl:grid-cols-3",children:e.map(t=>s.jsxs("button",{type:"button",className:L("flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs","text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),onClick:()=>{t.logId!==null&&zg(t.logId)},disabled:t.logId===null,children:[oR(t.kind),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate font-medium text-foreground/90",children:t.title}),s.jsx("span",{className:"block truncate font-mono text-[10px]",children:t.detail})]})]},`${t.kind}-${t.title}`))})}function aR(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function lR(e,t){if(t)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function cR(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function uR(e,t){const n=e.replace(/\s+/g," ").trim();return n.length<=t?n:`${n.slice(0,t-3)}...`}function dR(e,t){const n=e[0],r=e[e.length-1];if(n===void 0)return"No evidence logs";const o=js(n,t);return r===void 0||n===r?`#${o}`:`#${o}-#${js(r,t)}`}function ad(e){return e.join(", ")}function fR(e){return e.split(",").map(t=>t.trim()).filter(t=>t.length>0)}function pR({candidate:e,isPromoting:t,isUpdating:n,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i}){const[a,l]=c.useState(!1),[u,d]=c.useState(e.type),[f,p]=c.useState(e.title),[m,h]=c.useState(e.content),[g,y]=c.useState(ad(e.tags)),[b,w]=c.useState(null),v=e.status!=="promoted",j=e.status!=="promoted",k=c.useCallback(()=>{d(e.type),p(e.title),h(e.content),y(ad(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),S=c.useCallback(async()=>{const _=f.trim(),C=m.trim(),M=fR(g);if(_.length===0){w("Title is required.");return}if(C.length===0){w("Content is required.");return}if(M.length===0){w("At least one tag is required.");return}w(null),await o(e.id,{type:u,title:_,content:C,tags:M})&&l(!1)},[e.id,m,g,f,u,o]);return a?s.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:s.jsxs("div",{className:"grid gap-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("select",{value:u,disabled:n,onChange:_=>{const C=Er.shape.type.safeParse(_.currentTarget.value);C.success&&d(C.data)},className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate type",children:[s.jsx("option",{value:"episode",children:"episode"}),s.jsx("option",{value:"procedure",children:"procedure"}),s.jsx("option",{value:"preference",children:"preference"}),s.jsx("option",{value:"project-fact",children:"project-fact"})]}),s.jsx("input",{value:f,disabled:n,onChange:_=>p(_.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 min-w-[220px] flex-1 rounded-md px-2 text-xs","aria-label":"Candidate title"})]}),s.jsx("textarea",{value:m,disabled:n,onChange:_=>h(_.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground min-h-28 rounded-md px-2 py-1.5 font-mono text-[11px] leading-relaxed","aria-label":"Candidate content"}),s.jsx("input",{value:g,disabled:n,onChange:_=>y(_.currentTarget.value),className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 rounded-md px-2 text-xs","aria-label":"Candidate tags"}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[s.jsx(gu,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),s.jsx("span",{className:"flex-1"}),b!==null&&s.jsx("span",{className:"text-[10px] text-destructive",children:b}),s.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{k(),l(!1)},children:[s.jsx(jr,{className:"size-3.5"}),"Cancel"]}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:n,onClick:()=>{S()},children:[n?s.jsx(Pt,{className:"size-3.5 animate-spin"}):s.jsx(rk,{className:"size-3.5"}),"Save"]})]})]})}):s.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Te,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),s.jsx(Te,{variant:"outline",className:L("h-5 shrink-0 px-1.5 text-[10px] font-mono",YE[e.status]),children:aR(e.status)})]}),s.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:uR(e.content,360)}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(oj,{className:"size-3"}),dR(e.logIds,i)]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(gu,{className:"size-3"}),cR(e)]}),e.status==="promoted"&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[s.jsx(Oa,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&s.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[s.jsx(wp,{className:"size-3"}),e.error]})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(_=>{const C=js(_,i);return s.jsxs("a",{href:`#${Og(_)}`,onClick:M=>{M.preventDefault(),zg(_)},className:"rounded border border-blue-400/25 px-1.5 py-0.5 font-mono text-[10px] text-blue-400 underline-offset-2 transition-colors hover:bg-blue-400/10 hover:text-blue-300 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":`Jump to evidence log ${C}`,title:`Log ID ${String(_)}`,children:["#",C]},_)}),s.jsx("span",{className:"flex-1"}),j&&s.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:n||t,onClick:()=>l(!0),children:[s.jsx(Tp,{className:"size-3"}),"Review"]}),s.jsxs(ee,{type:"button",variant:v?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>r(e.id),disabled:!v||t||n,children:[t?s.jsx(Pt,{className:"size-3 animate-spin"}):v?s.jsx(Fw,{className:"size-3"}):s.jsx(Oa,{className:"size-3"}),lR(e,t)]})]})]})}function mR({candidates:e,promotingCandidateIds:t,updatingCandidateIds:n,onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i}){return e.length===0?null:s.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(a=>s.jsx(pR,{candidate:a,isPromoting:t.has(a.id),isUpdating:n.has(a.id),onPromoteCandidate:r,onUpdateCandidate:o,displayNumberByLogId:i},a.id))})}function hR({logs:e,scopeId:t,slowResponseThresholdSeconds:n,showRollupMetrics:r,timeDisplayFormat:o}){const[i,a]=c.useState([]),[l,u]=c.useState(!0),[d,f]=c.useState({status:"idle",error:null}),[p,m]=c.useState(()=>new Set),[h,g]=c.useState(()=>new Set),y=i.length>0,b=c.useMemo(()=>PE(e,n,i.length),[i.length,e,n]),w=c.useMemo(()=>sR(e),[e]),v=c.useMemo(()=>rR({logs:e,scopeId:t,summary:b,candidates:i,displayNumberByLogId:w}),[i,w,e,t,b]),j=r||b.maxElapsedMs!==null,k=c.useMemo(()=>XE(b.startedAt,b.endedAt,o),[b.endedAt,b.startedAt,o]),S=c.useCallback(()=>{e.length===0||d.status==="loading"||(f({status:"loading",error:null}),(async()=>{try{const M=await He(`/api/knowledge/sessions/${encodeURIComponent(t)}/candidates`,HE,KE,{method:"POST"},A=>`Candidate generation failed with ${String(A.status)}`);a(M.candidates),u(M.candidates.length>0),f(M.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(M){f({status:"failed",error:M instanceof Error?M.message:"Candidate response was invalid"})}})())},[d.status,e.length,t]),_=c.useCallback(M=>{m(A=>{if(A.has(M))return A;const I=new Set(A);return I.add(M),I}),(async()=>{try{const A=await Hn(`/api/knowledge/candidates/${encodeURIComponent(M)}/promote`,GE,{method:"POST"}),I=await A.json().catch(()=>null),N=VE.safeParse(I);if(A.ok&&N.success){a($=>$.map(F=>F.id===N.data.candidate.id?N.data.candidate:F)),f({status:"ready",error:null});return}const P=WE.safeParse(I);P.success&&P.data.candidate!==void 0&&a($=>$.map(F=>F.id===P.data.candidate?.id?P.data.candidate:F)),f({status:"failed",error:P.success?P.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(A.status)}`})}catch(A){f({status:"failed",error:A instanceof Error?A.message:"Candidate promotion failed"})}finally{m(A=>{const I=new Set(A);return I.delete(M),I})}})()},[]),C=c.useCallback(async(M,A)=>{g(I=>{if(I.has(M))return I;const N=new Set(I);return N.add(M),N});try{const I=await He(`/api/knowledge/candidates/${encodeURIComponent(M)}`,ZE,JE,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)},N=>`Candidate update failed with ${String(N.status)}`);return a(N=>N.map(P=>P.id===I.candidate.id?I.candidate:P)),f({status:"ready",error:null}),!0}catch(I){return f({status:"failed",error:I instanceof Error?I.message:"Candidate update failed"}),!1}finally{g(I=>{const N=new Set(I);return N.delete(M),N})}},[]);return e.length===0?null:s.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[s.jsx(ri,{className:"size-3.5 text-blue-400"}),b.llmCallCount," LLM"]}),s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(wr,{className:"size-3.5 text-sky-400/70"}),b.toolCallCount," tools"]}),r&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(ar,{className:"size-3.5 text-emerald-400"}),s.jsxs("span",{className:"font-mono",children:[Pe(b.totalInputTokens)," / ",Pe(b.totalOutputTokens)]})]}),(b.totalCacheCreationInputTokens>0||b.totalCacheReadInputTokens>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(ar,{className:"size-3.5 text-purple-400"}),s.jsxs("span",{className:"font-mono",children:["KV Cache +",Pe(b.totalCacheCreationInputTokens)," / ~",Pe(b.totalCacheReadInputTokens)]})]}),j&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[s.jsx(sn,{className:"size-3.5"}),r&&s.jsx("span",{className:"font-mono",children:ul(b.totalElapsedMs)}),b.maxElapsedMs!==null&&s.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",ul(b.maxElapsedMs)]})]}),r&&k!==null&&s.jsx("span",{className:"font-mono text-muted-foreground/70",children:k}),(b.failedCallCount>0||b.pendingCallCount>0||b.slowCallCount>0)&&s.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[s.jsx(yn,{className:"size-3.5"}),s.jsxs("span",{className:"font-mono",children:[b.failedCallCount," fail / ",b.pendingCallCount," pending /"," ",b.slowCallCount," slow"]})]}),s.jsx("span",{className:"flex-1"}),y&&s.jsx(Te,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:QE(b.knowledgeCandidateCount)}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:S,disabled:d.status==="loading",children:[d.status==="loading"?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(yp,{className:"size-3.5"}),"Candidate"]}),y&&s.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>u(M=>!M),"aria-expanded":l,"aria-label":l?"Collapse memory candidates":"Expand memory candidates",children:l?s.jsx(et,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"})})]}),d.status==="failed"&&s.jsx("p",{className:"mt-2 text-xs text-destructive",children:d.error}),s.jsx(iR,{insights:v}),l&&s.jsx(mR,{candidates:i,promotingCandidateIds:p,updatingCandidateIds:h,onPromoteCandidate:_,onUpdateCandidate:C,displayNumberByLogId:w})]})}function gR(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalInputTokens:t,totalOutputTokens:n}}function xR(e){const t=new Map;for(const n of e){if(n.model===null)continue;const r=u3(n.model);if(r==="unknown")continue;let o=t.get(r);o===void 0&&(o=new Set,t.set(r,o)),o.add(n.model)}return[...t.entries()].map(([n,r])=>({provider:n,models:[...r]}))}function bR(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function vR(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}const yR=c.memo(function({group:e,viewMode:t="simple",strip:n,slowResponseThresholdSeconds:r,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,onClearGroup:l,showClientIdentity:u=!0,showProcessMetadata:d=!0,showLogClientMetadata:f=!0,defaultExpanded:p=!1,timeDisplayFormat:m,expanded:h,onExpandedChange:g}){const[y,b]=c.useState(p),w=h??y,v=c.useCallback(N=>{if(g!==void 0){g(N);return}b(N)},[g]);c.useEffect(()=>{!p||h!==void 0||b(!0)},[h,p]);const j=c.useMemo(()=>gR(e.logs),[e.logs]),k=c.useMemo(()=>xR(e.logs),[e.logs]),S=e.logs[0]?.timestamp??new Date().toISOString(),_=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),C=e.logs.some(N=>N.responseStatus===null),M=c.useMemo(()=>bR(e.logs),[e.logs]),A=c.useMemo(()=>vR(e.logs),[e.logs]),I=c.useMemo(()=>cl(e.logs),[e.logs]);return c.useEffect(()=>{const N=P=>{const $=Ri(P);$!==null&&e.logs.some(F=>F.id===$.logId)&&v(!0)};return window.addEventListener(cn,N),()=>{window.removeEventListener(cn,N)}},[e.logs,v]),s.jsxs("div",{className:"mb-1.5",children:[s.jsx(NT,{conversationId:e.conversationId,startTime:S,endTime:_,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:w,onToggle:()=>v(!w),providers:k,isLoading:C,userAgent:e.logs[0]?.userAgent??null,clientPid:M,clientProjectFolder:A,showClientIdentity:u,showProcessMetadata:d,timeDisplayFormat:m,onClear:()=>l(e.logs.map(N=>N.id))}),w&&s.jsxs("div",{children:[s.jsx(hR,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:r,showRollupMetrics:!1,timeDisplayFormat:m}),s.jsx(DE,{turnGroups:I,viewMode:t,strip:n,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrends:o,onCompareWithPrevious:i,comparisonPredecessors:a,showLogClientMetadata:f})]})]})}),wR="flex w-full min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/35 px-3 py-2 sm:w-auto sm:max-w-full",jR="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function kR(e){return e==="full"}function SR(e){return e==="raw"}function _R(e,t){const n=t>0;return{redacted:n,raw:n&&kR(e)}}function NR(e,t){const n=e[0],r=e[e.length-1];return n===void 0||r===void 0?null:oi(n.timestamp,r.timestamp,t)}function CR(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function TR(e){const t=new Set;for(const r of e)r.model!==null&&r.model.length>0&&t.add(r.model);const n=[...t].sort();return n.length===0?"Model unknown":n.length===1?n[0]??"Model unknown":`${n.length} models`}function ER(e){const t=new Set;for(const r of e)r.providerName!==null&&r.providerName!==void 0&&r.providerName.length>0&&t.add(r.providerName);const n=[...t].sort();return n.length===0?"Provider unknown":n.length===1?n[0]??"Provider unknown":`${n.length} providers`}function RR(e){if(e<1e3)return`${e}ms`;if(e<6e4){const o=e/1e3;return`${o<10?o.toFixed(1):o.toFixed(0)}s`}const t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}m ${r}s`}function IR(e,t){return`${Pe(e)} in / ${Pe(t)} out`}function PR(e,t){if(e.length===0)return 0;if(t.length===0)return cl(e).length;let n=0;for(const r of t)n+=cl(r.logs).length;return n}function MR({stopReason:e,pending:t,lastFailureLogNumber:n}){if(t>0)return{label:"In flight",detail:`${t} request${t===1?"":"s"} pending`,tone:"cool"};if(n!==null&&e===null)return{label:"Error",detail:`Last failed request #${n}`,tone:"danger"};switch(e){case"end_turn":return{label:"End turn",detail:"Assistant completed the turn",tone:"neutral"};case"stop":return{label:"Stop",detail:"Model reached a stop condition",tone:"neutral"};case"length":return{label:"Output limit",detail:"Turn ended at max output tokens",tone:"watch"};case"tool_use":return{label:"Tool call",detail:"Assistant requested a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No finish reason captured",tone:"neutral"}}}function AR(e){if(e===null)return!1;const t=e.toLowerCase();return t.includes("abort")||t.includes("cancel")||t.includes("client disconnected")||t.includes("stream disconnected")||t.includes("connection closed")}function OR({pending:e,failures:t,lengthStops:n,stopReason:r,lastFailure:o}){if(o!==null&&(o.status===499||AR(o.error)))return{label:"Client aborted",detail:`Request #${o.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(o!==null&&o.status!==null&&o.status>=500)return{label:"Provider error",detail:`Request #${o.logNumber} returned HTTP ${o.status}`,tone:"danger"};if(t>0&&o!==null)return{label:"Failed",detail:`Request #${o.logNumber} needs attention`,tone:"danger"};if(n>0||r==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(r){case"end_turn":case"stop":return{label:"Completed",detail:"Assistant completed normally",tone:"neutral"};case"tool_use":return{label:"Tool requested",detail:"Assistant handed off to a tool",tone:"cool"};case null:return{label:"Unknown",detail:"No terminal signal captured",tone:"neutral"}}}function zR({logs:e,conversationGroups:t,isLoading:n,timeDisplayFormat:r,slowResponseThresholdSeconds:o}){let i=0,a=0,l=0,u=0,d=0,f=0,p=null,m=null,h=null,g=null,y=null,b=0,w=0,v=0,j=null;const k=o*1e3;for(let A=0;A<e.length;A+=1){const I=e[A];if(I===void 0)continue;const N=A+1,P=yg(I);P!==null&&(p=P),P==="length"&&(u+=1),CR(I)&&(i+=1,m=N,h={logNumber:N,status:I.responseStatus,error:I.error??null}),I.responseStatus===null&&(a+=1),o>0&&I.elapsedMs!==null&&I.elapsedMs>=k&&(l+=1),I.inputTokens!==null&&(d+=I.inputTokens),I.outputTokens!==null&&(f+=I.outputTokens),I.elapsedMs!==null&&(g===null||I.elapsedMs>g)&&(g=I.elapsedMs,y=N);const $=I.inputTokens??0,F=I.outputTokens??0,G=$+F;G>b&&(b=G,w=$,v=F,j=N)}const S=n||a>0&&i===0?"rolling":i>0?"failed":l>0||u>0?"watch":"clear",_=S==="rolling"?"Rolling":S==="failed"?"Failure":S==="watch"?"Watch":"Clear",C=MR({stopReason:p,pending:a,lastFailureLogNumber:m}),M=OR({pending:a,failures:i,lengthStops:u,stopReason:p,lastFailure:h});return{status:S,statusLabel:_,modelLabel:TR(e),providerLabel:ER(e),requests:e.length,turns:PR(e,t),failures:i,pending:a,slow:l,lengthStops:u,timeRange:NR(e,r),tokenLabel:`${Pe(d)} in / ${Pe(f)} out`,finishLabel:C.label,finishDetail:C.detail,finishTone:C.tone,outcomeLabel:M.label,outcomeDetail:M.detail,outcomeTone:M.tone,slowestLabel:g===null?"n/a":RR(g),slowestDetail:y===null?"Latency pending":`Request #${y}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${IR(w,v)}`}}function LR({pinnedSessionId:e,selectedSession:t,sessions:n,logs:r}){if(e!==void 0){const a=r.filter(l=>l.sessionId===e);return a.length===0?null:{label:e,logs:a,showBackLink:!0}}if(t!=="__all__"){const a=r.filter(l=>l.sessionId===t);return a.length===0?null:{label:t,logs:a,showBackLink:!0}}const o=n.length===1?n[0]??null:null;return o!==null&&r.every(l=>l.sessionId===o)?{label:o,logs:[...r],showBackLink:!1}:n.length===0&&r.length>0&&r.every(a=>a.sessionId===null)?{label:"Visible requests",logs:[...r],showBackLink:!1}:null}function $R({logs:e,pagination:t}){if(t.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const n=e[0],r=e[e.length-1],o=n===void 0||r===void 0?"Current page":`#${n.id}-#${r.id}`;return t.total===null?`Showing ${e.length} logs (${o})`:t.total<=e.length?`Showing all ${t.total} logs`:`Showing ${e.length} of ${t.total} logs (${o})`}function pr({...e}){return s.jsx(ch,{"data-slot":"select",...e})}function Uo({...e}){return s.jsx(ph,{"data-slot":"select-value",...e})}function mr({className:e,size:t="default",children:n,...r}){return s.jsxs(dh,{"data-slot":"select-trigger","data-size":t,className:L("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,s.jsx(mh,{asChild:!0,children:s.jsx(et,{className:"size-4 opacity-50"})})]})}function hr({className:e,children:t,position:n="popper",align:r="center",...o}){return s.jsx(gh,{children:s.jsxs(xh,{"data-slot":"select-content",className:L("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,align:r,...o,children:[s.jsx(DR,{}),s.jsx(jh,{className:L("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),s.jsx(FR,{})]})})}function lt({className:e,children:t,...n}){return s.jsxs(Nh,{"data-slot":"select-item",className:L("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...n,children:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(Eh,{children:s.jsx(qe,{className:"size-4"})})}),s.jsx(Ch,{children:t})]})}function DR({className:e,...t}){return s.jsx(Rh,{"data-slot":"select-scroll-up-button",className:L("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(Bl,{className:"size-4"})})}function FR({className:e,...t}){return s.jsx(Ih,{"data-slot":"select-scroll-down-button",className:L("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(et,{className:"size-4"})})}const UR=pe(["critical","warning","notice"]),BR=pe(["open"]),qR=pe(["proxy","tool-schema","run","group"]),Lg=pe(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),HR=pe(["log","session","run","group"]),VR=pe(["anthropic","openai","unknown"]),WR=E({kind:HR,id:x(),label:x(),href:x().nullable()}),ZR=E({id:x(),fingerprint:x(),severity:UR,category:Lg,source:qR,status:BR,title:x(),message:x(),count:R().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:K(R().int().positive()),sessionIds:K(x()),runIds:K(x()),groupIds:K(x()),provider:x().nullable(),model:x().nullable(),apiFormat:VR.nullable(),evidence:K(WR),metadata:We(x(),Qe)}),KR=E({category:Lg,count:R().int().nonnegative()}),$g=E({total:R().int().nonnegative(),open:R().int().nonnegative(),critical:R().int().nonnegative(),warning:R().int().nonnegative(),notice:R().int().nonnegative(),byCategory:K(KR)}),GR=E({alerts:K(ZR),total:R().int().nonnegative(),limit:R().int().positive(),summary:$g}),JR=8e3,YR=1e4;function XR(e){const t=new URLSearchParams;e.severity!==void 0&&t.set("severity",e.severity),e.category!==void 0&&t.set("category",e.category),e.source!==void 0&&t.set("source",e.source),e.limit!==void 0&&t.set("limit",String(e.limit));const n=t.toString();return n.length>0?`/api/alerts?${n}`:"/api/alerts"}function QR(e,t){const n=Bt(t?XR(e):null,r=>He(r,GR,YR));return{alerts:n.data?.alerts??[],total:n.data?.total??0,summary:n.data?.summary??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}function eI(){const e=Bt("/api/alerts/summary",t=>He(t,$g,JR),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const Rr="relative size-9 rounded-md border border-border/70 bg-muted/60 text-muted-foreground transition-colors hover:bg-muted hover:text-accent-foreground focus-visible:ring-ring/50 max-lg:size-11",tI=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function Dg(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function nI(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Tc(e){switch(e){case"request-failure":return"Request failure";case"request-timeout":return"Timeout";case"slow-response":return"Slow response";case"tool-schema":return"Tool calling";case"run-failure":return"Run failure";case"group-failure":return"Group failure";case"group-incomplete":return"Group incomplete"}}function sI(e){switch(e){case"critical":return"border-status-danger/40 bg-status-danger/10 text-status-danger";case"warning":return"border-status-watch/40 bg-status-watch/10 text-status-watch";case"notice":return"border-status-cool/40 bg-status-cool/10 text-status-cool"}}function rI(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function oI(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function iI(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return s.jsx(gk,{className:"size-3.5"});case"request-timeout":case"slow-response":return s.jsx(Lw,{className:"size-3.5"});case"tool-schema":return s.jsx(yn,{className:"size-3.5"});case"group-incomplete":return s.jsx(iw,{className:"size-3.5"})}}function dl(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function gt(e){return e.toLocaleString()}function Fg(e){return e.provider!==null&&e.model!==null?`${e.provider} / ${e.model}`:e.provider!==null?e.provider:e.model!==null?e.model:"Unknown target"}function aI(e,t){const n={limit:100};return e!=="all"&&(n.severity=e),t!=="all"&&(n.category=t),n}function lI(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function Gr({label:e,count:t,tone:n}){const r=n==="critical"?"border-status-danger/30 bg-status-danger/10 text-status-danger":n==="warning"?"border-status-watch/30 bg-status-watch/10 text-status-watch":n==="notice"?"border-status-cool/30 bg-status-cool/10 text-status-cool":"border-border bg-muted/40 text-foreground";return s.jsxs("div",{className:L("rounded-md border px-3 py-2",r),children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),s.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:gt(t)})]})}function Jr({value:e,active:t,label:n,count:r,onClick:o}){return s.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>o(e),className:"h-7 px-2",children:[n,r!==null?s.jsx(Te,{variant:"outline",children:gt(r)}):null]})}function cI({category:e,active:t,count:n,onClick:r}){return s.jsxs(ee,{type:"button",variant:t?"secondary":"ghost",size:"sm","aria-pressed":t,onClick:()=>r(e),className:"h-7 px-2",children:[iI(e),Tc(e),s.jsx(Te,{variant:"outline",children:gt(n)})]})}function uI({alerts:e,selectedAlertId:t,isLoading:n,error:r,onSelect:o}){return n?s.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[s.jsx(De,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):r!==void 0?s.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:r.message}):e.length===0?s.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"No alerts match the current filters."}):s.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(i=>{const a=i.id===t;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:L("w-full rounded-md border px-3 py-3 text-left transition-colors",a?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:L("size-2 rounded-full",rI(i.severity))}),s.jsx("span",{className:L("text-xs font-semibold",oI(i.severity)),children:Dg(i.severity)}),s.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Tc(i.category)})]}),s.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:i.title}),s.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:i.message})]}),i.count>1?s.jsxs(Te,{variant:"outline",className:"shrink-0",children:["x",gt(i.count)]}):null]}),s.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 leading-snug",children:Fg(i)}),s.jsx("span",{className:"shrink-0",children:dl(i.lastSeenAt)})]})]},i.id)})})}function dI({alert:e,onNavigate:t}){return e.evidence.length===0?s.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):s.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(n=>n.href===null?s.jsx(Te,{variant:"outline",children:n.label},`${n.kind}:${n.id}`):s.jsx(Te,{variant:"outline",asChild:!0,children:s.jsx("a",{href:n.href,onClick:t,children:n.label})},`${n.kind}:${n.id}`))})}function fI({alert:e,onNavigate:t}){return e===null?s.jsx("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground",children:"Select an alert to inspect its evidence."}):s.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[s.jsx("div",{className:L("border-b px-4 py-3",sI(e.severity)),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Te,{variant:"outline",children:Dg(e.severity)}),s.jsx(Te,{variant:"outline",children:nI(e.source)}),s.jsx(Te,{variant:"outline",children:Tc(e.category)})]}),s.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),s.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?s.jsxs(Te,{variant:"outline",className:"shrink-0",children:[gt(e.count)," hits"]}):null]})}),s.jsxs("div",{className:"space-y-4 p-4",children:[s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(dn,{label:"Target",value:Fg(e)}),s.jsx(dn,{label:"Last seen",value:dl(e.lastSeenAt)}),s.jsx(dn,{label:"First seen",value:dl(e.firstSeenAt)}),s.jsx(dn,{label:"Protocol",value:e.apiFormat??"n/a"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),s.jsx(dI,{alert:e,onNavigate:t})]}),s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsx(dn,{label:"Logs",value:e.logIds.length===0?"n/a":gt(e.logIds.length)}),s.jsx(dn,{label:"Sessions",value:e.sessionIds.length===0?"n/a":gt(e.sessionIds.length)}),s.jsx(dn,{label:"Runs",value:e.runIds.length===0?"n/a":gt(e.runIds.length)}),s.jsx(dn,{label:"Groups",value:e.groupIds.length===0?"n/a":gt(e.groupIds.length)})]})]})]})}function dn({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[s.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:t})]})}function pI(){const[e,t]=c.useState(!1),[n,r]=c.useState("all"),[o,i]=c.useState("all"),[a,l]=c.useState(null),{summary:u,isLoading:d}=eI(),f=c.useMemo(()=>aI(n,o),[o,n]),{alerts:p,total:m,isLoading:h,error:g,mutate:y}=QR(f,e),b=c.useMemo(()=>lI(p,a),[p,a]);c.useEffect(()=>{!e||a!==null&&p.some(C=>C.id===a)||l(p[0]?.id??null)},[p,e,a]);const w=u?.total??0,v=u?.critical??0,j=u?.warning??0,k=u?.notice??0,S=v>0?"bg-status-danger text-primary-foreground":j>0?"bg-status-watch text-primary-foreground":"bg-status-cool text-primary-foreground";return s.jsxs(Wt,{open:e,onOpenChange:t,children:[s.jsx(Nr,{asChild:!0,children:s.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:Rr,"aria-label":"Alerts",title:"Alerts",children:[s.jsx(Co,{className:"size-4"}),d?s.jsx(De,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?s.jsx("span",{className:L("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",S),children:gt(w)}):null,s.jsx("span",{className:"sr-only",children:"Alerts"})]})}),s.jsxs(Zt,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[s.jsxs(Yt,{children:[s.jsxs(Xt,{className:"flex items-center gap-2 pr-8",children:[s.jsx(Co,{className:"size-5 text-status-danger"}),s.jsx("span",{children:"Alerts"}),s.jsx(Te,{variant:"outline",children:gt(w)})]}),s.jsx(Cr,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(Gr,{label:"Open",count:u?.open??0,tone:"neutral"}),s.jsx(Gr,{label:"Critical",count:v,tone:"critical"}),s.jsx(Gr,{label:"Warning",count:j,tone:"warning"}),s.jsx(Gr,{label:"Notice",count:k,tone:"notice"})]}),s.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(Jr,{value:"all",active:n==="all",label:"All",count:u?.total??null,onClick:r}),s.jsx(Jr,{value:"critical",active:n==="critical",label:"Critical",count:v,onClick:r}),s.jsx(Jr,{value:"warning",active:n==="warning",label:"Warning",count:j,onClick:r}),s.jsx(Jr,{value:"notice",active:n==="notice",label:"Notice",count:k,onClick:r})]}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{y()},children:[s.jsx(Pt,{className:"size-3.5"}),"Refresh"]})]}),s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx(ee,{type:"button",variant:o==="all"?"secondary":"ghost",size:"sm","aria-pressed":o==="all",onClick:()=>i("all"),className:"h-7 px-2",children:"All categories"}),tI.map(_=>{const C=u?.byCategory.find(M=>M.category===_)?.count??0;return C===0?null:s.jsx(cI,{category:_,active:o===_,count:C,onClick:i},_)})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[s.jsxs("div",{className:"flex min-h-0 flex-col",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[s.jsxs("span",{children:[gt(m)," matched"]}),s.jsx("span",{children:p.length<m?`${gt(p.length)} shown`:"Latest"})]}),s.jsx(uI,{alerts:p,selectedAlertId:b?.id??null,isLoading:h,error:g,onSelect:l})]}),s.jsx(fI,{alert:b,onNavigate:()=>t(!1)})]})]})]})}const mI=12e3;function hI(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function gI(e){const t=Bt(hI(e),n=>He(n,Ay,mI));return{evidenceResponse:t.data??null,isLoading:t.isLoading,error:t.error,mutate:t.mutate}}const xI=8e3;function bI(){const e=Bt("/api/groups",t=>He(t,xp,xI));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const vI=3e3;function yI(e,t){return{id:(e?.id??0)+1,message:t.message,tone:t.tone??"error"}}function Ug(){const[e,t]=c.useState(null),n=c.useCallback(o=>{t(i=>yI(i,o))},[]),r=c.useCallback(()=>{t(null)},[]);return c.useEffect(()=>{if(e===null)return;const o=window.setTimeout(()=>{t(null)},vI);return()=>{window.clearTimeout(o)}},[e]),{notice:e,showToast:n,dismissToast:r}}function Bg({notice:e,onDismiss:t}){if(e===null)return null;const n=e.tone==="error",r=n?yn:Oa;return s.jsx("div",{"aria-atomic":"true","aria-live":"polite",className:"pointer-events-none fixed top-4 right-4 z-[100] w-[min(calc(100vw-2rem),26rem)]",role:"status",children:s.jsxs("div",{className:L("pointer-events-auto flex items-start gap-2 rounded-md border bg-popover/95 px-3 py-2 text-sm text-popover-foreground shadow-[0_18px_50px_color-mix(in_oklch,var(--foreground)_16%,transparent)] backdrop-blur",n?"border-status-danger/35":"border-status-success/35"),children:[s.jsx(r,{className:L("mt-0.5 size-4 shrink-0",n?"text-status-danger":"text-status-success")}),s.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),s.jsx("button",{type:"button",className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-current/70 transition-colors hover:bg-white/10 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none","aria-label":"Dismiss notification",onClick:t,children:s.jsx(jr,{className:"size-3.5"})})]},e.id)})}const da=2e4;function wI(e,t){const n=`/api/groups/${encodeURIComponent(e)}`;return t?`${n}?deleteEvidence=1`:n}function jI(e){return e?"/api/groups?deleteEvidence=1":"/api/groups"}function qg(e){let t=0,n=0,r=0,o=0;for(const i of e.members)switch(i.status){case"completed":t+=1;break;case"failed":case"cancelled":n+=1;break;case"running":r+=1;break;case"created":break;case null:o+=1;break}return{memberCount:e.members.length,completedMembers:t,failedMembers:n,runningMembers:r,missingStatusMembers:o}}function kI(e,t,n=null){return t!==null&&t.group.id===e.id?t.members.map(r=>({member:r.member,exportMember:r,source:"export"})):n!==null&&n.group.id===e.id&&n.members!==null?n.members.map(r=>({member:r.member,exportMember:r,source:"evidence"})):e.members.map(r=>({member:r,exportMember:null,source:"group"}))}function Ec(e){switch(e){case"completed":return"border-status-success/30 bg-status-success/10 text-status-success";case"failed":case"cancelled":return"border-status-danger/30 bg-status-danger/10 text-status-danger";case"running":return"border-status-cool/30 bg-status-cool/10 text-status-cool";case"created":return"border-border bg-muted/30 text-muted-foreground";case null:return"border-border bg-muted/30 text-muted-foreground"}}function Rc(e){return e??"unknown"}function SI(e){switch(e){case"PASS":return"border-status-success/30 bg-status-success/10 text-status-success";case"FAIL":return"border-status-danger/30 bg-status-danger/10 text-status-danger";case"RUNNING":return"border-status-cool/30 bg-status-cool/10 text-status-cool";case"UNKNOWN":return"border-border bg-muted/30 text-muted-foreground"}}function Ii(e){return e===null||e.trim().length===0?"-":e}function ht(e){return e.toLocaleString()}function fl(e){return e==null?"-":e<1e3?`${ht(e)} ms`:`${(e/1e3).toFixed(1)} s`}function As(e){const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(t)):e}function ld(e){return e===null?"-":As(e)}function _I(e){const t=JSON.stringify(e),n=t===void 0?String(e):t;return n.length<=160?n:`${n.slice(0,157)}...`}function Hg(...e){for(const t of e)if(t!==null&&t.trim().length>0)return t;return"-"}function NI(...e){for(const t of e)if(t!=null&&t.trim().length>0)return t;return null}function CI(e){const t=e.provider,n=e.model;return t!==null&&t.length>0&&n!==null&&n.length>0?`${t} / ${n}`:Hg(t,n)}function TI(e,t){if(t!==null){const n=e.find(r=>r.id===t);if(n!==void 0)return n}return e[0]??null}function EI(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function RI(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function II(e,t){return t!==null&&t.group.id===e.id?t.evidence:e.evidence}function PI(e,t,n){return t!==null&&t.group.id===e.id?t.summary:n!==null&&n.group.id===e.id?n.summary:null}function MI(e,t,n){return t!==null&&t.group.id===e.id?t.jenkinsReport:n!==null&&n.group.id===e.id?n.report:null}function AI({labelledTrigger:e=!1}){const[t,n]=c.useState(!1),[r,o]=c.useState(null),[i,a]=c.useState(null),[l,u]=c.useState(null),[d,f]=c.useState(null),[p,m]=c.useState(null),[h,g]=c.useState(!1),[y,b]=c.useState(null),[w,v]=c.useState(null),[j,k]=c.useState(!1),{notice:S,showToast:_,dismissToast:C}=Ug(),{groups:M,isLoading:A,error:I,mutate:N}=bI(),P=c.useMemo(()=>TI(M,r),[M,r]);c.useEffect(()=>{!t||r!==null&&M.some(ie=>ie.id===r)||o(M[0]?.id??null)},[M,t,r]);const $=P!==null&&d!==null&&d.group.id===P.id?d:null,{evidenceResponse:F,isLoading:G,error:X,mutate:U}=gI(P),V=c.useCallback(()=>{N()},[N]),Y=c.useCallback(async()=>{if(!(M.length===0||j)){k(!0),m(null),g(!1),v(null),u(null);try{const D=await He(jI(!1),mp,da,{method:"DELETE"},ie=>`Clear failed with status ${String(ie.status)}`);f(null),o(null),await N(),await U(),_({message:`Cleared ${ht(D.deleted)} group${D.deleted===1?"":"s"}.`,tone:"success"})}catch(D){_({message:D instanceof Error?D.message:"Unknown error clearing groups",tone:"error"})}finally{k(!1)}}},[j,M.length,N,U,_]),B=c.useCallback(async D=>{a(D.id),u(null);try{const ie=await He(`/api/groups/${encodeURIComponent(D.id)}/evidence`,Oy,da,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},te=>`Export failed with status ${String(te.status)}`);f(ie),await N(),await U()}catch(ie){u(ie instanceof Error?ie.message:String(ie))}finally{a(null)}},[N,U]),W=c.useCallback(D=>{m(D),g(!1),v(null)},[]),me=c.useCallback(()=>{y===null&&(m(null),g(!1),v(null))},[y]),ve=c.useCallback(D=>{o(D),m(null),g(!1),v(null)},[]),we=c.useCallback(async()=>{const D=p;if(D!==null){b(D.id),v(null);try{await He(wI(D.id,h),pp,da,{method:"DELETE"},ie=>`Delete failed with status ${String(ie.status)}`),f(ie=>ie!==null&&ie.group.id===D.id?null:ie),o(ie=>ie===D.id?null:ie),m(null),g(!1),await N(),await U()}catch(ie){v(ie instanceof Error?ie.message:String(ie))}finally{b(null)}}},[h,p,N,U]);return s.jsxs(Wt,{open:t,onOpenChange:n,children:[s.jsx(Bg,{notice:S,onDismiss:C}),s.jsx(Nr,{asChild:!0,children:s.jsxs(ee,{type:"button",variant:"ghost",size:e?"default":"icon",className:L(Rr,e&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"Evaluation groups",title:"Evaluation groups",children:[s.jsx(pu,{className:"size-4"}),A?s.jsx(De,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):M.length>0?s.jsx("span",{className:"absolute -right-1 -top-1 min-w-4 rounded-full bg-primary px-1 text-[10px] leading-4 text-primary-foreground",children:M.length}):null,s.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),s.jsxs(Zt,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[s.jsx(Yt,{children:s.jsxs(Xt,{className:"flex items-center gap-2 pr-8",children:[s.jsx(pu,{className:"size-5 text-muted-foreground"}),s.jsx("span",{children:"Groups"}),s.jsx(Te,{variant:"outline",children:ht(M.length)})]})}),s.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[s.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:M.length===0||j,onClick:()=>{Y()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(wn,{className:"size-3.5"}),"Clear"]}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:V,children:[s.jsx(Pt,{className:"size-3.5"}),"Refresh"]})]})]}),s.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[s.jsx(OI,{groups:M,selectedGroupId:P?.id??null,isLoading:A,error:I,onSelect:ve}),s.jsx(zI,{group:P,deleteTarget:p,deleteEvidence:h,exportResult:$,evidenceResponse:F,evidenceLoading:G,evidenceError:X,exportError:l,deleteError:w,exportingGroupId:i,deletingGroupId:y,onDeleteEvidenceChange:g,onExport:B,onRequestDelete:W,onCancelDelete:me,onConfirmDelete:()=>{we()}})]})]})]})}function OI({groups:e,selectedGroupId:t,isLoading:n,error:r,onSelect:o}){return n?s.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Loading groups..."}):r!==void 0?s.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:r.message}):e.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No groups yet."}):s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsx("div",{className:"space-y-2",children:e.map(i=>{const a=qg(i),l=t===i.id;return s.jsxs("button",{type:"button",onClick:()=>o(i.id),className:L("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",l?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:i.title}),s.jsx(Te,{variant:"outline",className:Ec(i.status),children:Rc(i.status)})]}),s.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[s.jsxs("span",{children:[a.memberCount," sessions"]}),s.jsx("span",{children:As(i.updatedAt)})]})]},i.id)})})})}function zI({group:e,deleteTarget:t,deleteEvidence:n,exportResult:r,evidenceResponse:o,evidenceLoading:i,evidenceError:a,exportError:l,deleteError:u,exportingGroupId:d,deletingGroupId:f,onDeleteEvidenceChange:p,onExport:m,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:y}){if(e===null)return s.jsx("div",{className:"flex min-h-48 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:"Select a group to inspect."});const b=qg(e),w=PI(e,r,o),v=MI(e,r,o),j=II(e,r),k=kI(e,r,o),S=d===e.id,_=f===e.id,C=t?.id===e.id;return s.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),s.jsx(Te,{variant:"outline",className:Ec(e.status),children:Rc(e.status)}),s.jsx(Te,{variant:"outline",children:e.kind})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[s.jsx("span",{children:Ii(e.project)}),s.jsxs("span",{children:["updated ",As(e.updatedAt)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(ee,{type:"button",variant:"outline",size:"icon",className:"size-8 text-status-danger hover:text-status-danger/80","aria-label":"Delete group",title:"Delete group",disabled:_,onClick:()=>h(e),children:_?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(wn,{className:"size-3.5"})}),s.jsxs(ee,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:S||_,onClick:()=>{m(e)},children:[S?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(yr,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&s.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),C&&s.jsx(LI,{group:e,deleteEvidence:n,isDeleting:_,error:u,onDeleteEvidenceChange:p,onCancel:g,onConfirm:y}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(fn,{label:"Members",value:b.memberCount}),s.jsx(fn,{label:"Done",value:b.completedMembers}),s.jsx(fn,{label:"Failed",value:b.failedMembers}),s.jsx(fn,{label:"Running",value:b.runningMembers})]}),w!==null&&s.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[s.jsx(fn,{label:"Requests",value:w.requestCount}),s.jsx(fn,{label:"Errors",value:w.errorCount}),s.jsx(fn,{label:"Tokens",value:w.tokenUsage.total}),s.jsx(fn,{label:"Missing",value:w.missingSessions})]}),s.jsx($I,{report:v,loading:i,error:a,hasEvidence:j!==null}),s.jsx(DI,{evidence:j}),l!==null&&s.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:l}),u!==null&&!C&&s.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:u}),s.jsx(FI,{rows:k})]})})}function LI({group:e,deleteEvidence:t,isDeleting:n,error:r,onDeleteEvidenceChange:o,onCancel:i,onConfirm:a}){const l=e.evidence!==null,u=e.evidence?.markdownPath??"No evidence pack exported.";return s.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:s.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[s.jsxs("div",{className:"min-w-0 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[s.jsx(wn,{className:"size-4 text-status-danger"}),s.jsx("span",{children:"Delete group?"})]}),s.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",s.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),s.jsxs("label",{className:L("flex min-w-0 items-start gap-2 text-xs",l?"cursor-pointer":"opacity-60"),children:[s.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:t,disabled:!l||n,onChange:d=>o(d.currentTarget.checked)}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),s.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:u})]})]}),r!==null&&s.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:r})]}),s.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[s.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:n,onClick:i,children:"Cancel"}),s.jsxs(ee,{type:"button",variant:"destructive",size:"sm",disabled:n,onClick:a,children:[n?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(wn,{className:"size-3.5"}),"Delete"]})]})]})})}function fn({label:e,value:t}){return s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),s.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:ht(t)})]})}function $I({report:e,loading:t,error:n,hasEvidence:r}){const{copied:o,copy:i}=bn(e?.markdown??null);return e===null&&!t&&n===void 0?null:t?s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[s.jsx(De,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):n!==void 0&&r?s.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:["Failed to load evidence report: ",n.message]}):e===null?null:s.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),s.jsx(Te,{variant:"outline",className:SI(e.status),children:e.status})]}),s.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":o?"Copied evidence report":"Copy evidence report",onClick:i,children:o?s.jsx(qe,{className:"size-3.5 text-status-success"}):s.jsx(zt,{className:"size-3.5"})})]}),s.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function DI({evidence:e}){return e===null?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No evidence pack exported yet."}):s.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),s.jsx("span",{className:"text-[11px] text-muted-foreground",children:As(e.exportedAt)})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(fa,{label:"JSON",value:e.jsonPath}),s.jsx(fa,{label:"Markdown",value:e.markdownPath}),s.jsx(fa,{label:"HTML",value:e.htmlPath})]})]})}function fa({label:e,value:t}){const{copied:n,copy:r}=bn(t);return s.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[s.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:t}),s.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":n?`Copied ${e} path`:`Copy ${e} path`,onClick:r,children:n?s.jsx(qe,{className:"size-3.5 text-status-success"}):s.jsx(zt,{className:"size-3.5"})})]})}function FI({rows:e}){const[t,n]=c.useState(null),r=c.useCallback(o=>{n(i=>i===o?null:o)},[]);return e.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-8 text-center text-xs text-muted-foreground",children:"No sessions attached."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[s.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:s.jsxs("tr",{children:[s.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),s.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),s.jsx("tbody",{children:e.map(o=>{const i=t===o.member.id;return s.jsxs(c.Fragment,{children:[s.jsx(UI,{row:o,isExpanded:i,onToggleDetails:r}),s.jsx(BI,{row:o,isExpanded:i})]},o.member.id)})})]})})]})}function UI({row:e,isExpanded:t,onToggleDetails:n}){const r=e.member,o=e.exportMember?.session??null,i=EI(e),a=o?.inspectorPath??uf(r.sessionId),l=e.source!=="evidence",u=o?.requestCount??null,d=o?.errorCount??null,f=o?.tokenUsage.total??null,p=i?.firstChunkMs??null,m=Hg(r.label,r.sessionId),h=NI(o?.clientUserAgent,i?.userAgent,r.agent),g=o?.clientProjectFolder??null,y=xc({userAgent:h,conversationId:r.sessionId,clientProjectFolder:g}),b=Ni(y);return s.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[s.jsxs("td",{className:"max-w-56 px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":t?`Hide member ${m}`:`Show member ${m}`,title:t?"Hide member details":"Show member details",onClick:()=>{n(r.id)},children:t?s.jsx(et,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"})}),b!==null&&s.jsx(Ci,{client:y,className:"size-5"}),l?s.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-primary outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","aria-label":`Open session ${m}`,title:`Open session ${m}`,children:[s.jsx("span",{className:"min-w-0 truncate",children:m}),s.jsx(ql,{className:"size-3 shrink-0 text-muted-foreground"})]}):s.jsxs("button",{type:"button",className:"inline-flex max-w-full min-w-0 items-center gap-2 rounded-sm font-mono text-xs text-foreground outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",title:`Show evidence snapshot for ${m}`,"aria-label":`Show evidence snapshot for ${m}`,onClick:()=>{n(r.id)},children:[s.jsx("span",{className:"min-w-0 truncate",children:m}),s.jsx(Te,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),s.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Ii(r.agent)})]}),s.jsx("td",{className:"max-w-52 px-3 py-2",children:s.jsx("span",{className:"block whitespace-normal leading-snug",children:CI(r)})}),s.jsx("td",{className:"px-3 py-2",children:s.jsx(Te,{variant:"outline",className:Ec(r.status),children:Rc(r.status)})}),s.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":ht(u)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":ht(d)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:fl(p)}),s.jsx("td",{className:"px-3 py-2 font-mono",children:f===null?"-":ht(f)})]})}function BI({row:e,isExpanded:t}){if(!t)return null;const n=e.member,r=e.exportMember,o=r?.session??null,i=r?.run??null,a=Object.entries(n.metadata);return s.jsx("tr",{className:"border-b border-border bg-muted/10",children:s.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:s.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(tt,{label:"Source",value:RI(e.source)}),s.jsx(tt,{label:"Member ID",value:n.id,mono:!0}),s.jsx(tt,{label:"Session ID",value:n.sessionId,mono:!0}),s.jsx(tt,{label:"Run ID",value:i?.id??n.runId??"-",mono:!0}),s.jsx(tt,{label:"Created",value:As(n.addedAt)}),s.jsx(tt,{label:"Updated",value:As(n.updatedAt)}),s.jsx(tt,{label:"Session created",value:ld(o?.createdAt??null)}),s.jsx(tt,{label:"Session updated",value:ld(o?.updatedAt??null)})]}),o===null?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No session snapshot is available for this member."}):s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(tt,{label:"Log coverage",value:o.logCoverage}),s.jsx(tt,{label:"Runtime",value:Ii(o.runtimeMode)}),s.jsx(tt,{label:"Requests",value:ht(o.requestCount),mono:!0}),s.jsx(tt,{label:"Errors",value:ht(o.errorCount),mono:!0}),s.jsx(tt,{label:"Input tokens",value:ht(o.tokenUsage.input),mono:!0}),s.jsx(tt,{label:"Output tokens",value:ht(o.tokenUsage.output),mono:!0}),s.jsx(tt,{label:"Cache read",value:ht(o.tokenUsage.cacheRead),mono:!0}),s.jsx(tt,{label:"Total tokens",value:ht(o.tokenUsage.total),mono:!0})]}),s.jsx(qI,{logs:o?.latestLogs??[]}),s.jsx(HI,{entries:a})]})})})}function tt({label:e,value:t,mono:n=!1}){return s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),s.jsx("div",{className:L("truncate text-xs text-foreground",n?"font-mono":""),title:t,children:t})]})}function qI({logs:e}){const t=e.slice(0,5);return t.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-border px-3 py-2 text-xs text-muted-foreground",children:"No latest logs in this snapshot."}):s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Latest logs"}),s.jsx("div",{className:"divide-y divide-border",children:t.map(n=>{const r=n.sessionLogNumber??n.id;return s.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[s.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(n.id)}`,children:["#",r]}),s.jsxs("span",{className:"min-w-0 truncate",children:[Ii(n.model)," · ",n.apiFormat," · ",n.path]}),s.jsx("span",{className:"font-mono text-muted-foreground",children:fl(n.firstChunkMs)}),s.jsx("span",{className:"font-mono text-muted-foreground",children:fl(n.latencyMs)})]},n.id)})})]})}function HI({entries:e}){return e.length===0?null:s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Metadata"}),s.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([t,n])=>{const r=_I(n);return s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"mr-2 text-muted-foreground",children:t}),s.jsx("span",{className:"font-mono text-foreground",title:r,children:r})]},t)})})]})}const VI=E({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:pe(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:K(x()),sourceTool:pe(["claude-code","opencode","mimo-code"]),alreadyExists:Re()}),WI=E({scanId:x().uuid(),providers:K(VI),warnings:K(x()).optional()});E({scanId:x().uuid(),selectionIds:K(x().uuid()).min(1).max(100)});const ZI=E({success:Re().optional(),imported:R().optional(),message:x().optional(),errors:K(x()).optional()}),cd=2e4;function KI({open:e,onOpenChange:t,onImportComplete:n}){const[r,o]=c.useState(!1),[i,a]=c.useState(null),[l,u]=c.useState(null),[d,f]=c.useState([]),[p,m]=c.useState([]),[h,g]=c.useState(new Set),[y,b]=c.useState(!1),[w,v]=c.useState(null),[j,k]=c.useState(null),S=c.useRef(0),_=c.useRef(0),C=c.useCallback(()=>{const N=S.current+1;S.current=N,o(!0),a(null),m([]),u(null),f([]),g(new Set),v(null),k(null),He("/api/providers/scan",WI,cd,{method:"POST"},P=>`Scan failed (${String(P.status)})`).then(P=>{if(S.current!==N)return;u(P.scanId),f(P.providers),m(P.warnings??[]);const $=new Set;P.providers.forEach((F,G)=>{F.alreadyExists||$.add(G)}),g($)}).catch(P=>{S.current===N&&a(P instanceof Error?P.message:String(P))}).finally(()=>{S.current===N&&o(!1)})},[]);c.useEffect(()=>{e&&C()},[e,C]),c.useEffect(()=>{e||(S.current+=1,_.current+=1,o(!1),b(!1))},[e]);const M=c.useCallback(N=>{g(P=>{const $=new Set(P);return $.has(N)?$.delete(N):$.add(N),$})},[]),A=c.useCallback(()=>{const N=d.filter(($,F)=>h.has(F));if(N.length===0||l===null)return;const P=_.current+1;_.current=P,b(!0),k(null),v(null),He("/api/providers/import",ZI,cd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:l,selectionIds:N.map($=>$.selectionId)})},$=>`Import failed (${String($.status)})`).then($=>{_.current===P&&(f(F=>F.map((G,X)=>h.has(X)?{...G,alreadyExists:!0}:G)),g(new Set),$.errors!==void 0&&$.errors.length>0&&$.message!==void 0?v($.message):v(`Imported ${$.imported??N.length} provider(s)`),n())}).catch($=>{_.current===P&&k($ instanceof Error?$.message:String($))}).finally(()=>{_.current===P&&b(!1)})},[d,l,h,n]),I=d.some(N=>!N.alreadyExists);return s.jsx(Wt,{open:e,onOpenChange:t,children:s.jsxs(Zt,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[s.jsxs(Yt,{children:[s.jsx(Xt,{children:"Import from External Tools"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[r&&s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[s.jsx(De,{className:"size-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),i!==null&&s.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[s.jsx(Cs,{className:"size-4"}),i]}),!r&&i===null&&d.length===0&&s.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",s.jsx("br",{}),s.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!r&&d.map((N,P)=>s.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${N.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!N.alreadyExists&&s.jsx("input",{type:"checkbox",checked:h.has(P),disabled:y,onChange:()=>M(P),className:"mt-0.5 size-4"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Ci,{client:N.sourceTool,className:"size-7 rounded-[8px]"}),N.alreadyExists&&s.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),s.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[N.models.slice(0,4).join(", "),N.models.length>4?` +${N.models.length-4} more`:""]}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:N.format==="anthropic"?N.anthropicBaseUrl:N.openaiResponsesBaseUrl!==""?N.openaiResponsesBaseUrl:N.openaiBaseUrl}),s.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:N.apiKeyHint})]})]},N.selectionId)),p.length>0&&s.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:p.map((N,P)=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Cs,{className:"size-3"}),N]},P))}),w!==null&&s.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:w}),j!==null&&s.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[s.jsxs(ee,{variant:"outline",size:"sm",onClick:C,disabled:r,children:[s.jsx(De,{className:`size-3 mr-1 ${r?"animate-spin":""}`}),"Rescan"]}),s.jsxs(ee,{size:"sm",onClick:A,disabled:!I||h.size===0||y,children:[s.jsx(yr,{className:"size-3 mr-1"}),y?"Importing...":`Import Selected (${h.size})`]})]})]})})}const Vg=E({id:x().min(1).max(Fa),aliases:K(x().max(Fa)).max(Vn).optional().default([]),contextWindow:R().int().positive().optional(),outputLimit:R().int().positive().optional(),sourceUrl:x().optional()}),GI=E({name:x().min(1).optional(),aliases:K(x()).max(Vn).optional().default([]),baseUrls:K(x()).max(Vn).optional().default([]),models:K(Vg).min(1).max(Vn)});E({version:R().int().positive().optional(),updatedAt:x().optional(),providers:K(GI).max(Vn).optional().default([]),models:K(Vg).max(Vn).optional().default([])});function ud(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function JI(e){const t=e.models.filter(n=>n.trim()!=="");return t.length>0?t:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Ic(e,t){const n=ud(t);return(e.modelMetadata??[]).find(o=>ud(o.model)===n)??null}function YI(e){const t=JI(e);return t.length===0?!1:t.every(n=>{const r=Ic(e,n);return r!==null&&r.contextWindow!==void 0})}function XI(e,t){if(e===null)return null;for(const n of t){const r=Ic(n,e);if(r!==null&&r.contextWindow!==void 0)return{providerName:n.name,model:r.model,tokens:r.contextWindow,sourceUrl:r.sourceUrl}}return null}function gr(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Pi(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function kt(e){return e!==void 0&&e!==""}function it(e){return e!==void 0&&e.trim()!==""}function ks(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Wg(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function Zg(e){switch(e){case"timeout":return"Timeout";case"network_unreachable":return"Offline";case"connection_refused":return"Refused";case"auth_failed":return"Auth";case"rate_limited":return"Rate limit";case"server_error":return"Server";case"invalid_response":return"Invalid";case"unknown":return"Failed"}}function QI(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?ks(e.firstChunkMs):e.latencyMs!==void 0?ks(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?ks(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?Wg(e.tokensPerSecond):null}function eP(e){return Pi(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:gr(e)?e.success?{tone:"success",label:"Pass",metric:QI(e),hasDetails:!0}:{tone:"failure",label:Zg(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function tP(e,t){if(t===void 0)return[];const n=[];return kt(e.anthropicBaseUrl)&&n.push(t.anthropic),kt(e.openaiBaseUrl)&&n.push(t.openaiChat),kt(e.openaiResponsesBaseUrl)&&n.push(t.openaiResponses),n}function nP(e,t){const n={total:0,passed:0,failed:0,testing:0};for(const r of tP(e,t))for(const o of[r.nonStreaming,r.streaming])Pi(o)||(n.total+=1,gr(o)?o.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function dd(e){if(e===void 0)return;const t=Object.entries(e).map(([n,r])=>`${n}: ${r}`);return t.length===0?void 0:t.join(`
124
- `)}function pn({title:e,children:t}){return s.jsxs("section",{className:"space-y-1.5",children:[s.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),t]})}function Ln({value:e}){return s.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted/40 p-3 font-mono text-[11px] leading-relaxed text-foreground/80",children:e})}function $n({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[s.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),s.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:t,children:t})]})}function sP({result:e}){const t=e.inputTokens!==void 0||e.outputTokens!==void 0,n=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return it(e.model)||t||n||e.latencyMs!==void 0||e.firstChunkMs!==void 0&&e.firstChunkMs!==null||e.totalStreamMs!==void 0&&e.totalStreamMs!==null||e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?s.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[it(e.model)&&s.jsx($n,{label:"Model",value:e.model}),e.latencyMs!==void 0&&s.jsx($n,{label:"Latency",value:ks(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&s.jsx($n,{label:"First chunk",value:ks(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&s.jsx($n,{label:"Stream total",value:ks(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&s.jsx($n,{label:"Token rate",value:`${Wg(e.tokensPerSecond)} tok`}),t&&s.jsx($n,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),n&&s.jsx($n,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function rP({result:e}){const t=e.debug,n=t?.requestUrl,r=t?.requestMethod??"POST",o=dd(t?.requestHeaders),i=dd(t?.responseHeaders),a=t?.responseStatus===void 0?void 0:`${String(t.responseStatus)}${it(t.responseStatusText)?` ${t.responseStatusText}`:""}`,l=t?.responseBody??e.rawResponse;return it(e.error?.hint)||it(e.error?.details)||it(n)||o!==void 0||it(t?.requestBody)||it(a)||i!==void 0||it(l)?s.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[it(e.error?.hint)&&s.jsx(pn,{title:"Hint",children:s.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),it(e.error?.details)&&s.jsx(pn,{title:"Error details",children:s.jsx(Ln,{value:e.error.details})}),it(n)&&s.jsx(pn,{title:"Request",children:s.jsx(Ln,{value:`${r} ${n}`})}),o!==void 0&&s.jsx(pn,{title:"Request headers",children:s.jsx(Ln,{value:o})}),it(t?.requestBody)&&s.jsx(pn,{title:"Request body",children:s.jsx(Ln,{value:t.requestBody})}),it(a)&&s.jsx(pn,{title:"Response status",children:s.jsx(Ln,{value:a})}),i!==void 0&&s.jsx(pn,{title:"Response headers",children:s.jsx(Ln,{value:i})}),it(l)&&s.jsx(pn,{title:"Response body",children:s.jsx(Ln,{value:l})})]}):null}function oP({result:e,probeLabel:t,children:n}){const r=e.error?.message??"Connection failed";return s.jsxs(Wt,{children:[s.jsx(Nr,{asChild:!0,children:n}),s.jsxs(Zt,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[s.jsxs(Yt,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[e.success?s.jsx(vr,{className:"size-4 text-status-success"}):s.jsx(Cs,{className:"size-4 text-status-danger"}),s.jsx(Xt,{className:"text-base",children:t})]}),s.jsx(Cr,{children:e.success?"Connection probe passed.":r})]}),s.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&s.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[s.jsx("div",{className:"font-medium",children:Zg(e.error?.type??"unknown")}),s.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:r})]}),s.jsx(sP,{result:e}),s.jsx(rP,{result:e})]})]})]})}function iP(e){const t="size-3 shrink-0";switch(e){case"timeout":return s.jsx(sn,{className:t});case"network_unreachable":return s.jsx(Tk,{className:t});case"connection_refused":return s.jsx(Rk,{className:t});case"auth_failed":return s.jsx(_j,{className:t});case"rate_limited":return s.jsx(Hl,{className:t});case"server_error":return s.jsx(fk,{className:t});case"invalid_response":return s.jsx(Rw,{className:t});case"unknown":return s.jsx(Cs,{className:t})}}const aP={success:"bg-status-success/10 text-status-success hover:bg-status-success/15",failure:"bg-status-danger/10 text-status-danger hover:bg-status-danger/15",pending:"bg-muted/40 text-foreground/80",quiet:"bg-transparent text-muted-foreground/70"};function fd({result:e,probeLabel:t}){const n=eP(e),r=Pi(e)?s.jsx(Cp,{className:"size-3 shrink-0"}):gr(e)?e.success?s.jsx(vr,{className:"size-3 shrink-0"}):iP(e.error?.type??"unknown"):s.jsx(No,{className:"size-3 shrink-0 animate-spin"}),o=s.jsxs(s.Fragment,{children:[r,s.jsx("span",{className:"min-w-0 truncate",children:n.label}),n.metric!==null&&s.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:n.metric})]}),i=L("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",aP[n.tone]);return gr(e)&&n.hasDetails?s.jsx(oP,{result:e,probeLabel:t,children:s.jsx("button",{type:"button",className:i,"aria-label":`Open ${t} result: ${n.label}`,children:o})}):s.jsx("div",{className:i,children:o})}function pd({label:e}){return s.jsxs("div",{className:"inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-xs text-muted-foreground/70",children:[s.jsx(Cp,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate",children:e})]})}function pa({label:e,results:t,configured:n=!0}){return s.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] items-center gap-2 border-t border-border/60 px-2 py-2",children:[s.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),n&&t!==void 0?s.jsx(fd,{result:t.nonStreaming,probeLabel:`${e} non-stream`}):s.jsx(pd,{label:n?"Not tested":"Off"}),n&&t!==void 0?s.jsx(fd,{result:t.streaming,probeLabel:`${e} stream`}):s.jsx(pd,{label:n?"Not tested":"Off"})]})}function Kg({provider:e,results:t}){const n=kt(e.anthropicBaseUrl),r=kt(e.openaiBaseUrl),o=kt(e.openaiResponsesBaseUrl);return!n&&!r&&!o?s.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):s.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:s.jsxs("div",{className:"min-w-[20rem]",children:[s.jsxs("div",{className:"grid grid-cols-[minmax(6.5rem,1fr)_minmax(6rem,0.9fr)_minmax(6rem,0.9fr)] gap-2 bg-muted/25 px-2 py-1.5 text-[10px] text-muted-foreground",children:[s.jsx("span",{children:"Protocol"}),s.jsx("span",{children:"Non-stream"}),s.jsx("span",{children:"Stream"})]}),n&&s.jsx(pa,{label:"Anthropic",results:t?.anthropic}),r&&s.jsx(pa,{label:"OpenAI Chat",results:t?.openaiChat}),o&&s.jsx(pa,{label:"OpenAI Responses",results:t?.openaiResponses})]})})}function lP(e){const t={total:0,passed:0,failed:0,testing:0};for(const n of[e.nonStreaming,e.streaming])Pi(n)||(t.total+=1,gr(n)?n.success?t.passed+=1:t.failed+=1:t.testing+=1);return t}function ma({label:e,results:t}){const n=lP(t),r=n.failed>0?"border-status-danger/30 bg-status-danger/10 text-status-danger":n.testing>0?"border-status-watch/30 bg-status-watch/10 text-status-watch":n.total>0&&n.passed===n.total?"border-status-success/30 bg-status-success/10 text-status-success":"border-border/60 bg-transparent text-muted-foreground",o=n.failed>0?`${n.failed} fail`:n.testing>0?"running":n.total===0?"off":`${n.passed}/${n.total}`;return s.jsxs("span",{className:L("rounded border px-1.5 py-0.5 text-[10px]",r),children:[e," ",o]})}function cP({provider:e,modelName:t,results:n,expanded:r,onToggle:o}){return s.jsxs("div",{className:"min-w-0",children:[s.jsxs("button",{type:"button",onClick:o,className:"flex w-full min-w-0 flex-wrap items-center gap-2 px-2 py-2 text-left transition-colors hover:bg-muted/20","aria-expanded":r,children:[r?s.jsx(et,{className:"size-3.5 shrink-0 text-muted-foreground"}):s.jsx(bt,{className:"size-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:t,children:t}),s.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[kt(e.anthropicBaseUrl)&&s.jsx(ma,{label:"A",results:n.anthropic}),kt(e.openaiBaseUrl)&&s.jsx(ma,{label:"Chat",results:n.openaiChat}),kt(e.openaiResponsesBaseUrl)&&s.jsx(ma,{label:"Resp",results:n.openaiResponses})]})]}),r&&s.jsx("div",{className:"px-2 pb-3",children:s.jsx(Kg,{provider:e,results:n})})]})}function uP({provider:e,testResults:t}){const n=Object.entries(t.models??{}),[r,o]=c.useState(!1),[i,a]=c.useState(null);return n.length===0?null:s.jsxs("section",{className:"space-y-2",children:[s.jsxs("button",{type:"button",onClick:()=>o(l=>!l),className:"flex w-full items-center gap-1.5 text-left text-xs font-medium text-foreground/80 transition-colors hover:text-foreground","aria-expanded":r,children:[r?s.jsx(et,{className:"size-3.5"}):s.jsx(bt,{className:"size-3.5"}),"Model probes",s.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:n.length})]}),r&&s.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:n.map(([l,u])=>s.jsx(cP,{provider:e,modelName:l,results:u,expanded:i===l,onToggle:()=>a(d=>d===l?null:l)},l))})]})}function dP({provider:e,testResults:t,isTesting:n}){const r=kt(e.anthropicBaseUrl)||kt(e.openaiBaseUrl)||kt(e.openaiResponsesBaseUrl),o=nP(e,t);return n?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-cool/30 bg-status-cool/10 px-2 py-1 text-xs text-status-cool",children:[s.jsx(No,{className:"size-3 animate-spin"}),"Testing"]}):r?t===void 0||o.total===0?s.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):o.failed>0?s.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-danger/30 bg-status-danger/10 px-2 py-1 text-xs text-status-danger",children:[s.jsx(Cs,{className:"size-3"}),o.failed," failed"]}):o.testing>0||o.passed<o.total?s.jsxs("span",{className:"rounded border border-status-watch/30 bg-status-watch/10 px-2 py-1 text-xs text-status-watch",children:[o.passed,"/",o.total]}):s.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-status-success/30 bg-status-success/10 px-2 py-1 text-xs text-status-success",children:[s.jsx(vr,{className:"size-3"}),o.passed,"/",o.total]}):s.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const fP={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function ha(e){return e!==void 0&&e!==""}function ga({label:e}){return s.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-border/70 bg-muted/25 px-1.5 py-0.5 text-foreground/80",children:[s.jsx(vr,{className:"size-3"}),e]})}function pP({provider:e}){const t=ha(e.anthropicBaseUrl),n=ha(e.openaiBaseUrl),r=ha(e.openaiResponsesBaseUrl);return!t&&!n&&!r?s.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[t&&s.jsx(ga,{label:"Anthropic"}),n&&s.jsx(ga,{label:"OpenAI Chat"}),r&&s.jsx(ga,{label:"OpenAI Responses"})]})}function mP(e){const t=e.models??[];if(t.length===0)return"No models configured";const n=t.slice(0,2).join(", "),r=t.length-2;return r>0?`${n} +${r} more`:n}function hP({provider:e,model:t}){const n=Ic(e,t),r=xP(n?.sourceUrl);return s.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[s.jsx("span",{children:t}),n!==null&&n.contextWindow!==void 0&&s.jsx("span",{className:"font-mono text-foreground/80",children:ff(n.contextWindow)}),r!==null&&s.jsx(Ds,{children:s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsx("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-0.5 rounded border border-border/70 bg-background/70 px-1 font-mono text-[10px] leading-4 text-muted-foreground transition-colors hover:text-foreground","aria-label":r.title,children:r.label})}),s.jsx(pt,{children:r.title})]})})]})}function gP(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n,o=Math.floor(r/1e3);if(o<60)return"just now";const i=Math.floor(o/60);if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function xP(e){if(e===void 0||e.trim()==="")return null;try{const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")return null;const n=t.hostname.toLowerCase(),r=n==="huggingface.co"||n.endsWith(".huggingface.co");return{label:r?"HF":"Source",title:r?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function bP({provider:e,testResults:t,isTesting:n,testingTimeLeft:r,isHighlighted:o,onEdit:i,onDelete:a,onTest:l,onRefreshMetadata:u,isRefreshingMetadata:d=!1}){const[f,p]=c.useState(!1),m=e.apiDocsUrl??Object.entries(fP).find(([v])=>e.name.toLowerCase().includes(v))?.[1],h=YI(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",y=g?"Refresh":"Import defaults",b=n??!1,w=e.source==="company"?s.jsx("span",{className:"shrink-0 rounded border border-status-cool/30 bg-status-cool/10 px-1.5 py-0.5 text-xs text-status-cool",children:"Company"}):e.source==="personal"?s.jsx("span",{className:"shrink-0 rounded border border-status-accent/30 bg-status-accent/10 px-1.5 py-0.5 text-xs text-status-accent",children:"Personal"}):null;return s.jsxs("div",{"data-provider-id":e.id,className:`flex flex-col gap-3 rounded-[8px] border border-border bg-card p-4 shadow-sm transition-all duration-500 ${o===!0?"ring-2 ring-primary shadow-md":""}`,children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),s.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:mP(e)})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(dP,{provider:e,testResults:t,isTesting:b}),m!==void 0&&s.jsxs("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",title:"View API documentation",children:[s.jsx(ql,{className:"size-3"}),s.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[s.jsx(pP,{provider:e}),t?.testedAt!==void 0&&s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(sn,{className:"size-3"}),gP(t.testedAt)]})]}),!h&&s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-status-watch/30 bg-status-watch/10 px-2 py-1.5 text-xs text-status-watch",children:[s.jsx("span",{children:"Context window metadata missing"}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>u?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:d,children:[s.jsx(No,{className:`size-3 ${d?"animate-spin":""}`}),y]}),!g&&s.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),f&&s.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(vr,{className:"size-3.5 text-status-success"}),s.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(v=>s.jsx(hP,{provider:e,model:v},v))}),s.jsxs("section",{className:"space-y-2",children:[s.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),s.jsx(Kg,{provider:e,results:t})]}),t!==void 0&&s.jsx(uP,{provider:e,testResults:t})]}),s.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[s.jsxs("button",{type:"button",onClick:()=>p(v=>!v),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":f,children:[f?s.jsx(et,{className:"size-3"}):s.jsx(bt,{className:"size-3"}),"Details"]}),s.jsxs("div",{className:"flex gap-2",children:[l!==void 0&&s.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>l(e.id),className:"text-xs h-7 gap-1",disabled:b,children:[s.jsx(No,{className:`size-3 ${b?"animate-spin":""}`}),b?r!==void 0?`Testing (${r}s)`:"Testing...":"Test"]}),s.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>i(e),className:"text-xs h-7 gap-1",disabled:b,children:[s.jsx(Tp,{className:"size-3"}),"Edit"]}),s.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>a(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:b,children:[s.jsx(wn,{className:"size-3"}),"Delete"]})]})]})]})}const Ss="/v1/chat/completions",pl="/v1/responses",vP="/v1/messages";function yP(e,t){const n=e.endsWith("/")?e.slice(0,-1):e,r=Gg(t),o=t.indexOf("?"),i=o>=0?t.slice(o):"";return r!==""&&n.endsWith(r)?n+i:Yg(n)&&Jg(t)||n.endsWith("/v1")&&t.startsWith("/v1/")?n+t.slice(3):n+t}function wP(e,t,n={}){const r=e.trim().replace(/\/+$/,""),o=Gg(t),i=yP(r,t),a=[];return o!==""&&r.endsWith(o)?a.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):Yg(r)&&Jg(t)?a.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):r.endsWith("/v1")&&t.startsWith("/v1/")&&a.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),md(o)&&kP(r)&&a.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),jP(o)&&SP(r)&&a.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),md(o)&&_P(r,n.providerName)&&a.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:i,diagnostics:a}}function Gg(e){return e.split("?")[0]??e}function Jg(e){return e===Ss||e.startsWith(`${Ss}?`)||e.startsWith(`${Ss}/`)}function jP(e){return e===Ss||e.startsWith(`${Ss}/`)}function md(e){return e===pl||e.startsWith(`${pl}/`)}function kP(e){return e.toLowerCase().endsWith("/chat/completions")}function SP(e){return e.toLowerCase().endsWith("/responses")}function _P(e,t){const n=t?.toLowerCase();if(n!==void 0&&n.includes("deepseek"))return!0;try{return new URL(e).hostname.toLowerCase().includes("deepseek")}catch{return e.toLowerCase().includes("deepseek")}}function Yg(e){try{const t=new URL(e),n=t.pathname.replace(/\/+$/,"");return t.hostname==="open.bigmodel.cn"&&(n==="/api/paas/v4"||n==="/api/coding/paas/v4")}catch{return!1}}function xa(e){return e!==void 0&&e.trim()!==""}function hd(e){const t=xa(e?.anthropicBaseUrl),n=xa(e?.openaiBaseUrl),r=xa(e?.openaiResponsesBaseUrl);return{anthropic:t,openai:n||r,openaiChat:n,openaiResponses:r}}function ba(e,t,n){if(!e)return n?"":void 0;const r=t.trim();return r===""?void 0:r}const gd=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],xd=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],Yr=vP,Xr=Ss,Qr=pl,NP={deepseek:{openaiBaseUrl:"https://api.deepseek.com"},minimax:{anthropicBaseUrl:"https://api.minimaxi.com/anthropic",openaiBaseUrl:"https://api.minimaxi.com",openaiResponsesBaseUrl:"https://api.minimaxi.com",apiDocsUrl:"https://platform.minimaxi.com/docs/api-reference/api-overview"},"zhipu coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"glm coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"bigmodel coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"z.ai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},"zai coding":{anthropicBaseUrl:"https://open.bigmodel.cn/api/anthropic",openaiBaseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/coding-plan/quick-start"},zhipu:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zhipuai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},bigmodel:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},"z.ai":{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},zai:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},glm:{openaiBaseUrl:"https://open.bigmodel.cn/api/paas/v4",apiDocsUrl:"https://docs.bigmodel.cn/cn/guide/develop/openai/introduction"},alibaba:{openaiBaseUrl:"https://dashscope.aliyuncs.com/compatible-mode"}},bd=["MiniMax M3","MiniMax M2.7","MiniMax M2.7-highspeed","MiniMax M2.5","MiniMax M2.5-highspeed","MiniMax M2.1","MiniMax M2.1-highspeed","MiniMax M2"],vd=["qwen3.6-plus","qwen3.7-max"],yd=["glm-5.2","glm-5.1","glm-5","glm-5-turbo","glm-4.7","glm-4.7-flashx","glm-4.6","glm-4.5","glm-4.5-air","glm-4.5-x","glm-4.5-airx","glm-4.5-flash"],ml="__unset__",Bo="__custom__",Xg=[{value:"32K",label:"Small"},{value:"64K",label:"Standard"},{value:"128K",label:"Medium"},{value:"200K",label:"Long"},{value:"256K",label:"Extended"},{value:"512K",label:"Large"},{value:"1M",label:"Max"}];function Dn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function wd(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Qg(e,t){const n=wd(t);return e?.modelMetadata?.find(r=>wd(r.model)===n)??null}function ex(e){const t=xo(e);if(t===null)return null;for(const n of Xg)if(xo(n.value)===t)return n.value;return null}function CP(e){return e.trim()===""?"unset":ex(e)!==null?"preset":"custom"}function TP(e){switch(e.contextWindowMode){case"unset":return ml;case"custom":return Bo;case"preset":return ex(e.contextWindow)??Bo}}function va(e){const t=e.trim().replaceAll(",","");if(t==="")return{amount:"",unit:"K"};const n=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(t);if(n===null)return{amount:t,unit:"K"};const r=n[1];if(r===void 0)return{amount:t,unit:"K"};const o=n[2];if(o===void 0||o==="")return{amount:r,unit:"tokens"};switch(o.toLowerCase()){case"k":return{amount:r,unit:"K"};case"m":return{amount:r,unit:"M"};default:return{amount:t,unit:"K"}}}function jd(e,t){const n=e.trim();if(n==="")return"";switch(t){case"K":return`${n}K`;case"M":return`${n}M`;case"tokens":return n}}function kd(e,t){return t.map(n=>{const r=Qg(e,n),o=r?.contextWindow!==void 0?Yx(r.contextWindow):"";return{contextWindow:o,contextWindowMode:CP(o),outputLimit:r?.outputLimit?.toString()??""}})}function Sd(e){const t=e.trim();if(t==="")return null;const n=Number(t);return!Number.isInteger(n)||n<=0?null:n}function us(e,t){if(e===void 0)return"";const n=e.trim(),r=n.replace(/\/+$/,"");return r.endsWith(t)?r.slice(0,-t.length).replace(/\/+$/,""):n}function EP(e,t,n){const r=e.trim();return r===""?null:wP(r,t,{providerName:n})}function ya({baseUrl:e,endpoint:t,providerName:n}){const r=EP(e,t,n);return r===null?null:s.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[s.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),s.jsx("div",{className:"break-all font-mono text-foreground",children:r.finalUrl}),r.diagnostics.length>0&&s.jsx("div",{className:"mt-2 space-y-1",children:r.diagnostics.map(o=>s.jsx("div",{className:o.severity==="warning"?"text-status-watch":"text-muted-foreground",children:o.message},`${o.severity}:${o.message}`))})]})}function RP({provider:e,onSubmit:t,onCancel:n}){const r=hd(e),[o,i]=c.useState(e?.name??""),[a,l]=c.useState(""),[u,d]=c.useState(!1),[f,p]=c.useState(!1),m=e?.models,[h,g]=c.useState(m!==void 0&&m.length>0?m:[""]),[y,b]=c.useState(()=>kd(e,m!==void 0&&m.length>0?m:[""])),[w,v]=c.useState(r.anthropic),[j,k]=c.useState(r.openai),[S,_]=c.useState(r.openaiChat),[C,M]=c.useState(r.openaiResponses),[A,I]=c.useState(us(e?.anthropicBaseUrl,Yr)),[N,P]=c.useState(us(e?.openaiBaseUrl,Xr)),[$,F]=c.useState(us(e?.openaiResponsesBaseUrl,Qr)),[G,X]=c.useState(e?.apiDocsUrl??""),[U,V]=c.useState(e?.modelMetadataUrl??""),[Y,B]=c.useState(e?.source),[W,me]=c.useState({}),[ve,we]=c.useState(!1),[D,ie]=c.useState(null),te=c.useRef([]);c.useEffect(()=>{if(D===null)return;const T=D;function z(Z){if(!(Z.target instanceof Node))return;const re=te.current[T];re!=null&&!re.contains(Z.target)&&ie(null)}return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[D]);const[_e,Ne]=c.useState(!1),[ce,de]=c.useState(!1),[he,je]=c.useState(!1),Ce=o.toLowerCase().includes("minimax"),Fe=o.toLowerCase().includes("alibaba"),Ze=[...gd,...xd].some(T=>o.toLowerCase().includes(T)),Ue=Ce?bd:Ze?yd:Fe?vd:[],ut=e?.modelMetadata?.some(T=>T.contextWindow!==void 0)??!1;function Qt(){It(a).then(T=>{T&&(p(!0),setTimeout(()=>p(!1),2e3))})}c.useEffect(()=>{if(e){i(e.name),l(""),d(!1);const T=(e.models?.length??0)>0?e.models:[""];g(T),b(kd(e,T));const z=hd(e);v(z.anthropic),k(z.openai),_(z.openaiChat),M(z.openaiResponses),I(us(e.anthropicBaseUrl,Yr)),P(us(e.openaiBaseUrl,Xr)),F(us(e.openaiResponsesBaseUrl,Qr)),X(e.apiDocsUrl??""),V(e.modelMetadataUrl??""),B(e.source),Ne(!1),de(!1),je(!1)}},[e]),c.useEffect(()=>{const T=o.toLowerCase();for(const[z,Z]of Object.entries(NP))if(T.includes(z)){Z.anthropicBaseUrl!==void 0&&!_e&&I(Z.anthropicBaseUrl),Z.openaiBaseUrl!==void 0&&!ce&&P(Z.openaiBaseUrl),Z.openaiResponsesBaseUrl!==void 0&&!he&&F(Z.openaiResponsesBaseUrl),Z.apiDocsUrl!==void 0&&!G&&X(Z.apiDocsUrl),z==="minimax"&&h.length===1&&h[0]===""&&g([bd[0]??""]),z==="alibaba"&&h.length===1&&h[0]===""&&g([vd[0]??""]),(gd.includes(z)||xd.includes(z))&&h.length===1&&h[0]===""&&g([yd[0]??""]);break}},[o]);function yt(){const T={};return o.trim()||(T.name="Name is required"),e===void 0&&!a.trim()&&(T.apiKey="API key is required"),(h.length===0||h.every(z=>!z.trim()))&&(T.models="At least one model is required"),!w&&!j&&(T.capabilities="Select at least one API capability"),j&&!S&&!C&&(T.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(A.trim()===""?T.anthropicBaseUrl="Anthropic base URL is required":Ke(A.trim())||(T.anthropicBaseUrl="Invalid URL format")),j&&S&&(N.trim()===""?T.openaiBaseUrl="OpenAI Chat base URL is required":Ke(N.trim())||(T.openaiBaseUrl="Invalid URL format")),j&&C&&($.trim()===""?T.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Ke($.trim())||(T.openaiResponsesBaseUrl="Invalid URL format")),U.trim()&&!Ke(U.trim())&&(T.modelMetadataUrl="Invalid URL format"),y.forEach((z,Z)=>{const re=xo(z.contextWindow),ae=Sd(z.outputLimit);z.contextWindow.trim()!==""&&re===null&&(T[`modelMetadata.${Z}.contextWindow`]="Context window must be a positive number, optionally using K or M"),z.outputLimit.trim()!==""&&ae===null&&(T[`modelMetadata.${Z}.outputLimit`]="Output limit must be a positive integer"),re!==null&&ae!==null&&ae>re&&(T[`modelMetadata.${Z}.outputLimit`]="Output limit should not exceed context window")}),me(T),Object.keys(T).length===0}function Ke(T){try{return new URL(T),!0}catch{return!1}}function Ae(T,z){g(Z=>{const re=[...Z];return re[T]=z,re})}function Be(T,z){b(Z=>{const re=[...Z];return re[T]={...re[T]??Dn(),...z},re})}function q(T,z){switch(z){case ml:Be(T,{contextWindow:"",contextWindowMode:"unset"});return;case Bo:{const Z=y[T]??Dn();Be(T,{contextWindow:Z.contextWindow,contextWindowMode:"custom"});return}default:Be(T,{contextWindow:z,contextWindowMode:"preset"});return}}function ne(T,z){const Z=y[T]??Dn(),re=va(Z.contextWindow);Be(T,{contextWindow:jd(z,re.unit),contextWindowMode:"custom"})}function ke(T,z){const Z=y[T]??Dn(),re=va(Z.contextWindow);switch(z){case"K":case"M":case"tokens":Be(T,{contextWindow:jd(re.amount,z),contextWindowMode:"custom"});return;default:return}}function ge(T){g(z=>z.filter((Z,re)=>re!==T)),b(z=>z.filter((Z,re)=>re!==T))}function Se(){g(T=>[...T,""]),b(T=>[...T,Dn()])}function Je(){const T=new Date().toISOString(),z=[];return h.forEach((Z,re)=>{const ae=Z.trim();if(ae==="")return;const se=y[re]??Dn(),be=xo(se.contextWindow),ue=Sd(se.outputLimit);if(be===null&&ue===null)return;const Ct=Qg(e,ae);if(Ct!==null&&Ct.contextWindow===(be??void 0)&&Ct.outputLimit===(ue??void 0)){z.push({...Ct,model:ae});return}const Pn={model:ae,source:"manual",updatedAt:T};be!==null&&(Pn.contextWindow=be),ue!==null&&(Pn.outputLimit=ue),z.push(Pn)}),z.length>0?z:e?.modelMetadata!==void 0?[]:void 0}function J(T){if(T.preventDefault(),!yt())return;we(!0);const z=e!==void 0;try{t({name:o.trim(),apiKey:a.trim(),models:h.map(Z=>Z.trim()).filter(Z=>Z!==""),anthropicBaseUrl:ba(w,A,z),openaiBaseUrl:ba(j&&S,N,z),openaiResponsesBaseUrl:ba(j&&C,$,z),apiDocsUrl:G.trim()||void 0,modelMetadataUrl:U.trim()||void 0,modelMetadata:Je(),source:Y})}finally{we(!1)}}return s.jsxs("form",{onSubmit:J,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsx("input",{id:"provider-name",type:"text",value:o,onChange:T=>i(T.target.value),placeholder:"Provider Name",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),W.name!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.name})]}),s.jsxs("fieldset",{className:"space-y-3",children:[s.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[s.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[s.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[s.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:T=>k(T.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),s.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&s.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[s.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[s.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:S,onChange:T=>_(T.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),s.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[s.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:C,onChange:T=>M(T.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),W.openaiCapabilities!==void 0&&j&&s.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:W.openaiCapabilities})]}),s.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[s.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:T=>v(T.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),s.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),W.capabilities!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.capabilities})]}),(w||j&&(S||C))&&s.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[s.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[s.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:A,onChange:T=>{Ne(!0),I(T.target.value)},placeholder:"https://api.anthropic.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:Yr})]}),W.anthropicBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.anthropicBaseUrl}),s.jsx(ya,{baseUrl:A,endpoint:Yr,providerName:o})]}),j&&S&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[s.jsx("input",{id:"provider-openai-base-url",type:"text",value:N,onChange:T=>{de(!0),P(T.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:Xr})]}),W.openaiBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.openaiBaseUrl}),s.jsx(ya,{baseUrl:N,endpoint:Xr,providerName:o})]}),j&&C&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground flex min-w-0 overflow-hidden rounded-md focus-within:border-ring focus-within:outline-ring focus-within:ring-[3px]",children:[s.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:$,onChange:T=>{je(!0),F(T.target.value)},placeholder:"https://api.openai.com",className:"min-w-0 flex-1 bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"shrink-0 select-none border-l border-border bg-muted/35 px-3 py-2 font-mono text-xs text-muted-foreground",children:Qr})]}),W.openaiResponsesBaseUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.openaiResponsesBaseUrl}),s.jsx(ya,{baseUrl:$,endpoint:Qr,providerName:o})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),s.jsxs("select",{id:"provider-source",value:Y??"",onChange:T=>B(T.target.value==="company"||T.target.value==="personal"?T.target.value:void 0),className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx("option",{value:"",children:"Unspecified"}),s.jsx("option",{value:"personal",children:"个人 (Personal)"}),s.jsx("option",{value:"company",children:"公司 (Company)"})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),s.jsx("input",{id:"provider-model-metadata-url",type:"text",value:U,onChange:T=>V(T.target.value),placeholder:"https://example.com/agent-inspector-models.json",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),W.modelMetadataUrl!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.modelMetadataUrl}),U.trim()===""&&s.jsx("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs text-muted-foreground",children:"Built-in limits cover DeepSeek v4 pro/flash, MiniMax M3/M2.7/M2.5/M2.1, and GLM coding models. Use a registry URL for private or custom model limits."}),e!==void 0&&!ut&&U.trim()===""&&s.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),U.trim()!==""&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&s.jsx("span",{className:"text-destructive",children:"*"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-apikey",type:u?"text":"password",value:a,onChange:T=>l(T.target.value),placeholder:e===void 0?"sk-ant-...":"Leave blank to keep current key",className:"flex-1 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("button",{type:"button",onClick:()=>d(T=>!T),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":u?"Hide API key":"Show API key",children:u?s.jsx(Xw,{className:"size-4"}):s.jsx(kp,{className:"size-4"})}),s.jsx("button",{type:"button",onClick:Qt,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:f?s.jsx(qe,{className:"size-4 text-status-success"}):s.jsx(zt,{className:"size-4"})})]}),e!==void 0&&a.trim()===""&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"A key is configured. Enter a new value only to rotate it."}),W.apiKey!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.apiKey})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"text-sm font-medium",children:["Models ",s.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((T,z)=>{const Z=y[z]??Dn(),re=W[`modelMetadata.${z}.contextWindow`],ae=W[`modelMetadata.${z}.outputLimit`],se=TP(Z),be=va(Z.contextWindow);return s.jsxs("div",{ref:ue=>{te.current[z]=ue},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:"text",value:T,onChange:ue=>Ae(z,ue.target.value),placeholder:Ue.length>0?"Type or select a model...":"Model name",className:"w-full rounded-md border border-input bg-background px-4 py-3 pr-8 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),Ue.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:()=>ie(D===z?null:z),className:"absolute right-1 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 z-10","aria-label":"Show model suggestions",children:s.jsx(et,{className:"size-4"})}),D===z&&s.jsx("div",{className:"bg-popover text-popover-foreground absolute left-0 right-0 top-full z-50 mt-1 max-h-48 overflow-y-auto rounded-md border shadow-md",children:Ue.map(ue=>s.jsx("button",{type:"button",onClick:()=>{Ae(z,ue),ie(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:ue},ue))})]})]}),h.length>1&&s.jsx("button",{type:"button",onClick:()=>ge(z),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:s.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),s.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),s.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Context Window"}),s.jsxs(pr,{value:se,onValueChange:ue=>q(z,ue),children:[s.jsx(mr,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(Uo,{})}),s.jsxs(hr,{className:"max-h-64",children:[s.jsx(lt,{value:ml,children:"Not set"}),Xg.map(ue=>s.jsxs(lt,{value:ue.value,children:[ue.label," · ",ue.value]},ue.value)),s.jsx(lt,{value:Bo,children:"Custom"})]})]}),Z.contextWindowMode==="custom"&&s.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[s.jsx("input",{type:"text",inputMode:"decimal",value:be.amount,onChange:ue=>ne(z,ue.target.value),placeholder:"128",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),s.jsxs(pr,{value:be.unit,onValueChange:ue=>ke(z,ue),children:[s.jsx(mr,{size:"sm",className:"w-full bg-background font-mono text-xs",children:s.jsx(Uo,{})}),s.jsxs(hr,{children:[s.jsx(lt,{value:"K",children:"K"}),s.jsx(lt,{value:"M",children:"M"}),s.jsx(lt,{value:"tokens",children:"tokens"})]})]})]}),re!==void 0&&s.jsx("span",{className:"block text-destructive",children:re})]}),s.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[s.jsx("span",{children:"Output Limit"}),s.jsx("input",{type:"number",min:1,step:1e3,value:Z.outputLimit,onChange:ue=>Be(z,{outputLimit:ue.target.value}),placeholder:"e.g. 8192",className:"w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-xs text-foreground ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px]"}),ae!==void 0&&s.jsx("span",{className:"block text-destructive",children:ae})]})]})]},z)}),s.jsx("button",{type:"button",onClick:Se,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),W.models!==void 0&&s.jsx("p",{className:"text-xs text-destructive",children:W.models})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),s.jsx("input",{id:"provider-api-docs-url",type:"text",value:G,onChange:T=>X(T.target.value),placeholder:"https://api.example.com/docs",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:outline-ring focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),s.jsxs("div",{className:"border border-border bg-background/95 shadow-sm sticky bottom-0 flex justify-end gap-2 rounded-[8px] px-3 py-2",children:[s.jsx(ee,{type:"button",variant:"outline",onClick:n,disabled:ve,children:"Cancel"}),s.jsx(ee,{type:"submit",disabled:ve,children:ve?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const IP=pe(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),PP=E({message:x(),type:IP,details:x().optional(),hint:x().optional()}),MP=E({type:pe(["text","thinking"]),text:x().optional(),thinking:x().optional()}),AP=E({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:We(x(),x()).optional(),requestBody:x().optional(),responseStatus:R().optional(),responseStatusText:x().optional(),responseHeaders:We(x(),x()).optional(),responseBody:x().optional()}),OP=E({success:Re(),error:PP.optional(),model:x().optional(),inputTokens:R().optional(),outputTokens:R().optional(),cacheCreationInputTokens:R().optional(),cacheReadInputTokens:R().optional(),latencyMs:R().optional(),firstChunkMs:R().nullable().optional(),totalStreamMs:R().nullable().optional(),tokensPerSecond:R().nullable().optional(),content:K(MP).optional(),rawResponse:x().optional(),streaming:Re().optional(),streamingChunks:E({chunks:K(Zf),truncated:Re().default(!1)}).optional(),requestHeaders:We(x(),x()).optional(),debug:AP.optional()}),_d=Ot([OP,E({notConfigured:le(!0)}),E({testing:le(!0)})]),vn=E({nonStreaming:_d,streaming:_d});function qo(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const zP=E({anthropic:vn,openai:vn.optional(),openaiChat:vn.optional(),openaiResponses:vn.optional()}).transform(e=>{const t=e.openaiChat??e.openai??qo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??qo()}}),LP=E({anthropic:vn,openai:vn.optional(),openaiChat:vn.optional(),openaiResponses:vn.optional(),models:We(x(),zP).optional(),testedAt:x().optional()}).transform(e=>{const t=e.openaiChat??e.openai??qo();return{...e,openai:e.openai??t,openaiChat:t,openaiResponses:e.openaiResponses??qo()}});function $P(){return{anthropic:{nonStreaming:{testing:!0},streaming:{testing:!0}},openai:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiChat:{nonStreaming:{testing:!0},streaming:{testing:!0}},openaiResponses:{nonStreaming:{testing:!0},streaming:{testing:!0}}}}function Nd(e,t){const n=()=>({nonStreaming:{success:!1,error:{message:e,type:t}},streaming:{notConfigured:!0}});return{anthropic:n(),openai:n(),openaiChat:n(),openaiResponses:n()}}const DP=E({providerConfig:x()}),FP=E({success:Re().optional(),imported:R().optional(),message:x().optional(),errors:K(x()).optional()}),UP=E({provider:To,imported:R(),matchedModels:K(x()),missingModels:K(x()),sourceUrl:x()}),eo="Network error: could not reach the server. Is the proxy running?",BP=5e3,qP=5e3,Cd=15e3,HP=1e4,VP=2e4,WP=2e4,ZP=3e4;function wa(e,t){return(e?.length??0)>0?e:t&&e!==void 0?"":void 0}function Td(e,t=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:wa(e.anthropicBaseUrl,t),openaiBaseUrl:wa(e.openaiBaseUrl,t),openaiResponsesBaseUrl:wa(e.openaiResponsesBaseUrl,t),apiDocsUrl:(e.apiDocsUrl?.length??0)>0?e.apiDocsUrl:void 0,modelMetadataUrl:(e.modelMetadataUrl?.length??0)>0?e.modelMetadataUrl:void 0,modelMetadata:e.modelMetadata,source:e.source}}function KP(e,t){const n=e?.models?.map(r=>r.trim()).filter(r=>r!=="").length??0;return Math.max(1,n)*t}async function GP(e,t){if(t.models!==void 0)try{await Hn(`/api/providers/${e}/test/log`,qP,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch{}}function JP({externalProviders:e,isLoading:t=!1,externalTestResults:n,externalTestingProviders:r,externalTestingTimeLeft:o,onProvidersMutate:i,onTestResultsChange:a,onTestingProvidersChange:l,onTestingTimeLeftChange:u}){const[d,f]=c.useState(!1),[p,m]=c.useState(),[h,g]=c.useState(null),[y,b]=c.useState({}),[w,v]=c.useState(new Set),[j,k]=c.useState({}),[S,_]=c.useState(null),[C,M]=c.useState(!1),[A,I]=c.useState(null),[N,P]=c.useState(!1),[$,F]=c.useState(!1),[G,X]=c.useState(null),[U,V]=c.useState("all"),[Y,B]=c.useState(new Set),{providerTestTimeoutSeconds:W}=Fl(),me=c.useRef(null),ve=c.useRef(null),we=e??[],D=c.useMemo(()=>{const q=U==="all"?we:we.filter(ne=>ne.source===U);return U==="all"?[...q].sort((ne,ke)=>{const ge={personal:0,company:1};return(ge[ne.source??""]??2)-(ge[ke.source??""]??2)}):q},[we,U]),ie=n??y,te=r??w,_e=o??j,Ne=u?(q,ne)=>u(q,ne):(q,ne)=>{k(ne===void 0?ke=>{const ge={...ke};return delete ge[q],ge}:ke=>({...ke,[q]:ne}))};c.useEffect(()=>{(async()=>{try{const q=await He("/api/config/paths",DP,BP);_(q.providerConfig)}catch{}})()},[]);const ce=c.useCallback(q=>{ve.current!==null&&clearTimeout(ve.current),I(q),me.current?.scrollTo({top:me.current.scrollHeight,behavior:"smooth"}),ve.current=setTimeout(()=>{I(null),ve.current=null},2e3)},[]);c.useEffect(()=>()=>{ve.current!==null&&clearTimeout(ve.current)},[]);const de=c.useCallback(()=>{i?.().catch(()=>{})},[i]),he=c.useCallback((q,ne)=>{a?a(q,ne):b(ke=>({...ke,[q]:ne}))},[a]),je=c.useCallback((q,ne)=>{if(l){l(q,ne);return}v(ke=>{const ge=new Set(ke);return ne?ge.add(q):ge.delete(q),ge})},[l]),Ce=c.useCallback(async q=>{he(q,$P()),je(q,!0);const ne=new AbortController,ke=we.find(J=>J.id===q),ge=KP(ke,W);let Se=ge;Ne(q,Se);const Je=setInterval(()=>{Se--,Ne(q,Se),Se<=0&&(clearInterval(Je),ne.abort())},1e3);try{const J=await He(`/api/providers/${q}/test`,LP,ge*1e3+1e3,{method:"POST",signal:ne.signal},T=>`HTTP ${T.status}: ${T.statusText}`);he(q,J),await GP(q,J)}catch(J){const T=J instanceof Error&&J.name==="AbortError",z=J instanceof ni;T||z?he(q,Nd("Request timed out","timeout")):J instanceof Error&&he(q,Nd(J.message,"server_error"))}finally{clearInterval(Je),Ne(q,void 0),je(q,!1)}},[W,we,Ne,he,je]),Fe=c.useCallback(async(q,ne,ke=!0)=>{B(ge=>{const Se=new Set(ge);return Se.add(q),Se});try{const ge=ne!==void 0&&ne.trim()!==""?{url:ne}:{},Se=await He(`/api/providers/${q}/model-metadata`,UP,ZP,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ge)},()=>"Failed to refresh model metadata");return Se.imported===0&&ke?g("No matching model metadata found for this provider."):g(null),ce(Se.provider.id),de(),Se.imported>0}catch(ge){return ke&&g(ge instanceof Error?ge.message:eo),!1}finally{B(ge=>{const Se=new Set(ge);return Se.delete(q),Se})}},[de,ce]);function Ze(q){(async()=>{try{const ne=await He("/api/providers",To,Cd,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Td(q))},()=>"Failed to add provider");f(!1),ce(ne.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Fe(ne.id,q.modelMetadataUrl,!1),de(),await Ce(ne.id)}catch(ne){g(ne instanceof Error?ne.message:eo)}})()}function Ue(q){p&&(async()=>{try{const ne=await He(`/api/providers/${p.id}`,To,Cd,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Td(q,!0))},()=>"Failed to update provider");m(void 0),ce(ne.id),q.modelMetadataUrl!==void 0&&q.modelMetadataUrl.trim()!==""&&await Fe(ne.id,q.modelMetadataUrl,!1),de(),(q.apiKey.trim()!==""||JSON.stringify(q.models)!==JSON.stringify(p.models)||(q.anthropicBaseUrl??"")!==(p.anthropicBaseUrl??"")||(q.openaiBaseUrl??"")!==(p.openaiBaseUrl??"")||(q.openaiResponsesBaseUrl??"")!==(p.openaiResponsesBaseUrl??""))&&await Ce(ne.id)}catch(ne){g(ne instanceof Error?ne.message:eo)}})()}function ut(q){X(q),F(!0)}function Qt(){const q=G;q!==null&&(async()=>{let ne;try{ne=await Hn(`/api/providers/${q}`,HP,{method:"DELETE"})}catch{g(eo);return}if(!ne.ok){g(await Il(ne,"Failed to delete provider"));return}de()})()}const yt=c.useRef(null);function Ke(q){const ne="/api/providers/export";(async()=>{try{const ke=await Hn(ne,VP);if(!ke.ok){g("Failed to export providers");return}const ge=await ke.blob(),Se=URL.createObjectURL(ge),Je=document.createElement("a");Je.href=Se,Je.download=ke.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Je),Je.click(),document.body.removeChild(Je),URL.revokeObjectURL(Se)}catch{g("Failed to export providers")}})()}function Ae(){yt.current?.click()}function Be(q){const ne=q.target.files?.[0];ne&&(async()=>{try{const ke=await ne.text(),ge=await Hn("/api/providers/import",WP,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ke)}),Se=await Rl(ge,FP);ge.ok&&Se.imported!==void 0&&Se.imported>0?(de(),g(null)):Se.errors&&Se.errors.length>0?g(Se.errors.join("; ")):g(Se.message??"Import failed")}catch{g("Failed to import providers")}q.target.value=""})()}return t?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):d||p?s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur",children:s.jsx("h3",{className:"text-lg font-medium",children:p?"Edit Provider":"Add New Provider"})}),s.jsx(RP,{provider:p,onSubmit:p?Ue:Ze,onCancel:()=>{f(!1),m(void 0)}})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{"data-provider-toolbar":"true",className:"sticky top-0 z-10 flex min-w-0 flex-wrap items-center justify-start gap-2 rounded-[8px] bg-background/95 px-1 py-1 backdrop-blur sm:justify-end",children:[s.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>Ke(),className:"gap-1 hover:bg-muted",children:[s.jsx(yr,{className:"size-3"}),"Export"]}),s.jsxs(ee,{variant:"outline",size:"sm",onClick:Ae,className:"gap-1 hover:bg-muted",children:[s.jsx(Pp,{className:"size-3"}),"Import"]}),s.jsx("input",{type:"file",ref:yt,accept:".json",onChange:Be,style:{display:"none"}}),s.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>P(!0),className:"gap-1",children:[s.jsx(ik,{className:"size-3"}),"Scan"]}),s.jsxs(ee,{onClick:()=>f(!0),size:"sm",className:"gap-1",children:[s.jsx(mu,{className:"size-4"}),"Add Provider"]})]}),S!==null&&s.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[s.jsx("span",{className:"font-mono truncate",title:S,children:S}),s.jsx("button",{type:"button",onClick:()=>{It(S).then(q=>{q&&(M(!0),setTimeout(()=>M(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":C?"Copied config file path":"Copy config file path",children:C?s.jsx(qe,{className:"size-3 text-status-success"}):s.jsx(zt,{className:"size-3"})})]}),h!==null&&s.jsxs("div",{className:"border border-border bg-card shadow-sm flex items-center gap-2 rounded-[8px] px-3 py-2 text-sm text-destructive",children:[s.jsx(Cs,{className:"size-4 shrink-0"}),h]}),we.length===0?s.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),s.jsxs(ee,{onClick:()=>f(!0),variant:"outline",size:"sm",children:[s.jsx(mu,{className:"size-4"}),"Add Your First Provider"]})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(q=>s.jsx("button",{type:"button",onClick:()=>V(q),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${U===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:q==="all"?"All":q==="personal"?"Personal":"Company"},q))}),s.jsx("div",{ref:me,className:"space-y-3",children:D.map(q=>s.jsx(bP,{provider:q,testResults:ie[q.id],isTesting:te.has(q.id),testingTimeLeft:_e[q.id],isHighlighted:q.id===A,onEdit:ne=>m(ne),onDelete:ut,onRefreshMetadata:ne=>{Fe(ne)},isRefreshingMetadata:Y.has(q.id),onTest:ne=>{Ce(ne)}},q.id))})]}),s.jsx(KI,{open:N,onOpenChange:P,onImportComplete:()=>{i!==void 0&&i()}}),s.jsx(sg,{open:$,onOpenChange:F,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:Qt})]})}const YP=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function XP(){return s.jsx(Sg,{"aria-label":"Settings sections",className:"grid w-full grid-cols-3 justify-stretch gap-1 bg-muted/35 p-1 group-data-[orientation=horizontal]/tabs:h-auto sm:grid-cols-5",children:YP.map(e=>s.jsx(gn,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function QP(){const[e,t]=c.useState(!1),[n,r]=c.useState("providers"),{providers:o,isLoading:i,mutate:a}=Wl(),[l,u]=c.useState({}),[d,f]=c.useState(new Set),[p,m]=c.useState({}),h=c.useCallback((b,w)=>{u(v=>({...v,[b]:w}))},[]),g=c.useCallback((b,w)=>{f(v=>{const j=new Set(v);return w?j.add(b):j.delete(b),j})},[]),y=c.useCallback((b,w)=>{m(v=>{if(w===void 0){const j={...v};return delete j[b],j}return{...v,[b]:w}})},[]);return s.jsxs(Wt,{open:e,onOpenChange:t,children:[s.jsx(Nr,{asChild:!0,children:s.jsxs(ee,{variant:"ghost",size:"icon",className:Rr,"aria-label":"Settings",title:"Settings",children:[s.jsx(mk,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:"Settings"})]})}),s.jsxs(Zt,{className:"flex max-h-[calc(100vh-1rem)] w-[calc(100%-1rem)] max-w-2xl flex-col overflow-hidden p-4 sm:max-h-[80vh] sm:p-6",children:[s.jsx(Yt,{children:s.jsx(Xt,{children:"Settings"})}),s.jsxs(kg,{value:n,onValueChange:r,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[s.jsx(XP,{}),s.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[s.jsx(jt,{value:"providers",children:s.jsx(JP,{externalProviders:o,isLoading:i,externalTestResults:l,externalTestingProviders:d,externalTestingTimeLeft:p,onProvidersMutate:()=>a(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:y})}),s.jsx(jt,{value:"proxy",children:s.jsx(oM,{})}),s.jsx(jt,{value:"storage",children:s.jsx(nM,{})}),s.jsx(jt,{value:"mcp",children:s.jsx(rM,{})}),s.jsx(jt,{value:"onboarding",children:s.jsx(sM,{})})]})]})]})]})}const eM=E({memoryCount:R(),logDir:x(),logFileCount:R(),logBytes:R(),chunkDir:x(),chunkFileCount:R(),chunkBytes:R(),sessionArchiveDir:x(),sessionArchiveFileCount:R(),sessionArchiveBytes:R()}),tM=1e4;function ja(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024/1024/1024).toFixed(1)} GiB`}function nM(){const[e,t]=c.useState(null),[n,r]=c.useState(null),[o,i]=c.useState(!1),[a,l]=c.useState(null),u=c.useCallback(async()=>{i(!0),r(null);try{const f=await He("/api/logs?stats=1",eM,tM,void 0,p=>`Failed to load storage stats: HTTP ${String(p.status)}`);t(f)}catch(f){r(f instanceof Error?f.message:String(f))}finally{i(!1)}},[]);c.useEffect(()=>{u()},[u]);const d=c.useCallback((f,p)=>{It(p).then(m=>{m&&(l(f),setTimeout(()=>l(null),1600))})},[]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),s.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{u()},children:o?"Refreshing...":"Refresh"})]}),e!==null&&s.jsxs("div",{className:"grid gap-2 text-xs",children:[s.jsx(er,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:a,onCopy:d}),s.jsx(er,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:a,onCopy:d}),s.jsx(er,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:a,onCopy:d}),s.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"In-memory logs"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),s.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Log files"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",ja(e.logBytes)]})]}),s.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Streaming chunks"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",ja(e.chunkBytes)]})]}),s.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[s.jsx("div",{className:"font-medium",children:"Session archives"}),s.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",ja(e.sessionArchiveBytes)]})]})]}),n!==null&&s.jsx("p",{className:"text-xs text-destructive",children:n})]})}function er({id:e,label:t,value:n,copiedId:r,onCopy:o}){const i=r===e;return s.jsxs("div",{className:"min-w-0 rounded-md border border-border/45 bg-muted/15 px-3 py-2 transition-colors hover:bg-muted/25",children:[s.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:n,children:n}),s.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>o(e,n),"aria-label":i?`Copied ${t}`:`Copy ${t}`,children:i?s.jsx(qe,{className:"size-3.5 text-status-success"}):s.jsx(zt,{className:"size-3.5"})})]})]})}function sM(){const[e,t]=c.useState(null),n=c.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[]),r=c.useMemo(()=>zp(n,pf()),[n]),o=c.useMemo(()=>[{id:"status",label:"Check onboarding",value:"agent-inspector onboard --status"},{id:"status-json",label:"Check onboarding JSON",value:"agent-inspector onboard --status --json"},{id:"refresh",label:"Refresh generated files",value:"agent-inspector onboard --force"},{id:"uninstall",label:"Remove matching generated files",value:"agent-inspector onboard --uninstall"},{id:"claude",label:"Claude Code command",value:"/agent-inspector:onboard"},{id:"codex",label:"Codex prompt",value:"Use the agent-inspector-onboard skill"},{id:"opencode-config",label:"OpenCode config",value:"agent-inspector onboard --opencode-only"},{id:"opencode-status",label:"OpenCode status",value:"agent-inspector onboard --status --opencode-only"},{id:"opencode-verify",label:"OpenCode verify",value:"opencode mcp list"},{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${r.proxy}`},{id:"mimo-config",label:"MiMo Code config",value:"agent-inspector onboard --mimo-only"},{id:"mimo-status",label:"MiMo Code status",value:"agent-inspector onboard --status --mimo-only"},{id:"mimo-verify",label:"MiMo Code verify",value:"mimo mcp list"},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${r.proxy}`},{id:"mcp",label:"MCP URL",value:r.mcp},{id:"proxy",label:"Proxy URL",value:r.proxy},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${r.proxy}`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${r.openAiV1}`}],[r]),i=c.useCallback((a,l)=>{It(l).then(u=>{u&&(t(a),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Xn,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),s.jsx("div",{className:"grid gap-2",children:o.map(a=>s.jsx(er,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))}),s.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qe,{className:"size-3.5 text-status-success"}),s.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qe,{className:"size-3.5 text-status-success"}),s.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(qe,{className:"mt-0.5 size-3.5 text-status-success"}),s.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",s.jsx("code",{className:"mx-1 rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"agent-inspector-mcp stdio"}),"instead. Configure only one entry for the same Inspector."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(qe,{className:"mt-0.5 size-3.5 text-status-success"}),s.jsxs("span",{children:["OpenCode onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(qe,{className:"mt-0.5 size-3.5 text-status-success"}),s.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mimocode.jsonc"}),", then route OpenAI-format traffic with"," ",s.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(qe,{className:"mt-0.5 size-3.5 text-status-success"}),s.jsx("span",{children:"If your AI tool runs in another container or host, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})]})}function rM(){const[e,t]=c.useState(null),r=`${c.useMemo(()=>typeof window>"u"?"http://localhost:9527":window.location.origin,[])}${Jo("/api/mcp")}`,o=c.useMemo(()=>[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:r},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${r}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${r}`},{id:"writes",label:"Enable write tools",value:"AGENT_INSPECTOR_MCP_WRITES=1 agent-inspector"},{id:"capabilities",label:"Capabilities resource",value:"inspector://mcp/capabilities"},{id:"context",label:"Current context resource",value:"inspector://context/current"},{id:"streamable-json",label:"Streamable HTTP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{type:"streamableHttp",url:r}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",r]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",r],enabled:!0}}},null,2)},{id:"mimo-local",label:"MiMo Code local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",r],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
125
- command = "agent-inspector-mcp"
126
- args = ["stdio", "--url", "${r}"]`}],[r]),i=c.useCallback((a,l)=>{It(l).then(u=>{u&&(t(a),setTimeout(()=>t(null),1600))})},[]);return s.jsxs("div",{className:"min-w-0 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Xn,{className:"size-4 text-muted-foreground"}),s.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),s.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[s.jsx("div",{children:"Use Streamable HTTP when the client supports URL-based MCP. Use the stdio bridge only for stdio-only clients. Configure one entry for the same Inspector instance."}),s.jsx("div",{children:"If the MCP client runs in another container or host, replace localhost with a reachable host/IP and verify the network path."})]}),s.jsx("div",{className:"grid gap-2",children:o.map(a=>s.jsx(er,{id:a.id,label:a.label,value:a.value,copiedId:e,onCopy:i},a.id))})]})}function oM(){const{strip:e,slowResponseThresholdSeconds:t,providerTestTimeoutSeconds:n,timeDisplayFormat:r,isLoading:o,setStrip:i,setSlowResponseThresholdSeconds:a,setProviderTestTimeoutSeconds:l,setTimeDisplayFormat:u}=Fl(),[d,f]=c.useState(null),[p,m]=c.useState(!1),h=c.useCallback(async w=>{f(null),m(!0);try{await i(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[i]),g=c.useCallback(async w=>{f(null),m(!0);try{await a(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[a]),y=c.useCallback(async w=>{f(null),m(!0);try{await l(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[l]),b=c.useCallback(async w=>{f(null),m(!0);try{await u(w)}catch(v){f(v instanceof Error?v.message:String(v))}finally{m(!1)}},[u]);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Strip Claude Code's synthetic billing block before upstream forwarding. This can improve prefix-cache hits with third-party providers and is persisted to ",s.jsx("code",{children:"config.json"}),"."]})]}),s.jsxs("label",{className:"flex items-center gap-3",children:[s.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:o||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-sm",children:o?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",s.jsx("code",{children:"0"})," to disable it."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:Ma,step:1,value:t,disabled:o||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>Ma||g(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:Aa,step:1,value:n,disabled:o||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<1||v>Aa||y(v))},className:"h-8 w-24 rounded-md border border-input bg-transparent px-2 text-sm font-mono disabled:cursor-not-allowed disabled:opacity-50"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),s.jsxs("select",{id:"time-display-format",value:r,disabled:o||p,onChange:w=>{const v=bp.safeParse(w.currentTarget.value);v.success&&b(v.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx("option",{value:"time",children:"Time only"}),s.jsx("option",{value:"full",children:"Full ISO"})]})]}),d!==null&&s.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",d]})]})}const iM=pe(["installed","update-available","available","planned","unknown"]),aM=E({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:iM,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:Re()}),lM=E({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:K(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),cM=E({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:Re(),runnable:Re()}),uM=E({checkedAt:x(),packages:K(aM),runnerPresets:K(lM),recipes:K(cM)}),tx=pe(["install","upgrade","help","runner-presets","recipe"]),nx="RUN_LOCAL_COMMAND",dM=E({action:tx,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:R().int().positive(),scope:x()}),fM=E({nonce:x().uuid(),phrase:le(nx),expiresAt:x().datetime(),plan:dM}),sx=E({confirmation:fM});Cn("intent",[E({intent:le("prepare")}),E({intent:le("confirm"),nonce:x().uuid(),confirmation:le(nx)})]);const pM=pe(["queued","running","succeeded","failed"]),rx=E({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:tx,status:pM,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:R().nullable(),error:x().nullable()}),ox=E({task:rx}),mM=E({tasks:K(rx)}),hM=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:Zy},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:Pt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Ul},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:Dj}];async function gM(e){return st(e,uM,void 0,t=>`Failed to load ecosystem packages: ${String(t.status)}`)}async function xM(e){return st(e,ox,void 0,t=>`Failed to load ecosystem task: ${String(t.status)}`)}async function bM(e){return st(e,mM,void 0,t=>`Failed to load ecosystem tasks: ${String(t.status)}`)}async function vM(e,t){const n=`/api/ecosystem/packages/${encodeURIComponent(e)}/${t}`,r=await st(n,sx,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem task: ${String(o.status)}`);return{endpoint:n,confirmation:r.confirmation}}async function yM(e){const t=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,n=await st(t,sx,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},r=>`Failed to prepare ecosystem recipe: ${String(r.status)}`);return{endpoint:t,confirmation:n.confirmation}}async function wM(e){return(await st(e.endpoint,ox,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:e.confirmation.nonce,confirmation:e.confirmation.phrase})},n=>`Failed to start ecosystem task: ${String(n.status)}`)).task}function jM(e){switch(e){case"installed":return"Installed";case"update-available":return"Update";case"available":return"Available";case"planned":return"Planned";case"unknown":return"Unknown"}}function kM(e){switch(e){case"installed":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-200";case"update-available":return"border-amber-400/20 bg-amber-400/8 text-amber-200";case"available":return"border-sky-400/20 bg-sky-400/8 text-sky-200";case"planned":return"border-white/10 bg-white/[0.04] text-white/55";case"unknown":return"border-white/10 bg-white/[0.04] text-white/45"}}function SM(e){return e.installedVersion!==null&&e.latestVersion!==null?e.installedVersion===e.latestVersion?`v${e.installedVersion}`:`v${e.installedVersion} -> v${e.latestVersion}`:e.installedVersion!==null?`v${e.installedVersion}`:e.latestVersion!==null?`latest v${e.latestVersion}`:"not published"}function tr(e){switch(e){case"install":return"Install";case"upgrade":return"Upgrade";case"help":return"Help";case"runner-presets":return"Presets";case"recipe":return"Recipe"}}function _M(e){switch(e.status){case"queued":return"Queued";case"running":return`${tr(e.action)} running`;case"succeeded":return`${tr(e.action)} complete`;case"failed":return`${tr(e.action)} failed`}}function ix(e){switch(e){case"queued":case"running":return"border-cyan-300/20 bg-cyan-300/8 text-cyan-100";case"succeeded":return"border-emerald-400/20 bg-emerald-400/8 text-emerald-100";case"failed":return"border-red-400/20 bg-red-400/8 text-red-100"}}function NM(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function CM({pkg:e,activeTask:t,onStartTask:n}){const r=NM(e),o=t!==null&&t.packageId===e.id&&t.status==="running";return s.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(qj,{className:"size-4 shrink-0 text-white/55"}),s.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),s.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),s.jsx(Te,{className:L("shrink-0",kM(e.state)),variant:"outline",children:jM(e.state)})]}),s.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[s.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:SM(e)}),s.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),s.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[r!==null&&s.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:o,onClick:()=>n(e.id,r),children:[o?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(yr,{className:"size-3.5"}),tr(r)]}),s.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:o||e.state==="planned",onClick:()=>n(e.id,"help"),children:[s.jsx(Xn,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&s.jsxs(ee,{type:"button",size:"sm",variant:"ghost",disabled:o||e.state==="planned",onClick:()=>n(e.id,"runner-presets"),children:[s.jsx(Ul,{className:"size-3.5"}),"Presets"]})]})]})}function TM({task:e}){if(e===null)return null;const t=e.status==="queued"||e.status==="running";return s.jsxs("section",{className:"mt-3 rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t?s.jsx(De,{className:"size-4 animate-spin text-cyan-200/75"}):s.jsx(Xn,{className:"size-4 text-white/55"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-semibold",children:_M(e)}),s.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),s.jsx(Te,{variant:"outline",className:L("shrink-0",ix(e.status)),children:e.status})]}),s.jsx("pre",{className:"mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-black/30 p-3 font-mono text-[11px] leading-5 text-white/60 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.output.trim().length>0?e.output:"Waiting for npm output..."}),e.error!==null&&s.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function EM({workflow:e}){const t=e.icon;return s.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(t,{className:"size-4 shrink-0 text-cyan-200/75"}),s.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),s.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),s.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),s.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function RM(e){return e===null?'npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke" --latest-log-limit 5':`npx @tonyclaw/eval-harness inspector-smoke --title "TonyClaw Lab smoke ${e}" --latest-log-limit 5`}function IM({preset:e}){return s.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Ep,{className:"size-4 shrink-0 text-cyan-200/75"}),s.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),s.jsxs("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:[e.binary," ",e.modelFlag,e.variantFlag!==null?` ${e.variantFlag}`:""]})]}),s.jsxs(Te,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[s.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),s.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),s.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),s.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function PM({recipe:e,copied:t,running:n,onCopy:r,onRun:o}){return s.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Sp,{className:"size-4 shrink-0 text-cyan-200/75"}),s.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),s.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),s.jsx(Te,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),s.jsx("div",{className:"mt-3 rounded-md bg-black/20 p-2 font-mono text-[11px] leading-5 text-white/50 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:e.command}),s.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[s.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>r(e),children:[t?s.jsx(qe,{className:"size-3.5"}):s.jsx(zt,{className:"size-3.5"}),t?"Copied":"Copy"]}),e.runnable&&s.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:n,onClick:()=>o(e),children:[n?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(Ep,{className:"size-3.5"}),n?"Running":"Run"]})]})]})]})}function MM({task:e,selected:t,onSelect:n}){const r=e.recipeId??tr(e.action);return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md bg-white/[0.025] px-3 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Np,{className:"size-3.5 shrink-0 text-white/40"}),s.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:r}),s.jsx(Te,{variant:"outline",className:L("shrink-0",ix(e.status)),children:e.status})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[s.jsx("span",{children:e.packageId}),s.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&s.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),s.jsx(ee,{type:"button",size:"sm",variant:t?"secondary":"outline",onClick:()=>n(e),children:t?"Open":"View"})]})}function AM({pending:e,busy:t,onOpenChange:n,onConfirm:r}){const o=e?.confirmation.plan??null;return s.jsx(Wt,{open:e!==null,onOpenChange:n,children:s.jsxs(Zt,{className:"max-w-xl",children:[s.jsxs(Yt,{children:[s.jsx(Xt,{children:"Confirm local command"}),s.jsx(Cr,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),o!==null&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[s.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[s.jsx("div",{className:"text-muted-foreground",children:"Source"}),s.jsx("div",{className:"mt-1 break-words font-medium",children:o.source})]}),s.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[s.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),s.jsxs("div",{className:"mt-1 font-medium",children:[String(o.timeoutMs/1e3)," seconds"]})]}),s.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[s.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),s.jsx("div",{className:"mt-1 font-medium",children:o.scope})]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),s.jsx("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md bg-black/80 p-3 font-mono text-xs leading-5 text-white/80",children:o.command})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",s.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),s.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[s.jsx(ee,{type:"button",variant:"outline",disabled:t,onClick:()=>n(!1),children:"Cancel"}),s.jsxs(ee,{type:"button",variant:"secondary",disabled:t||o===null,onClick:r,children:[t?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(Xn,{className:"size-3.5"}),t?"Starting":"Confirm & Run"]})]})]})})}function OM({currentSessionId:e,logCount:t,labelledTrigger:n=!1}){const[r,o]=c.useState(!1),[i,a]=c.useState(!1),[l,u]=c.useState(!1),[d,f]=c.useState(null),[p,m]=c.useState(null),[h,g]=c.useState(null),[y,b]=c.useState(null),[w,v]=c.useState(!1),j=Bt("/api/ecosystem/packages",gM,{revalidateOnFocus:!1,revalidateIfStale:!1}),k=Bt(p===null?null:`/api/ecosystem/tasks/${p}`,xM,{refreshInterval:B=>{const W=B?.task;return W!==void 0&&(W.status==="queued"||W.status==="running")?900:0},revalidateOnFocus:!1}),S=Bt(r?"/api/ecosystem/tasks":null,bM,{refreshInterval:2500,revalidateOnFocus:!1}),_=j.data?.packages??[],C=j.data?.runnerPresets??[],M=j.data?.recipes??[],A=(S.data?.tasks??[]).slice(0,6),I=c.useMemo(()=>_.filter(B=>B.state==="installed"||B.state==="update-available").length,[_]),N=RM(e),P="npx @tonyclaw/eval-harness runner-presets",$=()=>{It(N).then(()=>{a(!0),window.setTimeout(()=>a(!1),1200)})},F=()=>{It(P).then(()=>{u(!0),window.setTimeout(()=>u(!1),1200)})},G=B=>{It(B.command).then(()=>{f(B.id),window.setTimeout(()=>f(null),1200)})},X=B=>{g(null),yM(B.id).then(W=>{b(W)}).catch(W=>{g(W instanceof Error?W.message:"Failed to prepare ecosystem recipe")})},U=k.data?.task??null;c.useEffect(()=>{U!==null&&(S.mutate(),U.status==="succeeded"&&j.mutate())},[U,j,S]);const V=(B,W)=>{g(null),vM(B,W).then(me=>{b(me)}).catch(me=>{g(me instanceof Error?me.message:"Failed to prepare ecosystem task")})},Y=()=>{y!==null&&(g(null),v(!0),wM(y).then(B=>{m(B.id),b(null),k.mutate({task:B},{revalidate:!0}),S.mutate()}).catch(B=>{g(B instanceof Error?B.message:"Failed to start ecosystem task")}).finally(()=>{v(!1)}))};return s.jsxs(Wt,{open:r,onOpenChange:o,children:[s.jsx(Nr,{asChild:!0,children:s.jsxs(ee,{variant:"ghost",size:n?"default":"icon",className:L(Rr,n&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[s.jsx(Sp,{className:"size-4"}),s.jsx("span",{className:n?"":"sr-only",children:"Lab"})]})}),s.jsxs(Zt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[s.jsx(Yt,{children:s.jsxs(Xt,{className:"flex items-center gap-2",children:[s.jsx(za,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),s.jsxs("div",{className:"overflow-y-auto pr-2",children:[s.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[s.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),s.jsx("div",{className:"mt-1 max-w-2xl text-xs leading-5 text-muted-foreground",children:"Treat captured traffic as durable assets: observe it, replay it, evaluate it, and expose it back to agents through MCP."})]}),s.jsxs(Te,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(I),"/",String(_.length)," packages"]})]}),s.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:hM.map(B=>s.jsx(EM,{workflow:B},B.id))})]}),s.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),s.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),s.jsxs(Te,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(t)," logs"]})]}),s.jsx("div",{className:"mt-4 rounded-md bg-black/20 p-3 font-mono text-[11px] leading-5 text-white/55 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:N}),s.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[s.jsxs(ee,{size:"sm",variant:"secondary",onClick:$,children:[i?s.jsx(qe,{className:"size-3.5"}):s.jsx(zt,{className:"size-3.5"}),i?"Copied":"Copy"]}),s.jsxs(ee,{size:"sm",variant:"outline",onClick:F,children:[s.jsx(Ul,{className:"size-3.5"}),l?"Presets copied":"Runner Presets"]})]})]})]}),s.jsxs("section",{className:"mt-3",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),s.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[s.jsx(za,{className:"size-3.5"}),"copy-ready workflows"]})]}),s.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[M.map(B=>s.jsx(PM,{recipe:B,copied:d===B.id,running:U!==null&&U.recipeId===B.id&&(U.status==="queued"||U.status==="running"),onCopy:G,onRun:X},B.id)),j.isLoading&&M.length===0&&[0,1].map(B=>s.jsx("div",{className:"h-40 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},B))]})]}),s.jsxs("section",{className:"mt-3",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),s.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[s.jsx(Xn,{className:"size-3.5"}),P]})]}),s.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[C.map(B=>s.jsx(IM,{preset:B},B.id)),j.isLoading&&C.length===0&&[0,1,2,3].map(B=>s.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},B))]})]}),s.jsxs("section",{className:"mt-3",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&s.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&s.jsx("div",{className:"rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:"Package status is temporarily unavailable."}),s.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[_.map(B=>s.jsx(CM,{pkg:B,activeTask:U,onStartTask:V},B.id)),j.isLoading&&_.length===0&&[0,1,2].map(B=>s.jsx("div",{className:"h-36 animate-pulse rounded-lg bg-white/[0.025] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]"},B))]})]}),h!==null&&s.jsx("div",{className:"mt-3 rounded-lg bg-red-500/8 p-3 text-xs text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:h}),A.length>0&&s.jsxs("section",{className:"mt-3",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[s.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),s.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(A.length)]})]}),s.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:A.map(B=>s.jsx(MM,{task:B,selected:p===B.id,onSelect:W=>{m(W.id),k.mutate({task:W},{revalidate:!0})}},B.id))})]}),s.jsx(TM,{task:U})]})]}),s.jsx(AM,{pending:y,busy:w,onOpenChange:B=>{!B&&!w&&b(null)},onConfirm:Y})]})}function zM(e){return[...new Set(e.evidence.map(t=>t.logId).filter(t=>t!==null))]}const LM=[{id:"reliability",label:"Reliability",question:"Which requests failed, stalled, or look most likely to hang, and why?"},{id:"performance",label:"Performance",question:"Summarize latency and identify the slowest requests with supporting evidence."},{id:"tokens",label:"Token usage",question:"Where are tokens being spent, and which requests have unusually high usage?"},{id:"providers",label:"Providers",question:"Compare Provider and model reliability, latency, and token usage in this scope."},{id:"tools",label:"Tool activity",question:"Which tools were used most, and where did tool calls fail or produce warnings?"}],$M=4e3,ka=12;function Ed(){return{messages:[],question:"",error:null}}function DM(e){return e.filter(t=>t.content.trim().length>0).slice(-10).map(t=>({role:t.role,content:t.content.trim().slice(0,$M)}))}function at(e,...t){for(const n of t){const r=Q(e,n);if(typeof r=="string"&&r.trim().length>0)return r}return null}function xn(e,...t){for(const n of t){const r=Q(e,n);if(typeof r=="number"&&Number.isFinite(r))return r}return null}function FM(e,t){const n=Q(e,t);return Array.isArray(n)?n.filter(r=>typeof r=="string").slice(0,8):[]}function UM(e){const t=at(e,"source")??"log",n=at(e,"id")??"",r=xn(e,"logId","id");if(n===""&&r===null||r!==null&&(!Number.isInteger(r)||r<0))return null;const o=xn(e,"inputTokens"),i=xn(e,"outputTokens"),a=xn(e,"totalTokens","tokenCount"),l=xn(e,"responseStatus","status"),u=at(e,"responseStatus","status");return{source:t,id:n!==""?n:String(r),logId:r,sessionId:at(e,"sessionId"),timestamp:at(e,"timestamp"),model:at(e,"model"),providerName:at(e,"providerName","provider"),path:at(e,"path"),status:l??u,elapsedMs:xn(e,"elapsedMs","latencyMs"),inputTokens:o,outputTokens:i,totalTokens:a??(o===null&&i===null?null:(o??0)+(i??0)),score:xn(e,"score","relevanceScore"),matchedFields:FM(e,"matchedFields"),excerpt:at(e,"excerpt","snippet")??"No excerpt available."}}function Sa(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return t.length===0?"Metric":`${t[0]?.toUpperCase()??""}${t.slice(1)}`}function Rd(e){if(typeof e=="number"&&Number.isFinite(e))return e.toLocaleString();if(typeof e=="string"&&e.trim().length>0)return e;if(typeof e=="boolean")return e?"Yes":"No";if(Array.isArray(e)){const t=e.filter(n=>typeof n=="string"||typeof n=="number"&&Number.isFinite(n)).slice(0,6);return t.length>0?t.join(", "):null}return null}function Id(e){return Object.getOwnPropertyNames(e).map(t=>[t,Q(e,t)])}function Pd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const t=[];for(const[n,r]of Id(e)){const o=Rd(r);if(o!==null){if(t.push({key:n,label:Sa(n),value:o}),t.length>=ka)break;continue}if(!(r===null||typeof r!="object"||Array.isArray(r))){for(const[i,a]of Id(r)){const l=Rd(a);if(l===null)continue;const u=`${n}.${i}`;if(t.push({key:u,label:`${Sa(n)} ${Sa(i).toLowerCase()}`,value:l}),t.length>=ka)break}if(t.length>=ka)break}}return t}function BM(e){const t=at(e,"answer"),n=at(e,"providerId"),r=at(e,"providerName"),o=at(e,"model"),i=at(e,"protocol"),a=xn(e,"logCount");if(t===null||n===null||r===null||o===null||i===null||a===null)return null;const l=Q(e,"evidence"),u=Array.isArray(l)?l.map(UM).filter(d=>d!==null).slice(0,12):[];return{answer:t,providerId:n,providerName:r,model:o,protocol:i,logCount:a,evidence:u,summaryMetrics:Pd(Q(e,"summary")),queryMetrics:Pd(Q(e,"queryStats"))}}const qM=c.lazy(()=>Kt(()=>import("./index-xF_NY8Yb.js"),__vite__mapDeps([9,1]))),HM="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]";function VM({text:e}){return s.jsx("div",{className:HM,children:s.jsx(c.Suspense,{fallback:s.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:s.jsx(qM,{children:e})})})}const Md="What looks abnormal, slow, or likely to hang?";function WM(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function ZM(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function KM(e){return e.toSorted((t,n)=>{const r=t.source==="company"?0:1,o=n.source==="company"?0:1;return r!==o?r-o:t.name.localeCompare(n.name)})}function Ad(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Un({label:e,value:t,tone:n="muted"}){return s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[s.jsx("span",{className:n==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),t!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-muted-foreground/55",children:":"}),s.jsx("span",{className:"truncate text-muted-foreground",children:t})]})]})}function GM({metrics:e}){return e.length===0?null:s.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(t=>s.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[s.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:t.label}),s.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:t.value})]},t.key))})}function JM({evidence:e}){const t=()=>{e.logId!==null&&Ms({logId:e.logId,tab:"anatomy"})},n=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return s.jsxs("button",{type:"button",onClick:t,disabled:e.logId===null,className:"w-full rounded-sm bg-black/25 px-2 py-2 text-left shadow-[inset_2px_0_0_rgba(103,232,249,0.22),inset_0_0_0_1px_rgba(255,255,255,0.045)] transition-colors hover:bg-black/35 disabled:cursor-default disabled:hover:bg-black/25",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[s.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:n}),e.score!==null&&s.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&s.jsx("span",{children:e.providerName}),e.model!==null&&s.jsx("span",{children:e.model}),e.status!==null&&s.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&s.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),s.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function YM({response:e}){return s.jsxs("div",{className:"overflow-hidden rounded-md bg-[#050b12]/85 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.12),0_10px_24px_rgba(0,0,0,0.18)]",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2 border-b border-cyan-100/[0.08] bg-cyan-400/[0.045] px-3 py-2",children:[s.jsx(Un,{label:"assistant@inspector",value:"output",tone:"cyan"}),s.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),s.jsxs("div",{className:"space-y-3 p-3",children:[s.jsx("div",{className:"rounded-sm bg-black/20 px-2.5 py-2 text-xs leading-5 shadow-[inset_2px_0_0_rgba(103,232,249,0.28)]",children:s.jsx(VM,{text:e.answer})}),s.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[s.jsx(Un,{label:"provider",value:e.providerName}),s.jsx(Un,{label:"model",value:e.model}),s.jsx(Un,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Un,{label:"metrics",tone:"cyan"}),s.jsx(GM,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Un,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(t=>s.jsx(JM,{evidence:t},`${t.source}-${t.id}`))]})]})]})}function XM({message:e}){return e.role==="assistant"&&e.response!==null?s.jsx(YM,{response:e.response}):s.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[s.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:s.jsx(Un,{label:"user@inspector",value:"query",tone:"cyan"})}),s.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[s.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function QM({currentSessionId:e,logCount:t,onResultChange:n}){const{providers:r}=Wl(),o=c.useMemo(()=>KM(r.filter(WM)),[r]),[i,a]=c.useState(()=>({...Ed(),question:Md})),[l,u]=c.useState("__auto__"),[d,f]=c.useState("__auto__"),[p,m]=c.useState(!1),g=o.find(_=>_.id===l)?.models??[],y=i.question,b=y.trim()!==""&&o.length>0&&!p;if(o.length===0)return null;const w=_=>{a(C=>({...C,question:_.currentTarget.value}))},v=_=>{u(_),f("__auto__")},j=()=>{a({...Ed(),question:Md}),n(null)},k=_=>{a(C=>({...C,question:_,error:null}))},S=()=>{if(!b)return;const _=y.trim(),C=DM(i.messages),M={id:Ad("user"),role:"user",content:_,response:null};m(!0),a(I=>({...I,messages:[...I.messages,M],question:"",error:null}));const A={question:_,history:C,...e!==null?{sessionId:e}:{},...l!=="__auto__"?{providerId:l}:{},...d!=="__auto__"?{model:d}:{},logLimit:16};fetch(Jo("/api/pi-agent"),{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(A)}).then(async I=>{const N=await I.text();if(!I.ok){a(F=>({...F,error:`Inspector Assistant failed: HTTP ${String(I.status)} ${N}`}));return}const P=JSON.parse(N),$=BM(P);if($===null){a(F=>({...F,error:"Inspector Assistant returned an unexpected response."}));return}a(F=>({...F,messages:[...F.messages,{id:Ad("assistant"),role:"assistant",content:$.answer,response:$}]})),n({question:_,logIds:zM($),reportedLogCount:$.logCount})}).catch(I=>{a(N=>({...N,error:I instanceof Error?I.message:"Inspector Assistant request failed."}))}).finally(()=>{m(!1)})};return s.jsxs("section",{className:"rounded-md bg-black/20 px-3 py-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uw,{className:"size-4 text-cyan-200"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),s.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),s.jsx("button",{type:"button",onClick:j,className:"inline-flex size-7 items-center justify-center rounded-md bg-black/25 text-muted-foreground transition-colors hover:text-foreground",title:"Reset conversation",children:s.jsx(Rp,{className:"size-3.5"})})]}),i.messages.length===0&&s.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[s.jsxs(pr,{value:l,onValueChange:v,children:[s.jsx(mr,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:s.jsx(Uo,{placeholder:"Provider"})}),s.jsxs(hr,{children:[s.jsx(lt,{value:"__auto__",children:"Auto provider"}),o.map(_=>s.jsxs(lt,{value:_.id,children:[_.name," / ",ZM(_)]},_.id))]})]}),s.jsxs(pr,{value:d,onValueChange:f,children:[s.jsx(mr,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:s.jsx(Uo,{placeholder:"Model"})}),s.jsxs(hr,{children:[s.jsx(lt,{value:"__auto__",children:"Auto model"}),g.map(_=>s.jsx(lt,{value:_,children:_},_))]})]})]}),i.messages.length===0&&s.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:LM.map(_=>s.jsxs("button",{type:"button",onClick:()=>{k(_.question)},className:"inline-flex h-7 items-center gap-1.5 rounded-sm bg-black/25 px-2 text-[11px] text-cyan-50 transition-colors hover:bg-cyan-400/12",children:[s.jsx(za,{className:"size-3"}),s.jsx("span",{children:_.label})]},_.id))}),i.messages.length>0&&s.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[i.messages.map(_=>s.jsx(XM,{message:_},_.id)),p&&s.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[s.jsx(De,{className:"size-3.5 animate-spin"}),s.jsx("span",{children:"Searching Inspector..."})]})]}),s.jsx("textarea",{value:y,onChange:w,className:"mt-3 min-h-20 w-full resize-y rounded-md bg-black/25 px-3 py-2 text-xs leading-5 text-foreground outline-none shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors placeholder:text-muted-foreground focus-visible:ring-1 focus-visible:ring-ring",placeholder:"Ask about this Inspector data..."}),s.jsxs("button",{type:"button",onClick:S,disabled:!b,className:"mt-2 inline-flex h-8 w-full items-center justify-center gap-2 rounded-md bg-cyan-400/12 px-3 text-xs font-medium text-cyan-100 shadow-[inset_0_0_0_1px_rgba(103,232,249,0.18)] transition-colors hover:bg-cyan-400/18 disabled:cursor-not-allowed disabled:opacity-50",children:[p?s.jsx(De,{className:"size-3.5 animate-spin"}):s.jsx(uk,{className:"size-3.5"}),s.jsx("span",{children:p?"Searching...":"Ask Assistant"})]}),i.error!==null&&s.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:i.error}),t===0&&s.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function eA(e){const t=new Map;for(const n of e){const r=n.logs;for(let o=1;o<r.length;o++){const i=r[o-1],a=r[o];i===void 0||a===void 0||t.set(a.id,{creation:Od(i.cacheCreationInputTokens,a.cacheCreationInputTokens),read:Od(i.cacheReadInputTokens,a.cacheReadInputTokens)})}}return t}function Od(e,t){return t===null||e===null?null:t>e?{direction:"up",delta:t-e}:t<e?{direction:"down",delta:e-t}:null}function ax(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ds(e,t,n){const r=ax(e.lastSuccessAt),o=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",i=n?" Captured logs remain visible.":"",a=r===null?"":` Last update ${r}.`;return`${t}${a}${o}${i}`}function lx(e,t,n){switch(e){case"connecting":return{label:"Connecting",description:ds(t,"Waiting for the first live update.",n),toneClass:"border-cyan-400/20 bg-cyan-500/8 text-cyan-100",dotClass:"bg-cyan-300 animate-pulse motion-reduce:animate-none",canRetry:!1,canStop:!1};case"live":return{label:"Live",description:ds(t,"Live updates are current.",n),toneClass:"border-emerald-400/20 bg-emerald-500/8 text-emerald-100",dotClass:"bg-emerald-300",canRetry:!1,canStop:!1};case"reconnecting":return{label:"Reconnecting",description:ds(t,"Live updates were interrupted.",n),toneClass:"border-amber-400/20 bg-amber-500/8 text-amber-100",dotClass:"bg-amber-300 animate-pulse motion-reduce:animate-none",canRetry:!0,canStop:!0};case"stale":return{label:"Stale data",description:ds(t,"Live updates have not resumed.",n),toneClass:"border-orange-400/25 bg-orange-500/10 text-orange-100",dotClass:"bg-orange-300",canRetry:!0,canStop:!0};case"offline":return{label:"Offline",description:ds(t,t.errorMessage??"Live updates are paused.",n),toneClass:"border-slate-400/20 bg-slate-500/10 text-slate-200",dotClass:"bg-slate-400",canRetry:!0,canStop:!1};case"error":return{label:"Connection error",description:ds(t,t.errorMessage??"The live stream reported a recoverable error.",n),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function tA({state:e}){const t=lx(e.status,e,!1),n=ax(e.lastSuccessAt),r=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return s.jsxs("span",{role:"status","aria-label":t.description,"data-connection-state":e.status,className:L("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",t.toneClass),children:[s.jsx("span",{className:L("size-1.5 shrink-0 rounded-full",t.dotClass)}),s.jsx("span",{className:"shrink-0",children:t.label}),r!==null&&s.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:r}),n!==null&&s.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",n]})]})}function nA({state:e,hasLogs:t,onRetry:n,onStop:r}){const o=lx(e.status,e,t);return s.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:L("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",o.toneClass),children:[s.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[s.jsx("span",{className:L("size-2 shrink-0 rounded-full",o.dotClass)}),s.jsx("span",{className:"shrink-0 font-semibold",children:o.label}),s.jsx("span",{className:"min-w-0 text-current/75",children:o.description})]}),(o.canRetry||o.canStop)&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[o.canRetry&&s.jsxs("button",{type:"button",onClick:n,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[s.jsx(Pt,{className:"size-3"}),"Retry now"]}),o.canStop&&s.jsxs("button",{type:"button",onClick:r,className:"inline-flex h-7 items-center gap-1 rounded-md px-2 text-current/70 transition-colors hover:bg-black/15 hover:text-current focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[s.jsx(Pw,{className:"size-3"}),"Stop retrying"]})]})]})}function sA(){const[e,t]=c.useState(!1),[n,r]=c.useState(!1);c.useEffect(()=>{const a=()=>{t(document.fullscreenElement!==null),r(document.fullscreenEnabled&&document.documentElement.requestFullscreen!==void 0&&document.exitFullscreen!==void 0)};return a(),document.addEventListener("fullscreenchange",a),()=>{document.removeEventListener("fullscreenchange",a)}},[]);const o=c.useCallback(()=>{if(n){if(document.fullscreenElement===null){document.documentElement.requestFullscreen().catch(()=>{t(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{t(document.fullscreenElement!==null)})}},[n]),i=e?"Exit fullscreen":"Enter fullscreen";return s.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:Rr,"aria-label":i,"aria-pressed":e,title:i,disabled:!n,onClick:o,children:[e?s.jsx(Rj,{className:"size-4"}):s.jsx(Cj,{className:"size-4"}),s.jsx("span",{className:"sr-only",children:i})]})}function rA({liveConnection:e,alertsAction:t,settingsAction:n}){return s.jsx("header",{"data-application-bar":"true",className:"border-border/70 bg-background/95 sticky top-0 z-50 shrink-0 border-b px-3 py-2 shadow-[0_10px_30px_rgba(0,0,0,0.14)] backdrop-blur lg:px-4",children:s.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-2 sm:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]",children:[s.jsxs("a",{href:"/","aria-label":"Agent Inspector home",className:"flex min-w-0 items-center gap-2 rounded-md focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[s.jsx(mf,{className:"size-7 shrink-0 text-amber-500"}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),s.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),s.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",Mp.version]})]}),s.jsx("div",{className:"order-3 col-span-2 flex min-w-0 justify-start sm:order-2 sm:col-span-1 sm:justify-center",children:e===void 0?s.jsxs("span",{"data-connection-state":"stored",className:"border-border/70 bg-muted/50 inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium text-muted-foreground",children:[s.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):s.jsx(tA,{state:e})}),s.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[s.jsx(sA,{}),t,n]})]})})}function oA(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function ho({progress:e}){const t=Math.min(1,e.elapsedMs/e.timeoutMs),n=Math.max(4,Math.round(t*100)),r=Math.max(0,e.timeoutMs-e.elapsedMs),o=t>=.75,i=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${oA(r)} before timeout`].filter(l=>l!==null),a=`${e.label}: ${i.join(", ")}`;return s.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 truncate",children:e.label}),s.jsx("span",{className:L("shrink-0 tabular-nums",o&&"text-amber-300"),children:i.join(" / ")})]}),s.jsx("div",{role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.timeoutMs,"aria-valuenow":Math.min(e.elapsedMs,e.timeoutMs),"aria-valuetext":a,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:s.jsx("div",{className:L("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",o?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${n.toString()}%`}})})]})}function cx(e){return e?"auto":"smooth"}function ux(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function iA(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function nn(e,t){switch(t.type){case"connect-requested":return{...e,status:e.lastSuccessAt===null?"connecting":e.status==="stale"?"stale":"reconnecting",errorMessage:null};case"message-received":return{status:"live",lastSuccessAt:t.at,retryCount:0,errorMessage:null};case"connection-lost":{const n=e.retryCount+1;return t.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:n,errorMessage:t.message}:{...e,status:"offline",retryCount:n,errorMessage:"Browser is offline."}}case"stale-timeout":return e.lastSuccessAt===null||e.status==="live"||e.status==="offline"?e:{...e,status:"stale"};case"browser-offline":return{...e,status:"offline",errorMessage:"Browser is offline."};case"stop-retrying":return{...e,status:"offline",errorMessage:"Automatic live updates are paused."};case"recoverable-error":return{...e,status:"error",errorMessage:t.message}}}function aA(e){return e===void 0||e.status==="live"?"empty":e.status}function lA(e){switch(e){case"connecting":return{title:"Connecting to the live stream...",description:"Waiting for the first successful initialization before checking for logs.",showConnectionCommands:!1};case"empty":return{title:"No logs captured yet.",description:"Connect an AI coding tool to capture its first request.",showConnectionCommands:!0};case"reconnecting":return{title:"Reconnecting to live updates...",description:"The stream was interrupted. Agent Inspector is retrying automatically.",showConnectionCommands:!1};case"stale":return{title:"Live data is stale.",description:"No logs are hidden; retry the connection to resume live updates.",showConnectionCommands:!1};case"offline":return{title:"Live updates are offline.",description:"Check the browser and Inspector connection, then retry.",showConnectionCommands:!1};case"error":return{title:"Live updates could not initialize.",description:"The error is recoverable. Retry without reloading the page.",showConnectionCommands:!1}}}const zd="agent-inspector.hierarchy.collapsedClients",Ld="agent-inspector.hierarchy.collapsedProcesses";function Ho(e){return e.some(t=>t.responseStatus===null)}function dx(e){return e.filter(t=>t.responseStatus===null).length}function fx(e){for(const t of e){const n=t.userAgent;if(n!=null&&n!=="")return n}return null}function cA(e){for(const t of e){const n=t.clientPid;if(n!=null)return n}return null}function px(e){for(const t of e){const n=t.clientProjectFolder;if(n!=null&&n!=="")return n}return null}function uA(e){return xc({userAgent:fx(e.logs),conversationId:e.conversationId,clientProjectFolder:px(e.logs)})}function dA(e){if(e===null||e==="")return"Unknown client";const t=e.split(/[ /;]/)[0]??"";return t===""?"Unknown client":t}function fA(e,t){const n=Ni(e);return n!==null?n:dA(t)}function Vo(e){return e===null||e===""?"unknown":String(e)}function pA(e,t,n){return e!=="unknown"?e:`unknown:${Vo(t)}:${Vo(n)}`}function mA(e,t){return`${Vo(e)}:${Vo(t)}`}function $d(e){return[...e].sort((t,n)=>t.timestamp.localeCompare(n.timestamp))}function Dd(e){let t="";for(const n of e)n.timestamp>t&&(t=n.timestamp);return t}function Fd(e){return Ho(e)?0:e.some(t=>t.error!==null&&t.error!==void 0||t.responseStatus!==null&&t.responseStatus!==void 0&&t.responseStatus>=400)?1:2}function _a(e){return[...e].sort((t,n)=>{const r=Fd(t.logs)-Fd(n.logs);if(r!==0)return r;const o=Dd(n.logs).localeCompare(Dd(t.logs));return o!==0?o:t.id.localeCompare(n.id)})}function hA(e){const t=new Map;for(const r of e){const o=fx(r.logs),i=px(r.logs),a=uA(r),l=pA(a,o,i);let u=t.get(l);u===void 0&&(u={id:l,client:a,label:fA(a,o),userAgent:o,processes:new Map,logs:[]},t.set(l,u)),u.logs.push(...r.logs);const d=cA(r.logs),f=`${l}:${mA(d,i)}`;let p=u.processes.get(f);p===void 0&&(p={id:f,clientPid:d,clientProjectFolder:i,sessions:[],logs:[]},u.processes.set(f,p)),p.sessions.push(r),p.logs.push(...r.logs)}const n=[];for(const r of t.values()){const o=_a([...r.processes.values()].map(i=>({id:i.id,clientPid:i.clientPid,clientProjectFolder:i.clientProjectFolder,sessions:_a(i.sessions),logs:$d(i.logs)})));n.push({id:r.id,client:r.client,label:r.label,userAgent:r.userAgent,processes:o,logs:$d(r.logs)})}return _a(n)}function Wo(e){return e<=0?"0":Pe(e)}function mx(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&r.inputTokens!==void 0&&(t+=r.inputTokens),r.outputTokens!==null&&r.outputTokens!==void 0&&(n+=r.outputTokens);return{inputTokens:t,outputTokens:n}}function gA(e){let t=0;for(const n of e)t+=n.sessions.length;return t}function Ud(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(t===null)return null;const n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(r=>typeof r=="string")):null}catch{return null}}function Bd(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t]))}catch{}}function qd(e,t){let n=!1;const r=new Set(e);for(const o of t)r.delete(o)&&(n=!0);return n?r:e}function xA(e){const t=new Set;for(const n of e)for(let r=1;r<n.processes.length;r++){const o=n.processes[r];o!==void 0&&!Ho(o.logs)&&t.add(o.id)}return t}function bA(e){if(e===null||e==="")return null;const t=e.replaceAll("\\","/").split("/").filter(o=>o!==""),n=t[t.length-1];if(n===void 0)return e;const r=t[t.length-2];return r===void 0?n:`${r}/${n}`}function Zo({label:e,value:t,className:n}){return s.jsxs("span",{className:L("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",n),children:[s.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),s.jsx("span",{className:"font-mono tabular-nums text-foreground",children:t})]})}function hx({count:e}){const t=`${e} open turn${e===1?"":"s"}`;return s.jsxs("span",{className:"relative inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-medium)] text-[var(--inspector-status-watch)] ring-1 ring-border/50","aria-label":t,title:t,children:[s.jsx(De,{className:"size-3 animate-spin"}),e>1&&s.jsx("span",{className:"absolute translate-x-2 -translate-y-2 rounded bg-card px-0.5 font-mono text-[8px] tabular-nums text-[var(--inspector-status-watch)]",children:e})]})}function vA({groups:e,...t}){const n=c.useMemo(()=>hA(e),[e]),[r,o]=c.useState(()=>new Set),[i,a]=c.useState(()=>xA(n)),[l,u]=c.useState(!1);c.useEffect(()=>{const p=Ud(zd),m=Ud(Ld);p!==null&&o(p),m!==null&&a(m),u(!0)},[]),c.useEffect(()=>{l&&(Bd(zd,r),Bd(Ld,i))},[r,i,l]),c.useEffect(()=>{const p=new Set(n.filter(h=>Ho(h.logs)).map(h=>h.id)),m=new Set(n.flatMap(h=>h.processes.filter(g=>Ho(g.logs)).map(g=>g.id)));o(h=>qd(h,p)),a(h=>qd(h,m))},[n]);const d=c.useCallback(p=>{o(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})},[]),f=c.useCallback(p=>{a(m=>{const h=new Set(m);return h.has(p)?h.delete(p):h.add(p),h})},[]);return s.jsx("div",{className:"space-y-2",children:n.map(p=>s.jsx(yA,{group:p,collapsed:r.has(p.id),collapsedProcessIds:i,onToggleClient:()=>d(p.id),onToggleProcess:f,conversationProps:t},p.id))})}function yA({group:e,collapsed:t,collapsedProcessIds:n,onToggleClient:r,onToggleProcess:o,conversationProps:i}){const a=mx(e.logs),l=gA(e.processes),u=e.logs.length,d=dx(e.logs),f=d>0;return s.jsxs("section",{className:L("relative isolate overflow-hidden rounded-[8px] bg-card/65",f&&"bg-card/80"),"data-ide-group":e.id,children:[s.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2.25rem_minmax(0,1fr)_auto] items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-[var(--inspector-surface-low)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:r,"aria-expanded":!t,children:[e.client==="unknown"?s.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:s.jsx(Mj,{className:"size-4"})}):s.jsx(Ci,{client:e.client,className:"size-9 rounded-md",decorative:!0}),s.jsxs("span",{className:"min-w-0",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),s.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:YC(e.client)}),f&&s.jsx(hx,{count:d})]}),s.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),s.jsxs("span",{children:[l," session",l!==1?"s":""]}),s.jsxs("span",{children:[u," req"]})]})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&s.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[s.jsx(Zo,{label:"IN",value:Wo(a.inputTokens)}),s.jsx(Zo,{label:"OUT",value:Wo(a.outputTokens)})]}),s.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors group-hover:bg-[var(--inspector-surface-medium)]",children:t?s.jsx(bt,{className:"size-4"}):s.jsx(et,{className:"size-4"})})]})]}),!t&&s.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>s.jsx(wA,{group:p,collapsed:n.has(p.id),onToggle:()=>o(p.id),conversationProps:i},p.id))})]})}function wA({group:e,collapsed:t,onToggle:n,conversationProps:r}){const o=mx(e.logs),i=bA(e.clientProjectFolder),a=e.sessions.length,l=e.logs.length,u=dx(e.logs),d=u>0,f=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return s.jsxs("section",{className:"relative pl-3",children:[s.jsxs("button",{type:"button",className:"grid w-full min-w-0 grid-cols-[2rem_minmax(0,1fr)_auto] items-center gap-2.5 rounded-md bg-[var(--inspector-surface-low)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--inspector-surface-medium)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:n,"aria-expanded":!t,children:[s.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:s.jsx(Ww,{className:"size-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:f}),d&&s.jsx(hx,{count:u}),i!==null&&s.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??i,children:[s.jsx(mj,{className:"size-3 shrink-0"}),s.jsx("span",{className:"truncate font-mono",children:i})]})]}),s.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{children:[a," session",a!==1?"s":""]}),s.jsxs("span",{children:[l," req"]})]})]}),s.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[t&&s.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[s.jsx(Zo,{label:"IN",value:Wo(o.inputTokens)}),s.jsx(Zo,{label:"OUT",value:Wo(o.outputTokens)})]}),s.jsx("span",{className:"inline-flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground transition-colors hover:bg-[var(--inspector-surface-medium)]",children:t?s.jsx(bt,{className:"size-4"}):s.jsx(et,{className:"size-4"})})]})]}),!t&&s.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>s.jsx(yR,{group:p,...r,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const jA="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",kA=[{label:"Headers",detail:"request and response headers, including authorization or cookie values"},{label:"Prompts",detail:"system instructions, user prompts, model responses, and conversation history"},{label:"Source content",detail:"source code, file contents, tool inputs, and tool output"},{label:"Secrets",detail:"API keys, access tokens, credentials, and other sensitive values"}];function SA({onCancel:e,onExportRedacted:t,onConfirmRaw:n}){return s.jsxs(s.Fragment,{children:[s.jsxs(Yt,{children:[s.jsx(Xt,{children:"Export unredacted logs?"}),s.jsx(Cr,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),s.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[s.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),s.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:kA.map(r=>s.jsxs("li",{children:[s.jsxs("span",{className:"font-semibold text-foreground",children:[r.label,":"]})," ",r.detail]},r.label))}),s.jsx("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:"Only continue if you trust where this file will be stored and everyone it may be shared with."})]}),s.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[s.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),s.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:t,children:"Export redacted instead"}),s.jsx(ee,{type:"button",variant:"destructive",size:"sm",onClick:n,children:"Export raw data"})]})]})}const Ko="data-nav-id",_A="data-nav-action";function Hd(e){return Array.from(e.querySelectorAll(`[${Ko}]`))}function Vd(e){return e instanceof HTMLElement}function NA(e,t){let n=e;for(;n!==null&&n!==t;){if(n.hasAttribute(Ko))return n;n=n.parentElement}return e.hasAttribute(Ko)?e:null}function Na(e){const t=e.getAttribute(_A);return t==="toggle"||t==="expand"||t==="collapse"?t:null}function Ks(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Gs(e,t){return e[t]??null}function gx(e){const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function Wd(e){const t=e.tagName;return t==="BUTTON"||t==="A"||gx(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function CA(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function TA(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function to(e,t){return e.key===t&&e.shiftKey}function EA(e,t,n={}){const r=t??e,o=n.pageWide===!0,i=c.useCallback(a=>{const l=e.current,u=r.current;if(!l||!u)return;const d=a.target;if(!Vd(d)||d!==u)return;const f=Hd(l),p=Gs(f,0);p!==null&&Ks(p)},[e,r]);c.useEffect(()=>{const a=l=>{if(l.altKey||l.ctrlKey||l.metaKey)return;const u=e.current;if(!u)return;const d=l.target;if(!Vd(d)||gx(d)||TA())return;const f=u.contains(d);if(f&&Wd(d)&&!d.hasAttribute(Ko)||!f&&(!o||Wd(d)||CA(d)))return;const p=Hd(u);if(p.length===0)return;const m=NA(d,u),h=m!==null?p.indexOf(m):-1;let g=!1;switch(l.key){case"ArrowUp":case"W":{if(l.shiftKey&&l.key==="ArrowUp"||l.key==="W"&&!to(l,"W"))break;l.preventDefault();const y=h>0?h-1:h===-1?p.length-1:-1;if(y!==-1){const b=Gs(p,y);b!==null&&Ks(b)}g=!0;break}case"ArrowDown":case"S":{if(l.shiftKey&&l.key==="ArrowDown"||l.key==="S"&&!to(l,"S"))break;l.preventDefault();const y=h<p.length-1?h+1:h===-1?0:-1;if(y!==-1){const b=Gs(p,y);b!==null&&Ks(b)}g=!0;break}case"ArrowLeft":case"A":{if(l.shiftKey&&l.key==="ArrowLeft"||l.key==="A"&&!to(l,"A")||m===null)break;if(l.preventDefault(),Na(m)==="collapse")m.click();else if(h>0){const b=Gs(p,h-1);b!==null&&Ks(b)}g=!0;break}case"ArrowRight":case"D":{if(l.shiftKey&&l.key==="ArrowRight"||l.key==="D"&&!to(l,"D")||m===null)break;if(l.preventDefault(),Na(m)==="expand")m.click();else if(h<p.length-1){const b=Gs(p,h+1);b!==null&&Ks(b)}g=!0;break}case" ":{if(m===null)break;l.preventDefault(),Na(m)!==null&&m.click(),g=!0;break}}g&&l.stopPropagation()};return document.addEventListener("keydown",a,{capture:!0}),()=>document.removeEventListener("keydown",a,{capture:!0})},[e,o,r]),c.useEffect(()=>(document.addEventListener("focusin",i),()=>document.removeEventListener("focusin",i)),[i])}const RA={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},IA={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},PA={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},Ca=12,no=1,Zd=80,Kd=24;function MA(e){return e.length<=Kd?e:`${e.slice(0,Kd-3)}...`}function AA(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Zd?t:`${t.slice(0,Zd)}...`}function so(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const OA=c.memo(function({segments:t,totalTokens:n,showLabels:r=!0,onActivate:o}){const i=c.useMemo(()=>n>0?n:t.reduce((b,w)=>b+w.size,0),[t,n]),a=t.slice(0,Ca),l=t.slice(Ca),u=l.reduce((b,w)=>b+w.size,0),d=l.length,f=Ca,p=f+d-1,m=d>0,h=o!==void 0,g=c.useMemo(()=>a.reduce((b,w)=>b+w.size,0),[a]),y=c.useMemo(()=>`Request context: ~${Pe(i)} tokens across ${t.length} segment${t.length===1?"":"s"}`,[t.length,i]);return t.length===0||i<=0?s.jsx("div",{role:"img","aria-label":y,className:"h-6"}):s.jsx(Ds,{delayDuration:150,children:s.jsxs("div",{role:"img","aria-label":y,className:"flex flex-col gap-1.5",children:[s.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[a.map((b,w)=>{const v=i>0?b.size/i*100:0,j=Math.max(no,v),k=L("h-full border-r border-background/80 last:border-r-0",h?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",IA[b.role],h?PA[b.role]:""),S={width:`${j}%`},_=`${b.label}, ${so(v)}, ~${Pe(b.size)} tokens`;return s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:h?s.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>o(b),onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(b))},"data-anatomy-path":b.path,"aria-label":_,className:k,style:S}):s.jsx("span",{"aria-label":_,className:k,style:S})}),s.jsxs(pt,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[s.jsxs("div",{className:"font-semibold",children:[b.label," - ",so(v)," - ~",Pe(b.size)," ","tokens"]}),s.jsx("div",{className:"text-muted-foreground",children:RA[b.role]}),s.jsxs("div",{className:"text-muted-foreground",children:[b.characters.toLocaleString()," chars"]}),b.text.length>0&&s.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:AA(b.text)})]})]},`${b.path}-${w}`)}),m&&s.jsxs(dt,{children:[s.jsx(ft,{asChild:!0,children:s.jsxs("div",{role:"img","aria-label":`${d} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max(no,u/i*100)}%`},children:["... +",d]})}),s.jsxs(pt,{side:"bottom",className:"text-xs",children:[d," more segment",d===1?"":"s"," (indices"," ",f,"-",p,")"]})]})]}),r&&s.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[a.map((b,w)=>{const v=i>0?b.size/i*100:0,j=Math.max(no,v);return s.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${b.label} - ${so(v)} - ~${Pe(b.size)} tokens`,children:[s.jsx("span",{className:"truncate font-mono text-foreground/80",children:MA(b.label)}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[so(v)," - ~",Pe(b.size)]})]},`label-${b.path}-${w}`)}),m&&s.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(no,u/i*100)}%`},children:[s.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",d]}),s.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Pe(u)]})]})]}),g<i*.1&&s.jsx("div",{className:"h-0"})]})})}),xx=.75,bx=.9,hl=8e3,zA=.35,vx=40,yx=160,LA=5,$A=8,DA=18,FA=6e4,UA=.7,Gd=3e3,BA=.3,Jd=160,qA=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),HA=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],VA=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],WA=[{family:"OpenAI GPT-4.1",tokens:1047576,mode:"prefix",patterns:["gpt-4.1"]},{family:"OpenAI GPT-4o",tokens:128e3,mode:"prefix",patterns:["gpt-4o"]},{family:"OpenAI o-series",tokens:128e3,mode:"prefix",patterns:["o1","o3","o4"]},{family:"Anthropic Claude",tokens:2e5,mode:"prefix",patterns:["claude-"]},{family:"DeepSeek V4",tokens:1048576,mode:"prefix",patterns:["deepseek-v4-pro","deepseek-v4-flash"]},{family:"DeepSeek",tokens:64e3,mode:"prefix",patterns:["deepseek-"]},{family:"MiniMax M3",tokens:1048576,mode:"includes",patterns:["minimax-m3"]},{family:"MiniMax M2.7",tokens:204800,mode:"includes",patterns:["minimax-m2.7"]},{family:"MiniMax M2.5/M2.1",tokens:196608,mode:"includes",patterns:["minimax-m2.5","minimax-m2.1"]},{family:"GLM-5.2",tokens:1048576,mode:"prefix",patterns:["glm-5.2"]},{family:"GLM-5",tokens:202752,mode:"prefix",patterns:["glm-5","glm-5.1"]}],ZA={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function KA(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}return null}function wx(e,t){for(const n of t){const r=KA(Q(e,n));if(r!==null)return r}return null}function GA(e){const t=Q(e,"model");if(typeof t!="string")return null;const n=t.trim();return n===""?null:n}function JA(e,t){switch(t.mode){case"prefix":return t.patterns.some(n=>e.startsWith(n));case"includes":return t.patterns.some(n=>e.includes(n))}}function YA(e,t,n=[]){const r=wx(t,HA);if(r!==null)return{tokens:r,label:"Request metadata",source:"request"};const o=XI(e,n);if(o!==null)return{tokens:o.tokens,label:`${o.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const i=e.trim().toLowerCase().replace(/\s+/g,"-");for(const a of WA)if(JA(i,a))return{tokens:a.tokens,label:`${a.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function XA(e){return e<0?0:e>1?1:e}function QA(e){return e===null?"unknown":e>=bx?"danger":e>=xx?"watch":"ok"}function eO(e,t){return e.filter(n=>n.role===t).reduce((n,r)=>n+r.size,0)}function tO(e,t){return["system","user","assistant","tool","tools"].map(r=>{const o=eO(e,r);return{role:r,label:ZA[r],tokens:o,percent:t>0?o/t:0}}).filter(r=>r.tokens>0).sort((r,o)=>o.tokens-r.tokens)}function gl(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function nO(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Jd?t:`${t.slice(0,Jd-3)}...`}function sO(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function rO(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function oO(e){const t=e.trim();return t.startsWith("{")||t.startsWith("[")}function iO(e){if(!oO(e))return null;try{return JSON.parse(e)}catch{return null}}function aO(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function lO(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t]??"";if(!(n.startsWith("[")&&n.endsWith("]")))return n}return null}function cO(e){const t=lO(e);return t===null?!1:qA.has(aO(t))}function uO(e){return e.map(t=>t.startsWith("[")?t:`.${t}`).join("").replace(/^\./,"")}function dO(e,t,n){const r=wc(t);if(r<yx)return null;const o=yc(t);return o<vx?null:{role:e.role,label:`${e.label} ${uO(n)}`,path:e.path,tokens:o,characters:r,text:t}}function xl({value:e,segment:t,path:n,depth:r,candidates:o}){if(!(o.length>=$A)&&!(r>LA)){if(typeof e=="string"){if(!cO(n))return;const i=dO(t,e,n);i!==null&&o.push(i);return}if(Array.isArray(e)){e.forEach((i,a)=>xl({value:i,segment:t,path:[...n,`[${String(a)}]`],depth:r+1,candidates:o}));return}jc(e)&&Object.entries(e).forEach(([i,a])=>xl({value:a,segment:t,path:[...n,i],depth:r+1,candidates:o}))}}function fO(e){const t=rO(e),n=iO(e.text);if(n===null)return[t];const r=[];xl({value:n,segment:e,path:[],depth:0,candidates:r});const o=gl(e.text),i=new Set([o]),a=r.filter(l=>{const u=gl(l.text);return u===""||i.has(u)?!1:(i.add(u),!0)});return[t,...a]}function pO(e){const t=new Map;for(const r of e){const o=fO(r);for(const i of o){if(i.tokens<vx||i.characters<yx)continue;const a=gl(i.text);if(a==="")continue;const l=t.get(a);if(l===void 0){t.set(a,{tokens:i.tokens,candidates:[i]});continue}t.set(a,{tokens:l.tokens+i.tokens,candidates:[...l.candidates,i]})}}const n=[];for(const r of t.values()){if(r.candidates.length<2)continue;const o=r.candidates[0]??null;if(o===null)continue;const i=r.tokens-o.tokens;n.push({key:`${o.path}:${o.label}:${String(r.candidates.length)}:${String(r.tokens)}`,count:r.candidates.length,totalTokens:r.tokens,repeatedTokens:i,preview:nO(o.text),firstLabel:o.label,segments:r.candidates.map(sO)})}return n.sort((r,o)=>o.repeatedTokens-r.repeatedTokens||o.totalTokens-r.totalTokens)}function mO(e){if(e.length===0)return null;const t=e.length,n=e.reduce((o,i)=>o+i.count,0),r=e.reduce((o,i)=>o+i.repeatedTokens,0);return{kind:"duplicate",severity:r>=hl?"danger":"watch",title:"Duplicate context",detail:`${String(n)} repeated blocks across ${String(t)} group${t===1?"":"s"}, ~${String(r)} repeated tokens.`}}function hO(e){return e.reduce((t,n)=>t+n.repeatedTokens,0)}function gO(e,t,n){const r=[],o=e.find(u=>u.role==="tools")??null;o!==null&&(o.tokens>=hl||o.percent>=zA&&o.tokens>=Gd)&&r.push({kind:"tool-schema",severity:o.tokens>=hl?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(o.percent*100)}% of request context.`});const i=e.find(u=>u.role==="system")??null;i!==null&&i.tokens>=Gd&&i.percent>=BA&&r.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(i.percent*100)}% of request context.`});const a=e.filter(u=>u.role==="user"||u.role==="assistant"||u.role==="tool").reduce((u,d)=>u+d.tokens,0),l=t>0?a/t:0;return n>=DA&&(a>=FA||l>=UA)&&r.push({kind:"history-bloat",severity:l>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(n)} message blocks take ${Math.round(l*100)}% of request context.`}),r}function xO({risk:e,contextWindow:t,diagnostics:n,duplicateGroups:r}){let i=new Set(n.map(u=>u.kind)).size;(e==="watch"||e==="danger")&&(i+=1),t.source==="unknown"&&(i+=1);const a=n.some(u=>u.severity==="danger");return{level:e==="danger"||a?"risk":i>0?"optimizable":"ok",opportunityCount:i,reclaimableTokens:hO(r)}}function bO({segments:e,inputTokens:t,parsed:n,model:r,providers:o=[]}){const i=e.reduce((_,C)=>_+C.size,0),a=r??GA(n),l=t??i,u=wx(n,VA),d=YA(a,n,o),f=u??0,p=d.tokens===null?null:l+f,m=d.tokens===null?null:d.tokens-l,h=d.tokens===null?null:d.tokens-l-f,g=d.tokens===null||p===null?null:XA(p/d.tokens),y=tO(e,i),b=y[0]??null,w=e.filter(_=>_.role!=="tools").length,v=pO(e),j=mO(v),k=gO(y,i,w);j!==null&&k.unshift(j);const S=QA(g);return{model:a,contextWindow:d,estimatedInputTokens:l,outputReserveTokens:u,windowUsedTokens:p,remainingInputTokens:m,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:S,roleUsages:y,largestRole:b,diagnostics:k,duplicateGroups:v,health:xO({risk:S,contextWindow:d,diagnostics:k,duplicateGroups:v})}}const E6={watch:xx,danger:bx},Yd=new WeakMap;function vO(e){return e.map(t=>{const n=t.modelMetadata?.map(r=>`${r.model}:${String(r.contextWindow??"")}`).join(",")??"";return`${t.id}:${t.updatedAt}:${t.models.join(",")}:${n}`}).join("|")}function yO(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function wO(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function jO(e,t){const n=yO(e.rawRequestBody);if(n===null)return null;const o=mg(ur(e)).anatomySegments(n);if(o===null)return null;const i=bO({segments:o,inputTokens:e.inputTokens??null,parsed:n,model:e.model,providers:t}),a=i.model??e.model??"Unknown model",l=i.roleUsages.map(wO);return{logId:e.id,model:a,timestamp:e.timestamp,contextWindow:i.contextWindow,estimatedInputTokens:i.estimatedInputTokens,windowUsedTokens:i.windowUsedTokens,usagePercent:i.usagePercent,riskLevel:i.riskLevel,health:i.health,diagnostics:i.diagnostics.map(u=>u.title),roleSegments:l,roleTotalTokens:l.reduce((u,d)=>u+d.size,0)}}function kO(e,t,n){const r=Yd.get(e);if(r!==void 0&&r.id===e.id&&r.rawRequestBody===e.rawRequestBody&&r.inputTokens===e.inputTokens&&r.model===e.model&&r.path===e.path&&r.apiFormat===e.apiFormat&&r.timestamp===e.timestamp&&r.providersSignature===n)return r.snapshot;const o=jO(e,t);return Yd.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:n,snapshot:o}),o}function SO(e,t){return e.usagePercent!==null&&t.usagePercent!==null?e.usagePercent>t.usagePercent:e.usagePercent!==null&&t.usagePercent===null?!0:e.usagePercent===null&&t.usagePercent!==null?!1:e.estimatedInputTokens>t.estimatedInputTokens}function Xd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function _O(e,t){const n=Xd(t.latest.riskLevel)-Xd(e.latest.riskLevel);if(n!==0)return n;const r=e.peak.usagePercent??-1,i=(t.peak.usagePercent??-1)-r;return i!==0?i:t.latest.logId-e.latest.logId}function NO(e,t){return e.usagePercent===null||t.usagePercent===null?null:(t.usagePercent-e.usagePercent)*100}function CO(e){for(let t=1;t<e.length;t++){const n=e[t-1],r=e[t];if(!(n===void 0||r===void 0)&&n.id>r.id)return[...e].sort((o,i)=>o.id-i.id)}return e}function TO(e,t=[]){const n=CO(e),r=vO(t),o=new Map;for(const a of n){const l=kO(a,t,r);if(l===null)continue;const u=o.get(l.model);if(u===void 0){o.set(l.model,{model:l.model,requestCount:1,first:l,latest:l,peak:l});continue}o.set(l.model,{model:u.model,requestCount:u.requestCount+1,first:u.first,latest:l,peak:SO(l,u.peak)?l:u.peak})}return{models:[...o.values()].map(a=>({model:a.model,requestCount:a.requestCount,first:a.first,latest:a.latest,peak:a.peak,trendPercent:NO(a.first,a.latest)})).sort(_O)}}function Bn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function EO(e){const t=new Map;for(const n of e)for(let r=0;r<n.logs.length;r+=1){const o=n.logs[r];o!==void 0&&t.set(o.id,r+1)}return t}function Qd(e,t){return t.get(e.id)??e.id}function ef(e){let t=0,n=0;for(const r of e)r.inputTokens!==null&&(t+=r.inputTokens),r.outputTokens!==null&&(n+=r.outputTokens);return{totalIn:t,totalOut:n}}function RO(e){for(const t of e)if(t.userAgent!==null&&t.userAgent!==void 0&&t.userAgent!=="")return t.userAgent;return null}function IO(e,t){const n=e[0],r=e[e.length-1];return n===void 0||r===void 0?null:oi(n.timestamp,r.timestamp,t)}function PO(e){switch(e){case"cool":return"text-status-cool";case"danger":return"text-status-danger";case"watch":return"text-status-watch";case"neutral":return"text-foreground"}}function MO(e){switch(e){case"rolling":return s.jsx(Pt,{className:"size-3 text-status-cool"});case"failed":return s.jsx(Co,{className:"size-3 text-status-danger"});case"watch":return s.jsx(Ip,{className:"size-3 text-status-watch"});case"clear":return s.jsx(qe,{className:"size-3 text-status-success"})}}function AO(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function OO(e){return e.pending>0?`${e.pending} pending / ${e.failures} failed`:e.lengthStops>0?`${e.lengthStops} output limit / ${e.failures} failed`:`${e.failures} failed / ${e.slow} slow`}function fs({label:e,value:t,detail:n,icon:r,tone:o="neutral"}){return s.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[r,e]}),s.jsx("div",{className:L("mt-2 font-mono text-sm font-semibold",PO(o)),children:t}),s.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:n})]})}function zO({stats:e}){return e.requests===0?null:s.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[s.jsx("div",{className:"px-4 py-3",children:s.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[s.jsx(Ow,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),s.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),s.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),s.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[s.jsx(fs,{label:"Status",value:e.statusLabel,detail:OO(e),icon:MO(e.status),tone:AO(e.status)}),s.jsx(fs,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:s.jsx(dj,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),s.jsx(fs,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:s.jsx(Co,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),s.jsx(fs,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:s.jsx(Ip,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),s.jsx(fs,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:s.jsx(Hl,{className:"size-3 text-muted-foreground"})}),s.jsx(fs,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function nr(e){if(e===null)return"Unknown";const t=e*100;return t>=10?`${t.toFixed(0)}%`:t>=1?`${t.toFixed(1)}%`:t>0?"<1%":"0%"}function LO(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function bl(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function $O(e,t){if(t===null)return null;const n=bl(e),r=bl(t);return r<=0||Math.abs(r-n)<.5?null:r}function DO(e){switch(e){case"danger":return"bg-red-400";case"watch":return"bg-amber-300";case"unknown":return"bg-muted-foreground/50";case"ok":return"bg-cyan-300"}}function FO(e){const t=e.latest.contextWindow.tokens;return t===null?"Context window unknown":`Context window ${ff(t)}`}const UO=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function jx(e){return typeof e=="string"?e.length>0?e:null:typeof e=="number"||typeof e=="boolean"?String(e):e===null?null:JSON.stringify(e)}function Ta(e,t){if(e===null)return null;const n=e.metadata[t];return n===void 0?null:jx(n)}function BO(e){const t=e.toLowerCase();return t.includes("reject")||t.includes("fail")||t.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":t.includes("partial")||t.includes("pending")||t.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":t.includes("pass")||t.includes("complete")||t.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function qO(e){const t=[];for(const n of UO){const r=e.metadata[n];if(r===void 0)continue;const o=jx(r);o!==null&&t.push({key:n,value:o})}return t}function tf({memberships:e,defaultOpen:t=!1}){const[n,r]=c.useState(t);if(e.length===0)return null;const o=e[0],i=o?.member??null,a=Ta(i,"score"),l=Ta(i,"decision"),u=Ta(i,"final_status"),d=[a===null?null:{label:`score ${a}`,value:a},l===null?null:{label:l,value:l},u===null?null:{label:u,value:u},i?.model===null||i?.model===void 0?null:{label:i.model,value:i.model}].filter(f=>f!==null&&f.label.length>0&&f.value.length>0);return s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[s.jsxs("button",{type:"button",onClick:()=>r(f=>!f),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":n,children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),o!==void 0&&s.jsx("span",{className:"truncate text-muted-foreground",title:o.groupTitle,children:o.groupTitle}),s.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),d.length>0&&s.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:d.slice(0,4).map(f=>s.jsx("span",{className:L("rounded border px-1.5 py-0.5 font-mono text-[10px]",BO(f.value)),children:f.label},f.label))})]}),n?s.jsx(Bl,{className:"size-4 shrink-0 text-muted-foreground"}):s.jsx(et,{className:"size-4 shrink-0 text-muted-foreground"})]}),n&&s.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(f=>{const p=f.member,m=qO(p);return s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:"truncate font-medium text-foreground",title:f.groupTitle,children:f.groupTitle}),s.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:f.groupStatus}),p.status!==null&&s.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsx("span",{className:"font-mono",title:p.sessionId,children:Bn(p.sessionId)}),p.label!==null&&s.jsx("span",{children:p.label}),p.provider!==null&&s.jsx("span",{children:p.provider}),p.model!==null&&s.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&s.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",Bn(p.runId)]})]}),m.length>0&&s.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:m.map(h=>s.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[s.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),s.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${f.groupId}:${p.id}`)})})]})}function ro({label:e,title:t,icon:n,disabled:r,onClick:o}){return s.jsxs("button",{type:"button",onClick:o,disabled:r,className:"border border-input bg-background hover:bg-accent hover:text-accent-foreground inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-45",title:t,children:[n,s.jsx("span",{children:e})]})}function nf({logs:e,pagination:t,embedded:n=!1}){if(t===void 0)return null;const r=t.isLoading;return s.jsxs("nav",{"aria-label":"Session log pagination",className:L("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",n?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[s.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[s.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[$R({logs:e,pagination:t}),t.isLoading&&e.length>0&&s.jsx("span",{className:"ml-2",children:"Loading..."})]}),t.loadProgress!==void 0&&s.jsx(ho,{progress:t.loadProgress})]}),s.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[s.jsx(ro,{label:"Oldest",title:"Load the oldest logs in this session",icon:s.jsx(ww,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOldest}),s.jsx(ro,{label:"Older",title:"Load older logs",icon:s.jsx(hw,{className:"size-3.5"}),disabled:r||!t.hasOlder,onClick:t.onOlder}),s.jsx(ro,{label:"Newer",title:"Load newer logs",icon:s.jsx(bt,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewer}),s.jsx(ro,{label:"Newest",title:"Load the newest logs in this session",icon:s.jsx(kw,{className:"size-3.5"}),disabled:r||!t.hasNewer,onClick:t.onNewest})]})]})}function HO(e){return`${e} ${e===1?"request":"requests"}`}function sf(e){return`#${String(e)}`}function rf(e){switch(e){case"danger":return"text-red-300";case"watch":return"text-amber-200";case"unknown":return"text-muted-foreground";case"ok":return"text-cyan-200"}}function VO(e){switch(e){case"risk":return"border-red-400/30 bg-red-500/10 text-red-100";case"optimizable":return"border-amber-400/25 bg-amber-400/8 text-amber-100";case"ok":return"border-cyan-300/25 bg-cyan-400/8 text-cyan-100"}}function WO(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const ZO=10,KO=80;function GO(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function JO(e){const t=document.getElementById(`log-${String(e)}`);return t instanceof HTMLElement?(t.scrollIntoView({block:"center",behavior:cx(ux())}),t.focus({preventScroll:!0}),GO(t),!0):!1}function kx(e){Ms({logId:e,tab:"anatomy"});let t=0;const n=()=>{Ms({logId:e,tab:"anatomy"}),!JO(e)&&(t+=1,t<ZO&&window.setTimeout(n,KO))};window.setTimeout(n,0)}function Js({command:e}){const[t,n]=c.useState(!1),r=c.useCallback(()=>{It(e).then(o=>{o&&(n(!0),setTimeout(()=>n(!1),2e3))})},[e]);return s.jsxs("div",{"data-command-example":"true",className:wR,children:[s.jsx("pre",{className:jR,children:e}),s.jsx("button",{type:"button",onClick:r,className:"shrink-0 cursor-pointer rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none","aria-label":"Copy command",children:t?s.jsx(qe,{className:"size-4"}):s.jsx(zt,{className:"size-4"})})]})}function Ea({label:e,children:t,className:n}){return s.jsxs("section",{className:L("rounded-[8px] border border-border/60 bg-card/55",n),children:[s.jsx("div",{className:"px-3 pt-3",children:s.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),s.jsx("div",{className:"p-3 pt-2",children:t})]})}function oo({label:e,value:t}){return s.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[s.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:t}),s.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function YO(){const{themeMode:e,setThemeMode:t}=Xk();return s.jsxs("div",{className:"inline-flex h-9 items-center rounded-md border border-border/70 bg-muted/70 p-0.5","aria-label":"Theme mode",role:"group",children:[s.jsx("button",{type:"button",onClick:()=>t("light"),className:L("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="light"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use light mode","aria-pressed":e==="light",title:"Light mode",children:s.jsx(wk,{className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:()=>t("eye-care"),className:L("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="eye-care"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use eye care mode","aria-pressed":e==="eye-care",title:"Eye care mode",children:s.jsx(kp,{className:"size-3.5"})}),s.jsx("button",{type:"button",onClick:()=>t("dark"),className:L("inline-flex size-8 items-center justify-center rounded-[6px] text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-lg:size-11",e==="dark"&&"bg-background text-foreground shadow-sm"),"aria-label":"Use dark mode","aria-pressed":e==="dark",title:"Dark mode",children:s.jsx(Oj,{className:"size-3.5"})})]})}function XO({visible:e,onToggle:t}){const n=e?"Hide Inspector pet":"Summon Inspector pet";return s.jsx("button",{type:"button",onClick:t,className:L("border-border/70 bg-muted/70 inline-flex size-8 shrink-0 items-center justify-center rounded-md border text-muted-foreground shadow-sm transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",e&&"bg-background text-amber-500 shadow-sm"),"aria-label":n,"aria-pressed":e,title:n,children:s.jsx(mf,{className:L("size-4 transition-opacity",!e&&"opacity-45")})})}function QO({preference:e,resolvedScale:t,onChange:n}){const r=Xx(t),o=e==="auto"?`Auto (${r})`:`${e}%`;return s.jsxs(pr,{value:e,onValueChange:i=>n(cf(i)),children:[s.jsxs(mr,{size:"sm",className:"h-9 min-w-[4.5rem] justify-center gap-1 border-border/70 bg-muted/70 px-2 py-0 text-muted-foreground hover:bg-muted max-lg:h-11 [&>svg:last-child]:hidden","aria-label":`Interface size: ${o}`,children:[s.jsx(Vy,{className:"size-3.5"}),s.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:r})]}),s.jsxs(hr,{align:"end",children:[s.jsx(lt,{value:"auto",children:"Auto"}),s.jsx(lt,{value:"100",children:"100%"}),s.jsx(lt,{value:"125",children:"125%"}),s.jsx(lt,{value:"150",children:"150%"})]})]})}const Sx="agent-inspector.detailsPanelCollapsed",_x="agent-inspector.detailsPanelWidth",Nx="agent-inspector.pet.visible",xs=360,e6=288,t6=520;function Cx(e){return Math.min(Math.max(e,e6),t6)}function n6(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(Sx);return e===null||e==="1"}catch{return!0}}function s6(){if(typeof window>"u")return xs;try{const e=window.localStorage.getItem(_x);if(e===null)return xs;const t=Number.parseInt(e,10);return Number.isFinite(t)?Cx(t):xs}catch{return xs}}function r6(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(Nx)!=="0"}catch{return!0}}function of({label:e,logId:t}){return s.jsxs("button",{type:"button",onClick:()=>kx(t),className:"inline-flex h-5 items-center rounded px-1 font-mono text-[10px] text-muted-foreground transition-colors hover:bg-white/[0.06] hover:text-foreground",title:`Open Context for ${sf(t)}`,children:[e," ",sf(t)]})}function o6({latestPercent:e,peakPercent:t,risk:n,onOpenContext:r}){const o=bl(e),i=$O(e,t),a=t===null?`Latest context window usage ${nr(e)}`:`Latest context window usage ${nr(e)}, peak ${nr(t)}`;return s.jsx("button",{type:"button",onClick:r,className:"group block w-full rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","aria-label":`${a}. Open latest Context details`,title:"Open latest Context details",children:s.jsxs("span",{className:"relative block h-2.5 overflow-hidden rounded-full border border-white/10 bg-black/25 transition-colors group-hover:border-cyan-200/35",role:"meter","aria-label":a,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(o),children:[s.jsx("span",{className:L("block h-full rounded-full transition-[width]",DO(n)),style:{width:`${o}%`}}),i!==null&&s.jsx("span",{className:"absolute top-0 h-full w-0.5 rounded-full bg-amber-100/75 shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${i}% - 0.5px)`},"aria-hidden":"true"})]})})}function i6({summary:e}){const t=e.trendPercent,n=t===null||Math.abs(t)<.1?null:t>0?tw:Gy,r=e.latest.diagnostics[0]??null,o=nr(e.latest.usagePercent),i=nr(e.peak.usagePercent),a=()=>{kx(e.latest.logId)};return s.jsxs("div",{className:"grid gap-x-4 gap-y-2 border-t border-white/10 py-2 first:border-t-0 lg:grid-cols-[minmax(180px,1fr)_minmax(260px,1fr)_minmax(260px,1.4fr)]",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("button",{type:"button",onClick:a,className:"min-w-0 truncate rounded-sm text-left font-mono font-semibold text-foreground transition-colors hover:text-text-link focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",title:`Open latest Context for ${e.model}`,children:e.model}),s.jsx("span",{className:L("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",VO(e.latest.health.level)),children:WO(e.latest.health.level)})]}),s.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsx("span",{children:HO(e.requestCount)}),s.jsx("span",{children:FO(e)})]})]}),s.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[s.jsx(o6,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:a}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),s.jsx("div",{className:L("mt-0.5 font-mono",rf(e.latest.riskLevel)),children:o}),s.jsx(of,{label:"Log",logId:e.latest.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),s.jsx("div",{className:L("mt-0.5 font-mono",rf(e.peak.riskLevel)),children:i}),s.jsx(of,{label:"Log",logId:e.peak.logId})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),s.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[n!==null&&s.jsx(n,{className:L("size-3",t!==null&&t>0?"text-amber-300":"text-cyan-300")}),LO(t)]}),s.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[s.jsx(OA,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[s.jsxs("span",{className:"font-mono",children:["~",Pe(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&s.jsxs("span",{className:"font-mono",children:["~",Pe(e.latest.windowUsedTokens)," used"]}),r!==null&&s.jsx("span",{className:"truncate",children:r})]})]})]})}function a6({summary:e}){return e.models.length===0?null:s.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),s.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),s.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(t=>s.jsx(i6,{summary:t},t.model))})]})}function l6(e){const t=e.models.filter(r=>r.latest.health.level==="risk").length;if(t>0)return`${t} risk`;const n=e.models.filter(r=>r.latest.health.level==="optimizable").length;return n>0?`${n} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function c6({label:e,logs:t,totalIn:n,totalOut:r,timeDisplayFormat:o,contextSummary:i,showBackLink:a}){const[l,u]=c.useState(!1),[d,f]=c.useState(!1),p=c.useMemo(()=>IO(t,o),[t,o]),m=c.useMemo(()=>RO(t),[t]),h=c.useMemo(()=>l6(i),[i]),g=c.useCallback(()=>{It(window.location.href).then(y=>{y&&(u(!0),setTimeout(()=>u(!1),2e3))})},[]);return s.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a&&s.jsx("a",{href:"/",className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":"Back to all sessions",title:"Back to all sessions",children:s.jsx(Qy,{className:"size-3.5"})}),s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:Bn(e)}),m!==null&&s.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:m,children:m})]}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[s.jsxs("span",{children:[t.length," request",t.length!==1?"s":""]}),p!==null&&s.jsx("span",{children:p}),(n>0||r>0)&&s.jsxs("span",{className:"font-mono",children:[Pe(n)," in / ",Pe(r)," out"]})]})]}),i.models.length>0&&s.jsxs("button",{type:"button",onClick:()=>f(y=>!y),className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-2.5 font-mono text-[11px] text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-expanded":d,title:d?"Hide context details":"Show context details",children:[s.jsx("span",{children:h}),d?s.jsx(Bl,{className:"size-3.5"}):s.jsx(et,{className:"size-3.5"})]}),s.jsx("button",{type:"button",onClick:g,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground","aria-label":l?"Copied session link":"Copy session link",title:l?"Copied session link":"Copy session link",children:l?s.jsx(qe,{className:"size-3.5"}):s.jsx(zt,{className:"size-3.5"})})]}),d&&s.jsx(a6,{summary:i})]})}function u6({logs:e,sessions:t,selectedSession:n,selectedModel:r,onSessionChange:o,onClearAll:i,onDeleteCurrentView:a,onReloadSession:l,onClearGroup:u,onNotify:d,onImportLogs:f,viewMode:p,captureMode:m,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:y,isLoading:b=!1,liveConnection:w,onRetryLiveConnection:v,onStopLiveConnection:j,pagination:k,sessionLoadProgress:S,sessionLoadError:_,sessionMemberships:C=[],hideSessionFilter:M=!1,pinnedSessionId:A}){const{totalIn:I,totalOut:N}=c.useMemo(()=>ef(e),[e]),{providers:P}=Wl(),{uiScalePreference:$,resolvedUiScale:F,setUiScalePreference:G}=Qk(),[X,U]=c.useState(null),[V,Y]=c.useState(null),[B,W]=c.useState(!1),[me,ve]=c.useState(!1),[we,D]=c.useState(null),[ie,te]=c.useState(null),[_e,Ne]=c.useState(!1),[ce,de]=c.useState(!1),[he,je]=c.useState(!0),[Ce,Fe]=c.useState(xs),[Ze,Ue]=c.useState(!1),[ut,Qt]=c.useState(!1),[yt,Ke]=c.useState(!0),[Ae,Be]=c.useState(!1),[q,ne]=c.useState(null),[ke,ge]=c.useState(null),Se=c.useRef(null),Je=c.useRef(null),J=c.useRef(null),T=c.useRef(null),z=c.useRef(0),Z=c.useRef(null);EA(Se,Je,{pageWide:!0});const re=c.useMemo(()=>{const ye=typeof window>"u"?"http://localhost:9527":window.location.origin;return zp(ye,pf())},[]),ae=c.useCallback(()=>{z.current+=1,T.current?.abort(),T.current=null,U(null),Y(null)},[]);c.useEffect(()=>()=>{z.current+=1,T.current?.abort(),T.current=null},[]),c.useEffect(()=>{je(n6()),Fe(s6()),Qt(!0)},[]),c.useEffect(()=>{ut&&window.localStorage.setItem(Sx,he?"1":"0")},[he,ut]),c.useEffect(()=>{if(ut)try{window.localStorage.setItem(_x,String(Ce))}catch{}},[ut,Ce]),c.useEffect(()=>{Ke(r6()),Be(!0)},[]),c.useEffect(()=>{if(Ae)try{window.localStorage.setItem(Nx,yt?"1":"0")}catch{}},[Ae,yt]),c.useEffect(()=>{if(A===void 0){document.title="Agent Inspector";return}const ye=e.length===1?"1 req":`${e.length} req`;document.title=`${Bn(A)} - ${ye} - Agent Inspector`},[e.length,A]);const se=c.useCallback(async ye=>{T.current?.abort();const Ye=new AbortController;T.current=Ye;const Tt=z.current+1;z.current=Tt,U(ye),Y(null);try{const tn=await Yk(e,ye,{signal:Ye.signal});if(z.current!==Tt)return;if(!tn.ok){if(tn.canceled===!0)return;d!==void 0?d({message:tn.message,tone:"error"}):Y(tn.message)}}finally{z.current===Tt&&(T.current=null,U(null))}},[e,d]),be=c.useCallback(ye=>{if(SR(ye)){W(!0);return}se(ye)},[se]),ue=c.useCallback(()=>{W(!1),se("redacted")},[se]),Ct=c.useCallback(()=>{W(!1),se("raw")},[se]),Pn=c.useCallback(()=>{J.current?.click()},[]),Me=c.useCallback(ye=>{const Ye=ye.currentTarget.files?.[0];ye.currentTarget.value="",!(Ye===void 0||f===void 0)&&(ve(!0),te(null),D(null),f(Ye).then(Tt=>{const tn=Tt.skipped>0?`, skipped ${String(Tt.skipped)}`:"",Uc=`Imported ${String(Tt.imported)} logs as ${Tt.sessionId}${tn}.`;d!==void 0?d({message:Uc,tone:"success"}):D(Uc)}).catch(Tt=>{const tn=Tt instanceof Error?Tt.message:"Failed to import logs";d!==void 0?d({message:tn,tone:"error"}):te(tn)}).finally(()=>{ve(!1)}))},[f,d]);c.useEffect(()=>{ae(),ge(null),ne(null)},[ae,n,r]);const en=c.useCallback(()=>{ae(),D(null),te(null),ge(null),i()},[ae,i]),wt=c.useCallback(()=>{Ne(!0)},[]),Fs=c.useCallback(()=>{ae(),D(null),te(null),ge(null),a!==void 0&&(de(!0),a().then(()=>{Ne(!1)}).catch(ye=>{const Ye=ye instanceof Error?ye.message:"Failed to delete stored logs";d!==void 0?d({message:Ye,tone:"error"}):te(Ye)}).finally(()=>{de(!1)}))},[ae,a,d]),rt=c.useCallback(()=>{l!==void 0&&(ae(),D(null),te(null),ge(null),l())},[ae,l]),Us=c.useCallback(()=>{ge(null)},[]),Mc=c.useCallback(()=>{je(ye=>!ye)},[]),Ex=c.useCallback(ye=>{Z.current={startX:ye.clientX,startWidth:Ce,pointerId:ye.pointerId},ye.currentTarget.setPointerCapture(ye.pointerId),Ue(!0)},[Ce]),Rx=c.useCallback(ye=>{const Ye=Z.current;Ye===null||Ye.pointerId!==ye.pointerId||Fe(Cx(Ye.startWidth+Ye.startX-ye.clientX))},[]),Ac=c.useCallback(ye=>{const Ye=Z.current;Ye===null||Ye.pointerId!==ye.pointerId||(ye.currentTarget.hasPointerCapture(ye.pointerId)&&ye.currentTarget.releasePointerCapture(ye.pointerId),Z.current=null,Ue(!1))},[]),Ix=c.useCallback(()=>{Fe(xs)},[]),Px=c.useCallback(()=>{Ke(ye=>!ye)},[]),Mi=c.useMemo(()=>q===null?null:new Set(q.logIds),[q]),Mn=c.useMemo(()=>Mi===null?e:e.filter(ye=>Mi.has(ye.id)),[Mi,e]),$t=c.useMemo(()=>TT(Mn),[Mn]),Oc=c.useMemo(()=>EO($t),[$t]),An=c.useMemo(()=>LR({pinnedSessionId:A,selectedSession:n,sessions:t,logs:e}),[e,A,n,t]),ts=An?.logs??[],Bs=An!==null&&ts.length>0,{totalIn:zc,totalOut:Lc}=c.useMemo(()=>ef(ts),[ts]),Mx=c.useMemo(()=>TO(ts,P),[ts,P]),Ax=c.useMemo(()=>eA($t),[$t]),Ai=c.useMemo(()=>EE($t),[$t]),$c=_R(m,e.length),Ox=A!==void 0,zx=e.length>0,Lx=a!==void 0&&(e.length>0||n!=="__all__"),$x=n==="__all__"?"all sessions":"this session",Dx=n==="__all__"?"Deletes every stored log, streaming chunk, and session archive entry across all sessions.":"Deletes every stored log, streaming chunk, and session archive entry for this session, including history that is not currently loaded.",Fx=e.length===0?"Load":"Reload",Oi=Bs&&An!==null?Bn(An.label):n==="__all__"?"All sessions":Bn(n),Dc=aA(w),zi=lA(Dc),Ux=c.useMemo(()=>zR({logs:Mn,conversationGroups:$t,isLoading:b,timeDisplayFormat:y,slowResponseThresholdSeconds:g}),[Mn,$t,b,g,y]),Bx=c.useCallback(ye=>{const Ye=Ai.get(ye.id);Ye!==void 0&&ge([Ye,ye])},[Ai]),Fc=A!==void 0?A:n==="__all__"?null:n;return s.jsxs("div",{className:"bg-background min-h-screen w-full overflow-x-clip text-foreground lg:h-screen lg:flex lg:flex-col lg:overflow-hidden",children:[s.jsx(rA,{liveConnection:w,alertsAction:s.jsx(pI,{}),settingsAction:s.jsx(QP,{})}),s.jsxs("button",{type:"button",onClick:Mc,className:L("group fixed top-1/2 right-3 z-50 inline-flex h-14 w-8 -translate-y-1/2 items-center justify-center rounded-l-md border border-border/70 bg-background/90 text-muted-foreground shadow-lg backdrop-blur transition-colors motion-reduce:transition-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none"),"aria-label":he?"Show details panel":"Hide details panel",title:he?"Show details panel":"Hide details panel",children:[s.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),he?s.jsx(Zj,{className:"size-3.5"}):s.jsx(Vj,{className:"size-3.5"})]}),Ae&&yt&&s.jsx(go,{feature:"Inspector Pet",children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(w4,{logs:e})})}),s.jsxs("div",{className:L("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",Ze&&"cursor-col-resize select-none"),children:[!he&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:Mc,"aria-label":"Close details panel"}),s.jsxs("aside",{className:"inspector-scrollbar fixed inset-x-3 bottom-3 top-24 z-40 order-1 overflow-y-auto rounded-lg border border-border bg-background/98 shadow-2xl max-lg:!w-auto lg:relative lg:inset-auto lg:order-2 lg:h-full lg:shrink-0 lg:rounded-none lg:border-y-0 lg:border-r-0 lg:shadow-none",style:{width:Ce},children:[s.jsx("button",{type:"button",className:"absolute bottom-0 left-0 top-0 z-30 hidden w-2 -translate-x-1/2 cursor-col-resize touch-none items-center justify-center lg:flex",onPointerDown:Ex,onPointerMove:Rx,onPointerUp:Ac,onPointerCancel:Ac,onDoubleClick:Ix,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:s.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),s.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[s.jsxs("div",{className:"sticky top-0 z-20 -mx-4 -mt-4 grid gap-2 border-b border-border/60 bg-background/95 px-4 pb-3 pt-4 backdrop-blur",children:[s.jsx(Ea,{label:"View",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsx(YO,{}),s.jsx(QO,{preference:$,resolvedScale:F,onChange:G})]})}),s.jsx(Ea,{label:"Workspace",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(AI,{labelledTrigger:!0}),s.jsx(OM,{currentSessionId:Fc,logCount:e.length,labelledTrigger:!0})]})})]}),s.jsxs(Ea,{label:"Current scope",children:[s.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[s.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:Oi,children:Oi}),s.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:Ox?"Pinned session":"Live Inspector data"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx(oo,{label:q===null?"Requests":"Results",value:Mn.length}),s.jsx(oo,{label:"Sessions",value:t.length}),s.jsx(oo,{label:"Input",value:Pe(Bs?zc:I)}),s.jsx(oo,{label:"Output",value:Pe(Bs?Lc:N)})]}),S!==void 0&&s.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:s.jsx(ho,{progress:S})})]}),Bs&&An!==null&&s.jsx(c6,{label:An.label,logs:ts,totalIn:zc,totalOut:Lc,timeDisplayFormat:y,contextSummary:Mx,showBackLink:An.showBackLink}),Bs&&A!==void 0&&C.length>0&&s.jsx(tf,{memberships:C}),s.jsx("div",{className:"flex-1"}),s.jsx(QM,{currentSessionId:Fc,logCount:e.length,onResultChange:ne})]})]})]}),s.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[s.jsxs("div",{className:"bg-background/95 shadow-[0_12px_36px_rgba(0,0,0,0.18),inset_0_-1px_0_rgba(255,255,255,0.045)] sticky top-0 z-30 px-4 py-3 lg:px-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("div",{className:"min-w-[180px] flex-1",children:[s.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),s.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:Oi})]}),s.jsx(XO,{visible:yt,onToggle:Px}),f!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:J,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:Me}),s.jsx("button",{type:"button",onClick:Pn,disabled:me,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Import Agent Inspector export",children:me?s.jsx("span",{children:"Importing..."}):s.jsxs(s.Fragment,{children:[s.jsx(Pp,{className:"size-3.5"}),s.jsx("span",{children:"Import"})]})})]}),$c.redacted&&s.jsx("button",{type:"button",onClick:()=>{be("redacted")},disabled:X!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export redacted logs as JSON ZIP",children:X==="redacted"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(yr,{className:"size-3.5"}),s.jsx("span",{children:"Export"})]})}),$c.raw&&s.jsx("button",{type:"button",onClick:()=>{be("raw")},disabled:X!==null,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Export raw logs without redaction",children:X==="raw"?s.jsx("span",{children:"Exporting..."}):s.jsxs(s.Fragment,{children:[s.jsx(tj,{className:"size-3.5"}),s.jsx("span",{children:"Raw"})]})}),l!==void 0&&s.jsxs("button",{type:"button",onClick:rt,disabled:b,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Reload this session from stored logs",children:[s.jsx(Pt,{className:L("size-3.5",b&&"animate-spin motion-reduce:animate-none")}),s.jsx("span",{children:Fx})]}),s.jsxs("button",{type:"button",onClick:en,disabled:!zx,className:"bg-white/[0.035] hover:bg-white/[0.065] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Clear the current view. Stored logs remain reloadable.",children:[s.jsx(wn,{className:"size-3.5"}),s.jsx("span",{children:"Clear"})]}),a!==void 0&&s.jsxs("button",{type:"button",onClick:wt,disabled:!Lx||ce,className:"bg-red-500/[0.07] hover:bg-red-500/[0.12] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-red-200 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.14)] transition-colors hover:text-red-100 focus-visible:ring-1 focus-visible:ring-red-300 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",title:"Delete persisted history for the selected session.",children:[s.jsx(wn,{className:"size-3.5"}),s.jsx("span",{children:"Delete"})]})]}),k===void 0&&S!==void 0&&s.jsx("div",{className:"mt-2 rounded-md bg-black/20 px-2 py-2 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:s.jsx(ho,{progress:S})}),_!==void 0&&s.jsxs("div",{role:"alert",className:"mt-2 flex flex-wrap items-center gap-2 rounded-md border border-red-400/25 bg-red-500/10 px-3 py-2 text-xs text-red-100",children:[s.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",_," Existing logs remain visible."]}),l!==void 0&&s.jsxs("button",{type:"button",onClick:rt,className:"inline-flex h-7 items-center gap-1 rounded-md bg-black/15 px-2 font-medium transition-colors hover:bg-black/25 focus-visible:ring-1 focus-visible:ring-current focus-visible:outline-none",children:[s.jsx(Pt,{className:"size-3"}),"Retry"]})]}),q!==null&&s.jsxs("div",{className:"mt-2 flex items-center gap-3 rounded-md bg-cyan-400/[0.07] px-3 py-2 shadow-[inset_2px_0_0_rgba(103,232,249,0.35),inset_0_0_0_1px_rgba(103,232,249,0.08)]",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:q.question}),s.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(Mn.length)," loaded logs from"," ",String(q.logIds.length)," linked results"]})]}),s.jsxs("button",{type:"button",onClick:()=>ne(null),className:"inline-flex h-7 shrink-0 items-center gap-1 rounded-md bg-black/20 px-2 text-[11px] text-muted-foreground transition-colors hover:bg-black/30 hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[s.jsx(jr,{className:"size-3"}),"All logs"]})]}),q===null&&s.jsx(nf,{logs:e,pagination:k,embedded:!0}),d===void 0&&V!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:V}),d===void 0&&ie!==null&&s.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:ie}),d===void 0&&we!==null&&ie===null&&s.jsx("div",{className:"mt-2 rounded-md border border-cyan-400/25 bg-cyan-500/10 px-3 py-2 text-xs text-cyan-100",children:we}),w!==void 0&&w.status!=="live"&&v!==void 0&&j!==void 0&&s.jsx(nA,{state:w,hasLogs:e.length>0,onRetry:v,onStop:j})]}),s.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[s.jsx(zO,{stats:Ux}),q!==null&&Mn.length===0?s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"mx-auto max-w-xl rounded-[8px] bg-white/[0.035] px-5 py-8 shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)]",children:[s.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),s.jsx("p",{className:"mt-2 text-xs leading-5 text-muted-foreground",children:"Assistant found evidence, but none of its linked log IDs are in the current loaded window. Open an evidence card in Assistant or restore the full log view."}),s.jsx("button",{type:"button",onClick:()=>ne(null),className:"mt-4 inline-flex h-8 items-center rounded-md bg-cyan-400/10 px-3 text-xs text-cyan-100 transition-colors hover:bg-cyan-400/16",children:"Show all logs"})]})}):e.length===0?n!=="__all__"?s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm font-medium",children:b?"Loading session data...":_===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),s.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:Bn(n)}),S!==void 0&&s.jsx("div",{className:"mx-auto max-w-md rounded-md bg-black/20 px-2 py-2 text-left shadow-[inset_0_0_0_1px_rgba(255,255,255,0.045)]",children:s.jsx(ho,{progress:S})}),C.length>0&&s.jsx("div",{className:"text-left",children:s.jsx(tf,{memberships:C})}),!b&&s.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[s.jsx("p",{children:"Stored logs may still be available."}),s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[l!==void 0&&s.jsxs("button",{type:"button",onClick:rt,className:"bg-white/[0.045] hover:bg-white/[0.075] inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs text-muted-foreground shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)] transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:[s.jsx(Pt,{className:"size-3.5"}),s.jsx("span",{children:"Load session"})]}),M?s.jsx("a",{href:"/",className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Back to all sessions"}):s.jsx("button",{type:"button",onClick:()=>o("__all__"),className:"inline-flex h-8 items-center rounded-md px-3 text-xs text-muted-foreground underline transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-none",children:"Show all sessions"})]})]})]})}):s.jsx("div",{className:"py-16 text-center text-muted-foreground",children:s.jsxs("div",{className:"bg-white/[0.035] shadow-[inset_0_1px_0_rgba(255,255,255,0.045),0_18px_52px_rgba(0,0,0,0.18)] mx-auto max-w-2xl space-y-4 rounded-[8px] px-4 py-8",children:[s.jsx("p",{className:"text-sm font-medium",children:zi.title}),s.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:zi.description}),Dc==="empty"&&t.length>0&&s.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Pick a session from the filter panel to load stored logs on demand."}),zi.showConnectionCommands&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(Js,{command:`ANTHROPIC_BASE_URL=${re.proxy} <your-tool>`}),s.jsx(Js,{command:`LLM_BASE_URL=${re.proxy} opencode`}),s.jsx(Js,{command:`OPENAI_BASE_URL=${re.openAiV1} <your-tool>`}),s.jsx(Js,{command:`base_url = "${re.openAiV1}"`}),s.jsx(Js,{command:`MCP_URL=${re.mcp}`})]}),s.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:"Container note: if your AI tool runs in a different container or host than Agent Inspector, replace localhost with an address reachable from that tool and verify the network/firewall path."})]})]})}):s.jsxs("div",{ref:Je,tabIndex:0,"aria-label":"Captured logs",className:"flex flex-col gap-2 rounded-md focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none",children:[s.jsx("div",{ref:Se,children:s.jsx(vA,{groups:$t,viewMode:p,strip:h,slowResponseThresholdSeconds:g,cacheTrends:Ax,onCompareWithPrevious:Bx,comparisonPredecessors:Ai,onClearGroup:u,defaultExpanded:$t.length===1,timeDisplayFormat:y})}),q===null&&s.jsx("div",{className:"mt-3",children:s.jsx(nf,{logs:e,pagination:k})})]})]})]})]}),s.jsx(Wt,{open:B,onOpenChange:W,children:s.jsx(Zt,{className:jA,children:s.jsx(SA,{onCancel:()=>W(!1),onExportRedacted:ue,onConfirmRaw:Ct})})}),s.jsx(Wt,{open:_e,onOpenChange:Ne,children:s.jsxs(Zt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[s.jsxs(Yt,{children:[s.jsxs(Xt,{children:["Delete ",$x," history?"]}),s.jsx(Cr,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),s.jsxs("div",{className:"rounded-md bg-red-500/[0.08] px-3 py-3 text-sm text-red-100 shadow-[inset_0_0_0_1px_rgba(248,113,113,0.16)]",children:[s.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),s.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:Dx})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:ce,onClick:()=>Ne(!1),children:"Cancel"}),s.jsx(ee,{type:"button",variant:"destructive",size:"sm",disabled:ce,onClick:Fs,children:ce?"Deleting...":"Delete history"})]})]})}),ke!==null&&s.jsx(go,{feature:"Compare",children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(y4,{left:ke[0],right:ke[1],leftDisplayNumber:Qd(ke[0],Oc),rightDisplayNumber:Qd(ke[1],Oc),onClose:Us})})})]})}function d6(e,t,n){return t==="__all__"&&n==="__all__"?e:e.filter(r=>!(t!=="__all__"&&r.sessionId!==t||n!=="__all__"&&r.model!==n))}function io(e,t){if(e.length===0)return[...t];if(t.length===0)return[...e];const n=new Map;for(const r of e)n.set(r.id,r);for(const r of t)n.set(r.id,r);return[...n.values()].toSorted((r,o)=>r.id-o.id)}function Fn(e,t){const n=new Set;for(const r of e)r!==""&&n.add(r);for(const r of t)r!==""&&n.add(r);return[...n].sort()}const f6=Ot([E({type:le("init"),logs:K(ir)}),E({type:le("update"),log:ir})]),p6=E({logs:K(ir),total:R().int().nonnegative(),limit:R().int().positive(),hasOlder:Re(),hasNewer:Re(),oldestLogId:R().int().positive().nullable(),newestLogId:R().int().positive().nullable()}),m6=K(x()),af=E({success:Re(),cleared:R().int().nonnegative(),logFilesRewritten:R().int().nonnegative().optional(),chunkFilesDeleted:R().int().nonnegative(),sessionArchiveLogsDeleted:R().int().nonnegative().optional()});function h6(e,t){const n=[];for(const r of e)for(const o of r.members)o.sessionId===t&&n.push({groupId:r.id,groupTitle:r.title,groupKind:r.kind,groupStatus:r.status,groupTask:r.task,groupProject:r.project,groupEvidence:r.evidence,member:o});return n}function ao(e){const t=new Set;for(const n of e)n.sessionId!==null&&n.sessionId!==""&&t.add(n.sessionId);return[...t]}function g6(e){const t=new Set;for(const n of e)n.model!==null&&n.model!==""&&t.add(n.model);return[...t]}const x6=100,b6=12,v6=1800,Pc=100,Go=500,Tx=200,vl=2e4,y6=1e4,w6=3e3,j6=1e4;function k6(e){const t=new URLSearchParams({compact:"1"});e!==void 0&&t.set("sessionId",e);const n=t.toString();return Jo(n.length>0?`/api/logs/stream?${n}`:"/api/logs/stream")}function S6(e,t,n=Pc){const r=new URLSearchParams({cursor:"1",compact:"1",limit:String(n),sessionId:e});switch(t.kind){case"oldest":r.set("anchor","oldest");break;case"older":r.set("beforeLogId",String(t.beforeLogId));break;case"newer":r.set("afterLogId",String(t.afterLogId));break}return`/api/logs?${r.toString()}`}function mn(e){const t=new Map;for(let n=0;n<e.length;n++){const r=e[n];r!==void 0&&t.set(r.id,n)}return t}function sr(e,t,n=Pc){return He(S6(e,t,n),p6,vl)}async function _6(e,t){const n=new Set;let r=await sr(e,{kind:"oldest"},Go);for(const i of r.logs)n.add(i.id);t(n.size,1);let o=1;for(;r.hasNewer&&r.newestLogId!==null&&o<Tx;){r=await sr(e,{kind:"newer",afterLogId:r.newestLogId},Go);for(const i of r.logs)n.add(i.id);o+=1,t(n.size,o)}return{ids:[...n],truncated:r.hasNewer}}async function N6(){try{return{deleted:(await st("/api/groups",mp,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function R6({initialSessionId:e}={}){const[t,n]=c.useState([]),[r,o]=c.useState(e??"__all__"),[i,a]=c.useState("__all__"),[l,u]=c.useState([]),{notice:d,showToast:f,dismissToast:p}=Ug(),[m,h]=c.useState(iA),[g,y]=c.useState(null),[b,w]=c.useState(e!==void 0),[v,j]=c.useState(null),[k,S]=c.useState(void 0),[_,C]=c.useState([]),[,M]=c.useTransition(),A=c.useRef(null),I=c.useRef(null),N=c.useRef(null),P=c.useRef(!0),$=c.useRef(null),F=c.useRef(0),G=c.useRef(null),X=c.useRef(null),U=c.useRef(new Map),V=c.useRef([]),Y=c.useRef(null),B=c.useCallback(J=>{f({message:J,tone:"error"})},[f]),W=c.useCallback(()=>{X.current!==null&&(clearInterval(X.current),X.current=null),G.current=null,S(void 0)},[]),me=c.useCallback((J,T,z=0,Z=0)=>{X.current!==null&&clearInterval(X.current);const re=Date.now();G.current=re;const ae=()=>{F.current===T&&S({label:J,elapsedMs:Date.now()-re,timeoutMs:vl,loadedLogs:z,loadedPages:Z})};ae(),X.current=setInterval(ae,250)},[]),ve=c.useCallback((J,T,z,Z)=>{const re=G.current;re===null||F.current!==T||S({label:J,elapsedMs:Date.now()-re,timeoutMs:vl,loadedLogs:z,loadedPages:Z})},[]),we=c.useMemo(()=>d6(t,r,i),[t,r,i]),D=c.useMemo(()=>Fn(l,ao(t)),[t,l]),ie=c.useMemo(()=>g6(t),[t]),te=c.useCallback(()=>{st("/api/sessions",m6).then(J=>{u(T=>Fn(T,J))}).catch(()=>{})},[]),_e=c.useCallback(()=>{Y.current=null;const J=V.current;V.current=[],J.length!==0&&M(()=>{n(T=>{const z=io(T,J);return U.current=mn(z),z})})},[M]),Ne=c.useCallback(J=>{V.current.push(J),Y.current===null&&(Y.current=setTimeout(_e,x6))},[_e]),ce=c.useCallback(()=>{A.current&&A.current.close(),I.current!==null&&(clearTimeout(I.current),I.current=null),h(T=>nn(T,{type:"connect-requested"}));const J=new EventSource(k6(e));A.current=J,J.onmessage=T=>{try{const z=String(T.data),Z=JSON.parse(z),re=f6.safeParse(Z);if(!re.success){h(se=>nn(se,{type:"recoverable-error",message:"The live stream returned invalid data."})),B("Failed to parse SSE data");return}const ae=re.data;ae.type==="init"?(Y.current!==null&&(clearTimeout(Y.current),Y.current=null),V.current=[],n(se=>{const be=io(se,ae.logs);return U.current=mn(be),be}),u(se=>Fn(se,ao(ae.logs))),N.current!==null&&(clearTimeout(N.current),N.current=null),h(se=>nn(se,{type:"message-received",at:Date.now()})),p()):ae.type==="update"&&(u(se=>ae.log.sessionId===null||ae.log.sessionId===""?se:Fn(se,[ae.log.sessionId])),Ne(ae.log),N.current!==null&&(clearTimeout(N.current),N.current=null),h(se=>nn(se,{type:"message-received",at:Date.now()})))}catch{h(z=>nn(z,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),B("Failed to parse SSE data")}},J.onerror=()=>{const T=navigator.onLine;h(z=>nn(z,{type:"connection-lost",online:T,message:"The live stream disconnected."})),J.close(),!(!T||!P.current)&&(N.current===null&&(N.current=setTimeout(()=>{N.current=null,h(z=>nn(z,{type:"stale-timeout"}))},j6)),I.current=setTimeout(ce,w6))}},[p,e,Ne,B]),de=c.useCallback(()=>{P.current=!0,I.current!==null&&(clearTimeout(I.current),I.current=null),ce()},[ce]),he=c.useCallback(()=>{P.current=!1,A.current?.close(),A.current=null,I.current!==null&&(clearTimeout(I.current),I.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),h(J=>nn(J,{type:"stop-retrying"}))},[]),je=c.useCallback(J=>{if(e===void 0)return;const T=F.current+1;F.current=T,w(!0),j(null),me("Loading session logs",T),p(),sr(e,J).then(z=>{if(F.current!==T)return;const Z=z.logs;U.current=mn(Z),n(Z),y(z),o(e),w(!1),j(null),W(),p()}).catch(z=>{if(F.current!==T)return;w(!1),W();const Z=z instanceof Error?z.message:"Failed to load session logs";j(Z),B(Z)})},[p,e,B,me,W]),Ce=c.useCallback(J=>{const T=F.current+1;F.current=T,w(!0),j(null),me("Reloading full session",T),p(),(async()=>{const z=[];let Z=await sr(J,{kind:"oldest"},Go);z.push(...Z.logs),ve("Reloading full session",T,z.length,1);let re=1;for(;Z.hasNewer&&Z.newestLogId!==null&&re<Tx;)Z=await sr(J,{kind:"newer",afterLogId:Z.newestLogId},Go),z.push(...Z.logs),re+=1,ve("Reloading full session",T,z.length,re);F.current===T&&(n(ae=>{const se=io(ae,z);return U.current=mn(se),se}),u(ae=>Fn(ae,[J])),w(!1),j(null),W(),Z.hasNewer?f({message:`Loaded ${String(z.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(z=>{if(F.current!==T)return;w(!1),W();const Z=z instanceof Error?z.message:"Failed to reload session logs";j(Z),B(Z)})},[p,B,f,me,W,ve]);c.useEffect(()=>{if(e===void 0){C([]);return}let J=!1;return He("/api/groups",xp,y6).then(T=>T.groups).then(T=>{J||T===null||C(h6(T,e))}).catch(()=>{J||C([])}),()=>{J=!0}},[e]),c.useEffect(()=>{te()},[te]),c.useEffect(()=>()=>{W()},[W]),c.useEffect(()=>{e!==void 0&&je({kind:"newest"})},[e,je]),c.useEffect(()=>{e===void 0&&r!=="__all__"&&Ce(r)},[e,Ce,r]),c.useEffect(()=>{if(e!==void 0)return;ce();const J=()=>{A.current?.close(),A.current=null,I.current!==null&&(clearTimeout(I.current),I.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),h(z=>nn(z,{type:"browser-offline"}))},T=()=>{P.current&&ce()};return window.addEventListener("offline",J),window.addEventListener("online",T),()=>{window.removeEventListener("offline",J),window.removeEventListener("online",T),A.current&&(A.current.close(),A.current=null),I.current!==null&&(clearTimeout(I.current),I.current=null),N.current!==null&&(clearTimeout(N.current),N.current=null),Y.current!==null&&(clearTimeout(Y.current),Y.current=null)}},[ce,e]),c.useEffect(()=>{const J=window.location.hash;if(!J.startsWith("#log-")||$.current===J)return;const T=J.slice(1),z=Number(T.replace(/^log-/,""));Number.isInteger(z)&&z>0&&Ms({logId:z,tab:"request"});let Z=!1,re=0,ae=null,se=null;const be=()=>{if(Z)return;const ue=document.getElementById(T);if(ue!==null){$.current=J,ue.scrollIntoView({block:"center",behavior:cx(ux())}),ue instanceof HTMLElement&&(ae=ue,ue.setAttribute("data-deep-link-highlight","true"),se=window.setTimeout(()=>{ue.removeAttribute("data-deep-link-highlight")},v6),ue.focus({preventScroll:!0}),ue.getAttribute("data-nav-action")==="expand"&&ue.click());return}re+=1,re<b6&&window.setTimeout(be,100)};return be(),()=>{Z=!0,se!==null&&window.clearTimeout(se),ae!==null&&ae.removeAttribute("data-deep-link-highlight")}},[we.length]);const Fe=c.useCallback(()=>{const J=ao(t);W(),w(!1),U.current.clear(),n([]),y(null),u(T=>Fn(T,J)),f({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[t,f,W]),Ze=c.useCallback(J=>{if(J.length===0)return;const T=new Set(J);n(z=>{const Z=z.filter(ae=>T.has(ae.id)),re=z.filter(ae=>!T.has(ae.id));return u(ae=>Fn(ae,ao(Z))),U.current=mn(re),re}),f({message:"Cleared this group from the current view.",tone:"success"})},[f]),Ue=c.useCallback(async()=>{const J=F.current+1;F.current=J,w(!0),W(),p();try{if(r==="__all__"){me("Deleting stored history",J);const se=await st("/api/logs",af,{method:"DELETE"}),be=await N6();if(F.current!==J)return;n([]),U.current.clear(),y(null),u([]),C([]),w(!1),W();const ue=be.ok?` Cleared ${be.deleted.toString()} group${be.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";f({message:`Deleted ${se.cleared.toString()} stored log${se.cleared===1?"":"s"} across all sessions.${ue}`,tone:be.ok?"success":"error"});return}const T=r;me("Deleting session history",J);const z=await _6(T,(se,be)=>{ve("Deleting session history",J,se,be)}),Z=new Set(z.ids);for(const se of t)se.sessionId===T&&Z.add(se.id);const re=[...Z].filter(se=>Number.isInteger(se)&&se>=0);if(re.length===0){if(F.current!==J)return;n(se=>{const be=se.filter(ue=>ue.sessionId!==T);return U.current=mn(be),be}),y(se=>se===null?null:{...se,logs:se.logs.filter(be=>be.sessionId!==T)}),u(se=>se.filter(be=>be!==T)),w(!1),W(),f({message:"No stored log records were found for this session.",tone:"success"});return}const ae=await st("/api/logs",af,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:re})});if(F.current!==J)return;n(se=>{const be=se.filter(ue=>ue.sessionId!==T);return U.current=mn(be),be}),y(se=>se===null?null:{...se,logs:se.logs.filter(be=>be.sessionId!==T)}),u(se=>se.filter(be=>be!==T)),w(!1),W(),f({message:`Deleted ${ae.cleared.toString()} stored log${ae.cleared===1?"":"s"} for this session${z.truncated?". More history may remain.":"."}`,tone:z.truncated?"error":"success"})}finally{F.current===J&&(w(!1),W())}},[t,p,r,f,me,W,ve]),ut=c.useCallback(()=>{if(e!==void 0){je({kind:"newest"});return}if(r==="__all__"){te();return}Ce(r)},[e,je,te,Ce,r]),Qt=c.useCallback(async J=>{const T=new FormData;T.set("file",J);const z=await st("/api/logs/import",zy,{method:"POST",body:T});return n(Z=>{const re=new Set(z.logs.map(se=>se.id)),ae=io(Z.filter(se=>!re.has(se.id)),z.logs);return U.current=mn(ae),ae}),o(z.sessionId),a("__all__"),y(null),p(),z},[p]),{strip:yt,captureMode:Ke,slowResponseThresholdSeconds:Ae,timeDisplayFormat:Be}=Fl(),q=Ke,ne=c.useCallback(()=>{je({kind:"oldest"})},[je]),ke=c.useCallback(()=>{je({kind:"newest"})},[je]),ge=c.useCallback(()=>{const J=t[0],T=g?.oldestLogId??J?.id??null;T!==null&&je({kind:"older",beforeLogId:T})},[t,je,g]),Se=c.useCallback(()=>{const J=t[t.length-1],T=g?.newestLogId??J?.id??null;T!==null&&je({kind:"newer",afterLogId:T})},[t,je,g]),Je=c.useMemo(()=>{if(e!==void 0)return{isLoading:b,loadProgress:k,total:g?.total??null,pageSize:g?.limit??Pc,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ne,onOlder:ge,onNewer:Se,onNewest:ke}},[e,ke,Se,ge,ne,g,k,b]);return s.jsxs(s.Fragment,{children:[s.jsx(Bg,{notice:d,onDismiss:p}),s.jsx($k,{}),s.jsx(u6,{logs:we,sessions:D,models:ie,selectedSession:r,selectedModel:i,onSessionChange:o,onModelChange:a,onClearAll:Fe,onDeleteCurrentView:Ue,onReloadSession:e!==void 0||r!=="__all__"?ut:void 0,onClearGroup:Ze,onNotify:f,onImportLogs:e===void 0?Qt:void 0,isLoading:e===void 0&&m.status==="connecting"&&m.lastSuccessAt===null||b,liveConnection:e===void 0?m:void 0,onRetryLiveConnection:de,onStopLiveConnection:he,pagination:Je,sessionLoadProgress:k,sessionLoadError:v??void 0,sessionMemberships:_,viewMode:q,captureMode:Ke,strip:yt,slowResponseThresholdSeconds:Ae,timeDisplayFormat:Be,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{Xn as $,Ms as A,Te as B,qw as C,Wt as D,ni as E,Re as F,x as G,ir as H,bO as I,wj as J,IA as K,N4 as L,Cp as M,RA as N,E6 as O,R6 as P,et as Q,nk as R,OA as S,kg as T,xe as U,nE as V,T6 as W,jr as X,yp as Y,sE as Z,rE as _,CT as a,il as a0,$o as a1,VM as a2,Pw as a3,ar as a4,Q as a5,yn as a6,De as a7,Zf as a8,b4 as a9,vw as aa,mu as b,H as c,Tp as d,bt as e,qe as f,mg as g,zt as h,He as i,Zt as j,Yt as k,Xt as l,Rp as m,Sg as n,gn as o,jt as p,Rj as q,ur as r,Ds as s,dt as t,Wl as u,ft as v,pt as w,E as x,R as y,K as z};