@tonyclaw/agent-inspector 3.0.45 → 3.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/{nitro.json → backend/nitro.json} +3 -3
- package/.output/backend-public/assets/index-D4LX-sw-.js +11 -0
- package/.output/cli.js +8018 -5451
- package/.output/server/_libs/extend.mjs +4 -8
- package/.output/server/_libs/jszip.mjs +9 -35
- package/.output/server/_libs/react-dom.mjs +2 -3
- package/.output/server/_libs/react.mjs +1 -27
- package/.output/server/_libs/tanstack__react-router.mjs +1 -329
- package/.output/server/_libs/tanstack__router-core.mjs +42 -100
- package/.output/server/_libs/use-sync-external-store.mjs +1 -64
- package/.output/server/_libs/ws.mjs +1 -1
- package/.output/server/_ssr/index.mjs +4 -4
- package/.output/server/_ssr/{publicBasePathContext-5264L3rX.mjs → publicBasePathContext-IH2ilOfu.mjs} +52 -24
- package/.output/server/_ssr/{router-BJ_ltLim.mjs → router-BwZEsYfS.mjs} +19794 -19444
- package/.output/server/_ssr/{start-C6MjPjxp.mjs → start-COQu_AgD.mjs} +1 -1
- package/.output/server/_tanstack-start-manifest_v-DnbdNeun.mjs +4 -0
- package/.output/server/index.mjs +5 -145
- package/.output/{public/assets/CompareDrawer-B3_TLTJh.js → ui/assets/CompareDrawer-V-8lPASC.js} +1 -1
- package/.output/{public/assets/InspectorPet-Cpn6hv4P.js → ui/assets/InspectorPet-D4CVnfdf.js} +1 -1
- package/.output/ui/assets/ProxyViewerContainer-CO3ZVHLX.js +59 -0
- package/.output/{public/assets/ReplayDialog-B3EKVdJk.js → ui/assets/ReplayDialog-CpGyTLtt.js} +1 -1
- package/.output/{public/assets/RequestAnatomy-COOQjyUC.js → ui/assets/RequestAnatomy-BLuJL9dZ.js} +1 -1
- package/.output/ui/assets/ResponseView-BuSC-CH7.js +2 -0
- package/.output/ui/assets/StreamingChunkSequence-DeA-JJKa.js +1 -0
- package/.output/{public/assets/_sessionId-zbgYl7ZJ.js → ui/assets/_sessionId-8HuHFhjo.js} +1 -1
- package/.output/{public/assets/_sessionId-BJlM3nmt.js → ui/assets/_sessionId-Chp67th6.js} +1 -1
- package/.output/ui/assets/favicon-DYEkHSNl.svg +21 -0
- package/.output/ui/assets/index-BvXp42al.css +1 -0
- package/.output/{public/assets/index-xF_NY8Yb.js → ui/assets/index-DPmKK_5d.js} +5 -5
- package/.output/{public/assets/index-BIK4bPTv.js → ui/assets/index-atoQrlb8.js} +1 -1
- package/.output/ui/assets/index-nY3E1vxV.js +73 -0
- package/.output/{public/assets/index-D2Qw6Ri2.js → ui/assets/index-nl9-dpZn.js} +1 -1
- package/.output/ui/assets/json-viewer-B9kIzqeX.js +1 -0
- package/.output/{public/assets/jszip.min-B_rfAUCe.js → ui/assets/jszip.min-B7tfyE-I.js} +1 -1
- package/.output/ui/index.html +229 -0
- package/.output/ui/runtime-config.js +2 -0
- package/.output/workers/logFinalizer.worker.js +979 -414
- package/.output/workers/sessionWorkerEntry.js +979 -414
- package/README.md +182 -43
- package/docs/instance-control.openapi.yaml +59 -4
- package/package.json +40 -6
- package/scripts/generate-theme-scales.mjs +3 -3
- package/src/{router.tsx → backend/router.tsx} +3 -15
- package/src/backend/routes/$.ts +26 -0
- package/src/backend/routes/__root.ts +4 -0
- package/src/backend/routes/api/-instances.ts +7 -0
- package/src/{routes → backend/routes}/api/alerts.summary.ts +3 -3
- package/src/{routes → backend/routes}/api/alerts.ts +4 -4
- package/src/{routes → backend/routes}/api/config.paths.ts +1 -1
- package/src/{routes → backend/routes}/api/config.ts +11 -2
- package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.help.ts +1 -1
- package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.install.ts +1 -1
- package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.runner-presets.ts +1 -1
- package/src/{routes → backend/routes}/api/ecosystem.packages.$packageId.upgrade.ts +1 -1
- package/src/{routes → backend/routes}/api/ecosystem.packages.ts +5 -1
- package/src/{routes → backend/routes}/api/ecosystem.recipes.$recipeId.run.ts +1 -1
- package/src/{routes → backend/routes}/api/ecosystem.tasks.$taskId.ts +1 -1
- package/src/{routes → backend/routes}/api/ecosystem.tasks.ts +1 -1
- package/src/{routes → backend/routes}/api/groups.$groupId.evidence.ts +2 -2
- package/src/{routes → backend/routes}/api/groups.$groupId.sessions.ts +2 -2
- package/src/{routes → backend/routes}/api/groups.$groupId.ts +2 -2
- package/src/{routes → backend/routes}/api/groups.ts +2 -2
- package/src/{routes → backend/routes}/api/health.ts +3 -3
- package/src/{routes → backend/routes}/api/instances.$name.connection.ts +1 -1
- package/src/{routes → backend/routes}/api/instances.$name.restart.ts +2 -2
- package/src/{routes → backend/routes}/api/instances.$name.start.ts +2 -2
- package/src/{routes → backend/routes}/api/instances.$name.stop.ts +2 -2
- package/src/{routes → backend/routes}/api/instances.$name.ts +1 -1
- package/src/{routes → backend/routes}/api/instances.ts +1 -1
- package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.promote.ts +2 -2
- package/src/{routes → backend/routes}/api/knowledge.candidates.$candidateId.ts +2 -2
- package/src/{routes → backend/routes}/api/knowledge.candidates.ts +1 -1
- package/src/{routes → backend/routes}/api/knowledge.project-context.ts +2 -2
- package/src/{routes → backend/routes}/api/knowledge.search.ts +2 -2
- package/src/{routes → backend/routes}/api/knowledge.sessions.$sessionId.candidates.ts +3 -3
- package/src/{routes → backend/routes}/api/logs.$id.body.ts +6 -6
- package/src/{routes → backend/routes}/api/logs.$id.chunks.ts +5 -4
- package/src/{routes → backend/routes}/api/logs.$id.replay.ts +12 -11
- package/src/{routes → backend/routes}/api/logs.$id.ts +4 -3
- package/src/{routes → backend/routes}/api/logs.import.ts +3 -3
- package/src/{routes → backend/routes}/api/logs.stream.ts +11 -7
- package/src/{routes → backend/routes}/api/logs.ts +17 -9
- package/src/{routes → backend/routes}/api/mcp.ts +1 -1
- package/src/{routes → backend/routes}/api/models.ts +1 -1
- package/src/{routes → backend/routes}/api/pi-agent.ts +2 -2
- package/src/{routes → backend/routes}/api/providers.$providerId.model-metadata.ts +5 -5
- package/src/{routes → backend/routes}/api/providers.$providerId.test.log.ts +7 -7
- package/src/{routes → backend/routes}/api/providers.$providerId.ts +4 -4
- package/src/{routes → backend/routes}/api/providers.export.ts +1 -1
- package/src/{routes → backend/routes}/api/providers.import.ts +3 -3
- package/src/{routes → backend/routes}/api/providers.scan.ts +2 -2
- package/src/{routes → backend/routes}/api/providers.ts +9 -4
- package/src/{routes → backend/routes}/api/runs.$runId.evidence.ts +2 -2
- package/src/{routes → backend/routes}/api/runs.$runId.ts +2 -2
- package/src/{routes → backend/routes}/api/runs.ts +4 -4
- package/src/backend/routes/api/runtime.ts +46 -0
- package/src/{routes → backend/routes}/api/sessions.ts +3 -3
- package/src/{routes → backend/routes}/proxy/$.ts +1 -1
- package/src/{routes → backend/routes}/readyz.ts +1 -1
- package/src/{start.ts → backend/start.ts} +1 -1
- package/src/cli/alias.ts +2 -11
- package/src/cli/doctor.ts +32 -9
- package/src/cli/instance.ts +36 -13
- package/src/cli/instanceApi.ts +213 -0
- package/src/cli/instanceArgs.ts +46 -11
- package/src/cli/instanceControl.ts +10 -2
- package/src/cli/instanceModel.ts +18 -17
- package/src/cli/instanceRegistry.ts +0 -9
- package/src/cli/networkHints.ts +27 -14
- package/src/cli/onboard.ts +69 -2
- package/src/cli/onboardTarget.ts +89 -40
- package/src/cli/rustBackendPackage.ts +450 -0
- package/src/cli/templates/codex-skill-onboard.ts +44 -14
- package/src/cli/templates/skill-onboard.ts +64 -28
- package/src/cli.ts +341 -75
- package/src/components/ProxyViewer.tsx +11 -9
- package/src/components/ProxyViewerContainer.tsx +12 -11
- package/src/components/pi-agent/PiAgentPanel.tsx +2 -2
- package/src/components/providers/ProviderCard.tsx +1 -1
- package/src/components/providers/ProviderTestResultsView.tsx +1 -1
- package/src/components/providers/SettingsDialog.tsx +159 -144
- package/src/components/proxy-viewer/ApplicationBar.tsx +2 -1
- package/src/components/proxy-viewer/LogEntry.tsx +1 -1
- package/src/components/proxy-viewer/log-formats/index.ts +1 -1
- package/src/contracts/index.ts +5 -0
- package/src/contracts/log.ts +33 -3
- package/src/knowledge/types.ts +3 -2
- package/src/lib/alertContract.ts +2 -2
- package/src/lib/apiClient.ts +30 -7
- package/src/lib/apiFormat.ts +29 -0
- package/src/lib/backendImplementation.ts +16 -0
- package/src/lib/basePath.ts +29 -11
- package/src/lib/browserRuntimeContract.ts +124 -0
- package/src/lib/browserRuntimeResolver.ts +244 -0
- package/src/{proxy → lib}/claudeCodeStrip.ts +6 -7
- package/src/lib/codingAgentEndpoints.ts +38 -0
- package/src/lib/instanceContract.ts +30 -11
- package/src/lib/managedInstance.ts +9 -1
- package/src/lib/piAgentContract.ts +3 -2
- package/src/lib/publicBasePathContext.ts +40 -10
- package/src/lib/resourceLimits.ts +2 -0
- package/src/lib/runContract.ts +3 -3
- package/src/lib/sessionInfoContract.ts +3 -2
- package/src/mcp/instanceHandlers.ts +2 -0
- package/src/mcp/server.ts +19 -24
- package/src/proxy/config.ts +25 -30
- package/src/proxy/dataDir.ts +43 -7
- package/src/proxy/ecosystemTasks.ts +161 -70
- package/src/proxy/formats/registry.ts +6 -21
- package/src/proxy/handler.ts +129 -29
- package/src/proxy/identityProxy.ts +567 -39
- package/src/proxy/jsonlRecovery.ts +554 -0
- package/src/proxy/logFinalizer.ts +25 -10
- package/src/proxy/logImporter.ts +2 -1
- package/src/proxy/logIndex.ts +191 -95
- package/src/proxy/logger.ts +77 -14
- package/src/proxy/platformCommands.ts +41 -0
- package/src/proxy/privateDataPath.ts +310 -88
- package/src/proxy/rawStreamCapture.ts +194 -13
- package/src/proxy/runtimeAdmission.ts +5 -2
- package/src/proxy/runtimeHealth.ts +14 -1
- package/src/proxy/runtimeShutdown.ts +11 -1
- package/src/proxy/schemas.ts +7 -1
- package/src/proxy/sessionArchive.ts +70 -14
- package/src/proxy/sqliteLogIndex.ts +65 -42
- package/src/proxy/store.ts +141 -34
- package/src/proxy/uiAssetServer.ts +106 -0
- package/src/proxy/upstream.ts +29 -2
- package/src/ui/bootstrap.ts +167 -0
- package/src/ui/index.html +38 -0
- package/src/ui/logsStreamClient.ts +20 -0
- package/src/ui/main.tsx +13 -0
- package/src/ui/public/runtime-config.js +2 -0
- package/src/ui/router.tsx +13 -0
- package/src/ui/routes/__root.tsx +69 -0
- package/src/{routes → ui/routes}/index.tsx +2 -3
- package/src/{routes → ui/routes}/session/$sessionId.tsx +5 -11
- package/src/ui/runtimeDiscovery.ts +50 -0
- package/styles/globals.css +1 -0
- package/.output/public/assets/ProxyViewerContainer-BEAhuGOJ.js +0 -126
- package/.output/public/assets/ResponseView-DBCjkwye.js +0 -2
- package/.output/public/assets/StreamingChunkSequence-CuXhDgMo.js +0 -1
- package/.output/public/assets/index-BZo_8koU.js +0 -70
- package/.output/public/assets/index-ZWschkCh.css +0 -1
- package/.output/public/assets/json-viewer-B-Ao6pwW.js +0 -1
- package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +0 -1
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +0 -344
- package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +0 -2
- package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +0 -2
- package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +0 -2
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +0 -11
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +0 -69
- package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +0 -1
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +0 -28
- package/.output/server/_libs/@radix-ui/react-use-layout-effect+[...].mjs +0 -6
- package/.output/server/_libs/@radix-ui/react-visually-hidden+[...].mjs +0 -34
- package/.output/server/_libs/aria-hidden.mjs +0 -122
- package/.output/server/_libs/bail.mjs +0 -8
- package/.output/server/_libs/character-entities.mjs +0 -2130
- package/.output/server/_libs/class-variance-authority.mjs +0 -44
- package/.output/server/_libs/clsx.mjs +0 -16
- package/.output/server/_libs/comma-separated-tokens.mjs +0 -10
- package/.output/server/_libs/decode-named-character-reference+[...].mjs +0 -8
- package/.output/server/_libs/dequal.mjs +0 -27
- package/.output/server/_libs/detect-node-es.mjs +0 -1
- package/.output/server/_libs/devlop.mjs +0 -8
- package/.output/server/_libs/diff.mjs +0 -320
- package/.output/server/_libs/estree-util-is-identifier-name.mjs +0 -11
- package/.output/server/_libs/floating-ui__core.mjs +0 -725
- package/.output/server/_libs/floating-ui__dom.mjs +0 -622
- package/.output/server/_libs/floating-ui__react-dom.mjs +0 -292
- package/.output/server/_libs/floating-ui__utils.mjs +0 -320
- package/.output/server/_libs/get-nonce.mjs +0 -9
- package/.output/server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
- package/.output/server/_libs/hast-util-whitespace.mjs +0 -10
- package/.output/server/_libs/html-url-attributes.mjs +0 -26
- package/.output/server/_libs/inline-style-parser.mjs +0 -142
- package/.output/server/_libs/is-plain-obj.mjs +0 -10
- package/.output/server/_libs/lucide-react.mjs +0 -1027
- package/.output/server/_libs/mdast-util-from-markdown.mjs +0 -717
- package/.output/server/_libs/mdast-util-to-hast.mjs +0 -710
- package/.output/server/_libs/mdast-util-to-string.mjs +0 -38
- package/.output/server/_libs/micromark-core-commonmark.mjs +0 -2259
- package/.output/server/_libs/micromark-factory-destination.mjs +0 -94
- package/.output/server/_libs/micromark-factory-label.mjs +0 -63
- package/.output/server/_libs/micromark-factory-space.mjs +0 -24
- package/.output/server/_libs/micromark-factory-title.mjs +0 -65
- package/.output/server/_libs/micromark-factory-whitespace.mjs +0 -22
- package/.output/server/_libs/micromark-util-character.mjs +0 -44
- package/.output/server/_libs/micromark-util-chunked.mjs +0 -36
- package/.output/server/_libs/micromark-util-classify-character+[...].mjs +0 -12
- package/.output/server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
- package/.output/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
- package/.output/server/_libs/micromark-util-decode-string.mjs +0 -21
- package/.output/server/_libs/micromark-util-encode.mjs +0 -1
- package/.output/server/_libs/micromark-util-html-tag-name.mjs +0 -69
- package/.output/server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
- package/.output/server/_libs/micromark-util-resolve-all.mjs +0 -15
- package/.output/server/_libs/micromark-util-sanitize-uri.mjs +0 -41
- package/.output/server/_libs/micromark-util-subtokenize.mjs +0 -346
- package/.output/server/_libs/micromark.mjs +0 -906
- package/.output/server/_libs/property-information.mjs +0 -1209
- package/.output/server/_libs/radix-ui.mjs +0 -1
- package/.output/server/_libs/radix-ui__number.mjs +0 -6
- package/.output/server/_libs/radix-ui__primitive.mjs +0 -11
- package/.output/server/_libs/radix-ui__react-accordion.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-arrow.mjs +0 -23
- package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-avatar.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-checkbox.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +0 -144
- package/.output/server/_libs/radix-ui__react-collection.mjs +0 -69
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -38
- package/.output/server/_libs/radix-ui__react-context-menu.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-context.mjs +0 -64
- package/.output/server/_libs/radix-ui__react-dialog.mjs +0 -280
- package/.output/server/_libs/radix-ui__react-direction.mjs +0 -9
- package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +0 -39
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +0 -210
- package/.output/server/_libs/radix-ui__react-form.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-hover-card.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-id.mjs +0 -14
- package/.output/server/_libs/radix-ui__react-label.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-menu.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-menubar.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-popover.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-popper.mjs +0 -340
- package/.output/server/_libs/radix-ui__react-portal.mjs +0 -16
- package/.output/server/_libs/radix-ui__react-presence.mjs +0 -173
- package/.output/server/_libs/radix-ui__react-primitive.mjs +0 -42
- package/.output/server/_libs/radix-ui__react-progress.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-radio-group.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-roving-focus.mjs +0 -235
- package/.output/server/_libs/radix-ui__react-scroll-area.mjs +0 -731
- package/.output/server/_libs/radix-ui__react-select.mjs +0 -1207
- package/.output/server/_libs/radix-ui__react-separator.mjs +0 -28
- package/.output/server/_libs/radix-ui__react-slider.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-slot.mjs +0 -132
- package/.output/server/_libs/radix-ui__react-switch.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-tabs.mjs +0 -194
- package/.output/server/_libs/radix-ui__react-toast.mjs +0 -2
- package/.output/server/_libs/radix-ui__react-toggle-group.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-toggle.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-toolbar.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +0 -498
- package/.output/server/_libs/radix-ui__react-use-previous.mjs +0 -14
- package/.output/server/_libs/radix-ui__react-use-size.mjs +0 -39
- package/.output/server/_libs/react-markdown.mjs +0 -235
- package/.output/server/_libs/react-remove-scroll-bar.mjs +0 -82
- package/.output/server/_libs/react-remove-scroll.mjs +0 -328
- package/.output/server/_libs/react-style-singleton.mjs +0 -69
- package/.output/server/_libs/remark-parse.mjs +0 -19
- package/.output/server/_libs/remark-rehype.mjs +0 -21
- package/.output/server/_libs/space-separated-tokens.mjs +0 -6
- package/.output/server/_libs/style-to-js.mjs +0 -72
- package/.output/server/_libs/style-to-object.mjs +0 -38
- package/.output/server/_libs/swr.mjs +0 -947
- package/.output/server/_libs/tailwind-merge.mjs +0 -3255
- package/.output/server/_libs/tanstack__react-virtual.mjs +0 -130
- package/.output/server/_libs/tanstack__virtual-core.mjs +0 -1319
- package/.output/server/_libs/three.mjs +0 -26016
- package/.output/server/_libs/trim-lines.mjs +0 -41
- package/.output/server/_libs/trough.mjs +0 -85
- package/.output/server/_libs/tslib.mjs +0 -1
- package/.output/server/_libs/ungap__structured-clone.mjs +0 -212
- package/.output/server/_libs/unified.mjs +0 -661
- package/.output/server/_libs/unist-util-is.mjs +0 -100
- package/.output/server/_libs/unist-util-position.mjs +0 -27
- package/.output/server/_libs/unist-util-stringify-position.mjs +0 -27
- package/.output/server/_libs/unist-util-visit-parents.mjs +0 -82
- package/.output/server/_libs/unist-util-visit.mjs +0 -24
- package/.output/server/_libs/use-callback-ref.mjs +0 -66
- package/.output/server/_libs/use-sidecar.mjs +0 -106
- package/.output/server/_libs/vfile-message.mjs +0 -138
- package/.output/server/_libs/vfile.mjs +0 -467
- package/.output/server/_sessionId-CJ99gZFV.mjs +0 -84
- package/.output/server/_sessionId-DEjScBpK.mjs +0 -146
- package/.output/server/_ssr/CompareDrawer-DtOIMeQB.mjs +0 -1060
- package/.output/server/_ssr/InspectorPet-CXc4oCBQ.mjs +0 -938
- package/.output/server/_ssr/ProxyViewerContainer-DVPlwfkt.mjs +0 -17632
- package/.output/server/_ssr/ReplayDialog-BQEA95qC.mjs +0 -725
- package/.output/server/_ssr/RequestAnatomy-BMyd8B7Q.mjs +0 -837
- package/.output/server/_ssr/ResponseView-qrTaEIM8.mjs +0 -757
- package/.output/server/_ssr/StreamingChunkSequence-BFTL8mIy.mjs +0 -274
- package/.output/server/_ssr/index-Bcj1Hcy4.mjs +0 -135
- package/.output/server/_ssr/index-DW-M7XUG.mjs +0 -84
- package/.output/server/_ssr/json-viewer-DiI0Yjsn.mjs +0 -483
- package/.output/server/_tanstack-start-manifest_v-C6pXXX9R.mjs +0 -4
- package/.output/server/node_modules/tslib/modules/index.js +0 -70
- package/.output/server/node_modules/tslib/modules/package.json +0 -3
- package/.output/server/node_modules/tslib/package.json +0 -47
- package/.output/server/node_modules/tslib/tslib.js +0 -484
- package/.output/server/package.json +0 -9
- package/src/routes/__root.tsx +0 -170
- package/src/routes/api/-instances.ts +0 -109
- /package/.output/{public → ui}/assets/agent-inspector-58K1_MsC.ico +0 -0
- /package/.output/{public → ui}/assets/alibaba-TTwafVwX.svg +0 -0
- /package/.output/{public → ui}/assets/minimax-BPMzvuL-.jpeg +0 -0
- /package/.output/{public → ui}/assets/qwen-mMn3f5ul.webp +0 -0
- /package/.output/{public → ui}/assets/zhipuai-BPNAnxo-.svg +0 -0
- /package/src/{routes → backend/routes}/livez.ts +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-B7tfyE-I.js","./index-nY3E1vxV.js","./index-BvXp42al.css","./CompareDrawer-V-8lPASC.js","./InspectorPet-D4CVnfdf.js","./ReplayDialog-CpGyTLtt.js","./ResponseView-BuSC-CH7.js","./RequestAnatomy-BLuJL9dZ.js","./StreamingChunkSequence-DeA-JJKa.js","./json-viewer-B9kIzqeX.js","./index-DPmKK_5d.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{l as jh,u as Ot,s as x,n as E,b as _e,_ as zo,a as K,c as ze,o as T,d as ue,e as re,f as un,g as Ts,h as Et,i as Ad,k as Ge,r as l,j as t,m as Dt,p as Xn,A as $l,q as Sh,t as Vr,v as pr,w as ms,x as O,B as ee,y as An,z as Id,C as Ee,D as Pd,E as vt,F as ji,G as Nh,H as De,L as $o,I as Ld,J as Ch,K as Fo,M as kh,N as _h,O as Th,P as Od,Q as Si,T as Eh,U as Rh}from"./index-nY3E1vxV.js";const We=jh(()=>Ot([x(),E(),_e(),zo(),K(We),ze(x(),We)])),At=E().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Mh=ue(["capacity-exceeded","pipeline-closed","write-failed","finalize-failed","upstream-stream-error","shutdown"]),Dd=T({index:E(),timestamp:E(),type:x(),data:We}),Ah=T({chunks:K(Dd),truncated:_e().optional().default(!1)}),Ih=ue(["request","response"]),Ph=T({logId:At,part:Ih,text:x(),offset:E().int().nonnegative(),limit:E().int().positive(),totalBytes:E().int().nonnegative(),textBytes:E().int().nonnegative(),nextOffset:E().int().nonnegative().nullable(),hasMore:_e(),contentMode:ue(["empty","partial","full"])}),Is=T({id:At,timestamp:x(),method:x(),path:x(),model:x().nullable(),sessionId:x().nullable(),rawRequestBody:x().nullable(),responseStatus:E().nullable(),responseText:x().nullable(),inputTokens:E().nullable(),outputTokens:E().nullable(),cacheCreationInputTokens:E().nullable(),cacheReadInputTokens:E().nullable(),elapsedMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),streaming:_e(),userAgent:x().nullable(),origin:x().nullable(),rawHeaders:ze(x(),x()).optional(),headers:ze(x(),x()).optional(),apiFormat:ue(["anthropic","openai","unknown"]).default("unknown"),isTest:_e().optional().default(!1),replayOfLogId:At.nullable().optional(),providerName:x().nullable().optional(),clientPort:E().nullable().optional(),clientPid:E().nullable().optional(),clientCwd:x().nullable().optional(),clientProjectFolder:x().nullable().optional(),streamingChunks:Ah.optional(),streamingChunksPath:x().nullable().optional(),rawRequestBodyBytes:E().int().nonnegative().nullable().optional(),responseTextBytes:E().int().nonnegative().nullable().optional(),bodyContentMode:ue(["full","compact","truncated"]).optional(),captureIncomplete:_e().optional(),droppedChunks:E().int().nonnegative().optional(),droppedBytes:E().int().nonnegative().optional(),captureIncompleteReason:Mh.nullable().optional(),warnings:K(x()).optional(),error:x().nullable().optional()}),Ni=T({type:x(),ttl:x().optional(),scope:x().optional()}),Ci=T({type:re("text"),text:x(),cache_control:Ni.optional()}),zd=T({type:re("thinking"),thinking:x(),signature:x().optional()}),Lh=T({type:re("think"),thinking:x(),signature:x().optional()}),Oh=T({type:re("base64"),media_type:x(),data:x()}),$d=T({type:re("image"),source:Oh}),Fd=T({type:re("tool_use"),id:x(),name:x(),input:ze(x(),We)}),Dh=un("type",[Ci,$d]),zh=T({type:re("tool_result"),tool_use_id:x().optional(),content:Ot([x(),K(Dh)]),is_error:_e().optional()}),$h=un("type",[Ci,zd,$d,Fd,zh]),Fh=Ot([x(),K($h)]),Uh=T({role:ue(["user","assistant"]),content:Fh}),Bh=T({type:re("text"),text:x(),cache_control:Ni.optional()}),qh=T({type:x(),properties:ze(x(),ze(x(),We)).optional(),required:K(x()).optional(),additionalProperties:_e().optional(),$schema:x().optional()}),Hh=T({name:x(),description:x().optional(),input_schema:qh.optional(),cache_control:Ni.optional()}),Wh=un("type",[T({type:re("enabled"),budget_tokens:E()}),T({type:re("disabled")}),T({type:re("adaptive")})]),Vh=T({model:x(),messages:K(Uh),system:K(Bh).optional(),tools:K(Hh).optional(),max_tokens:E().optional(),temperature:E().optional(),stream:_e().optional(),thinking:Wh.optional(),metadata:T({user_id:x().optional()}).optional()}),ki=un("type",[Ci,zd,Lh,Fd]),Kh=T({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),cache_creation_input_tokens:E().nullable().optional(),cache_read_input_tokens:E().nullable().optional()}).passthrough(),Gh=T({id:x(),type:re("message"),model:x(),role:re("assistant"),content:K(ki),stop_reason:x().nullable(),stop_sequence:x().nullable().optional(),usage:Kh}).passthrough(),Jh=T({type:re("message_start"),message:T({id:x(),type:re("message"),model:x(),role:re("assistant"),content:K(ki),stop_reason:zo(),stop_sequence:zo(),usage:T({input_tokens:E(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()})}),Yh=T({type:re("content_block_start"),index:E(),content_block:ki}),Xh=un("type",[T({type:re("text_delta"),text:x()}),T({type:re("input_json_delta"),partial_json:x()}),T({type:re("thinking_delta"),thinking:x()}),T({type:re("signature_delta"),signature:x()})]),Zh=T({type:re("content_block_delta"),index:E(),delta:Xh}),Qh=T({type:re("content_block_stop"),index:E()}),ex=T({type:re("message_delta"),delta:T({stop_reason:x().nullable(),stop_sequence:x().nullable().optional()}),usage:T({output_tokens:E(),input_tokens:E().optional(),cache_creation_input_tokens:E().optional(),cache_read_input_tokens:E().optional()}).passthrough()}),tx=T({type:re("message_stop")}),nx=T({type:re("ping")}),sx=T({type:re("error"),error:T({type:x(),message:x()})});un("type",[Jh,Yh,Zh,Qh,ex,tx,nx,sx]);const ox=Ot([x(),K(un("type",[T({type:re("text"),text:x()}),T({type:re("image_url"),image_url:T({url:x(),detail:x().optional()})})]))]),Ud=T({role:ue(["system","user","assistant","tool"]),content:ox,name:x().optional(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional()}),rx=T({name:x(),arguments:x()}),Bd=T({index:E().optional(),id:x().optional(),type:re("function").optional(),function:T({name:x().optional(),arguments:x().optional()})});Ud.extend({content:Ot([x(),K(T({type:re("text"),text:x()}))]).optional(),function_call:rx.optional(),tool_calls:K(Bd).optional()});const ax=T({type:re("function"),function:T({name:x(),description:x().optional(),parameters:ze(x(),We)})}),ix=T({model:x(),messages:K(Ud),temperature:E().optional(),max_tokens:E().optional(),stream:_e().optional(),tools:K(ax).optional(),tool_choice:Ot([ue(["auto","none","required"]),T({type:re("auto")}),T({type:re("none")}),T({type:re("function"),function:T({name:x()})})]).optional(),user:x().optional()}),lx=T({type:x(),name:x().optional(),description:x().optional(),parameters:We.optional(),function:T({name:x().optional(),description:x().optional(),parameters:We.optional()}).optional()}).passthrough(),cx=T({model:x(),input:Ts().optional(),instructions:Ot([x(),zo()]).optional(),stream:_e().optional(),tools:K(lx).optional(),tool_choice:Ts().optional(),max_output_tokens:E().optional(),temperature:E().optional(),user:x().optional(),metadata:ze(x(),Ts()).optional()}).passthrough(),qd=T({role:ue(["assistant"]).optional(),content:x().nullable().optional(),reasoning_content:x().nullable().optional(),thinking:x().nullable().optional(),think:x().nullable().optional(),function_call:T({name:x().optional(),arguments:x().optional()}).nullable().optional(),tool_calls:K(T({index:E(),id:x().optional(),type:re("function").optional(),function:T({name:x().optional(),arguments:x().optional()})})).nullable().optional()}),dx=T({index:E(),message:T({role:ue(["assistant"]),content:x().nullable(),reasoning_content:x().optional(),thinking:x().optional(),think:x().optional(),function_call:T({name:x(),arguments:x()}).nullable().optional(),tool_calls:K(Bd).optional()}).optional(),delta:qd.optional(),finish_reason:x().nullable()}),ux=T({id:x(),object:re("chat.completion"),created:E(),model:x(),choices:K(dx),usage:T({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough(),service_tier:x().nullable().optional(),system_fingerprint:x().nullable().optional()}).passthrough();T({id:x(),object:re("chat.completion.chunk"),created:E(),model:x(),choices:K(T({index:E(),delta:qd,finish_reason:x().nullable().optional()})),usage:T({prompt_tokens:E().nullable().optional(),completion_tokens:E().nullable().optional(),total_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough();const mx=T({input_tokens:E().nullable().optional(),output_tokens:E().nullable().optional(),total_tokens:E().nullable().optional(),input_tokens_details:T({cached_tokens:E().nullable().optional()}).passthrough().nullable().optional(),output_tokens_details:T({reasoning_tokens:E().nullable().optional()}).passthrough().nullable().optional()}).passthrough(),px=T({type:x()}).passthrough(),fx=T({id:x(),object:re("response").optional(),created_at:E().optional(),status:x().nullable().optional(),model:x().optional(),output:K(px).optional(),output_text:x().optional(),usage:mx.nullable().optional(),error:Ts().optional()}).passthrough();T({type:x()}).passthrough();function hx(e){try{const n=JSON.parse(e),s=ux.safeParse(n);return s.success?s.data:null}catch{return null}}function xx(e){try{const n=JSON.parse(e),s=fx.safeParse(n);return s.success?s.data:null}catch{return null}}const Hd=T({input:E().int().nonnegative(),output:E().int().nonnegative(),cacheCreate:E().int().nonnegative(),cacheRead:E().int().nonnegative(),total:E().int().nonnegative()}),gx=T({id:At,sessionLogNumber:E().int().positive().optional(),timestamp:x(),provider:x().nullable(),model:x().nullable(),apiFormat:ue(["anthropic","openai","unknown"]),method:x(),path:x(),status:E().nullable(),isStreaming:_e(),hasError:_e(),error:x().nullable(),latencyMs:E().nullable(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),tokens:T({input:E().nullable(),output:E().nullable(),cacheCreate:E().nullable(),cacheRead:E().nullable()}),sessionId:x().nullable(),userAgent:x().nullable().optional(),clientPid:E().nullable().optional(),clientProjectFolder:x().nullable().optional()}),Wd=T({id:x(),status:ue(["active","failed","completed","empty"]),logCoverage:ue(["recent","history"]),source:ue(["explicit","client-process","client-connection","provider-test"]).nullable(),runtimeMode:ue(["in-process","worker-thread","child-process"]).nullable(),createdAt:x().nullable(),updatedAt:x().nullable(),requestCount:E().int().nonnegative(),activeRequests:E().int().nonnegative(),completedRequests:E().int().nonnegative(),failedRequests:E().int().nonnegative(),queuedTasks:E().int().nonnegative(),runningTasks:E().int().nonnegative(),lastTaskError:x().nullable(),logCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),models:K(x()),providers:K(x()),tokenUsage:Hd,lastLogId:At.nullable(),lastModel:x().nullable(),clientUserAgent:x().nullable().optional(),clientPid:E().nullable(),clientProjectFolder:x().nullable(),inspectorPath:x(),inspectorUrl:x(),apiPath:x(),apiUrl:x(),compactLogsPath:x(),compactLogsUrl:x(),latestLogLimit:E().int().positive(),latestLogs:K(gx)}),Hs=ue(["created","running","completed","failed","cancelled"]),_i=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),bx=ue(["run-created","session-started","request","session-finished","evidence-exported"]),vx=ue(["info","success","warning","error"]),yx=T({timestamp:x(),kind:bx,severity:vx,title:x(),details:x(),logId:At.nullable(),status:E().nullable(),model:x().nullable(),provider:x().nullable(),latencyMs:E().nullable(),isStreaming:_e().nullable()}),wx=ue(["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"]),Vd=T({outcome:ue(["success","failure","active","unknown"]),severity:ue(["none","low","medium","high"]),category:wx,summary:x(),evidenceLogIds:K(At),hints:K(x())}),Ti=T({status:ue(["PASS","FAIL","RUNNING","UNKNOWN"]),summary:x(),markdown:x()}),Kd=Ti,Ei=T({id:x(),sessionId:x(),groupId:x().nullable().default(null),title:x(),task:x().nullable(),project:x().nullable(),agent:x().nullable(),status:Hs,tags:K(x()),metadata:ze(x(),We),evidence:_i.nullable(),createdAt:x(),updatedAt:x()});T({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:Hs.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()}).optional();T({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:Hs.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()});T({includeHistory:_e().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();T({run:Ei,evidence:_i,session:Wd.nullable(),timeline:K(yx),classification:Vd,jenkinsReport:Ti});const jx=T({run:Ei,classification:Vd,evidence:_i.nullable(),jenkinsReport:Ti.nullable(),sessionId:x(),inspectorUrl:x().nullable(),evidenceMarkdownPath:x().nullable(),updatedAt:x()});T({failures:K(jx),total:E().int().nonnegative(),limit:E().int().positive()});const Ri=ue(["created","running","completed","failed","cancelled"]),Mi=ue(["evaluation","batch","manual"]),Ai=T({jsonPath:x(),markdownPath:x(),htmlPath:x(),exportedAt:x()}),Gd=T({id:x(),groupId:x(),sessionId:x(),runId:x().nullable(),label:x().nullable(),agent:x().nullable(),provider:x().nullable(),model:x().nullable(),status:Hs.nullable(),metadata:ze(x(),We),addedAt:x(),updatedAt:x()}),Ii=T({id:x(),title:x(),kind:Mi,task:x().nullable(),project:x().nullable(),status:Ri,tags:K(x()),metadata:ze(x(),We),evidence:Ai.nullable(),members:K(Gd),createdAt:x(),updatedAt:x()});T({groupId:x().min(1).optional(),title:x().min(1).optional(),kind:Mi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ri.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()}).optional();T({title:x().min(1).optional(),kind:Mi.optional(),task:x().nullable().optional(),project:x().nullable().optional(),status:Ri.optional(),tags:K(x()).optional(),metadata:ze(x(),We).optional()});T({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:Hs.nullable().optional(),metadata:ze(x(),We).optional()});T({includeHistory:_e().optional(),latestLogLimit:E().int().positive().max(50).optional()}).optional();T({deleteEvidence:_e().optional()});const Jd=T({groupId:x(),deleted:_e(),evidenceDeleted:_e(),evidencePath:x().nullable()}),Yd=T({deleted:E().int().nonnegative(),groups:K(Jd)}),Xd=T({member:Gd,run:Ei.nullable(),session:Wd.nullable()}),Zd=T({memberCount:E().int().nonnegative(),sessionsWithData:E().int().nonnegative(),missingSessions:E().int().nonnegative(),requestCount:E().int().nonnegative(),errorCount:E().int().nonnegative(),tokenUsage:Hd,models:K(x()),providers:K(x()),completedMembers:E().int().nonnegative(),failedMembers:E().int().nonnegative(),runningMembers:E().int().nonnegative()}),Sx=T({group:Ii,evidence:Ai,members:K(Xd).nullable(),markdown:x(),summary:Zd.nullable(),report:Kd.nullable()}),Nx=T({group:Ii,evidence:Ai,members:K(Xd),summary:Zd,jenkinsReport:Kd}),Qd=T({groups:K(Ii)}),Cx=T({sessionId:x(),imported:E().int().nonnegative(),skipped:E().int().nonnegative(),warnings:K(x()),logs:K(Is)}),Uo=10,za=600,Bo=60,$a=600,qo="time",Pi="simple",eu=ue(["time","full"]),kx=ue(["simple","full"]),fr=T({stripClaudeCodeBillingHeader:_e(),hasSeenOnboarding:_e().default(!1),slowResponseThresholdSeconds:E().int().min(0).max(za).default(Uo),providerTestTimeoutSeconds:E().int().min(1).max($a).default(Bo),timeDisplayFormat:eu.default(qo),captureMode:kx.default(Pi)}),Gn="/api/config";async function _x(e){return Ge(e,fr,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function no(e){return Ge(Gn,fr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function Li(){const e=Et(Gn,_x,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=Ad(),s=e.data?.stripClaudeCodeBillingHeader??!1,o=e.data?.captureMode??Pi,r=e.data?.slowResponseThresholdSeconds??Uo,a=e.data?.providerTestTimeoutSeconds??Bo,i=e.data?.timeDisplayFormat??qo,c=f=>({stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:e.data?.hasSeenOnboarding??!1,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Uo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Bo,timeDisplayFormat:e.data?.timeDisplayFormat??qo,captureMode:o,...f}),d=async f=>{await n(Gn,no({stripClaudeCodeBillingHeader:f}),{optimisticData:c({stripClaudeCodeBillingHeader:f}),rollbackOnError:!0,revalidate:!1})},m=async f=>{await n(Gn,no({slowResponseThresholdSeconds:f}),{optimisticData:c({slowResponseThresholdSeconds:f}),rollbackOnError:!0,revalidate:!1})},u=async f=>{await n(Gn,no({timeDisplayFormat:f}),{optimisticData:c({timeDisplayFormat:f}),rollbackOnError:!0,revalidate:!1})},p=async f=>{await n(Gn,no({providerTestTimeoutSeconds:f}),{optimisticData:c({providerTestTimeoutSeconds:f}),rollbackOnError:!0,revalidate:!1})};return{strip:s,captureMode:o,slowResponseThresholdSeconds:r,providerTestTimeoutSeconds:a,timeDisplayFormat:i,isLoading:e.isLoading,isError:e.error!==void 0,setStrip:d,setSlowResponseThresholdSeconds:m,setProviderTestTimeoutSeconds:p,setTimeDisplayFormat:u}}const tu=(...e)=>e.filter((n,s,o)=>!!n&&n.trim()!==""&&o.indexOf(n)===s).join(" ").trim();const Tx=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const Ex=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,s,o)=>o?o.toUpperCase():s.toLowerCase());const Fl=e=>{const n=Ex(e);return n.charAt(0).toUpperCase()+n.slice(1)};var Rx={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 Mx=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1};const Ax=l.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:s=2,absoluteStrokeWidth:o,className:r="",children:a,iconNode:i,...c},d)=>l.createElement("svg",{ref:d,...Rx,width:n,height:n,stroke:e,strokeWidth:o?Number(s)*24/Number(n):s,className:tu("lucide",r),...!a&&!Mx(c)&&{"aria-hidden":"true"},...c},[...i.map(([m,u])=>l.createElement(m,u)),...Array.isArray(a)?a:[a]]));const q=(e,n)=>{const s=l.forwardRef(({className:o,...r},a)=>l.createElement(Ax,{ref:a,iconNode:n,className:tu(`lucide-${Tx(Fl(e))}`,`lucide-${e}`,o),...r}));return s.displayName=Fl(e),s};const Ix=[["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"}]],Px=q("a-large-small",Ix);const Lx=[["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"}]],Ox=q("activity",Lx);const Dx=[["path",{d:"m7 7 10 10",key:"1fmybs"}],["path",{d:"M17 7v10H7",key:"6fjiku"}]],zx=q("arrow-down-right",Dx);const $x=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Fx=q("arrow-down",$x);const Ux=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],Bx=q("arrow-left",Ux);const qx=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],Hx=q("arrow-up-right",qx);const Wx=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Vx=q("arrow-up",Wx);const Kx=[["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"}]],Oi=q("beaker",Kx);const Gx=[["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"}]],Jx=q("bell",Gx);const Yx=[["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"}]],Xx=q("blocks",Yx);const Zx=[["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"}]],Qx=q("brain-circuit",Zx);const e0=[["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"}]],nu=q("brain",e0);const t0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Oe=q("check",t0);const n0=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ve=q("chevron-down",n0);const s0=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],o0=q("chevron-left",s0);const r0=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],it=q("chevron-right",r0);const a0=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Di=q("chevron-up",a0);const i0=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],l0=q("chevrons-down",i0);const c0=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],d0=q("chevrons-left",c0);const u0=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],m0=q("chevrons-right",u0);const p0=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],f0=q("chevrons-up",p0);const h0=[["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"}]],os=q("circle-alert",h0);const x0=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ws=q("circle-check-big",x0);const g0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Fa=q("circle-check",g0);const b0=[["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"}]],v0=q("circle-question-mark",b0);const y0=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],w0=q("circle-stop",y0);const j0=[["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"}]],su=q("circle-x",j0);const S0=[["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"}]],N0=q("clapperboard",S0);const C0=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],k0=q("clock-3",C0);const _0=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Wt=q("clock",_0);const T0=[["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"}]],E0=q("cloud-upload",T0);const R0=[["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"}]],ou=q("code-xml",R0);const M0=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],A0=q("columns-2",M0);const I0=[["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"}]],St=q("copy",I0);const P0=[["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"}]],L0=q("cpu",P0);const O0=[["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"}]],Vs=q("download",O0);const D0=[["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"}]],z0=q("ellipsis",D0);const $0=[["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"}]],zi=q("external-link",$0);const F0=[["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"}]],U0=q("eye-off",F0);const B0=[["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"}]],ru=q("eye",B0);const q0=[["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"}]],H0=q("file-braces",q0);const W0=[["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"}]],V0=q("file-diff",W0);const K0=[["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"}]],G0=q("file-search",K0);const J0=[["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"}]],Y0=q("file-terminal",J0);const X0=[["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"}]],Z0=q("file-text",X0);const Q0=[["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"}]],eg=q("flag",Q0);const tg=[["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"}]],au=q("flask-conical",tg);const ng=[["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"}]],sg=q("folder-open",ng);const og=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],$i=q("gauge",og);const rg=[["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"}]],ag=q("git-compare-arrows",rg);const ig=[["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"}]],iu=q("globe",ig);const lg=[["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"}]],lu=q("history",lg);const cg=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],dg=q("info",cg);const ug=[["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"}]],Ul=q("layers",ug);const mg=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Ae=q("loader-circle",mg);const pg=[["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"}]],fg=q("lock",pg);const hg=[["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"}]],xg=q("maximize-2",hg);const gg=[["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"}]],hr=q("message-square",gg);const bg=[["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"}]],vg=q("minimize-2",bg);const yg=[["path",{d:"M5 12h14",key:"1ays0h"}]],cu=q("minus",yg);const wg=[["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"}]],jg=q("monitor",wg);const Sg=[["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"}]],Ng=q("moon",Sg);const Cg=[["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"}]],kg=q("mouse-pointer-click",Cg);const _g=[["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"}]],Tg=q("network",_g);const Eg=[["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"}]],Rg=q("octagon-alert",Eg);const Mg=[["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"}]],Ag=q("package-check",Mg);const Ig=[["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"}]],Pg=q("panel-right-close",Ig);const Lg=[["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"}]],Og=q("panel-right-open",Lg);const Dg=[["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"}]],du=q("pencil",Dg);const zg=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Bl=q("plus",zg);const $g=[["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"}]],ql=q("radio",$g);const Fg=[["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"}]],yt=q("refresh-cw",Fg);const Ug=[["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"}]],uu=q("rocket",Ug);const Bg=[["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"}]],mu=q("rotate-ccw",Bg);const qg=[["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"}]],Ho=q("rotate-cw",qg);const Hg=[["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"}]],Wg=q("rows-3",Hg);const Vg=[["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"}]],Kg=q("save",Vg);const Gg=[["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"}]],Jg=q("scan",Gg);const Yg=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],Xg=q("search",Yg);const Zg=[["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"}]],Qg=q("send",Zg);const e1=[["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"}]],t1=q("server",e1);const n1=[["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"}]],s1=q("settings",n1);const o1=[["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"}]],r1=q("shield-alert",o1);const a1=[["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"}]],Hl=q("shield-check",a1);const i1=[["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"}]],Wo=q("siren",i1);const l1=[["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"}]],Ua=q("sparkles",l1);const c1=[["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"}]],d1=q("sun",c1);const u1=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],In=q("terminal",u1);const m1=[["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"}]],pu=q("timer",m1);const p1=[["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"}]],an=q("trash-2",p1);const f1=[["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"}]],rn=q("triangle-alert",f1);const h1=[["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"}]],fu=q("upload",h1);const x1=[["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"}]],g1=q("wifi-off",x1);const b1=[["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"}]],v1=q("wifi",b1);const y1=[["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"}]],Ks=q("wrench",y1);const w1=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Gs=q("x",w1);const j1=[["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"}]],Ps=q("zap",j1),Ba="/api/config";async function S1(e){return Ge(e,fr,void 0,n=>`Failed to fetch ${e}: ${n.status}`)}async function N1(e){return Ge(Ba,fr,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e)},n=>`PATCH failed with status ${n.status}`)}function C1(){const e=Et(Ba,S1,{revalidateOnFocus:!1,revalidateIfStale:!1}),{mutate:n}=Ad(),s=e.data?.hasSeenOnboarding??!1,o=e.data?.captureMode??Pi,r=async()=>{await n(Ba,N1({hasSeenOnboarding:!0}),{optimisticData:{stripClaudeCodeBillingHeader:e.data?.stripClaudeCodeBillingHeader??!1,hasSeenOnboarding:!0,slowResponseThresholdSeconds:e.data?.slowResponseThresholdSeconds??Uo,providerTestTimeoutSeconds:e.data?.providerTestTimeoutSeconds??Bo,timeDisplayFormat:e.data?.timeDisplayFormat??qo,captureMode:o},rollbackOnError:!0,revalidate:!1})};return{hasSeenOnboarding:s,captureMode:o,isLoading:e.isLoading,markSeen:r}}function k1({expanded:e,onToggle:n,onDismiss:s}){const o=e?"grid":"hidden sm:grid";return t.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:t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(dg,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-medium text-foreground",children:"Inspector ready"}),t.jsx("span",{className:"hidden truncate text-xs text-muted-foreground sm:inline",children:"Request, response, tool, timing, token, replay, and memory signals are active."})]}),t.jsx("div",{className:"mt-1 text-xs leading-relaxed text-muted-foreground sm:hidden",children:"Core capture is active."}),t.jsxs("div",{className:`${o} mt-2 gap-x-4 gap-y-1 text-xs leading-relaxed text-muted-foreground sm:grid-cols-2`,children:[t.jsxs("div",{children:[t.jsx("strong",{children:"Evidence"}),": logs, sessions, groups, and MCP exports are available."]}),t.jsxs("div",{children:[t.jsx("strong",{children:"Network"}),": replace ",t.jsx("code",{children:"localhost"})," if containers differ."]})]})]}),t.jsx("button",{type:"button",onClick:n,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:t.jsx(Ve,{className:`size-3.5 transition-transform ${e?"rotate-180":""}`})}),t.jsxs("button",{type:"button",onClick:s,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:[t.jsx(Oe,{className:"size-3.5"}),"Got it"]}),t.jsx("button",{type:"button",onClick:s,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:t.jsx(Gs,{className:"size-3.5"})})]})})}function _1(){const{hasSeenOnboarding:e,isLoading:n,markSeen:s}=C1(),[o,r]=l.useState(!1);return n||e?null:t.jsx(k1,{expanded:o,onToggle:()=>r(a=>!a),onDismiss:()=>{s()}})}const T1="3.0.47",hu={version:T1};function ks(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const xu="[REDACTED]",E1=/(^|[-_])(api[-_]?key|authorization|cookie|token|secret|password|access[-_]?token|refresh[-_]?token)([-_]|$)/i,R1=[/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],Wl=200,M1=25e6,gu=50,A1=1e4;function I1(e){return e<1024?`${e} chars`:e<1024*1024?`${Math.ceil(e/1024)} KB`:`${Math.ceil(e/(1024*1024))} MB`}function P1(e){let n=0;for(const s of e)n+=s.rawRequestBody?.length??0,n+=s.responseText?.length??0;return n}function L1(e){if(e.length>Wl)return`Export is limited to ${Wl} logs at once. Narrow the filter and try again.`;const n=P1(e);return n>M1?`Export is too large (${I1(n)} of text). Narrow the filter and try again.`:null}function so(e){return e?.aborted===!0?{ok:!1,message:"Export canceled.",canceled:!0}:null}async function O1(e,n){try{const s=await Xn(`/api/logs/${e}/chunks`,A1,{signal:n});if(!s.ok)return null;const o=await s.json();return JSON.stringify(o,null,2)}catch{return null}}function qa(e){if(Array.isArray(e))return e.map(s=>qa(s));if(!ks(e))return e;const n={};for(const[s,o]of Object.entries(e))n[s]=E1.test(s)?xu:qa(o);return n}function D1(e){const n=s=>{let o=s;for(const r of R1)o=o.replace(r,xu);return o};try{const s=JSON.parse(e);return n(JSON.stringify(qa(s),null,2))}catch{return n(e)}}function Kr(e,n){return n==="redacted"?D1(e):e}function z1(e,n){return{...e,rawRequestBody:null,responseText:null,rawHeaders:n==="raw"?e.rawHeaders:void 0,headers:n==="raw"?e.headers:void 0,streamingChunks:void 0,bodyContentMode:"compact"}}function $1(e,n,s,o=new Date().toISOString()){return{version:hu.version,exportedAt:o,mode:n,redacted:n==="redacted",logCount:e.length,logIds:e.map(r=>r.id),streamingChunkExportLimit:gu,streamingChunkLogIds:s.map(r=>r.id)}}async function F1(e,n="redacted",s={}){const o=so(s.signal);if(o!==null)return o;const r=L1(e);if(r!==null)return{ok:!1,message:r};const{default:a}=await Dt(async()=>{const{default:h}=await import("./jszip.min-B7tfyE-I.js").then(g=>g.j);return{default:h}},__vite__mapDeps([0,1,2]),import.meta.url),i=new a,c=n==="redacted"?"redacted":"raw",d=e.filter(h=>h.streaming).slice(0,gu);i.file("manifest.json",JSON.stringify($1(e,n,d),null,2)),i.file("logs.json",JSON.stringify(e.map(h=>z1(h,n)),null,2));for(const h of e){const g=so(s.signal);if(g!==null)return g;h.rawRequestBody!==null&&i.file(`#${h.id}.Request.json`,Kr(h.rawRequestBody,n)),h.responseText!==null&&i.file(`#${h.id}.Response.json`,Kr(h.responseText,n))}for(const h of d){const g=so(s.signal);if(g!==null)return g;const b=await O1(h.id,s.signal);b!==null&&i.file(`#${h.id}.SSE.Response.json`,Kr(b,n))}const m=await i.generateAsync({type:"blob"}),u=so(s.signal);if(u!==null)return u;const p=URL.createObjectURL(m),f=document.createElement("a");return f.href=p,f.download=`agent-inspector-export-${c}-${new Date().toISOString().slice(0,10)}.zip`,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(p),{ok:!0}}function U1(e){const n=Vr(e,"/proxy"),s=Vr(e,"/proxy/v1"),o=Vr(e,"/api/mcp");return n===null||s===null||o===null?null:{proxy:n,openAiV1:s,mcp:o}}function B1(){const e=Sh();return e.ok?U1(e.runtime):null}function Fi(e){const n=()=>e(B1());return n(),typeof globalThis.addEventListener!="function"||typeof globalThis.removeEventListener!="function"?()=>{}:(globalThis.addEventListener($l,n),()=>globalThis.removeEventListener($l,n))}function Ha(e,n){switch(n){case"full":return e;case"time":return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}}function xr(e,n,s){return`${Ha(e,s)} - ${Ha(n,s)}`}const Ui="agent-inspector.theme";function bu(e){switch(e){case"light":return"light";case"dark":return"dark";case"eye-care":return"eye-care";case null:return"dark";default:return"dark"}}function Gr(e){typeof document>"u"||(document.documentElement.dataset.theme=e)}function q1(){if(typeof window>"u")return"dark";try{return bu(window.localStorage.getItem(Ui))}catch{return"dark"}}function H1(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ui,e)}catch{}}function W1(){const[e,n]=l.useState(q1),s=l.useCallback(o=>{n(o),Gr(o),H1(o)},[]);return l.useEffect(()=>{Gr(e)},[e]),l.useEffect(()=>{function o(r){if(r.key!==Ui)return;const a=bu(r.newValue);n(a),Gr(a)}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)},[]),{themeMode:e,setThemeMode:s}}const Bi="agent-inspector.uiScale",V1=1.25,K1=2200,G1=3e3,J1=12;function Jr(e,n){return Number.isFinite(e)&&e>0?e:n}function qi(e){switch(e){case"auto":return"auto";case"100":return"100";case"125":return"125";case"150":return"150";case null:return"auto";default:return"auto"}}function Y1(e,n){switch(e){case"100":return 1;case"125":return 1.25;case"150":return 1.5;case"auto":{const s=Jr(n.viewportWidth,1280),o=Jr(n.screenWidth,s),r=Jr(n.devicePixelRatio,1),a=Math.min(s,o);return r>V1?1:a>=G1?1.25:a>=K1?1.125:1}}}function X1(e){return`${Math.round(e*100)}%`}function Yr(e,n){return Math.max(J1,e*n)}function Z1(){if(typeof window>"u")return{viewportWidth:1280,screenWidth:1280,devicePixelRatio:1};const e=typeof window.screen>"u"?window.innerWidth:window.screen.availWidth;return{viewportWidth:window.innerWidth,screenWidth:e,devicePixelRatio:window.devicePixelRatio}}function Xr(e){const n=Y1(e,Z1());if(typeof document>"u")return n;const s=document.documentElement;return s.dataset.uiScale=e,s.dataset.uiScaleResolved=String(Math.round(n*100)),s.style.setProperty("--inspector-ui-scale",String(n)),s.style.setProperty("--inspector-root-font-size",`${String(16*n)}px`),s.style.setProperty("--inspector-font-9",`${String(Yr(9,n))}px`),s.style.setProperty("--inspector-font-10",`${String(Yr(10,n))}px`),s.style.setProperty("--inspector-font-11",`${String(Yr(11,n))}px`),s.style.setProperty("--inspector-font-13",`${String(13*n)}px`),n}function Q1(){if(typeof window>"u")return"auto";try{return qi(window.localStorage.getItem(Bi))}catch{return"auto"}}function eb(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Bi,e)}catch{}}function tb(){const[e,n]=l.useState(Q1),[s,o]=l.useState(1),r=l.useCallback(a=>{n(a),eb(a),o(Xr(a))},[]);return l.useEffect(()=>{const a=()=>{o(Xr(e))};if(a(),e==="auto")return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e]),l.useEffect(()=>{const a=i=>{if(i.key!==Bi)return;const c=qi(i.newValue);n(c),o(Xr(c))};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]),{uiScalePreference:e,resolvedUiScale:s,setUiScalePreference:r}}const _n=64,Wa=256,nb=64,sb=ue(["invalid-page-request","search-limit-exceeded","provider-model-limit-exceeded","sse-capacity-exceeded","provider-test-capacity-exceeded","proxy-capacity-exceeded"]),ob=Ot([re(400),re(413),re(429),re(503)]);T({error:x().min(1).max(300),code:sb,status:ob,resource:x().min(1).max(80),limit:E().int().positive(),retryable:_e()});function oo(){return x().refine(e=>{if(e.length===0)return!0;try{const n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}},"Must be a valid http(s) URL")}const Hi=x().max(Wa),rb=K(Hi).max(_n),ab=T({model:Hi.min(1),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),source:ue(["manual","registry"]).optional(),sourceUrl:x().optional(),updatedAt:x().optional()}),ib=K(ab).max(nb),lb=T({id:x(),name:x(),apiKey:x(),model:Hi.optional(),models:rb.optional().default([]),format:ue(["anthropic","openai"]).optional(),baseUrl:oo().optional(),anthropicBaseUrl:oo().optional(),openaiBaseUrl:oo().optional(),openaiResponsesBaseUrl:oo().optional(),authHeader:ue(["bearer","x-api-key"]).optional().default("bearer"),apiDocsUrl:x().optional(),modelMetadataUrl:x().optional(),modelMetadata:ib.optional(),source:ue(["company","personal"]).optional(),createdAt:x(),updatedAt:x()}),cb="configured",Vo=lb.extend({apiKey:re(cb)});async function db(e){return Ge(e,Vo.array(),void 0,n=>`Failed to fetch ${e}: ${n.status}`)}function Wi(){const e=Et("/api/providers",db,{revalidateOnFocus:!1,revalidateIfStale:!1});return{providers:e.data??[],isLoading:e.isLoading,isError:e.error,mutate:e.mutate}}function Vl(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function ub(...e){return n=>{let s=!1;const o=e.map(r=>{const a=Vl(r,n);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():Vl(e[r],null)}}}}function Te(...e){return l.useCallback(ub(...e),e)}function rs(e){const n=l.forwardRef((s,o)=>{let{children:r,...a}=s,i=null,c=!1;const d=[];Kl(r)&&typeof ro=="function"&&(r=ro(r._payload)),l.Children.forEach(r,f=>{if(gb(f)){c=!0;const h=f;let g="child"in h.props?h.props.child:h.props.children;Kl(g)&&typeof ro=="function"&&(g=ro(g._payload)),i=fb(h,g),d.push(i?.props?.children)}else d.push(f)}),i?i=l.cloneElement(i,void 0,d):!c&&l.Children.count(r)===1&&l.isValidElement(r)&&(i=r);const m=i?xb(i):void 0,u=Te(o,m);if(!i){if(r||r===0)throw new Error(c?wb(e):yb(e));return r}const p=hb(a,i.props??{});return i.type!==l.Fragment&&(p.ref=o?u:m),l.cloneElement(i,p)});return n.displayName=`${e}.Slot`,n}var mb=rs("Slot"),vu=Symbol.for("radix.slottable");function pb(e){const n=s=>"child"in s?s.children(s.child):s.children;return n.displayName=`${e}.Slottable`,n.__radixId=vu,n}var fb=(e,n)=>{if("child"in e.props){const s=e.props.child;return l.isValidElement(s)?l.cloneElement(s,void 0,e.props.children(s.props.children)):null}return l.isValidElement(n)?n:null};function hb(e,n){const s={...n};for(const o in n){const r=e[o],a=n[o];/^on[A-Z]/.test(o)?r&&a?s[o]=(...c)=>{const d=a(...c);return r(...c),d}:r&&(s[o]=r):o==="style"?s[o]={...r,...a}:o==="className"&&(s[o]=[r,a].filter(Boolean).join(" "))}return{...e,...s}}function xb(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function gb(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===vu}var bb=Symbol.for("react.lazy");function Kl(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===bb&&"_payload"in e&&vb(e._payload)}function vb(e){return typeof e=="object"&&e!==null&&"then"in e}var yb=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,wb=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,ro=pr[" use ".trim().toString()],jb=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],xe=jb.reduce((e,n)=>{const s=rs(`Primitive.${n}`),o=l.forwardRef((r,a)=>{const{asChild:i,...c}=r,d=i?s:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(d,{...c,ref:a})});return o.displayName=`Primitive.${n}`,{...e,[n]:o}},{});function Sb(e,n){e&&ms.flushSync(()=>e.dispatchEvent(n))}var yu=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"}),Nb="VisuallyHidden",wu=l.forwardRef((e,n)=>t.jsx(xe.span,{...e,ref:n,style:{...yu,...e.style}}));wu.displayName=Nb;var Cb=wu;function Jt(e,n=[]){let s=[];function o(a,i){const c=l.createContext(i);c.displayName=a+"Context";const d=s.length;s=[...s,i];const m=p=>{const{scope:f,children:h,...g}=p,b=f?.[e]?.[d]||c,y=l.useMemo(()=>g,Object.values(g));return t.jsx(b.Provider,{value:y,children:h})};m.displayName=a+"Provider";function u(p,f,h={}){const{optional:g=!1}=h,b=f?.[e]?.[d]||c,y=l.useContext(b);if(y)return y;if(i!==void 0)return i;if(!g)throw new Error(`\`${p}\` must be used within \`${a}\``)}return[m,u]}const r=()=>{const a=s.map(i=>l.createContext(i));return function(c){const d=c?.[e]||a;return l.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return r.scopeName=e,[o,kb(r,...n)]}function kb(...e){const n=e[0];if(e.length===1)return n;const s=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((c,{useScope:d,scopeName:m})=>{const p=d(a)[`__scope${m}`];return{...c,...p}},{});return l.useMemo(()=>({[`__scope${n.scopeName}`]:i}),[i])}};return s.scopeName=n.scopeName,s}function ju(e){const n=e+"CollectionProvider",[s,o]=Jt(n),[r,a]=s(n,{collectionRef:{current:null},itemMap:new Map}),i=b=>{const{scope:y,children:w}=b,v=l.useRef(null),j=l.useRef(new Map).current;return t.jsx(r,{scope:y,itemMap:j,collectionRef:v,children:w})};i.displayName=n;const c=e+"CollectionSlot",d=rs(c),m=l.forwardRef((b,y)=>{const{scope:w,children:v}=b,j=a(c,w),S=Te(y,j.collectionRef);return t.jsx(d,{ref:S,children:v})});m.displayName=c;const u=e+"CollectionItemSlot",p="data-radix-collection-item",f=rs(u),h=l.forwardRef((b,y)=>{const{scope:w,children:v,...j}=b,S=l.useRef(null),N=Te(y,S),C=a(u,w);return l.useEffect(()=>(C.itemMap.set(S,{ref:S,...j}),()=>{C.itemMap.delete(S)})),t.jsx(f,{[p]:"",ref:N,children:v})});h.displayName=u;function g(b){const y=a(e+"CollectionConsumer",b);return l.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const j=Array.from(v.querySelectorAll(`[${p}]`));return Array.from(y.itemMap.values()).sort((C,R)=>j.indexOf(C.ref.current)-j.indexOf(R.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:m,ItemSlot:h},g,o]}function de(e,n,{checkForDefaultPrevented:s=!0}={}){return function(r){if(e?.(r),s===!1||!r||!r.defaultPrevented)return n?.(r)}}var Ue=globalThis?.document?l.useLayoutEffect:()=>{},_b=pr[" useInsertionEffect ".trim().toString()]||Ue;function En({prop:e,defaultProp:n,onChange:s=()=>{},caller:o}){const[r,a,i]=Tb({defaultProp:n,onChange:s}),c=e!==void 0,d=c?e:r;{const u=l.useRef(e!==void 0);l.useEffect(()=>{const p=u.current;p!==c&&console.warn(`${o} is changing from ${p?"controlled":"uncontrolled"} to ${c?"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.`),u.current=c},[c,o])}const m=l.useCallback(u=>{if(c){const p=Eb(u)?u(e):u;p!==e&&i.current?.(p)}else a(u)},[c,e,a,i]);return[d,m]}function Tb({defaultProp:e,onChange:n}){const[s,o]=l.useState(e),r=l.useRef(s),a=l.useRef(n);return _b(()=>{a.current=n},[n]),l.useEffect(()=>{r.current!==s&&(a.current?.(s),r.current=s)},[s,r]),[s,o,a]}function Eb(e){return typeof e=="function"}function Rb(e,n){return l.useReducer((s,o)=>n[s][o]??s,e)}var lt=e=>{const{present:n,children:s}=e,o=Mb(n),r=typeof s=="function"?s({present:o.isPresent}):l.Children.only(s),a=Ab(o.ref,Ib(r));return typeof s=="function"||o.isPresent?l.cloneElement(r,{ref:a}):null};lt.displayName="Presence";function Mb(e){const[n,s]=l.useState(),o=l.useRef(null),r=l.useRef(e),a=l.useRef("none"),i=l.useRef(void 0),c=e?"mounted":"unmounted",[d,m]=Rb(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return l.useEffect(()=>{d==="mounted"?(a.current=i.current??bs(o.current),i.current=void 0):a.current="none"},[d]),Ue(()=>{const u=o.current,p=r.current;if(p!==e){const h=a.current,g=bs(u);e?(i.current=g,m("MOUNT")):g==="none"||u?.display==="none"?m("UNMOUNT"):m(p&&h!==g?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,m]),Ue(()=>{if(n){let u;const p=n.ownerDocument.defaultView??window,f=g=>{const y=bs(o.current).includes(CSS.escape(g.animationName));if(g.target===n&&y&&(m("ANIMATION_END"),!r.current)){const w=n.style.animationFillMode;n.style.animationFillMode="forwards",u=p.setTimeout(()=>{n.style.animationFillMode==="forwards"&&(n.style.animationFillMode=w)})}},h=g=>{g.target===n&&(a.current=bs(o.current))};return n.addEventListener("animationstart",h),n.addEventListener("animationcancel",f),n.addEventListener("animationend",f),()=>{p.clearTimeout(u),n.removeEventListener("animationstart",h),n.removeEventListener("animationcancel",f),n.removeEventListener("animationend",f)}}else m("ANIMATION_END")},[n,m]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:l.useCallback(u=>{if(u){const p=getComputedStyle(u);o.current=p,i.current=bs(p)}else o.current=null;s(u)},[])}}function Gl(e,n){if(typeof e=="function")return e(n);e!=null&&(e.current=n)}function Ab(...e){const n=l.useRef(e);return n.current=e,l.useCallback(s=>{const o=n.current;let r=!1;const a=o.map(i=>{const c=Gl(i,s);return!r&&typeof c=="function"&&(r=!0),c});if(r)return()=>{for(let i=0;i<a.length;i++){const c=a[i];typeof c=="function"?c():Gl(o[i],null)}}},[])}function bs(e){return e?.animationName||"none"}function Ib(e){let n=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning;return s?e.ref:(n=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=n&&"isReactWarning"in n&&n.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Pb=pr[" useId ".trim().toString()]||(()=>{}),Lb=0;function Rt(e){const[n,s]=l.useState(Pb());return Ue(()=>{s(o=>o??String(Lb++))},[e]),e||(n?`radix-${n}`:"")}var gr="Collapsible",[Ob]=Jt(gr),[Db,Vi]=Ob(gr),Su=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,open:o,defaultOpen:r,disabled:a,onOpenChange:i,...c}=e,[d,m]=En({prop:o,defaultProp:r??!1,onChange:i,caller:gr});return t.jsx(Db,{scope:s,disabled:a,contentId:Rt(),open:d,onOpenToggle:l.useCallback(()=>m(u=>!u),[m]),children:t.jsx(xe.div,{"data-state":Gi(d),"data-disabled":a?"":void 0,...c,ref:n})})});Su.displayName=gr;var Nu="CollapsibleTrigger",Cu=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,...o}=e,r=Vi(Nu,s);return t.jsx(xe.button,{type:"button","aria-controls":r.open?r.contentId:void 0,"aria-expanded":r.open||!1,"data-state":Gi(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...o,ref:n,onClick:de(e.onClick,r.onOpenToggle)})});Cu.displayName=Nu;var Ki="CollapsibleContent",ku=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=Vi(Ki,e.__scopeCollapsible);return t.jsx(lt,{present:s||r.open,children:({present:a})=>t.jsx(zb,{...o,ref:n,present:a})})});ku.displayName=Ki;var zb=l.forwardRef((e,n)=>{const{__scopeCollapsible:s,present:o,children:r,...a}=e,i=Vi(Ki,s),[c,d]=l.useState(o),m=l.useRef(null),u=Te(n,m),p=l.useRef(0),f=p.current,h=l.useRef(0),g=h.current,b=i.open||c,y=l.useRef(b),w=l.useRef(void 0);return l.useEffect(()=>{const v=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(v)},[]),Ue(()=>{const v=m.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,y.current||(v.style.transitionDuration=w.current.transitionDuration,v.style.animationName=w.current.animationName),d(o)}},[i.open,o]),t.jsx(xe.div,{"data-state":Gi(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!b,...a,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:b&&r})});function Gi(e){return e?"open":"closed"}var $b=Su,Fb=l.createContext(void 0);function br(e){const n=l.useContext(Fb);return e||n||"ltr"}function He(e){const n=l.useRef(e);return l.useEffect(()=>{n.current=e}),l.useMemo(()=>((...s)=>n.current?.(...s)),[])}var Ub="DismissableLayer",Va="dismissableLayer.update",Bb="dismissableLayer.pointerDownOutside",qb="dismissableLayer.focusOutside",Jl,Ji=l.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),vr=l.forwardRef((e,n)=>{const{disableOutsidePointerEvents:s=!1,deferPointerDownOutside:o=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:c,onDismiss:d,...m}=e,u=l.useContext(Ji),[p,f]=l.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=l.useState({}),b=Te(n,f),y=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=w?y.indexOf(w):-1,j=p?y.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,N=j>=v,C=l.useRef(!1),R=Gb(k=>{a?.(k),c?.(k),k.defaultPrevented||d?.()},{ownerDocument:h,deferPointerDownOutside:o,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:l.useCallback(k=>{if(!(k instanceof Node))return!1;const A=[...u.branches].some(D=>D.contains(k));return N&&!A},[u.branches,N])}),I=Jb(k=>{if(o&&C.current)return;const A=k.target;[...u.branches].some($=>$.contains(A))||(i?.(k),c?.(k),k.defaultPrevented||d?.())},h),P=p?j===y.length-1:!1,M=He(k=>{k.key==="Escape"&&(r?.(k),!k.defaultPrevented&&d&&(k.preventDefault(),d()))});return l.useEffect(()=>{if(P)return h.addEventListener("keydown",M,{capture:!0}),()=>h.removeEventListener("keydown",M,{capture:!0})},[h,P,M]),l.useEffect(()=>{if(p)return s&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Jl=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),Yl(),()=>{s&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=Jl))}},[p,h,s,u]),l.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),Yl())},[p,u]),l.useEffect(()=>{const k=()=>g({});return document.addEventListener(Va,k),()=>document.removeEventListener(Va,k)},[]),t.jsx(xe.div,{...m,ref:b,style:{pointerEvents:S?N?"auto":"none":void 0,...e.style},onFocusCapture:de(e.onFocusCapture,I.onFocusCapture),onBlurCapture:de(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:de(e.onPointerDownCapture,R.onPointerDownCapture)})});vr.displayName=Ub;var Hb="DismissableLayerBranch",Wb=l.forwardRef((e,n)=>{const s=l.useContext(Ji),o=l.useRef(null),r=Te(n,o);return l.useEffect(()=>{const a=o.current;if(a)return s.branches.add(a),()=>{s.branches.delete(a)}},[s.branches]),t.jsx(xe.div,{...e,ref:r})});Wb.displayName=Hb;function Vb(){const e=l.useContext(Ji),[n,s]=l.useState(null);return l.useEffect(()=>{if(n)return e.dismissableSurfaces.add(n),()=>{e.dismissableSurfaces.delete(n)}},[n,e.dismissableSurfaces]),s}var Kb=()=>!0;function Gb(e,n){const{ownerDocument:s=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:r,dismissableSurfaces:a,shouldHandlePointerDownOutside:i=Kb}=n,c=He(e),d=l.useRef(!1),m=l.useRef(!1),u=l.useRef(new Map),p=l.useRef(()=>{});return l.useEffect(()=>{function f(){m.current=!1,r.current=!1,u.current.clear()}function h(){return Array.from(u.current.values()).some(Boolean)}function g(j){if(!m.current)return;const S=j.target;S instanceof Node&&[...a].some(C=>C.contains(S))||u.current.set(j.type,!0),j.type==="click"&&window.setTimeout(()=>{m.current&&p.current()},0)}function b(j){m.current&&u.current.set(j.type,!1)}const y=j=>{if(j.target&&!d.current){let S=function(){s.removeEventListener("click",p.current);const C=h();f(),C||_u(Bb,c,N,{discrete:!0})};if(!i(j.target)){s.removeEventListener("click",p.current),f(),d.current=!1;return}const N={originalEvent:j};m.current=!0,r.current=o&&j.button===0,u.current.clear(),!o||j.button!==0?S():(s.removeEventListener("click",p.current),p.current=S,s.addEventListener("click",p.current,{once:!0}))}else s.removeEventListener("click",p.current),f();d.current=!1},w=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const j of w)s.addEventListener(j,g,!0),s.addEventListener(j,b);const v=window.setTimeout(()=>{s.addEventListener("pointerdown",y)},0);return()=>{window.clearTimeout(v),s.removeEventListener("pointerdown",y),s.removeEventListener("click",p.current);for(const j of w)s.removeEventListener(j,g,!0),s.removeEventListener(j,b)}},[s,c,o,r,a,i]),{onPointerDownCapture:()=>d.current=!0}}function Jb(e,n=globalThis?.document){const s=He(e),o=l.useRef(!1);return l.useEffect(()=>{const r=a=>{a.target&&!o.current&&_u(qb,s,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",r),()=>n.removeEventListener("focusin",r)},[n,s]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Yl(){const e=new CustomEvent(Va);document.dispatchEvent(e)}function _u(e,n,s,{discrete:o}){const r=s.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});n&&r.addEventListener(e,n,{once:!0}),o?Sb(r,a):r.dispatchEvent(a)}var Zr="focusScope.autoFocusOnMount",Qr="focusScope.autoFocusOnUnmount",Xl={bubbles:!1,cancelable:!0},Yb="FocusScope",Yi=l.forwardRef((e,n)=>{const{loop:s=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[c,d]=l.useState(null),m=He(r),u=He(a),p=l.useRef(null),f=Te(n,d),h=l.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;l.useEffect(()=>{if(o){let b=function(j){if(h.paused||!c)return;const S=j.target;c.contains(S)?p.current=S:en(p.current,{select:!0})},y=function(j){if(h.paused||!c)return;const S=j.relatedTarget;S!==null&&(c.contains(S)||en(p.current,{select:!0}))},w=function(j){if(document.activeElement===document.body)for(const N of j)N.removedNodes.length>0&&en(c)};document.addEventListener("focusin",b),document.addEventListener("focusout",y);const v=new MutationObserver(w);return c&&v.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",b),document.removeEventListener("focusout",y),v.disconnect()}}},[o,c,h.paused]),l.useEffect(()=>{if(c){Ql.add(h);const b=document.activeElement;if(!c.contains(b)){const w=new CustomEvent(Zr,Xl);c.addEventListener(Zr,m),c.dispatchEvent(w),w.defaultPrevented||(Xb(nv(Tu(c)),{select:!0}),document.activeElement===b&&en(c))}return()=>{c.removeEventListener(Zr,m),setTimeout(()=>{const w=new CustomEvent(Qr,Xl);c.addEventListener(Qr,u),c.dispatchEvent(w),w.defaultPrevented||en(b??document.body,{select:!0}),c.removeEventListener(Qr,u),Ql.remove(h)},0)}}},[c,m,u,h]);const g=l.useCallback(b=>{if(!s&&!o||h.paused)return;const y=b.key==="Tab"&&!b.altKey&&!b.ctrlKey&&!b.metaKey,w=document.activeElement;if(y&&w){const v=b.currentTarget,[j,S]=Zb(v);j&&S?!b.shiftKey&&w===S?(b.preventDefault(),s&&en(j,{select:!0})):b.shiftKey&&w===j&&(b.preventDefault(),s&&en(S,{select:!0})):w===v&&b.preventDefault()}},[s,o,h.paused]);return t.jsx(xe.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});Yi.displayName=Yb;function Xb(e,{select:n=!1}={}){const s=document.activeElement;for(const o of e)if(en(o,{select:n}),document.activeElement!==s)return}function Zb(e){const n=Tu(e),s=Zl(n,e),o=Zl(n.reverse(),e);return[s,o]}function Tu(e){const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)n.push(s.currentNode);return n}function Zl(e,n){const s=typeof n.checkVisibility=="function"&&n.checkVisibility({checkVisibilityCSS:!0});for(const o of e)if(!(s?!o.checkVisibility({checkVisibilityCSS:!0}):Qb(o,{upTo:n})))return o}function Qb(e,{upTo:n}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(n!==void 0&&e===n)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ev(e){return e instanceof HTMLInputElement&&"select"in e}function en(e,{select:n=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&ev(e)&&n&&e.select()}}var Ql=tv();function tv(){let e=[];return{add(n){const s=e[0];n!==s&&s?.pause(),e=ec(e,n),e.unshift(n)},remove(n){e=ec(e,n),e[0]?.resume()}}}function ec(e,n){const s=[...e],o=s.indexOf(n);return o!==-1&&s.splice(o,1),s}function nv(e){return e.filter(n=>n.tagName!=="A")}var sv="Portal",yr=l.forwardRef((e,n)=>{const{container:s,...o}=e,[r,a]=l.useState(!1);Ue(()=>a(!0),[]);const i=s||r&&globalThis?.document?.body;return i?ms.createPortal(t.jsx(xe.div,{...o,ref:n}),i):null});yr.displayName=sv;var ao=0,Dn=null;function Eu(){l.useEffect(()=>{Dn||(Dn={start:tc(),end:tc()});const{start:e,end:n}=Dn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==n&&document.body.insertAdjacentElement("beforeend",n),ao++,()=>{ao===1&&(Dn?.start.remove(),Dn?.end.remove(),Dn=null),ao=Math.max(0,ao-1)}},[])}function tc(){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 _t=function(){return _t=Object.assign||function(n){for(var s,o=1,r=arguments.length;o<r;o++){s=arguments[o];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=s[a])}return n},_t.apply(this,arguments)};function Ru(e,n){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(s[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(s[o[r]]=e[o[r]]);return s}function ov(e,n,s){if(s||arguments.length===2)for(var o=0,r=n.length,a;o<r;o++)(a||!(o in n))&&(a||(a=Array.prototype.slice.call(n,0,o)),a[o]=n[o]);return e.concat(a||Array.prototype.slice.call(n))}var Mo="right-scroll-bar-position",Ao="width-before-scroll-bar",rv="with-scroll-bars-hidden",av="--removed-body-scroll-bar-size";function ea(e,n){return typeof e=="function"?e(n):e&&(e.current=n),e}function iv(e,n){var s=l.useState(function(){return{value:e,callback:n,facade:{get current(){return s.value},set current(o){var r=s.value;r!==o&&(s.value=o,s.callback(o,r))}}}})[0];return s.callback=n,s.facade}var lv=typeof window<"u"?l.useLayoutEffect:l.useEffect,nc=new WeakMap;function cv(e,n){var s=iv(null,function(o){return e.forEach(function(r){return ea(r,o)})});return lv(function(){var o=nc.get(s);if(o){var r=new Set(o),a=new Set(e),i=s.current;r.forEach(function(c){a.has(c)||ea(c,null)}),a.forEach(function(c){r.has(c)||ea(c,i)})}nc.set(s,e)},[e]),s}function dv(e){return e}function uv(e,n){n===void 0&&(n=dv);var s=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return s.length?s[s.length-1]:e},useMedium:function(a){var i=n(a,o);return s.push(i),function(){s=s.filter(function(c){return c!==i})}},assignSyncMedium:function(a){for(o=!0;s.length;){var i=s;s=[],i.forEach(a)}s={push:function(c){return a(c)},filter:function(){return s}}},assignMedium:function(a){o=!0;var i=[];if(s.length){var c=s;s=[],c.forEach(a),i=s}var d=function(){var u=i;i=[],u.forEach(a)},m=function(){return Promise.resolve().then(d)};m(),s={push:function(u){i.push(u),m()},filter:function(u){return i=i.filter(u),s}}}};return r}function mv(e){e===void 0&&(e={});var n=uv(null);return n.options=_t({async:!0,ssr:!1},e),n}var Mu=function(e){var n=e.sideCar,s=Ru(e,["sideCar"]);if(!n)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=n.read();if(!o)throw new Error("Sidecar medium not found");return l.createElement(o,_t({},s))};Mu.isSideCarExport=!0;function pv(e,n){return e.useMedium(n),Mu}var Au=mv(),ta=function(){},wr=l.forwardRef(function(e,n){var s=l.useRef(null),o=l.useState({onScrollCapture:ta,onWheelCapture:ta,onTouchMoveCapture:ta}),r=o[0],a=o[1],i=e.forwardProps,c=e.children,d=e.className,m=e.removeScrollBar,u=e.enabled,p=e.shards,f=e.sideCar,h=e.noRelative,g=e.noIsolation,b=e.inert,y=e.allowPinchZoom,w=e.as,v=w===void 0?"div":w,j=e.gapMode,S=Ru(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),N=f,C=cv([s,n]),R=_t(_t({},S),r);return l.createElement(l.Fragment,null,u&&l.createElement(N,{sideCar:Au,removeScrollBar:m,shards:p,noRelative:h,noIsolation:g,inert:b,setCallbacks:a,allowPinchZoom:!!y,lockRef:s,gapMode:j}),i?l.cloneElement(l.Children.only(c),_t(_t({},R),{ref:C})):l.createElement(v,_t({},R,{className:d,ref:C}),c))});wr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};wr.classNames={fullWidth:Ao,zeroRight:Mo};var fv=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function hv(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var n=fv();return n&&e.setAttribute("nonce",n),e}function xv(e,n){e.styleSheet?e.styleSheet.cssText=n:e.appendChild(document.createTextNode(n))}function gv(e){var n=document.head||document.getElementsByTagName("head")[0];n.appendChild(e)}var bv=function(){var e=0,n=null;return{add:function(s){e==0&&(n=hv())&&(xv(n,s),gv(n)),e++},remove:function(){e--,!e&&n&&(n.parentNode&&n.parentNode.removeChild(n),n=null)}}},vv=function(){var e=bv();return function(n,s){l.useEffect(function(){return e.add(n),function(){e.remove()}},[n&&s])}},Iu=function(){var e=vv(),n=function(s){var o=s.styles,r=s.dynamic;return e(o,r),null};return n},yv={left:0,top:0,right:0,gap:0},na=function(e){return parseInt(e||"",10)||0},wv=function(e){var n=window.getComputedStyle(document.body),s=n[e==="padding"?"paddingLeft":"marginLeft"],o=n[e==="padding"?"paddingTop":"marginTop"],r=n[e==="padding"?"paddingRight":"marginRight"];return[na(s),na(o),na(r)]},jv=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return yv;var n=wv(e),s=document.documentElement.clientWidth,o=window.innerWidth;return{left:n[0],top:n[1],right:n[2],gap:Math.max(0,o-s+n[2]-n[0])}},Sv=Iu(),Zn="data-scroll-locked",Nv=function(e,n,s,o){var r=e.left,a=e.top,i=e.right,c=e.gap;return s===void 0&&(s="margin"),`
|
|
3
|
+
.`.concat(rv,` {
|
|
4
|
+
overflow: hidden `).concat(o,`;
|
|
5
|
+
padding-right: `).concat(c,"px ").concat(o,`;
|
|
6
|
+
}
|
|
7
|
+
body[`).concat(Zn,`] {
|
|
8
|
+
overflow: hidden `).concat(o,`;
|
|
9
|
+
overscroll-behavior: contain;
|
|
10
|
+
`).concat([n&&"position: relative ".concat(o,";"),s==="margin"&&`
|
|
11
|
+
padding-left: `.concat(r,`px;
|
|
12
|
+
padding-top: `).concat(a,`px;
|
|
13
|
+
padding-right: `).concat(i,`px;
|
|
14
|
+
margin-left:0;
|
|
15
|
+
margin-top:0;
|
|
16
|
+
margin-right: `).concat(c,"px ").concat(o,`;
|
|
17
|
+
`),s==="padding"&&"padding-right: ".concat(c,"px ").concat(o,";")].filter(Boolean).join(""),`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.`).concat(Mo,` {
|
|
21
|
+
right: `).concat(c,"px ").concat(o,`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.`).concat(Ao,` {
|
|
25
|
+
margin-right: `).concat(c,"px ").concat(o,`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.`).concat(Mo," .").concat(Mo,` {
|
|
29
|
+
right: 0 `).concat(o,`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.`).concat(Ao," .").concat(Ao,` {
|
|
33
|
+
margin-right: 0 `).concat(o,`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
body[`).concat(Zn,`] {
|
|
37
|
+
`).concat(av,": ").concat(c,`px;
|
|
38
|
+
}
|
|
39
|
+
`)},sc=function(){var e=parseInt(document.body.getAttribute(Zn)||"0",10);return isFinite(e)?e:0},Cv=function(){l.useEffect(function(){return document.body.setAttribute(Zn,(sc()+1).toString()),function(){var e=sc()-1;e<=0?document.body.removeAttribute(Zn):document.body.setAttribute(Zn,e.toString())}},[])},kv=function(e){var n=e.noRelative,s=e.noImportant,o=e.gapMode,r=o===void 0?"margin":o;Cv();var a=l.useMemo(function(){return jv(r)},[r]);return l.createElement(Sv,{styles:Nv(a,!n,r,s?"":"!important")})},Ka=!1;if(typeof window<"u")try{var io=Object.defineProperty({},"passive",{get:function(){return Ka=!0,!0}});window.addEventListener("test",io,io),window.removeEventListener("test",io,io)}catch{Ka=!1}var zn=Ka?{passive:!1}:!1,_v=function(e){return e.tagName==="TEXTAREA"},Pu=function(e,n){if(!(e instanceof Element))return!1;var s=window.getComputedStyle(e);return s[n]!=="hidden"&&!(s.overflowY===s.overflowX&&!_v(e)&&s[n]==="visible")},Tv=function(e){return Pu(e,"overflowY")},Ev=function(e){return Pu(e,"overflowX")},oc=function(e,n){var s=n.ownerDocument,o=n;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var r=Lu(e,o);if(r){var a=Ou(e,o),i=a[1],c=a[2];if(i>c)return!0}o=o.parentNode}while(o&&o!==s.body);return!1},Rv=function(e){var n=e.scrollTop,s=e.scrollHeight,o=e.clientHeight;return[n,s,o]},Mv=function(e){var n=e.scrollLeft,s=e.scrollWidth,o=e.clientWidth;return[n,s,o]},Lu=function(e,n){return e==="v"?Tv(n):Ev(n)},Ou=function(e,n){return e==="v"?Rv(n):Mv(n)},Av=function(e,n){return e==="h"&&n==="rtl"?-1:1},Iv=function(e,n,s,o,r){var a=Av(e,window.getComputedStyle(n).direction),i=a*o,c=s.target,d=n.contains(c),m=!1,u=i>0,p=0,f=0;do{if(!c)break;var h=Ou(e,c),g=h[0],b=h[1],y=h[2],w=b-y-a*g;(g||w)&&Lu(e,c)&&(p+=w,f+=g);var v=c.parentNode;c=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!d&&c!==document.body||d&&(n.contains(c)||n===c));return(u&&Math.abs(p)<1||!u&&Math.abs(f)<1)&&(m=!0),m},lo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},rc=function(e){return[e.deltaX,e.deltaY]},ac=function(e){return e&&"current"in e?e.current:e},Pv=function(e,n){return e[0]===n[0]&&e[1]===n[1]},Lv=function(e){return`
|
|
40
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
41
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
42
|
+
`)},Ov=0,$n=[];function Dv(e){var n=l.useRef([]),s=l.useRef([0,0]),o=l.useRef(),r=l.useState(Ov++)[0],a=l.useState(Iu)[0],i=l.useRef(e);l.useEffect(function(){i.current=e},[e]),l.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var b=ov([e.lockRef.current],(e.shards||[]).map(ac),!0).filter(Boolean);return b.forEach(function(y){return y.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),b.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var c=l.useCallback(function(b,y){if("touches"in b&&b.touches.length===2||b.type==="wheel"&&b.ctrlKey)return!i.current.allowPinchZoom;var w=lo(b),v=s.current,j="deltaX"in b?b.deltaX:v[0]-w[0],S="deltaY"in b?b.deltaY:v[1]-w[1],N,C=b.target,R=Math.abs(j)>Math.abs(S)?"h":"v";if("touches"in b&&R==="h"&&C.type==="range")return!1;var I=window.getSelection(),P=I&&I.anchorNode,M=P?P===C||P.contains(C):!1;if(M)return!1;var k=oc(R,C);if(!k)return!0;if(k?N=R:(N=R==="v"?"h":"v",k=oc(R,C)),!k)return!1;if(!o.current&&"changedTouches"in b&&(j||S)&&(o.current=N),!N)return!0;var A=o.current||N;return Iv(A,y,b,A==="h"?j:S)},[]),d=l.useCallback(function(b){var y=b;if(!(!$n.length||$n[$n.length-1]!==a)){var w="deltaY"in y?rc(y):lo(y),v=n.current.filter(function(N){return N.name===y.type&&(N.target===y.target||y.target===N.shadowParent)&&Pv(N.delta,w)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var j=(i.current.shards||[]).map(ac).filter(Boolean).filter(function(N){return N.contains(y.target)}),S=j.length>0?c(y,j[0]):!i.current.noIsolation;S&&y.cancelable&&y.preventDefault()}}},[]),m=l.useCallback(function(b,y,w,v){var j={name:b,delta:y,target:w,should:v,shadowParent:zv(w)};n.current.push(j),setTimeout(function(){n.current=n.current.filter(function(S){return S!==j})},1)},[]),u=l.useCallback(function(b){s.current=lo(b),o.current=void 0},[]),p=l.useCallback(function(b){m(b.type,rc(b),b.target,c(b,e.lockRef.current))},[]),f=l.useCallback(function(b){m(b.type,lo(b),b.target,c(b,e.lockRef.current))},[]);l.useEffect(function(){return $n.push(a),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:f}),document.addEventListener("wheel",d,zn),document.addEventListener("touchmove",d,zn),document.addEventListener("touchstart",u,zn),function(){$n=$n.filter(function(b){return b!==a}),document.removeEventListener("wheel",d,zn),document.removeEventListener("touchmove",d,zn),document.removeEventListener("touchstart",u,zn)}},[]);var h=e.removeScrollBar,g=e.inert;return l.createElement(l.Fragment,null,g?l.createElement(a,{styles:Lv(r)}):null,h?l.createElement(kv,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function zv(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const $v=pv(Au,Dv);var Xi=l.forwardRef(function(e,n){return l.createElement(wr,_t({},e,{ref:n,sideCar:$v}))});Xi.classNames=wr.classNames;var Fv=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Fn=new WeakMap,co=new WeakMap,uo={},sa=0,Du=function(e){return e&&(e.host||Du(e.parentNode))},Uv=function(e,n){return n.map(function(s){if(e.contains(s))return s;var o=Du(s);return o&&e.contains(o)?o:(console.error("aria-hidden",s,"in not contained inside",e,". Doing nothing"),null)}).filter(function(s){return!!s})},Bv=function(e,n,s,o){var r=Uv(n,Array.isArray(e)?e:[e]);uo[s]||(uo[s]=new WeakMap);var a=uo[s],i=[],c=new Set,d=new Set(r),m=function(p){!p||c.has(p)||(c.add(p),m(p.parentNode))};r.forEach(m);var u=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(f){if(c.has(f))u(f);else try{var h=f.getAttribute(o),g=h!==null&&h!=="false",b=(Fn.get(f)||0)+1,y=(a.get(f)||0)+1;Fn.set(f,b),a.set(f,y),i.push(f),b===1&&g&&co.set(f,!0),y===1&&f.setAttribute(s,"true"),g||f.setAttribute(o,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return u(n),c.clear(),sa++,function(){i.forEach(function(p){var f=Fn.get(p)-1,h=a.get(p)-1;Fn.set(p,f),a.set(p,h),f||(co.has(p)||p.removeAttribute(o),co.delete(p)),h||p.removeAttribute(s)}),sa--,sa||(Fn=new WeakMap,Fn=new WeakMap,co=new WeakMap,uo={})}},zu=function(e,n,s){s===void 0&&(s="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=Fv(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),Bv(o,r,s,"aria-hidden")):function(){return null}},jr="Dialog",[$u]=Jt(jr),[qv,Nt]=$u(jr),Fu=e=>{const{__scopeDialog:n,children:s,open:o,defaultOpen:r,onOpenChange:a,modal:i=!0}=e,c=l.useRef(null),d=l.useRef(null),[m,u]=En({prop:o,defaultProp:r??!1,onChange:a,caller:jr});return t.jsx(qv,{scope:n,triggerRef:c,contentRef:d,contentId:Rt(),titleId:Rt(),descriptionId:Rt(),open:m,onOpenChange:u,onOpenToggle:l.useCallback(()=>u(p=>!p),[u]),modal:i,children:s})};Fu.displayName=jr;var Uu="DialogTrigger",Bu=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Uu,s),a=Te(n,r.triggerRef);return t.jsx(xe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.open?r.contentId:void 0,"data-state":Qi(r.open),...o,ref:a,onClick:de(e.onClick,r.onOpenToggle)})});Bu.displayName=Uu;var Zi="DialogPortal",[Hv,qu]=$u(Zi,{forceMount:void 0}),Hu=e=>{const{__scopeDialog:n,forceMount:s,children:o,container:r}=e,a=Nt(Zi,n);return t.jsx(Hv,{scope:n,forceMount:s,children:l.Children.map(o,i=>t.jsx(lt,{present:s||a.open,children:t.jsx(yr,{asChild:!0,container:r,children:i})}))})};Hu.displayName=Zi;var Ko="DialogOverlay",Wu=l.forwardRef((e,n)=>{const s=qu(Ko,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Nt(Ko,e.__scopeDialog);return a.modal?t.jsx(lt,{present:o||a.open,children:t.jsx(Vv,{...r,ref:n})}):null});Wu.displayName=Ko;var Wv=rs("DialogOverlay.RemoveScroll"),Vv=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Ko,s),a=Vb(),i=Te(n,a);return t.jsx(Xi,{as:Wv,allowPinchZoom:!0,shards:[r.contentRef],children:t.jsx(xe.div,{"data-state":Qi(r.open),...o,ref:i,style:{pointerEvents:"auto",...o.style}})})}),as="DialogContent",Vu=l.forwardRef((e,n)=>{const s=qu(as,e.__scopeDialog),{forceMount:o=s.forceMount,...r}=e,a=Nt(as,e.__scopeDialog);return t.jsx(lt,{present:o||a.open,children:a.modal?t.jsx(Kv,{...r,ref:n}):t.jsx(Gv,{...r,ref:n})})});Vu.displayName=as;var Kv=l.forwardRef((e,n)=>{const s=Nt(as,e.__scopeDialog),o=l.useRef(null),r=Te(n,s.contentRef,o);return l.useEffect(()=>{const a=o.current;if(a)return zu(a)},[]),t.jsx(Ku,{...e,ref:r,trapFocus:s.open,disableOutsidePointerEvents:s.open,onCloseAutoFocus:de(e.onCloseAutoFocus,a=>{a.preventDefault(),s.triggerRef.current?.focus()}),onPointerDownOutside:de(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,c=i.button===0&&i.ctrlKey===!0;(i.button===2||c)&&a.preventDefault()}),onFocusOutside:de(e.onFocusOutside,a=>a.preventDefault())})}),Gv=l.forwardRef((e,n)=>{const s=Nt(as,e.__scopeDialog),o=l.useRef(!1),r=l.useRef(!1);return t.jsx(Ku,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),a.defaultPrevented||(o.current||s.triggerRef.current?.focus(),a.preventDefault()),o.current=!1,r.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(r.current=!0));const i=a.target;s.triggerRef.current?.contains(i)&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&r.current&&a.preventDefault()}})}),Ku=l.forwardRef((e,n)=>{const{__scopeDialog:s,trapFocus:o,onOpenAutoFocus:r,onCloseAutoFocus:a,...i}=e,c=Nt(as,s);return Eu(),t.jsx(t.Fragment,{children:t.jsx(Yi,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:r,onUnmountAutoFocus:a,children:t.jsx(vr,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Qi(c.open),...i,ref:n,deferPointerDownOutside:!0,onDismiss:()=>c.onOpenChange(!1)})})})}),Gu="DialogTitle",Ju=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Gu,s);return t.jsx(xe.h2,{id:r.titleId,...o,ref:n})});Ju.displayName=Gu;var Yu="DialogDescription",Xu=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Yu,s);return t.jsx(xe.p,{id:r.descriptionId,...o,ref:n})});Xu.displayName=Yu;var Zu="DialogClose",Qu=l.forwardRef((e,n)=>{const{__scopeDialog:s,...o}=e,r=Nt(Zu,s);return t.jsx(xe.button,{type:"button",...o,ref:n,onClick:de(e.onClick,()=>r.onOpenChange(!1))})});Qu.displayName=Zu;function Qi(e){return e?"open":"closed"}function Jv(e){const n=l.useRef({value:e,previous:e});return l.useMemo(()=>(n.current.value!==e&&(n.current.previous=n.current.value,n.current.value=e),n.current.previous),[e])}function Yv(e){const[n,s]=l.useState(void 0);return Ue(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let i,c;if("borderBoxSize"in a){const d=a.borderBoxSize,m=Array.isArray(d)?d[0]:d;i=m.inlineSize,c=m.blockSize}else i=e.offsetWidth,c=e.offsetHeight;s({width:i,height:c})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else s(void 0)},[e]),n}const Xv=["top","right","bottom","left"],ln=Math.min,st=Math.max,Go=Math.round,mo=Math.floor,Mt=e=>({x:e,y:e}),Zv={left:"right",right:"left",bottom:"top",top:"bottom"},Qv={start:"end",end:"start"};function Ga(e,n,s){return st(e,ln(n,s))}function Vt(e,n){return typeof e=="function"?e(n):e}function Kt(e){return e.split("-")[0]}function ps(e){return e.split("-")[1]}function el(e){return e==="x"?"y":"x"}function tl(e){return e==="y"?"height":"width"}const e2=new Set(["top","bottom"]);function Tt(e){return e2.has(Kt(e))?"y":"x"}function nl(e){return el(Tt(e))}function t2(e,n,s){s===void 0&&(s=!1);const o=ps(e),r=nl(e),a=tl(r);let i=r==="x"?o===(s?"end":"start")?"right":"left":o==="start"?"bottom":"top";return n.reference[a]>n.floating[a]&&(i=Jo(i)),[i,Jo(i)]}function n2(e){const n=Jo(e);return[Ja(e),n,Ja(n)]}function Ja(e){return e.replace(/start|end/g,n=>Qv[n])}const ic=["left","right"],lc=["right","left"],s2=["top","bottom"],o2=["bottom","top"];function r2(e,n,s){switch(e){case"top":case"bottom":return s?n?lc:ic:n?ic:lc;case"left":case"right":return n?s2:o2;default:return[]}}function a2(e,n,s,o){const r=ps(e);let a=r2(Kt(e),s==="start",o);return r&&(a=a.map(i=>i+"-"+r),n&&(a=a.concat(a.map(Ja)))),a}function Jo(e){return e.replace(/left|right|bottom|top/g,n=>Zv[n])}function i2(e){return{top:0,right:0,bottom:0,left:0,...e}}function em(e){return typeof e!="number"?i2(e):{top:e,right:e,bottom:e,left:e}}function Yo(e){const{x:n,y:s,width:o,height:r}=e;return{width:o,height:r,top:s,left:n,right:n+o,bottom:s+r,x:n,y:s}}function cc(e,n,s){let{reference:o,floating:r}=e;const a=Tt(n),i=nl(n),c=tl(i),d=Kt(n),m=a==="y",u=o.x+o.width/2-r.width/2,p=o.y+o.height/2-r.height/2,f=o[c]/2-r[c]/2;let h;switch(d){case"top":h={x:u,y:o.y-r.height};break;case"bottom":h={x:u,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:p};break;case"left":h={x:o.x-r.width,y:p};break;default:h={x:o.x,y:o.y}}switch(ps(n)){case"start":h[i]-=f*(s&&m?-1:1);break;case"end":h[i]+=f*(s&&m?-1:1);break}return h}async function l2(e,n){var s;n===void 0&&(n={});const{x:o,y:r,platform:a,rects:i,elements:c,strategy:d}=e,{boundary:m="clippingAncestors",rootBoundary:u="viewport",elementContext:p="floating",altBoundary:f=!1,padding:h=0}=Vt(n,e),g=em(h),y=c[f?p==="floating"?"reference":"floating":p],w=Yo(await a.getClippingRect({element:(s=await(a.isElement==null?void 0:a.isElement(y)))==null||s?y:y.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:m,rootBoundary:u,strategy:d})),v=p==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,j=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),S=await(a.isElement==null?void 0:a.isElement(j))?await(a.getScale==null?void 0:a.getScale(j))||{x:1,y:1}:{x:1,y:1},N=Yo(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:j,strategy:d}):v);return{top:(w.top-N.top+g.top)/S.y,bottom:(N.bottom-w.bottom+g.bottom)/S.y,left:(w.left-N.left+g.left)/S.x,right:(N.right-w.right+g.right)/S.x}}const c2=async(e,n,s)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=s,c=a.filter(Boolean),d=await(i.isRTL==null?void 0:i.isRTL(n));let m=await i.getElementRects({reference:e,floating:n,strategy:r}),{x:u,y:p}=cc(m,o,d),f=o,h={},g=0;for(let y=0;y<c.length;y++){var b;const{name:w,fn:v}=c[y],{x:j,y:S,data:N,reset:C}=await v({x:u,y:p,initialPlacement:o,placement:f,strategy:r,middlewareData:h,rects:m,platform:{...i,detectOverflow:(b=i.detectOverflow)!=null?b:l2},elements:{reference:e,floating:n}});u=j??u,p=S??p,h={...h,[w]:{...h[w],...N}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(m=C.rects===!0?await i.getElementRects({reference:e,floating:n,strategy:r}):C.rects),{x:u,y:p}=cc(m,f,d)),y=-1)}return{x:u,y:p,placement:f,strategy:r,middlewareData:h}},d2=e=>({name:"arrow",options:e,async fn(n){const{x:s,y:o,placement:r,rects:a,platform:i,elements:c,middlewareData:d}=n,{element:m,padding:u=0}=Vt(e,n)||{};if(m==null)return{};const p=em(u),f={x:s,y:o},h=nl(r),g=tl(h),b=await i.getDimensions(m),y=h==="y",w=y?"top":"left",v=y?"bottom":"right",j=y?"clientHeight":"clientWidth",S=a.reference[g]+a.reference[h]-f[h]-a.floating[g],N=f[h]-a.reference[h],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(m));let R=C?C[j]:0;(!R||!await(i.isElement==null?void 0:i.isElement(C)))&&(R=c.floating[j]||a.floating[g]);const I=S/2-N/2,P=R/2-b[g]/2-1,M=ln(p[w],P),k=ln(p[v],P),A=M,D=R-b[g]-k,$=R/2-b[g]/2+I,J=Ga(A,$,D),X=!d.arrow&&ps(r)!=null&&$!==J&&a.reference[g]/2-($<A?M:k)-b[g]/2<0,F=X?$<A?$-A:$-D:0;return{[h]:f[h]+F,data:{[h]:J,centerOffset:$-J-F,...X&&{alignmentOffset:F}},reset:X}}}),u2=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var s,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:c,platform:d,elements:m}=n,{mainAxis:u=!0,crossAxis:p=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...y}=Vt(e,n);if((s=a.arrow)!=null&&s.alignmentOffset)return{};const w=Kt(r),v=Tt(c),j=Kt(c)===c,S=await(d.isRTL==null?void 0:d.isRTL(m.floating)),N=f||(j||!b?[Jo(c)]:n2(c)),C=g!=="none";!f&&C&&N.push(...a2(c,b,g,S));const R=[c,...N],I=await d.detectOverflow(n,y),P=[];let M=((o=a.flip)==null?void 0:o.overflows)||[];if(u&&P.push(I[w]),p){const $=t2(r,i,S);P.push(I[$[0]],I[$[1]])}if(M=[...M,{placement:r,overflows:P}],!P.every($=>$<=0)){var k,A;const $=(((k=a.flip)==null?void 0:k.index)||0)+1,J=R[$];if(J&&(!(p==="alignment"?v!==Tt(J):!1)||M.every(H=>Tt(H.placement)===v?H.overflows[0]>0:!0)))return{data:{index:$,overflows:M},reset:{placement:J}};let X=(A=M.filter(F=>F.overflows[0]<=0).sort((F,H)=>F.overflows[1]-H.overflows[1])[0])==null?void 0:A.placement;if(!X)switch(h){case"bestFit":{var D;const F=(D=M.filter(H=>{if(C){const Y=Tt(H.placement);return Y===v||Y==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(Y=>Y>0).reduce((Y,U)=>Y+U,0)]).sort((H,Y)=>H[1]-Y[1])[0])==null?void 0:D[0];F&&(X=F);break}case"initialPlacement":X=c;break}if(r!==X)return{reset:{placement:X}}}return{}}}};function dc(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function uc(e){return Xv.some(n=>e[n]>=0)}const m2=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:s,platform:o}=n,{strategy:r="referenceHidden",...a}=Vt(e,n);switch(r){case"referenceHidden":{const i=await o.detectOverflow(n,{...a,elementContext:"reference"}),c=dc(i,s.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:uc(c)}}}case"escaped":{const i=await o.detectOverflow(n,{...a,altBoundary:!0}),c=dc(i,s.floating);return{data:{escapedOffsets:c,escaped:uc(c)}}}default:return{}}}}},tm=new Set(["left","top"]);async function p2(e,n){const{placement:s,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=Kt(s),c=ps(s),d=Tt(s)==="y",m=tm.has(i)?-1:1,u=a&&d?-1:1,p=Vt(n,e);let{mainAxis:f,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 c&&typeof g=="number"&&(h=c==="end"?g*-1:g),d?{x:h*u,y:f*m}:{x:f*m,y:h*u}}const f2=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var s,o;const{x:r,y:a,placement:i,middlewareData:c}=n,d=await p2(n,e);return i===((s=c.offset)==null?void 0:s.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+d.x,y:a+d.y,data:{...d,placement:i}}}}},h2=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:s,y:o,placement:r,platform:a}=n,{mainAxis:i=!0,crossAxis:c=!1,limiter:d={fn:w=>{let{x:v,y:j}=w;return{x:v,y:j}}},...m}=Vt(e,n),u={x:s,y:o},p=await a.detectOverflow(n,m),f=Tt(Kt(r)),h=el(f);let g=u[h],b=u[f];if(i){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",j=g+p[w],S=g-p[v];g=Ga(j,g,S)}if(c){const w=f==="y"?"top":"left",v=f==="y"?"bottom":"right",j=b+p[w],S=b-p[v];b=Ga(j,b,S)}const y=d.fn({...n,[h]:g,[f]:b});return{...y,data:{x:y.x-s,y:y.y-o,enabled:{[h]:i,[f]:c}}}}}},x2=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:s,y:o,placement:r,rects:a,middlewareData:i}=n,{offset:c=0,mainAxis:d=!0,crossAxis:m=!0}=Vt(e,n),u={x:s,y:o},p=Tt(r),f=el(p);let h=u[f],g=u[p];const b=Vt(c,n),y=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:0,crossAxis:0,...b};if(d){const j=f==="y"?"height":"width",S=a.reference[f]-a.floating[j]+y.mainAxis,N=a.reference[f]+a.reference[j]-y.mainAxis;h<S?h=S:h>N&&(h=N)}if(m){var w,v;const j=f==="y"?"width":"height",S=tm.has(Kt(r)),N=a.reference[p]-a.floating[j]+(S&&((w=i.offset)==null?void 0:w[p])||0)+(S?0:y.crossAxis),C=a.reference[p]+a.reference[j]+(S?0:((v=i.offset)==null?void 0:v[p])||0)-(S?y.crossAxis:0);g<N?g=N:g>C&&(g=C)}return{[f]:h,[p]:g}}}},g2=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var s,o;const{placement:r,rects:a,platform:i,elements:c}=n,{apply:d=()=>{},...m}=Vt(e,n),u=await i.detectOverflow(n,m),p=Kt(r),f=ps(r),h=Tt(r)==="y",{width:g,height:b}=a.floating;let y,w;p==="top"||p==="bottom"?(y=p,w=f===(await(i.isRTL==null?void 0:i.isRTL(c.floating))?"start":"end")?"left":"right"):(w=p,y=f==="end"?"top":"bottom");const v=b-u.top-u.bottom,j=g-u.left-u.right,S=ln(b-u[y],v),N=ln(g-u[w],j),C=!n.middlewareData.shift;let R=S,I=N;if((s=n.middlewareData.shift)!=null&&s.enabled.x&&(I=j),(o=n.middlewareData.shift)!=null&&o.enabled.y&&(R=v),C&&!f){const M=st(u.left,0),k=st(u.right,0),A=st(u.top,0),D=st(u.bottom,0);h?I=g-2*(M!==0||k!==0?M+k:st(u.left,u.right)):R=b-2*(A!==0||D!==0?A+D:st(u.top,u.bottom))}await d({...n,availableWidth:I,availableHeight:R});const P=await i.getDimensions(c.floating);return g!==P.width||b!==P.height?{reset:{rects:!0}}:{}}}};function Sr(){return typeof window<"u"}function fs(e){return nm(e)?(e.nodeName||"").toLowerCase():"#document"}function at(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function zt(e){var n;return(n=(nm(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function nm(e){return Sr()?e instanceof Node||e instanceof at(e).Node:!1}function wt(e){return Sr()?e instanceof Element||e instanceof at(e).Element:!1}function It(e){return Sr()?e instanceof HTMLElement||e instanceof at(e).HTMLElement:!1}function mc(e){return!Sr()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof at(e).ShadowRoot}const b2=new Set(["inline","contents"]);function Js(e){const{overflow:n,overflowX:s,overflowY:o,display:r}=jt(e);return/auto|scroll|overlay|hidden|clip/.test(n+o+s)&&!b2.has(r)}const v2=new Set(["table","td","th"]);function y2(e){return v2.has(fs(e))}const w2=[":popover-open",":modal"];function Nr(e){return w2.some(n=>{try{return e.matches(n)}catch{return!1}})}const j2=["transform","translate","scale","rotate","perspective"],S2=["transform","translate","scale","rotate","perspective","filter"],N2=["paint","layout","strict","content"];function sl(e){const n=ol(),s=wt(e)?jt(e):e;return j2.some(o=>s[o]?s[o]!=="none":!1)||(s.containerType?s.containerType!=="normal":!1)||!n&&(s.backdropFilter?s.backdropFilter!=="none":!1)||!n&&(s.filter?s.filter!=="none":!1)||S2.some(o=>(s.willChange||"").includes(o))||N2.some(o=>(s.contain||"").includes(o))}function C2(e){let n=cn(e);for(;It(n)&&!is(n);){if(sl(n))return n;if(Nr(n))return null;n=cn(n)}return null}function ol(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const k2=new Set(["html","body","#document"]);function is(e){return k2.has(fs(e))}function jt(e){return at(e).getComputedStyle(e)}function Cr(e){return wt(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cn(e){if(fs(e)==="html")return e;const n=e.assignedSlot||e.parentNode||mc(e)&&e.host||zt(e);return mc(n)?n.host:n}function sm(e){const n=cn(e);return is(n)?e.ownerDocument?e.ownerDocument.body:e.body:It(n)&&Js(n)?n:sm(n)}function Ls(e,n,s){var o;n===void 0&&(n=[]),s===void 0&&(s=!0);const r=sm(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=at(r);if(a){const c=Ya(i);return n.concat(i,i.visualViewport||[],Js(r)?r:[],c&&s?Ls(c):[])}return n.concat(r,Ls(r,[],s))}function Ya(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function om(e){const n=jt(e);let s=parseFloat(n.width)||0,o=parseFloat(n.height)||0;const r=It(e),a=r?e.offsetWidth:s,i=r?e.offsetHeight:o,c=Go(s)!==a||Go(o)!==i;return c&&(s=a,o=i),{width:s,height:o,$:c}}function rl(e){return wt(e)?e:e.contextElement}function Qn(e){const n=rl(e);if(!It(n))return Mt(1);const s=n.getBoundingClientRect(),{width:o,height:r,$:a}=om(n);let i=(a?Go(s.width):s.width)/o,c=(a?Go(s.height):s.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!c||!Number.isFinite(c))&&(c=1),{x:i,y:c}}const _2=Mt(0);function rm(e){const n=at(e);return!ol()||!n.visualViewport?_2:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function T2(e,n,s){return n===void 0&&(n=!1),!s||n&&s!==at(e)?!1:n}function Rn(e,n,s,o){n===void 0&&(n=!1),s===void 0&&(s=!1);const r=e.getBoundingClientRect(),a=rl(e);let i=Mt(1);n&&(o?wt(o)&&(i=Qn(o)):i=Qn(e));const c=T2(a,s,o)?rm(a):Mt(0);let d=(r.left+c.x)/i.x,m=(r.top+c.y)/i.y,u=r.width/i.x,p=r.height/i.y;if(a){const f=at(a),h=o&&wt(o)?at(o):o;let g=f,b=Ya(g);for(;b&&o&&h!==g;){const y=Qn(b),w=b.getBoundingClientRect(),v=jt(b),j=w.left+(b.clientLeft+parseFloat(v.paddingLeft))*y.x,S=w.top+(b.clientTop+parseFloat(v.paddingTop))*y.y;d*=y.x,m*=y.y,u*=y.x,p*=y.y,d+=j,m+=S,g=at(b),b=Ya(g)}}return Yo({width:u,height:p,x:d,y:m})}function kr(e,n){const s=Cr(e).scrollLeft;return n?n.left+s:Rn(zt(e)).left+s}function am(e,n){const s=e.getBoundingClientRect(),o=s.left+n.scrollLeft-kr(e,s),r=s.top+n.scrollTop;return{x:o,y:r}}function E2(e){let{elements:n,rect:s,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=zt(o),c=n?Nr(n.floating):!1;if(o===i||c&&a)return s;let d={scrollLeft:0,scrollTop:0},m=Mt(1);const u=Mt(0),p=It(o);if((p||!p&&!a)&&((fs(o)!=="body"||Js(i))&&(d=Cr(o)),It(o))){const h=Rn(o);m=Qn(o),u.x=h.x+o.clientLeft,u.y=h.y+o.clientTop}const f=i&&!p&&!a?am(i,d):Mt(0);return{width:s.width*m.x,height:s.height*m.y,x:s.x*m.x-d.scrollLeft*m.x+u.x+f.x,y:s.y*m.y-d.scrollTop*m.y+u.y+f.y}}function R2(e){return Array.from(e.getClientRects())}function M2(e){const n=zt(e),s=Cr(e),o=e.ownerDocument.body,r=st(n.scrollWidth,n.clientWidth,o.scrollWidth,o.clientWidth),a=st(n.scrollHeight,n.clientHeight,o.scrollHeight,o.clientHeight);let i=-s.scrollLeft+kr(e);const c=-s.scrollTop;return jt(o).direction==="rtl"&&(i+=st(n.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:c}}const pc=25;function A2(e,n){const s=at(e),o=zt(e),r=s.visualViewport;let a=o.clientWidth,i=o.clientHeight,c=0,d=0;if(r){a=r.width,i=r.height;const u=ol();(!u||u&&n==="fixed")&&(c=r.offsetLeft,d=r.offsetTop)}const m=kr(o);if(m<=0){const u=o.ownerDocument,p=u.body,f=getComputedStyle(p),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(o.clientWidth-p.clientWidth-h);g<=pc&&(a-=g)}else m<=pc&&(a+=m);return{width:a,height:i,x:c,y:d}}const I2=new Set(["absolute","fixed"]);function P2(e,n){const s=Rn(e,!0,n==="fixed"),o=s.top+e.clientTop,r=s.left+e.clientLeft,a=It(e)?Qn(e):Mt(1),i=e.clientWidth*a.x,c=e.clientHeight*a.y,d=r*a.x,m=o*a.y;return{width:i,height:c,x:d,y:m}}function fc(e,n,s){let o;if(n==="viewport")o=A2(e,s);else if(n==="document")o=M2(zt(e));else if(wt(n))o=P2(n,s);else{const r=rm(e);o={x:n.x-r.x,y:n.y-r.y,width:n.width,height:n.height}}return Yo(o)}function im(e,n){const s=cn(e);return s===n||!wt(s)||is(s)?!1:jt(s).position==="fixed"||im(s,n)}function L2(e,n){const s=n.get(e);if(s)return s;let o=Ls(e,[],!1).filter(c=>wt(c)&&fs(c)!=="body"),r=null;const a=jt(e).position==="fixed";let i=a?cn(e):e;for(;wt(i)&&!is(i);){const c=jt(i),d=sl(i);!d&&c.position==="fixed"&&(r=null),(a?!d&&!r:!d&&c.position==="static"&&!!r&&I2.has(r.position)||Js(i)&&!d&&im(e,i))?o=o.filter(u=>u!==i):r=c,i=cn(i)}return n.set(e,o),o}function O2(e){let{element:n,boundary:s,rootBoundary:o,strategy:r}=e;const i=[...s==="clippingAncestors"?Nr(n)?[]:L2(n,this._c):[].concat(s),o],c=i[0],d=i.reduce((m,u)=>{const p=fc(n,u,r);return m.top=st(p.top,m.top),m.right=ln(p.right,m.right),m.bottom=ln(p.bottom,m.bottom),m.left=st(p.left,m.left),m},fc(n,c,r));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function D2(e){const{width:n,height:s}=om(e);return{width:n,height:s}}function z2(e,n,s){const o=It(n),r=zt(n),a=s==="fixed",i=Rn(e,!0,a,n);let c={scrollLeft:0,scrollTop:0};const d=Mt(0);function m(){d.x=kr(r)}if(o||!o&&!a)if((fs(n)!=="body"||Js(r))&&(c=Cr(n)),o){const h=Rn(n,!0,a,n);d.x=h.x+n.clientLeft,d.y=h.y+n.clientTop}else r&&m();a&&!o&&r&&m();const u=r&&!o&&!a?am(r,c):Mt(0),p=i.left+c.scrollLeft-d.x-u.x,f=i.top+c.scrollTop-d.y-u.y;return{x:p,y:f,width:i.width,height:i.height}}function oa(e){return jt(e).position==="static"}function hc(e,n){if(!It(e)||jt(e).position==="fixed")return null;if(n)return n(e);let s=e.offsetParent;return zt(e)===s&&(s=s.ownerDocument.body),s}function lm(e,n){const s=at(e);if(Nr(e))return s;if(!It(e)){let r=cn(e);for(;r&&!is(r);){if(wt(r)&&!oa(r))return r;r=cn(r)}return s}let o=hc(e,n);for(;o&&y2(o)&&oa(o);)o=hc(o,n);return o&&is(o)&&oa(o)&&!sl(o)?s:o||C2(e)||s}const $2=async function(e){const n=this.getOffsetParent||lm,s=this.getDimensions,o=await s(e.floating);return{reference:z2(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function F2(e){return jt(e).direction==="rtl"}const U2={convertOffsetParentRelativeRectToViewportRelativeRect:E2,getDocumentElement:zt,getClippingRect:O2,getOffsetParent:lm,getElementRects:$2,getClientRects:R2,getDimensions:D2,getScale:Qn,isElement:wt,isRTL:F2};function cm(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function B2(e,n){let s=null,o;const r=zt(e);function a(){var c;clearTimeout(o),(c=s)==null||c.disconnect(),s=null}function i(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),a();const m=e.getBoundingClientRect(),{left:u,top:p,width:f,height:h}=m;if(c||n(),!f||!h)return;const g=mo(p),b=mo(r.clientWidth-(u+f)),y=mo(r.clientHeight-(p+h)),w=mo(u),j={rootMargin:-g+"px "+-b+"px "+-y+"px "+-w+"px",threshold:st(0,ln(1,d))||1};let S=!0;function N(C){const R=C[0].intersectionRatio;if(R!==d){if(!S)return i();R?i(!1,R):o=setTimeout(()=>{i(!1,1e-7)},1e3)}R===1&&!cm(m,e.getBoundingClientRect())&&i(),S=!1}try{s=new IntersectionObserver(N,{...j,root:r.ownerDocument})}catch{s=new IntersectionObserver(N,j)}s.observe(e)}return i(!0),a}function q2(e,n,s,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=o,m=rl(e),u=r||a?[...m?Ls(m):[],...Ls(n)]:[];u.forEach(w=>{r&&w.addEventListener("scroll",s,{passive:!0}),a&&w.addEventListener("resize",s)});const p=m&&c?B2(m,s):null;let f=-1,h=null;i&&(h=new ResizeObserver(w=>{let[v]=w;v&&v.target===m&&h&&(h.unobserve(n),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var j;(j=h)==null||j.observe(n)})),s()}),m&&!d&&h.observe(m),h.observe(n));let g,b=d?Rn(e):null;d&&y();function y(){const w=Rn(e);b&&!cm(b,w)&&s(),b=w,g=requestAnimationFrame(y)}return s(),()=>{var w;u.forEach(v=>{r&&v.removeEventListener("scroll",s),a&&v.removeEventListener("resize",s)}),p?.(),(w=h)==null||w.disconnect(),h=null,d&&cancelAnimationFrame(g)}}const H2=f2,W2=h2,V2=u2,K2=g2,G2=m2,xc=d2,J2=x2,Y2=(e,n,s)=>{const o=new Map,r={platform:U2,...s},a={...r.platform,_c:o};return c2(e,n,{...r,platform:a})};var X2=typeof document<"u",Z2=function(){},Io=X2?l.useLayoutEffect:Z2;function Xo(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let s,o,r;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==n.length)return!1;for(o=s;o--!==0;)if(!Xo(e[o],n[o]))return!1;return!0}if(r=Object.keys(e),s=r.length,s!==Object.keys(n).length)return!1;for(o=s;o--!==0;)if(!{}.hasOwnProperty.call(n,r[o]))return!1;for(o=s;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!Xo(e[a],n[a]))return!1}return!0}return e!==e&&n!==n}function dm(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function gc(e,n){const s=dm(e);return Math.round(n*s)/s}function ra(e){const n=l.useRef(e);return Io(()=>{n.current=e}),n}function Q2(e){e===void 0&&(e={});const{placement:n="bottom",strategy:s="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:c=!0,whileElementsMounted:d,open:m}=e,[u,p]=l.useState({x:0,y:0,strategy:s,placement:n,middlewareData:{},isPositioned:!1}),[f,h]=l.useState(o);Xo(f,o)||h(o);const[g,b]=l.useState(null),[y,w]=l.useState(null),v=l.useCallback(H=>{H!==C.current&&(C.current=H,b(H))},[]),j=l.useCallback(H=>{H!==R.current&&(R.current=H,w(H))},[]),S=a||g,N=i||y,C=l.useRef(null),R=l.useRef(null),I=l.useRef(u),P=d!=null,M=ra(d),k=ra(r),A=ra(m),D=l.useCallback(()=>{if(!C.current||!R.current)return;const H={placement:n,strategy:s,middleware:f};k.current&&(H.platform=k.current),Y2(C.current,R.current,H).then(Y=>{const U={...Y,isPositioned:A.current!==!1};$.current&&!Xo(I.current,U)&&(I.current=U,ms.flushSync(()=>{p(U)}))})},[f,n,s,k,A]);Io(()=>{m===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,p(H=>({...H,isPositioned:!1})))},[m]);const $=l.useRef(!1);Io(()=>($.current=!0,()=>{$.current=!1}),[]),Io(()=>{if(S&&(C.current=S),N&&(R.current=N),S&&N){if(M.current)return M.current(S,N,D);D()}},[S,N,D,M,P]);const J=l.useMemo(()=>({reference:C,floating:R,setReference:v,setFloating:j}),[v,j]),X=l.useMemo(()=>({reference:S,floating:N}),[S,N]),F=l.useMemo(()=>{const H={position:s,left:0,top:0};if(!X.floating)return H;const Y=gc(X.floating,u.x),U=gc(X.floating,u.y);return c?{...H,transform:"translate("+Y+"px, "+U+"px)",...dm(X.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:Y,top:U}},[s,c,X.floating,u.x,u.y]);return l.useMemo(()=>({...u,update:D,refs:J,elements:X,floatingStyles:F}),[u,D,J,X,F])}const ey=e=>{function n(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:o,padding:r}=typeof e=="function"?e(s):e;return o&&n(o)?o.current!=null?xc({element:o.current,padding:r}).fn(s):{}:o?xc({element:o,padding:r}).fn(s):{}}}},ty=(e,n)=>({...H2(e),options:[e,n]}),ny=(e,n)=>({...W2(e),options:[e,n]}),sy=(e,n)=>({...J2(e),options:[e,n]}),oy=(e,n)=>({...V2(e),options:[e,n]}),ry=(e,n)=>({...K2(e),options:[e,n]}),ay=(e,n)=>({...G2(e),options:[e,n]}),iy=(e,n)=>({...ey(e),options:[e,n]});var ly="Arrow",um=l.forwardRef((e,n)=>{const{children:s,width:o=10,height:r=5,...a}=e;return t.jsx(xe.svg,{...a,ref:n,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});um.displayName=ly;var cy=um,al="Popper",[mm,_r]=Jt(al),[dy,pm]=mm(al),fm=e=>{const{__scopePopper:n,children:s}=e,[o,r]=l.useState(null),[a,i]=l.useState(void 0);return t.jsx(dy,{scope:n,anchor:o,onAnchorChange:r,placementState:a,setPlacementState:i,children:s})};fm.displayName=al;var hm="PopperAnchor",xm=l.forwardRef((e,n)=>{const{__scopePopper:s,virtualRef:o,...r}=e,a=pm(hm,s),i=l.useRef(null),c=a.onAnchorChange,d=l.useCallback(g=>{i.current=g,g&&c(g)},[c]),m=Te(n,d),u=l.useRef(null);l.useEffect(()=>{if(!o)return;const g=u.current;u.current=o.current,g!==u.current&&c(u.current)});const p=a.placementState&&ll(a.placementState),f=p?.[0],h=p?.[1];return o?null:t.jsx(xe.div,{"data-radix-popper-side":f,"data-radix-popper-align":h,...r,ref:m})});xm.displayName=hm;var il="PopperContent",[uy,my]=mm(il),gm=l.forwardRef((e,n)=>{const{__scopePopper:s,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:m=[],collisionPadding:u=0,sticky:p="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:g,...b}=e,y=pm(il,s),[w,v]=l.useState(null),j=Te(n,v),[S,N]=l.useState(null),C=Yv(S),R=C?.width??0,I=C?.height??0,P=o+(a!=="center"?"-"+a:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(m)?m:[m],A=k.length>0,D={padding:M,boundary:k.filter(fy),altBoundary:A},{refs:$,floatingStyles:J,placement:X,isPositioned:F,middlewareData:H}=Q2({strategy:"fixed",placement:P,whileElementsMounted:(...Se)=>q2(...Se,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[ty({mainAxis:r+I,alignmentAxis:i}),d&&ny({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?sy():void 0,...D}),d&&oy({...D}),ry({...D,apply:({elements:Se,rects:Ne,availableWidth:ie,availableHeight:le})=>{const{width:fe,height:ve}=Ne.reference,Ce=Se.floating.style;Ce.setProperty("--radix-popper-available-width",`${ie}px`),Ce.setProperty("--radix-popper-available-height",`${le}px`),Ce.setProperty("--radix-popper-anchor-width",`${fe}px`),Ce.setProperty("--radix-popper-anchor-height",`${ve}px`)}}),S&&iy({element:S,padding:c}),hy({arrowWidth:R,arrowHeight:I}),f&&ay({strategy:"referenceHidden",...D,boundary:A?D.boundary:void 0})]}),Y=y.setPlacementState;Ue(()=>(Y(X),()=>{Y(void 0)}),[X,Y]);const[U,W]=ll(X),me=He(g);Ue(()=>{F&&me?.()},[F,me]);const ge=H.arrow?.x,be=H.arrow?.y,z=H.arrow?.centerOffset!==0,[oe,te]=l.useState();return Ue(()=>{w&&te(window.getComputedStyle(w).zIndex)},[w]),t.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...J,transform:F?J.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[H.transformOrigin?.x,H.transformOrigin?.y].join(" "),...H.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(uy,{scope:s,placedSide:U,placedAlign:W,onArrowChange:N,arrowX:ge,arrowY:be,shouldHideArrow:z,children:t.jsx(xe.div,{"data-side":U,"data-align":W,...b,ref:j,style:{...b.style,animation:F?void 0:"none"}})})})});gm.displayName=il;var bm="PopperArrow",py={top:"bottom",right:"left",bottom:"top",left:"right"},vm=l.forwardRef(function(n,s){const{__scopePopper:o,...r}=n,a=my(bm,o),i=py[a.placedSide];return t.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:t.jsx(cy,{...r,ref:s,style:{...r.style,display:"block"}})})});vm.displayName=bm;function fy(e){return e!==null}var hy=e=>({name:"transformOrigin",options:e,fn(n){const{placement:s,rects:o,middlewareData:r}=n,i=r.arrow?.centerOffset!==0,c=i?0:e.arrowWidth,d=i?0:e.arrowHeight,[m,u]=ll(s),p={start:"0%",center:"50%",end:"100%"}[u],f=(r.arrow?.x??0)+c/2,h=(r.arrow?.y??0)+d/2;let g="",b="";return m==="bottom"?(g=i?p:`${f}px`,b=`${-d}px`):m==="top"?(g=i?p:`${f}px`,b=`${o.floating.height+d}px`):m==="right"?(g=`${-d}px`,b=i?p:`${h}px`):m==="left"&&(g=`${o.floating.width+d}px`,b=i?p:`${h}px`),{data:{x:g,y:b}}}});function ll(e){const[n,s="center"]=e.split("-");return[n,s]}var ym=fm,wm=xm,jm=gm,Sm=vm,aa=!1;function xy(){const[e,n]=l.useState(aa);return l.useEffect(()=>{aa||(aa=!0,n(!0))},[]),e}var Nm=pr[" useSyncExternalStore ".trim().toString()];function gy(){return()=>{}}function by(){return Nm(gy,()=>!0,()=>!1)}var vy=typeof Nm=="function"?by:xy,ia="rovingFocusGroup.onEntryFocus",yy={bubbles:!1,cancelable:!0},Ys="RovingFocusGroup",[Xa,Cm,wy]=ju(Ys),[jy,km]=Jt(Ys,[wy]),[Sy,Ny]=jy(Ys),_m=l.forwardRef((e,n)=>t.jsx(Xa.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Xa.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Cy,{...e,ref:n})})}));_m.displayName=Ys;var Cy=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,orientation:o,loop:r=!1,dir:a,currentTabStopId:i,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:m,preventScrollOnEntryFocus:u=!1,...p}=e,f=l.useRef(null),h=Te(n,f),g=br(a),[b,y]=En({prop:i,defaultProp:c??null,onChange:d,caller:Ys}),[w,v]=l.useState(!1),j=He(m),S=Cm(s),N=l.useRef(!1),[C,R]=l.useState(0);return l.useEffect(()=>{const I=f.current;if(I)return I.addEventListener(ia,j),()=>I.removeEventListener(ia,j)},[j]),t.jsx(Sy,{scope:s,orientation:o,dir:g,loop:r,currentTabStopId:b,onItemFocus:l.useCallback(I=>y(I),[y]),onItemShiftTab:l.useCallback(()=>v(!0),[]),onFocusableItemAdd:l.useCallback(()=>R(I=>I+1),[]),onFocusableItemRemove:l.useCallback(()=>R(I=>I-1),[]),children:t.jsx(xe.div,{tabIndex:w||C===0?-1:0,"data-orientation":o,...p,ref:h,style:{outline:"none",...e.style},onMouseDown:de(e.onMouseDown,()=>{N.current=!0}),onFocus:de(e.onFocus,I=>{const P=!N.current;if(I.target===I.currentTarget&&P&&!w){const M=new CustomEvent(ia,yy);if(I.currentTarget.dispatchEvent(M),!M.defaultPrevented){const k=S().filter(X=>X.focusable),A=k.find(X=>X.active),D=k.find(X=>X.id===b),J=[A,D,...k].filter(Boolean).map(X=>X.ref.current);Rm(J,u)}}N.current=!1}),onBlur:de(e.onBlur,()=>v(!1))})})}),Tm="RovingFocusGroupItem",Em=l.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:s,focusable:o=!0,active:r=!1,tabStopId:a,children:i,...c}=e,d=Rt(),m=a||d,u=Ny(Tm,s),p=u.currentTabStopId===m,f=Cm(s),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:b}=u,y=vy();return Ue(()=>{if(!(!y||!o))return h(),()=>g()},[y,o,h,g]),l.useEffect(()=>{if(!(y||!o))return h(),()=>g()},[y,o,h,g]),t.jsx(Xa.ItemSlot,{scope:s,id:m,focusable:o,active:r,children:t.jsx(xe.span,{tabIndex:p?0:-1,"data-orientation":u.orientation,...c,ref:n,onMouseDown:de(e.onMouseDown,w=>{o?u.onItemFocus(m):w.preventDefault()}),onFocus:de(e.onFocus,()=>u.onItemFocus(m)),onKeyDown:de(e.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){u.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const v=Ty(w,u.orientation,u.dir);if(v!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let S=f().filter(N=>N.focusable).map(N=>N.ref.current);if(v==="last")S.reverse();else if(v==="prev"||v==="next"){v==="prev"&&S.reverse();const N=S.indexOf(w.currentTarget);S=u.loop?Ey(S,N+1):S.slice(N+1)}setTimeout(()=>Rm(S))}}),children:typeof i=="function"?i({isCurrentTabStop:p,hasTabStop:b!=null}):i})})});Em.displayName=Tm;var ky={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function _y(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Ty(e,n,s){const o=_y(e.key,s);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return ky[o]}function Rm(e,n=!1){const s=document.activeElement;for(const o of e)if(o===s||(o.focus({preventScroll:n}),document.activeElement!==s))return}function Ey(e,n){return e.map((s,o)=>e[(n+o)%e.length])}var Ry=_m,My=Em;function Za(e,[n,s]){return Math.min(s,Math.max(n,e))}function Ay(e,n){return l.useReducer((s,o)=>n[s][o]??s,e)}var cl="ScrollArea",[Mm]=Jt(cl),[Iy,pt]=Mm(cl),Am=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,type:o="hover",dir:r,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[w,v]=l.useState(0),[j,S]=l.useState(0),[N,C]=l.useState(!1),[R,I]=l.useState(!1),P=Te(n,d),M=br(r);return t.jsx(Iy,{scope:s,type:o,dir:M,scrollHideDelay:a,scrollArea:c,viewport:m,onViewportChange:u,content:p,onContentChange:f,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:N,onScrollbarXEnabledChange:C,scrollbarY:b,onScrollbarYChange:y,scrollbarYEnabled:R,onScrollbarYEnabledChange:I,onCornerWidthChange:v,onCornerHeightChange:S,children:t.jsx(xe.div,{dir:M,...i,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":j+"px",...e.style}})})});Am.displayName=cl;var Im="ScrollAreaViewport",Pm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,children:o,nonce:r,...a}=e,i=pt(Im,s),c=l.useRef(null),d=Te(n,c,i.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx(Py,{nonce:r}),t.jsx(xe.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});Pm.displayName=Im;var Py=l.memo(({nonce:e})=>t.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,n)=>e.nonce===n.nonce),$t="ScrollAreaScrollbar",Lm=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=pt($t,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=r,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),r.type==="hover"?t.jsx(Ly,{...o,ref:n,forceMount:s}):r.type==="scroll"?t.jsx(Oy,{...o,ref:n,forceMount:s}):r.type==="auto"?t.jsx(Om,{...o,ref:n,forceMount:s}):r.type==="always"?t.jsx(dl,{...o,ref:n,"data-state":"visible"}):null});Lm.displayName=$t;var Ly=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=pt($t,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=r.scrollArea;let d=0;if(c){const m=()=>{window.clearTimeout(d),i(!0)},u=()=>{d=window.setTimeout(()=>i(!1),r.scrollHideDelay)};return c.addEventListener("pointerenter",m),c.addEventListener("pointerleave",u),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",m),c.removeEventListener("pointerleave",u)}}},[r.scrollArea,r.scrollHideDelay]),t.jsx(lt,{present:s||a,children:t.jsx(Om,{"data-state":a?"visible":"hidden",...o,ref:n})})}),Oy=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=pt($t,e.__scopeScrollArea),a=e.orientation==="horizontal",i=Er(()=>d("SCROLL_END"),100),[c,d]=Ay("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 l.useEffect(()=>{if(c==="idle"){const m=window.setTimeout(()=>d("HIDE"),r.scrollHideDelay);return()=>window.clearTimeout(m)}},[c,r.scrollHideDelay,d]),l.useEffect(()=>{const m=r.viewport,u=a?"scrollLeft":"scrollTop";if(m){let p=m[u];const f=()=>{const h=m[u];p!==h&&(d("SCROLL"),i()),p=h};return m.addEventListener("scroll",f),()=>m.removeEventListener("scroll",f)}},[r.viewport,a,d,i]),t.jsx(lt,{present:s||c!=="hidden",children:t.jsx(dl,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:de(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:de(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Om=l.forwardRef((e,n)=>{const s=pt($t,e.__scopeScrollArea),{forceMount:o,...r}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=Er(()=>{if(s.viewport){const m=s.viewport.offsetWidth<s.viewport.scrollWidth,u=s.viewport.offsetHeight<s.viewport.scrollHeight;i(c?m:u)}},10);return ls(s.viewport,d),ls(s.content,d),t.jsx(lt,{present:o||a,children:t.jsx(dl,{"data-state":a?"visible":"hidden",...r,ref:n})})}),dl=l.forwardRef((e,n)=>{const{orientation:s="vertical",...o}=e,r=pt($t,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=Um(c.viewport,c.content),u={...o,sizes:c,onSizesChange:d,hasThumb:m>0&&m<1,onThumbChange:f=>a.current=f,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:f=>i.current=f};function p(f,h){return By(f,i.current,c,h)}return s==="horizontal"?t.jsx(Dy,{...u,ref:n,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollLeft,h=bc(f,c,r.dir);a.current.style.transform=`translate3d(${h}px, 0, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollLeft=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollLeft=p(f,r.dir))}}):s==="vertical"?t.jsx(zy,{...u,ref:n,onThumbPositionChange:()=>{if(r.viewport&&a.current){const f=r.viewport.scrollTop,h=bc(f,c);a.current.style.transform=`translate3d(0, ${h}px, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollTop=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollTop=p(f))}}):null}),Dy=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:o,...r}=e,a=pt($t,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Te(n,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(zm,{"data-orientation":"horizontal",...r,ref:m,sizes:s,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Tr(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,p)=>{if(a.viewport){const f=a.viewport.scrollLeft+u.deltaX;e.onWheelScroll(f),qm(f,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:Qo(i.paddingLeft),paddingEnd:Qo(i.paddingRight)}})}})}),zy=l.forwardRef((e,n)=>{const{sizes:s,onSizesChange:o,...r}=e,a=pt($t,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),m=Te(n,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(zm,{"data-orientation":"vertical",...r,ref:m,sizes:s,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Tr(s)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,p)=>{if(a.viewport){const f=a.viewport.scrollTop+u.deltaY;e.onWheelScroll(f),qm(f,p)&&u.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:Qo(i.paddingTop),paddingEnd:Qo(i.paddingBottom)}})}})}),[$y,Dm]=Mm($t),zm=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,sizes:o,hasThumb:r,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:m,onWheelScroll:u,onResize:p,...f}=e,h=pt($t,s),[g,b]=l.useState(null),y=Te(n,b),w=l.useRef(null),v=l.useRef(""),j=h.viewport,S=o.content-o.viewport,N=He(u),C=He(d),R=Er(p,10);function I(P){if(w.current){const M=P.clientX-w.current.left,k=P.clientY-w.current.top;m({x:M,y:k})}}return l.useEffect(()=>{const P=M=>{const k=M.target;g?.contains(k)&&N(M,S)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[j,g,S,N]),l.useEffect(C,[o,C]),ls(g,R),ls(h.content,R),t.jsx($y,{scope:s,scrollbar:g,hasThumb:r,onThumbChange:He(a),onThumbPointerUp:He(i),onThumbPositionChange:C,onThumbPointerDown:He(c),children:t.jsx(xe.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:de(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),w.current=g.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",h.viewport&&(h.viewport.style.scrollBehavior="auto"),I(P))}),onPointerMove:de(e.onPointerMove,I),onPointerUp:de(e.onPointerUp,P=>{const M=P.target;M.hasPointerCapture(P.pointerId)&&M.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=v.current,h.viewport&&(h.viewport.style.scrollBehavior=""),w.current=null})})})}),Zo="ScrollAreaThumb",$m=l.forwardRef((e,n)=>{const{forceMount:s,...o}=e,r=Dm(Zo,e.__scopeScrollArea);return t.jsx(lt,{present:s||r.hasThumb,children:t.jsx(Fy,{ref:n,...o})})}),Fy=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,style:o,...r}=e,a=pt(Zo,s),i=Dm(Zo,s),{onThumbPositionChange:c}=i,d=Te(n,i.onThumbChange),m=l.useRef(void 0),u=Er(()=>{m.current&&(m.current(),m.current=void 0)},100);return l.useEffect(()=>{const p=a.viewport;if(p){const f=()=>{if(u(),!m.current){const h=qy(p,c);m.current=h,c()}};return c(),p.addEventListener("scroll",f),()=>p.removeEventListener("scroll",f)}},[a.viewport,u,c]),t.jsx(xe.div,{"data-state":i.hasThumb?"visible":"hidden",...r,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:de(e.onPointerDownCapture,p=>{const h=p.target.getBoundingClientRect(),g=p.clientX-h.left,b=p.clientY-h.top;i.onThumbPointerDown({x:g,y:b})}),onPointerUp:de(e.onPointerUp,i.onThumbPointerUp)})});$m.displayName=Zo;var ul="ScrollAreaCorner",Fm=l.forwardRef((e,n)=>{const s=pt(ul,e.__scopeScrollArea),o=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&o?t.jsx(Uy,{...e,ref:n}):null});Fm.displayName=ul;var Uy=l.forwardRef((e,n)=>{const{__scopeScrollArea:s,...o}=e,r=pt(ul,s),[a,i]=l.useState(0),[c,d]=l.useState(0),m=!!(a&&c),{onCornerWidthChange:u,onCornerHeightChange:p}=r;return ls(r.scrollbarX,()=>{const f=r.scrollbarX?.offsetHeight||0;r.onCornerHeightChange(f),d(f)}),ls(r.scrollbarY,()=>{const f=r.scrollbarY?.offsetWidth||0;r.onCornerWidthChange(f),i(f)}),l.useEffect(()=>()=>{u(0),p(0)},[u,p]),m?t.jsx(xe.div,{...o,ref:n,style:{width:a,height:c,position:"absolute",right:r.dir==="ltr"?0:void 0,left:r.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Qo(e){return e?parseInt(e,10):0}function Um(e,n){const s=e/n;return isNaN(s)?0:s}function Tr(e){const n=Um(e.viewport,e.content),s=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-s)*n;return Math.max(o,18)}function By(e,n,s,o="ltr"){const r=Tr(s),a=r/2,i=n||a,c=r-i,d=s.scrollbar.paddingStart+i,m=s.scrollbar.size-s.scrollbar.paddingEnd-c,u=s.content-s.viewport,p=o==="ltr"?[0,u]:[u*-1,0];return Bm([d,m],p)(e)}function bc(e,n,s="ltr"){const o=Tr(n),r=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,a=n.scrollbar.size-r,i=n.content-n.viewport,c=a-o,d=s==="ltr"?[0,i]:[i*-1,0],m=Za(e,d);return Bm([0,i],[0,c])(m)}function Bm(e,n){return s=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(e[1]-e[0]);return n[0]+o*(s-e[0])}}function qm(e,n){return e>0&&e<n}var qy=(e,n=()=>{})=>{let s={left:e.scrollLeft,top:e.scrollTop},o=0;return(function r(){const a={left:e.scrollLeft,top:e.scrollTop},i=s.left!==a.left,c=s.top!==a.top;(i||c)&&n(),s=a,o=window.requestAnimationFrame(r)})(),()=>window.cancelAnimationFrame(o)};function Er(e,n){const s=He(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(s,n)},[s,n])}function ls(e,n){const s=He(n);Ue(()=>{let o=0;if(e){const r=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(s)});return r.observe(e),()=>{window.cancelAnimationFrame(o),r.unobserve(e)}}},[e,s])}var Hy=Am,Wy=Pm,Vy=Fm,Ky=[" ","Enter","ArrowUp","ArrowDown"],Gy=[" ","Enter"],Mn="Select",[Rr,Mr,Jy]=ju(Mn),[Pn]=Jt(Mn,[Jy,_r]),Ar=_r(),[Yy,mn]=Pn(Mn),[Xy,Zy]=Pn(Mn),Qy="SelectProvider";function Hm(e){const{__scopeSelect:n,children:s,open:o,defaultOpen:r,onOpenChange:a,value:i,defaultValue:c,onValueChange:d,dir:m,name:u,autoComplete:p,disabled:f,required:h,form:g,internal_do_not_use_render:b}=e,y=Ar(n),[w,v]=l.useState(null),[j,S]=l.useState(null),[N,C]=l.useState(!1),R=br(m),[I,P]=En({prop:o,defaultProp:r??!1,onChange:a,caller:Mn}),[M,k]=En({prop:i,defaultProp:c,onChange:d,caller:Mn}),A=l.useRef(null),D=l.useRef(M);l.useEffect(()=>{const me=g?w?.ownerDocument.getElementById(g):w?.form;if(me instanceof HTMLFormElement){const ge=()=>k(D.current);return me.addEventListener("reset",ge),()=>me.removeEventListener("reset",ge)}},[g,w,k]);const $=w?!!g||!!w.closest("form"):!0,[J,X]=l.useState(new Set),F=Rt(),H=Array.from(J).map(me=>me.props.value).join(";"),Y=l.useCallback(me=>{X(ge=>new Set(ge).add(me))},[]),U=l.useCallback(me=>{X(ge=>{const be=new Set(ge);return be.delete(me),be})},[]),W={required:h,trigger:w,onTriggerChange:v,valueNode:j,onValueNodeChange:S,valueNodeHasChildren:N,onValueNodeHasChildrenChange:C,contentId:F,value:M,onValueChange:k,open:I,onOpenChange:P,dir:R,triggerPointerDownPosRef:A,disabled:f,name:u,autoComplete:p,form:g,nativeOptions:J,nativeSelectKey:H,isFormControl:$};return t.jsx(ym,{...y,children:t.jsx(Yy,{scope:n,...W,children:t.jsx(Rr.Provider,{scope:n,children:t.jsx(Xy,{scope:n,onNativeOptionAdd:Y,onNativeOptionRemove:U,children:xw(b)?b(W):s})})})})}Hm.displayName=Qy;var Wm=e=>{const{__scopeSelect:n,children:s,...o}=e;return t.jsx(Hm,{__scopeSelect:n,...o,internal_do_not_use_render:({isFormControl:r})=>t.jsxs(t.Fragment,{children:[s,r?t.jsx(gp,{__scopeSelect:n}):null]})})};Wm.displayName=Mn;var Vm="SelectTrigger",Km=l.forwardRef((e,n)=>{const{__scopeSelect:s,disabled:o=!1,...r}=e,a=Ar(s),i=mn(Vm,s),c=i.disabled||o,d=Te(n,i.onTriggerChange),m=Mr(s),u=l.useRef("touch"),[p,f,h]=bp(b=>{const y=m().filter(j=>!j.disabled),w=y.find(j=>j.value===i.value),v=vp(y,b,w);v!==void 0&&i.onValueChange(v.value)}),g=b=>{c||(i.onOpenChange(!0),h()),b&&(i.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return t.jsx(wm,{asChild:!0,...a,children:t.jsx(xe.button,{type:"button",role:"combobox","aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":Ir(i.value)?"":void 0,...r,ref:d,onClick:de(r.onClick,b=>{b.currentTarget.focus(),u.current!=="mouse"&&g(b)}),onPointerDown:de(r.onPointerDown,b=>{u.current=b.pointerType;const y=b.target;y.hasPointerCapture(b.pointerId)&&y.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(g(b),b.preventDefault())}),onKeyDown:de(r.onKeyDown,b=>{const y=p.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&f(b.key),!(y&&b.key===" ")&&Ky.includes(b.key)&&(g(),b.preventDefault())})})})});Km.displayName=Vm;var Gm="SelectValue",Jm=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:o,style:r,children:a,placeholder:i="",...c}=e,d=mn(Gm,s),{onValueNodeHasChildrenChange:m}=d,u=a!==void 0,p=Te(n,d.onValueNodeChange);Ue(()=>{m(u)},[m,u]);const f=Ir(d.value);return t.jsx(xe.span,{...c,asChild:f?!1:c.asChild,ref:p,style:{pointerEvents:"none"},children:t.jsx(l.Fragment,{children:f?i:a},f?"placeholder":"value")})});Jm.displayName=Gm;var ew="SelectIcon",Ym=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:o,...r}=e;return t.jsx(xe.span,{"aria-hidden":!0,...r,ref:n,children:o||"▼"})});Ym.displayName=ew;var Xm="SelectPortal",[tw,nw]=Pn(Xm,{forceMount:void 0}),Zm=e=>{const{__scopeSelect:n,forceMount:s,...o}=e;return t.jsx(tw,{scope:e.__scopeSelect,forceMount:s,children:t.jsx(yr,{asChild:!0,...o})})};Zm.displayName=Xm;var dn="SelectContent",Qm=l.forwardRef((e,n)=>{const s=nw(dn,e.__scopeSelect),{forceMount:o=s.forceMount,...r}=e,a=mn(dn,e.__scopeSelect),[i,c]=l.useState();return Ue(()=>{c(new DocumentFragment)},[]),t.jsx(lt,{present:o||a.open,children:({present:d})=>d?t.jsx(np,{...r,ref:n}):t.jsx(ep,{...r,fragment:i})})});Qm.displayName=dn;var ep=l.forwardRef((e,n)=>{const{__scopeSelect:s,children:o,fragment:r}=e;return r?ms.createPortal(t.jsx(tp,{scope:s,children:t.jsx(Rr.Slot,{scope:s,children:t.jsx("div",{ref:n,children:o})})}),r):null});ep.displayName="SelectContentFragment";var bt=10,[tp,pn]=Pn(dn),sw="SelectContentImpl",ow=rs("SelectContent.RemoveScroll"),np=l.forwardRef((e,n)=>{const{__scopeSelect:s}=e,{position:o="item-aligned",onCloseAutoFocus:r,onEscapeKeyDown:a,onPointerDownOutside:i,side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:b,avoidCollisions:y,...w}=e,v=mn(dn,s),[j,S]=l.useState(null),[N,C]=l.useState(null),R=Te(n,S),[I,P]=l.useState(null),[M,k]=l.useState(null),A=Mr(s),[D,$]=l.useState(!1),J=l.useRef(!1);l.useEffect(()=>{if(j)return zu(j)},[j]),Eu();const X=l.useCallback(te=>{const[Se,...Ne]=A().map(fe=>fe.ref.current),[ie]=Ne.slice(-1),le=document.activeElement;for(const fe of te)if(fe===le||(fe?.scrollIntoView({block:"nearest"}),fe===Se&&N&&(N.scrollTop=0),fe===ie&&N&&(N.scrollTop=N.scrollHeight),fe?.focus(),document.activeElement!==le))return},[A,N]),F=l.useCallback(()=>X([I,j]),[X,I,j]);l.useEffect(()=>{D&&F()},[D,F]);const{onOpenChange:H,triggerPointerDownPosRef:Y}=v;l.useEffect(()=>{if(j){let te={x:0,y:0};const Se=ie=>{te={x:Math.abs(Math.round(ie.pageX)-(Y.current?.x??0)),y:Math.abs(Math.round(ie.pageY)-(Y.current?.y??0))}},Ne=ie=>{te.x<=10&&te.y<=10?ie.preventDefault():ie.composedPath().includes(j)||H(!1),document.removeEventListener("pointermove",Se),Y.current=null};return Y.current!==null&&(document.addEventListener("pointermove",Se),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Se),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[j,H,Y]),l.useEffect(()=>{const te=()=>H(!1);return window.addEventListener("blur",te),window.addEventListener("resize",te),()=>{window.removeEventListener("blur",te),window.removeEventListener("resize",te)}},[H]);const[U,W]=bp(te=>{const Se=A().filter(le=>!le.disabled),Ne=Se.find(le=>le.ref.current===document.activeElement),ie=vp(Se,te,Ne);ie&&setTimeout(()=>ie.ref.current?.focus())}),me=l.useCallback((te,Se,Ne)=>{const ie=!J.current&&!Ne;(v.value!==void 0&&v.value===Se||ie)&&(P(te),ie&&(J.current=!0))},[v.value]),ge=l.useCallback(()=>j?.focus(),[j]),be=l.useCallback((te,Se,Ne)=>{const ie=!J.current&&!Ne;(v.value!==void 0&&v.value===Se||ie)&&k(te)},[v.value]),z=o==="popper"?Qa:sp,oe=z===Qa?{side:c,sideOffset:d,align:m,alignOffset:u,arrowPadding:p,collisionBoundary:f,collisionPadding:h,sticky:g,hideWhenDetached:b,avoidCollisions:y}:{};return t.jsx(tp,{scope:s,content:j,viewport:N,onViewportChange:C,itemRefCallback:me,selectedItem:I,onItemLeave:ge,itemTextRefCallback:be,focusSelectedItem:F,selectedItemText:M,position:o,isPositioned:D,searchRef:U,children:t.jsx(Xi,{as:ow,allowPinchZoom:!0,children:t.jsx(Yi,{asChild:!0,trapped:v.open,onMountAutoFocus:te=>{te.preventDefault()},onUnmountAutoFocus:de(r,te=>{v.trigger?.focus({preventScroll:!0}),te.preventDefault()}),children:t.jsx(vr,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:te=>te.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:t.jsx(z,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:te=>te.preventDefault(),...w,...oe,onPlaced:()=>$(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...w.style},onKeyDown:de(w.onKeyDown,te=>{const Se=te.ctrlKey||te.altKey||te.metaKey;if(te.key==="Tab"&&te.preventDefault(),!Se&&te.key.length===1&&W(te.key),["ArrowUp","ArrowDown","Home","End"].includes(te.key)){let ie=A().filter(le=>!le.disabled).map(le=>le.ref.current);if(["ArrowUp","End"].includes(te.key)&&(ie=ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(te.key)){const le=te.target,fe=ie.indexOf(le);ie=ie.slice(fe+1)}setTimeout(()=>X(ie)),te.preventDefault()}})})})})})})});np.displayName=sw;var rw="SelectItemAlignedPosition",sp=l.forwardRef((e,n)=>{const{__scopeSelect:s,onPlaced:o,...r}=e,a=mn(dn,s),i=pn(dn,s),[c,d]=l.useState(null),[m,u]=l.useState(null),p=Te(n,u),f=Mr(s),h=l.useRef(!1),g=l.useRef(!0),{viewport:b,selectedItem:y,selectedItemText:w,focusSelectedItem:v}=i,j=l.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&m&&b&&y&&w){const R=a.trigger.getBoundingClientRect(),I=m.getBoundingClientRect(),P=a.valueNode.getBoundingClientRect(),M=w.getBoundingClientRect();if(a.dir!=="rtl"){const le=M.left-I.left,fe=P.left-le,ve=R.left-fe,Ce=R.width+ve,Ie=Math.max(Ce,I.width),$e=window.innerWidth-bt,Pe=Za(fe,[bt,Math.max(bt,$e-Ie)]);c.style.minWidth=Ce+"px",c.style.left=Pe+"px"}else{const le=I.right-M.right,fe=window.innerWidth-P.right-le,ve=window.innerWidth-R.right-fe,Ce=R.width+ve,Ie=Math.max(Ce,I.width),$e=window.innerWidth-bt,Pe=Za(fe,[bt,Math.max(bt,$e-Ie)]);c.style.minWidth=Ce+"px",c.style.right=Pe+"px"}const k=f(),A=window.innerHeight-bt*2,D=b.scrollHeight,$=window.getComputedStyle(m),J=parseInt($.borderTopWidth,10),X=parseInt($.paddingTop,10),F=parseInt($.borderBottomWidth,10),H=parseInt($.paddingBottom,10),Y=J+X+D+H+F,U=Math.min(y.offsetHeight*5,Y),W=window.getComputedStyle(b),me=parseInt(W.paddingTop,10),ge=parseInt(W.paddingBottom,10),be=R.top+R.height/2-bt,z=A-be,oe=y.offsetHeight/2,te=y.offsetTop+oe,Se=J+X+te,Ne=Y-Se;if(Se<=be){const le=k.length>0&&y===k[k.length-1].ref.current;c.style.bottom="0px";const fe=m.clientHeight-b.offsetTop-b.offsetHeight,ve=Math.max(z,oe+(le?ge:0)+fe+F),Ce=Se+ve;c.style.height=Ce+"px"}else{const le=k.length>0&&y===k[0].ref.current;c.style.top="0px";const ve=Math.max(be,J+b.offsetTop+(le?me:0)+oe)+Ne;c.style.height=ve+"px",b.scrollTop=Se-be+b.offsetTop}c.style.margin=`${bt}px 0`,c.style.minHeight=U+"px",c.style.maxHeight=A+"px",o?.(),requestAnimationFrame(()=>h.current=!0)}},[f,a.trigger,a.valueNode,c,m,b,y,w,a.dir,o]);Ue(()=>j(),[j]);const[S,N]=l.useState();Ue(()=>{m&&N(window.getComputedStyle(m).zIndex)},[m]);const C=l.useCallback(R=>{R&&g.current===!0&&(j(),v?.(),g.current=!1)},[j,v]);return t.jsx(iw,{scope:s,contentWrapper:c,shouldExpandOnScrollRef:h,onScrollButtonChange:C,children:t.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:t.jsx(xe.div,{...r,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...r.style}})})})});sp.displayName=rw;var aw="SelectPopperPosition",Qa=l.forwardRef((e,n)=>{const{__scopeSelect:s,align:o="start",collisionPadding:r=bt,...a}=e,i=Ar(s);return t.jsx(jm,{...i,...a,ref:n,align:o,collisionPadding:r,style:{boxSizing:"border-box",...a.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)"}})});Qa.displayName=aw;var[iw,ml]=Pn(dn,{}),ei="SelectViewport",op=l.forwardRef((e,n)=>{const{__scopeSelect:s,nonce:o,...r}=e,a=pn(ei,s),i=ml(ei,s),c=Te(n,a.onViewportChange),d=l.useRef(0);return t.jsxs(t.Fragment,{children:[t.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:o}),t.jsx(Rr.Slot,{scope:s,children:t.jsx(xe.div,{"data-radix-select-viewport":"",role:"presentation",...r,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...r.style},onScroll:de(r.onScroll,m=>{const u=m.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:f}=i;if(f?.current&&p){const h=Math.abs(d.current-u.scrollTop);if(h>0){const g=window.innerHeight-bt*2,b=parseFloat(p.style.minHeight),y=parseFloat(p.style.height),w=Math.max(b,y);if(w<g){const v=w+h,j=Math.min(g,v),S=v-j;p.style.height=j+"px",p.style.bottom==="0px"&&(u.scrollTop=S>0?S:0,p.style.justifyContent="flex-end")}}}d.current=u.scrollTop})})})]})});op.displayName=ei;var rp="SelectGroup",[lw,cw]=Pn(rp),dw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=Rt();return t.jsx(lw,{scope:s,id:r,children:t.jsx(xe.div,{role:"group","aria-labelledby":r,...o,ref:n})})});dw.displayName=rp;var ap="SelectLabel",uw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=cw(ap,s);return t.jsx(xe.div,{id:r.id,...o,ref:n})});uw.displayName=ap;var er="SelectItem",[mw,ip]=Pn(er),lp=l.forwardRef((e,n)=>{const{__scopeSelect:s,value:o,disabled:r=!1,textValue:a,...i}=e,c=mn(er,s),d=pn(er,s),m=c.value===o,[u,p]=l.useState(a??""),[f,h]=l.useState(!1),g=He(j=>d.itemRefCallback?.(j,o,r)),b=Te(n,g),y=Rt(),w=l.useRef("touch"),v=()=>{r||(c.onValueChange(o),c.onOpenChange(!1))};return t.jsx(mw,{scope:s,value:o,disabled:r,textId:y,isSelected:m,onItemTextChange:l.useCallback(j=>{p(S=>S||(j?.textContent??"").trim())},[]),children:t.jsx(Rr.ItemSlot,{scope:s,value:o,disabled:r,textValue:u,children:t.jsx(xe.div,{role:"option","aria-labelledby":y,"data-highlighted":f?"":void 0,"aria-selected":m&&f,"data-state":m?"checked":"unchecked","aria-disabled":r||void 0,"data-disabled":r?"":void 0,tabIndex:r?void 0:-1,...i,ref:b,onFocus:de(i.onFocus,()=>h(!0)),onBlur:de(i.onBlur,()=>h(!1)),onClick:de(i.onClick,()=>{w.current!=="mouse"&&v()}),onPointerUp:de(i.onPointerUp,()=>{w.current==="mouse"&&v()}),onPointerDown:de(i.onPointerDown,j=>{w.current=j.pointerType}),onPointerMove:de(i.onPointerMove,j=>{w.current=j.pointerType,r?d.onItemLeave?.():w.current==="mouse"&&j.currentTarget.focus({preventScroll:!0})}),onPointerLeave:de(i.onPointerLeave,j=>{j.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:de(i.onKeyDown,j=>{r||j.target!==j.currentTarget||d.searchRef?.current!==""&&j.key===" "||(Gy.includes(j.key)&&v(),j.key===" "&&j.preventDefault())})})})})});lp.displayName=er;var _s="SelectItemText",cp=l.forwardRef((e,n)=>{const{__scopeSelect:s,className:o,style:r,...a}=e,i=mn(_s,s),c=pn(_s,s),d=ip(_s,s),m=Zy(_s,s),[u,p]=l.useState(null),f=He(v=>c.itemTextRefCallback?.(v,d.value,d.disabled)),h=Te(n,p,d.onItemTextChange,f),g=u?.textContent,b=l.useMemo(()=>t.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:y,onNativeOptionRemove:w}=m;return Ue(()=>(y(b),()=>w(b)),[y,w,b]),t.jsxs(t.Fragment,{children:[t.jsx(xe.span,{id:d.textId,...a,ref:h}),d.isSelected&&i.valueNode&&!i.valueNodeHasChildren&&!Ir(i.value)?ms.createPortal(a.children,i.valueNode):null]})});cp.displayName=_s;var dp="SelectItemIndicator",up=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e;return ip(dp,s).isSelected?t.jsx(xe.span,{"aria-hidden":!0,...o,ref:n}):null});up.displayName=dp;var ti="SelectScrollUpButton",mp=l.forwardRef((e,n)=>{const s=pn(ti,e.__scopeSelect),o=ml(ti,e.__scopeSelect),[r,a]=l.useState(!1),i=Te(n,o.onScrollButtonChange);return Ue(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollTop>0;a(m)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),r?t.jsx(fp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});mp.displayName=ti;var ni="SelectScrollDownButton",pp=l.forwardRef((e,n)=>{const s=pn(ni,e.__scopeSelect),o=ml(ni,e.__scopeSelect),[r,a]=l.useState(!1),i=Te(n,o.onScrollButtonChange);return Ue(()=>{if(s.viewport&&s.isPositioned){let c=function(){const m=d.scrollHeight-d.clientHeight,u=Math.ceil(d.scrollTop)<m;a(u)};const d=s.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[s.viewport,s.isPositioned]),r?t.jsx(fp,{...e,ref:i,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=s;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});pp.displayName=ni;var fp=l.forwardRef((e,n)=>{const{__scopeSelect:s,onAutoScroll:o,...r}=e,a=pn("SelectScrollButton",s),i=l.useRef(null),c=Mr(s),d=l.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return l.useEffect(()=>()=>d(),[d]),Ue(()=>{c().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),t.jsx(xe.div,{"aria-hidden":!0,...r,ref:n,style:{flexShrink:0,...r.style},onPointerDown:de(r.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(o,50))}),onPointerMove:de(r.onPointerMove,()=>{a.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(o,50))}),onPointerLeave:de(r.onPointerLeave,()=>{d()})})}),pw="SelectSeparator",fw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e;return t.jsx(xe.div,{"aria-hidden":!0,...o,ref:n})});fw.displayName=pw;var hp="SelectArrow",hw=l.forwardRef((e,n)=>{const{__scopeSelect:s,...o}=e,r=Ar(s);return pn(hp,s).position==="popper"?t.jsx(Sm,{...r,...o,ref:n}):null});hw.displayName=hp;var xp="SelectBubbleInput",gp=l.forwardRef(({__scopeSelect:e,...n},s)=>{const o=mn(xp,e),{value:r,onValueChange:a,required:i,disabled:c,name:d,autoComplete:m,form:u}=o,{nativeOptions:p,nativeSelectKey:f}=o,h=l.useRef(null),g=Te(s,h),b=r??"",y=Jv(b),w=Array.from(p).some(v=>(v.props.value??"")==="");return l.useEffect(()=>{const v=h.current;if(!v)return;const j=window.HTMLSelectElement.prototype,N=Object.getOwnPropertyDescriptor(j,"value").set;if(y!==b&&N){const C=new Event("change",{bubbles:!0});N.call(v,b),v.dispatchEvent(C)}},[y,b]),t.jsxs(xe.select,{"aria-hidden":!0,required:i,tabIndex:-1,name:d,autoComplete:m,disabled:c,form:u,onChange:v=>a(v.target.value),...n,style:{...yu,...n.style},ref:g,defaultValue:b,children:[Ir(r)&&!w?t.jsx("option",{value:""}):null,Array.from(p)]},f)});gp.displayName=xp;function xw(e){return typeof e=="function"}function Ir(e){return e===""||e===void 0}function bp(e){const n=He(e),s=l.useRef(""),o=l.useRef(0),r=l.useCallback(i=>{const c=s.current+i;n(c),(function d(m){s.current=m,window.clearTimeout(o.current),m!==""&&(o.current=window.setTimeout(()=>d(""),1e3))})(c)},[n]),a=l.useCallback(()=>{s.current="",window.clearTimeout(o.current)},[]);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),[s,r,a]}function vp(e,n,s){const r=n.length>1&&Array.from(n).every(m=>m===n[0])?n[0]:n,a=s?e.indexOf(s):-1;let i=gw(e,Math.max(a,0));r.length===1&&(i=i.filter(m=>m!==s));const d=i.find(m=>m.textValue.toLowerCase().startsWith(r.toLowerCase()));return d!==s?d:void 0}function gw(e,n){return e.map((s,o)=>e[(n+o)%e.length])}var Pr="Tabs",[bw]=Jt(Pr,[km]),yp=km(),[vw,pl]=bw(Pr),wp=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,onValueChange:r,defaultValue:a,orientation:i="horizontal",dir:c,activationMode:d="automatic",...m}=e,u=br(c),[p,f]=En({prop:o,onChange:r,defaultProp:a??"",caller:Pr});return t.jsx(vw,{scope:s,baseId:Rt(),value:p,onValueChange:f,orientation:i,dir:u,activationMode:d,children:t.jsx(xe.div,{dir:u,"data-orientation":i,...m,ref:n})})});wp.displayName=Pr;var jp="TabsList",Sp=l.forwardRef((e,n)=>{const{__scopeTabs:s,loop:o=!0,...r}=e,a=pl(jp,s),i=yp(s);return t.jsx(Ry,{asChild:!0,...i,orientation:a.orientation,dir:a.dir,loop:o,children:t.jsx(xe.div,{role:"tablist","aria-orientation":a.orientation,...r,ref:n})})});Sp.displayName=jp;var Np="TabsTrigger",Cp=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,disabled:r=!1,...a}=e,i=pl(Np,s),c=yp(s),d=Tp(i.baseId,o),m=Ep(i.baseId,o),u=o===i.value;return t.jsx(My,{asChild:!0,...c,focusable:!r,active:u,children:t.jsx(xe.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":m,"data-state":u?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:d,...a,ref:n,onMouseDown:de(e.onMouseDown,p=>{!r&&p.button===0&&p.ctrlKey===!1?i.onValueChange(o):p.preventDefault()}),onKeyDown:de(e.onKeyDown,p=>{r||p.target!==p.currentTarget||[" ","Enter"].includes(p.key)&&i.onValueChange(o)}),onFocus:de(e.onFocus,()=>{const p=i.activationMode!=="manual";!u&&!r&&p&&i.onValueChange(o)})})})});Cp.displayName=Np;var kp="TabsContent",_p=l.forwardRef((e,n)=>{const{__scopeTabs:s,value:o,forceMount:r,children:a,...i}=e,c=pl(kp,s),d=Tp(c.baseId,o),m=Ep(c.baseId,o),u=o===c.value,p=l.useRef(u);return l.useEffect(()=>{const f=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(f)},[]),t.jsx(lt,{present:r||u,children:({present:f})=>t.jsx(xe.div,{"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!f,id:m,tabIndex:0,...i,ref:n,style:{...e.style,animationDuration:p.current?"0s":void 0},children:f&&a})})});_p.displayName=kp;function Tp(e,n){return`${e}-trigger-${n}`}function Ep(e,n){return`${e}-content-${n}`}var yw=wp,ww=Sp,jw=Cp,Sw=_p,[Lr]=Jt("Tooltip",[_r]),Or=_r(),Rp="TooltipProvider",Nw=700,si="tooltip.open",[Cw,fl]=Lr(Rp),Mp=e=>{const{__scopeTooltip:n,delayDuration:s=Nw,skipDelayDuration:o=300,disableHoverableContent:r=!1,children:a}=e,i=l.useRef(!0),c=l.useRef(!1),d=l.useRef(0);return l.useEffect(()=>{const m=d.current;return()=>window.clearTimeout(m)},[]),t.jsx(Cw,{scope:n,isOpenDelayedRef:i,delayDuration:s,onOpen:l.useCallback(()=>{o<=0||(window.clearTimeout(d.current),i.current=!1)},[o]),onClose:l.useCallback(()=>{o<=0||(window.clearTimeout(d.current),d.current=window.setTimeout(()=>i.current=!0,o))},[o]),isPointerInTransitRef:c,onPointerInTransitChange:l.useCallback(m=>{c.current=m},[]),disableHoverableContent:r,children:a})};Mp.displayName=Rp;var Os="Tooltip",[kw,Xs]=Lr(Os),Ap=e=>{const{__scopeTooltip:n,children:s,open:o,defaultOpen:r,onOpenChange:a,disableHoverableContent:i,delayDuration:c}=e,d=fl(Os,e.__scopeTooltip),m=Or(n),[u,p]=l.useState(null),f=Rt(),h=l.useRef(0),g=i??d.disableHoverableContent,b=c??d.delayDuration,y=l.useRef(!1),[w,v]=En({prop:o,defaultProp:r??!1,onChange:R=>{R?(d.onOpen(),document.dispatchEvent(new CustomEvent(si))):d.onClose(),a?.(R)},caller:Os}),j=l.useMemo(()=>w?y.current?"delayed-open":"instant-open":"closed",[w]),S=l.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,v(!0)},[v]),N=l.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v(!1)},[v]),C=l.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,v(!0),h.current=0},b)},[b,v]);return l.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),t.jsx(ym,{...m,children:t.jsx(kw,{scope:n,contentId:f,open:w,stateAttribute:j,trigger:u,onTriggerChange:p,onTriggerEnter:l.useCallback(()=>{d.isOpenDelayedRef.current?C():S()},[d.isOpenDelayedRef,C,S]),onTriggerLeave:l.useCallback(()=>{g?N():(window.clearTimeout(h.current),h.current=0)},[N,g]),onOpen:S,onClose:N,disableHoverableContent:g,children:s})})};Ap.displayName=Os;var oi="TooltipTrigger",Ip=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...o}=e,r=Xs(oi,s),a=fl(oi,s),i=Or(s),c=l.useRef(null),d=Te(n,c,r.onTriggerChange),m=l.useRef(!1),u=l.useRef(!1),p=l.useCallback(()=>m.current=!1,[]);return l.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),t.jsx(wm,{asChild:!0,...i,children:t.jsx(xe.button,{"aria-describedby":r.open?r.contentId:void 0,"data-state":r.stateAttribute,...o,ref:d,onPointerMove:de(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!a.isPointerInTransitRef.current&&(r.onTriggerEnter(),u.current=!0)}),onPointerLeave:de(e.onPointerLeave,()=>{r.onTriggerLeave(),u.current=!1}),onPointerDown:de(e.onPointerDown,()=>{r.open&&r.onClose(),m.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:de(e.onFocus,()=>{m.current||r.onOpen()}),onBlur:de(e.onBlur,r.onClose),onClick:de(e.onClick,r.onClose)})})});Ip.displayName=oi;var hl="TooltipPortal",[_w,Tw]=Lr(hl,{forceMount:void 0}),Pp=e=>{const{__scopeTooltip:n,forceMount:s,children:o,container:r}=e,a=Xs(hl,n);return t.jsx(_w,{scope:n,forceMount:s,children:t.jsx(lt,{present:s||a.open,children:t.jsx(yr,{asChild:!0,container:r,children:o})})})};Pp.displayName=hl;var cs="TooltipContent",Lp=l.forwardRef((e,n)=>{const s=Tw(cs,e.__scopeTooltip),{forceMount:o=s.forceMount,side:r="top",...a}=e,i=Xs(cs,e.__scopeTooltip);return t.jsx(lt,{present:o||i.open,children:i.disableHoverableContent?t.jsx(Op,{side:r,...a,ref:n}):t.jsx(Ew,{side:r,...a,ref:n})})}),Ew=l.forwardRef((e,n)=>{const s=Xs(cs,e.__scopeTooltip),o=fl(cs,e.__scopeTooltip),r=l.useRef(null),a=Te(n,r),[i,c]=l.useState(null),{trigger:d,onClose:m}=s,u=r.current,{onPointerInTransitChange:p}=o,f=l.useCallback(()=>{c(null),p(!1)},[p]),h=l.useCallback((g,b)=>{const y=g.currentTarget,w={x:g.clientX,y:g.clientY},v=Iw(w,y.getBoundingClientRect()),j=Pw(w,v),S=Lw(b.getBoundingClientRect()),N=Dw([...j,...S]);c(N),p(!0)},[p]);return l.useEffect(()=>()=>f(),[f]),l.useEffect(()=>{if(d&&u){const g=y=>h(y,u),b=y=>h(y,d);return d.addEventListener("pointerleave",g),u.addEventListener("pointerleave",b),()=>{d.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",b)}}},[d,u,h,f]),l.useEffect(()=>{if(i){const g=b=>{const y=b.target,w={x:b.clientX,y:b.clientY},v=d?.contains(y)||u?.contains(y),j=!Ow(w,i);v?f():j&&(f(),m())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[d,u,i,m,f]),t.jsx(Op,{...e,ref:a})}),[Rw,Mw]=Lr(Os,{isInside:!1}),Aw=pb("TooltipContent"),Op=l.forwardRef((e,n)=>{const{__scopeTooltip:s,children:o,"aria-label":r,onEscapeKeyDown:a,onPointerDownOutside:i,...c}=e,d=Xs(cs,s),m=Or(s),{onClose:u}=d;return l.useEffect(()=>(document.addEventListener(si,u),()=>document.removeEventListener(si,u)),[u]),l.useEffect(()=>{if(d.trigger){const p=f=>{f.target instanceof Node&&f.target.contains(d.trigger)&&u()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,u]),t.jsx(vr,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:p=>p.preventDefault(),onDismiss:u,children:t.jsxs(jm,{"data-state":d.stateAttribute,...m,...c,ref:n,style:{...c.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:[t.jsx(Aw,{children:o}),t.jsx(Rw,{scope:s,isInside:!0,children:t.jsx(Cb,{id:d.contentId,role:"tooltip",children:r||o})})]})})});Lp.displayName=cs;var Dp="TooltipArrow",zp=l.forwardRef((e,n)=>{const{__scopeTooltip:s,...o}=e,r=Or(s);return Mw(Dp,s).isInside?null:t.jsx(Sm,{...r,...o,ref:n})});zp.displayName=Dp;function Iw(e,n){const s=Math.abs(n.top-e.y),o=Math.abs(n.bottom-e.y),r=Math.abs(n.right-e.x),a=Math.abs(n.left-e.x);switch(Math.min(s,o,r,a)){case a:return"left";case r:return"right";case s:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function Pw(e,n,s=5){const o=[];switch(n){case"top":o.push({x:e.x-s,y:e.y+s},{x:e.x+s,y:e.y+s});break;case"bottom":o.push({x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s});break;case"left":o.push({x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s});break;case"right":o.push({x:e.x-s,y:e.y-s},{x:e.x-s,y:e.y+s});break}return o}function Lw(e){const{top:n,right:s,bottom:o,left:r}=e;return[{x:r,y:n},{x:s,y:n},{x:s,y:o},{x:r,y:o}]}function Ow(e,n){const{x:s,y:o}=e;let r=!1;for(let a=0,i=n.length-1;a<n.length;i=a++){const c=n[a],d=n[i],m=c.x,u=c.y,p=d.x,f=d.y;u>o!=f>o&&s<(p-m)*(o-u)/(f-u)+m&&(r=!r)}return r}function Dw(e){const n=e.slice();return n.sort((s,o)=>s.x<o.x?-1:s.x>o.x?1:s.y<o.y?-1:s.y>o.y?1:0),zw(n)}function zw(e){if(e.length<=1)return e.slice();const n=[];for(let o=0;o<e.length;o++){const r=e[o];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))n.pop();else break}n.push(r)}n.pop();const s=[];for(let o=e.length-1;o>=0;o--){const r=e[o];for(;s.length>=2;){const a=s[s.length-1],i=s[s.length-2];if((a.x-i.x)*(r.y-i.y)>=(a.y-i.y)*(r.x-i.x))s.pop();else break}s.push(r)}return s.pop(),n.length===1&&s.length===1&&n[0].x===s[0].x&&n[0].y===s[0].y?n:n.concat(s)}var $w=Mp,Fw=Ap,Uw=Ip,Bw=Pp,qw=Lp,Hw=zp;function Pt({...e}){return t.jsx(Fu,{"data-slot":"dialog",...e})}function Zs({...e}){return t.jsx(Bu,{"data-slot":"dialog-trigger",...e})}function Ww({...e}){return t.jsx(Hu,{"data-slot":"dialog-portal",...e})}function Vw({className:e,...n}){return t.jsx(Wu,{"data-slot":"dialog-overlay",className:O("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),...n})}function Lt({className:e,children:n,...s}){return t.jsxs(Ww,{children:[t.jsx(Vw,{}),t.jsxs(Vu,{"data-slot":"dialog-content",className:O("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),...s,children:[n,t.jsxs(Qu,{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:[t.jsx(Gs,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Ft({className:e,...n}){return t.jsx("div",{"data-slot":"dialog-header",className:O("flex flex-col space-y-1.5 text-center sm:text-left",e),...n})}function Ut({className:e,...n}){return t.jsx(Ju,{"data-slot":"dialog-title",className:O("text-lg font-semibold leading-none tracking-tight",e),...n})}function Qs({className:e,...n}){return t.jsx(Xu,{"data-slot":"dialog-description",className:O("text-sm text-muted-foreground",e),...n})}function $p({open:e,onOpenChange:n,title:s,description:o,confirmLabel:r="Confirm",variant:a="default",onConfirm:i}){return t.jsx(Pt,{open:e,onOpenChange:n,children:t.jsxs(Lt,{children:[t.jsx(Ft,{children:t.jsx(Ut,{children:s})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:o}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx(ee,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),t.jsx(ee,{variant:a,size:"sm",onClick:()=>{i(),n(!1)},children:r})]})]})})}const Kw="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",Gw="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",Jw="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",Yw="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",Xw=""+new URL("agent-inspector-58K1_MsC.ico",import.meta.url).href,Zw={"agent-inspector":"Inspector",codex:"Codex",opencode:"OpenCode","mimo-code":"MiMo Code","claude-code":"Claude Code","ai-sdk":"AI SDK"};function po(e){return e?.toLowerCase()??""}function Un(e,n){for(const s of n)if(e.includes(s))return!0;return!1}function xl(e){const n=[po(e.userAgent),po(e.conversationId),po(e.clientProjectFolder)].join(" ");return Un(n,["agent-inspector","agent inspector","provider-test"])?"agent-inspector":Un(n,["mimocode","mimo-code","mimo code"])?"mimo-code":Un(n,["opencode","open-code","open code"])?"opencode":Un(n,["claude-code","claude code","claudecode","claude-cli","claude cli"])?"claude-code":Un(n,["codex desktop","codex-cli","openai-codex","codex"])?"codex":Un(po(e.userAgent),["ai-sdk","ai/"])?"ai-sdk":"unknown"}function Dr(e){switch(e){case"agent-inspector":case"codex":case"opencode":case"mimo-code":case"claude-code":case"ai-sdk":return Zw[e];case"unknown":return null}}function Qw(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 ej={"agent-inspector":Xw,codex:Gw,opencode:Jw,"mimo-code":Yw,"claude-code":Kw},tj={"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]"},nj={"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 zr({client:e,className:n,decorative:s=!1}){if(e==="unknown")return null;const o=Dr(e);if(o===null)return null;if(e==="ai-sdk")return t.jsx("span",{className:O("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]",n),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:t.jsx(ou,{className:"size-1/2","aria-hidden":"true"})});const r=ej[e];return t.jsx("span",{className:O("inline-flex size-6 shrink-0 items-center justify-center rounded-md border p-0 shadow-sm",tj[e],n),"aria-label":s?void 0:o,"aria-hidden":s?!0:void 0,title:o,children:t.jsx("img",{src:r,alt:"",className:O("size-full object-contain",nj[e]),"aria-hidden":"true"})})}const sj="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",oj="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",rj="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",aj=""+new URL("minimax-BPMzvuL-.jpeg",import.meta.url).href,ij=""+new URL("alibaba-TTwafVwX.svg",import.meta.url).href,lj=""+new URL("qwen-mMn3f5ul.webp",import.meta.url).href,cj=""+new URL("zhipuai-BPNAnxo-.svg",import.meta.url).href,dj={"claude-":"anthropic","gpt-":"openai","o1-":"openai","o3-":"openai","deepseek-":"deepseek",MiniMax:"minimax",qwen:"qwen"};function uj(e){return e.replace(/[_\s]+/g,"-").split(/[/:@]/).some(s=>s.startsWith("glm-"))}function mj(e){if(e===null)return"unknown";const n=e.toLowerCase();if(uj(n))return"zhipuai";for(const[s,o]of Object.entries(dj))if(n.startsWith(s.toLowerCase()))return o;return"unknown"}const Ln={width:24,height:24,objectFit:"contain"},pj=An.memo(({className:e})=>t.jsx("img",{src:sj,alt:"Anthropic",className:e,style:Ln})),fj=An.memo(({className:e})=>t.jsx("img",{src:oj,alt:"OpenAI",className:e,style:{...Ln,background:"white",borderRadius:"4px"}})),hj=An.memo(({className:e})=>t.jsx("img",{src:rj,alt:"DeepSeek",className:e,style:Ln})),xj=An.memo(({className:e})=>t.jsx("img",{src:aj,alt:"MiniMax",className:e,style:Ln})),gj=An.memo(({className:e})=>t.jsx("img",{src:ij,alt:"Alibaba",className:e,style:Ln})),bj=An.memo(({className:e})=>t.jsx("img",{src:lj,alt:"Qwen",className:e,style:Ln})),vj=An.memo(({className:e})=>t.jsx("img",{src:cj,alt:"ZhipuAI",className:e,style:Ln}));function yj({provider:e,className:n}){switch(e){case"anthropic":return t.jsx(pj,{className:n});case"openai":return t.jsx(fj,{className:n});case"deepseek":return t.jsx(hj,{className:n});case"minimax":return t.jsx(xj,{className:n});case"alibaba":return t.jsx(gj,{className:n});case"qwen":return t.jsx(bj,{className:n});case"zhipuai":return t.jsx(vj,{className:n});case"unknown":return null}}function hs({delayDuration:e=600,...n}){return t.jsx($w,{"data-slot":"tooltip-provider",delayDuration:e,...n})}function et({...e}){return t.jsx(Fw,{"data-slot":"tooltip",...e})}function tt({...e}){return t.jsx(Uw,{"data-slot":"tooltip-trigger",...e})}function nt({className:e,sideOffset:n=0,children:s,...o}){return t.jsx(Bw,{children:t.jsxs(qw,{"data-slot":"tooltip-content",sideOffset:n,className:O("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),...o,children:[s,t.jsx(Hw,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}const wj=3;function jj({items:e,ariaLabel:n,className:s}){if(e.length===0)return t.jsx("span",{className:O("flex h-8 w-12 shrink-0 items-center",s),"aria-hidden":"true"});const o=e.slice(0,wj),r=e.length-o.length;return t.jsx(hs,{delayDuration:150,children:t.jsxs("span",{className:O("flex h-8 w-12 shrink-0 items-center",s),"aria-label":n,children:[o.map((a,i)=>t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx("span",{className:O("border border-border bg-muted/40 inline-flex size-6 shrink-0 items-center justify-center rounded-md",i>0&&"-ml-2"),children:t.jsx(yj,{provider:a.provider,className:"size-4"})})}),t.jsx(nt,{children:a.tooltip})]},`${a.provider}-${String(i)}`)),r>0&&t.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:["+",r]})]})})}const Sj=[["/v1/messages","anthropic"],["/v1/chat/completions","openai"],["/chat/completions","openai"],["/v1/responses","openai"],["/responses","openai"]];function Nj(e){const n=e.split("?")[0]??"";for(const[s,o]of Sj)if(n===s)return o;return"unknown"}function Fp(e,n){for(const s of Array.from(e))n(s)}const Cj=/[\u3000-\u9FFF\uAC00-\uD7FF\uF900-\uFAFF\uFF00-\uFFEF\u{1F300}-\u{1FAFF}]/u;function gl(e){if(e.length===0)return 0;let n=0,s=0;return Fp(e,o=>{Cj.test(o)?n+=1:s+=1}),Math.ceil(n*1)+Math.ceil(s/4)}function bl(e){if(e.length===0)return 0;let n=0;return Fp(e,()=>{n+=1}),n}function vl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Z(e,n){return e===null||typeof e!="object"||Array.isArray(e)?void 0:Object.getOwnPropertyDescriptor(e,n)?.value}const kj=["file","shell","browser","web","mcp","code","other"];function ri(e){const n=e.replace(/\s+/g," ").trim();return n.length<=120?n:`${n.slice(0,119)}...`}function Up(e){if(e===null)return null;const n=e.replace(/\s+/g," ").trim();if(n.length===0)return null;const s=n.search(/[.!?。!?]/);return s>=24?ri(n.slice(0,s+1)):ri(n)}function _j(e,n){return`${e} ${n??""}`.toLowerCase()}function Bn(e,n){return n.some(s=>e.includes(s))}function Bp(e,n){const s=_j(e,n);return e.startsWith("mcp__")||e.startsWith("inspector_")||Bn(s,[" mcp","model context protocol"])?"mcp":Bn(s,["bash","shell","terminal","command","powershell","exec","process"])?"shell":Bn(s,["browser","playwright","screenshot","click","navigate","page","tab"])?"browser":Bn(s,["read","write","edit","file","glob","grep","patch","filesystem","directory"])?"file":Bn(s,["web","search","http","url","fetch"])?"web":Bn(s,["code","typescript","javascript","python","repl"])?"code":"other"}function qp(e){const n=Z(e,"properties");return n===null||typeof n!="object"||Array.isArray(n)?[]:Object.keys(n).sort((s,o)=>s.localeCompare(o))}function Hp(e){const n=Z(e,"required");if(!Array.isArray(n))return[];const s=[];for(const o of n)typeof o=="string"&&o.length>0&&s.push(o);return s.sort((o,r)=>o.localeCompare(r))}function Tj(e){const n=Z(e,"name");if(typeof n!="string"||n.length===0)return null;const s=Z(e,"description"),o=Z(e,"input_schema")??null,r=typeof s=="string"?s:null;return{name:n,description:r,descriptionPreview:Up(r),category:Bp(n,r),parameterCount:qp(o).length,requiredParameters:Hp(o),schema:o}}function Ej(e){const n=Z(e,"function"),s=Z(e,"type");if(n===void 0&&typeof s!="string")return null;const o=Z(n,"name")??Z(e,"name")??(typeof s=="string"?s:void 0);if(typeof o!="string"||o.length===0)return null;const r=Z(n,"description")??Z(e,"description"),a=Z(n,"parameters")??Z(e,"parameters")??null,i=typeof r=="string"?r:null;return{name:o,description:i,descriptionPreview:Up(i),category:Bp(o,i),parameterCount:qp(a).length,requiredParameters:Hp(a),schema:a}}function Rj(e){const n=Ej(e);return n!==null?n:Tj(e)}function Mj(e){if(e==null)return null;if(typeof e=="string")return e;const n=Z(e,"type"),s=Z(e,"name"),o=Z(Z(e,"function"),"name");if(typeof n=="string"&&typeof o=="string"&&o.length>0)return`${n}: ${o}`;if(typeof n=="string"&&typeof s=="string"&&s.length>0)return`${n}: ${s}`;if(typeof n=="string")return n;const r=JSON.stringify(e);return r===void 0?null:ri(r)}function Aj(e){const n=new Map;for(const s of e)n.set(s.category,(n.get(s.category)??0)+1);return kj.flatMap(s=>{const o=n.get(s)??0;return o>0?[{category:s,count:o}]:[]})}function yl(e){const n=Z(e,"tools");if(!Array.isArray(n)||n.length===0)return null;const s=[];for(const o of n){const r=Rj(o);r!==null&&s.push(r)}return s.length===0?null:{tools:s,toolChoiceLabel:Mj(Z(e,"tool_choice")),categories:Aj(s)}}function Tn(e){return{parsed:null,comparisonValue:e,messageCount:null,toolCount:null}}const es={parsed:null,toolNames:null};function Ij(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;switch(o.type){case"text":typeof o.text=="string"&&n.push(o.text);break;case"thinking":case"think":typeof o.thinking=="string"&&n.push(o.thinking);break;case"tool_use":{const a=typeof o.name=="string"?o.name:"",i=o.input!==void 0?JSON.stringify(o.input):"";n.push(`${a} ${i}`.trim());break}case"tool_result":{const a=o.content;if(typeof a=="string")n.push(a);else if(Array.isArray(a)){for(const i of a)if(i!==null&&typeof i=="object"){const c=i.text;typeof c=="string"&&n.push(c)}}break}case"image":n.push("[image]");break}}return n.join(`
|
|
43
|
+
`)}function Pj(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e)if(s!==null&&typeof s=="object"){const o=s.text;s.type==="text"&&typeof o=="string"&&n.push(o)}return n.join(`
|
|
44
|
+
`)}function Lj(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s;typeof o.name=="string"&&n.push(o.name),typeof o.description=="string"&&n.push(o.description),o.input_schema!==void 0&&n.push(JSON.stringify(o.input_schema))}return n.join(`
|
|
45
|
+
`)}function la(e,n,s,o){return{role:e,label:n,text:s,size:gl(s),characters:bl(s),path:o}}const Oj={format:"anthropic",analyzeRequest(e){if(e===null)return Tn(e);try{const n=JSON.parse(e),s=yl(n)?.tools.length??null,o=Vh.safeParse(n);return o.success?{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}:Tn(e)}catch{return Tn(e)}},analyzeResponse(e){if(e===null)return es;try{let n=JSON.parse(e);typeof n=="string"&&(n=JSON.parse(n));const s=Gh.safeParse(n);if(!s.success)return es;const o=s.data.content.filter(r=>r.type==="tool_use").map(r=>r.name);return{parsed:s.data,toolNames:o.length>0?o:null}}catch{return es}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(n.system!==void 0){const o=Pj(n.system);o.length>0&&s.push(la("system","system",o,"/system"))}if(Array.isArray(n.messages)&&n.messages.forEach((o,r)=>{if(o===null||typeof o!="object")return;const a=o,i=a.role==="user"||a.role==="assistant"?a.role:"user",c=Ij(a.content);s.push(la(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(n.tools)&&n.tools.length>0){const o=Lj(n.tools);s.push(la("tools","tools",o,"/tools"))}return s.length>0?s:null}};function ai(e){if(typeof e=="string")return e;if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=s,r=o.type;(r==="text"||r==="input_text"||r==="output_text")&&typeof o.text=="string"?n.push(o.text):(r==="image_url"||r==="input_image")&&n.push("[image]")}return n.join(`
|
|
46
|
+
`)}function Dj(e){const n=[],s=ai(e.content);s.length>0&&n.push(s);const o=typeof e.reasoning_content=="string"?e.reasoning_content:typeof e.thinking=="string"?e.thinking:typeof e.think=="string"?e.think:"";o.length>0&&n.push(o);const r=e.tool_calls;if(Array.isArray(r))for(const a of r){if(a===null||typeof a!="object")continue;const i=a.function;if(i===void 0)continue;const c=typeof i.name=="string"?i.name:"",d=typeof i.arguments=="string"?i.arguments:"";n.push(`${c} ${d}`.trim())}return n.join(`
|
|
47
|
+
`)}function zj(e){if(!Array.isArray(e))return"";const n=[];for(const s of e){if(s===null||typeof s!="object")continue;const o=Z(s,"function"),r=Z(o,"name")??Z(s,"name"),a=Z(o,"description")??Z(s,"description"),i=Z(o,"parameters")??Z(s,"parameters");typeof r=="string"&&n.push(r),typeof a=="string"&&n.push(a),i!==void 0&&n.push(JSON.stringify(i))}return n.join(`
|
|
48
|
+
`)}function $j(e){return typeof e=="string"?e.length>0?1:0:Array.isArray(e)?e.length:e==null?null:1}function Fj(e){if(typeof e=="string")return e;const n=Z(e,"text");if(typeof n=="string")return n;const s=ai(Z(e,"content"));if(s.length>0)return s;const o=ai(Z(e,"output"));if(o.length>0)return o;const r=Z(e,"arguments");return typeof r=="string"?r:""}function Uj(e){const n=Z(e,"role");if(n==="system"||n==="user"||n==="assistant"||n==="tool")return n;const s=Z(e,"type");return s==="function_call_output"?"tool":"user"}function Bj(e){const n=Z(e,"output");if(!Array.isArray(n))return[];const s=[];for(const o of n){if(Z(o,"type")!=="function_call")continue;const r=Z(o,"name");typeof r=="string"&&r.length>0&&s.push(r)}return s}function vs(e,n,s,o){return{role:e,label:n,text:s,size:gl(s),characters:bl(s),path:o}}const qj={format:"openai",analyzeRequest(e){if(e===null)return Tn(e);try{const n=JSON.parse(e),s=yl(n)?.tools.length??null,o=ix.safeParse(n);if(!o.success){const r=cx.safeParse(n);return r.success?{parsed:r.data,comparisonValue:r.data,messageCount:$j(r.data.input),toolCount:s}:Tn(e)}return{parsed:o.data,comparisonValue:o.data,messageCount:o.data.messages.length,toolCount:s}}catch{return Tn(e)}},analyzeResponse(e){if(e===null)return es;const n=hx(e);if(n===null){const o=xx(e);if(o===null)return es;const r=Bj(o);return{parsed:o,toolNames:r.length>0?r:null}}const s=n.choices[0]?.message?.tool_calls?.map(o=>o.function?.name??"").filter(o=>o!=="")??[];return{parsed:n,toolNames:s.length>0?s:null}},anatomySegments(e){if(e===null||typeof e!="object")return null;const n=e,s=[];if(typeof n.instructions=="string"&&n.instructions.length>0&&s.push(vs("system","instructions",n.instructions,"/instructions")),Array.isArray(n.messages)&&n.messages.forEach((o,r)=>{if(o===null||typeof o!="object")return;const a=o,i=a.role==="user"||a.role==="assistant"||a.role==="system"||a.role==="tool"?a.role:"user",c=Dj(a);s.push(vs(i,`[${r}] ${i}`,c,`/messages/${r}`))}),Array.isArray(n.messages)||(typeof n.input=="string"&&n.input.length>0?s.push(vs("user","input",n.input,"/input")):Array.isArray(n.input)&&n.input.forEach((o,r)=>{const a=Uj(o),i=Fj(o);s.push(vs(a,`[${r}] ${a}`,i,`/input/${r}`))})),Array.isArray(n.tools)&&n.tools.length>0){const o=zj(n.tools);s.push(vs("tools","tools",o,"/tools"))}return s.length>0?s:null}},Hj={format:"unknown",analyzeRequest(e){return Tn(e)},analyzeResponse(){return es},anatomySegments(){return null}},Wj={anthropic:Oj,openai:qj,unknown:Hj};function Wp(e){return Wj[e]}function Ds(e){const n=Nj(e.path);return n==="unknown"?e.apiFormat:n}const vc="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 Vp(e){return e.startsWith("PID:")||e.startsWith("process:")||e.startsWith("connection:")||e.includes("|")}function Vj(e){return Vp(e)?"No session ID":e.length>24?`${e.slice(0,12)}...${e.slice(-12)}`:e}function ca({icon:e,children:n,title:s,className:o}){return t.jsxs("span",{className:O("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",o),title:s,children:[e,t.jsx("span",{className:"min-w-0 font-mono tabular-nums",children:n})]})}function Kj(){return t.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:[t.jsx(Ae,{className:"size-3 animate-spin"}),"Turn open"]})}function Gj({conversationId:e,startTime:n,endTime:s,totalCalls:o,totalInputTokens:r,totalOutputTokens:a,expanded:i,onToggle:c,providers:d,isLoading:m=!1,userAgent:u,clientPid:p,clientProjectFolder:f,showClientIdentity:h=!0,showProcessMetadata:g=!0,timeDisplayFormat:b,onClear:y}){const[w,v]=l.useState(!1),j=J=>{J.stopPropagation(),y!==void 0&&v(!0)},S=l.useCallback(J=>{J.stopPropagation(),window.open(Id(e),"_blank","noopener,noreferrer")},[e]),N=d?.map(({provider:J,models:X})=>({provider:J,tooltip:X.length===1?X[0]??J:X.join(", ")}))??[],C=xl({userAgent:u,conversationId:e,clientProjectFolder:f}),R=Dr(C),I=u!=null&&u!=="",P=R??u??null,M=R!==null&&I?`${R} - ${u}`:null,k=Vp(e),A=Vj(e),D=xr(n,s,b),$=`${o} call${o!==1?"s":""}`;return t.jsxs("div",{role:"button",tabIndex:0,"data-nav-id":`conv-${e}`,"data-nav-action":i?"collapse":"expand",className:O("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:c,onKeyDown:J=>{J.target===J.currentTarget&&(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),c())},children:[t.jsx(jj,{items:N,ariaLabel:"Models used in this session",className:"mt-0.5"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.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"}),k&&g?p!=null?t.jsxs("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:`PID ${p}`,children:["PID ",p]}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:e}):t.jsx("span",{className:"min-w-0 max-w-full truncate font-mono text-xs font-semibold text-foreground",title:e,children:A}),!k&&g&&p!==null&&p!==void 0&&t.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]}),k&&g&&f!==null&&f!==void 0&&f!==""&&t.jsx("span",{className:"min-w-0 max-w-[240px] truncate font-mono text-xs text-muted-foreground",title:f,children:f}),h&&P!==null&&P!==""&&t.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:M??P,children:[t.jsx(zr,{client:C,className:"size-4 shrink-0",decorative:!0}),t.jsx("span",{className:"font-mono leading-snug tabular-nums",children:P})]}),m&&t.jsx(Kj,{})]}),t.jsxs("span",{className:"mt-1.5 flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx(ca,{icon:t.jsx(Wt,{className:"size-3 shrink-0"}),title:D,children:D}),t.jsx(ca,{icon:t.jsx(hr,{className:"size-3 shrink-0"}),children:$}),t.jsxs(ca,{icon:t.jsx(Ps,{className:"size-3 shrink-0"}),className:"max-w-full",children:[t.jsx("span",{className:"text-[var(--inspector-status-info)]",children:Ee(r)})," / ",t.jsx("span",{className:"text-[var(--inspector-status-watch)]",children:Ee(a)})]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[t.jsx("button",{type:"button",onClick:S,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&S(J)},"aria-label":`Open session ${e} in a new tab`,title:"Open this session in a new tab",className:vc,children:t.jsx(zi,{className:"size-3.5"})}),y!==void 0&&t.jsx("button",{type:"button",onClick:j,"aria-label":`Clear group (${o} request${o!==1?"s":""})`,title:"Clear this group from the current view",className:vc,children:t.jsx(an,{className:"size-3.5"})}),t.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:i?t.jsx(Ve,{className:"size-4 shrink-0"}):m?t.jsx(Ae,{className:"size-4 shrink-0 animate-spin"}):t.jsx(it,{className:"size-4 shrink-0"})})]}),m&&t.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:t.jsx("span",{className:"absolute inset-y-0 left-0 w-1/3 animate-pulse rounded-full bg-[var(--inspector-status-watch)] opacity-70"})}),t.jsx($p,{open:w,onOpenChange:v,title:"Clear this group from the current view?",description:`This will hide ${o} request${o!==1?"s":""} from the current view. Stored logs remain reloadable.`,confirmLabel:"Clear",variant:"destructive",onConfirm:()=>{y?.()}})]})}function Jj(e){if(e.sessionId!==null&&e.sessionId!==""&&e.sessionId!==void 0)return e.sessionId;if(e.isTest===!0)return"provider-test";const n=e.clientPid!==null&&e.clientPid!==void 0,s=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0;if(!n&&!s)return"default";const o=n?`PID:${e.clientPid}`:"unknown",r=s?e.clientProjectFolder:"no-folder";return`${o}|${r}`}function Yj(e){const n=new Map;for(const o of e){const r=Jj(o),a=n.get(r);a!==void 0?a.push(o):n.set(r,[o])}const s=[];for(const[o,r]of n){const a=[...r].sort((i,c)=>i.timestamp.localeCompare(c.timestamp));s.push({id:o,conversationId:o,logs:a})}return s.sort((o,r)=>(o.logs[0]?.timestamp??"").localeCompare(r.logs[0]?.timestamp??"")),s}function Xj(e,n,s){const o=new Array(e);return new Proxy(o,{get(r,a,i){if(typeof a=="string"){const c=a.charCodeAt(0);if(c>=48&&c<=57){const d=+a;if(Number.isInteger(d)&&d>=0&&d<e){let m=r[d];if(!m){const u=n[d*2];m=r[d]={index:d,key:s(d),start:u,size:n[d*2+1],end:u+n[d*2+1],lane:0}}return m}}if(a==="length")return e}return Reflect.get(r,a,i)}})}function qn(e,n,s){let o=s.initialDeps??[],r,a=!0;function i(){const c=e();return(c.length!==o.length||c.some((m,u)=>o[u]!==m))&&(o=c,r=n(...c),s?.onChange&&!(a&&s.skipInitialOnChange)&&s.onChange(r),a=!1),r}return i.updateDeps=c=>{o=c},i}function yc(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const Zj=(e,n)=>Math.abs(e-n)<1.01,Qj=(e,n,s)=>{let o;return function(...r){e.clearTimeout(o),o=e.setTimeout(()=>n.apply(this,r),s)}};let ys;const da=()=>{if(ys!==void 0)return ys;if(typeof navigator>"u")return ys=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return ys=!0;const e=navigator.maxTouchPoints;return ys=navigator.platform==="MacIntel"&&e!==void 0&&e>0},wc=e=>{const{offsetWidth:n,offsetHeight:s}=e;return{width:n,height:s}},e5=e=>e,t5=e=>{const n=Math.max(e.startIndex-e.overscan,0),o=Math.min(e.endIndex+e.overscan,e.count-1)-n+1,r=new Array(o);for(let a=0;a<o;a++)r[a]=n+a;return r},n5=(e,n)=>{const s=e.scrollElement;if(!s)return;const o=e.targetWindow;if(!o)return;const r=i=>{const{width:c,height:d}=i;n({width:Math.round(c),height:Math.round(d)})};if(r(wc(s)),!o.ResizeObserver)return()=>{};const a=new o.ResizeObserver(i=>{const c=()=>{const d=i[0];if(d?.borderBoxSize){const m=d.borderBoxSize[0];if(m){r({width:m.inlineSize,height:m.blockSize});return}}r(wc(s))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return a.observe(s,{box:"border-box"}),()=>{a.unobserve(s)}},zs={passive:!0},s5=(e,n)=>{const s=e.scrollElement;if(!s)return;const o=()=>{n({width:s.innerWidth,height:s.innerHeight})};return o(),s.addEventListener("resize",o,zs),()=>{s.removeEventListener("resize",o)}},o5=typeof window>"u"?!0:"onscrollend"in window,Kp=(e,n,s)=>{const o=e.scrollElement;if(!o)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&o5;let i=0;const c=a?null:Qj(r,()=>n(i,!1),e.options.isScrollingResetDelay),d=p=>()=>{i=s(o),c?.(),n(i,p)},m=d(!0),u=d(!1);return o.addEventListener("scroll",m,zs),a&&o.addEventListener("scrollend",u,zs),()=>{o.removeEventListener("scroll",m),a&&o.removeEventListener("scrollend",u)}},r5=(e,n)=>Kp(e,n,s=>{const{horizontal:o,isRtl:r}=e.options;return o?s.scrollLeft*(r&&-1||1):s.scrollTop}),a5=(e,n)=>Kp(e,n,s=>e.options.horizontal?s.scrollX:s.scrollY),i5=(e,n,s)=>{if(s.options.useCachedMeasurements){const o=s.indexFromElement(e),r=s.options.getItemKey(o);return s.itemSizeCache.get(r)??s.options.estimateSize(o)}if(n?.borderBoxSize){const o=n.borderBoxSize[0];if(o)return Math.round(o[s.options.horizontal?"inlineSize":"blockSize"])}if(!n){const o=s.indexFromElement(e),r=s.options.getItemKey(o),a=s.itemSizeCache.get(r);if(a!==void 0)return a}return e[s.options.horizontal?"offsetWidth":"offsetHeight"]},Gp=(e,{adjustments:n=0,behavior:s},o)=>{var r,a;(a=(r=o.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[o.options.horizontal?"left":"top"]:e+n,behavior:s})},l5=Gp,c5=Gp;class d5{constructor(n){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 s,o,r;return((r=(o=(s=this.targetWindow)==null?void 0:s.performance)==null?void 0:o.now)==null?void 0:r.call(o))??Date.now()},this.observer=(()=>{let s=null;const o=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const i=()=>{const c=a.target,d=this.indexFromElement(c);if(!c.isConnected){this.observer.unobserve(c);for(const[m,u]of this.elementsCache)if(u===c){this.elementsCache.delete(m);break}return}this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(c,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var r;(r=o())==null||r.disconnect(),s=null},observe:r=>{var a;return(a=o())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=o())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{var o,r;const a={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:e5,rangeExtractor:t5,onChange:()=>{},measureElement:i5,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 f in s){const h=s[f];h!==void 0&&(a[f]=h)}const i=this.options;let c=null,d=null,m=!1;if(i!==void 0&&i.enabled&&a.enabled&&a.anchorTo==="end"&&this.scrollElement!==null){const f=i.count,h=a.count,g=this.getMeasurements(),b=f>0?((o=g[0])==null?void 0:o.key)??i.getItemKey(0):null,y=f>0?((r=g[f-1])==null?void 0:r.key)??i.getItemKey(f-1):null;if(h!==f||f>0&&h>0&&(a.getItemKey(0)!==b||a.getItemKey(h-1)!==y)){m=!0;const j=f>0?this.getVirtualItemForOffset(this.getScrollOffset())??g[0]:null;j&&(c=[j.key,this.getScrollOffset()-j.start]);const S=a.followOnAppend===!0?"auto":a.followOnAppend||null;S&&h>f&&this.isAtEnd(i.scrollEndThreshold)&&(f===0||a.getItemKey(h-1)!==y)&&(d=S)}}this.options=a,m&&(this.pendingMin=0,this.itemSizeCacheVersion++);let u=!1,p=0;if(c&&this.scrollOffset!==null){const[f,h]=c,g=this.getMeasurements(),{count:b,getItemKey:y}=this.options;let w=0;for(;w<b&&y(w)!==f;)w++;if(w<b){const v=g[w];if(v){const j=v.start+h;j!==this.scrollOffset&&(p=j-this.scrollOffset,this.scrollOffset=j,u=!0)}}}(u||d)&&(this.pendingScrollAnchor=[u?c[0]:null,u?c[1]:0,d,p])},this.notify=s=>{var o,r;(r=(o=this.options).onChange)==null||r.call(o,this,s)},this.maybeNotify=qn(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{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(s=>s()),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 s;const o=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==o){if(this.cleanup(),!o){this.maybeNotify();return}if(this.scrollElement=o,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,i)=>{if(i&&this._intendedScrollOffset===null&&a===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(a-this._intendedScrollOffset)<1.5&&(a=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const c=this.getScrollOffset();this.scrollDirection=i?c===a?this.scrollDirection:c<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const a=this.scrollElement,i=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!da()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};a.addEventListener("touchstart",i,zs),a.addEventListener("touchend",c,zs),this.unsubs.push(()=>{a.removeEventListener("touchstart",i),a.removeEventListener("touchend",c),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 r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[a,i,c,d]=r;a!==null&&!c&&(da()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const s=this.getScrollOffset(),o=this.getMaxScrollOffset();if(s<0||s>o)return;const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(s,{adjustments:this.scrollAdjustments+=r,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=qn(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(s,o,r,a,i,c,d,m)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMin=null,{count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m}),{key:!1}),this.getMeasurements=qn(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:s,paddingStart:o,scrollMargin:r,getItemKey:a,enabled:i,lanes:c,laneAssignmentMode:d,gap:m},u)=>{const p=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const w of this.laneAssignments.keys())w>=s&&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 f=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1),c===1){const w=s*2;let v=this._flatMeasurements;if(!v||v.length<w){const N=new Float64Array(w);v&&f>0&&N.set(v.subarray(0,f*2)),v=N,this._flatMeasurements=v}let j;if(f===0)j=o+r;else{const N=f-1;j=v[N*2]+v[N*2+1]+m}for(let N=f;N<s;N++){const C=a(N),R=p.get(C),I=typeof R=="number"?R:this.options.estimateSize(N);v[N*2]=j,v[N*2+1]=I,j+=I+m}const S=Xj(s,v,a);return this.measurementsCache=S,S}const h=this.measurementsCache.slice(0,f),g=new Array(c).fill(void 0),b=new Float64Array(c);let y=0;for(let w=0;w<f;w++){const v=h[w];v&&(g[v.lane]===void 0&&y++,g[v.lane]=w,b[v.lane]=v.end)}for(let w=f;w<s;w++){const v=a(w),j=this.laneAssignments.get(w);let S,N;const C=d==="estimate"||p.has(v);if(j!==void 0&&this.options.lanes>1){S=j;const M=g[S],k=M!==void 0?h[M]:void 0;N=k?k.end+m:o+r}else if(y===c){let M=0,k=b[0],A=g[0];for(let D=1;D<c;D++){const $=b[D];($<k||$===k&&g[D]<A)&&(M=D,k=$,A=g[D])}S=M,N=k+m,C&&this.laneAssignments.set(w,S)}else S=w%this.options.lanes,N=o+r,C&&this.laneAssignments.set(w,S);const R=p.get(v),I=typeof R=="number"?R:this.options.estimateSize(w),P=N+I;h[w]={index:w,start:N,size:I,end:P,key:v,lane:S},g[S]===void 0&&y++,g[S]=w,b[S]=P}return this.measurementsCache=h,h},{key:!1,debug:()=>this.options.debug}),this.calculateRange=qn(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,o,r,a)=>s.length===0||o===0?(this.range=null,null):(this.range=m5(s,o,r,a,a===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=qn(()=>{let s=null,o=null;const r=this.calculateRange();return r&&(s=r.startIndex,o=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,o]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,o]},(s,o,r,a,i)=>a===null||i===null?[]:s({startIndex:a,endIndex:i,overscan:o,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const o=this.options.indexAttribute,r=s.getAttribute(o);return r?parseInt(r,10):(console.warn(`Missing attribute name '${o}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=s=>{var o;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((o=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:o.index);if(r!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,r-a),c=Math.min(this.options.count-1,r+a);return s>=i&&s<=c}return!0},this.measureElement=s=>{if(!s){this.elementsCache.forEach((i,c)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(c))});return}const o=this.indexFromElement(s),r=this.options.getItemKey(o),a=this.elementsCache.get(r);a!==s&&(a&&this.observer.unobserve(a),this.observer.observe(s),this.elementsCache.set(r,s)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(o)&&this.resizeItem(o,this.options.measureElement(s,void 0,this))},this.resizeItem=(s,o)=>{var r,a;if(s<0||s>=this.options.count)return;let i,c,d;const m=this._flatMeasurements;if(this.options.lanes===1&&m!==null)d=this.options.getItemKey(s),c=m[s*2],i=m[s*2+1];else{const f=this.measurementsCache[s];if(!f)return;d=f.key,c=f.start,i=f.size}const u=this.itemSizeCache.get(d)??i,p=o-u;if(p!==0){const f=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,h=f?this.getTotalSize():0,g=((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[s]??{index:s,key:d,start:c,size:i,end:c+i,lane:0},p,this):c<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(d)||this.scrollDirection!=="backward"));(this.pendingMin===null||s<this.pendingMin)&&(this.pendingMin=s),this.itemSizeCache.set(d,o),this.itemSizeCacheVersion++,f?this.applyScrollAdjustment(this.getTotalSize()-h):g&&this.applyScrollAdjustment(p),this.notify(!1)}},this.getVirtualItems=qn(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,o)=>{const r=[];for(let a=0,i=s.length;a<i;a++){const c=s[a],d=o[c];r.push(d)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=s=>{const o=this.getMeasurements();if(o.length===0)return;const r=this._flatMeasurements,a=this.options.lanes===1&&r!=null,i=Jp(0,o.length-1,a?c=>r[c*2]:c=>yc(o[c]).start,s);return yc(o[i])},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 s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.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=(s=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=s,this.getOffsetForAlignment=(s,o,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),i=this.getScrollOffset();o==="auto"&&(o=s>=i+a?"end":"start"),o==="center"?s+=(r-a)/2:o==="end"&&(s-=a);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,o="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),i=this.measurementsCache[s];if(!i)return;if(o==="auto")if(i.end>=a+r-this.options.scrollPaddingEnd)o="end";else if(i.start<=a+this.options.scrollPaddingStart)o="start";else return[a,o];if(o==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),o];const c=o==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,o,i.size),o]},this.scrollToOffset=(s,{align:o="start",behavior:r="auto"}={})=>{const a=this.getOffsetForAlignment(s,o),i=this.now();this.scrollState={index:null,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(s,{align:o="auto",behavior:r="auto"}={})=>{s=Math.max(0,Math.min(s,this.options.count-1));const a=this.getOffsetForIndex(s,o);if(!a)return;const[i,c]=a,d=this.now();this.scrollState={index:s,align:c,behavior:r,startedAt:d,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(s,{behavior:o="auto"}={})=>{const r=this.getScrollOffset()+s,a=this.now();this.scrollState={index:null,align:"start",behavior:o,startedAt:a,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:o}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:s="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:s});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:s})},this.getTotalSize=()=>{var s;const o=this.getMeasurements();let r;if(o.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const a=o.length-1,i=this._flatMeasurements;i!=null?r=i[a*2]+i[a*2+1]:r=((s=o[a])==null?void 0:s.end)??0}else{const a=Array(this.options.lanes).fill(null);let i=o.length-1;for(;i>=0&&a.some(c=>c===null);){const c=o[i];a[c.lane]===null&&(a[c.lane]=c.end),i--}r=Math.max(...a.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const s=[];if(this.itemSizeCache.size===0)return s;const o=this.getMeasurements();for(const r of o)r&&this.itemSizeCache.has(r.key)&&s.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return s},this._scrollToOffset=(s,{adjustments:o,behavior:r})=>{this._intendedScrollOffset=s+(o??0),this.options.scrollToFn(s,{behavior:r,adjustments:o},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(n)}applyScrollAdjustment(n,s){n!==0&&(da()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=n:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=n,behavior:s}),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 o=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=o?o[0]:this.scrollState.lastTargetOffset,a=1,i=r!==this.scrollState.lastTargetOffset;if(!i&&Zj(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=a){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){const c=this.getSize()||600,d=Math.abs(r-this.getScrollOffset()),m=this.scrollState.behavior==="smooth"&&d>c;this.scrollState.lastTargetOffset=r,m||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:m?"smooth":"auto"})}this.scheduleScrollReconcile()}}const Jp=(e,n,s,o)=>{for(;e<=n;){const r=(e+n)/2|0,a=s(r);if(a<o)e=r+1;else if(a>o)n=r-1;else return r}return e>0?e-1:0};function u5(e,n,s){let o=0;for(;o<=n;){const r=(o+n)/2|0,a=e[r*2];if(a<s)o=r+1;else if(a>s)n=r-1;else return r}return o>0?o-1:0}function m5(e,n,s,o,r){const a=e.length-1;if(e.length<=o)return{startIndex:0,endIndex:a};if(o===1&&r!==null){const m=u5(r,a,s);let u=m;const p=s+n;for(;u<a&&r[u*2]+r[u*2+1]<p;)u++;return{startIndex:m,endIndex:u}}let c=Jp(0,a,m=>e[m].start,s),d=c;if(o===1)for(;d<a&&e[d].end<s+n;)d++;else if(o>1){const m=Array(o).fill(0);for(;d<a&&m.some(p=>p<s+n);){const p=e[d];m[p.lane]=p.end,d++}const u=Array(o).fill(s+n);for(;c>=0&&u.some(p=>p>=s);){const p=e[c];u[p.lane]=p.start,c--}c=Math.max(0,c-c%o),d=Math.min(a,d+(o-1-d%o))}return{startIndex:c,endIndex:d}}const ua=typeof document<"u"?l.useLayoutEffect:l.useEffect;function Yp({useFlushSync:e=!0,directDomUpdates:n=!1,directDomUpdatesMode:s="transform",...o}){const r=l.useReducer(m=>m+1,0)[1],a=l.useRef({enabled:n,mode:s,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=n,a.current.mode=s;const i=m=>{const u=a.current;if(!u.enabled||!u.container)return;const p=m.getTotalSize();if(p!==u.lastSize){u.lastSize=p;const w=m.options.horizontal?"width":"height";u.container.style[w]=`${p}px`}const f=!!m.options.horizontal,h=u.mode==="transform",g=f?"left":"top",b=m.options.scrollMargin,y=m.getVirtualItems();for(const w of y){const v=w.start-b,j=m.elementsCache.get(w.key);j&&u.lastPositions.get(j)!==v&&(u.lastPositions.set(j,v),h?j.style.transform=f?`translate3d(${v}px, 0, 0)`:`translate3d(0, ${v}px, 0)`:j.style[g]=`${v}px`)}},c={...o,onChange:(m,u)=>{var p;const f=a.current;let h=!0;if(f.enabled){i(m);const g=m.range,b=f.prevRange;h=!b||b.isScrolling!==m.isScrolling||b.startIndex!==g?.startIndex||b.endIndex!==g?.endIndex,h&&(f.prevRange=g?{startIndex:g.startIndex,endIndex:g.endIndex,isScrolling:m.isScrolling}:null)}h&&(e&&u?ms.flushSync(r):r()),(p=o.onChange)==null||p.call(o,m,u)}},[d]=l.useState(()=>{const m=new d5(c);return Object.assign(m,{containerRef:u=>{const p=a.current;if(p.container=u,p.lastSize=null,u&&p.enabled){const f=m.getTotalSize();p.lastSize=f;const h=m.options.horizontal?"width":"height";u.style[h]=`${f}px`}}})});return d.setOptions(c),ua(()=>d._didMount(),[]),ua(()=>d._willUpdate()),ua(()=>{i(d)}),d}function p5(e){return Yp({observeElementRect:n5,observeElementOffset:r5,scrollToFn:c5,...e})}function f5(e){return Yp({getScrollElement:()=>typeof document<"u"?window:null,observeElementRect:s5,observeElementOffset:a5,scrollToFn:l5,initialOffset:()=>typeof document<"u"?window.scrollY:0,...e})}const Gt="agent-inspector:focus-log";function ds(e){window.dispatchEvent(new CustomEvent(Gt,{detail:e}))}function $r(e){if(typeof CustomEvent>"u"||!(e instanceof CustomEvent))return null;const n=e.detail,s=Z(n,"logId");if(typeof s!="number"||!Number.isInteger(s)||s<0)return null;const o=Z(n,"tab");switch(o){case"anatomy":case"request":case"response":break;case void 0:break;default:return null}const r=Z(n,"source"),a=Z(n,"toolCallIndex"),i=typeof a=="number"&&Number.isInteger(a)&&a>=0?{logId:s,tab:o??"request",toolCallIndex:a}:{logId:s,tab:o??"request"};switch(r){case"virtualizer":return{...i,source:r};case void 0:return i;default:return null}}function h5(e){switch(e){case"end_turn":case"tool_use":return e;case"max_tokens":return"length";default:return null}}function x5(e){switch(e){case"stop":case"length":return e;case"max_tokens":return"length";default:return null}}function g5(e){switch(e){case"max_output_tokens":case"max_tokens":return!0;default:return!1}}function Xp(e){if(e.responseText===null)return null;try{let n=JSON.parse(e.responseText);if(typeof n=="string"&&(n=JSON.parse(n)),!ks(n))return null;if(typeof n.stop_reason=="string")return h5(n.stop_reason);if(Array.isArray(n.choices))for(const s of n.choices){if(!ks(s)||typeof s.finish_reason!="string")continue;const o=x5(s.finish_reason);if(o!==null)return o}if(Array.isArray(n.output)){for(const s of n.output)if(ks(s)&&s.type==="function_call")return"tool_use";if(n.status==="completed")return"stop"}if(n.status==="incomplete"&&ks(n.incomplete_details)){const s=n.incomplete_details.reason;if(typeof s=="string"&&g5(s))return"length"}return null}catch{return null}}function wl(e){return e==="end_turn"||e==="stop"||e==="length"}function ft({className:e,style:n,d:s,eyeStalks:o,eyes:r,legs:a,extras:i}){return t.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:n,className:O("inline-block size-5",e),children:[t.jsx("path",{d:s}),o,r,a,i]})}const fn=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"6.5",y1:"16",x2:"4.5",y2:"19.5"}),t.jsx("line",{x1:"9",y1:"17.5",x2:"8",y2:"20.5"}),t.jsx("line",{x1:"15",y1:"17.5",x2:"16",y2:"20.5"}),t.jsx("line",{x1:"17.5",y1:"16",x2:"19.5",y2:"19.5"})]}),Zp=t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"16",x2:"5.5",y2:"18.5"}),t.jsx("line",{x1:"9.5",y1:"17",x2:"8.5",y2:"19.5"}),t.jsx("line",{x1:"14.5",y1:"17",x2:"15.5",y2:"19.5"}),t.jsx("line",{x1:"17",y1:"16",x2:"18.5",y2:"18.5"})]});function Qp({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.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 b5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"6.5",x2:"9.5",y2:"4.5"}),t.jsx("line",{x1:"14.5",y1:"6.5",x2:"14.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4",r:"1.1",fill:"currentColor",stroke:"none"})]}),legs:Zp,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C4 9.5 2.5 10 3 12 C3.5 13.5 4.5 13 5 12"}),t.jsx("path",{d:"M19 11 C20 9.5 21.5 10 21 12 C20.5 13.5 19.5 13 19 12"})]})})}function v5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"7",x2:"6.5",y2:"4.5"}),t.jsx("line",{x1:"17",y1:"7",x2:"17.5",y2:"4.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"6.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"17.5",cy:"4",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M4 12 C2.5 10.5 1 11 1.5 13 C2 14.5 3.5 14 4.5 13"}),t.jsx("path",{d:"M20 12 C21.5 10.5 23 11 22.5 13 C22 14.5 20.5 14 19.5 13"})]})})}function y5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"6.5",x2:"10",y2:"3.5"}),t.jsx("line",{x1:"14",y1:"6.5",x2:"14",y2:"3.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14",cy:"3",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7",y1:"17",x2:"5",y2:"20.5"}),t.jsx("line",{x1:"9.5",y1:"18.5",x2:"8.5",y2:"21.5"}),t.jsx("line",{x1:"14.5",y1:"18.5",x2:"15.5",y2:"21.5"}),t.jsx("line",{x1:"17",y1:"17",x2:"19",y2:"20.5"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M6.5 11 C5 8.5 3 9 3.5 11.5 C4 13.5 5 13 6 12"}),t.jsx("path",{d:"M17.5 11 C19 8.5 21 9 20.5 11.5 C20 13.5 19 13 18 12"})]})})}function w5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.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 j5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.9",fill:"currentColor",stroke:"none"}),t.jsx("line",{x1:"13.5",y1:"4",x2:"15.5",y2:"5"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.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 S5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"8",x2:"10",y2:"6"}),t.jsx("line",{x1:"14",y1:"8",x2:"14",y2:"6"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9",y1:"6",x2:"11",y2:"6.5"}),t.jsx("line",{x1:"13",y1:"6",x2:"15",y2:"6.5"})]}),legs:Zp,extras:t.jsxs(t.Fragment,{children:[t.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"}),t.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 N5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"0.7",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("line",{x1:"8.5",y1:"4",x2:"10.5",y2:"4.5"}),t.jsx("line",{x1:"15.5",y1:"4",x2:"13.5",y2:"4.5"}),t.jsx("path",{d:"M9 15.5 C10 14.5 14 14.5 15 15.5"})]})})}function C5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"}),t.jsx("circle",{cx:"14.5",cy:"4.5",r:"1.2",fill:"none",stroke:"currentColor"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("ellipse",{cx:"12",cy:"15",rx:"2",ry:"1.5",fill:"currentColor",stroke:"none"})]})})}function k5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"9.5",y1:"7",x2:"9",y2:"5"}),t.jsx("line",{x1:"14.5",y1:"7",x2:"15",y2:"5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"9",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"15",cy:"4.5",r:"1",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9 2 9.5 2.5 12 C3 14 4 13 5 12"}),t.jsx("path",{d:"M19 11 C20.5 9 22 9.5 21.5 12 C21 14 20 13 19 12"}),t.jsx("path",{d:"M9 14.5 C10 16 14 16 15 14.5"}),t.jsx("circle",{cx:"7",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"}),t.jsx("circle",{cx:"17",cy:"13",r:"1",fill:"currentColor",stroke:"none",opacity:"0.3"})]})})}function _5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10",y1:"7",x2:"9.5",y2:"5.5"}),t.jsx("line",{x1:"14",y1:"7",x2:"14.5",y2:"5.5"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"7.5",y1:"5.5",x2:"16.5",y2:"5.5"}),t.jsx("rect",{x:"7",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"}),t.jsx("rect",{x:"13",y:"5",width:"4",height:"2",rx:"0.5",fill:"currentColor",stroke:"none"})]}),legs:fn,extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M5 11 C3.5 9.5 1.5 10 2 12.5 C2.5 14 4 13.5 5 12.5"}),t.jsx("path",{d:"M19 11 C20.5 9.5 22.5 10 22 12.5 C21.5 14 20 13.5 19 12.5"}),t.jsx("path",{d:"M9.5 15 C10.5 16 13.5 16 14.5 15"})]})})}function T5({className:e}){return t.jsx(ft,{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:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"10.5",y1:"9.5",x2:"10.5",y2:"8"}),t.jsx("line",{x1:"13.5",y1:"9.5",x2:"13.5",y2:"8"})]}),eyes:t.jsxs(t.Fragment,{children:[t.jsx("circle",{cx:"10.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"13.5",cy:"7.5",r:"0.8",fill:"currentColor",stroke:"none"})]}),legs:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"8",y1:"16",x2:"6.5",y2:"18"}),t.jsx("line",{x1:"10",y1:"17",x2:"9.5",y2:"19"}),t.jsx("line",{x1:"14",y1:"17",x2:"14.5",y2:"19"}),t.jsx("line",{x1:"16",y1:"16",x2:"17.5",y2:"18"})]}),extras:t.jsxs(t.Fragment,{children:[t.jsx("path",{d:"M7.5 12 C6.5 11 5.5 11.5 6 13 C6.5 14 7 13.5 7.5 13"}),t.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 ii=[Qp,b5,v5,y5,w5,j5,S5,N5,C5,k5,_5,T5];function jl(e){return ii[Math.abs(e)%ii.length]??Qp}function E5(e){const n=ii.length-2;return n<=0?0:1+((Number.isFinite(e)?Math.trunc(e):0)%n+n)%n}function R5(e){return jl(E5(e))}const M5="x-anthropic-billing-header:";function A5(e){return e.trimStart().toLowerCase().startsWith(M5)}function I5(e){return vl(e)?Object.prototype.hasOwnProperty.call(e,"system"):!1}function P5(e){if(!vl(e))return!1;const n=Z(e,"type"),s=Z(e,"text");return typeof n!="string"||n!=="text"||typeof s!="string"?!1:A5(s)}function L5(e){let n;try{n=JSON.parse(e)}catch{return{body:e,removed:0}}if(!I5(n))return{body:e,removed:0};const s=n.system;if(!Array.isArray(s)||s.length===0)return{body:e,removed:0};const o=[];let r=0;for(const a of s){if(P5(a)){r+=1;continue}o.push(a)}return r===0?{body:e,removed:0}:(o.length===0?delete n.system:n.system=o,{body:JSON.stringify(n),removed:r})}const O5=400,jc=2e3;function D5(e){return Array.isArray(e)}function z5(e,n){const s=[e];let o=0;for(;s.length>0;){const r=s.pop();if(r!==void 0){if(o+=1,o>n)return o;if(!(r===null||typeof r!="object")){if(D5(r)){for(const a of r)s.push(a);continue}for(const a of Object.keys(r)){const i=r[a];i!==void 0&&s.push(i)}}}}return o}function $5(e){const n=z5(e,jc+1);return n<=O5?{depth:Number.POSITIVE_INFINITY}:n<=jc?{depth:3}:{depth:2}}function F5(e){try{const n=JSON.parse(e);return{kind:"json",data:tr(n)}}catch{return{kind:"text"}}}function ma(e){const n=l.useMemo(()=>e===null?null:F5(e),[e]),s=n?.kind==="json"?n.data:null,o=l.useMemo(()=>s===null?null:$5(s),[s]),[r,a]=l.useState(!1),[i,c]=l.useState(0),[d,m]=l.useState(0),[u,p]=l.useTransition(),f=l.useCallback(()=>{const h=!r,g=h&&o!==null?o.depth:0;p(()=>{a(h),c(g),m(b=>b+1)})},[r,o]);return{parsedData:s,policy:o,isExpanded:r,toggle:f,isPending:u,bulkDepth:i,bulkRevision:d}}function tr(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(s=>tr(s));const n={};for(const s of Object.keys(e)){const o=Object.getOwnPropertyDescriptor(e,s);n[s]=tr(o?.value)}return n}case"bigint":case"symbol":case"function":case"undefined":return String(e)}return null}function ef({className:e,orientation:n="horizontal",...s}){return t.jsx(yw,{"data-slot":"tabs","data-orientation":n,orientation:n,className:O("group/tabs flex gap-2 data-[orientation=horizontal]:flex-col",e),...s})}const U5=Pd("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 tf({className:e,variant:n="default",...s}){return t.jsx(ww,{"data-slot":"tabs-list","data-variant":n,className:O(U5({variant:n}),e),...s})}function tn({className:e,...n}){return t.jsx(jw,{"data-slot":"tabs-trigger",className:O("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),...n})}function ut({className:e,...n}){return t.jsx(Sw,{"data-slot":"tabs-content",className:O("flex-1 outline-none",e),...n})}function sn(e){const[n,s]=l.useState(!1),o=l.useRef(null);l.useEffect(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);const r=l.useCallback(a=>{a.stopPropagation(),e!==null&&vt(e).then(i=>{i&&(s(!0),o.current!==null&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3))})},[e]);return{copied:n,copy:r}}const B5=l.lazy(()=>Dt(()=>import("./CompareDrawer-V-8lPASC.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.CompareDrawer}))),q5=l.lazy(()=>Dt(()=>import("./InspectorPet-D4CVnfdf.js"),__vite__mapDeps([4,1,2]),import.meta.url).then(e=>({default:e.InspectorPet}))),H5=l.lazy(()=>Dt(()=>import("./ReplayDialog-CpGyTLtt.js"),__vite__mapDeps([5,1,2,6]),import.meta.url).then(e=>({default:e.ReplayDialog}))),W5=l.lazy(()=>Dt(()=>import("./RequestAnatomy-BLuJL9dZ.js"),__vite__mapDeps([7,1,2]),import.meta.url).then(e=>({default:e.RequestAnatomy}))),V5=l.lazy(()=>Dt(()=>import("./ResponseView-BuSC-CH7.js"),__vite__mapDeps([6,1,2]),import.meta.url).then(e=>({default:e.ResponseView}))),K5=l.lazy(()=>Dt(()=>import("./StreamingChunkSequence-DeA-JJKa.js"),__vite__mapDeps([8,1,2]),import.meta.url).then(e=>({default:e.StreamingChunkSequence}))),li=l.lazy(()=>Dt(()=>import("./json-viewer-B9kIzqeX.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewer}))),G5=l.lazy(()=>Dt(()=>import("./json-viewer-B9kIzqeX.js"),__vite__mapDeps([9,1,2]),import.meta.url).then(e=>({default:e.JsonViewerFromString}))),J5=1200,Y5=12;function X5(e){const{containerRef:n,setExpandToPath:s,ensureTabActive:o,highlightMs:r}=e,a=l.useRef(null);return l.useCallback(i=>{o?.(),s(i.path);const c=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"),a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{p.classList.remove("ring-2","ring-primary/60","ring-offset-1","ring-offset-background","rounded-sm","transition-shadow"),s(null)},r??J5)},m=`[data-anatomy-path="${(p=>typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(p):p.replace(/(["'\\[\](){}])/g,"\\$1"))(i.path)}"]`,u=p=>{const f=n.current;if(f!==null){const h=f.querySelector(m);if(h!==null){c(h);return}}p>0?window.requestAnimationFrame(()=>u(p-1)):s(null)};window.requestAnimationFrame(()=>u(Y5))},[n,o,r,s])}const Sc="The compact log metadata is still available. Retry if the local server was restarting or the body store was briefly unavailable.";function Jn(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 Z5(e,n){const s=[];return e!=null&&s.push(`Request ${Jn(e)}`),n!=null&&s.push(`Response ${Jn(n)}`),s.length===0?null:s.join(" · ")}function Q5(e){if(e instanceof ji)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 n=e.message.trim();return{title:"Full bodies could not be loaded",detail:n===""?Sc:n}}return{title:"Full bodies could not be loaded",detail:Sc}}class nf{diff(n,s,o={}){let r;typeof o=="function"?(r=o,o={}):"callback"in o&&(r=o.callback);const a=this.castInput(n,o),i=this.castInput(s,o),c=this.removeEmpty(this.tokenize(a,o)),d=this.removeEmpty(this.tokenize(i,o));return this.diffWithOptionsObj(c,d,o,r)}diffWithOptionsObj(n,s,o,r){var a;const i=v=>{if(v=this.postProcess(v,o),r){setTimeout(function(){r(v)},0);return}else return v},c=s.length,d=n.length;let m=1,u=c+d;o.maxEditLength!=null&&(u=Math.min(u,o.maxEditLength));const p=(a=o.timeout)!==null&&a!==void 0?a:1/0,f=Date.now()+p,h=[{oldPos:-1,lastComponent:void 0}];let g=this.extractCommon(h[0],s,n,0,o);if(h[0].oldPos+1>=d&&g+1>=c)return i(this.buildValues(h[0].lastComponent,s,n));let b=-1/0,y=1/0;const w=()=>{for(let v=Math.max(b,-m);v<=Math.min(y,m);v+=2){let j;const S=h[v-1],N=h[v+1];S&&(h[v-1]=void 0);let C=!1;if(N){const I=N.oldPos-v;C=N&&0<=I&&I<c}const R=S&&S.oldPos+1<d;if(!C&&!R){h[v]=void 0;continue}if(!R||C&&S.oldPos<N.oldPos?j=this.addToPath(N,!0,!1,0,o):j=this.addToPath(S,!1,!0,1,o),g=this.extractCommon(j,s,n,v,o),j.oldPos+1>=d&&g+1>=c)return i(this.buildValues(j.lastComponent,s,n))||!0;h[v]=j,j.oldPos+1>=d&&(y=Math.min(y,v-1)),g+1>=c&&(b=Math.max(b,v+1))}m++};if(r)(function v(){setTimeout(function(){if(m>u||Date.now()>f)return r(void 0);w()||v()},0)})();else for(;m<=u&&Date.now()<=f;){const v=w();if(v)return v}}addToPath(n,s,o,r,a){const i=n.lastComponent;return i&&!a.oneChangePerToken&&i.added===s&&i.removed===o?{oldPos:n.oldPos+r,lastComponent:{count:i.count+1,added:s,removed:o,previousComponent:i.previousComponent}}:{oldPos:n.oldPos+r,lastComponent:{count:1,added:s,removed:o,previousComponent:i}}}extractCommon(n,s,o,r,a){const i=s.length,c=o.length;let d=n.oldPos,m=d-r,u=0;for(;m+1<i&&d+1<c&&this.equals(o[d+1],s[m+1],a);)m++,d++,u++,a.oneChangePerToken&&(n.lastComponent={count:1,previousComponent:n.lastComponent,added:!1,removed:!1});return u&&!a.oneChangePerToken&&(n.lastComponent={count:u,previousComponent:n.lastComponent,added:!1,removed:!1}),n.oldPos=d,m}equals(n,s,o){return o.comparator?o.comparator(n,s):n===s||!!o.ignoreCase&&n.toLowerCase()===s.toLowerCase()}removeEmpty(n){const s=[];for(let o=0;o<n.length;o++)n[o]&&s.push(n[o]);return s}castInput(n,s){return n}tokenize(n,s){return Array.from(n)}join(n){return n.join("")}postProcess(n,s){return n}get useLongestToken(){return!1}buildValues(n,s,o){const r=[];let a;for(;n;)r.push(n),a=n.previousComponent,delete n.previousComponent,n=a;r.reverse();const i=r.length;let c=0,d=0,m=0;for(;c<i;c++){const u=r[c];if(u.removed)u.value=this.join(o.slice(m,m+u.count)),m+=u.count;else{if(!u.added&&this.useLongestToken){let p=s.slice(d,d+u.count);p=p.map(function(f,h){const g=o[m+h];return g.length>f.length?g:f}),u.value=this.join(p)}else u.value=this.join(s.slice(d,d+u.count));d+=u.count,u.added||(m+=u.count)}}return r}}class eS extends nf{constructor(){super(...arguments),this.tokenize=of}equals(n,s,o){return o.ignoreWhitespace?((!o.newlineIsToken||!n.includes(`
|
|
49
|
+
`))&&(n=n.trim()),(!o.newlineIsToken||!s.includes(`
|
|
50
|
+
`))&&(s=s.trim())):o.ignoreNewlineAtEof&&!o.newlineIsToken&&(n.endsWith(`
|
|
51
|
+
`)&&(n=n.slice(0,-1)),s.endsWith(`
|
|
52
|
+
`)&&(s=s.slice(0,-1))),super.equals(n,s,o)}}const tS=new eS;function sf(e,n,s){return tS.diff(e,n,s)}function of(e,n){n.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
53
|
+
`));const s=[],o=e.split(/(\n|\r\n)/);o[o.length-1]||o.pop();for(let r=0;r<o.length;r++){const a=o[r];r%2&&!n.newlineIsToken?s[s.length-1]+=a:s.push(a)}return s}class nS extends nf{constructor(){super(...arguments),this.tokenize=of}get useLongestToken(){return!0}castInput(n,s){const{undefinedReplacement:o,stringifyReplacer:r=(a,i)=>typeof i>"u"?o:i}=s;return typeof n=="string"?n:JSON.stringify(ci(n,null,null,r),null," ")}equals(n,s,o){return super.equals(n.replace(/,([\r\n])/g,"$1"),s.replace(/,([\r\n])/g,"$1"),o)}}const sS=new nS;function oS(e,n,s){return sS.diff(e,n,s)}function ci(e,n,s,o,r){n=n||[],s=s||[],o&&(e=o(r===void 0?"":r,e));let a;for(a=0;a<n.length;a+=1)if(n[a]===e)return s[a];let i;if(Object.prototype.toString.call(e)==="[object Array]"){for(n.push(e),i=new Array(e.length),s.push(i),a=0;a<e.length;a+=1)i[a]=ci(e[a],n,s,o,String(a));return n.pop(),s.pop(),i}if(e&&e.toJSON&&(e=e.toJSON()),typeof e=="object"&&e!==null){n.push(e),i={},s.push(i);const c=[];let d;for(d in e)Object.prototype.hasOwnProperty.call(e,d)&&c.push(d);for(c.sort(),a=0;a<c.length;a+=1)d=c[a],i[d]=ci(e[d],n,s,o,d);n.pop(),s.pop()}else i=e;return i}function Nc(e){return e===void 0?[]:Object.entries(e).map(n=>[n[0].toLowerCase(),n[1]]).sort(([n],[s])=>n.localeCompare(s))}function Cc([e,n]){return`${e}: ${n}`}function di(e){const n=[];let s=0,o=0;for(const r of e){const a=r.value.split(`
|
|
54
|
+
`);a.length>0&&a[a.length-1]===""&&a.pop();for(const i of a)r.added?(o+=1,n.push({kind:"added",text:i,oldLineNumber:null,newLineNumber:o})):r.removed?(s+=1,n.push({kind:"removed",text:i,oldLineNumber:s,newLineNumber:null})):(s+=1,o+=1,n.push({kind:"context",text:i,oldLineNumber:s,newLineNumber:o}))}return n}function rS(e,n){const s=Nc(e).map(Cc).join(`
|
|
55
|
+
`),o=Nc(n).map(Cc).join(`
|
|
56
|
+
`);if(s===o)return{lines:[],isEmpty:!0};const r=sf(s,o);return{lines:di(r),isEmpty:!1}}function kc(e){try{const n=JSON.parse(e);return n===null||typeof n=="string"||typeof n=="object"?n:null}catch{return null}}function aS(e,n){const s=e??"",o=n??"";if(s===o)return{lines:[],isEmpty:!0};const r=kc(s),a=kc(o);if(r!==null&&a!==null){const c=oS(r,a)??[];if(c.length===1){const d=c[0];if(d!==void 0&&!d.added&&!d.removed)return{lines:[],isEmpty:!0}}return{lines:di(c),isEmpty:!1}}const i=sf(s,o);return{lines:di(i),isEmpty:!1}}const iS=22,pa=1e4;function lS(e){return e==="added"?"+":e==="removed"?"-":" "}function cS(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 dS=function({result:n,emptyLabel:s}){const[o,r]=l.useState("unified"),a=l.useRef(null),i=p5({count:n.lines.length,getScrollElement:()=>a.current,estimateSize:()=>iS,overscan:10});if(n.isEmpty)return t.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:s??"No transformation applied — raw and processed are identical."});const c=n.lines.length,d=c>pa,m=d?n.lines.slice(0,pa):n.lines;return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[c.toLocaleString()," line",c===1?"":"s",d&&` (showing first ${pa.toLocaleString()})`]}),t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":o==="unified",className:O("flex items-center gap-1 px-2 py-1 transition-colors",o==="unified"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Unified diff (single column)",children:[t.jsx(Wg,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>r("split"),"aria-pressed":o==="split",className:O("flex items-center gap-1 px-2 py-1 transition-colors border-l border-border",o==="split"?"bg-muted text-foreground":"hover:bg-muted/50"),title:"Split diff (side by side)",children:[t.jsx(A0,{className:"size-3"}),"Split"]})]})]}),t.jsx("div",{ref:a,className:"max-h-[60vh] overflow-auto rounded border border-border bg-background font-mono text-xs","data-testid":"diff-viewport",children:o==="unified"?t.jsx(uS,{virtualizer:i,lines:m}):t.jsx(fS,{lines:m})})]})};function uS({virtualizer:e,lines:n}){return t.jsx("div",{style:{height:`${e.getTotalSize()}px`,width:"100%",position:"relative"},children:e.getVirtualItems().map(s=>{const o=n[s.index];return o===void 0?null:t.jsxs("div",{"data-index":s.index,ref:e.measureElement,className:O("flex items-start gap-3 px-2",cS(o.kind)),style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${s.start}px)`},children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.oldLineNumber??""}),t.jsx("span",{className:"select-none text-muted-foreground/60 w-10 text-right tabular-nums",children:o.newLineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",o.kind==="added"&&"text-green-600 dark:text-green-400",o.kind==="removed"&&"text-red-600 dark:text-red-400"),children:lS(o.kind)}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:o.text})]},s.key)})})}function mS(e){const n=[];let s=0;for(;s<e.length;){const o=e[s];if(o===void 0)break;if(o.kind==="context"){n.push({left:{text:o.text,lineNumber:o.oldLineNumber},right:{text:o.text,lineNumber:o.newLineNumber},kind:"equal"}),s+=1;continue}const r=[],a=[];for(;s<e.length&&e[s]?.kind==="removed";){const c=e[s];c!==void 0&&r.push(c),s+=1}for(;s<e.length&&e[s]?.kind==="added";){const c=e[s];c!==void 0&&a.push(c),s+=1}const i=Math.max(r.length,a.length);for(let c=0;c<i;c+=1){const d=r[c],m=a[c];d!==void 0&&m!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:{text:m.text,lineNumber:m.newLineNumber},kind:"changed"}):d!==void 0?n.push({left:{text:d.text,lineNumber:d.oldLineNumber},right:null,kind:"removed"}):m!==void 0&&n.push({left:null,right:{text:m.text,lineNumber:m.newLineNumber},kind:"added"})}}return n}function pS(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 fS({lines:e}){const n=mS(e);return t.jsx("div",{"data-testid":"diff-split",children:n.map((s,o)=>t.jsxs("div",{className:O("grid grid-cols-2 font-mono text-xs",pS(s.kind)),children:[t.jsxs("div",{className:"flex items-start gap-2 px-2 border-r border-border/50",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.left?.lineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="removed"||s.kind==="changed")&&"text-red-600 dark:text-red-400"),children:s.left!==null?"-":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.left?.text??""})]}),t.jsxs("div",{className:"flex items-start gap-2 px-2",children:[t.jsx("span",{className:"select-none text-muted-foreground/60 w-8 text-right tabular-nums",children:s.right?.lineNumber??""}),t.jsx("span",{className:O("select-none w-3 text-right font-bold",(s.kind==="added"||s.kind==="changed")&&"text-green-600 dark:text-green-400"),children:s.right!==null?"+":" "}),t.jsx("span",{className:"whitespace-pre-wrap break-all flex-1",children:s.right?.text??""})]})]},o))})}const rf=l.memo(dS),hS=Pd("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 ke({className:e,variant:n="default",asChild:s=!1,...o}){const r=s?mb:"span";return t.jsx(r,{"data-slot":"badge","data-variant":n,className:O(hS({variant:n}),e),...o})}const xS=3;function gS({event:e}){const n=s=>{s.stopPropagation(),ds({logId:e.logId,tab:"response",toolCallIndex:e.index})};return t.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:n,onKeyDown:s=>s.stopPropagation(),"aria-label":`Open response tool call ${e.name}`,title:e.name,children:t.jsx("span",{className:"min-w-0 truncate font-mono font-semibold",children:e.name})})}function bS({events:e}){if(e.length===0)return null;const n=e.slice(0,xS),s=Math.max(0,e.length-n.length);return t.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:o=>o.stopPropagation(),onKeyDown:o=>o.stopPropagation(),children:[t.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:[t.jsx(Ks,{className:"size-3"}),"Call ",e.length]}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-hidden",children:[n.map(o=>t.jsx(gS,{event:o},o.id)),s>0&&t.jsxs("span",{className:"inline-flex h-5 shrink-0 items-center rounded px-1 font-mono text-[10px] font-semibold text-muted-foreground",children:["+",s]})]})]})}const vS={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"},yS={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",gt="bg-white/[0.045] flex h-7 items-center gap-1 rounded-md px-2 text-xs";function js(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function wS(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function jS(e,n){switch(e){case"success":return n===null?"OK":String(n);case"client_error":return n===null?"WARN":String(n);case"server_error":return n===null?"FAIL":String(n);case"pending":return"ROLL"}}function _c({trend:e}){if(e===null)return null;const n=e.direction==="up",s=n?Vx:Fx,o=n?"+":"-";return t.jsxs("span",{className:"flex items-center gap-0.5 text-muted-foreground tabular-nums",children:[t.jsx(s,{className:n?"size-3 text-cyan-300":"size-3 text-rose-400"}),t.jsxs("span",{className:"font-mono",children:[o,Ee(e.delta)]})]})}const SS=l.memo(function({log:e,displayNumber:n,messageCount:s=null,toolCount:o=null,toolEvents:r=[],expanded:a,onToggle:i,cacheTrend:c=null,activeTab:d,tabActions:m,onReplay:u,slowResponseThresholdSeconds:p=0,showClientMetadata:f=!0,timeDisplayFormat:h}){const g=Nh(e.responseStatus),b=e.elapsedMs!==null&&p>0&&e.elapsedMs>p*1e3,y=e.inputTokens!==null||e.outputTokens!==null,w=e.firstChunkMs??null,v=e.tokensPerSecond??null,j=w===null?null:js(w),S=v===null||v<=0?null:wS(v),N=e.warnings?.length??0,C=e.clientPid!==null&&e.clientPid!==void 0,R=e.clientProjectFolder!==null&&e.clientProjectFolder!==void 0&&e.clientProjectFolder!=="";e.clientCwd!==null&&e.clientCwd!==void 0&&e.clientCwd;const I=yS[g],P=jS(g,e.responseStatus),M=g!=="success"||e.responseStatus!==200,k=e.streaming&&j===null&&S===null;return t.jsx(hs,{children:t.jsxs("div",{id:`log-${e.id}`,role:"button",tabIndex:0,"data-nav-id":`log-${e.id}`,"data-nav-action":a?"collapse":"expand",className:O("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]",a?"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:i,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),i())},children:[t.jsxs("span",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:O("inline-flex h-8 shrink-0 items-center rounded-md px-2 font-mono",I.frame),children:t.jsxs("span",{className:"text-xs font-semibold tabular-nums",title:`Log ID ${String(e.id)}`,children:["#",n]})}),t.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:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",title:e.timestamp,children:Ha(e.timestamp,h)})]}),M&&t.jsxs(ke,{variant:"outline",className:O("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)]",vS[g]),children:[g==="success"?t.jsx(Oe,{className:"size-3","aria-label":"Success"}):g==="server_error"?t.jsx(Rg,{className:"size-3","aria-label":"Server error"}):g==="client_error"?t.jsx(rn,{className:"size-3","aria-label":"Client error"}):t.jsx(Ae,{className:"size-3 animate-spin","aria-label":"Pending"}),P]}),N>0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs(ke,{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:[t.jsx(rn,{className:"size-3","aria-label":"Tool schema warnings"}),N]})}),t.jsx(nt,{children:N===1?"1 tool schema warning":`${N} tool schema warnings`})]}),e.elapsedMs!==null&&(b?t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs("span",{className:O(gt,"shrink-0 border-amber-300/25 text-amber-200"),children:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:js(e.elapsedMs)}),t.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsxs(nt,{children:["Slow response: ",js(e.elapsedMs)," exceeds"," ",js(p*1e3)]})]}):t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:js(e.elapsedMs)})]})),e.streaming&&j!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-cyan-300"),children:[t.jsx(ql,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:["first ",j]})]}),e.streaming&&S!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-cyan-300"),children:[t.jsx($i,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:S})]}),y&&t.jsxs("span",{className:O(gt,"min-w-0 sm:shrink-0"),children:[t.jsx(Ps,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-1 font-mono tabular-nums",children:[t.jsxs("span",{className:O("whitespace-nowrap",e.inputTokens!==null?"text-blue-400":"text-muted-foreground"),children:["IN ",e.inputTokens!==null?Ee(e.inputTokens):"n/a"]}),t.jsx("span",{className:"text-muted-foreground",children:"/"}),t.jsxs("span",{className:O("whitespace-nowrap",e.outputTokens!==null?"text-amber-400":"text-muted-foreground"),children:["OUT ",e.outputTokens!==null?Ee(e.outputTokens):"n/a"]})]})]}),e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:O(gt,"shrink-0"),children:[t.jsx(_c,{trend:c?.creation??null}),t.jsxs("span",{className:"font-mono tabular-nums text-cyan-300",children:["KV Cache +",Ee(e.cacheCreationInputTokens)]})]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:O(gt,"shrink-0"),children:[t.jsx(_c,{trend:c?.read??null}),t.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",Ee(e.cacheReadInputTokens)]})]}),s!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(hr,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:s})]}),o!==null&&t.jsxs("span",{className:O(gt,"shrink-0 text-muted-foreground"),children:[t.jsx(Ks,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:o})]}),t.jsx(bS,{events:r}),e.origin!==null&&t.jsxs("span",{className:O(gt,"hidden shrink-0 text-muted-foreground xl:flex"),title:`Origin: ${e.origin}`,children:[t.jsx(iu,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums truncate max-w-[120px]",title:e.origin,children:e.origin})]}),f&&(C||R)&&t.jsxs("span",{className:O(gt,"hidden shrink-0 text-purple-300 xl:flex"),children:[t.jsx(Y0,{className:"size-3"}),R?t.jsx("span",{className:"font-mono tabular-nums",children:e.clientProjectFolder}):t.jsxs("span",{className:"font-mono tabular-nums",children:["PID ",e.clientPid]})]}),k&&t.jsx(ql,{className:"size-3 shrink-0 text-muted-foreground/60"})]}),t.jsxs("span",{className:"flex shrink-0 items-start gap-1.5",children:[a&&t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",onClick:A=>A.stopPropagation(),onKeyDown:A=>A.stopPropagation(),children:[m!==void 0&&d!==void 0&&(()=>{const A=m[d];return A===void 0?null:t.jsxs(t.Fragment,{children:[A.expansion!==null&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:A.expansion.onToggle,disabled:A.expansion.isPending,"aria-pressed":A.expansion.isExpanded,"aria-label":A.expansion.isExpanded?"Collapse all JSON":"Expand all JSON",children:A.expansion.isExpanded?t.jsx(f0,{className:"size-3.5"}):t.jsx(l0,{className:"size-3.5"})})}),t.jsx(nt,{children:A.expansion.isExpanded?"Collapse all JSON nodes":"Expand all JSON nodes"})]}),A.diffWithRaw!==void 0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:O(ws,A.diffWithRaw.active&&"border-cyan-300/35 bg-cyan-400/15 text-cyan-100"),onClick:A.diffWithRaw.onToggle,"aria-pressed":A.diffWithRaw.active,"aria-label":A.diffWithRaw.active?"Hide raw diff":"Diff with raw",children:t.jsx(V0,{className:"size-3.5"})})}),t.jsx(nt,{children:A.diffWithRaw.active?"Hide diff with raw request":"Show diff between displayed and raw request body"})]}),A.diffWithPrevious!==void 0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:A.diffWithPrevious,"aria-label":"Diff with previous",children:t.jsx(lu,{className:"size-3.5"})})}),t.jsx(nt,{children:"Compare this request with the immediately preceding one"})]}),A.copyText!==null&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:A.onCopy,"aria-label":A.copyCopied?"Copied":A.copyLabel,children:A.copyCopied?t.jsx(Oe,{className:"size-3.5 text-cyan-300"}):t.jsx(St,{className:"size-3.5"})})}),t.jsx(nt,{children:A.copyCopied?"Copied to clipboard":A.copyLabel})]})]})})(),u!==void 0&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx(ee,{variant:"outline",size:"icon",className:ws,onClick:u,"aria-label":"Replay request",children:t.jsx(mu,{className:"size-3.5"})})}),t.jsx(nt,{children:"Re-send this request to the provider"})]})]}),t.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:a?t.jsx(Ve,{className:"size-4 shrink-0"}):t.jsx(it,{className:"size-4 shrink-0"})})]})]})})});function NS({...e}){return t.jsx($b,{"data-slot":"collapsible",...e})}function XT({...e}){return t.jsx(Cu,{"data-slot":"collapsible-trigger",...e})}function CS({...e}){return t.jsx(ku,{"data-slot":"collapsible-content",...e})}function kS({className:e,children:n,...s}){return t.jsxs(Hy,{"data-slot":"scroll-area",className:O("relative overflow-hidden",e),...s,children:[t.jsx(Wy,{"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:n}),t.jsx(_S,{}),t.jsx(Vy,{})]})}function _S({className:e,orientation:n="vertical",...s}){return t.jsx(Lm,{"data-slot":"scroll-area-scrollbar",orientation:n,className:O("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...s,children:t.jsx($m,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const af={file:"file",shell:"shell",browser:"browser",web:"web",mcp:"MCP",code:"code",other:"other"},TS={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 ES({category:e}){switch(e){case"file":return t.jsx(Z0,{className:"size-3.5"});case"shell":return t.jsx(In,{className:"size-3.5"});case"browser":return t.jsx(kg,{className:"size-3.5"});case"web":return t.jsx(iu,{className:"size-3.5"});case"mcp":return t.jsx(Xx,{className:"size-3.5"});case"code":return t.jsx(ou,{className:"size-3.5"});case"other":return t.jsx(z0,{className:"size-3.5"})}}function RS({names:e}){return e.length===0?null:t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:"required"}),e.slice(0,4).map(n=>t.jsx(ke,{variant:"outline",className:"h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",children:n},n)),e.length>4&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["+",e.length-4]})]})}function MS({tool:e,called:n}){const[s,o]=l.useState(!1),r=sn(e.name),a=e.description!==null||e.requiredParameters.length>0||e.schema!==null;return t.jsx(NS,{open:s,onOpenChange:o,children:t.jsxs("div",{className:"bg-white/[0.035] rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-2.5 py-2",children:[t.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:()=>o(i=>!i),"aria-expanded":s,disabled:!a,children:[t.jsx(ES,{category:e.category}),t.jsx("span",{className:"min-w-0 truncate font-mono text-xs font-semibold text-foreground/90",children:e.name}),n&&t.jsx(ke,{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"}),t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:[e.parameterCount," params"]}),e.descriptionPreview!==null&&t.jsx("span",{className:"hidden min-w-0 truncate text-xs text-muted-foreground md:inline",children:e.descriptionPreview}),t.jsx("span",{className:"flex-1"}),a&&(s?t.jsx(Ve,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(it,{className:"size-3.5 shrink-0 text-muted-foreground"}))]}),t.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:r.copy,"aria-label":r.copied?"Copied tool name":"Copy tool name",children:r.copied?t.jsx(Oe,{className:"size-3.5 text-emerald-400"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx(CS,{children:s&&t.jsxs("div",{className:"space-y-2 bg-white/[0.025] px-2.5 py-2",children:[e.description!==null&&t.jsx("p",{className:"text-xs leading-relaxed text-muted-foreground",children:e.description}),t.jsx(RS,{names:e.requiredParameters}),e.schema!==null&&t.jsx(kS,{className:"bg-black/[0.16] max-h-64 rounded-[8px] p-2",children:t.jsx(l.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(li,{data:tr(e.schema),defaultExpandDepth:0})})})]})})]})})}function AS(e,n){return n.length===0?!0:`${e.name} ${e.description??""} ${af[e.category]}`.toLowerCase().trim().includes(n)}const IS=l.memo(function({summary:n,calledToolNames:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(""),c=l.useMemo(()=>new Set(s),[s]),d=a.trim().toLowerCase(),m=l.useMemo(()=>n===null?[]:n.tools.filter(f=>AS(f,d)),[d,n]);if(n===null)return null;const u=n.tools.slice(0,6),p=n.tools.length-u.length;return t.jsxs("section",{className:"bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx(Ks,{className:"size-4 shrink-0 text-sky-300/80"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Request Tools"}),t.jsx(ke,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",children:n.tools.length}),n.toolChoiceLabel!==null&&t.jsxs(ke,{variant:"outline",className:"h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground",children:["tool_choice: ",n.toolChoiceLabel]})]}),t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap gap-1",children:n.categories.map(f=>t.jsxs(ke,{variant:"outline",className:O("h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",TS[f.category]),children:[f.count," ",af[f.category]]},f.category))})]})]}),t.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-cyan-100",onClick:()=>r(f=>!f),"aria-expanded":o,children:[o?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"}),o?"Hide":"Show"]})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2",children:[u.map(f=>t.jsx(ke,{variant:"outline",className:O("h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",c.has(f.name)&&"border-emerald-400/20 text-emerald-300"),children:f.name},f.name)),p>0&&t.jsxs("span",{className:"font-mono text-[10px] leading-5 text-muted-foreground",children:["+",p]})]}),o&&t.jsxs("div",{className:"space-y-2 bg-black/10 px-3 py-3",children:[t.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:[t.jsx(Xg,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("input",{value:a,onChange:f=>i(f.target.value),placeholder:"Filter tools",className:"min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"})]}),t.jsx("div",{className:"grid gap-1.5",children:m.length>0?m.map(f=>t.jsx(MS,{tool:f,called:c.has(f.name)},f.name)):t.jsx("p",{className:"py-2 text-xs text-muted-foreground",children:"No matching tools"})})]})]})});function Tc(e,n,s){return e==="anthropic"&&n==="full"&&s}function PS(e,n){return e==="full"&&n}function fa(e,n){return e==="full"&&n}function ha(e,n){return e==="full"&&n}function LS(e,n,s,o){return e==="anthropic"&&n==="full"&&s&&o}function Hn(){return t.jsx("div",{className:"h-1","aria-hidden":"true"})}function OS(e,n){switch(e){case"anatomy":return n===null?"request":"anatomy";case"request":return"request";case"response":return"parsed"}}const DS=15e3,zS=15e3,$S=256*1024,nr=1024*1024,vn="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 fo(e=null){return{status:"idle",text:"",offset:0,totalBytes:e,hasMore:e!==null&&e>0,error:null}}function sr(e){return e??0}function lf(e){return e.bodyContentMode==="compact"||e.bodyContentMode==="truncated"}function cf(e){return lf(e)?sr(e.rawRequestBodyBytes)>nr||sr(e.responseTextBytes)>nr:!1}function FS(e){return lf(e)&&!cf(e)}function US(e){return e instanceof ji?"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 ho({status:e,error:n,footprint:s,onRetry:o}){switch(e){case"idle":return null;case"loading":return t.jsx($s,{tone:"loading",title:"Loading full bodies",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ae,{className:"size-3.5 shrink-0 animate-spin text-cyan-200"}),t.jsx("span",{children:"Loading full request and response bodies from the log store."})]}),s!==null&&t.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:s})]})});case"failed":return t.jsx($s,{tone:"warning",title:n?.title??"Full bodies could not be loaded",children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("span",{children:n?.detail??"Compact metadata is still available."}),t.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:o,children:[t.jsx(yt,{className:"size-3"}),"Retry"]})]})})}}function Ec(e,n){return e?n.text!==""?n.text:n.status==="success"?"":null:null}function yn({children:e,className:n}){return t.jsx("div",{className:O("bg-black/[0.14] inspector-scrollbar mx-3 mb-3 max-h-[72vh] overflow-auto rounded-[8px] p-3",n),children:e})}function Po({children:e}){return t.jsx("div",{className:"bg-white/[0.035] rounded-md px-3 py-5 text-center text-xs italic text-muted-foreground",children:e})}function xo({children:e}){return t.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 BS={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 $s({tone:e,title:n,children:s}){return t.jsxs("div",{className:O("mb-3 rounded-md border px-3 py-2 text-xs shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",BS[e]),children:[n!==void 0&&t.jsx("div",{className:"mb-1 font-semibold",children:n}),t.jsx("div",{className:"leading-relaxed text-muted-foreground",children:s})]})}function go({label:e,state:n,expectedBytes:s,onLoadMore:o}){const r=n.totalBytes??s,a=r===null?Jn(n.offset):`${Jn(n.offset)} / ${Jn(r)}`,i=n.status!=="loading"&&n.hasMore,c=n.status==="failed"?"Retry":"Load more";return t.jsx($s,{tone:n.status==="failed"?"warning":"loading",title:`${e} body preview`,children:t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("span",{children:[n.status==="idle"&&r!==null?`${e} body is ${Jn(r)}. Loading the first preview chunk.`:`Loaded ${a}.`,n.status==="failed"&&n.error!==null&&` ${n.error}`]}),i&&t.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:o,children:c})]})})}function Rc({headers:e,emptyLabel:n}){const s=e===void 0?[]:Object.entries(e).sort(([o],[r])=>o.localeCompare(r));return s.length===0?t.jsx(Po,{children:n}):t.jsx("div",{className:"bg-black/[0.14] overflow-hidden rounded-[8px] font-mono text-xs",children:s.map(([o,r])=>t.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:[t.jsx("div",{className:"min-w-0 truncate bg-white/[0.035] px-2.5 py-2 font-semibold text-cyan-200",children:o}),t.jsx("div",{className:"min-w-0 truncate px-2.5 py-2 text-muted-foreground",title:r,children:r})]},o))})}function qS({active:e,onClick:n}){return t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs(ee,{variant:e?"default":"outline",size:"sm",className:O("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:n,"aria-pressed":e,children:[t.jsx(ag,{className:"size-3.5 mr-1"}),e?"Showing diff":"Diff with Raw"]})}),t.jsx(nt,{children:e?"Hide diff view":"Compare proxy output against the original raw version"})]})}const HS=l.memo(function({rawBody:e,displayedBody:n,emptyLabel:s}){const o=l.useMemo(()=>aS(e,n),[e,n]);return t.jsx(rf,{result:o,emptyLabel:s})}),WS=l.memo(function({rawHeaders:e,headers:n,emptyLabel:s}){const o=l.useMemo(()=>rS(e,n),[e,n]);return t.jsx(rf,{result:o,emptyLabel:s})}),VS=l.memo(function({log:e,displayNumber:n,viewMode:s="simple",strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:a,cacheTrend:i=null,onCompareWithPrevious:c,showClientMetadata:d=!0,toolEvents:m=[]}){const[u,p]=l.useState(!1),[f,h]=l.useState(!1),[g,b]=l.useState(!1),[y,w]=l.useState(!1),[v,j]=l.useState("request"),[S,N]=l.useState(null),[C,R]=l.useState(0),[I,P]=l.useState(null),[M,k]=l.useState(null),[A,D]=l.useState("idle"),[$,J]=l.useState(null),[X,F]=l.useState(0),[H,Y]=l.useState(()=>fo(e.rawRequestBodyBytes??null)),[U,W]=l.useState(()=>fo(e.responseTextBytes??null)),me=l.useRef(null),ge=l.useRef(e.id),be=l.useRef(!1),z=M??e,oe=M===null&&cf(e),te=l.useMemo(()=>Z5(e.rawRequestBodyBytes,e.responseTextBytes),[e.rawRequestBodyBytes,e.responseTextBytes]),Se=Ec(oe,H),Ne=Ec(oe,U),ie=z.rawRequestBody??Se,le=z.responseText??Ne,fe=z.rawRequestBody===null&&Se!==null,ve=z.responseText===null&&Ne!==null,Ce=!fe||H.hasMore===!1&&sr(H.totalBytes)<=nr,Ie=!ve||U.hasMore===!1&&sr(U.totalBytes)<=nr,$e=Ds(z),Pe=Wp($e),Ze=l.useMemo(()=>Pe.analyzeRequest(z.rawRequestBody),[Pe,z.rawRequestBody]),Bt=l.useMemo(()=>Pe.analyzeResponse(z.responseText),[Pe,z.responseText]),Fe=l.useMemo(()=>!o||$e!=="anthropic"||z.rawRequestBody===null?null:L5(z.rawRequestBody).body,[z.rawRequestBody,$e,o])??ie,Me=ma(Ce?Fe:null),Le=ma(v==="raw-request"&&Ce?ie:null),B=ma(v==="raw"&&Ie?le:null),ne=l.useMemo(()=>z.headers&&Object.keys(z.headers).length>0?JSON.stringify(z.headers,null,2):null,[z.headers]),ye=l.useMemo(()=>z.rawHeaders&&Object.keys(z.rawHeaders).length>0?JSON.stringify(z.rawHeaders,null,2):null,[z.rawHeaders]),he=sn(Fe),we=sn(ie),Be=sn(ne),G=sn(ye),_=sn(le),L=l.useMemo(()=>({request:{copyLabel:fe?"Copy loaded request preview":"Copy request body",copyText:Fe,copyCopied:he.copied,onCopy:he.copy,expansion:Ce?{isExpanded:Me.isExpanded,isPending:Me.isPending,onToggle:Me.toggle}:null,diffWithRaw:LS($e,s,o,z.rawRequestBody!==null)?{active:y,onToggle:()=>w(!y)}:void 0,diffWithPrevious:c===void 0?void 0:()=>{c(z)}},"raw-request":{copyLabel:fe?"Copy loaded raw request preview":"Copy raw request",copyText:ie,copyCopied:we.copied,onCopy:we.copy,expansion:Ce?{isExpanded:Le.isExpanded,isPending:Le.isPending,onToggle:Le.toggle}:null},...ha(s,z.headers!==void 0&&Object.keys(z.headers).length>0)?{headers:{copyLabel:"Copy headers",copyText:ne,copyCopied:Be.copied,onCopy:Be.copy,expansion:null}}:{},...fa(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)?{"raw-headers":{copyLabel:"Copy raw headers",copyText:ye,copyCopied:G.copied,onCopy:G.copy,expansion:null}}:{},raw:{copyLabel:ve?"Copy loaded response preview":"Copy response",copyText:le,copyCopied:_.copied,onCopy:_.copy,expansion:Ie?{isExpanded:B.isExpanded,isPending:B.isPending,onToggle:B.toggle}:null}}),[Fe,fe,Ce,he,Me,y,z,z.rawRequestBody,ie,we,Le,ne,Be,ye,G,z.responseText,ve,Ie,le,_,B,$e,s,o,c]),V=l.useMemo(()=>Me.parsedData!==null?Pe.anatomySegments(Me.parsedData):null,[Pe,Me.parsedData]),se=l.useMemo(()=>yl(Me.parsedData),[Me.parsedData]),ce=z.warnings??[],Q=l.useMemo(()=>{if(V!==null)return new Set(V.map(Re=>Re.path))},[V]),pe=X5({containerRef:me,setExpandToPath:P,ensureTabActive:()=>{v!=="request"&&j("request")}}),ae=l.useCallback((Re,qt)=>{const dt=Re==="request"?Y:W;dt(Qe=>({...Qe,status:"loading",error:null}));const xs=new URLSearchParams({part:Re,offset:String(qt),limit:String($S)});De(`/api/logs/${String(e.id)}/body?${xs.toString()}`,Ph,zS).then(Qe=>{ge.current===e.id&&dt(xn=>({status:"success",text:Qe.offset===0?Qe.text:`${xn.text}${Qe.text}`,offset:Qe.nextOffset??Qe.totalBytes,totalBytes:Qe.totalBytes,hasMore:Qe.hasMore,error:null}))}).catch(Qe=>{ge.current===e.id&&dt(xn=>({...xn,status:"failed",error:US(Qe)}))})},[e.id]),ht=l.useCallback(()=>{be.current||(k(null),D("idle"),J(null),F(Re=>Re+1))},[]),hn=l.useCallback(()=>{const Re=!u;Re&&j(V!==null?"anatomy":"request"),p(Re)},[V,u]);return l.useEffect(()=>{ge.current=e.id,be.current=!1,k(null),D("idle"),J(null),F(0),Y(fo(e.rawRequestBodyBytes??null)),W(fo(e.responseTextBytes??null))},[e.id,e.rawRequestBodyBytes,e.responseTextBytes]),l.useEffect(()=>{if(!u||!FS(e)||M!==null||be.current)return;let Re=!1;return be.current=!0,D("loading"),J(null),De(`/api/logs/${String(e.id)}`,Is,DS).then(qt=>{Re||(be.current=!1,k(qt),D("idle"),J(null))}).catch(qt=>{Re||(be.current=!1,D("failed"),J(Q5(qt)))}),()=>{Re=!0,be.current=!1}},[u,M,e.bodyContentMode,e.id,e.rawRequestBodyBytes,e.responseTextBytes,X]),l.useEffect(()=>{u&&oe&&H.status==="idle"&&(v!=="request"&&v!=="raw-request"&&v!=="anatomy"||ae("request",0))},[v,u,ae,H.status,oe]),l.useEffect(()=>{u&&oe&&U.status==="idle"&&(v!=="parsed"&&v!=="raw"||ae("response",0))},[v,u,ae,U.status,oe]),l.useEffect(()=>{const Re=qt=>{const dt=$r(qt);dt!==null&&dt.logId===e.id&&(p(!0),j(OS(dt.tab,V)),dt.tab==="response"&&dt.toolCallIndex!==void 0&&(N(dt.toolCallIndex),R(xs=>xs+1)))};return window.addEventListener(Gt,Re),()=>{window.removeEventListener(Gt,Re)}},[V,e.id]),t.jsxs(hs,{children:[t.jsxs("div",{className:O("bg-card/80 relative mb-1.5 overflow-hidden rounded-[8px] transition-[background-color,box-shadow]",u?"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:[t.jsx(SS,{log:z,displayNumber:n,messageCount:Ze.messageCount,toolCount:Ze.toolCount,toolEvents:m,expanded:u,onToggle:hn,cacheTrend:i,slowResponseThresholdSeconds:r,showClientMetadata:d,timeDisplayFormat:a,activeTab:v,tabActions:L,onReplay:c===void 0?void 0:()=>{h(!0)}}),u&&t.jsxs("div",{className:"relative bg-black/[0.14] pt-2",onClick:Re=>Re.stopPropagation(),onKeyDown:Re=>Re.stopPropagation(),children:[t.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"}),t.jsx($o,{feature:"Log details",children:t.jsxs(ef,{value:v,onValueChange:j,className:"gap-2",children:[t.jsxs(tf,{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:[fa(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(tn,{className:vn,value:"raw-headers",children:"Raw Headers"}),ha(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&t.jsx(tn,{className:vn,value:"headers",children:"Headers"}),V!==null&&t.jsx(tn,{className:vn,value:"anatomy",children:"Context"}),Tc($e,s,o)&&t.jsx(tn,{className:vn,value:"raw-request",children:"Raw Request"}),t.jsx(tn,{className:vn,value:"request",children:"Request"}),s==="full"&&t.jsx(tn,{className:vn,value:"raw",children:"Raw Response"}),t.jsx(tn,{className:vn,value:"parsed",children:"Response"})]}),Tc($e,s,o)&&t.jsx(ut,{value:"raw-request",children:v==="raw-request"&&t.jsxs(yn,{children:[t.jsx(ho,{status:A,error:$,footprint:te,onRetry:ht}),oe&&t.jsx(go,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ae("request",H.offset)}),ie===null?t.jsx(Po,{children:oe?"Request preview is loading":"No request body"}):Le.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(li,{data:Le.parsedData,bulkDepth:Le.bulkDepth,bulkRevision:Le.bulkRevision})}):t.jsx(xo,{children:ie})]})}),t.jsx(ut,{value:"request",children:v==="request"&&t.jsxs(yn,{children:[t.jsx(ho,{status:A,error:$,footprint:te,onRetry:ht}),oe&&t.jsx(go,{label:"Request",state:H,expectedBytes:e.rawRequestBodyBytes??null,onLoadMore:()=>ae("request",H.offset)}),ce.length>0&&t.jsxs($s,{tone:"warning",children:[t.jsxs("div",{className:"flex items-center gap-2 font-semibold text-amber-300",children:[t.jsx(rn,{className:"size-3.5"}),"Tool schema warnings"]}),t.jsx("ul",{className:"mt-2 space-y-1 text-muted-foreground",children:ce.map(Re=>t.jsx("li",{children:Re},Re))})]}),t.jsx(IS,{summary:se,calledToolNames:Bt.toolNames??[]}),y?t.jsx(HS,{rawBody:z.rawRequestBody,displayedBody:Fe,emptyLabel:"No transformation applied; raw and sent request bodies are identical."}):t.jsx("div",{ref:me,children:Fe===null?t.jsx(Po,{children:oe?"Request preview is loading":"No request body"}):Me.parsedData!==null?t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(li,{data:Me.parsedData,bulkDepth:Me.bulkDepth,bulkRevision:Me.bulkRevision,anatomyPaths:Q,expandToPath:I})}):t.jsx(xo,{children:Fe})})]})}),V!==null&&t.jsx(ut,{value:"anatomy",children:v==="anatomy"&&t.jsx(yn,{className:"p-0",children:t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(W5,{parsed:Me.parsedData,inputTokens:z.inputTokens??null,model:z.model,segments:V,onSegmentActivate:pe})})})}),ha(s,z.headers!==void 0&&Object.keys(z.headers).length>0)&&t.jsx(ut,{value:"headers",children:v==="headers"&&t.jsxs(yn,{children:[t.jsx("div",{className:"flex justify-end gap-2 mb-2",children:PS(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(qS,{active:g,onClick:Re=>{Re.stopPropagation(),b(!g)}})}),g?t.jsx(WS,{rawHeaders:z.rawHeaders,headers:z.headers,emptyLabel:"No transformation applied; raw and processed headers are identical."}):t.jsx(Rc,{headers:z.headers,emptyLabel:"No headers captured"})]})}),fa(s,z.rawHeaders!==void 0&&Object.keys(z.rawHeaders).length>0)&&t.jsx(ut,{value:"raw-headers",children:v==="raw-headers"&&t.jsx(yn,{children:t.jsx(Rc,{headers:z.rawHeaders,emptyLabel:"No raw headers captured"})})}),t.jsx(ut,{value:"raw",children:v==="raw"&&t.jsxs(yn,{className:"space-y-3",children:[t.jsx(ho,{status:A,error:$,footprint:te,onRetry:ht}),oe&&t.jsx(go,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ae("response",U.offset)}),z.error!==void 0&&z.error!==null&&t.jsx($s,{tone:"danger",title:"SSE Error",children:t.jsx("span",{className:"font-mono",children:z.error})}),le!==null&&Ie?t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(G5,{text:le,defaultExpandDepth:0,bulkDepth:B.bulkDepth,bulkRevision:B.bulkRevision})}):le!==null?t.jsx(xo,{children:le}):t.jsx(Po,{children:oe?"Response preview is loading":"No response"}),z.streaming===!0&&t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(K5,{logId:z.id,truncated:z.streamingChunksPath!==null})})]})}),t.jsx(ut,{value:"parsed",children:v==="parsed"&&t.jsxs(yn,{children:[t.jsx(ho,{status:A,error:$,footprint:te,onRetry:ht}),oe&&t.jsx(go,{label:"Response",state:U,expectedBytes:e.responseTextBytes??null,onLoadMore:()=>ae("response",U.offset)}),ve&&!Ie?t.jsx(xo,{children:le}):t.jsx(l.Suspense,{fallback:t.jsx(Hn,{}),children:t.jsx(V5,{responseText:le,responseStatus:z.responseStatus,streaming:z.streaming,inputTokens:z.inputTokens,outputTokens:z.outputTokens,cacheCreationInputTokens:z.cacheCreationInputTokens,cacheReadInputTokens:z.cacheReadInputTokens,apiFormat:$e,error:z.error,focusedToolIndex:S,toolFocusNonce:C})})]})})]})})]})]}),t.jsx($o,{feature:"Replay",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(H5,{log:z,displayNumber:n,open:f,onOpenChange:h})})})]})});function KS(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 xa(e){return e?"cursor-pointer transition-transform hover:scale-110":""}function GS({stopReason:e,isPending:n,isFirst:s,isTurnStart:o,isOnlyEntry:r=!1,isOpenTurnTail:a=!1,crabIndex:i=0,collapsible:c=!1,onToggle:d}){const m=wl(e),u=r&&o&&m,p=n&&!m,f=c&&d!==void 0,h=l.useMemo(()=>jl(i),[i]),g=l.useMemo(()=>R5(i),[i]),b=w=>{!f||d===void 0||(w.stopPropagation(),d())},y=w=>{!f||d===void 0||w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),d())};return t.jsxs("div",{className:"flex flex-col items-center w-6 shrink-0 pt-0.5 pb-0.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]",children:!s&&t.jsx("div",{className:"w-px bg-muted-foreground/18 h-full"})}),u?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Single-request turn",className:xa(f),onClick:b,onKeyDown:y,children:t.jsx(g,{className:O("size-3.5 text-[#80FF00]","animate-crab-settle","drop-shadow-[0_0_4px_rgba(128,255,0,0.5)]")})}):m?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:KS(e),className:xa(f),onClick:b,onKeyDown:y,children:t.jsx(h,{className:O("size-3.5 text-amber-400","animate-crab-settle","drop-shadow-[0_0_4px_rgba(251,191,36,0.5)]")})}):o?t.jsx("span",{role:f?"button":void 0,tabIndex:f?0:void 0,title:"Start of turn",className:xa(f),onClick:b,onKeyDown:y,children:t.jsx(h,{className:O("size-3.5 text-emerald-400","animate-crab-appear","drop-shadow-[0_0_4px_rgba(52,211,153,0.5)]")})}):a?t.jsx("span",{title:n?"Current end of open turn (processing)":"Current end of open turn",children:t.jsx(h,{className:O("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?t.jsx("span",{title:"Processing",children:t.jsx(h,{className:O("size-3.5 text-amber-300/80","animate-crab-crawl")})}):t.jsx("span",{title:"Request in turn",children:t.jsx(h,{className:"size-3.5 text-muted-foreground/40"})}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:!m&&!a&&t.jsx("div",{className:O("w-0.5 h-full",n?"border-dashed bg-transparent border-l border-muted-foreground/14":"bg-muted-foreground/18")})})]})}const Mc=180,ga=new WeakMap;function JS(e,n){const s=e.responseText;if(s===null)return!1;switch(n){case"anthropic":return s.includes("tool_use");case"openai":return s.includes("tool_calls")||s.includes("function_call");case"unknown":return!1}}function YS(e){return e>1}function ui(e){const n=[];let s=[],o=0;for(let r=0;r<e.length;r+=1){const a=e[r];if(a===void 0)continue;s.push({log:a,stopReason:Xp(a),sessionLogNumber:r+1});const i=s[s.length-1];i!==void 0&&wl(i.stopReason)&&(n.push({entries:s,turnIndex:o}),s=[],o+=1)}return s.length>0&&n.push({entries:s,turnIndex:o}),n}function XS(e){const n=new Map;for(const s of e)for(let o=1;o<s.logs.length;o+=1){const r=s.logs[o],a=s.logs[o-1];if(r===void 0||a===void 0)continue;const i=Ds(r),c=Ds(a);i==="unknown"||i!==c||n.set(r.id,a)}return n}function df(e){if(e===null)return null;try{const n=JSON.parse(e);return typeof n=="string"?JSON.parse(n):n}catch{return null}}function Lo(e){if(e==null)return null;const n=typeof e=="string"?e:JSON.stringify(e);if(n===void 0)return null;const s=n.replace(/\s+/g," ").trim();return s.length===0?null:s.length>Mc?`${s.slice(0,Mc-1)}...`:s}function Oo(e){if(e==null)return null;if(typeof e=="string")return e.length>0?e:null;const n=JSON.stringify(e,null,2);return n===void 0||n.length===0?null:n}function ZS(e){const n=df(e.responseText),s=Z(n,"content");if(!Array.isArray(s))return[];const o=[];for(const r of s){if(Z(r,"type")!=="tool_use")continue;const i=Z(r,"name");if(typeof i!="string"||i.length===0)continue;const c=Z(r,"input");o.push({id:`${String(e.id)}-anthropic-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"anthropic",name:i,argumentsText:Oo(c),argumentsPreview:Lo(c)})}return o}function QS(e){const n=df(e.responseText),s=Z(n,"choices");if(!Array.isArray(s))return[];const o=[];for(const a of s){const i=Z(a,"message"),c=Z(i,"tool_calls");if(Array.isArray(c))for(const u of c){const p=Z(u,"function"),f=Z(p,"name");if(typeof f!="string"||f.length===0)continue;const h=Z(p,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:f,argumentsText:Oo(h),argumentsPreview:Lo(h)})}const d=Z(i,"function_call"),m=Z(d,"name");if(typeof m=="string"&&m.length>0){const u=Z(d,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:m,argumentsText:Oo(u),argumentsPreview:Lo(u)})}}const r=Z(n,"output");if(Array.isArray(r))for(const a of r){if(Z(a,"type")!=="function_call")continue;const i=Z(a,"name");if(typeof i!="string"||i.length===0)continue;const c=Z(a,"arguments");o.push({id:`${String(e.id)}-openai-tool-${String(o.length)}`,logId:e.id,index:o.length,provider:"openai",name:i,argumentsText:Oo(c),argumentsPreview:Lo(c)})}return o}function Sl(e){const n=ga.get(e);if(n!==void 0&&n.apiFormat===e.apiFormat&&n.responseText===e.responseText)return n.events;const s=Ds(e);if(!JS(e,s)){const r=[];return ga.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:r}),r}let o;switch(s){case"anthropic":o=ZS(e);break;case"openai":o=QS(e);break;case"unknown":o=[];break}return ga.set(e,{apiFormat:e.apiFormat,responseText:e.responseText,events:o}),o}function eN(e,n,s=0){let o=0,r=0,a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=0;for(const h of e)h.responseStatus===null?r+=1:h.responseStatus>=400&&(o+=1),h.elapsedMs!==null&&n>0&&h.elapsedMs>n*1e3&&(a+=1),h.inputTokens!==null&&(i+=h.inputTokens),h.outputTokens!==null&&(c+=h.outputTokens),h.cacheCreationInputTokens!==null&&(d+=h.cacheCreationInputTokens),h.cacheReadInputTokens!==null&&(m+=h.cacheReadInputTokens),h.elapsedMs!==null&&(u+=h.elapsedMs,p=p===null?h.elapsedMs:Math.max(p,h.elapsedMs)),f+=Sl(h).length;return{llmCallCount:e.length,toolCallCount:f,failedCallCount:o,pendingCallCount:r,slowCallCount:a,totalInputTokens:i,totalOutputTokens:c,totalCacheCreationInputTokens:d,totalCacheReadInputTokens:m,totalElapsedMs:u,maxElapsedMs:p,startedAt:e[0]?.timestamp??null,endedAt:e[e.length-1]?.timestamp??null,knowledgeCandidateCount:s}}function ba(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}const tN=l.memo(function({entries:n,viewMode:s,strip:o,slowResponseThresholdSeconds:r,cacheTrends:a,onCompareWithPrevious:i,comparisonPredecessors:c,turnIndex:d=0,timeDisplayFormat:m,pendingFocusRequest:u,showLogClientMetadata:p=!0}){const f=n.length-1,h=n[f]?.stopReason??null,g=h!==null?wl(h):!1,b=n[f]?.log.responseStatus===null,y=n.length===1,w=YS(n.length),[v,j]=l.useState(!1),S=l.useRef(!1);l.useEffect(()=>{w?g&&!S.current&&j(!0):j(!1),S.current=g},[w,g]),l.useEffect(()=>{const F=H=>{const Y=$r(H);Y!==null&&n.some(U=>U.log.id===Y.logId)&&w&&j(!1)};return window.addEventListener(Gt,F),()=>{window.removeEventListener(Gt,F)}},[w,n]),l.useEffect(()=>{if(u===void 0||!n.some(H=>H.log.id===u.logId))return;w&&j(!1);const F=window.setTimeout(()=>{ds({logId:u.logId,tab:u.tab,source:"virtualizer"})},0);return()=>window.clearTimeout(F)},[w,n,u]);const N=l.useCallback(()=>{w&&j(F=>!F)},[w]),C=l.useMemo(()=>{let F=0,H=0,Y=null,U=!1;for(const W of n)W.log.inputTokens!==null&&(F+=W.log.inputTokens,U=!0),W.log.outputTokens!==null&&(H+=W.log.outputTokens,U=!0),W.log.elapsedMs!==null&&(Y=Y===null?W.log.elapsedMs:Math.max(Y,W.log.elapsedMs));return{totalInput:F,totalOutput:H,hasTokens:U,maxElapsed:Y}},[n,f]),R=d%2===0?"bg-white/[0.008]":"bg-cyan-300/[0.008]",I=C.maxElapsed!==null&&r>0&&C.maxElapsed>r*1e3,P=l.useMemo(()=>{const F=new Map;for(const H of n){const Y=Sl(H.log);Y.length>0&&F.set(H.log.id,Y)}return F},[n]),[M,k]=l.useState(0),A=l.useRef(null);l.useEffect(()=>{const F=A.current;if(!F)return;let H=0;const Y=new ResizeObserver(()=>{window.cancelAnimationFrame(H),H=window.requestAnimationFrame(()=>k(U=>U+1))});return Y.observe(F),()=>{Y.disconnect(),window.cancelAnimationFrame(H)}},[]);const D=n[0]?.log.id??d,$=`Turn ${String(d+1)}`,J=l.useMemo(()=>jl(D%12),[D]),X=l.useMemo(()=>({contentVisibility:"auto",containIntrinsicSize:v?"48px":"160px"}),[v]);return t.jsx("div",{ref:A,style:X,tabIndex:v?void 0:0,role:v?void 0:"group","aria-label":v?void 0:$,"data-nav-id":v?void 0:`turn-${String(D)}`,className:O("rounded-[8px] transition-[background-color,box-shadow]",b?"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?t.jsxs("div",{"data-nav-id":`turn-collapsed-${String(D)}`,"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:N,onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),N())},children:[t.jsxs("div",{className:"w-6 shrink-0 flex flex-col items-center pt-1.5 pb-1.5",children:[t.jsx("div",{className:"flex justify-center h-[calc(0.75rem-8px)]"}),t.jsx(J,{className:O("size-3.5",b?"animate-crab-crawl text-amber-300/80":"animate-crab-appear text-emerald-400",b?"drop-shadow-[0_0_4px_rgba(252,211,77,0.42)]":"drop-shadow-[0_0_4px_rgba(52,211,153,0.45)]")}),t.jsx("div",{className:"flex-1 flex justify-center min-h-0",children:t.jsx("div",{className:"w-px bg-muted-foreground/14 h-full"})}),g?t.jsx(J,{className:O("size-3.5 animate-crab-settle text-amber-400","drop-shadow-[0_0_4px_rgba(251,191,36,0.45)]")}):t.jsx("span",{title:"Current end of open turn","aria-label":"Current end of open turn",children:t.jsx(J,{className:O("size-3.5 text-cyan-300/85",b?"animate-crab-crawl":"animate-crab-appear","drop-shadow-[0_0_4px_rgba(103,232,249,0.4)]")})})]}),n.length>1&&t.jsxs("div",{className:O("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",R),children:[t.jsx("span",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-muted-foreground/70",children:$}),t.jsxs("span",{className:"text-blue-300/85 font-mono font-semibold tabular-nums shrink-0",title:`Log IDs ${String(n[0]?.log.id??"?")} ~ ${String(n[f]?.log.id??"?")}`,children:["#",n[0]?.sessionLogNumber??"?"," ~ #",n[f]?.sessionLogNumber??"?"]}),t.jsxs("span",{className:"text-muted-foreground shrink-0",children:[n.length," request",n.length>1?"s":""]}),C.maxElapsed!==null&&t.jsx(hs,{children:t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs("span",{className:O("flex items-center gap-1 shrink-0",I?"text-amber-400":"text-muted-foreground"),children:[t.jsx(Wt,{className:"size-3"}),t.jsx("span",{className:"font-mono tabular-nums",children:ba(C.maxElapsed)}),I&&t.jsx(rn,{className:"size-3","aria-label":"Slow response"})]})}),t.jsx(nt,{children:I?`Slow response: ${ba(C.maxElapsed)} exceeds ${ba(r*1e3)}`:"Slowest request in this turn"})]})}),C.hasTokens&&t.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Ps,{className:"size-3 text-muted-foreground"}),t.jsxs("span",{className:"font-mono tabular-nums",children:[t.jsxs("span",{className:"text-blue-400",children:["IN ",Ee(C.totalInput)]})," / ",t.jsxs("span",{className:"text-amber-400",children:["OUT ",Ee(C.totalOutput)]})]})]}),t.jsx("span",{className:"flex-1 min-w-0"}),t.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:t.jsx(it,{className:"size-4 shrink-0"})})]})]}):n.map((F,H)=>{const{log:Y,stopReason:U}=F,W=H===0;return t.jsxs("div",{className:"flex items-stretch",children:[t.jsx(GS,{stopReason:U,isPending:Y.responseStatus===null,isFirst:H===0,isTurnStart:W,isOnlyEntry:y,isOpenTurnTail:H===f&&!g,crabIndex:Y.id%12,collapsible:w&&W,onToggle:N}),t.jsx("div",{className:O("flex-1 min-w-0 mb-0.5 rounded-[8px]",R),children:t.jsx(VS,{log:Y,displayNumber:F.sessionLogNumber,viewMode:s,strip:o,slowResponseThresholdSeconds:r,timeDisplayFormat:m,cacheTrend:a?.get(Y.id)??null,showClientMetadata:p,toolEvents:P.get(Y.id),onCompareWithPrevious:c.has(Y.id)?i:void 0})})]},Y.id)})})}),nN=24,sN=132,oN=8;function rN(e){return e>nN}function aN(e){const n=new Map;for(let s=0;s<e.length;s++){const o=e[s];if(o!==void 0)for(const r of o.entries)n.set(r.log.id,s)}return n}function uf(e,n,s){return t.jsx(tN,{entries:e.entries,viewMode:n.viewMode,strip:n.strip,slowResponseThresholdSeconds:n.slowResponseThresholdSeconds,timeDisplayFormat:n.timeDisplayFormat,cacheTrends:n.cacheTrends,onCompareWithPrevious:n.onCompareWithPrevious,comparisonPredecessors:n.comparisonPredecessors,turnIndex:e.turnIndex,pendingFocusRequest:s,showLogClientMetadata:n.showLogClientMetadata},e.turnIndex)}function iN(e){return rN(e.turnGroups.length)?t.jsx(lN,{...e}):t.jsx(t.Fragment,{children:e.turnGroups.map(n=>uf(n,e))})}function lN(e){const{turnGroups:n}=e,[s,o]=l.useState(null),r=f5({count:n.length,estimateSize:()=>sN,overscan:oN,getItemKey:i=>n[i]?.turnIndex??i}),a=l.useMemo(()=>aN(n),[n]);return l.useEffect(()=>{const i=c=>{const d=$r(c);if(d===null||d.source==="virtualizer")return;const m=a.get(d.logId);m!==void 0&&(r.scrollToIndex(m,{align:"center"}),o(u=>({...d,turnIndex:m,nonce:u===null?1:u.nonce+1})))};return window.addEventListener(Gt,i),()=>{window.removeEventListener(Gt,i)}},[a,r]),t.jsx("div",{className:"relative w-full",style:{height:`${r.getTotalSize()}px`},"data-virtualized-turn-list":"true",children:r.getVirtualItems().map(i=>{const c=n[i.index];if(c===void 0)return null;const d=s!==null&&s.turnIndex===i.index?s:void 0;return t.jsx("div",{"data-index":i.index,ref:r.measureElement,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${i.start}px)`},children:uf(c,e,d)},i.key)})})}const Nl=ue(["episode","procedure","preference","project-fact"]),cN=ue(["draft","promoted","failed"]),mf=T({source:re("agent-inspector"),sessionId:x(),logIds:K(At),project:x().nullable(),models:K(x())}),dN=T({redacted:_e(),patterns:K(x())}),eo=T({id:x(),type:Nl,title:x(),content:x(),tags:K(x()),source:re("agent-inspector"),sessionId:x(),logIds:K(At),evidence:mf,status:cN,createdAt:x(),updatedAt:x(),openClawMemoryId:x().nullable(),error:x().nullable(),redaction:dN});T({idempotencyKey:x(),type:Nl,title:x(),content:x(),tags:K(x()),source:re("agent-inspector"),project:x().nullable(),evidence:mf});const uN=T({id:x(),type:Nl.or(x()),title:x(),content:x(),score:E().nullable(),source:x().nullable(),project:x().nullable(),evidence:Ts().optional()});T({results:K(uN),warning:x().nullable()});const mN=T({candidates:K(eo)}),pN=T({candidate:eo}),fN=T({error:x().optional(),candidate:eo.optional()}),hN=T({candidate:eo}),xN=3e4,gN=15e3,bN=15e3,vN={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 mi(e){return e===null?"-":e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function yN(e,n,s){return e===null||n===null?null:xr(e,n,s)}function wN(e){return`${String(e)} candidate${e===1?"":"s"}`}function pf(e){return`log-${String(e)}`}function ff(e){const n=pf(e),s=document.getElementById(n);window.history.replaceState(null,"",`#${n}`),s instanceof HTMLElement&&(s.scrollIntoView({block:"center",behavior:"smooth"}),s.focus({preventScroll:!0}))}function jN(e){for(const n of e)if(n.responseStatus!==null&&n.responseStatus>=400)return n;return null}function SN(e){let n=null,s=-1;for(const o of e)o.elapsedMs!==null&&o.elapsedMs>s&&(n=o,s=o.elapsedMs);return n}function NN(e){for(const n of e)if(Sl(n).length>0)return n;return null}function CN(e){const n=new Map;for(let s=0;s<e.length;s+=1){const o=e[s];o!==void 0&&n.set(o.id,s+1)}return n}function ts(e,n){return String(n.get(e)??e)}function kN(e){const n=[{kind:"session",title:`${String(e.summary.llmCallCount)} LLM call${e.summary.llmCallCount===1?"":"s"}`,detail:`Scope ${e.scopeId}`,logId:e.logs[0]?.id??null}],s=NN(e.logs);e.summary.toolCallCount>0&&s!==null&&n.push({kind:"tool",title:`${String(e.summary.toolCallCount)} tool call${e.summary.toolCallCount===1?"":"s"}`,detail:`First tool evidence at #${ts(s.id,e.displayNumberByLogId)}`,logId:s.id});const o=jN(e.logs);o!==null&&n.push({kind:"failure",title:`Failure #${String(o.responseStatus)}`,detail:`First failed request is #${ts(o.id,e.displayNumberByLogId)}`,logId:o.id});const r=SN(e.logs);if(r!==null&&e.summary.maxElapsedMs!==null&&n.push({kind:"slow",title:`Slowest ${mi(e.summary.maxElapsedMs)}`,detail:`Max latency observed at #${ts(r.id,e.displayNumberByLogId)}`,logId:r.id}),e.candidates.length>0){const a=e.candidates.filter(c=>c.status==="draft").length,i=e.candidates.filter(c=>c.status==="promoted").length;n.push({kind:"candidate",title:`${String(e.candidates.length)} memory candidate${e.candidates.length===1?"":"s"}`,detail:`${String(a)} draft / ${String(i)} promoted`,logId:e.candidates[0]?.logIds[0]??null})}return n}function _N(e){switch(e){case"session":return t.jsx(hr,{className:"size-3.5 text-blue-400"});case"tool":return t.jsx(Ks,{className:"size-3.5 text-sky-400/70"});case"slow":return t.jsx(Wt,{className:"size-3.5 text-amber-400"});case"failure":return t.jsx(su,{className:"size-3.5 text-destructive"});case"candidate":return t.jsx(nu,{className:"size-3.5 text-emerald-400"})}}function TN({insights:e}){return e.length===0?null:t.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(n=>t.jsxs("button",{type:"button",className:O("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:()=>{n.logId!==null&&ff(n.logId)},disabled:n.logId===null,children:[_N(n.kind),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate font-medium text-foreground/90",children:n.title}),t.jsx("span",{className:"block truncate font-mono text-[10px]",children:n.detail})]})]},`${n.kind}-${n.title}`))})}function EN(e){switch(e){case"draft":return"Draft";case"promoted":return"Promoted";case"failed":return"Failed"}}function RN(e,n){if(n)return"Promoting";switch(e.status){case"draft":return"Promote";case"failed":return"Retry";case"promoted":return"Promoted"}}function MN(e){return e.redaction.redacted?`Redacted ${e.redaction.patterns.join(", ")}`:"No sensitive pattern matched"}function AN(e,n){const s=e.replace(/\s+/g," ").trim();return s.length<=n?s:`${s.slice(0,n-3)}...`}function IN(e,n){const s=e[0],o=e[e.length-1];if(s===void 0)return"No evidence logs";const r=ts(s,n);return o===void 0||s===o?`#${r}`:`#${r}-#${ts(o,n)}`}function Ac(e){return e.join(", ")}function PN(e){return e.split(",").map(n=>n.trim()).filter(n=>n.length>0)}function LN({candidate:e,isPromoting:n,isUpdating:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){const[i,c]=l.useState(!1),[d,m]=l.useState(e.type),[u,p]=l.useState(e.title),[f,h]=l.useState(e.content),[g,b]=l.useState(Ac(e.tags)),[y,w]=l.useState(null),v=e.status!=="promoted",j=e.status!=="promoted",S=l.useCallback(()=>{m(e.type),p(e.title),h(e.content),b(Ac(e.tags)),w(null)},[e.content,e.tags,e.title,e.type]),N=l.useCallback(async()=>{const C=u.trim(),R=f.trim(),I=PN(g);if(C.length===0){w("Title is required.");return}if(R.length===0){w("Content is required.");return}if(I.length===0){w("At least one tag is required.");return}w(null),await r(e.id,{type:d,title:C,content:R,tags:I})&&c(!1)},[e.id,f,g,u,d,r]);return i?t.jsx("div",{className:"border border-border bg-card shadow-sm rounded-[8px] px-2.5 py-2",children:t.jsxs("div",{className:"grid gap-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("select",{value:d,disabled:s,onChange:C=>{const R=eo.shape.type.safeParse(C.currentTarget.value);R.success&&m(R.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:[t.jsx("option",{value:"episode",children:"episode"}),t.jsx("option",{value:"procedure",children:"procedure"}),t.jsx("option",{value:"preference",children:"preference"}),t.jsx("option",{value:"project-fact",children:"project-fact"})]}),t.jsx("input",{value:u,disabled:s,onChange:C=>p(C.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"})]}),t.jsx("textarea",{value:f,disabled:s,onChange:C=>h(C.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"}),t.jsx("input",{value:g,disabled:s,onChange:C=>b(C.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"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground",children:[t.jsx(Hl,{className:"size-3"}),"Saving reruns Inspector redaction before promotion."]}),t.jsx("span",{className:"flex-1"}),y!==null&&t.jsx("span",{className:"text-[10px] text-destructive",children:y}),t.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{S(),c(!1)},children:[t.jsx(Gs,{className:"size-3.5"}),"Cancel"]}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",disabled:s,onClick:()=>{N()},children:[s?t.jsx(yt,{className:"size-3.5 animate-spin"}):t.jsx(Kg,{className:"size-3.5"}),"Save"]})]})]})}):t.jsxs("div",{className:"rounded-md border border-border/80 bg-background/60 px-2.5 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(ke,{variant:"outline",className:"h-5 px-1.5 text-[10px] font-mono",children:e.type}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-medium",title:e.title,children:e.title}),t.jsx(ke,{variant:"outline",className:O("h-5 shrink-0 px-1.5 text-[10px] font-mono",vN[e.status]),children:EN(e.status)})]}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-muted-foreground",title:e.content,children:AN(e.content,360)}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-muted-foreground",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(G0,{className:"size-3"}),IN(e.logIds,a)]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Hl,{className:"size-3"}),MN(e)]}),e.status==="promoted"&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-emerald-500",children:[t.jsx(Fa,{className:"size-3"}),e.openClawMemoryId??"OpenClaw"]}),e.status==="failed"&&e.error!==null&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-destructive",children:[t.jsx(su,{className:"size-3"}),e.error]})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5",children:[e.logIds.map(C=>{const R=ts(C,a);return t.jsxs("a",{href:`#${pf(C)}`,onClick:I=>{I.preventDefault(),ff(C)},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 ${R}`,title:`Log ID ${String(C)}`,children:["#",R]},C)}),t.jsx("span",{className:"flex-1"}),j&&t.jsxs(ee,{type:"button",variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",disabled:s||n,onClick:()=>c(!0),children:[t.jsx(du,{className:"size-3"}),"Review"]}),t.jsxs(ee,{type:"button",variant:v?"outline":"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[10px]",onClick:()=>o(e.id),disabled:!v||n||s,children:[n?t.jsx(yt,{className:"size-3 animate-spin"}):v?t.jsx(E0,{className:"size-3"}):t.jsx(Fa,{className:"size-3"}),RN(e,n)]})]})]})}function ON({candidates:e,promotingCandidateIds:n,updatingCandidateIds:s,onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a}){return e.length===0?null:t.jsx("div",{className:"mt-2 grid gap-1.5",children:e.map(i=>t.jsx(LN,{candidate:i,isPromoting:n.has(i.id),isUpdating:s.has(i.id),onPromoteCandidate:o,onUpdateCandidate:r,displayNumberByLogId:a},i.id))})}function DN({logs:e,scopeId:n,slowResponseThresholdSeconds:s,showRollupMetrics:o,timeDisplayFormat:r}){const[a,i]=l.useState([]),[c,d]=l.useState(!0),[m,u]=l.useState({status:"idle",error:null}),[p,f]=l.useState(()=>new Set),[h,g]=l.useState(()=>new Set),b=a.length>0,y=l.useMemo(()=>eN(e,s,a.length),[a.length,e,s]),w=l.useMemo(()=>CN(e),[e]),v=l.useMemo(()=>kN({logs:e,scopeId:n,summary:y,candidates:a,displayNumberByLogId:w}),[a,w,e,n,y]),j=o||y.maxElapsedMs!==null,S=l.useMemo(()=>yN(y.startedAt,y.endedAt,r),[y.endedAt,y.startedAt,r]),N=l.useCallback(()=>{e.length===0||m.status==="loading"||(u({status:"loading",error:null}),(async()=>{try{const I=await De(`/api/knowledge/sessions/${encodeURIComponent(n)}/candidates`,mN,xN,{method:"POST"},P=>`Candidate generation failed with ${String(P.status)}`);i(I.candidates),d(I.candidates.length>0),u(I.candidates.length>0?{status:"ready",error:null}:{status:"failed",error:"No candidate was generated for this trace scope."})}catch(I){u({status:"failed",error:I instanceof Error?I.message:"Candidate response was invalid"})}})())},[m.status,e.length,n]),C=l.useCallback(I=>{f(P=>{if(P.has(I))return P;const M=new Set(P);return M.add(I),M}),(async()=>{try{const P=await Xn(`/api/knowledge/candidates/${encodeURIComponent(I)}/promote`,gN,{method:"POST"}),M=await P.json().catch(()=>null),k=pN.safeParse(M);if(P.ok&&k.success){i(D=>D.map($=>$.id===k.data.candidate.id?k.data.candidate:$)),u({status:"ready",error:null});return}const A=fN.safeParse(M);A.success&&A.data.candidate!==void 0&&i(D=>D.map($=>$.id===A.data.candidate?.id?A.data.candidate:$)),u({status:"failed",error:A.success?A.data.error??"Candidate promotion failed":`Candidate promotion failed with ${String(P.status)}`})}catch(P){u({status:"failed",error:P instanceof Error?P.message:"Candidate promotion failed"})}finally{f(P=>{const M=new Set(P);return M.delete(I),M})}})()},[]),R=l.useCallback(async(I,P)=>{g(M=>{if(M.has(I))return M;const k=new Set(M);return k.add(I),k});try{const M=await De(`/api/knowledge/candidates/${encodeURIComponent(I)}`,hN,bN,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)},k=>`Candidate update failed with ${String(k.status)}`);return i(k=>k.map(A=>A.id===M.candidate.id?M.candidate:A)),u({status:"ready",error:null}),!0}catch(M){return u({status:"failed",error:M instanceof Error?M.message:"Candidate update failed"}),!1}finally{g(M=>{const k=new Set(M);return k.delete(I),k})}},[]);return e.length===0?null:t.jsxs("section",{className:"border border-border bg-card shadow-sm mb-2 rounded-[8px] px-3 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 text-xs",children:[o&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 font-semibold text-foreground",children:[t.jsx(hr,{className:"size-3.5 text-blue-400"}),y.llmCallCount," LLM"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Ks,{className:"size-3.5 text-sky-400/70"}),y.toolCallCount," tools"]}),o&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Ps,{className:"size-3.5 text-emerald-400"}),t.jsxs("span",{className:"font-mono",children:[Ee(y.totalInputTokens)," / ",Ee(y.totalOutputTokens)]})]}),(y.totalCacheCreationInputTokens>0||y.totalCacheReadInputTokens>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Ps,{className:"size-3.5 text-purple-400"}),t.jsxs("span",{className:"font-mono",children:["KV Cache +",Ee(y.totalCacheCreationInputTokens)," / ~",Ee(y.totalCacheReadInputTokens)]})]}),j&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[t.jsx(Wt,{className:"size-3.5"}),o&&t.jsx("span",{className:"font-mono",children:mi(y.totalElapsedMs)}),y.maxElapsedMs!==null&&t.jsxs("span",{className:"font-mono text-muted-foreground/70",children:["max ",mi(y.maxElapsedMs)]})]}),o&&S!==null&&t.jsx("span",{className:"font-mono text-muted-foreground/70",children:S}),(y.failedCallCount>0||y.pendingCallCount>0||y.slowCallCount>0)&&t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-amber-400",children:[t.jsx(rn,{className:"size-3.5"}),t.jsxs("span",{className:"font-mono",children:[y.failedCallCount," fail / ",y.pendingCallCount," pending /"," ",y.slowCallCount," slow"]})]}),t.jsx("span",{className:"flex-1"}),b&&t.jsx(ke,{variant:"outline",className:"h-6 px-2 text-[10px] font-mono",children:wN(y.knowledgeCandidateCount)}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:N,disabled:m.status==="loading",children:[m.status==="loading"?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(nu,{className:"size-3.5"}),"Candidate"]}),b&&t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onClick:()=>d(I=>!I),"aria-expanded":c,"aria-label":c?"Collapse memory candidates":"Expand memory candidates",children:c?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"})})]}),m.status==="failed"&&t.jsx("p",{className:"mt-2 text-xs text-destructive",children:m.error}),t.jsx(TN,{insights:v}),c&&t.jsx(ON,{candidates:a,promotingCandidateIds:p,updatingCandidateIds:h,onPromoteCandidate:C,onUpdateCandidate:R,displayNumberByLogId:w})]})}function zN(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&(n+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalInputTokens:n,totalOutputTokens:s}}function $N(e){const n=new Map;for(const s of e){if(s.model===null)continue;const o=mj(s.model);if(o==="unknown")continue;let r=n.get(o);r===void 0&&(r=new Set,n.set(o,r)),r.add(s.model)}return[...n.entries()].map(([s,o])=>({provider:s,models:[...o]}))}function FN(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function UN(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}const BN=l.memo(function({group:e,viewMode:n="simple",strip:s,slowResponseThresholdSeconds:o,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,onClearGroup:c,showClientIdentity:d=!0,showProcessMetadata:m=!0,showLogClientMetadata:u=!0,defaultExpanded:p=!1,timeDisplayFormat:f,expanded:h,onExpandedChange:g}){const[b,y]=l.useState(p),w=h??b,v=l.useCallback(k=>{if(g!==void 0){g(k);return}y(k)},[g]);l.useEffect(()=>{!p||h!==void 0||y(!0)},[h,p]);const j=l.useMemo(()=>zN(e.logs),[e.logs]),S=l.useMemo(()=>$N(e.logs),[e.logs]),N=e.logs[0]?.timestamp??new Date().toISOString(),C=e.logs[e.logs.length-1]?.timestamp??new Date().toISOString(),R=e.logs.some(k=>k.responseStatus===null),I=l.useMemo(()=>FN(e.logs),[e.logs]),P=l.useMemo(()=>UN(e.logs),[e.logs]),M=l.useMemo(()=>ui(e.logs),[e.logs]);return l.useEffect(()=>{const k=A=>{const D=$r(A);D!==null&&e.logs.some($=>$.id===D.logId)&&v(!0)};return window.addEventListener(Gt,k),()=>{window.removeEventListener(Gt,k)}},[e.logs,v]),t.jsxs("div",{className:"mb-1.5",children:[t.jsx(Gj,{conversationId:e.conversationId,startTime:N,endTime:C,totalCalls:e.logs.length,totalInputTokens:j.totalInputTokens,totalOutputTokens:j.totalOutputTokens,expanded:w,onToggle:()=>v(!w),providers:S,isLoading:R,userAgent:e.logs[0]?.userAgent??null,clientPid:I,clientProjectFolder:P,showClientIdentity:d,showProcessMetadata:m,timeDisplayFormat:f,onClear:()=>c(e.logs.map(k=>k.id))}),w&&t.jsxs("div",{children:[t.jsx(DN,{logs:e.logs,scopeId:e.conversationId,slowResponseThresholdSeconds:o,showRollupMetrics:!1,timeDisplayFormat:f}),t.jsx(iN,{turnGroups:M,viewMode:n,strip:s,slowResponseThresholdSeconds:o,timeDisplayFormat:f,cacheTrends:r,onCompareWithPrevious:a,comparisonPredecessors:i,showLogClientMetadata:u})]})]})}),qN="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",HN="m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";function WN(e){return e==="full"}function VN(e){return e==="raw"}function KN(e,n){const s=n>0;return{redacted:s,raw:s&&WN(e)}}function GN(e,n){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:xr(s.timestamp,o.timestamp,n)}function JN(e){return e.error!==null&&e.error!==void 0&&e.error.length>0?!0:e.responseStatus!==null&&e.responseStatus>=400}function YN(e){const n=new Set;for(const o of e)o.model!==null&&o.model.length>0&&n.add(o.model);const s=[...n].sort();return s.length===0?"Model unknown":s.length===1?s[0]??"Model unknown":`${s.length} models`}function XN(e){const n=new Set;for(const o of e)o.providerName!==null&&o.providerName!==void 0&&o.providerName.length>0&&n.add(o.providerName);const s=[...n].sort();return s.length===0?"Provider unknown":s.length===1?s[0]??"Provider unknown":`${s.length} providers`}function ZN(e){if(e<1e3)return`${e}ms`;if(e<6e4){const r=e/1e3;return`${r<10?r.toFixed(1):r.toFixed(0)}s`}const n=Math.round(e/1e3),s=Math.floor(n/60),o=n%60;return`${s}m ${o}s`}function QN(e,n){return`${Ee(e)} in / ${Ee(n)} out`}function eC(e,n){if(e.length===0)return 0;if(n.length===0)return ui(e).length;let s=0;for(const o of n)s+=ui(o.logs).length;return s}function tC({stopReason:e,pending:n,lastFailureLogNumber:s}){if(n>0)return{label:"In flight",detail:`${n} request${n===1?"":"s"} pending`,tone:"cool"};if(s!==null&&e===null)return{label:"Error",detail:`Last failed request #${s}`,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 nC(e){if(e===null)return!1;const n=e.toLowerCase();return n.includes("abort")||n.includes("cancel")||n.includes("client disconnected")||n.includes("stream disconnected")||n.includes("connection closed")}function sC({pending:e,failures:n,lengthStops:s,stopReason:o,lastFailure:r}){if(r!==null&&(r.status===499||nC(r.error)))return{label:"Client aborted",detail:`Request #${r.logNumber} ended before completion`,tone:"watch"};if(e>0)return{label:"In flight",detail:`${e} request${e===1?"":"s"} still running`,tone:"cool"};if(r!==null&&r.status!==null&&r.status>=500)return{label:"Provider error",detail:`Request #${r.logNumber} returned HTTP ${r.status}`,tone:"danger"};if(n>0&&r!==null)return{label:"Failed",detail:`Request #${r.logNumber} needs attention`,tone:"danger"};if(s>0||o==="length")return{label:"Output limited",detail:"Model stopped at the output token limit",tone:"watch"};switch(o){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 oC({logs:e,conversationGroups:n,isLoading:s,timeDisplayFormat:o,slowResponseThresholdSeconds:r}){let a=0,i=0,c=0,d=0,m=0,u=0,p=null,f=null,h=null,g=null,b=null,y=0,w=0,v=0,j=null;const S=r*1e3;for(let P=0;P<e.length;P+=1){const M=e[P];if(M===void 0)continue;const k=P+1,A=Xp(M);A!==null&&(p=A),A==="length"&&(d+=1),JN(M)&&(a+=1,f=k,h={logNumber:k,status:M.responseStatus,error:M.error??null}),M.responseStatus===null&&(i+=1),r>0&&M.elapsedMs!==null&&M.elapsedMs>=S&&(c+=1),M.inputTokens!==null&&(m+=M.inputTokens),M.outputTokens!==null&&(u+=M.outputTokens),M.elapsedMs!==null&&(g===null||M.elapsedMs>g)&&(g=M.elapsedMs,b=k);const D=M.inputTokens??0,$=M.outputTokens??0,J=D+$;J>y&&(y=J,w=D,v=$,j=k)}const N=s||i>0&&a===0?"rolling":a>0?"failed":c>0||d>0?"watch":"clear",C=N==="rolling"?"Rolling":N==="failed"?"Failure":N==="watch"?"Watch":"Clear",R=tC({stopReason:p,pending:i,lastFailureLogNumber:f}),I=sC({pending:i,failures:a,lengthStops:d,stopReason:p,lastFailure:h});return{status:N,statusLabel:C,modelLabel:YN(e),providerLabel:XN(e),requests:e.length,turns:eC(e,n),failures:a,pending:i,slow:c,lengthStops:d,timeRange:GN(e,o),tokenLabel:`${Ee(m)} in / ${Ee(u)} out`,finishLabel:R.label,finishDetail:R.detail,finishTone:R.tone,outcomeLabel:I.label,outcomeDetail:I.detail,outcomeTone:I.tone,slowestLabel:g===null?"n/a":ZN(g),slowestDetail:b===null?"Latency pending":`Request #${b}`,heaviestDetail:j===null?"Tokens pending":`#${j} ${QN(w,v)}`}}function rC({pinnedSessionId:e,selectedSession:n,sessions:s,logs:o}){if(e!==void 0){const i=o.filter(c=>c.sessionId===e);return i.length===0?null:{label:e,logs:i,showBackLink:!0}}if(n!=="__all__"){const i=o.filter(c=>c.sessionId===n);return i.length===0?null:{label:n,logs:i,showBackLink:!0}}const r=s.length===1?s[0]??null:null;return r!==null&&o.every(c=>c.sessionId===r)?{label:r,logs:[...o],showBackLink:!1}:s.length===0&&o.length>0&&o.every(i=>i.sessionId===null)?{label:"Visible requests",logs:[...o],showBackLink:!1}:null}function aC({logs:e,pagination:n}){if(n.isLoading&&e.length===0)return"Loading logs...";if(e.length===0)return"No logs on this page";const s=e[0],o=e[e.length-1],r=s===void 0||o===void 0?"Current page":`#${s.id}-#${o.id}`;return n.total===null?`Showing ${e.length} logs (${r})`:n.total<=e.length?`Showing all ${n.total} logs`:`Showing ${e.length} of ${n.total} logs (${r})`}function Fs({...e}){return t.jsx(Wm,{"data-slot":"select",...e})}function or({...e}){return t.jsx(Jm,{"data-slot":"select-value",...e})}function Us({className:e,size:n="default",children:s,...o}){return t.jsxs(Km,{"data-slot":"select-trigger","data-size":n,className:O("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),...o,children:[s,t.jsx(Ym,{asChild:!0,children:t.jsx(Ve,{className:"size-4 opacity-50"})})]})}function Bs({className:e,children:n,position:s="popper",align:o="center",...r}){return t.jsx(Zm,{children:t.jsxs(Qm,{"data-slot":"select-content",className:O("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",s==="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:s,align:o,...r,children:[t.jsx(iC,{}),t.jsx(op,{className:O("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:n}),t.jsx(lC,{})]})})}function Xe({className:e,children:n,...s}){return t.jsxs(lp,{"data-slot":"select-item",className:O("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),...s,children:[t.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:t.jsx(up,{children:t.jsx(Oe,{className:"size-4"})})}),t.jsx(cp,{children:n})]})}function iC({className:e,...n}){return t.jsx(mp,{"data-slot":"select-scroll-up-button",className:O("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(Di,{className:"size-4"})})}function lC({className:e,...n}){return t.jsx(pp,{"data-slot":"select-scroll-down-button",className:O("flex cursor-default items-center justify-center py-1",e),...n,children:t.jsx(Ve,{className:"size-4"})})}const cC=ue(["critical","warning","notice"]),dC=ue(["open"]),uC=ue(["proxy","tool-schema","run","group"]),hf=ue(["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"]),mC=ue(["log","session","run","group"]),pC=ue(["anthropic","openai","unknown"]),fC=T({kind:mC,id:x(),label:x(),href:x().nullable()}),hC=T({id:x(),fingerprint:x(),severity:cC,category:hf,source:uC,status:dC,title:x(),message:x(),count:E().int().positive(),firstSeenAt:x(),lastSeenAt:x(),logIds:K(At),sessionIds:K(x()),runIds:K(x()),groupIds:K(x()),provider:x().nullable(),model:x().nullable(),apiFormat:pC.nullable(),evidence:K(fC),metadata:ze(x(),We)}),xC=T({category:hf,count:E().int().nonnegative()}),xf=T({total:E().int().nonnegative(),open:E().int().nonnegative(),critical:E().int().nonnegative(),warning:E().int().nonnegative(),notice:E().int().nonnegative(),byCategory:K(xC)}),gC=T({alerts:K(hC),total:E().int().nonnegative(),limit:E().int().positive(),summary:xf}),bC=8e3,vC=1e4;function yC(e){const n=new URLSearchParams;e.severity!==void 0&&n.set("severity",e.severity),e.category!==void 0&&n.set("category",e.category),e.source!==void 0&&n.set("source",e.source),e.limit!==void 0&&n.set("limit",String(e.limit));const s=n.toString();return s.length>0?`/api/alerts?${s}`:"/api/alerts"}function wC(e,n){const s=Et(n?yC(e):null,o=>De(o,gC,vC));return{alerts:s.data?.alerts??[],total:s.data?.total??0,summary:s.data?.summary??null,isLoading:s.isLoading,error:s.error,mutate:s.mutate}}function jC(){const e=Et("/api/alerts/summary",n=>De(n,xf,bC),{refreshInterval:5e3,revalidateOnFocus:!0});return{summary:e.data??null,isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const to="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",SC=["request-failure","request-timeout","slow-response","tool-schema","run-failure","group-failure","group-incomplete"];function gf(e){switch(e){case"critical":return"Critical";case"warning":return"Warning";case"notice":return"Notice"}}function NC(e){switch(e){case"proxy":return"Proxy";case"tool-schema":return"Tool schema";case"run":return"Run";case"group":return"Group"}}function Cl(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 CC(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 kC(e){switch(e){case"critical":return"bg-status-danger";case"warning":return"bg-status-watch";case"notice":return"bg-status-cool"}}function _C(e){switch(e){case"critical":return"text-status-danger";case"warning":return"text-status-watch";case"notice":return"text-status-cool"}}function TC(e){switch(e){case"request-failure":case"run-failure":case"group-failure":return t.jsx(r1,{className:"size-3.5"});case"request-timeout":case"slow-response":return t.jsx(k0,{className:"size-3.5"});case"tool-schema":return t.jsx(rn,{className:"size-3.5"});case"group-incomplete":return t.jsx(Jx,{className:"size-3.5"})}}function pi(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function rt(e){return e.toLocaleString()}function bf(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 EC(e,n){const s={limit:100};return e!=="all"&&(s.severity=e),n!=="all"&&(s.category=n),s}function RC(e,n){if(n!==null){const s=e.find(o=>o.id===n);if(s!==void 0)return s}return e[0]??null}function bo({label:e,count:n,tone:s}){const o=s==="critical"?"border-status-danger/30 bg-status-danger/10 text-status-danger":s==="warning"?"border-status-watch/30 bg-status-watch/10 text-status-watch":s==="notice"?"border-status-cool/30 bg-status-cool/10 text-status-cool":"border-border bg-muted/40 text-foreground";return t.jsxs("div",{className:O("rounded-md border px-3 py-2",o),children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase opacity-75",children:e}),t.jsx("div",{className:"mt-1 text-lg font-semibold leading-none",children:rt(n)})]})}function vo({value:e,active:n,label:s,count:o,onClick:r}){return t.jsxs(ee,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>r(e),className:"h-7 px-2",children:[s,o!==null?t.jsx(ke,{variant:"outline",children:rt(o)}):null]})}function MC({category:e,active:n,count:s,onClick:o}){return t.jsxs(ee,{type:"button",variant:n?"secondary":"ghost",size:"sm","aria-pressed":n,onClick:()=>o(e),className:"h-7 px-2",children:[TC(e),Cl(e),t.jsx(ke,{variant:"outline",children:rt(s)})]})}function AC({alerts:e,selectedAlertId:n,isLoading:s,error:o,onSelect:r}){return s?t.jsxs("div",{className:"flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"mr-2 size-3.5 animate-spin"}),"Loading alerts..."]}):o!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?t.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."}):t.jsx("div",{className:"min-h-0 space-y-2 overflow-y-auto pr-1",children:e.map(a=>{const i=a.id===n;return t.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-3 text-left transition-colors",i?"border-primary/60 bg-primary/12":"border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60"),children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:O("size-2 rounded-full",kC(a.severity))}),t.jsx("span",{className:O("text-xs font-semibold",_C(a.severity)),children:gf(a.severity)}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:Cl(a.category)})]}),t.jsx("div",{className:"mt-1 text-sm font-semibold leading-snug",children:a.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:a.message})]}),a.count>1?t.jsxs(ke,{variant:"outline",className:"shrink-0",children:["x",rt(a.count)]}):null]}),t.jsxs("div",{className:"mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 leading-snug",children:bf(a)}),t.jsx("span",{className:"shrink-0",children:pi(a.lastSeenAt)})]})]},a.id)})})}function IC({alert:e,onNavigate:n}){return e.evidence.length===0?t.jsx("span",{className:"text-xs text-muted-foreground",children:"No linked evidence"}):t.jsx("div",{className:"flex flex-wrap gap-2",children:e.evidence.map(s=>s.href===null?t.jsx(ke,{variant:"outline",children:s.label},`${s.kind}:${s.id}`):t.jsx(ke,{variant:"outline",asChild:!0,children:t.jsx("a",{href:s.href,onClick:n,children:s.label})},`${s.kind}:${s.id}`))})}function PC({alert:e,onNavigate:n}){return e===null?t.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."}):t.jsxs("div",{className:"min-h-0 overflow-y-auto rounded-md border border-border bg-background/70",children:[t.jsx("div",{className:O("border-b px-4 py-3",CC(e.severity)),children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(ke,{variant:"outline",children:gf(e.severity)}),t.jsx(ke,{variant:"outline",children:NC(e.source)}),t.jsx(ke,{variant:"outline",children:Cl(e.category)})]}),t.jsx("h3",{className:"mt-3 text-base font-semibold",children:e.title}),t.jsx("p",{className:"mt-1 text-sm opacity-85",children:e.message})]}),e.count>1?t.jsxs(ke,{variant:"outline",className:"shrink-0",children:[rt(e.count)," hits"]}):null]})}),t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(Yt,{label:"Target",value:bf(e)}),t.jsx(Yt,{label:"Last seen",value:pi(e.lastSeenAt)}),t.jsx(Yt,{label:"First seen",value:pi(e.firstSeenAt)}),t.jsx(Yt,{label:"Protocol",value:e.apiFormat??"n/a"})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-2 text-xs font-semibold text-muted-foreground",children:"Evidence"}),t.jsx(IC,{alert:e,onNavigate:n})]}),t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsx(Yt,{label:"Logs",value:e.logIds.length===0?"n/a":rt(e.logIds.length)}),t.jsx(Yt,{label:"Sessions",value:e.sessionIds.length===0?"n/a":rt(e.sessionIds.length)}),t.jsx(Yt,{label:"Runs",value:e.runIds.length===0?"n/a":rt(e.runIds.length)}),t.jsx(Yt,{label:"Groups",value:e.groupIds.length===0?"n/a":rt(e.groupIds.length)})]})]})]})}function Yt({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-3 py-2",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-foreground",children:n})]})}function LC(){const[e,n]=l.useState(!1),[s,o]=l.useState("all"),[r,a]=l.useState("all"),[i,c]=l.useState(null),{summary:d,isLoading:m}=jC(),u=l.useMemo(()=>EC(s,r),[r,s]),{alerts:p,total:f,isLoading:h,error:g,mutate:b}=wC(u,e),y=l.useMemo(()=>RC(p,i),[p,i]);l.useEffect(()=>{!e||i!==null&&p.some(R=>R.id===i)||c(p[0]?.id??null)},[p,e,i]);const w=d?.total??0,v=d?.critical??0,j=d?.warning??0,S=d?.notice??0,N=v>0?"bg-status-danger text-primary-foreground":j>0?"bg-status-watch text-primary-foreground":"bg-status-cool text-primary-foreground";return t.jsxs(Pt,{open:e,onOpenChange:n,children:[t.jsx(Zs,{asChild:!0,children:t.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:to,"aria-label":"Alerts",title:"Alerts",children:[t.jsx(Wo,{className:"size-4"}),m?t.jsx(Ae,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):w>0?t.jsx("span",{className:O("absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",N),children:rt(w)}):null,t.jsx("span",{className:"sr-only",children:"Alerts"})]})}),t.jsxs(Lt,{className:"flex max-h-[86vh] max-w-6xl flex-col overflow-hidden",children:[t.jsxs(Ft,{children:[t.jsxs(Ut,{className:"flex items-center gap-2 pr-8",children:[t.jsx(Wo,{className:"size-5 text-status-danger"}),t.jsx("span",{children:"Alerts"}),t.jsx(ke,{variant:"outline",children:rt(w)})]}),t.jsx(Qs,{className:"sr-only",children:"Local alert board for captured Inspector evidence."})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(bo,{label:"Open",count:d?.open??0,tone:"neutral"}),t.jsx(bo,{label:"Critical",count:v,tone:"critical"}),t.jsx(bo,{label:"Warning",count:j,tone:"warning"}),t.jsx(bo,{label:"Notice",count:S,tone:"notice"})]}),t.jsxs("div",{className:"flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3",children:[t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(vo,{value:"all",active:s==="all",label:"All",count:d?.total??null,onClick:o}),t.jsx(vo,{value:"critical",active:s==="critical",label:"Critical",count:v,onClick:o}),t.jsx(vo,{value:"warning",active:s==="warning",label:"Warning",count:j,onClick:o}),t.jsx(vo,{value:"notice",active:s==="notice",label:"Notice",count:S,onClick:o})]}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"h-7 shrink-0 px-2",onClick:()=>{b()},children:[t.jsx(yt,{className:"size-3.5"}),"Refresh"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1",children:[t.jsx(ee,{type:"button",variant:r==="all"?"secondary":"ghost",size:"sm","aria-pressed":r==="all",onClick:()=>a("all"),className:"h-7 px-2",children:"All categories"}),SC.map(C=>{const R=d?.byCategory.find(I=>I.category===C)?.count??0;return R===0?null:t.jsx(MC,{category:C,active:r===C,count:R,onClick:a},C)})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]",children:[t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between text-xs text-muted-foreground",children:[t.jsxs("span",{children:[rt(f)," matched"]}),t.jsx("span",{children:p.length<f?`${rt(p.length)} shown`:"Latest"})]}),t.jsx(AC,{alerts:p,selectedAlertId:y?.id??null,isLoading:h,error:g,onSelect:c})]}),t.jsx(PC,{alert:y,onNavigate:()=>n(!1)})]})]})]})}const OC=12e3;function DC(e){return e===null||e.evidence===null?null:`/api/groups/${encodeURIComponent(e.id)}/evidence`}function zC(e){const n=Et(DC(e),s=>De(s,Sx,OC));return{evidenceResponse:n.data??null,isLoading:n.isLoading,error:n.error,mutate:n.mutate}}const $C=8e3;function FC(){const e=Et("/api/groups",n=>De(n,Qd,$C));return{groups:e.data?.groups??[],isLoading:e.isLoading,error:e.error,mutate:e.mutate}}const UC=3e3;function BC(e,n){return{id:(e?.id??0)+1,message:n.message,tone:n.tone??"error"}}function vf(){const[e,n]=l.useState(null),s=l.useCallback(r=>{n(a=>BC(a,r))},[]),o=l.useCallback(()=>{n(null)},[]);return l.useEffect(()=>{if(e===null)return;const r=window.setTimeout(()=>{n(null)},UC);return()=>{window.clearTimeout(r)}},[e]),{notice:e,showToast:s,dismissToast:o}}function yf({notice:e,onDismiss:n}){if(e===null)return null;const s=e.tone==="error",o=s?rn:Fa;return t.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:t.jsxs("div",{className:O("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",s?"border-status-danger/35":"border-status-success/35"),children:[t.jsx(o,{className:O("mt-0.5 size-4 shrink-0",s?"text-status-danger":"text-status-success")}),t.jsx("div",{className:"min-w-0 flex-1 break-words leading-5",children:e.message}),t.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:n,children:t.jsx(Gs,{className:"size-3.5"})})]},e.id)})}const va=2e4;function qC(e,n){const s=`/api/groups/${encodeURIComponent(e)}`;return n?`${s}?deleteEvidence=1`:s}function HC(e){return"/api/groups"}function wf(e){let n=0,s=0,o=0,r=0;for(const a of e.members)switch(a.status){case"completed":n+=1;break;case"failed":case"cancelled":s+=1;break;case"running":o+=1;break;case"created":break;case null:r+=1;break}return{memberCount:e.members.length,completedMembers:n,failedMembers:s,runningMembers:o,missingStatusMembers:r}}function WC(e,n,s=null){return n!==null&&n.group.id===e.id?n.members.map(o=>({member:o.member,exportMember:o,source:"export"})):s!==null&&s.group.id===e.id&&s.members!==null?s.members.map(o=>({member:o.member,exportMember:o,source:"evidence"})):e.members.map(o=>({member:o,exportMember:null,source:"group"}))}function kl(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 _l(e){return e??"unknown"}function VC(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 Fr(e){return e===null||e.trim().length===0?"-":e}function ot(e){return e.toLocaleString()}function fi(e){return e==null?"-":e<1e3?`${ot(e)} ms`:`${(e/1e3).toFixed(1)} s`}function us(e){const n=Date.parse(e);return Number.isFinite(n)?new Intl.DateTimeFormat(void 0,{month:"short",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(n)):e}function Ic(e){return e===null?"-":us(e)}function KC(e){const n=JSON.stringify(e),s=n===void 0?String(e):n;return s.length<=160?s:`${s.slice(0,157)}...`}function jf(...e){for(const n of e)if(n!==null&&n.trim().length>0)return n;return"-"}function GC(...e){for(const n of e)if(n!=null&&n.trim().length>0)return n;return null}function JC(e){const n=e.provider,s=e.model;return n!==null&&n.length>0&&s!==null&&s.length>0?`${n} / ${s}`:jf(n,s)}function YC(e,n){if(n!==null){const s=e.find(o=>o.id===n);if(s!==void 0)return s}return e[0]??null}function XC(e){return(e.exportMember?.session?.latestLogs??[])[0]??null}function ZC(e){switch(e){case"export":return"fresh export";case"evidence":return"evidence";case"group":return"group"}}function QC(e,n){return n!==null&&n.group.id===e.id?n.evidence:e.evidence}function ek(e,n,s){return n!==null&&n.group.id===e.id?n.summary:s!==null&&s.group.id===e.id?s.summary:null}function tk(e,n,s){return n!==null&&n.group.id===e.id?n.jenkinsReport:s!==null&&s.group.id===e.id?s.report:null}function nk({labelledTrigger:e=!1}){const[n,s]=l.useState(!1),[o,r]=l.useState(null),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(!1),[b,y]=l.useState(null),[w,v]=l.useState(null),[j,S]=l.useState(!1),{notice:N,showToast:C,dismissToast:R}=vf(),{groups:I,isLoading:P,error:M,mutate:k}=FC(),A=l.useMemo(()=>YC(I,o),[I,o]);l.useEffect(()=>{!n||o!==null&&I.some(oe=>oe.id===o)||r(I[0]?.id??null)},[I,n,o]);const D=A!==null&&m!==null&&m.group.id===A.id?m:null,{evidenceResponse:$,isLoading:J,error:X,mutate:F}=zC(A),H=l.useCallback(()=>{k()},[k]),Y=l.useCallback(async()=>{if(!(I.length===0||j)){S(!0),f(null),g(!1),v(null),d(null);try{const z=await De(HC(!1),Yd,va,{method:"DELETE"},oe=>`Clear failed with status ${String(oe.status)}`);u(null),r(null),await k(),await F(),C({message:`Cleared ${ot(z.deleted)} group${z.deleted===1?"":"s"}.`,tone:"success"})}catch(z){C({message:z instanceof Error?z.message:"Unknown error clearing groups",tone:"error"})}finally{S(!1)}}},[j,I.length,k,F,C]),U=l.useCallback(async z=>{i(z.id),d(null);try{const oe=await De(`/api/groups/${encodeURIComponent(z.id)}/evidence`,Nx,va,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({latestLogLimit:10})},te=>`Export failed with status ${String(te.status)}`);u(oe),await k(),await F()}catch(oe){d(oe instanceof Error?oe.message:String(oe))}finally{i(null)}},[k,F]),W=l.useCallback(z=>{f(z),g(!1),v(null)},[]),me=l.useCallback(()=>{b===null&&(f(null),g(!1),v(null))},[b]),ge=l.useCallback(z=>{r(z),f(null),g(!1),v(null)},[]),be=l.useCallback(async()=>{const z=p;if(z!==null){y(z.id),v(null);try{await De(qC(z.id,h),Jd,va,{method:"DELETE"},oe=>`Delete failed with status ${String(oe.status)}`),u(oe=>oe!==null&&oe.group.id===z.id?null:oe),r(oe=>oe===z.id?null:oe),f(null),g(!1),await k(),await F()}catch(oe){v(oe instanceof Error?oe.message:String(oe))}finally{y(null)}}},[h,p,k,F]);return t.jsxs(Pt,{open:n,onOpenChange:s,children:[t.jsx(yf,{notice:N,onDismiss:R}),t.jsx(Zs,{asChild:!0,children:t.jsxs(ee,{type:"button",variant:"ghost",size:e?"default":"icon",className:O(to,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:[t.jsx(Ul,{className:"size-4"}),P?t.jsx(Ae,{className:"absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground"}):I.length>0?t.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:I.length}):null,t.jsx("span",{className:e?"":"sr-only",children:"Groups"})]})}),t.jsxs(Lt,{className:"flex max-h-[85vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Ft,{children:t.jsxs(Ut,{className:"flex items-center gap-2 pr-8",children:[t.jsx(Ul,{className:"size-5 text-muted-foreground"}),t.jsx("span",{children:"Groups"}),t.jsx(ke,{variant:"outline",children:ot(I.length)})]})}),t.jsxs("div",{className:"flex min-h-0 items-center justify-between gap-3 border-b border-border pb-3",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Evaluation batches, model runs, and exported evidence packs."}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsxs(ee,{type:"button",variant:"outline",size:"sm",disabled:I.length===0||j,onClick:()=>{Y()},title:"Clear all groups. Session logs and run records stay intact.",children:[j?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(an,{className:"size-3.5"}),"Clear"]}),t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:H,children:[t.jsx(yt,{className:"size-3.5"}),"Refresh"]})]})]}),t.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 md:grid-cols-[260px_minmax(0,1fr)]",children:[t.jsx(sk,{groups:I,selectedGroupId:A?.id??null,isLoading:P,error:M,onSelect:ge}),t.jsx(ok,{group:A,deleteTarget:p,deleteEvidence:h,exportResult:D,evidenceResponse:$,evidenceLoading:J,evidenceError:X,exportError:c,deleteError:w,exportingGroupId:a,deletingGroupId:b,onDeleteEvidenceChange:g,onExport:U,onRequestDelete:W,onCancelDelete:me,onConfirmDelete:()=>{be()}})]})]})]})}function sk({groups:e,selectedGroupId:n,isLoading:s,error:o,onSelect:r}){return s?t.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..."}):o!==void 0?t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:o.message}):e.length===0?t.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."}):t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsx("div",{className:"space-y-2",children:e.map(a=>{const i=wf(a),c=n===a.id;return t.jsxs("button",{type:"button",onClick:()=>r(a.id),className:O("w-full rounded-md border px-3 py-2 text-left text-xs transition-colors",c?"border-primary bg-primary/5":"border-border bg-background hover:bg-muted/50"),children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"min-w-0 text-sm font-medium leading-snug",children:a.title}),t.jsx(ke,{variant:"outline",className:kl(a.status),children:_l(a.status)})]}),t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[t.jsxs("span",{children:[i.memberCount," sessions"]}),t.jsx("span",{children:us(a.updatedAt)})]})]},a.id)})})})}function ok({group:e,deleteTarget:n,deleteEvidence:s,exportResult:o,evidenceResponse:r,evidenceLoading:a,evidenceError:i,exportError:c,deleteError:d,exportingGroupId:m,deletingGroupId:u,onDeleteEvidenceChange:p,onExport:f,onRequestDelete:h,onCancelDelete:g,onConfirmDelete:b}){if(e===null)return t.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 y=wf(e),w=ek(e,o,r),v=tk(e,o,r),j=QC(e,o),S=WC(e,o,r),N=m===e.id,C=u===e.id,R=n?.id===e.id;return t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"min-w-0 text-base font-semibold leading-snug",children:e.title}),t.jsx(ke,{variant:"outline",className:kl(e.status),children:_l(e.status)}),t.jsx(ke,{variant:"outline",children:e.kind})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[t.jsx("span",{children:Fr(e.project)}),t.jsxs("span",{children:["updated ",us(e.updatedAt)]})]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.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:C,onClick:()=>h(e),children:C?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(an,{className:"size-3.5"})}),t.jsxs(ee,{type:"button",variant:"default",size:"sm",className:"shrink-0",disabled:N||C,onClick:()=>{f(e)},children:[N?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Vs,{className:"size-3.5"}),"Export evidence"]})]})]}),e.task!==null&&e.task.trim().length>0&&t.jsx("p",{className:"rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:e.task}),R&&t.jsx(rk,{group:e,deleteEvidence:s,isDeleting:C,error:d,onDeleteEvidenceChange:p,onCancel:g,onConfirm:b}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(Xt,{label:"Members",value:y.memberCount}),t.jsx(Xt,{label:"Done",value:y.completedMembers}),t.jsx(Xt,{label:"Failed",value:y.failedMembers}),t.jsx(Xt,{label:"Running",value:y.runningMembers})]}),w!==null&&t.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[t.jsx(Xt,{label:"Requests",value:w.requestCount}),t.jsx(Xt,{label:"Errors",value:w.errorCount}),t.jsx(Xt,{label:"Tokens",value:w.tokenUsage.total}),t.jsx(Xt,{label:"Missing",value:w.missingSessions})]}),t.jsx(ak,{report:v,loading:a,error:i,hasEvidence:j!==null}),t.jsx(ik,{evidence:j}),c!==null&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:c}),d!==null&&!R&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger",children:d}),t.jsx(lk,{rows:S})]})})}function rk({group:e,deleteEvidence:n,isDeleting:s,error:o,onDeleteEvidenceChange:r,onCancel:a,onConfirm:i}){const c=e.evidence!==null,d=e.evidence?.markdownPath??"No evidence pack exported.";return t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-3 text-status-danger",children:t.jsxs("div",{className:"flex min-w-0 flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[t.jsx(an,{className:"size-4 text-status-danger"}),t.jsx("span",{children:"Delete group?"})]}),t.jsxs("p",{className:"text-xs text-status-danger",children:["Delete ",t.jsx("span",{className:"font-medium",children:e.title}),". Session logs and run records stay intact."]}),t.jsxs("label",{className:O("flex min-w-0 items-start gap-2 text-xs",c?"cursor-pointer":"opacity-60"),children:[t.jsx("input",{type:"checkbox",className:"mt-0.5 size-4 shrink-0",checked:n,disabled:!c||s,onChange:m=>r(m.currentTarget.checked)}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block font-medium",children:"Also delete exported evidence files"}),t.jsx("code",{className:"mt-1 block truncate font-mono text-[11px] text-status-danger",children:d})]})]}),o!==null&&t.jsx("div",{className:"rounded-md border border-status-danger/30 bg-card px-2 py-1.5 text-xs text-status-danger",children:o})]}),t.jsxs("div",{className:"flex shrink-0 justify-end gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:s,onClick:a,children:"Cancel"}),t.jsxs(ee,{type:"button",variant:"destructive",size:"sm",disabled:s,onClick:i,children:[s?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(an,{className:"size-3.5"}),"Delete"]})]})]})})}function Xt({label:e,value:n}){return t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase text-muted-foreground",children:e}),t.jsx("div",{className:"mt-1 font-mono text-sm font-semibold",children:ot(n)})]})}function ak({report:e,loading:n,error:s,hasEvidence:o}){const{copied:r,copy:a}=sn(e?.markdown??null);return e===null&&!n&&s===void 0?null:n?t.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:[t.jsx(Ae,{className:"size-3.5 animate-spin"}),"Loading evidence report..."]}):s!==void 0&&o?t.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: ",s.message]}):e===null?null:t.jsxs("div",{className:"rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence report"}),t.jsx(ke,{variant:"outline",className:VC(e.status),children:e.status})]}),t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":r?"Copied evidence report":"Copy evidence report",onClick:a,children:r?t.jsx(Oe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:e.summary})]})}function ik({evidence:e}){return e===null?t.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."}):t.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-semibold",children:"Evidence paths"}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:us(e.exportedAt)})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(ya,{label:"JSON",value:e.jsonPath}),t.jsx(ya,{label:"Markdown",value:e.markdownPath}),t.jsx(ya,{label:"HTML",value:e.htmlPath})]})]})}function ya({label:e,value:n}){const{copied:s,copy:o}=sn(n);return t.jsxs("div",{className:"flex min-w-0 items-center gap-2 rounded-md border border-border bg-background px-2 py-1.5",children:[t.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground",children:e}),t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:n}),t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0","aria-label":s?`Copied ${e} path`:`Copy ${e} path`,onClick:o,children:s?t.jsx(Oe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})}function lk({rows:e}){const[n,s]=l.useState(null),o=l.useCallback(r=>{s(a=>a===r?null:r)},[]);return e.length===0?t.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."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.jsx("div",{className:"border-b border-border bg-muted/30 px-3 py-2 text-xs font-semibold",children:"Members"}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[760px] text-left text-xs",children:[t.jsx("thead",{className:"border-b border-border bg-muted/20 text-muted-foreground",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 font-medium",children:"Session"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Provider / Model"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Status"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Requests"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Errors"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"First chunk"}),t.jsx("th",{className:"px-3 py-2 font-medium",children:"Tokens"})]})}),t.jsx("tbody",{children:e.map(r=>{const a=n===r.member.id;return t.jsxs(l.Fragment,{children:[t.jsx(ck,{row:r,isExpanded:a,onToggleDetails:o}),t.jsx(dk,{row:r,isExpanded:a})]},r.member.id)})})]})})]})}function ck({row:e,isExpanded:n,onToggleDetails:s}){const o=e.member,r=e.exportMember?.session??null,a=XC(e),i=r?.inspectorPath??Id(o.sessionId),c=e.source!=="evidence",d=r?.requestCount??null,m=r?.errorCount??null,u=r?.tokenUsage.total??null,p=a?.firstChunkMs??null,f=jf(o.label,o.sessionId),h=GC(r?.clientUserAgent,a?.userAgent,o.agent),g=r?.clientProjectFolder??null,b=xl({userAgent:h,conversationId:o.sessionId,clientProjectFolder:g}),y=Dr(b);return t.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/20",children:[t.jsxs("td",{className:"max-w-56 px-3 py-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-6 shrink-0 text-muted-foreground","aria-label":n?`Hide member ${f}`:`Show member ${f}`,title:n?"Hide member details":"Show member details",onClick:()=>{s(o.id)},children:n?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"})}),y!==null&&t.jsx(zr,{client:b,className:"size-5"}),c?t.jsxs("a",{href:i,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 ${f}`,title:`Open session ${f}`,children:[t.jsx("span",{className:"min-w-0 truncate",children:f}),t.jsx(zi,{className:"size-3 shrink-0 text-muted-foreground"})]}):t.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 ${f}`,"aria-label":`Show evidence snapshot for ${f}`,onClick:()=>{s(o.id)},children:[t.jsx("span",{className:"min-w-0 truncate",children:f}),t.jsx(ke,{variant:"outline",className:"shrink-0 border-border bg-muted/30 text-muted-foreground",children:"evidence"})]})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground",children:Fr(o.agent)})]}),t.jsx("td",{className:"max-w-52 px-3 py-2",children:t.jsx("span",{className:"block whitespace-normal leading-snug",children:JC(o)})}),t.jsx("td",{className:"px-3 py-2",children:t.jsx(ke,{variant:"outline",className:kl(o.status),children:_l(o.status)})}),t.jsx("td",{className:"px-3 py-2 font-mono",children:d===null?"-":ot(d)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:m===null?"-":ot(m)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:fi(p)}),t.jsx("td",{className:"px-3 py-2 font-mono",children:u===null?"-":ot(u)})]})}function dk({row:e,isExpanded:n}){if(!n)return null;const s=e.member,o=e.exportMember,r=o?.session??null,a=o?.run??null,i=Object.entries(s.metadata);return t.jsx("tr",{className:"border-b border-border bg-muted/10",children:t.jsx("td",{colSpan:7,className:"px-3 pb-4 pt-2",children:t.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-background p-3",children:[t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(Ke,{label:"Source",value:ZC(e.source)}),t.jsx(Ke,{label:"Member ID",value:s.id,mono:!0}),t.jsx(Ke,{label:"Session ID",value:s.sessionId,mono:!0}),t.jsx(Ke,{label:"Run ID",value:a?.id??s.runId??"-",mono:!0}),t.jsx(Ke,{label:"Created",value:us(s.addedAt)}),t.jsx(Ke,{label:"Updated",value:us(s.updatedAt)}),t.jsx(Ke,{label:"Session created",value:Ic(r?.createdAt??null)}),t.jsx(Ke,{label:"Session updated",value:Ic(r?.updatedAt??null)})]}),r===null?t.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."}):t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4",children:[t.jsx(Ke,{label:"Log coverage",value:r.logCoverage}),t.jsx(Ke,{label:"Runtime",value:Fr(r.runtimeMode)}),t.jsx(Ke,{label:"Requests",value:ot(r.requestCount),mono:!0}),t.jsx(Ke,{label:"Errors",value:ot(r.errorCount),mono:!0}),t.jsx(Ke,{label:"Input tokens",value:ot(r.tokenUsage.input),mono:!0}),t.jsx(Ke,{label:"Output tokens",value:ot(r.tokenUsage.output),mono:!0}),t.jsx(Ke,{label:"Cache read",value:ot(r.tokenUsage.cacheRead),mono:!0}),t.jsx(Ke,{label:"Total tokens",value:ot(r.tokenUsage.total),mono:!0})]}),t.jsx(uk,{logs:r?.latestLogs??[]}),t.jsx(mk,{entries:i})]})})})}function Ke({label:e,value:n,mono:s=!1}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:e}),t.jsx("div",{className:O("truncate text-xs text-foreground",s?"font-mono":""),title:n,children:n})]})}function uk({logs:e}){const n=e.slice(0,5);return n.length===0?t.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."}):t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.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"}),t.jsx("div",{className:"divide-y divide-border",children:n.map(s=>{const o=s.sessionLogNumber??s.id;return t.jsxs("div",{className:"grid gap-2 px-3 py-2 text-xs sm:grid-cols-[72px_1fr_88px_88px]",children:[t.jsxs("span",{className:"font-mono text-muted-foreground",title:`Log ID ${String(s.id)}`,children:["#",o]}),t.jsxs("span",{className:"min-w-0 truncate",children:[Fr(s.model)," · ",s.apiFormat," · ",s.path]}),t.jsx("span",{className:"font-mono text-muted-foreground",children:fi(s.firstChunkMs)}),t.jsx("span",{className:"font-mono text-muted-foreground",children:fi(s.latencyMs)})]},s.id)})})]})}function mk({entries:e}){return e.length===0?null:t.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[t.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"}),t.jsx("div",{className:"grid gap-x-3 gap-y-2 p-3 text-xs sm:grid-cols-2",children:e.map(([n,s])=>{const o=KC(s);return t.jsxs("div",{className:"min-w-0",children:[t.jsx("span",{className:"mr-2 text-muted-foreground",children:n}),t.jsx("span",{className:"font-mono text-foreground",title:o,children:o})]},n)})})]})}const pk=T({selectionId:x().uuid(),name:x(),apiKeyHint:x(),format:ue(["anthropic","openai"]),anthropicBaseUrl:x(),openaiBaseUrl:x(),openaiResponsesBaseUrl:x().optional().default(""),models:K(x()),sourceTool:ue(["claude-code","opencode","mimo-code"]),alreadyExists:_e()}),fk=T({scanId:x().uuid(),providers:K(pk),warnings:K(x()).optional()});T({scanId:x().uuid(),selectionIds:K(x().uuid()).min(1).max(100)});const hk=T({success:_e().optional(),imported:E().optional(),message:x().optional(),errors:K(x()).optional()}),Pc=2e4;function xk({open:e,onOpenChange:n,onImportComplete:s}){const[o,r]=l.useState(!1),[a,i]=l.useState(null),[c,d]=l.useState(null),[m,u]=l.useState([]),[p,f]=l.useState([]),[h,g]=l.useState(new Set),[b,y]=l.useState(!1),[w,v]=l.useState(null),[j,S]=l.useState(null),N=l.useRef(0),C=l.useRef(0),R=l.useCallback(()=>{const k=N.current+1;N.current=k,r(!0),i(null),f([]),d(null),u([]),g(new Set),v(null),S(null),De("/api/providers/scan",fk,Pc,{method:"POST"},A=>`Scan failed (${String(A.status)})`).then(A=>{if(N.current!==k)return;d(A.scanId),u(A.providers),f(A.warnings??[]);const D=new Set;A.providers.forEach(($,J)=>{$.alreadyExists||D.add(J)}),g(D)}).catch(A=>{N.current===k&&i(A instanceof Error?A.message:String(A))}).finally(()=>{N.current===k&&r(!1)})},[]);l.useEffect(()=>{e&&R()},[e,R]),l.useEffect(()=>{e||(N.current+=1,C.current+=1,r(!1),y(!1))},[e]);const I=l.useCallback(k=>{g(A=>{const D=new Set(A);return D.has(k)?D.delete(k):D.add(k),D})},[]),P=l.useCallback(()=>{const k=m.filter((D,$)=>h.has($));if(k.length===0||c===null)return;const A=C.current+1;C.current=A,y(!0),S(null),v(null),De("/api/providers/import",hk,Pc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({scanId:c,selectionIds:k.map(D=>D.selectionId)})},D=>`Import failed (${String(D.status)})`).then(D=>{C.current===A&&(u($=>$.map((J,X)=>h.has(X)?{...J,alreadyExists:!0}:J)),g(new Set),D.errors!==void 0&&D.errors.length>0&&D.message!==void 0?v(D.message):v(`Imported ${D.imported??k.length} provider(s)`),s())}).catch(D=>{C.current===A&&S(D instanceof Error?D.message:String(D))}).finally(()=>{C.current===A&&y(!1)})},[m,c,h,s]),M=m.some(k=>!k.alreadyExists);return t.jsx(Pt,{open:e,onOpenChange:n,children:t.jsxs(Lt,{className:"max-w-xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(Ft,{children:[t.jsx(Ut,{children:"Import from External Tools"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Detect provider configurations from Claude Code, OpenCode, and MiMo Code."})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto space-y-3",children:[o&&t.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-muted-foreground",children:[t.jsx(Ae,{className:"size-4 animate-spin"}),t.jsx("span",{className:"text-sm",children:"Scanning for external providers..."})]}),a!==null&&t.jsxs("div",{className:"flex items-center gap-2 text-destructive text-sm py-4",children:[t.jsx(os,{className:"size-4"}),a]}),!o&&a===null&&m.length===0&&t.jsxs("p",{className:"text-sm text-muted-foreground py-8 text-center",children:["No external provider configurations found.",t.jsx("br",{}),t.jsx("span",{className:"text-xs",children:"Supported tools: Claude Code (~/.claude/settings.json), OpenCode (~/.config/opencode/opencode.json), MiMo Code (~/.config/mimocode/mimocode.jsonc)"})]}),!o&&m.map((k,A)=>t.jsxs("label",{className:`flex items-start gap-3 p-3 border rounded-md ${k.alreadyExists?"":"cursor-pointer hover:bg-muted/50"}`,children:[!k.alreadyExists&&t.jsx("input",{type:"checkbox",checked:h.has(A),disabled:b,onChange:()=>I(A),className:"mt-0.5 size-4"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(zr,{client:k.sourceTool,className:"size-7 rounded-[8px]"}),k.alreadyExists&&t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Already added"})]}),t.jsxs("div",{className:"mt-1 text-xs leading-snug text-muted-foreground",children:[k.models.slice(0,4).join(", "),k.models.length>4?` +${k.models.length-4} more`:""]}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:k.format==="anthropic"?k.anthropicBaseUrl:k.openaiResponsesBaseUrl!==""?k.openaiResponsesBaseUrl:k.openaiBaseUrl}),t.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 font-mono",children:k.apiKeyHint})]})]},k.selectionId)),p.length>0&&t.jsx("div",{className:"text-xs text-muted-foreground space-y-1 border-t pt-2",children:p.map((k,A)=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(os,{className:"size-3"}),k]},A))}),w!==null&&t.jsx("div",{className:"border-t pt-2 text-sm text-status-success",children:w}),j!==null&&t.jsx("div",{className:"text-sm text-destructive border-t pt-2",children:j})]}),t.jsxs("div",{className:"flex items-center justify-between pt-3 border-t",children:[t.jsxs(ee,{variant:"outline",size:"sm",onClick:R,disabled:o,children:[t.jsx(Ae,{className:`size-3 mr-1 ${o?"animate-spin":""}`}),"Rescan"]}),t.jsxs(ee,{size:"sm",onClick:P,disabled:!M||h.size===0||b,children:[t.jsx(Vs,{className:"size-3 mr-1"}),b?"Importing...":`Import Selected (${h.size})`]})]})]})})}const Sf=T({id:x().min(1).max(Wa),aliases:K(x().max(Wa)).max(_n).optional().default([]),contextWindow:E().int().positive().optional(),outputLimit:E().int().positive().optional(),sourceUrl:x().optional()}),gk=T({name:x().min(1).optional(),aliases:K(x()).max(_n).optional().default([]),baseUrls:K(x()).max(_n).optional().default([]),models:K(Sf).min(1).max(_n)});T({version:E().int().positive().optional(),updatedAt:x().optional(),providers:K(gk).max(_n).optional().default([]),models:K(Sf).max(_n).optional().default([])});function Lc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function bk(e){const n=e.models.filter(s=>s.trim()!=="");return n.length>0?n:e.model!==void 0&&e.model.trim()!==""?[e.model]:[]}function Tl(e,n){const s=Lc(n);return(e.modelMetadata??[]).find(r=>Lc(r.model)===s)??null}function vk(e){const n=bk(e);return n.length===0?!1:n.every(s=>{const o=Tl(e,s);return o!==null&&o.contextWindow!==void 0})}function yk(e,n){if(e===null)return null;for(const s of n){const o=Tl(s,e);if(o!==null&&o.contextWindow!==void 0)return{providerName:s.name,model:o.model,tokens:o.contextWindow,sourceUrl:o.sourceUrl}}return null}function qs(e){return Object.prototype.hasOwnProperty.call(e,"success")}function Ur(e){return Object.prototype.hasOwnProperty.call(e,"notConfigured")}function mt(e){return e!==void 0&&e!==""}function Je(e){return e!==void 0&&e.trim()!==""}function ns(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Nf(e){return e>=10?`${e.toFixed(0)}/s`:`${e.toFixed(1)}/s`}function Cf(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 wk(e){return e.firstChunkMs!==void 0&&e.firstChunkMs!==null?ns(e.firstChunkMs):e.latencyMs!==void 0?ns(e.latencyMs):e.totalStreamMs!==void 0&&e.totalStreamMs!==null?ns(e.totalStreamMs):e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0?Nf(e.tokensPerSecond):null}function jk(e){return Ur(e)?{tone:"quiet",label:"N/A",metric:null,hasDetails:!1}:qs(e)?e.success?{tone:"success",label:"Pass",metric:wk(e),hasDetails:!0}:{tone:"failure",label:Cf(e.error?.type??"unknown"),metric:null,hasDetails:!0}:{tone:"pending",label:"Running",metric:null,hasDetails:!1}}function Sk(e,n){if(n===void 0)return[];const s=[];return mt(e.anthropicBaseUrl)&&s.push(n.anthropic),mt(e.openaiBaseUrl)&&s.push(n.openaiChat),mt(e.openaiResponsesBaseUrl)&&s.push(n.openaiResponses),s}function Nk(e,n){const s={total:0,passed:0,failed:0,testing:0};for(const o of Sk(e,n))for(const r of[o.nonStreaming,o.streaming])Ur(r)||(s.total+=1,qs(r)?r.success?s.passed+=1:s.failed+=1:s.testing+=1);return s}function Oc(e){if(e===void 0)return;const n=Object.entries(e).map(([s,o])=>`${s}: ${o}`);return n.length===0?void 0:n.join(`
|
|
57
|
+
`)}function Zt({title:e,children:n}){return t.jsxs("section",{className:"space-y-1.5",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:e}),n]})}function wn({value:e}){return t.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 jn({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md bg-muted/35 px-3 py-2",children:[t.jsx("dt",{className:"text-[10px] text-muted-foreground",children:e}),t.jsx("dd",{className:"mt-1 truncate font-mono text-xs font-semibold text-foreground",title:n,children:n})]})}function Ck({result:e}){const n=e.inputTokens!==void 0||e.outputTokens!==void 0,s=e.cacheCreationInputTokens!==void 0||e.cacheReadInputTokens!==void 0;return Je(e.model)||n||s||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?t.jsxs("dl",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:[Je(e.model)&&t.jsx(jn,{label:"Model",value:e.model}),e.latencyMs!==void 0&&t.jsx(jn,{label:"Latency",value:ns(e.latencyMs)}),e.firstChunkMs!==void 0&&e.firstChunkMs!==null&&t.jsx(jn,{label:"First chunk",value:ns(e.firstChunkMs)}),e.totalStreamMs!==void 0&&e.totalStreamMs!==null&&t.jsx(jn,{label:"Stream total",value:ns(e.totalStreamMs)}),e.tokensPerSecond!==void 0&&e.tokensPerSecond!==null&&e.tokensPerSecond>0&&t.jsx(jn,{label:"Token rate",value:`${Nf(e.tokensPerSecond)} tok`}),n&&t.jsx(jn,{label:"Tokens in / out",value:`${String(e.inputTokens??0)} / ${String(e.outputTokens??0)}`}),s&&t.jsx(jn,{label:"Cache create / read",value:`${String(e.cacheCreationInputTokens??0)} / ${String(e.cacheReadInputTokens??0)}`})]}):null}function kk({result:e}){const n=e.debug,s=n?.requestUrl,o=n?.requestMethod??"POST",r=Oc(n?.requestHeaders),a=Oc(n?.responseHeaders),i=n?.responseStatus===void 0?void 0:`${String(n.responseStatus)}${Je(n.responseStatusText)?` ${n.responseStatusText}`:""}`,c=n?.responseBody??e.rawResponse;return Je(e.error?.hint)||Je(e.error?.details)||Je(s)||r!==void 0||Je(n?.requestBody)||Je(i)||a!==void 0||Je(c)?t.jsxs("div",{className:"space-y-4 border-t border-border/70 pt-4 text-xs text-muted-foreground",children:[Je(e.error?.hint)&&t.jsx(Zt,{title:"Hint",children:t.jsx("p",{className:"break-words text-foreground/80",children:e.error.hint})}),Je(e.error?.details)&&t.jsx(Zt,{title:"Error details",children:t.jsx(wn,{value:e.error.details})}),Je(s)&&t.jsx(Zt,{title:"Request",children:t.jsx(wn,{value:`${o} ${s}`})}),r!==void 0&&t.jsx(Zt,{title:"Request headers",children:t.jsx(wn,{value:r})}),Je(n?.requestBody)&&t.jsx(Zt,{title:"Request body",children:t.jsx(wn,{value:n.requestBody})}),Je(i)&&t.jsx(Zt,{title:"Response status",children:t.jsx(wn,{value:i})}),a!==void 0&&t.jsx(Zt,{title:"Response headers",children:t.jsx(wn,{value:a})}),Je(c)&&t.jsx(Zt,{title:"Response body",children:t.jsx(wn,{value:c})})]}):null}function _k({result:e,probeLabel:n,children:s}){const o=e.error?.message??"Connection failed";return t.jsxs(Pt,{children:[t.jsx(Zs,{asChild:!0,children:s}),t.jsxs(Lt,{className:"max-h-[82vh] max-w-2xl gap-0 overflow-hidden p-0",children:[t.jsxs(Ft,{className:"border-b border-border/70 px-5 py-4 pr-12",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[e.success?t.jsx(Ws,{className:"size-4 text-status-success"}):t.jsx(os,{className:"size-4 text-status-danger"}),t.jsx(Ut,{className:"text-base",children:n})]}),t.jsx(Qs,{children:e.success?"Connection probe passed.":o})]}),t.jsxs("div",{className:"space-y-4 overflow-y-auto p-5",children:[!e.success&&t.jsxs("div",{className:"rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-sm text-status-danger",children:[t.jsx("div",{className:"font-medium",children:Cf(e.error?.type??"unknown")}),t.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:o})]}),t.jsx(Ck,{result:e}),t.jsx(kk,{result:e})]})]})]})}function Tk(e){const n="size-3 shrink-0";switch(e){case"timeout":return t.jsx(Wt,{className:n});case"network_unreachable":return t.jsx(g1,{className:n});case"connection_refused":return t.jsx(v1,{className:n});case"auth_failed":return t.jsx(fg,{className:n});case"rate_limited":return t.jsx($i,{className:n});case"server_error":return t.jsx(t1,{className:n});case"invalid_response":return t.jsx(v0,{className:n});case"unknown":return t.jsx(os,{className:n})}}const Ek={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 Dc({result:e,probeLabel:n}){const s=jk(e),o=Ur(e)?t.jsx(cu,{className:"size-3 shrink-0"}):qs(e)?e.success?t.jsx(Ws,{className:"size-3 shrink-0"}):Tk(e.error?.type??"unknown"):t.jsx(Ho,{className:"size-3 shrink-0 animate-spin"}),r=t.jsxs(t.Fragment,{children:[o,t.jsx("span",{className:"min-w-0 truncate",children:s.label}),s.metric!==null&&t.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] opacity-75",children:s.metric})]}),a=O("inline-flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2 text-left text-xs transition-colors",Ek[s.tone]);return qs(e)&&s.hasDetails?t.jsx(_k,{result:e,probeLabel:n,children:t.jsx("button",{type:"button",className:a,"aria-label":`Open ${n} result: ${s.label}`,children:r})}):t.jsx("div",{className:a,children:r})}function zc({label:e}){return t.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:[t.jsx(cu,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e})]})}function wa({label:e,results:n,configured:s=!0}){return t.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:[t.jsx("div",{className:"min-w-0 truncate text-xs font-medium text-foreground/85",title:e,children:e}),s&&n!==void 0?t.jsx(Dc,{result:n.nonStreaming,probeLabel:`${e} non-stream`}):t.jsx(zc,{label:s?"Not tested":"Off"}),s&&n!==void 0?t.jsx(Dc,{result:n.streaming,probeLabel:`${e} stream`}):t.jsx(zc,{label:s?"Not tested":"Off"})]})}function kf({provider:e,results:n}){const s=mt(e.anthropicBaseUrl),o=mt(e.openaiBaseUrl),r=mt(e.openaiResponsesBaseUrl);return!s&&!o&&!r?t.jsx("div",{className:"text-xs text-muted-foreground",children:"No testable endpoint configured."}):t.jsx("div",{className:"min-w-0 overflow-x-auto rounded-md border border-border/70",children:t.jsxs("div",{className:"min-w-[20rem]",children:[t.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:[t.jsx("span",{children:"Protocol"}),t.jsx("span",{children:"Non-stream"}),t.jsx("span",{children:"Stream"})]}),s&&t.jsx(wa,{label:"Anthropic",results:n?.anthropic}),o&&t.jsx(wa,{label:"OpenAI Chat",results:n?.openaiChat}),r&&t.jsx(wa,{label:"OpenAI Responses",results:n?.openaiResponses})]})})}function Rk(e){const n={total:0,passed:0,failed:0,testing:0};for(const s of[e.nonStreaming,e.streaming])Ur(s)||(n.total+=1,qs(s)?s.success?n.passed+=1:n.failed+=1:n.testing+=1);return n}function ja({label:e,results:n}){const s=Rk(n),o=s.failed>0?"border-status-danger/30 bg-status-danger/10 text-status-danger":s.testing>0?"border-status-watch/30 bg-status-watch/10 text-status-watch":s.total>0&&s.passed===s.total?"border-status-success/30 bg-status-success/10 text-status-success":"border-border/60 bg-transparent text-muted-foreground",r=s.failed>0?`${s.failed} fail`:s.testing>0?"running":s.total===0?"off":`${s.passed}/${s.total}`;return t.jsxs("span",{className:O("rounded border px-1.5 py-0.5 text-[10px]",o),children:[e," ",r]})}function Mk({provider:e,modelName:n,results:s,expanded:o,onToggle:r}){return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("button",{type:"button",onClick:r,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":o,children:[o?t.jsx(Ve,{className:"size-3.5 shrink-0 text-muted-foreground"}):t.jsx(it,{className:"size-3.5 shrink-0 text-muted-foreground"}),t.jsx("span",{className:"min-w-[8rem] flex-1 truncate text-xs font-medium",title:n,children:n}),t.jsxs("span",{className:"flex flex-wrap items-center justify-end gap-1",children:[mt(e.anthropicBaseUrl)&&t.jsx(ja,{label:"A",results:s.anthropic}),mt(e.openaiBaseUrl)&&t.jsx(ja,{label:"Chat",results:s.openaiChat}),mt(e.openaiResponsesBaseUrl)&&t.jsx(ja,{label:"Resp",results:s.openaiResponses})]})]}),o&&t.jsx("div",{className:"px-2 pb-3",children:t.jsx(kf,{provider:e,results:s})})]})}function Ak({provider:e,testResults:n}){const s=Object.entries(n.models??{}),[o,r]=l.useState(!1),[a,i]=l.useState(null);return s.length===0?null:t.jsxs("section",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>r(c=>!c),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":o,children:[o?t.jsx(Ve,{className:"size-3.5"}):t.jsx(it,{className:"size-3.5"}),"Model probes",t.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s.length})]}),o&&t.jsx("div",{className:"min-w-0 divide-y divide-border/60 rounded-md border border-border/70",children:s.map(([c,d])=>t.jsx(Mk,{provider:e,modelName:c,results:d,expanded:a===c,onToggle:()=>i(m=>m===c?null:c)},c))})]})}function Ik({provider:e,testResults:n,isTesting:s}){const o=mt(e.anthropicBaseUrl)||mt(e.openaiBaseUrl)||mt(e.openaiResponsesBaseUrl),r=Nk(e,n);return s?t.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:[t.jsx(Ho,{className:"size-3 animate-spin"}),"Testing"]}):o?n===void 0||r.total===0?t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"Not tested"}):r.failed>0?t.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:[t.jsx(os,{className:"size-3"}),r.failed," failed"]}):r.testing>0||r.passed<r.total?t.jsxs("span",{className:"rounded border border-status-watch/30 bg-status-watch/10 px-2 py-1 text-xs text-status-watch",children:[r.passed,"/",r.total]}):t.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:[t.jsx(Ws,{className:"size-3"}),r.passed,"/",r.total]}):t.jsx("span",{className:"rounded border border-border/70 bg-muted/20 px-2 py-1 text-xs text-muted-foreground",children:"No endpoint"})}const Pk={deepseek:"https://api-docs.deepseek.com/zh-cn/"};function Sa(e){return e!==void 0&&e!==""}function Na({label:e}){return t.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:[t.jsx(Ws,{className:"size-3"}),e]})}function Lk({provider:e}){const n=Sa(e.anthropicBaseUrl),s=Sa(e.openaiBaseUrl),o=Sa(e.openaiResponsesBaseUrl);return!n&&!s&&!o?t.jsx("div",{className:"text-xs text-muted-foreground",children:"Test requires at least one configured endpoint."}):t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5 text-xs text-muted-foreground",children:[n&&t.jsx(Na,{label:"Anthropic"}),s&&t.jsx(Na,{label:"OpenAI Chat"}),o&&t.jsx(Na,{label:"OpenAI Responses"})]})}function Ok(e){const n=e.models??[];if(n.length===0)return"No models configured";const s=n.slice(0,2).join(", "),o=n.length-2;return o>0?`${s} +${o} more`:s}function Dk({provider:e,model:n}){const s=Tl(e,n),o=$k(s?.sourceUrl);return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",children:[t.jsx("span",{children:n}),s!==null&&s.contextWindow!==void 0&&t.jsx("span",{className:"font-mono text-foreground/80",children:Ld(s.contextWindow)}),o!==null&&t.jsx(hs,{children:t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsx("a",{href:o.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":o.title,children:o.label})}),t.jsx(nt,{children:o.title})]})})]})}function zk(e){const n=Date.now(),s=new Date(e).getTime(),o=n-s,r=Math.floor(o/1e3);if(r<60)return"just now";const a=Math.floor(r/60);if(a<60)return`${a}m ago`;const i=Math.floor(a/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function $k(e){if(e===void 0||e.trim()==="")return null;try{const n=new URL(e);if(n.protocol!=="https:"&&n.protocol!=="http:")return null;const s=n.hostname.toLowerCase(),o=s==="huggingface.co"||s.endsWith(".huggingface.co");return{label:o?"HF":"Source",title:o?"Open Hugging Face model source":"Open model metadata source",url:e}}catch{return null}}function Fk({provider:e,testResults:n,isTesting:s,testingTimeLeft:o,isHighlighted:r,onEdit:a,onDelete:i,onTest:c,onRefreshMetadata:d,isRefreshingMetadata:m=!1}){const[u,p]=l.useState(!1),f=e.apiDocsUrl??Object.entries(Pk).find(([v])=>e.name.toLowerCase().includes(v))?.[1],h=vk(e),g=e.modelMetadataUrl!==void 0&&e.modelMetadataUrl.trim()!=="",b=g?"Refresh":"Import defaults",y=s??!1,w=e.source==="company"?t.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"?t.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 t.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 ${r===!0?"ring-2 ring-primary shadow-md":""}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0 space-y-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-medium leading-snug",children:e.name}),w]}),t.jsx("div",{className:"text-xs leading-snug text-muted-foreground",children:Ok(e)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Ik,{provider:e,testResults:n,isTesting:y}),f!==void 0&&t.jsxs("a",{href:f,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:[t.jsx(zi,{className:"size-3"}),t.jsx("span",{className:"sr-only",children:"Docs"})]})]})]}),t.jsxs("div",{className:"flex flex-col gap-2 text-xs text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[t.jsx(Lk,{provider:e}),n?.testedAt!==void 0&&t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Wt,{className:"size-3"}),zk(n.testedAt)]})]}),!h&&t.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:[t.jsx("span",{children:"Context window metadata missing"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsxs(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>d?.(e.id),className:"h-6 gap-1 px-2 text-xs",disabled:m,children:[t.jsx(Ho,{className:`size-3 ${m?"animate-spin":""}`}),b]}),!g&&t.jsx(ee,{type:"button",variant:"ghost",size:"sm",onClick:()=>a(e),className:"h-6 px-2 text-xs",children:"Set URL"})]})]}),u&&t.jsxs("div",{className:"space-y-3 border-t border-border/60 pt-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsx(Ws,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"API key configured"})]}),e.models!==void 0&&e.models.length>0&&t.jsx("div",{className:"flex flex-wrap gap-1",children:e.models.map(v=>t.jsx(Dk,{provider:e,model:v},v))}),t.jsxs("section",{className:"space-y-2",children:[t.jsx("h4",{className:"text-xs font-medium text-foreground/80",children:"Connection probes"}),t.jsx(kf,{provider:e,results:n})]}),n!==void 0&&t.jsx(Ak,{provider:e,testResults:n})]}),t.jsxs("div",{className:"flex flex-col gap-2 border-t pt-1 sm:flex-row sm:items-center sm:justify-between",children:[t.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":u,children:[u?t.jsx(Ve,{className:"size-3"}):t.jsx(it,{className:"size-3"}),"Details"]}),t.jsxs("div",{className:"flex gap-2",children:[c!==void 0&&t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>c(e.id),className:"text-xs h-7 gap-1",disabled:y,children:[t.jsx(Ho,{className:`size-3 ${y?"animate-spin":""}`}),y?o!==void 0?`Testing (${o}s)`:"Testing...":"Test"]}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>a(e),className:"text-xs h-7 gap-1",disabled:y,children:[t.jsx(du,{className:"size-3"}),"Edit"]}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>i(e.id),className:"text-xs h-7 gap-1 text-destructive hover:text-destructive",disabled:y,children:[t.jsx(an,{className:"size-3"}),"Delete"]})]})]})]})}const ss="/v1/chat/completions",hi="/v1/responses",Uk="/v1/messages";function Bk(e,n){const s=e.endsWith("/")?e.slice(0,-1):e,o=_f(n),r=n.indexOf("?"),a=r>=0?n.slice(r):"";return o!==""&&s.endsWith(o)?s+a:Ef(s)&&Tf(n)||s.endsWith("/v1")&&n.startsWith("/v1/")?s+n.slice(3):s+n}function qk(e,n,s={}){const o=e.trim().replace(/\/+$/,""),r=_f(n),a=Bk(o,n),i=[];return r!==""&&o.endsWith(r)?i.push({severity:"info",message:"This already includes the exact endpoint; no duplicate suffix will be appended."}):Ef(o)&&Tf(n)?i.push({severity:"info",message:"Zhipu bases already include the API version; only /chat/completions is appended."}):o.endsWith("/v1")&&n.startsWith("/v1/")&&i.push({severity:"info",message:"Base URL already ends with /v1; the suffix will not repeat /v1."}),$c(r)&&Wk(o)&&i.push({severity:"warning",message:"This looks like a Chat Completions endpoint, so Responses would append after it."}),Hk(r)&&Vk(o)&&i.push({severity:"warning",message:"This looks like a Responses endpoint, so Chat Completions would append after it."}),$c(r)&&Kk(o,s.providerName)&&i.push({severity:"warning",message:"DeepSeek's official API does not currently expose OpenAI Responses."}),{finalUrl:a,diagnostics:i}}function _f(e){return e.split("?")[0]??e}function Tf(e){return e===ss||e.startsWith(`${ss}?`)||e.startsWith(`${ss}/`)}function Hk(e){return e===ss||e.startsWith(`${ss}/`)}function $c(e){return e===hi||e.startsWith(`${hi}/`)}function Wk(e){return e.toLowerCase().endsWith("/chat/completions")}function Vk(e){return e.toLowerCase().endsWith("/responses")}function Kk(e,n){const s=n?.toLowerCase();if(s!==void 0&&s.includes("deepseek"))return!0;try{return new URL(e).hostname.toLowerCase().includes("deepseek")}catch{return e.toLowerCase().includes("deepseek")}}function Ef(e){try{const n=new URL(e),s=n.pathname.replace(/\/+$/,"");return n.hostname==="open.bigmodel.cn"&&(s==="/api/paas/v4"||s==="/api/coding/paas/v4")}catch{return!1}}function Ca(e){return e!==void 0&&e.trim()!==""}function Fc(e){const n=Ca(e?.anthropicBaseUrl),s=Ca(e?.openaiBaseUrl),o=Ca(e?.openaiResponsesBaseUrl);return{anthropic:n,openai:s||o,openaiChat:s,openaiResponses:o}}function ka(e,n,s){if(!e)return s?"":void 0;const o=n.trim();return o===""?void 0:o}const Uc=["zhipu","zhipuai","bigmodel","z.ai","zai","glm"],Bc=["zhipu coding","glm coding","bigmodel coding","z.ai coding","zai coding"],yo=Uk,wo=ss,jo=hi,Gk={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"}},qc=["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"],Hc=["qwen3.6-plus","qwen3.7-max"],Wc=["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"],xi="__unset__",rr="__custom__",Rf=[{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 Sn(){return{contextWindow:"",contextWindowMode:"unset",outputLimit:""}}function Vc(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Mf(e,n){const s=Vc(n);return e?.modelMetadata?.find(o=>Vc(o.model)===s)??null}function Af(e){const n=Fo(e);if(n===null)return null;for(const s of Rf)if(Fo(s.value)===n)return s.value;return null}function Jk(e){return e.trim()===""?"unset":Af(e)!==null?"preset":"custom"}function Yk(e){switch(e.contextWindowMode){case"unset":return xi;case"custom":return rr;case"preset":return Af(e.contextWindow)??rr}}function _a(e){const n=e.trim().replaceAll(",","");if(n==="")return{amount:"",unit:"K"};const s=/^(\d+(?:\.\d+)?)\s*([kKmM])?$/.exec(n);if(s===null)return{amount:n,unit:"K"};const o=s[1];if(o===void 0)return{amount:n,unit:"K"};const r=s[2];if(r===void 0||r==="")return{amount:o,unit:"tokens"};switch(r.toLowerCase()){case"k":return{amount:o,unit:"K"};case"m":return{amount:o,unit:"M"};default:return{amount:n,unit:"K"}}}function Kc(e,n){const s=e.trim();if(s==="")return"";switch(n){case"K":return`${s}K`;case"M":return`${s}M`;case"tokens":return s}}function Gc(e,n){return n.map(s=>{const o=Mf(e,s),r=o?.contextWindow!==void 0?Ch(o.contextWindow):"";return{contextWindow:r,contextWindowMode:Jk(r),outputLimit:o?.outputLimit?.toString()??""}})}function Jc(e){const n=e.trim();if(n==="")return null;const s=Number(n);return!Number.isInteger(s)||s<=0?null:s}function Wn(e,n){if(e===void 0)return"";const s=e.trim(),o=s.replace(/\/+$/,"");return o.endsWith(n)?o.slice(0,-n.length).replace(/\/+$/,""):s}function Xk(e,n,s){const o=e.trim();return o===""?null:qk(o,n,{providerName:s})}function Ta({baseUrl:e,endpoint:n,providerName:s}){const o=Xk(e,n,s);return o===null?null:t.jsxs("div",{className:"border border-border bg-muted/40 rounded-md px-3 py-2 text-xs",children:[t.jsx("div",{className:"text-muted-foreground",children:"Final URL"}),t.jsx("div",{className:"break-all font-mono text-foreground",children:o.finalUrl}),o.diagnostics.length>0&&t.jsx("div",{className:"mt-2 space-y-1",children:o.diagnostics.map(r=>t.jsx("div",{className:r.severity==="warning"?"text-status-watch":"text-muted-foreground",children:r.message},`${r.severity}:${r.message}`))})]})}function Zk({provider:e,onSubmit:n,onCancel:s}){const o=Fc(e),[r,a]=l.useState(e?.name??""),[i,c]=l.useState(""),[d,m]=l.useState(!1),[u,p]=l.useState(!1),f=e?.models,[h,g]=l.useState(f!==void 0&&f.length>0?f:[""]),[b,y]=l.useState(()=>Gc(e,f!==void 0&&f.length>0?f:[""])),[w,v]=l.useState(o.anthropic),[j,S]=l.useState(o.openai),[N,C]=l.useState(o.openaiChat),[R,I]=l.useState(o.openaiResponses),[P,M]=l.useState(Wn(e?.anthropicBaseUrl,yo)),[k,A]=l.useState(Wn(e?.openaiBaseUrl,wo)),[D,$]=l.useState(Wn(e?.openaiResponsesBaseUrl,jo)),[J,X]=l.useState(e?.apiDocsUrl??""),[F,H]=l.useState(e?.modelMetadataUrl??""),[Y,U]=l.useState(e?.source),[W,me]=l.useState({}),[ge,be]=l.useState(!1),[z,oe]=l.useState(null),te=l.useRef([]);l.useEffect(()=>{if(z===null)return;const _=z;function L(V){if(!(V.target instanceof Node))return;const se=te.current[_];se!=null&&!se.contains(V.target)&&oe(null)}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[z]);const[Se,Ne]=l.useState(!1),[ie,le]=l.useState(!1),[fe,ve]=l.useState(!1),Ce=r.toLowerCase().includes("minimax"),Ie=r.toLowerCase().includes("alibaba"),$e=[...Uc,...Bc].some(_=>r.toLowerCase().includes(_)),Pe=Ce?qc:$e?Wc:Ie?Hc:[],Ze=e?.modelMetadata?.some(_=>_.contextWindow!==void 0)??!1;function Bt(){vt(i).then(_=>{_&&(p(!0),setTimeout(()=>p(!1),2e3))})}l.useEffect(()=>{if(e){a(e.name),c(""),m(!1);const _=(e.models?.length??0)>0?e.models:[""];g(_),y(Gc(e,_));const L=Fc(e);v(L.anthropic),S(L.openai),C(L.openaiChat),I(L.openaiResponses),M(Wn(e.anthropicBaseUrl,yo)),A(Wn(e.openaiBaseUrl,wo)),$(Wn(e.openaiResponsesBaseUrl,jo)),X(e.apiDocsUrl??""),H(e.modelMetadataUrl??""),U(e.source),Ne(!1),le(!1),ve(!1)}},[e]),l.useEffect(()=>{const _=r.toLowerCase();for(const[L,V]of Object.entries(Gk))if(_.includes(L)){V.anthropicBaseUrl!==void 0&&!Se&&M(V.anthropicBaseUrl),V.openaiBaseUrl!==void 0&&!ie&&A(V.openaiBaseUrl),V.openaiResponsesBaseUrl!==void 0&&!fe&&$(V.openaiResponsesBaseUrl),V.apiDocsUrl!==void 0&&!J&&X(V.apiDocsUrl),L==="minimax"&&h.length===1&&h[0]===""&&g([qc[0]??""]),L==="alibaba"&&h.length===1&&h[0]===""&&g([Hc[0]??""]),(Uc.includes(L)||Bc.includes(L))&&h.length===1&&h[0]===""&&g([Wc[0]??""]);break}},[r]);function ct(){const _={};return r.trim()||(_.name="Name is required"),e===void 0&&!i.trim()&&(_.apiKey="API key is required"),(h.length===0||h.every(L=>!L.trim()))&&(_.models="At least one model is required"),!w&&!j&&(_.capabilities="Select at least one API capability"),j&&!N&&!R&&(_.openaiCapabilities="Select Chat Completions, Responses, or both"),w&&(P.trim()===""?_.anthropicBaseUrl="Anthropic base URL is required":Fe(P.trim())||(_.anthropicBaseUrl="Invalid URL format")),j&&N&&(k.trim()===""?_.openaiBaseUrl="OpenAI Chat base URL is required":Fe(k.trim())||(_.openaiBaseUrl="Invalid URL format")),j&&R&&(D.trim()===""?_.openaiResponsesBaseUrl="OpenAI Responses base URL is required":Fe(D.trim())||(_.openaiResponsesBaseUrl="Invalid URL format")),F.trim()&&!Fe(F.trim())&&(_.modelMetadataUrl="Invalid URL format"),b.forEach((L,V)=>{const se=Fo(L.contextWindow),ce=Jc(L.outputLimit);L.contextWindow.trim()!==""&&se===null&&(_[`modelMetadata.${V}.contextWindow`]="Context window must be a positive number, optionally using K or M"),L.outputLimit.trim()!==""&&ce===null&&(_[`modelMetadata.${V}.outputLimit`]="Output limit must be a positive integer"),se!==null&&ce!==null&&ce>se&&(_[`modelMetadata.${V}.outputLimit`]="Output limit should not exceed context window")}),me(_),Object.keys(_).length===0}function Fe(_){try{return new URL(_),!0}catch{return!1}}function Me(_,L){g(V=>{const se=[...V];return se[_]=L,se})}function Le(_,L){y(V=>{const se=[...V];return se[_]={...se[_]??Sn(),...L},se})}function B(_,L){switch(L){case xi:Le(_,{contextWindow:"",contextWindowMode:"unset"});return;case rr:{const V=b[_]??Sn();Le(_,{contextWindow:V.contextWindow,contextWindowMode:"custom"});return}default:Le(_,{contextWindow:L,contextWindowMode:"preset"});return}}function ne(_,L){const V=b[_]??Sn(),se=_a(V.contextWindow);Le(_,{contextWindow:Kc(L,se.unit),contextWindowMode:"custom"})}function ye(_,L){const V=b[_]??Sn(),se=_a(V.contextWindow);switch(L){case"K":case"M":case"tokens":Le(_,{contextWindow:Kc(se.amount,L),contextWindowMode:"custom"});return;default:return}}function he(_){g(L=>L.filter((V,se)=>se!==_)),y(L=>L.filter((V,se)=>se!==_))}function we(){g(_=>[..._,""]),y(_=>[..._,Sn()])}function Be(){const _=new Date().toISOString(),L=[];return h.forEach((V,se)=>{const ce=V.trim();if(ce==="")return;const Q=b[se]??Sn(),pe=Fo(Q.contextWindow),ae=Jc(Q.outputLimit);if(pe===null&&ae===null)return;const ht=Mf(e,ce);if(ht!==null&&ht.contextWindow===(pe??void 0)&&ht.outputLimit===(ae??void 0)){L.push({...ht,model:ce});return}const hn={model:ce,source:"manual",updatedAt:_};pe!==null&&(hn.contextWindow=pe),ae!==null&&(hn.outputLimit=ae),L.push(hn)}),L.length>0?L:e?.modelMetadata!==void 0?[]:void 0}function G(_){if(_.preventDefault(),!ct())return;be(!0);const L=e!==void 0;try{n({name:r.trim(),apiKey:i.trim(),models:h.map(V=>V.trim()).filter(V=>V!==""),anthropicBaseUrl:ka(w,P,L),openaiBaseUrl:ka(j&&N,k,L),openaiResponsesBaseUrl:ka(j&&R,D,L),apiDocsUrl:J.trim()||void 0,modelMetadataUrl:F.trim()||void 0,modelMetadata:Be(),source:Y})}finally{be(!1)}}return t.jsxs("form",{onSubmit:G,className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-name",className:"text-sm font-medium",children:["Name ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsx("input",{id:"provider-name",type:"text",value:r,onChange:_=>a(_.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&&t.jsx("p",{className:"text-xs text-destructive",children:W.name})]}),t.jsxs("fieldset",{className:"space-y-3",children:[t.jsxs("legend",{className:"text-sm font-medium",children:["Capabilities ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"divide-y divide-border overflow-hidden rounded-md border border-border",children:[t.jsxs("div",{className:j?"bg-primary/[0.04] px-3 py-3":"px-3 py-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai",className:"flex cursor-pointer items-start gap-3",children:[t.jsx("input",{id:"provider-capability-openai",type:"checkbox",checked:j,onChange:_=>S(_.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"OpenAI"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Chat Completions and Responses"})]})]}),j&&t.jsxs("div",{className:"ml-7 mt-3 flex flex-wrap gap-x-5 gap-y-2 border-t border-border/70 pt-3",children:[t.jsxs("label",{htmlFor:"provider-capability-openai-chat",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-chat",type:"checkbox",checked:N,onChange:_=>C(_.target.checked),className:"size-4 shrink-0 accent-primary"}),"Chat Completions"]}),t.jsxs("label",{htmlFor:"provider-capability-openai-responses",className:"flex cursor-pointer items-center gap-2 text-sm",children:[t.jsx("input",{id:"provider-capability-openai-responses",type:"checkbox",checked:R,onChange:_=>I(_.target.checked),className:"size-4 shrink-0 accent-primary"}),"Responses"]})]}),W.openaiCapabilities!==void 0&&j&&t.jsx("p",{className:"ml-7 mt-2 text-xs text-destructive",children:W.openaiCapabilities})]}),t.jsxs("label",{htmlFor:"provider-capability-anthropic",className:`flex cursor-pointer items-start gap-3 px-3 py-3 ${w?"bg-primary/[0.04]":""}`,children:[t.jsx("input",{id:"provider-capability-anthropic",type:"checkbox",checked:w,onChange:_=>v(_.target.checked),className:"mt-0.5 size-4 shrink-0 accent-primary"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-sm font-medium",children:"Anthropic"}),t.jsx("span",{className:"block text-xs text-muted-foreground",children:"Messages"})]})]})]}),W.capabilities!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.capabilities})]}),(w||j&&(N||R))&&t.jsxs("section",{className:"space-y-5 border-l border-border pl-4","aria-label":"API endpoints",children:[t.jsx("h3",{className:"text-sm font-medium",children:"Endpoint Configuration"}),w&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-anthropic-base-url",className:"text-sm font-medium",children:["Anthropic Messages Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.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:[t.jsx("input",{id:"provider-anthropic-base-url",type:"text",value:P,onChange:_=>{Ne(!0),M(_.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"}),t.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:yo})]}),W.anthropicBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.anthropicBaseUrl}),t.jsx(Ta,{baseUrl:P,endpoint:yo,providerName:r})]}),j&&N&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-base-url",className:"text-sm font-medium",children:["OpenAI Chat Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.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:[t.jsx("input",{id:"provider-openai-base-url",type:"text",value:k,onChange:_=>{le(!0),A(_.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"}),t.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:wo})]}),W.openaiBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.openaiBaseUrl}),t.jsx(Ta,{baseUrl:k,endpoint:wo,providerName:r})]}),j&&R&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-openai-responses-base-url",className:"text-sm font-medium",children:["OpenAI Responses Base URL ",t.jsx("span",{className:"text-destructive",children:"*"})]}),t.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:[t.jsx("input",{id:"provider-openai-responses-base-url",type:"text",value:D,onChange:_=>{ve(!0),$(_.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"}),t.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:jo})]}),W.openaiResponsesBaseUrl!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.openaiResponsesBaseUrl}),t.jsx(Ta,{baseUrl:D,endpoint:jo,providerName:r})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-source",className:"text-sm font-medium",children:"Token Source"}),t.jsxs("select",{id:"provider-source",value:Y??"",onChange:_=>U(_.target.value==="company"||_.target.value==="personal"?_.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:[t.jsx("option",{value:"",children:"Unspecified"}),t.jsx("option",{value:"personal",children:"个人 (Personal)"}),t.jsx("option",{value:"company",children:"公司 (Company)"})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Label whether this API key is company-provided or personal."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-model-metadata-url",className:"text-sm font-medium",children:"Model Metadata URL"}),t.jsx("input",{id:"provider-model-metadata-url",type:"text",value:F,onChange:_=>H(_.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&&t.jsx("p",{className:"text-xs text-destructive",children:W.modelMetadataUrl}),F.trim()===""&&t.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&&!Ze&&F.trim()===""&&t.jsx("p",{className:"text-xs text-status-watch",children:"This provider has no matching context metadata yet."}),F.trim()!==""&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent Inspector will refresh model limits from this JSON registry after save."})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{htmlFor:"provider-apikey",className:"text-sm font-medium",children:["API Key ",e===void 0&&t.jsx("span",{className:"text-destructive",children:"*"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-apikey",type:d?"text":"password",value:i,onChange:_=>c(_.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"}),t.jsx("button",{type:"button",onClick:()=>m(_=>!_),className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":d?"Hide API key":"Show API key",children:d?t.jsx(U0,{className:"size-4"}):t.jsx(ru,{className:"size-4"})}),t.jsx("button",{type:"button",onClick:Bt,className:"text-muted-foreground hover:text-foreground transition-colors p-1 shrink-0","aria-label":"Copy API key",children:u?t.jsx(Oe,{className:"size-4 text-status-success"}):t.jsx(St,{className:"size-4"})})]}),e!==void 0&&i.trim()===""&&t.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&&t.jsx("p",{className:"text-xs text-destructive",children:W.apiKey})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:"text-sm font-medium",children:["Models ",t.jsx("span",{className:"text-destructive",children:"*"})]}),h.map((_,L)=>{const V=b[L]??Sn(),se=W[`modelMetadata.${L}.contextWindow`],ce=W[`modelMetadata.${L}.outputLimit`],Q=Yk(V),pe=_a(V.contextWindow);return t.jsxs("div",{ref:ae=>{te.current[L]=ae},className:"border border-border bg-card shadow-sm space-y-2 rounded-[8px] p-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx("input",{type:"text",value:_,onChange:ae=>Me(L,ae.target.value),placeholder:Pe.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"}),Pe.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>oe(z===L?null:L),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:t.jsx(Ve,{className:"size-4"})}),z===L&&t.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:Pe.map(ae=>t.jsx("button",{type:"button",onClick:()=>{Me(L,ae),oe(null)},className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/60",children:ae},ae))})]})]}),h.length>1&&t.jsx("button",{type:"button",onClick:()=>he(L),className:"text-muted-foreground hover:text-destructive transition-colors p-1 shrink-0","aria-label":"Remove model",children:t.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:[t.jsx("path",{d:"M3 6h18"}),t.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),t.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Context Window"}),t.jsxs(Fs,{value:Q,onValueChange:ae=>B(L,ae),children:[t.jsx(Us,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(or,{})}),t.jsxs(Bs,{className:"max-h-64",children:[t.jsx(Xe,{value:xi,children:"Not set"}),Rf.map(ae=>t.jsxs(Xe,{value:ae.value,children:[ae.label," · ",ae.value]},ae.value)),t.jsx(Xe,{value:rr,children:"Custom"})]})]}),V.contextWindowMode==="custom"&&t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_5.75rem] gap-1.5",children:[t.jsx("input",{type:"text",inputMode:"decimal",value:pe.amount,onChange:ae=>ne(L,ae.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]"}),t.jsxs(Fs,{value:pe.unit,onValueChange:ae=>ye(L,ae),children:[t.jsx(Us,{size:"sm",className:"w-full bg-background font-mono text-xs",children:t.jsx(or,{})}),t.jsxs(Bs,{children:[t.jsx(Xe,{value:"K",children:"K"}),t.jsx(Xe,{value:"M",children:"M"}),t.jsx(Xe,{value:"tokens",children:"tokens"})]})]})]}),se!==void 0&&t.jsx("span",{className:"block text-destructive",children:se})]}),t.jsxs("label",{className:"space-y-1 text-xs text-muted-foreground",children:[t.jsx("span",{children:"Output Limit"}),t.jsx("input",{type:"number",min:1,step:1e3,value:V.outputLimit,onChange:ae=>Le(L,{outputLimit:ae.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]"}),ce!==void 0&&t.jsx("span",{className:"block text-destructive",children:ce})]})]})]},L)}),t.jsx("button",{type:"button",onClick:we,className:"text-xs text-primary hover:underline flex items-center gap-1",children:"+ Add Model"}),W.models!==void 0&&t.jsx("p",{className:"text-xs text-destructive",children:W.models})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:"provider-api-docs-url",className:"text-sm font-medium",children:"API Docs URL"}),t.jsx("input",{id:"provider-api-docs-url",type:"text",value:J,onChange:_=>X(_.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"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional API documentation URL. If not set, uses known provider docs."})]}),t.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:[t.jsx(ee,{type:"button",variant:"outline",onClick:s,disabled:ge,children:"Cancel"}),t.jsx(ee,{type:"submit",disabled:ge,children:ge?"Saving...":e?"Update Provider":"Add Provider"})]})]})}const Qk=ue(["timeout","network_unreachable","connection_refused","auth_failed","rate_limited","server_error","invalid_response","unknown"]),e3=T({message:x(),type:Qk,details:x().optional(),hint:x().optional()}),t3=T({type:ue(["text","thinking"]),text:x().optional(),thinking:x().optional()}),n3=T({requestUrl:x().optional(),requestMethod:x().optional(),requestHeaders:ze(x(),x()).optional(),requestBody:x().optional(),responseStatus:E().optional(),responseStatusText:x().optional(),responseHeaders:ze(x(),x()).optional(),responseBody:x().optional()}),s3=T({success:_e(),error:e3.optional(),model:x().optional(),inputTokens:E().optional(),outputTokens:E().optional(),cacheCreationInputTokens:E().optional(),cacheReadInputTokens:E().optional(),latencyMs:E().optional(),firstChunkMs:E().nullable().optional(),totalStreamMs:E().nullable().optional(),tokensPerSecond:E().nullable().optional(),content:K(t3).optional(),rawResponse:x().optional(),streaming:_e().optional(),streamingChunks:T({chunks:K(Dd),truncated:_e().default(!1)}).optional(),requestHeaders:ze(x(),x()).optional(),debug:n3.optional()}),Yc=Ot([s3,T({notConfigured:re(!0)}),T({testing:re(!0)})]),on=T({nonStreaming:Yc,streaming:Yc});function ar(){return{nonStreaming:{notConfigured:!0},streaming:{notConfigured:!0}}}const o3=T({anthropic:on,openai:on.optional(),openaiChat:on.optional(),openaiResponses:on.optional()}).transform(e=>{const n=e.openaiChat??e.openai??ar();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??ar()}}),r3=T({anthropic:on,openai:on.optional(),openaiChat:on.optional(),openaiResponses:on.optional(),models:ze(x(),o3).optional(),testedAt:x().optional()}).transform(e=>{const n=e.openaiChat??e.openai??ar();return{...e,openai:e.openai??n,openaiChat:n,openaiResponses:e.openaiResponses??ar()}});function a3(){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 Xc(e,n){const s=()=>({nonStreaming:{success:!1,error:{message:e,type:n}},streaming:{notConfigured:!0}});return{anthropic:s(),openai:s(),openaiChat:s(),openaiResponses:s()}}const i3=T({providerConfig:x()}),l3=T({success:_e().optional(),imported:E().optional(),message:x().optional(),errors:K(x()).optional()}),c3=T({provider:Vo,imported:E(),matchedModels:K(x()),missingModels:K(x()),sourceUrl:x()}),So="Network error: could not reach the server. Is the proxy running?",d3=5e3,u3=5e3,Zc=15e3,m3=1e4,p3=2e4,f3=2e4,h3=3e4;function Ea(e,n){return(e?.length??0)>0?e:n&&e!==void 0?"":void 0}function Qc(e,n=!1){return{name:e.name,...e.apiKey.trim()===""?{}:{apiKey:e.apiKey},models:e.models,anthropicBaseUrl:Ea(e.anthropicBaseUrl,n),openaiBaseUrl:Ea(e.openaiBaseUrl,n),openaiResponsesBaseUrl:Ea(e.openaiResponsesBaseUrl,n),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 x3(e,n){const s=e?.models?.map(o=>o.trim()).filter(o=>o!=="").length??0;return Math.max(1,s)*n}async function g3(e,n){if(n.models!==void 0)try{await Xn(`/api/providers/${e}/test/log`,u3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}catch{}}function b3({externalProviders:e,isLoading:n=!1,externalTestResults:s,externalTestingProviders:o,externalTestingTimeLeft:r,onProvidersMutate:a,onTestResultsChange:i,onTestingProvidersChange:c,onTestingTimeLeftChange:d}){const[m,u]=l.useState(!1),[p,f]=l.useState(),[h,g]=l.useState(null),[b,y]=l.useState({}),[w,v]=l.useState(new Set),[j,S]=l.useState({}),[N,C]=l.useState(null),[R,I]=l.useState(!1),[P,M]=l.useState(null),[k,A]=l.useState(!1),[D,$]=l.useState(!1),[J,X]=l.useState(null),[F,H]=l.useState("all"),[Y,U]=l.useState(new Set),{providerTestTimeoutSeconds:W}=Li(),me=l.useRef(null),ge=l.useRef(null),be=e??[],z=l.useMemo(()=>{const B=F==="all"?be:be.filter(ne=>ne.source===F);return F==="all"?[...B].sort((ne,ye)=>{const he={personal:0,company:1};return(he[ne.source??""]??2)-(he[ye.source??""]??2)}):B},[be,F]),oe=s??b,te=o??w,Se=r??j,Ne=d?(B,ne)=>d(B,ne):(B,ne)=>{S(ne===void 0?ye=>{const he={...ye};return delete he[B],he}:ye=>({...ye,[B]:ne}))};l.useEffect(()=>{(async()=>{try{const B=await De("/api/config/paths",i3,d3);C(B.providerConfig)}catch{}})()},[]);const ie=l.useCallback(B=>{ge.current!==null&&clearTimeout(ge.current),M(B),me.current?.scrollTo({top:me.current.scrollHeight,behavior:"smooth"}),ge.current=setTimeout(()=>{M(null),ge.current=null},2e3)},[]);l.useEffect(()=>()=>{ge.current!==null&&clearTimeout(ge.current)},[]);const le=l.useCallback(()=>{a?.().catch(()=>{})},[a]),fe=l.useCallback((B,ne)=>{i?i(B,ne):y(ye=>({...ye,[B]:ne}))},[i]),ve=l.useCallback((B,ne)=>{if(c){c(B,ne);return}v(ye=>{const he=new Set(ye);return ne?he.add(B):he.delete(B),he})},[c]),Ce=l.useCallback(async B=>{fe(B,a3()),ve(B,!0);const ne=new AbortController,ye=be.find(G=>G.id===B),he=x3(ye,W);let we=he;Ne(B,we);const Be=setInterval(()=>{we--,Ne(B,we),we<=0&&(clearInterval(Be),ne.abort())},1e3);try{const G=await De(`/api/providers/${B}/test`,r3,he*1e3+1e3,{method:"POST",signal:ne.signal},_=>`HTTP ${_.status}: ${_.statusText}`);fe(B,G),await g3(B,G)}catch(G){const _=G instanceof Error&&G.name==="AbortError",L=G instanceof ji;_||L?fe(B,Xc("Request timed out","timeout")):G instanceof Error&&fe(B,Xc(G.message,"server_error"))}finally{clearInterval(Be),Ne(B,void 0),ve(B,!1)}},[W,be,Ne,fe,ve]),Ie=l.useCallback(async(B,ne,ye=!0)=>{U(he=>{const we=new Set(he);return we.add(B),we});try{const he=ne!==void 0&&ne.trim()!==""?{url:ne}:{},we=await De(`/api/providers/${B}/model-metadata`,c3,h3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)},()=>"Failed to refresh model metadata");return we.imported===0&&ye?g("No matching model metadata found for this provider."):g(null),ie(we.provider.id),le(),we.imported>0}catch(he){return ye&&g(he instanceof Error?he.message:So),!1}finally{U(he=>{const we=new Set(he);return we.delete(B),we})}},[le,ie]);function $e(B){(async()=>{try{const ne=await De("/api/providers",Vo,Zc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qc(B))},()=>"Failed to add provider");u(!1),ie(ne.id),B.modelMetadataUrl!==void 0&&B.modelMetadataUrl.trim()!==""&&await Ie(ne.id,B.modelMetadataUrl,!1),le(),await Ce(ne.id)}catch(ne){g(ne instanceof Error?ne.message:So)}})()}function Pe(B){p&&(async()=>{try{const ne=await De(`/api/providers/${p.id}`,Vo,Zc,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Qc(B,!0))},()=>"Failed to update provider");f(void 0),ie(ne.id),B.modelMetadataUrl!==void 0&&B.modelMetadataUrl.trim()!==""&&await Ie(ne.id,B.modelMetadataUrl,!1),le(),(B.apiKey.trim()!==""||JSON.stringify(B.models)!==JSON.stringify(p.models)||(B.anthropicBaseUrl??"")!==(p.anthropicBaseUrl??"")||(B.openaiBaseUrl??"")!==(p.openaiBaseUrl??"")||(B.openaiResponsesBaseUrl??"")!==(p.openaiResponsesBaseUrl??""))&&await Ce(ne.id)}catch(ne){g(ne instanceof Error?ne.message:So)}})()}function Ze(B){X(B),$(!0)}function Bt(){const B=J;B!==null&&(async()=>{let ne;try{ne=await Xn(`/api/providers/${B}`,m3,{method:"DELETE"})}catch{g(So);return}if(!ne.ok){g(await _h(ne,"Failed to delete provider"));return}le()})()}const ct=l.useRef(null);function Fe(B){const ne="/api/providers/export";(async()=>{try{const ye=await Xn(ne,p3);if(!ye.ok){g("Failed to export providers");return}const he=await ye.blob(),we=URL.createObjectURL(he),Be=document.createElement("a");Be.href=we,Be.download=ye.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]??"providers.json",document.body.appendChild(Be),Be.click(),document.body.removeChild(Be),URL.revokeObjectURL(we)}catch{g("Failed to export providers")}})()}function Me(){ct.current?.click()}function Le(B){const ne=B.target.files?.[0];ne&&(async()=>{try{const ye=await ne.text(),he=await Xn("/api/providers/import",f3,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ye)}),we=await kh(he,l3);he.ok&&we.imported!==void 0&&we.imported>0?(le(),g(null)):we.errors&&we.errors.length>0?g(we.errors.join("; ")):g(we.message??"Import failed")}catch{g("Failed to import providers")}B.target.value=""})()}return n?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading providers..."})}):m||p?t.jsxs("div",{className:"space-y-4",children:[t.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:t.jsx("h3",{className:"text-lg font-medium",children:p?"Edit Provider":"Add New Provider"})}),t.jsx(Zk,{provider:p,onSubmit:p?Pe:$e,onCancel:()=>{u(!1),f(void 0)}})]}):t.jsxs("div",{className:"space-y-4",children:[t.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:[t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>Fe(),className:"gap-1 hover:bg-muted",children:[t.jsx(Vs,{className:"size-3"}),"Export"]}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:Me,className:"gap-1 hover:bg-muted",children:[t.jsx(fu,{className:"size-3"}),"Import"]}),t.jsx("input",{type:"file",ref:ct,accept:".json",onChange:Le,style:{display:"none"}}),t.jsxs(ee,{variant:"outline",size:"sm",onClick:()=>A(!0),className:"gap-1",children:[t.jsx(Jg,{className:"size-3"}),"Scan"]}),t.jsxs(ee,{onClick:()=>u(!0),size:"sm",className:"gap-1",children:[t.jsx(Bl,{className:"size-4"}),"Add Provider"]})]}),N!==null&&t.jsxs("div",{className:"flex items-center gap-2 rounded-[8px] bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx("span",{className:"font-mono truncate",title:N,children:N}),t.jsx("button",{type:"button",onClick:()=>{vt(N).then(B=>{B&&(I(!0),setTimeout(()=>I(!1),2e3))})},className:"ml-auto shrink-0 text-muted-foreground transition-colors hover:text-foreground","aria-label":R?"Copied config file path":"Copy config file path",children:R?t.jsx(Oe,{className:"size-3 text-status-success"}):t.jsx(St,{className:"size-3"})})]}),h!==null&&t.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:[t.jsx(os,{className:"size-4 shrink-0"}),h]}),be.length===0?t.jsxs("div",{className:"border border-border bg-card shadow-sm space-y-3 rounded-[8px] py-12 text-center",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:"No providers configured yet."}),t.jsxs(ee,{onClick:()=>u(!0),variant:"outline",size:"sm",children:[t.jsx(Bl,{className:"size-4"}),"Add Your First Provider"]})]}):t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"inline-flex w-fit gap-1 rounded-[8px] bg-muted/20 p-1",children:["all","personal","company"].map(B=>t.jsx("button",{type:"button",onClick:()=>H(B),className:`rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${F===B?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:B==="all"?"All":B==="personal"?"Personal":"Company"},B))}),t.jsx("div",{ref:me,className:"space-y-3",children:z.map(B=>t.jsx(Fk,{provider:B,testResults:oe[B.id],isTesting:te.has(B.id),testingTimeLeft:Se[B.id],isHighlighted:B.id===P,onEdit:ne=>f(ne),onDelete:Ze,onRefreshMetadata:ne=>{Ie(ne)},isRefreshingMetadata:Y.has(B.id),onTest:ne=>{Ce(ne)}},B.id))})]}),t.jsx(xk,{open:k,onOpenChange:A,onImportComplete:()=>{a!==void 0&&a()}}),t.jsx($p,{open:D,onOpenChange:$,title:"Delete Provider",description:"Are you sure you want to delete this provider? This action cannot be undone.",confirmLabel:"Delete",variant:"destructive",onConfirm:Bt})]})}const v3=[{value:"providers",label:"Providers"},{value:"proxy",label:"Proxy"},{value:"storage",label:"Storage"},{value:"mcp",label:"MCP"},{value:"onboarding",label:"Onboarding"}];function y3(){return t.jsx(tf,{"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:v3.map(e=>t.jsx(tn,{value:e.value,className:"min-w-0 w-full",children:e.label},e.value))})}function w3(){const[e,n]=l.useState(!1),[s,o]=l.useState("providers"),{providers:r,isLoading:a,mutate:i}=Wi(),[c,d]=l.useState({}),[m,u]=l.useState(new Set),[p,f]=l.useState({}),h=l.useCallback((y,w)=>{d(v=>({...v,[y]:w}))},[]),g=l.useCallback((y,w)=>{u(v=>{const j=new Set(v);return w?j.add(y):j.delete(y),j})},[]),b=l.useCallback((y,w)=>{f(v=>{if(w===void 0){const j={...v};return delete j[y],j}return{...v,[y]:w}})},[]);return t.jsxs(Pt,{open:e,onOpenChange:n,children:[t.jsx(Zs,{asChild:!0,children:t.jsxs(ee,{variant:"ghost",size:"icon",className:to,"aria-label":"Settings",title:"Settings",children:[t.jsx(s1,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:"Settings"})]})}),t.jsxs(Lt,{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:[t.jsx(Ft,{children:t.jsx(Ut,{children:"Settings"})}),t.jsxs(ef,{value:s,onValueChange:o,className:"min-h-0 min-w-0 flex-1 overflow-hidden",children:[t.jsx(y3,{}),t.jsxs("div",{className:"mt-4 min-w-0 flex-1 overflow-x-hidden overflow-y-auto pr-1 sm:pr-2",children:[t.jsx(ut,{value:"providers",children:t.jsx(b3,{externalProviders:r,isLoading:a,externalTestResults:c,externalTestingProviders:m,externalTestingTimeLeft:p,onProvidersMutate:()=>i(),onTestResultsChange:h,onTestingProvidersChange:g,onTestingTimeLeftChange:b})}),t.jsx(ut,{value:"proxy",children:t.jsx(_3,{})}),t.jsx(ut,{value:"storage",children:t.jsx(N3,{})}),t.jsx(ut,{value:"mcp",children:t.jsx(k3,{})}),t.jsx(ut,{value:"onboarding",children:t.jsx(C3,{})})]})]})]})]})}const j3=T({memoryCount:E(),logDir:x(),logFileCount:E(),logBytes:E(),chunkDir:x(),chunkFileCount:E(),chunkBytes:E(),sessionArchiveDir:x(),sessionArchiveFileCount:E(),sessionArchiveBytes:E()}),S3=1e4;function Ra(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 N3(){const[e,n]=l.useState(null),[s,o]=l.useState(null),[r,a]=l.useState(!1),[i,c]=l.useState(null),d=l.useCallback(async()=>{a(!0),o(null);try{const u=await De("/api/logs?stats=1",j3,S3,void 0,p=>`Failed to load storage stats: HTTP ${String(p.status)}`);n(u)}catch(u){o(u instanceof Error?u.message:String(u))}finally{a(!1)}},[]);l.useEffect(()=>{d()},[d]);const m=l.useCallback((u,p)=>{vt(p).then(f=>{f&&(c(u),setTimeout(()=>c(null),1600))})},[]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Log storage"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Inspect local log and streaming chunk footprint before exporting or clearing sessions."})]}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:()=>{d()},children:r?"Refreshing...":"Refresh"})]}),e!==null&&t.jsxs("div",{className:"grid gap-2 text-xs",children:[t.jsx(Es,{id:"log-dir",label:"Log storage path",value:e.logDir,copiedId:i,onCopy:m}),t.jsx(Es,{id:"chunk-dir",label:"Streaming chunks storage path",value:e.chunkDir,copiedId:i,onCopy:m}),t.jsx(Es,{id:"session-archive-dir",label:"Session archive storage path",value:e.sessionArchiveDir,copiedId:i,onCopy:m}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"In-memory logs"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.memoryCount.toLocaleString()," loaded"]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Log files"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.logFileCount.toLocaleString()," files / ",Ra(e.logBytes)]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Streaming chunks"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.chunkFileCount.toLocaleString()," files / ",Ra(e.chunkBytes)]})]}),t.jsxs("div",{className:"rounded-md bg-muted/20 px-3 py-2",children:[t.jsx("div",{className:"font-medium",children:"Session archives"}),t.jsxs("div",{className:"mt-1 font-mono text-muted-foreground",children:[e.sessionArchiveFileCount.toLocaleString()," files /"," ",Ra(e.sessionArchiveBytes)]})]})]}),s!==null&&t.jsx("p",{className:"text-xs text-destructive",children:s})]})}function Es({id:e,label:n,value:s,copiedId:o,onCopy:r}){const a=o===e;return t.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:[t.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:n}),t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",title:s,children:s}),t.jsx(ee,{type:"button",variant:"ghost",size:"icon",className:"size-7 shrink-0",onClick:()=>r(e,s),"aria-label":a?`Copied ${n}`:`Copy ${n}`,children:a?t.jsx(Oe,{className:"size-3.5 text-status-success"}):t.jsx(St,{className:"size-3.5"})})]})]})}function C3(){const[e,n]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Fi(o),[]);const r=l.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:"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"},...s===null?[]:[{id:"opencode-proxy",label:"OpenCode proxy",value:`LLM_BASE_URL=${s.proxy}`},{id:"mimo-proxy",label:"MiMo Code proxy",value:`OPENAI_BASE_URL=${s.openAiV1}`},{id:"mcp",label:"MCP URL",value:s.mcp},{id:"proxy",label:"Proxy URL",value:s.proxy},{id:"anthropic",label:"Anthropic base",value:`ANTHROPIC_BASE_URL=${s.proxy}`},{id:"openai",label:"OpenAI base",value:`OPENAI_BASE_URL=${s.openAiV1}`}]],[s]),a=l.useCallback((i,c)=>{vt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(In,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"Agent onboarding"})]}),t.jsx("div",{className:"grid gap-2",children:r.map(i=>t.jsx(Es,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oe,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Provider test creates a traceable memory probe session."})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Oe,{className:"size-3.5 text-status-success"}),t.jsx("span",{children:"Captured sessions can produce reviewable memory candidates."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["Streamable HTTP clients should use the MCP URL directly. Stdio-only clients should use",t.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."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["OpenCode onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode.json"}),", then verify with"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"opencode mcp list"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.jsxs("span",{children:["MiMo Code onboarding safely merges"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"mcp.agent-inspector"})," ","into"," ",t.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"," ",t.jsx("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-[11px] text-foreground",children:"OPENAI_BASE_URL"}),"."]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Oe,{className:"mt-0.5 size-3.5 text-status-success"}),t.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 k3(){const[e,n]=l.useState(null),[s,o]=l.useState(null);l.useEffect(()=>Fi(i=>{o(i?.mcp??null)}),[]);const r=l.useMemo(()=>s===null?[]:[{id:"mcp-url",label:"Streamable HTTP MCP URL",value:s},{id:"stdio",label:"Stdio bridge command",value:`agent-inspector-mcp stdio --url ${s}`},{id:"doctor",label:"Bridge doctor",value:`agent-inspector-mcp doctor --url ${s}`},{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:s}}},null,2)},{id:"stdio-json",label:"Stdio MCP JSON",value:JSON.stringify({mcpServers:{"agent-inspector":{command:"agent-inspector-mcp",args:["stdio","--url",s]}}},null,2)},{id:"opencode-local",label:"OpenCode local MCP",value:JSON.stringify({mcp:{"agent-inspector":{type:"local",command:["agent-inspector-mcp","stdio","--url",s],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",s],enabled:!0}}},null,2)},{id:"codex-toml",label:"Codex TOML",value:`[mcp_servers.agent-inspector]
|
|
58
|
+
command = "agent-inspector-mcp"
|
|
59
|
+
args = ["stdio", "--url", "${s}"]`}],[s]),a=l.useCallback((i,c)=>{vt(c).then(d=>{d&&(n(i),setTimeout(()=>n(null),1600))})},[]);return t.jsxs("div",{className:"min-w-0 space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(In,{className:"size-4 text-muted-foreground"}),t.jsx("h3",{className:"text-sm font-semibold",children:"MCP access"})]}),t.jsxs("div",{className:"grid gap-2 rounded-md bg-muted/15 px-3 py-2 text-xs text-muted-foreground",children:[t.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."}),t.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===null?t.jsx("div",{role:"alert",className:"rounded-md bg-destructive/10 px-3 py-2 text-xs text-destructive",children:"The browser runtime does not provide a valid agent-facing MCP endpoint."}):t.jsx("div",{className:"grid gap-2",children:r.map(i=>t.jsx(Es,{id:i.id,label:i.label,value:i.value,copiedId:e,onCopy:a},i.id))})]})}function _3(){const{strip:e,slowResponseThresholdSeconds:n,providerTestTimeoutSeconds:s,timeDisplayFormat:o,isLoading:r,setStrip:a,setSlowResponseThresholdSeconds:i,setProviderTestTimeoutSeconds:c,setTimeDisplayFormat:d}=Li(),[m,u]=l.useState(null),[p,f]=l.useState(!1),h=l.useCallback(async w=>{u(null),f(!0);try{await a(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[a]),g=l.useCallback(async w=>{u(null),f(!0);try{await i(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[i]),b=l.useCallback(async w=>{u(null),f(!0);try{await c(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[c]),y=l.useCallback(async w=>{u(null),f(!0);try{await d(w)}catch(v){u(v instanceof Error?v.message:String(v))}finally{f(!1)}},[d]);return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Claude Code billing header"}),t.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 ",t.jsx("code",{children:"config.json"}),"."]})]}),t.jsxs("label",{className:"flex items-center gap-3",children:[t.jsx("input",{type:"checkbox",role:"switch",checked:e,disabled:r||p,onChange:w=>{h(w.currentTarget.checked)},className:"size-4 cursor-pointer disabled:cursor-not-allowed disabled:opacity-50"}),t.jsx("span",{className:"text-sm",children:r?"Loading...":e?"Stripping enabled":"Stripping disabled"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"slow-response-threshold",className:"text-sm font-semibold",children:"Slow response threshold"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Show a slow marker when elapsed time exceeds this many seconds. Use ",t.jsx("code",{children:"0"})," to disable it."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"slow-response-threshold",type:"number",min:0,max:za,step:1,value:n,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<0||v>za||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"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"provider-test-timeout",className:"text-sm font-semibold",children:"Provider test timeout"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Abort slow Provider Test probes after this many seconds per model."}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{id:"provider-test-timeout",type:"number",min:1,max:$a,step:1,value:s,disabled:r||p,onChange:w=>{const v=Number(w.currentTarget.value);Number.isInteger(v)&&(v<1||v>$a||b(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"}),t.jsx("span",{className:"text-xs text-muted-foreground",children:"seconds / model"})]})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{htmlFor:"time-display-format",className:"text-sm font-semibold",children:"Time display"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Controls timestamps in session summaries, headers, and log rows."}),t.jsxs("select",{id:"time-display-format",value:o,disabled:r||p,onChange:w=>{const v=eu.safeParse(w.currentTarget.value);v.success&&y(v.data)},className:"h-8 rounded-md border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx("option",{value:"time",children:"Time only"}),t.jsx("option",{value:"full",children:"Full ISO"})]})]}),m!==null&&t.jsxs("p",{className:"text-xs text-destructive",children:["Failed to save: ",m]})]})}const T3=ue(["installed","update-available","available","planned","unknown"]),E3=T({id:x(),name:x(),npmName:x(),capability:x(),description:x(),workflow:x(),installCommand:x(),state:T3,installedVersion:x().nullable(),latestVersion:x().nullable(),primary:_e()}),R3=T({id:x(),name:x(),validatedVersion:x(),binary:x(),modelFlag:x(),variantFlag:x().nullable(),tools:K(x()),logDir:x(),skillsDir:x(),agentsDir:x()}),M3=T({id:x(),title:x(),stage:x(),packageId:x(),description:x(),command:x(),requiresSession:_e(),runnable:_e()}),A3=T({checkedAt:x(),packages:K(E3),runnerPresets:K(R3),recipes:K(M3)}),If=ue(["install","upgrade","help","runner-presets","recipe"]),Pf="RUN_LOCAL_COMMAND",I3=T({action:If,targetId:x(),targetName:x(),command:x(),source:x(),timeoutMs:E().int().positive(),scope:x()}),P3=T({nonce:x().uuid(),phrase:re(Pf),expiresAt:x().datetime(),plan:I3}),Lf=T({confirmation:P3});un("intent",[T({intent:re("prepare")}),T({intent:re("confirm"),nonce:x().uuid(),confirmation:re(Pf)})]);const L3=ue(["queued","running","succeeded","failed"]),Of=T({id:x(),packageId:x(),npmName:x(),recipeId:x().nullable().default(null),action:If,status:L3,command:x(),output:x(),createdAt:x(),startedAt:x().nullable(),finishedAt:x().nullable(),exitCode:E().nullable(),error:x().nullable()}),Df=T({task:Of}),O3=T({tasks:K(Of)}),D3=[{id:"observe",title:"Observe",label:"Live",description:"Capture IDE, process, session, turn, request, response, tools, and providers.",metric:"Inspector core",icon:Ox},{id:"replay",title:"Replay",label:"Ready",description:"Promote real logs into repeatable replay evidence without losing the raw context.",metric:"Session asset",icon:yt},{id:"evaluate",title:"Evaluate",label:"Next",description:"Use eval-harness to turn sessions into regression cases and provider bakeoffs.",metric:"Eval loop",icon:Oi},{id:"connect",title:"Connect",label:"MCP",description:"Expose Inspector state to coding agents as queryable context and durable evidence.",metric:"/api/mcp",icon:Tg}];async function z3(e){return Ge(e,A3,void 0,n=>`Failed to load ecosystem packages: ${String(n.status)}`)}async function $3(e){return Ge(e,Df,void 0,n=>`Failed to load ecosystem task: ${String(n.status)}`)}async function F3(e){return Ge(e,O3,void 0,n=>`Failed to load ecosystem tasks: ${String(n.status)}`)}async function U3(e,n){const s=`/api/ecosystem/packages/${encodeURIComponent(e)}/${n}`,o=await Ge(s,Lf,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},r=>`Failed to prepare ecosystem task: ${String(r.status)}`);return{endpoint:s,confirmation:o.confirmation}}async function B3(e){const n=`/api/ecosystem/recipes/${encodeURIComponent(e)}/run`,s=await Ge(n,Lf,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"prepare"})},o=>`Failed to prepare ecosystem recipe: ${String(o.status)}`);return{endpoint:n,confirmation:s.confirmation}}async function q3(e){return(await Ge(e.endpoint,Df,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({intent:"confirm",nonce:e.confirmation.nonce,confirmation:e.confirmation.phrase})},s=>`Failed to start ecosystem task: ${String(s.status)}`)).task}function H3(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 W3(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 V3(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 Rs(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 K3(e){switch(e.status){case"queued":return"Queued";case"running":return`${Rs(e.action)} running`;case"succeeded":return`${Rs(e.action)} complete`;case"failed":return`${Rs(e.action)} failed`}}function zf(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 G3(e){switch(e.state){case"available":return"install";case"update-available":return"upgrade";case"installed":case"planned":case"unknown":return null}}function J3({pkg:e,activeTask:n,onStartTask:s}){const o=G3(e),r=n!==null&&n.packageId===e.id&&n.status==="running";return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(Ag,{className:"size-4 shrink-0 text-white/55"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.jsx("div",{className:"mt-1 break-all font-mono text-[11px] leading-snug text-white/35",children:e.npmName})]}),t.jsx(ke,{className:O("shrink-0",W3(e.state)),variant:"outline",children:H3(e.state)})]}),t.jsx("div",{className:"mt-3 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/50",children:V3(e)}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 text-white/45",children:e.capability}),t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-white/35",children:e.installCommand})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[o!==null&&t.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:r,onClick:()=>s(e.id,o),children:[r?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Vs,{className:"size-3.5"}),Rs(o)]}),t.jsxs(ee,{type:"button",size:"sm",variant:"outline",disabled:r||e.state==="planned",onClick:()=>s(e.id,"help"),children:[t.jsx(In,{className:"size-3.5"}),"Help"]}),e.id==="eval-harness"&&t.jsxs(ee,{type:"button",size:"sm",variant:"ghost",disabled:r||e.state==="planned",onClick:()=>s(e.id,"runner-presets"),children:[t.jsx(Oi,{className:"size-3.5"}),"Presets"]})]})]})}function Y3({task:e}){if(e===null)return null;const n=e.status==="queued"||e.status==="running";return t.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:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[n?t.jsx(Ae,{className:"size-4 animate-spin text-cyan-200/75"}):t.jsx(In,{className:"size-4 text-white/55"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-sm font-semibold",children:K3(e)}),t.jsx("div",{className:"break-all font-mono text-[11px] text-white/35",children:e.command})]})]}),t.jsx(ke,{variant:"outline",className:O("shrink-0",zf(e.status)),children:e.status})]}),t.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&&t.jsx("div",{className:"mt-2 text-xs text-red-100",children:e.error})]})}function X3({workflow:e}){const n=e.icon;return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(n,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold",children:e.title})]}),t.jsx("span",{className:"rounded bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-white/45",children:e.label})]}),t.jsx("div",{className:"mt-2 min-h-10 text-xs leading-5 text-muted-foreground",children:e.description}),t.jsx("div",{className:"mt-3 font-mono text-[11px] text-white/35",children:e.metric})]})}function Z3(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 Q3({preset:e}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(uu,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.name})]}),t.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}`:""]})]}),t.jsxs(ke,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:["v",e.validatedVersion]})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-[11px]",children:[t.jsxs("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:["logs/",e.logDir]}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 text-white/45",children:e.tools.join(", ")}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.skillsDir}),t.jsx("div",{className:"rounded bg-black/15 px-2 py-1 font-mono text-white/35",children:e.agentsDir})]})]})}function e4({recipe:e,copied:n,running:s,onCopy:o,onRun:r}){return t.jsxs("div",{className:"rounded-lg bg-white/[0.025] p-3 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[t.jsx(au,{className:"size-4 shrink-0 text-cyan-200/75"}),t.jsx("div",{className:"text-sm font-semibold leading-snug",children:e.title})]}),t.jsx("div",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:e.description})]}),t.jsx(ke,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:e.runnable?e.stage:"Template"})]}),t.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}),t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"rounded bg-white/[0.035] px-2 py-1 font-mono text-[11px] text-white/35",children:e.packageId}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ee,{type:"button",size:"sm",variant:"outline",onClick:()=>o(e),children:[n?t.jsx(Oe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),n?"Copied":"Copy"]}),e.runnable&&t.jsxs(ee,{type:"button",size:"sm",variant:"secondary",disabled:s,onClick:()=>r(e),children:[s?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(uu,{className:"size-3.5"}),s?"Running":"Run"]})]})]})]})}function t4({task:e,selected:n,onSelect:s}){const o=e.recipeId??Rs(e.action);return t.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:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(lu,{className:"size-3.5 shrink-0 text-white/40"}),t.jsx("div",{className:"truncate text-xs font-semibold text-white/75",children:o}),t.jsx(ke,{variant:"outline",className:O("shrink-0",zf(e.status)),children:e.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-2 font-mono text-[10px] text-white/35",children:[t.jsx("span",{children:e.packageId}),t.jsx("span",{children:new Date(e.createdAt).toLocaleTimeString()}),e.exitCode!==null&&t.jsxs("span",{children:["exit ",String(e.exitCode)]})]})]}),t.jsx(ee,{type:"button",size:"sm",variant:n?"secondary":"outline",onClick:()=>s(e),children:n?"Open":"View"})]})}function n4({pending:e,busy:n,onOpenChange:s,onConfirm:o}){const r=e?.confirmation.plan??null;return t.jsx(Pt,{open:e!==null,onOpenChange:s,children:t.jsxs(Lt,{className:"max-w-xl",children:[t.jsxs(Ft,{children:[t.jsx(Ut,{children:"Confirm local command"}),t.jsx(Qs,{children:"Review the exact allowlisted action Agent Inspector will run on this machine."})]}),r!==null&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid gap-2 text-xs sm:grid-cols-2",children:[t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Source"}),t.jsx("div",{className:"mt-1 break-words font-medium",children:r.source})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3",children:[t.jsx("div",{className:"text-muted-foreground",children:"Timeout"}),t.jsxs("div",{className:"mt-1 font-medium",children:[String(r.timeoutMs/1e3)," seconds"]})]}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-3 sm:col-span-2",children:[t.jsx("div",{className:"text-muted-foreground",children:"Affected scope"}),t.jsx("div",{className:"mt-1 font-medium",children:r.scope})]})]}),t.jsxs("div",{children:[t.jsx("div",{className:"mb-1 text-xs font-medium",children:"Resolved command"}),t.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:r.command})]}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Confirmation phrase: ",t.jsx("code",{children:e?.confirmation.phrase}),". The one-time confirmation expires at"," ",new Date(e?.confirmation.expiresAt??"").toLocaleTimeString(),"."]})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(ee,{type:"button",variant:"outline",disabled:n,onClick:()=>s(!1),children:"Cancel"}),t.jsxs(ee,{type:"button",variant:"secondary",disabled:n||r===null,onClick:o,children:[n?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(In,{className:"size-3.5"}),n?"Starting":"Confirm & Run"]})]})]})})}function s4({currentSessionId:e,logCount:n,labelledTrigger:s=!1}){const[o,r]=l.useState(!1),[a,i]=l.useState(!1),[c,d]=l.useState(!1),[m,u]=l.useState(null),[p,f]=l.useState(null),[h,g]=l.useState(null),[b,y]=l.useState(null),[w,v]=l.useState(!1),j=Et("/api/ecosystem/packages",z3,{revalidateOnFocus:!1,revalidateIfStale:!1}),S=Et(p===null?null:`/api/ecosystem/tasks/${p}`,$3,{refreshInterval:U=>{const W=U?.task;return W!==void 0&&(W.status==="queued"||W.status==="running")?900:0},revalidateOnFocus:!1}),N=Et(o?"/api/ecosystem/tasks":null,F3,{refreshInterval:2500,revalidateOnFocus:!1}),C=j.data?.packages??[],R=j.data?.runnerPresets??[],I=j.data?.recipes??[],P=(N.data?.tasks??[]).slice(0,6),M=l.useMemo(()=>C.filter(U=>U.state==="installed"||U.state==="update-available").length,[C]),k=Z3(e),A="npx @tonyclaw/eval-harness runner-presets",D=()=>{vt(k).then(()=>{i(!0),window.setTimeout(()=>i(!1),1200)})},$=()=>{vt(A).then(()=>{d(!0),window.setTimeout(()=>d(!1),1200)})},J=U=>{vt(U.command).then(()=>{u(U.id),window.setTimeout(()=>u(null),1200)})},X=U=>{g(null),B3(U.id).then(W=>{y(W)}).catch(W=>{g(W instanceof Error?W.message:"Failed to prepare ecosystem recipe")})},F=S.data?.task??null;l.useEffect(()=>{F!==null&&(N.mutate(),F.status==="succeeded"&&j.mutate())},[F,j,N]);const H=(U,W)=>{g(null),U3(U,W).then(me=>{y(me)}).catch(me=>{g(me instanceof Error?me.message:"Failed to prepare ecosystem task")})},Y=()=>{b!==null&&(g(null),v(!0),q3(b).then(U=>{f(U.id),y(null),S.mutate({task:U},{revalidate:!0}),N.mutate()}).catch(U=>{g(U instanceof Error?U.message:"Failed to start ecosystem task")}).finally(()=>{v(!1)}))};return t.jsxs(Pt,{open:o,onOpenChange:r,children:[t.jsx(Zs,{asChild:!0,children:t.jsxs(ee,{variant:"ghost",size:s?"default":"icon",className:O(to,s&&"w-auto gap-2 px-3 text-xs max-lg:h-11 max-lg:w-auto"),"aria-label":"TonyClaw Lab",title:"TonyClaw Lab",children:[t.jsx(au,{className:"size-4"}),t.jsx("span",{className:s?"":"sr-only",children:"Lab"})]})}),t.jsxs(Lt,{className:"flex max-h-[84vh] max-w-5xl flex-col overflow-hidden",children:[t.jsx(Ft,{children:t.jsxs(Ut,{className:"flex items-center gap-2",children:[t.jsx(Ua,{className:"size-4 text-cyan-200/80"}),"TonyClaw Lab"]})}),t.jsxs("div",{className:"overflow-y-auto pr-2",children:[t.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.1fr_0.9fr]",children:[t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Session asset pipeline"}),t.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."})]}),t.jsxs(ke,{variant:"outline",className:"border-cyan-300/20 bg-cyan-300/8 text-cyan-100",children:[String(M),"/",String(C.length)," packages"]})]}),t.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:D3.map(U=>t.jsx(X3,{workflow:U},U.id))})]}),t.jsxs("section",{className:"rounded-lg bg-white/[0.025] p-4 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold",children:"Current session"}),t.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:e===null?"MCP smoke command":e})]}),t.jsxs(ke,{variant:"outline",className:"border-white/10 bg-white/[0.04] text-white/55",children:[String(n)," logs"]})]}),t.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:k}),t.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t.jsxs(ee,{size:"sm",variant:"secondary",onClick:D,children:[a?t.jsx(Oe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"}),a?"Copied":"Copy"]}),t.jsxs(ee,{size:"sm",variant:"outline",onClick:$,children:[t.jsx(Oi,{className:"size-3.5"}),c?"Presets copied":"Runner Presets"]})]})]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Lab recipes"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(Ua,{className:"size-3.5"}),"copy-ready workflows"]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[I.map(U=>t.jsx(e4,{recipe:U,copied:m===U.id,running:F!==null&&F.recipeId===U.id&&(F.status==="queued"||F.status==="running"),onCopy:J,onRun:X},U.id)),j.isLoading&&I.length===0&&[0,1].map(U=>t.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)]"},U))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Runner presets"}),t.jsxs("div",{className:"hidden items-center gap-1 font-mono text-[11px] text-muted-foreground sm:flex",children:[t.jsx(In,{className:"size-3.5"}),A]})]}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-2 xl:grid-cols-4",children:[R.map(U=>t.jsx(Q3,{preset:U},U.id)),j.isLoading&&R.length===0&&[0,1,2,3].map(U=>t.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)]"},U))]})]}),t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"TonyClaw packages"}),j.isLoading&&t.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:"checking npm..."})]}),j.error!==void 0&&t.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."}),t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[C.map(U=>t.jsx(J3,{pkg:U,activeTask:F,onStartTask:H},U.id)),j.isLoading&&C.length===0&&[0,1,2].map(U=>t.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)]"},U))]})]}),h!==null&&t.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}),P.length>0&&t.jsxs("section",{className:"mt-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[t.jsx("div",{className:"text-sm font-semibold",children:"Recent Lab runs"}),t.jsxs("div",{className:"hidden font-mono text-[11px] text-muted-foreground sm:block",children:["last ",String(P.length)]})]}),t.jsx("div",{className:"grid gap-2 md:grid-cols-2",children:P.map(U=>t.jsx(t4,{task:U,selected:p===U.id,onSelect:W=>{f(W.id),S.mutate({task:W},{revalidate:!0})}},U.id))})]}),t.jsx(Y3,{task:F})]})]}),t.jsx(n4,{pending:b,busy:w,onOpenChange:U=>{!U&&!w&&y(null)},onConfirm:Y})]})}function o4(e){return[...new Set(e.evidence.map(n=>n.logId).filter(n=>n!==null))]}const r4=[{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?"}],a4=4e3,Ma=12;function ed(){return{messages:[],question:"",error:null}}function i4(e){return e.filter(n=>n.content.trim().length>0).slice(-10).map(n=>({role:n.role,content:n.content.trim().slice(0,a4)}))}function Ye(e,...n){for(const s of n){const o=Z(e,s);if(typeof o=="string"&&o.trim().length>0)return o}return null}function nn(e,...n){for(const s of n){const o=Z(e,s);if(typeof o=="number"&&Number.isFinite(o))return o}return null}function l4(e,n){const s=Z(e,n);return Array.isArray(s)?s.filter(o=>typeof o=="string").slice(0,8):[]}function c4(e){const n=Ye(e,"source")??"log",s=Ye(e,"id")??"",o=nn(e,"logId","id");if(s===""&&o===null||o!==null&&(!Number.isInteger(o)||o<0))return null;const r=nn(e,"inputTokens"),a=nn(e,"outputTokens"),i=nn(e,"totalTokens","tokenCount"),c=nn(e,"responseStatus","status"),d=Ye(e,"responseStatus","status");return{source:n,id:s!==""?s:String(o),logId:o,sessionId:Ye(e,"sessionId"),timestamp:Ye(e,"timestamp"),model:Ye(e,"model"),providerName:Ye(e,"providerName","provider"),path:Ye(e,"path"),status:c??d,elapsedMs:nn(e,"elapsedMs","latencyMs"),inputTokens:r,outputTokens:a,totalTokens:i??(r===null&&a===null?null:(r??0)+(a??0)),score:nn(e,"score","relevanceScore"),matchedFields:l4(e,"matchedFields"),excerpt:Ye(e,"excerpt","snippet")??"No excerpt available."}}function Aa(e){const n=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return n.length===0?"Metric":`${n[0]?.toUpperCase()??""}${n.slice(1)}`}function td(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 n=e.filter(s=>typeof s=="string"||typeof s=="number"&&Number.isFinite(s)).slice(0,6);return n.length>0?n.join(", "):null}return null}function nd(e){return Object.getOwnPropertyNames(e).map(n=>[n,Z(e,n)])}function sd(e){if(e===null||typeof e!="object"||Array.isArray(e))return[];const n=[];for(const[s,o]of nd(e)){const r=td(o);if(r!==null){if(n.push({key:s,label:Aa(s),value:r}),n.length>=Ma)break;continue}if(!(o===null||typeof o!="object"||Array.isArray(o))){for(const[a,i]of nd(o)){const c=td(i);if(c===null)continue;const d=`${s}.${a}`;if(n.push({key:d,label:`${Aa(s)} ${Aa(a).toLowerCase()}`,value:c}),n.length>=Ma)break}if(n.length>=Ma)break}}return n}function d4(e){const n=Ye(e,"answer"),s=Ye(e,"providerId"),o=Ye(e,"providerName"),r=Ye(e,"model"),a=Ye(e,"protocol"),i=nn(e,"logCount");if(n===null||s===null||o===null||r===null||a===null||i===null)return null;const c=Z(e,"evidence"),d=Array.isArray(c)?c.map(c4).filter(m=>m!==null).slice(0,12):[];return{answer:n,providerId:s,providerName:o,model:r,protocol:a,logCount:i,evidence:d,summaryMetrics:sd(Z(e,"summary")),queryMetrics:sd(Z(e,"queryStats"))}}const u4=l.lazy(()=>Dt(()=>import("./index-DPmKK_5d.js"),__vite__mapDeps([10,1,2]),import.meta.url)),m4="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 p4({text:e}){return t.jsx("div",{className:m4,children:t.jsx(l.Suspense,{fallback:t.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:t.jsx(u4,{children:e})})})}const od="What looks abnormal, slow, or likely to hang?";function f4(e){return e.openaiResponsesBaseUrl!==void 0||e.openaiBaseUrl!==void 0||e.anthropicBaseUrl!==void 0}function h4(e){return e.openaiResponsesBaseUrl!==void 0&&e.openaiResponsesBaseUrl!==""?"Responses":e.openaiBaseUrl!==void 0&&e.openaiBaseUrl!==""?"Chat":"Anthropic"}function x4(e){return e.toSorted((n,s)=>{const o=n.source==="company"?0:1,r=s.source==="company"?0:1;return o!==r?o-r:n.name.localeCompare(s.name)})}function rd(e){return`${e}-${String(Date.now())}-${String(Math.random()).slice(2)}`}function Cn({label:e,value:n,tone:s="muted"}){return t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 font-mono text-[10px]",children:[t.jsx("span",{className:s==="cyan"?"text-cyan-100":"text-muted-foreground",children:e}),n!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-muted-foreground/55",children:":"}),t.jsx("span",{className:"truncate text-muted-foreground",children:n})]})]})}function g4({metrics:e}){return e.length===0?null:t.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:e.slice(0,8).map(n=>t.jsxs("div",{className:"rounded-sm bg-black/25 px-2 py-1 shadow-[inset_2px_0_0_rgba(103,232,249,0.22)]",children:[t.jsx("div",{className:"truncate font-mono text-[9px] text-muted-foreground",children:n.label}),t.jsx("div",{className:"truncate font-mono text-[11px] text-cyan-50/95",children:n.value})]},n.key))})}function b4({evidence:e}){const n=()=>{e.logId!==null&&ds({logId:e.logId,tab:"anatomy"})},s=e.logId===null?`${e.source}:${e.id}`:`${e.source}:log #${String(e.logId)}`;return t.jsxs("button",{type:"button",onClick:n,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:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate font-mono text-[10px] text-cyan-100",children:s}),e.score!==null&&t.jsx("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:e.score.toFixed(1)})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-1 text-[10px] text-muted-foreground",children:[e.providerName!==null&&t.jsx("span",{children:e.providerName}),e.model!==null&&t.jsx("span",{children:e.model}),e.status!==null&&t.jsxs("span",{children:["status ",String(e.status)]}),e.elapsedMs!==null&&t.jsxs("span",{children:[String(e.elapsedMs)," ms"]})]}),t.jsx("p",{className:"mt-1 line-clamp-3 text-[11px] leading-4 text-foreground/85",children:e.excerpt})]})}function v4({response:e}){return t.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:[t.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:[t.jsx(Cn,{label:"assistant@inspector",value:"output",tone:"cyan"}),t.jsxs("span",{className:"shrink-0 font-mono text-[9px] text-muted-foreground",children:[String(e.logCount)," logs"]})]}),t.jsxs("div",{className:"space-y-3 p-3",children:[t.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:t.jsx(p4,{text:e.answer})}),t.jsxs("div",{className:"grid gap-1.5 rounded-sm bg-black/20 px-2 py-1.5",children:[t.jsx(Cn,{label:"provider",value:e.providerName}),t.jsx(Cn,{label:"model",value:e.model}),t.jsx(Cn,{label:"protocol",value:e.protocol})]}),(e.summaryMetrics.length>0||e.queryMetrics.length>0)&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Cn,{label:"metrics",tone:"cyan"}),t.jsx(g4,{metrics:[...e.summaryMetrics,...e.queryMetrics]})]}),e.evidence.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Cn,{label:"evidence",value:"click to inspect source log",tone:"cyan"}),e.evidence.slice(0,6).map(n=>t.jsx(b4,{evidence:n},`${n.source}-${n.id}`))]})]})]})}function y4({message:e}){return e.role==="assistant"&&e.response!==null?t.jsx(v4,{response:e.response}):t.jsxs("div",{className:"overflow-hidden rounded-md bg-black/25 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.055)]",children:[t.jsx("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:t.jsx(Cn,{label:"user@inspector",value:"query",tone:"cyan"})}),t.jsxs("div",{className:"px-3 py-2 font-mono text-[11px] leading-5 text-cyan-50",children:[t.jsx("span",{className:"select-none text-cyan-100/60",children:"> "}),e.content]})]})}function w4({currentSessionId:e,logCount:n,onResultChange:s}){const{providers:o}=Wi(),r=l.useMemo(()=>x4(o.filter(f4)),[o]),[a,i]=l.useState(()=>({...ed(),question:od})),[c,d]=l.useState("__auto__"),[m,u]=l.useState("__auto__"),[p,f]=l.useState(!1),g=r.find(C=>C.id===c)?.models??[],b=a.question,y=b.trim()!==""&&r.length>0&&!p;if(r.length===0)return null;const w=C=>{i(R=>({...R,question:C.currentTarget.value}))},v=C=>{d(C),u("__auto__")},j=()=>{i({...ed(),question:od}),s(null)},S=C=>{i(R=>({...R,question:C,error:null}))},N=()=>{if(!y)return;const C=b.trim(),R=i4(a.messages),I={id:rd("user"),role:"user",content:C,response:null};f(!0),i(M=>({...M,messages:[...M.messages,I],question:"",error:null}));const P={question:C,history:R,...e!==null?{sessionId:e}:{},...c!=="__auto__"?{providerId:c}:{},...m!=="__auto__"?{model:m}:{},logLimit:16};Th("/api/pi-agent",{method:"POST",headers:{"content-type":"application/json","x-agent-inspector-csrf":"1"},body:JSON.stringify(P)}).then(async M=>{const k=await M.text();if(!M.ok){i($=>({...$,error:`Inspector Assistant failed: HTTP ${String(M.status)} ${k}`}));return}const A=JSON.parse(k),D=d4(A);if(D===null){i($=>({...$,error:"Inspector Assistant returned an unexpected response."}));return}i($=>({...$,messages:[...$.messages,{id:rd("assistant"),role:"assistant",content:D.answer,response:D}]})),s({question:C,logIds:o4(D),reportedLogCount:D.logCount})}).catch(M=>{i(k=>({...k,error:M instanceof Error?M.message:"Inspector Assistant request failed."}))}).finally(()=>{f(!1)})};return t.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:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Qx,{className:"size-4 text-cyan-200"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:"Assistant"}),t.jsx("div",{className:"text-[11px] text-muted-foreground",children:e===null?"All evidence":"Current session"})]}),t.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:t.jsx(mu,{className:"size-3.5"})})]}),a.messages.length===0&&t.jsx("p",{className:"mt-3 text-[11px] leading-5 text-muted-foreground",children:"Ask about failures, latency, tokens, and tools."}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[t.jsxs(Fs,{value:c,onValueChange:v,children:[t.jsx(Us,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(or,{placeholder:"Provider"})}),t.jsxs(Bs,{children:[t.jsx(Xe,{value:"__auto__",children:"Auto provider"}),r.map(C=>t.jsxs(Xe,{value:C.id,children:[C.name," / ",h4(C)]},C.id))]})]}),t.jsxs(Fs,{value:m,onValueChange:u,children:[t.jsx(Us,{className:"h-8 border-0 bg-black/25 text-xs shadow-[inset_0_0_0_1px_rgba(255,255,255,0.06)]",children:t.jsx(or,{placeholder:"Model"})}),t.jsxs(Bs,{children:[t.jsx(Xe,{value:"__auto__",children:"Auto model"}),g.map(C=>t.jsx(Xe,{value:C,children:C},C))]})]})]}),a.messages.length===0&&t.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5",children:r4.map(C=>t.jsxs("button",{type:"button",onClick:()=>{S(C.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:[t.jsx(Ua,{className:"size-3"}),t.jsx("span",{children:C.label})]},C.id))}),a.messages.length>0&&t.jsxs("div",{className:"mt-3 max-h-96 space-y-2 overflow-y-auto pr-1",children:[a.messages.map(C=>t.jsx(y4,{message:C},C.id)),p&&t.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md bg-black/25 px-3 py-2 text-xs text-muted-foreground",children:[t.jsx(Ae,{className:"size-3.5 animate-spin"}),t.jsx("span",{children:"Searching Inspector..."})]})]}),t.jsx("textarea",{value:b,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..."}),t.jsxs("button",{type:"button",onClick:N,disabled:!y,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?t.jsx(Ae,{className:"size-3.5 animate-spin"}):t.jsx(Qg,{className:"size-3.5"}),t.jsx("span",{children:p?"Searching...":"Ask Assistant"})]}),a.error!==null&&t.jsx("p",{className:"mt-2 break-words text-[11px] leading-5 text-red-200",children:a.error}),n===0&&t.jsx("p",{className:"mt-2 text-[11px] leading-5 text-muted-foreground",children:"No logs in this scope. Setup questions still work."})]})}function j4(e){const n=new Map;for(const s of e){const o=s.logs;for(let r=1;r<o.length;r++){const a=o[r-1],i=o[r];a===void 0||i===void 0||n.set(i.id,{creation:ad(a.cacheCreationInputTokens,i.cacheCreationInputTokens),read:ad(a.cacheReadInputTokens,i.cacheReadInputTokens)})}}return n}function ad(e,n){return n===null||e===null?null:n>e?{direction:"up",delta:n-e}:n<e?{direction:"down",delta:e-n}:null}function $f(e){return e===null?null:new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Vn(e,n,s){const o=$f(e.lastSuccessAt),r=e.retryCount>0?` Retry ${e.retryCount.toString()}.`:"",a=s?" Captured logs remain visible.":"",i=o===null?"":` Last update ${o}.`;return`${n}${i}${r}${a}`}function Ff(e,n,s){switch(e){case"connecting":return{label:"Connecting",description:Vn(n,"Waiting for the first live update.",s),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:Vn(n,"Live updates are current.",s),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:Vn(n,"Live updates were interrupted.",s),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:Vn(n,"Live updates have not resumed.",s),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:Vn(n,n.errorMessage??"Live updates are paused.",s),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:Vn(n,n.errorMessage??"The live stream reported a recoverable error.",s),toneClass:"border-red-400/25 bg-red-500/10 text-red-100",dotClass:"bg-red-300",canRetry:!0,canStop:!0}}}function S4({state:e}){const n=Ff(e.status,e,!1),s=$f(e.lastSuccessAt),o=e.retryCount>0?`Retry ${e.retryCount.toString()}`:null;return t.jsxs("span",{role:"status","aria-label":n.description,"data-connection-state":e.status,className:O("inline-flex h-7 max-w-full items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium",n.toneClass),children:[t.jsx("span",{className:O("size-1.5 shrink-0 rounded-full",n.dotClass)}),t.jsx("span",{className:"shrink-0",children:n.label}),o!==null&&t.jsx("span",{className:"hidden truncate text-current/70 sm:inline",children:o}),s!==null&&t.jsxs("span",{className:"hidden truncate font-mono text-[10px] text-current/65 md:inline",children:["Last ",s]})]})}function N4({state:e,hasLogs:n,onRetry:s,onStop:o}){const r=Ff(e.status,e,n);return t.jsxs("div",{role:"status","aria-live":"polite","data-connection-state":e.status,className:O("mt-2 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-md border px-3 py-2 text-xs",r.toneClass),children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:O("size-2 shrink-0 rounded-full",r.dotClass)}),t.jsx("span",{className:"shrink-0 font-semibold",children:r.label}),t.jsx("span",{className:"min-w-0 text-current/75",children:r.description})]}),(r.canRetry||r.canStop)&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[r.canRetry&&t.jsxs("button",{type:"button",onClick:s,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:[t.jsx(yt,{className:"size-3"}),"Retry now"]}),r.canStop&&t.jsxs("button",{type:"button",onClick:o,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:[t.jsx(w0,{className:"size-3"}),"Stop retrying"]})]})]})}function C4(){const[e,n]=l.useState(!1),[s,o]=l.useState(!1);l.useEffect(()=>{const i=()=>{n(document.fullscreenElement!==null),o(document.fullscreenEnabled&&document.documentElement.requestFullscreen!==void 0&&document.exitFullscreen!==void 0)};return i(),document.addEventListener("fullscreenchange",i),()=>{document.removeEventListener("fullscreenchange",i)}},[]);const r=l.useCallback(()=>{if(s){if(document.fullscreenElement===null){document.documentElement.requestFullscreen().catch(()=>{n(document.fullscreenElement!==null)});return}document.exitFullscreen().catch(()=>{n(document.fullscreenElement!==null)})}},[s]),a=e?"Exit fullscreen":"Enter fullscreen";return t.jsxs(ee,{type:"button",variant:"ghost",size:"icon",className:to,"aria-label":a,"aria-pressed":e,title:a,disabled:!s,onClick:r,children:[e?t.jsx(vg,{className:"size-4"}):t.jsx(xg,{className:"size-4"}),t.jsx("span",{className:"sr-only",children:a})]})}function k4({liveConnection:e,alertsAction:n,settingsAction:s}){return t.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:t.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:[t.jsxs("a",{href:Si("/"),"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:[t.jsx(Od,{className:"size-7 shrink-0 text-amber-500"}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block truncate text-sm font-bold leading-4",children:"Agent Inspector"}),t.jsx("span",{className:"hidden truncate text-[10px] font-medium text-muted-foreground md:block",children:"Local First. Evidence First."})]}),t.jsxs("span",{className:"hidden shrink-0 font-mono text-[10px] text-muted-foreground lg:inline",children:["v",hu.version]})]}),t.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?t.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:[t.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-slate-400"}),"Stored session"]}):t.jsx(S4,{state:e})}),t.jsxs("nav",{"aria-label":"Application actions",className:"order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3",children:[t.jsx(C4,{}),n,s]})]})})}function _4(e){return`${Math.max(0,Math.ceil(e/1e3)).toString()}s`}function Do({progress:e}){const n=Math.min(1,e.elapsedMs/e.timeoutMs),s=Math.max(4,Math.round(n*100)),o=Math.max(0,e.timeoutMs-e.elapsedMs),r=n>=.75,a=[e.loadedLogs>0?`${e.loadedLogs.toString()} logs`:null,e.loadedPages>0?`${e.loadedPages.toString()} page${e.loadedPages===1?"":"s"}`:null,`${_4(o)} before timeout`].filter(c=>c!==null),i=`${e.label}: ${a.join(", ")}`;return t.jsxs("div",{className:"min-w-0 space-y-1 px-1 pb-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 truncate",children:e.label}),t.jsx("span",{className:O("shrink-0 tabular-nums",r&&"text-amber-300"),children:a.join(" / ")})]}),t.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":i,className:"h-1.5 overflow-hidden rounded-full bg-white/[0.06]",children:t.jsx("div",{className:O("h-full rounded-full transition-all duration-300 motion-reduce:transition-none",r?"bg-amber-300/80":"bg-cyan-300/70"),style:{width:`${s.toString()}%`}})})]})}function Uf(e){return e?"auto":"smooth"}function Bf(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function T4(){return{status:"connecting",lastSuccessAt:null,retryCount:0,errorMessage:null}}function kt(e,n){switch(n.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:n.at,retryCount:0,errorMessage:null};case"connection-lost":{const s=e.retryCount+1;return n.online?{...e,status:e.lastSuccessAt===null?"error":"reconnecting",retryCount:s,errorMessage:n.message}:{...e,status:"offline",retryCount:s,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:n.message}}}function E4(e){return e===void 0||e.status==="live"?"empty":e.status}function R4(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 id="agent-inspector.hierarchy.collapsedClients",ld="agent-inspector.hierarchy.collapsedProcesses";function ir(e){return e.some(n=>n.responseStatus===null)}function qf(e){return e.filter(n=>n.responseStatus===null).length}function Hf(e){for(const n of e){const s=n.userAgent;if(s!=null&&s!=="")return s}return null}function M4(e){for(const n of e){const s=n.clientPid;if(s!=null)return s}return null}function Wf(e){for(const n of e){const s=n.clientProjectFolder;if(s!=null&&s!=="")return s}return null}function A4(e){return xl({userAgent:Hf(e.logs),conversationId:e.conversationId,clientProjectFolder:Wf(e.logs)})}function I4(e){if(e===null||e==="")return"Unknown client";const n=e.split(/[ /;]/)[0]??"";return n===""?"Unknown client":n}function P4(e,n){const s=Dr(e);return s!==null?s:I4(n)}function lr(e){return e===null||e===""?"unknown":String(e)}function L4(e,n,s){return e!=="unknown"?e:`unknown:${lr(n)}:${lr(s)}`}function O4(e,n){return`${lr(e)}:${lr(n)}`}function cd(e){return[...e].sort((n,s)=>n.timestamp.localeCompare(s.timestamp))}function dd(e){let n="";for(const s of e)s.timestamp>n&&(n=s.timestamp);return n}function ud(e){return ir(e)?0:e.some(n=>n.error!==null&&n.error!==void 0||n.responseStatus!==null&&n.responseStatus!==void 0&&n.responseStatus>=400)?1:2}function Ia(e){return[...e].sort((n,s)=>{const o=ud(n.logs)-ud(s.logs);if(o!==0)return o;const r=dd(s.logs).localeCompare(dd(n.logs));return r!==0?r:n.id.localeCompare(s.id)})}function D4(e){const n=new Map;for(const o of e){const r=Hf(o.logs),a=Wf(o.logs),i=A4(o),c=L4(i,r,a);let d=n.get(c);d===void 0&&(d={id:c,client:i,label:P4(i,r),userAgent:r,processes:new Map,logs:[]},n.set(c,d)),d.logs.push(...o.logs);const m=M4(o.logs),u=`${c}:${O4(m,a)}`;let p=d.processes.get(u);p===void 0&&(p={id:u,clientPid:m,clientProjectFolder:a,sessions:[],logs:[]},d.processes.set(u,p)),p.sessions.push(o),p.logs.push(...o.logs)}const s=[];for(const o of n.values()){const r=Ia([...o.processes.values()].map(a=>({id:a.id,clientPid:a.clientPid,clientProjectFolder:a.clientProjectFolder,sessions:Ia(a.sessions),logs:cd(a.logs)})));s.push({id:o.id,client:o.client,label:o.label,userAgent:o.userAgent,processes:r,logs:cd(o.logs)})}return Ia(s)}function cr(e){return e<=0?"0":Ee(e)}function Vf(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&o.inputTokens!==void 0&&(n+=o.inputTokens),o.outputTokens!==null&&o.outputTokens!==void 0&&(s+=o.outputTokens);return{inputTokens:n,outputTokens:s}}function z4(e){let n=0;for(const s of e)n+=s.sessions.length;return n}function md(e){if(typeof window>"u")return null;try{const n=window.localStorage.getItem(e);if(n===null)return null;const s=JSON.parse(n);return Array.isArray(s)?new Set(s.filter(o=>typeof o=="string")):null}catch{return null}}function pd(e,n){try{window.localStorage.setItem(e,JSON.stringify([...n]))}catch{}}function fd(e,n){let s=!1;const o=new Set(e);for(const r of n)o.delete(r)&&(s=!0);return s?o:e}function $4(e){const n=new Set;for(const s of e)for(let o=1;o<s.processes.length;o++){const r=s.processes[o];r!==void 0&&!ir(r.logs)&&n.add(r.id)}return n}function F4(e){if(e===null||e==="")return null;const n=e.replaceAll("\\","/").split("/").filter(r=>r!==""),s=n[n.length-1];if(s===void 0)return e;const o=n[n.length-2];return o===void 0?s:`${o}/${s}`}function dr({label:e,value:n,className:s}){return t.jsxs("span",{className:O("inline-flex h-7 items-center gap-1 rounded-md bg-[var(--inspector-surface-low)] px-2 text-xs text-muted-foreground",s),children:[t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e}),t.jsx("span",{className:"font-mono tabular-nums text-foreground",children:n})]})}function Kf({count:e}){const n=`${e} open turn${e===1?"":"s"}`;return t.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":n,title:n,children:[t.jsx(Ae,{className:"size-3 animate-spin"}),e>1&&t.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 U4({groups:e,...n}){const s=l.useMemo(()=>D4(e),[e]),[o,r]=l.useState(()=>new Set),[a,i]=l.useState(()=>$4(s)),[c,d]=l.useState(!1);l.useEffect(()=>{const p=md(id),f=md(ld);p!==null&&r(p),f!==null&&i(f),d(!0)},[]),l.useEffect(()=>{c&&(pd(id,o),pd(ld,a))},[o,a,c]),l.useEffect(()=>{const p=new Set(s.filter(h=>ir(h.logs)).map(h=>h.id)),f=new Set(s.flatMap(h=>h.processes.filter(g=>ir(g.logs)).map(g=>g.id)));r(h=>fd(h,p)),i(h=>fd(h,f))},[s]);const m=l.useCallback(p=>{r(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]),u=l.useCallback(p=>{i(f=>{const h=new Set(f);return h.has(p)?h.delete(p):h.add(p),h})},[]);return t.jsx("div",{className:"space-y-2",children:s.map(p=>t.jsx(B4,{group:p,collapsed:o.has(p.id),collapsedProcessIds:a,onToggleClient:()=>m(p.id),onToggleProcess:u,conversationProps:n},p.id))})}function B4({group:e,collapsed:n,collapsedProcessIds:s,onToggleClient:o,onToggleProcess:r,conversationProps:a}){const i=Vf(e.logs),c=z4(e.processes),d=e.logs.length,m=qf(e.logs),u=m>0;return t.jsxs("section",{className:O("relative isolate overflow-hidden rounded-[8px] bg-card/65",u&&"bg-card/80"),"data-ide-group":e.id,children:[t.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:o,"aria-expanded":!n,children:[e.client==="unknown"?t.jsx("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-[var(--inspector-surface-low)] text-muted-foreground",children:t.jsx(jg,{className:"size-4"})}):t.jsx(zr,{client:e.client,className:"size-9 rounded-md",decorative:!0}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-semibold text-foreground",title:e.userAgent??e.label,children:e.label}),t.jsx("span",{className:"rounded bg-[var(--inspector-surface-medium)] px-1.5 py-0.5 font-mono text-[9px] uppercase text-muted-foreground",children:Qw(e.client)}),u&&t.jsx(Kf,{count:m})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[e.processes.length," process",e.processes.length!==1?"es":""]}),t.jsxs("span",{children:[c," session",c!==1?"s":""]}),t.jsxs("span",{children:[d," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(dr,{label:"IN",value:cr(i.inputTokens)}),t.jsx(dr,{label:"OUT",value:cr(i.outputTokens)})]}),t.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:n?t.jsx(it,{className:"size-4"}):t.jsx(Ve,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-0.5 px-2 pb-2 pt-0.5",children:e.processes.map(p=>t.jsx(q4,{group:p,collapsed:s.has(p.id),onToggle:()=>r(p.id),conversationProps:a},p.id))})]})}function q4({group:e,collapsed:n,onToggle:s,conversationProps:o}){const r=Vf(e.logs),a=F4(e.clientProjectFolder),i=e.sessions.length,c=e.logs.length,d=qf(e.logs),m=d>0,u=e.clientPid!==null&&e.clientPid!==void 0?`PID ${e.clientPid}`:"Process unavailable";return t.jsxs("section",{className:"relative pl-3",children:[t.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:s,"aria-expanded":!n,children:[t.jsx("span",{className:"inline-flex size-8 shrink-0 items-center justify-center text-[var(--inspector-status-watch)]",children:t.jsx(L0,{className:"size-4"})}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-mono text-xs font-semibold tabular-nums text-foreground",children:u}),m&&t.jsx(Kf,{count:d}),a!==null&&t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground",title:e.clientProjectFolder??a,children:[t.jsx(sg,{className:"size-3 shrink-0"}),t.jsx("span",{className:"truncate font-mono",children:a})]})]}),t.jsxs("span",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{children:[i," session",i!==1?"s":""]}),t.jsxs("span",{children:[c," req"]})]})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[n&&t.jsxs("span",{className:"hidden shrink-0 items-center gap-2 md:flex",children:[t.jsx(dr,{label:"IN",value:cr(r.inputTokens)}),t.jsx(dr,{label:"OUT",value:cr(r.outputTokens)})]}),t.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:n?t.jsx(it,{className:"size-4"}):t.jsx(Ve,{className:"size-4"})})]})]}),!n&&t.jsx("div",{className:"space-y-1 pb-1 pl-3 pr-1 pt-1",children:e.sessions.map(p=>t.jsx(BN,{group:p,...o,showClientIdentity:!1,showLogClientMetadata:!1,showProcessMetadata:!1},p.id))})]})}const H4="w-[calc(100%-1rem)] border-warning/30 bg-popover text-popover-foreground sm:max-w-lg",W4=[{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 V4({onCancel:e,onExportRedacted:n,onConfirmRaw:s}){return t.jsxs(t.Fragment,{children:[t.jsxs(Ft,{children:[t.jsx(Ut,{children:"Export unredacted logs?"}),t.jsx(Qs,{children:"Raw exports bypass Agent Inspector redaction and may expose sensitive captured data."})]}),t.jsxs("div",{role:"alert",className:"rounded-md border border-warning/35 bg-warning/10 px-3 py-3 text-sm text-foreground",children:[t.jsx("p",{className:"font-medium",children:"The raw archive may include:"}),t.jsx("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-xs leading-relaxed text-muted-foreground",children:W4.map(o=>t.jsxs("li",{children:[t.jsxs("span",{className:"font-semibold text-foreground",children:[o.label,":"]})," ",o.detail]},o.label))}),t.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."})]}),t.jsxs("div",{className:"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:e,children:"Cancel"}),t.jsx(ee,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Export redacted instead"}),t.jsx(ee,{type:"button",variant:"destructive",size:"sm",onClick:s,children:"Export raw data"})]})]})}const ur="data-nav-id",K4="data-nav-action";function hd(e){return Array.from(e.querySelectorAll(`[${ur}]`))}function xd(e){return e instanceof HTMLElement}function G4(e,n){let s=e;for(;s!==null&&s!==n;){if(s.hasAttribute(ur))return s;s=s.parentElement}return e.hasAttribute(ur)?e:null}function Pa(e){const n=e.getAttribute(K4);return n==="toggle"||n==="expand"||n==="collapse"?n:null}function Ss(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Ns(e,n){return e[n]??null}function Gf(e){const n=e.tagName;return!!(n==="INPUT"||n==="TEXTAREA"||n==="SELECT"||e.isContentEditable)}function gd(e){const n=e.tagName;return n==="BUTTON"||n==="A"||Gf(e)?!0:e.closest("[role='button'],[role='menuitem'],[role='option']")!==null}function J4(e){return e.closest("[role='dialog'],[role='menu'],[role='listbox']")!==null?!0:document.querySelector("[role='dialog'],[role='menu'],[role='listbox']")!==null}function Y4(){const e=window.getSelection();return e===null?!1:e.type==="Range"&&e.toString().length>0}function No(e,n){return e.key===n&&e.shiftKey}function X4(e,n,s={}){const o=n??e,r=s.pageWide===!0,a=l.useCallback(i=>{const c=e.current,d=o.current;if(!c||!d)return;const m=i.target;if(!xd(m)||m!==d)return;const u=hd(c),p=Ns(u,0);p!==null&&Ss(p)},[e,o]);l.useEffect(()=>{const i=c=>{if(c.altKey||c.ctrlKey||c.metaKey)return;const d=e.current;if(!d)return;const m=c.target;if(!xd(m)||Gf(m)||Y4())return;const u=d.contains(m);if(u&&gd(m)&&!m.hasAttribute(ur)||!u&&(!r||gd(m)||J4(m)))return;const p=hd(d);if(p.length===0)return;const f=G4(m,d),h=f!==null?p.indexOf(f):-1;let g=!1;switch(c.key){case"ArrowUp":case"W":{if(c.shiftKey&&c.key==="ArrowUp"||c.key==="W"&&!No(c,"W"))break;c.preventDefault();const b=h>0?h-1:h===-1?p.length-1:-1;if(b!==-1){const y=Ns(p,b);y!==null&&Ss(y)}g=!0;break}case"ArrowDown":case"S":{if(c.shiftKey&&c.key==="ArrowDown"||c.key==="S"&&!No(c,"S"))break;c.preventDefault();const b=h<p.length-1?h+1:h===-1?0:-1;if(b!==-1){const y=Ns(p,b);y!==null&&Ss(y)}g=!0;break}case"ArrowLeft":case"A":{if(c.shiftKey&&c.key==="ArrowLeft"||c.key==="A"&&!No(c,"A")||f===null)break;if(c.preventDefault(),Pa(f)==="collapse")f.click();else if(h>0){const y=Ns(p,h-1);y!==null&&Ss(y)}g=!0;break}case"ArrowRight":case"D":{if(c.shiftKey&&c.key==="ArrowRight"||c.key==="D"&&!No(c,"D")||f===null)break;if(c.preventDefault(),Pa(f)==="expand")f.click();else if(h<p.length-1){const y=Ns(p,h+1);y!==null&&Ss(y)}g=!0;break}case" ":{if(f===null)break;c.preventDefault(),Pa(f)!==null&&f.click(),g=!0;break}}g&&c.stopPropagation()};return document.addEventListener("keydown",i,{capture:!0}),()=>document.removeEventListener("keydown",i,{capture:!0})},[e,r,o]),l.useEffect(()=>(document.addEventListener("focusin",a),()=>document.removeEventListener("focusin",a)),[a])}const Z4={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},Q4={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"},e_={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"},La=12,Co=1,bd=80,vd=24;function t_(e){return e.length<=vd?e:`${e.slice(0,vd-3)}...`}function n_(e){const n=e.replace(/\s+/g," ").trim();return n.length<=bd?n:`${n.slice(0,bd)}...`}function ko(e){return e>=10?`${e.toFixed(0)}%`:e>=1?`${e.toFixed(1)}%`:e>0?"<1%":"0%"}const s_=l.memo(function({segments:n,totalTokens:s,showLabels:o=!0,onActivate:r}){const a=l.useMemo(()=>s>0?s:n.reduce((y,w)=>y+w.size,0),[n,s]),i=n.slice(0,La),c=n.slice(La),d=c.reduce((y,w)=>y+w.size,0),m=c.length,u=La,p=u+m-1,f=m>0,h=r!==void 0,g=l.useMemo(()=>i.reduce((y,w)=>y+w.size,0),[i]),b=l.useMemo(()=>`Request context: ~${Ee(a)} tokens across ${n.length} segment${n.length===1?"":"s"}`,[n.length,a]);return n.length===0||a<=0?t.jsx("div",{role:"img","aria-label":b,className:"h-6"}):t.jsx(hs,{delayDuration:150,children:t.jsxs("div",{role:"img","aria-label":b,className:"flex flex-col gap-1.5",children:[t.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:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(Co,v),S=O("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",Q4[y.role],h?e_[y.role]:""),N={width:`${j}%`},C=`${y.label}, ${ko(v)}, ~${Ee(y.size)} tokens`;return t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:h?t.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>r(y),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),r(y))},"data-anatomy-path":y.path,"aria-label":C,className:S,style:N}):t.jsx("span",{"aria-label":C,className:S,style:N})}),t.jsxs(nt,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[t.jsxs("div",{className:"font-semibold",children:[y.label," - ",ko(v)," - ~",Ee(y.size)," ","tokens"]}),t.jsx("div",{className:"text-muted-foreground",children:Z4[y.role]}),t.jsxs("div",{className:"text-muted-foreground",children:[y.characters.toLocaleString()," chars"]}),y.text.length>0&&t.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:n_(y.text)})]})]},`${y.path}-${w}`)}),f&&t.jsxs(et,{children:[t.jsx(tt,{asChild:!0,children:t.jsxs("div",{role:"img","aria-label":`${m} 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(Co,d/a*100)}%`},children:["... +",m]})}),t.jsxs(nt,{side:"bottom",className:"text-xs",children:[m," more segment",m===1?"":"s"," (indices"," ",u,"-",p,")"]})]})]}),o&&t.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[i.map((y,w)=>{const v=a>0?y.size/a*100:0,j=Math.max(Co,v);return t.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${j}%`},title:`${y.label} - ${ko(v)} - ~${Ee(y.size)} tokens`,children:[t.jsx("span",{className:"truncate font-mono text-foreground/80",children:t_(y.label)}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[ko(v)," - ~",Ee(y.size)]})]},`label-${y.path}-${w}`)}),f&&t.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max(Co,d/a*100)}%`},children:[t.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",m]}),t.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",Ee(d)]})]})]}),g<a*.1&&t.jsx("div",{className:"h-0"})]})})}),Jf=.75,Yf=.9,gi=8e3,o_=.35,Xf=40,Zf=160,r_=5,a_=8,i_=18,l_=6e4,c_=.7,yd=3e3,d_=.3,wd=160,u_=new Set(["answer","body","content","data","error","message","markdown","output","response","result","stderr","stdout","text","transcript"]),m_=["context_window","contextWindow","context_length","contextLength","max_context_length","maxContextLength","max_input_tokens","maxInputTokens"],p_=["max_tokens","maxTokens","max_completion_tokens","maxCompletionTokens","max_output_tokens","maxOutputTokens"],f_=[{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"]}],h_={system:"System",user:"User messages",assistant:"Assistant messages",tool:"Tool results",tools:"Tool definitions"};function x_(e){if(typeof e=="number")return Number.isFinite(e)&&e>0?Math.floor(e):null;if(typeof e=="string"){const n=Number(e);if(Number.isFinite(n)&&n>0)return Math.floor(n)}return null}function Qf(e,n){for(const s of n){const o=x_(Z(e,s));if(o!==null)return o}return null}function g_(e){const n=Z(e,"model");if(typeof n!="string")return null;const s=n.trim();return s===""?null:s}function b_(e,n){switch(n.mode){case"prefix":return n.patterns.some(s=>e.startsWith(s));case"includes":return n.patterns.some(s=>e.includes(s))}}function v_(e,n,s=[]){const o=Qf(n,m_);if(o!==null)return{tokens:o,label:"Request metadata",source:"request"};const r=yk(e,s);if(r!==null)return{tokens:r.tokens,label:`${r.providerName} config`,source:"provider"};if(e===null)return{tokens:null,label:"Unknown model",source:"unknown"};const a=e.trim().toLowerCase().replace(/\s+/g,"-");for(const i of f_)if(b_(a,i))return{tokens:i.tokens,label:`${i.family} local rule`,source:"model-rule"};return{tokens:null,label:"No local rule",source:"unknown"}}function y_(e){return e<0?0:e>1?1:e}function w_(e){return e===null?"unknown":e>=Yf?"danger":e>=Jf?"watch":"ok"}function j_(e,n){return e.filter(s=>s.role===n).reduce((s,o)=>s+o.size,0)}function S_(e,n){return["system","user","assistant","tool","tools"].map(o=>{const r=j_(e,o);return{role:o,label:h_[o],tokens:r,percent:n>0?r/n:0}}).filter(o=>o.tokens>0).sort((o,r)=>r.tokens-o.tokens)}function bi(e){return e.replace(/\s+/g," ").trim().toLowerCase()}function N_(e){const n=e.replace(/\s+/g," ").trim();return n.length<=wd?n:`${n.slice(0,wd-3)}...`}function C_(e){return{role:e.role,label:e.label,path:e.path,tokens:e.tokens,characters:e.characters}}function k_(e){return{role:e.role,label:e.label,path:e.path,tokens:e.size,characters:e.characters,text:e.text}}function __(e){const n=e.trim();return n.startsWith("{")||n.startsWith("[")}function T_(e){if(!__(e))return null;try{return JSON.parse(e)}catch{return null}}function E_(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}function R_(e){for(let n=e.length-1;n>=0;n-=1){const s=e[n]??"";if(!(s.startsWith("[")&&s.endsWith("]")))return s}return null}function M_(e){const n=R_(e);return n===null?!1:u_.has(E_(n))}function A_(e){return e.map(n=>n.startsWith("[")?n:`.${n}`).join("").replace(/^\./,"")}function I_(e,n,s){const o=bl(n);if(o<Zf)return null;const r=gl(n);return r<Xf?null:{role:e.role,label:`${e.label} ${A_(s)}`,path:e.path,tokens:r,characters:o,text:n}}function vi({value:e,segment:n,path:s,depth:o,candidates:r}){if(!(r.length>=a_)&&!(o>r_)){if(typeof e=="string"){if(!M_(s))return;const a=I_(n,e,s);a!==null&&r.push(a);return}if(Array.isArray(e)){e.forEach((a,i)=>vi({value:a,segment:n,path:[...s,`[${String(i)}]`],depth:o+1,candidates:r}));return}vl(e)&&Object.entries(e).forEach(([a,i])=>vi({value:i,segment:n,path:[...s,a],depth:o+1,candidates:r}))}}function P_(e){const n=k_(e),s=T_(e.text);if(s===null)return[n];const o=[];vi({value:s,segment:e,path:[],depth:0,candidates:o});const r=bi(e.text),a=new Set([r]),i=o.filter(c=>{const d=bi(c.text);return d===""||a.has(d)?!1:(a.add(d),!0)});return[n,...i]}function L_(e){const n=new Map;for(const o of e){const r=P_(o);for(const a of r){if(a.tokens<Xf||a.characters<Zf)continue;const i=bi(a.text);if(i==="")continue;const c=n.get(i);if(c===void 0){n.set(i,{tokens:a.tokens,candidates:[a]});continue}n.set(i,{tokens:c.tokens+a.tokens,candidates:[...c.candidates,a]})}}const s=[];for(const o of n.values()){if(o.candidates.length<2)continue;const r=o.candidates[0]??null;if(r===null)continue;const a=o.tokens-r.tokens;s.push({key:`${r.path}:${r.label}:${String(o.candidates.length)}:${String(o.tokens)}`,count:o.candidates.length,totalTokens:o.tokens,repeatedTokens:a,preview:N_(r.text),firstLabel:r.label,segments:o.candidates.map(C_)})}return s.sort((o,r)=>r.repeatedTokens-o.repeatedTokens||r.totalTokens-o.totalTokens)}function O_(e){if(e.length===0)return null;const n=e.length,s=e.reduce((r,a)=>r+a.count,0),o=e.reduce((r,a)=>r+a.repeatedTokens,0);return{kind:"duplicate",severity:o>=gi?"danger":"watch",title:"Duplicate context",detail:`${String(s)} repeated blocks across ${String(n)} group${n===1?"":"s"}, ~${String(o)} repeated tokens.`}}function D_(e){return e.reduce((n,s)=>n+s.repeatedTokens,0)}function z_(e,n,s){const o=[],r=e.find(d=>d.role==="tools")??null;r!==null&&(r.tokens>=gi||r.percent>=o_&&r.tokens>=yd)&&o.push({kind:"tool-schema",severity:r.tokens>=gi?"danger":"watch",title:"Large tool schema",detail:`Tool definitions take ${Math.round(r.percent*100)}% of request context.`});const a=e.find(d=>d.role==="system")??null;a!==null&&a.tokens>=yd&&a.percent>=d_&&o.push({kind:"system-heavy",severity:"watch",title:"Large system prompt",detail:`System instructions take ${Math.round(a.percent*100)}% of request context.`});const i=e.filter(d=>d.role==="user"||d.role==="assistant"||d.role==="tool").reduce((d,m)=>d+m.tokens,0),c=n>0?i/n:0;return s>=i_&&(i>=l_||c>=c_)&&o.push({kind:"history-bloat",severity:c>=.85?"danger":"watch",title:"Conversation history growth",detail:`${String(s)} message blocks take ${Math.round(c*100)}% of request context.`}),o}function $_({risk:e,contextWindow:n,diagnostics:s,duplicateGroups:o}){let a=new Set(s.map(d=>d.kind)).size;(e==="watch"||e==="danger")&&(a+=1),n.source==="unknown"&&(a+=1);const i=s.some(d=>d.severity==="danger");return{level:e==="danger"||i?"risk":a>0?"optimizable":"ok",opportunityCount:a,reclaimableTokens:D_(o)}}function F_({segments:e,inputTokens:n,parsed:s,model:o,providers:r=[]}){const a=e.reduce((C,R)=>C+R.size,0),i=o??g_(s),c=n??a,d=Qf(s,p_),m=v_(i,s,r),u=d??0,p=m.tokens===null?null:c+u,f=m.tokens===null?null:m.tokens-c,h=m.tokens===null?null:m.tokens-c-u,g=m.tokens===null||p===null?null:y_(p/m.tokens),b=S_(e,a),y=b[0]??null,w=e.filter(C=>C.role!=="tools").length,v=L_(e),j=O_(v),S=z_(b,a,w);j!==null&&S.unshift(j);const N=w_(g);return{model:i,contextWindow:m,estimatedInputTokens:c,outputReserveTokens:d,windowUsedTokens:p,remainingInputTokens:f,remainingAfterReserveTokens:h,usagePercent:g,riskLevel:N,roleUsages:b,largestRole:y,diagnostics:S,duplicateGroups:v,health:$_({risk:N,contextWindow:m,diagnostics:S,duplicateGroups:v})}}const ZT={watch:Jf,danger:Yf},jd=new WeakMap;function U_(e){return e.map(n=>{const s=n.modelMetadata?.map(o=>`${o.model}:${String(o.contextWindow??"")}`).join(",")??"";return`${n.id}:${n.updatedAt}:${n.models.join(",")}:${s}`}).join("|")}function B_(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}function q_(e){return{role:e.role,label:e.label,size:e.tokens,characters:e.tokens*4,text:"",path:`role:${e.role}`}}function H_(e,n){const s=B_(e.rawRequestBody);if(s===null)return null;const r=Wp(Ds(e)).anatomySegments(s);if(r===null)return null;const a=F_({segments:r,inputTokens:e.inputTokens??null,parsed:s,model:e.model,providers:n}),i=a.model??e.model??"Unknown model",c=a.roleUsages.map(q_);return{logId:e.id,model:i,timestamp:e.timestamp,contextWindow:a.contextWindow,estimatedInputTokens:a.estimatedInputTokens,windowUsedTokens:a.windowUsedTokens,usagePercent:a.usagePercent,riskLevel:a.riskLevel,health:a.health,diagnostics:a.diagnostics.map(d=>d.title),roleSegments:c,roleTotalTokens:c.reduce((d,m)=>d+m.size,0)}}function W_(e,n,s){const o=jd.get(e);if(o!==void 0&&o.id===e.id&&o.rawRequestBody===e.rawRequestBody&&o.inputTokens===e.inputTokens&&o.model===e.model&&o.path===e.path&&o.apiFormat===e.apiFormat&&o.timestamp===e.timestamp&&o.providersSignature===s)return o.snapshot;const r=H_(e,n);return jd.set(e,{id:e.id,rawRequestBody:e.rawRequestBody,inputTokens:e.inputTokens,model:e.model,path:e.path,apiFormat:e.apiFormat,timestamp:e.timestamp,providersSignature:s,snapshot:r}),r}function V_(e,n){return e.usagePercent!==null&&n.usagePercent!==null?e.usagePercent>n.usagePercent:e.usagePercent!==null&&n.usagePercent===null?!0:e.usagePercent===null&&n.usagePercent!==null?!1:e.estimatedInputTokens>n.estimatedInputTokens}function Sd(e){switch(e){case"danger":return 4;case"watch":return 3;case"unknown":return 2;case"ok":return 1}}function K_(e,n){const s=Sd(n.latest.riskLevel)-Sd(e.latest.riskLevel);if(s!==0)return s;const o=e.peak.usagePercent??-1,a=(n.peak.usagePercent??-1)-o;return a!==0?a:n.latest.logId-e.latest.logId}function G_(e,n){return e.usagePercent===null||n.usagePercent===null?null:(n.usagePercent-e.usagePercent)*100}function J_(e){for(let n=1;n<e.length;n++){const s=e[n-1],o=e[n];if(!(s===void 0||o===void 0)&&s.id>o.id)return[...e].sort((r,a)=>r.id-a.id)}return e}function Y_(e,n=[]){const s=J_(e),o=U_(n),r=new Map;for(const i of s){const c=W_(i,n,o);if(c===null)continue;const d=r.get(c.model);if(d===void 0){r.set(c.model,{model:c.model,requestCount:1,first:c,latest:c,peak:c});continue}r.set(c.model,{model:d.model,requestCount:d.requestCount+1,first:d.first,latest:c,peak:V_(c,d.peak)?c:d.peak})}return{models:[...r.values()].map(i=>({model:i.model,requestCount:i.requestCount,first:i.first,latest:i.latest,peak:i.peak,trendPercent:G_(i.first,i.latest)})).sort(K_)}}function kn(e){return e.length<=30?e:`${e.slice(0,12)}...${e.slice(-12)}`}function X_(e){const n=new Map;for(const s of e)for(let o=0;o<s.logs.length;o+=1){const r=s.logs[o];r!==void 0&&n.set(r.id,o+1)}return n}function Nd(e,n){return n.get(e.id)??e.id}function Cd(e){let n=0,s=0;for(const o of e)o.inputTokens!==null&&(n+=o.inputTokens),o.outputTokens!==null&&(s+=o.outputTokens);return{totalIn:n,totalOut:s}}function Z_(e){for(const n of e)if(n.userAgent!==null&&n.userAgent!==void 0&&n.userAgent!=="")return n.userAgent;return null}function Q_(e,n){const s=e[0],o=e[e.length-1];return s===void 0||o===void 0?null:xr(s.timestamp,o.timestamp,n)}function eT(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 tT(e){switch(e){case"rolling":return t.jsx(yt,{className:"size-3 text-status-cool"});case"failed":return t.jsx(Wo,{className:"size-3 text-status-danger"});case"watch":return t.jsx(pu,{className:"size-3 text-status-watch"});case"clear":return t.jsx(Oe,{className:"size-3 text-status-success"})}}function nT(e){switch(e){case"rolling":return"cool";case"failed":return"danger";case"watch":return"watch";case"clear":return"neutral"}}function sT(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 Kn({label:e,value:n,detail:s,icon:o,tone:r="neutral"}){return t.jsxs("div",{className:"min-w-0 border-t border-border/60 px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase text-muted-foreground",children:[o,e]}),t.jsx("div",{className:O("mt-2 font-mono text-sm font-semibold",eT(r)),children:n}),t.jsx("div",{className:"mt-1 font-mono text-[11px] leading-snug text-muted-foreground",children:s})]})}function oT({stats:e}){return e.requests===0?null:t.jsxs("div",{className:"mb-4 overflow-hidden rounded-[8px] border border-border bg-card",children:[t.jsx("div",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] font-semibold uppercase text-muted-foreground",children:[t.jsx(N0,{className:"size-3.5 text-slate-300"}),"Flight Recorder"]}),t.jsx("div",{className:"mt-2 min-w-0 font-mono text-sm font-semibold text-foreground",children:e.modelLabel})]}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 font-mono",children:e.providerLabel}),t.jsx("span",{className:"min-w-0 font-mono",children:e.timeRange??"Timeline pending"})]})]})}),t.jsxs("div",{className:"grid grid-cols-2 border-t border-border/60 md:grid-cols-3 2xl:grid-cols-6",children:[t.jsx(Kn,{label:"Status",value:e.statusLabel,detail:sT(e),icon:tT(e.status),tone:nT(e.status)}),t.jsx(Kn,{label:"Turns",value:String(e.turns),detail:e.finishLabel,icon:t.jsx(eg,{className:"size-3 text-muted-foreground"}),tone:e.finishTone}),t.jsx(Kn,{label:"Requests",value:String(e.requests),detail:`${e.failures} failed / ${e.slow} slow`,icon:t.jsx(Wo,{className:"size-3 text-muted-foreground"}),tone:e.failures>0?"danger":"neutral"}),t.jsx(Kn,{label:"Peak",value:e.slowestLabel,detail:e.slowestDetail,icon:t.jsx(pu,{className:"size-3 text-muted-foreground"}),tone:e.slow>0?"watch":"neutral"}),t.jsx(Kn,{label:"Tokens",value:e.tokenLabel,detail:e.heaviestDetail,icon:t.jsx($i,{className:"size-3 text-muted-foreground"})}),t.jsx(Kn,{label:"Outcome",value:e.outcomeLabel,detail:e.outcomeDetail,tone:e.outcomeTone})]})]})}function Ms(e){if(e===null)return"Unknown";const n=e*100;return n>=10?`${n.toFixed(0)}%`:n>=1?`${n.toFixed(1)}%`:n>0?"<1%":"0%"}function rT(e){return e===null?"n/a":Math.abs(e)<.1?"0%":`${e>0?"+":""}${e.toFixed(1)}%`}function yi(e){return e===null||!Number.isFinite(e)?0:Math.min(Math.max(e*100,0),100)}function aT(e,n){if(n===null)return null;const s=yi(e),o=yi(n);return o<=0||Math.abs(o-s)<.5?null:o}function iT(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 lT(e){const n=e.latest.contextWindow.tokens;return n===null?"Context window unknown":`Context window ${Ld(n)}`}const cT=["score","decision","final_status","validation_pass_ratio","semantic_memory_score","opencode_exit","actual_model","run_dir","workspace","project_dir","work_dir"];function eh(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 Oa(e,n){if(e===null)return null;const s=e.metadata[n];return s===void 0?null:eh(s)}function dT(e){const n=e.toLowerCase();return n.includes("reject")||n.includes("fail")||n.includes("error")?"border-red-400/35 bg-red-500/10 text-red-100":n.includes("partial")||n.includes("pending")||n.includes("slow")?"border-amber-300/35 bg-amber-400/10 text-amber-100":n.includes("pass")||n.includes("complete")||n.includes("accept")?"border-cyan-300/25 bg-cyan-400/10 text-cyan-100":"border-border/70 bg-background/70 text-muted-foreground"}function uT(e){const n=[];for(const s of cT){const o=e.metadata[s];if(o===void 0)continue;const r=eh(o);r!==null&&n.push({key:s,value:r})}return n}function kd({memberships:e,defaultOpen:n=!1}){const[s,o]=l.useState(n);if(e.length===0)return null;const r=e[0],a=r?.member??null,i=Oa(a,"score"),c=Oa(a,"decision"),d=Oa(a,"final_status"),m=[i===null?null:{label:`score ${i}`,value:i},c===null?null:{label:c,value:c},d===null?null:{label:d,value:d},a?.model===null||a?.model===void 0?null:{label:a.model,value:a.model}].filter(u=>u!==null&&u.label.length>0&&u.value.length>0);return t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] text-xs",children:[t.jsxs("button",{type:"button",onClick:()=>o(u=>!u),className:"flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-white/[0.04]","aria-expanded":s,children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"font-semibold text-foreground",children:"Case File"}),r!==void 0&&t.jsx("span",{className:"truncate text-muted-foreground",title:r.groupTitle,children:r.groupTitle}),t.jsxs("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:[e.length," group",e.length===1?"":"s"]})]}),m.length>0&&t.jsx("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:m.slice(0,4).map(u=>t.jsx("span",{className:O("rounded border px-1.5 py-0.5 font-mono text-[10px]",dT(u.value)),children:u.label},u.label))})]}),s?t.jsx(Di,{className:"size-4 shrink-0 text-muted-foreground"}):t.jsx(Ve,{className:"size-4 shrink-0 text-muted-foreground"})]}),s&&t.jsx("div",{className:"space-y-2 border-t border-white/10 px-3 py-2",children:e.map(u=>{const p=u.member,f=uT(p);return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"truncate font-medium text-foreground",title:u.groupTitle,children:u.groupTitle}),t.jsx("span",{className:"font-mono text-[10px] uppercase text-muted-foreground",children:u.groupStatus}),p.status!==null&&t.jsxs("span",{className:"font-mono text-[10px] text-muted-foreground",children:["member ",p.status]})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsx("span",{className:"font-mono",title:p.sessionId,children:kn(p.sessionId)}),p.label!==null&&t.jsx("span",{children:p.label}),p.provider!==null&&t.jsx("span",{children:p.provider}),p.model!==null&&t.jsx("span",{className:"font-mono",children:p.model}),p.runId!==null&&t.jsxs("span",{className:"font-mono",title:p.runId,children:["run ",kn(p.runId)]})]}),f.length>0&&t.jsx("div",{className:"mt-2 grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:f.map(h=>t.jsxs("div",{className:"border border-border bg-muted/40 min-w-0 rounded-md px-2 py-1",children:[t.jsx("div",{className:"font-mono text-[10px] text-muted-foreground",children:h.key}),t.jsx("div",{className:"truncate font-mono text-[11px] text-foreground",title:h.value,children:h.value})]},h.key))})]},`${u.groupId}:${p.id}`)})})]})}function _o({label:e,title:n,icon:s,disabled:o,onClick:r}){return t.jsxs("button",{type:"button",onClick:r,disabled:o,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:n,children:[s,t.jsx("span",{children:e})]})}function _d({logs:e,pagination:n,embedded:s=!1}){if(n===void 0)return null;const o=n.isLoading;return t.jsxs("nav",{"aria-label":"Session log pagination",className:O("flex min-h-9 flex-col gap-2 px-1 py-1 sm:flex-row sm:items-center",s?"border-t border-white/10 pt-2":"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-2"),children:[t.jsxs("div",{className:"w-full min-w-0 px-1 font-mono text-[11px] text-muted-foreground sm:flex-1",children:[t.jsxs("div",{role:"status","aria-live":"polite","aria-atomic":"true",children:[aC({logs:e,pagination:n}),n.isLoading&&e.length>0&&t.jsx("span",{className:"ml-2",children:"Loading..."})]}),n.loadProgress!==void 0&&t.jsx(Do,{progress:n.loadProgress})]}),t.jsxs("div",{className:"flex w-full items-center gap-1 overflow-x-auto sm:w-auto",children:[t.jsx(_o,{label:"Oldest",title:"Load the oldest logs in this session",icon:t.jsx(d0,{className:"size-3.5"}),disabled:o||!n.hasOlder,onClick:n.onOldest}),t.jsx(_o,{label:"Older",title:"Load older logs",icon:t.jsx(o0,{className:"size-3.5"}),disabled:o||!n.hasOlder,onClick:n.onOlder}),t.jsx(_o,{label:"Newer",title:"Load newer logs",icon:t.jsx(it,{className:"size-3.5"}),disabled:o||!n.hasNewer,onClick:n.onNewer}),t.jsx(_o,{label:"Newest",title:"Load the newest logs in this session",icon:t.jsx(m0,{className:"size-3.5"}),disabled:o||!n.hasNewer,onClick:n.onNewest})]})]})}function mT(e){return`${e} ${e===1?"request":"requests"}`}function Td(e){return`#${String(e)}`}function Ed(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 pT(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 fT(e){switch(e){case"risk":return"Risk";case"optimizable":return"Optimizable";case"ok":return"OK"}}const hT=10,xT=80;function gT(e){e.setAttribute("data-deep-link-highlight","true"),window.setTimeout(()=>{e.removeAttribute("data-deep-link-highlight")},1800)}function bT(e){const n=document.getElementById(`log-${String(e)}`);return n instanceof HTMLElement?(n.scrollIntoView({block:"center",behavior:Uf(Bf())}),n.focus({preventScroll:!0}),gT(n),!0):!1}function th(e){ds({logId:e,tab:"anatomy"});let n=0;const s=()=>{ds({logId:e,tab:"anatomy"}),!bT(e)&&(n+=1,n<hT&&window.setTimeout(s,xT))};window.setTimeout(s,0)}function Cs({command:e}){const[n,s]=l.useState(!1),o=l.useCallback(()=>{vt(e).then(r=>{r&&(s(!0),setTimeout(()=>s(!1),2e3))})},[e]);return t.jsxs("div",{"data-command-example":"true",className:qN,children:[t.jsx("pre",{className:HN,children:e}),t.jsx("button",{type:"button",onClick:o,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:n?t.jsx(Oe,{className:"size-4"}):t.jsx(St,{className:"size-4"})})]})}function Da({label:e,children:n,className:s}){return t.jsxs("section",{className:O("rounded-[8px] border border-border/60 bg-card/55",s),children:[t.jsx("div",{className:"px-3 pt-3",children:t.jsx("div",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-text-subtle",children:e})}),t.jsx("div",{className:"p-3 pt-2",children:n})]})}function To({label:e,value:n}){return t.jsxs("div",{className:"min-w-0 rounded-md border border-border/50 bg-muted/30 px-2 py-2",children:[t.jsx("div",{className:"truncate font-mono text-lg font-semibold leading-6 text-text-strong",children:n}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] uppercase tracking-[0.12em] text-text-subtle",children:e})]})}function vT(){const{themeMode:e,setThemeMode:n}=W1();return t.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:[t.jsx("button",{type:"button",onClick:()=>n("light"),className:O("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:t.jsx(d1,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("eye-care"),className:O("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:t.jsx(ru,{className:"size-3.5"})}),t.jsx("button",{type:"button",onClick:()=>n("dark"),className:O("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:t.jsx(Ng,{className:"size-3.5"})})]})}function yT({visible:e,onToggle:n}){const s=e?"Hide Inspector pet":"Summon Inspector pet";return t.jsx("button",{type:"button",onClick:n,className:O("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":s,"aria-pressed":e,title:s,children:t.jsx(Od,{className:O("size-4 transition-opacity",!e&&"opacity-45")})})}function wT({preference:e,resolvedScale:n,onChange:s}){const o=X1(n),r=e==="auto"?`Auto (${o})`:`${e}%`;return t.jsxs(Fs,{value:e,onValueChange:a=>s(qi(a)),children:[t.jsxs(Us,{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: ${r}`,children:[t.jsx(Px,{className:"size-3.5"}),t.jsx("span",{className:"font-mono text-[10px] font-semibold tabular-nums",children:o})]}),t.jsxs(Bs,{align:"end",children:[t.jsx(Xe,{value:"auto",children:"Auto"}),t.jsx(Xe,{value:"100",children:"100%"}),t.jsx(Xe,{value:"125",children:"125%"}),t.jsx(Xe,{value:"150",children:"150%"})]})]})}const nh="agent-inspector.detailsPanelCollapsed",sh="agent-inspector.detailsPanelWidth",oh="agent-inspector.pet.visible",Yn=360,jT=288,ST=520;function rh(e){return Math.min(Math.max(e,jT),ST)}function NT(){if(typeof window>"u")return!0;try{const e=window.localStorage.getItem(nh);return e===null||e==="1"}catch{return!0}}function CT(){if(typeof window>"u")return Yn;try{const e=window.localStorage.getItem(sh);if(e===null)return Yn;const n=Number.parseInt(e,10);return Number.isFinite(n)?rh(n):Yn}catch{return Yn}}function kT(){if(typeof window>"u")return!0;try{return window.localStorage.getItem(oh)!=="0"}catch{return!0}}function Rd({label:e,logId:n}){return t.jsxs("button",{type:"button",onClick:()=>th(n),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 ${Td(n)}`,children:[e," ",Td(n)]})}function _T({latestPercent:e,peakPercent:n,risk:s,onOpenContext:o}){const r=yi(e),a=aT(e,n),i=n===null?`Latest context window usage ${Ms(e)}`:`Latest context window usage ${Ms(e)}, peak ${Ms(n)}`;return t.jsx("button",{type:"button",onClick:o,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":`${i}. Open latest Context details`,title:"Open latest Context details",children:t.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":i,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(r),children:[t.jsx("span",{className:O("block h-full rounded-full transition-[width]",iT(s)),style:{width:`${r}%`}}),a!==null&&t.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(${a}% - 0.5px)`},"aria-hidden":"true"})]})})}function TT({summary:e}){const n=e.trendPercent,s=n===null||Math.abs(n)<.1?null:n>0?Hx:zx,o=e.latest.diagnostics[0]??null,r=Ms(e.latest.usagePercent),a=Ms(e.peak.usagePercent),i=()=>{th(e.latest.logId)};return t.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:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,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}),t.jsx("span",{className:O("inline-flex h-5 shrink-0 items-center rounded border px-1.5 font-mono text-[10px]",pT(e.latest.health.level)),children:fT(e.latest.health.level)})]}),t.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:[t.jsx("span",{children:mT(e.requestCount)}),t.jsx("span",{children:lT(e)})]})]}),t.jsxs("div",{className:"min-w-0 space-y-2 text-xs",children:[t.jsx(_T,{latestPercent:e.latest.usagePercent,peakPercent:e.peak.usagePercent,risk:e.latest.riskLevel,onOpenContext:i}),t.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Latest"}),t.jsx("div",{className:O("mt-0.5 font-mono",Ed(e.latest.riskLevel)),children:r}),t.jsx(Rd,{label:"Log",logId:e.latest.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Peak"}),t.jsx("div",{className:O("mt-0.5 font-mono",Ed(e.peak.riskLevel)),children:a}),t.jsx(Rd,{label:"Log",logId:e.peak.logId})]}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:"Trend"}),t.jsxs("div",{className:"mt-0.5 flex items-center gap-1 font-mono text-foreground",children:[s!==null&&t.jsx(s,{className:O("size-3",n!==null&&n>0?"text-amber-300":"text-cyan-300")}),rT(n)]}),t.jsx("div",{className:"h-5","aria-hidden":"true"})]})]})]}),t.jsxs("div",{className:"min-w-0 space-y-1.5",children:[t.jsx(s_,{segments:e.latest.roleSegments,totalTokens:e.latest.roleTotalTokens,showLabels:!1}),t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground",children:[t.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.estimatedInputTokens)," input"]}),e.latest.windowUsedTokens!==null&&t.jsxs("span",{className:"font-mono",children:["~",Ee(e.latest.windowUsedTokens)," used"]}),o!==null&&t.jsx("span",{className:"truncate",children:o})]})]})]})}function ET({summary:e}){return e.models.length===0?null:t.jsxs("div",{className:"mt-3 border-t border-white/10 pt-2",children:[t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-normal text-muted-foreground",children:"Session Context"}),t.jsxs("div",{className:"font-mono text-[10px] text-muted-foreground",children:[e.models.length," model",e.models.length===1?"":"s"]})]}),t.jsx("div",{className:"max-h-52 overflow-y-auto pr-1",children:e.models.map(n=>t.jsx(TT,{summary:n},n.model))})]})}function RT(e){const n=e.models.filter(o=>o.latest.health.level==="risk").length;if(n>0)return`${n} risk`;const s=e.models.filter(o=>o.latest.health.level==="optimizable").length;return s>0?`${s} optimizable`:`${e.models.length} model${e.models.length===1?"":"s"}`}function MT({label:e,logs:n,totalIn:s,totalOut:o,timeDisplayFormat:r,contextSummary:a,showBackLink:i}){const[c,d]=l.useState(!1),[m,u]=l.useState(!1),p=l.useMemo(()=>Q_(n,r),[n,r]),f=l.useMemo(()=>Z_(n),[n]),h=l.useMemo(()=>RT(a),[a]),g=l.useCallback(()=>{vt(window.location.href).then(b=>{b&&(d(!0),setTimeout(()=>d(!1),2e3))})},[]);return t.jsxs("div",{className:"border border-border bg-card shadow-sm mb-3 rounded-[8px] px-3 py-2 text-xs",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i&&t.jsx("a",{href:Si("/"),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:t.jsx(Bx,{className:"size-3.5"})}),t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"font-mono font-semibold text-purple-400/90 truncate",title:e,children:kn(e)}),f!==null&&t.jsx("span",{className:"font-mono text-muted-foreground truncate max-w-[220px]",title:f,children:f})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-muted-foreground",children:[t.jsxs("span",{children:[n.length," request",n.length!==1?"s":""]}),p!==null&&t.jsx("span",{children:p}),(s>0||o>0)&&t.jsxs("span",{className:"font-mono",children:[Ee(s)," in / ",Ee(o)," out"]})]})]}),a.models.length>0&&t.jsxs("button",{type:"button",onClick:()=>u(b=>!b),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":m,title:m?"Hide context details":"Show context details",children:[t.jsx("span",{children:h}),m?t.jsx(Di,{className:"size-3.5"}):t.jsx(Ve,{className:"size-3.5"})]}),t.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":c?"Copied session link":"Copy session link",title:c?"Copied session link":"Copy session link",children:c?t.jsx(Oe,{className:"size-3.5"}):t.jsx(St,{className:"size-3.5"})})]}),m&&t.jsx(ET,{summary:a})]})}function AT({logs:e,sessions:n,selectedSession:s,selectedModel:o,onSessionChange:r,onClearAll:a,onDeleteCurrentView:i,onReloadSession:c,onClearGroup:d,onNotify:m,onImportLogs:u,viewMode:p,captureMode:f,strip:h,slowResponseThresholdSeconds:g,timeDisplayFormat:b,isLoading:y=!1,liveConnection:w,onRetryLiveConnection:v,onStopLiveConnection:j,pagination:S,sessionLoadProgress:N,sessionLoadError:C,sessionMemberships:R=[],hideSessionFilter:I=!1,pinnedSessionId:P}){const{totalIn:M,totalOut:k}=l.useMemo(()=>Cd(e),[e]),{providers:A}=Wi(),{uiScalePreference:D,resolvedUiScale:$,setUiScalePreference:J}=tb(),[X,F]=l.useState(null),[H,Y]=l.useState(null),[U,W]=l.useState(!1),[me,ge]=l.useState(!1),[be,z]=l.useState(null),[oe,te]=l.useState(null),[Se,Ne]=l.useState(!1),[ie,le]=l.useState(!1),[fe,ve]=l.useState(!0),[Ce,Ie]=l.useState(Yn),[$e,Pe]=l.useState(!1),[Ze,Bt]=l.useState(!1),[ct,Fe]=l.useState(!0),[Me,Le]=l.useState(!1),[B,ne]=l.useState(null),[ye,he]=l.useState(null),we=l.useRef(null),Be=l.useRef(null),G=l.useRef(null),_=l.useRef(null),L=l.useRef(0),V=l.useRef(null);X4(we,Be,{pageWide:!0});const[se,ce]=l.useState(null);l.useEffect(()=>Fi(ce),[]);const Q=l.useCallback(()=>{L.current+=1,_.current?.abort(),_.current=null,F(null),Y(null)},[]);l.useEffect(()=>()=>{L.current+=1,_.current?.abort(),_.current=null},[]),l.useEffect(()=>{ve(NT()),Ie(CT()),Bt(!0)},[]),l.useEffect(()=>{Ze&&window.localStorage.setItem(nh,fe?"1":"0")},[fe,Ze]),l.useEffect(()=>{if(Ze)try{window.localStorage.setItem(sh,String(Ce))}catch{}},[Ze,Ce]),l.useEffect(()=>{Fe(kT()),Le(!0)},[]),l.useEffect(()=>{if(Me)try{window.localStorage.setItem(oh,ct?"1":"0")}catch{}},[Me,ct]),l.useEffect(()=>{if(P===void 0){document.title="Agent Inspector";return}const je=e.length===1?"1 req":`${e.length} req`;document.title=`${kn(P)} - ${je} - Agent Inspector`},[e.length,P]);const pe=l.useCallback(async je=>{_.current?.abort();const qe=new AbortController;_.current=qe;const xt=L.current+1;L.current=xt,F(je),Y(null);try{const Ht=await F1(e,je,{signal:qe.signal});if(L.current!==xt)return;if(!Ht.ok){if(Ht.canceled===!0)return;m!==void 0?m({message:Ht.message,tone:"error"}):Y(Ht.message)}}finally{L.current===xt&&(_.current=null,F(null))}},[e,m]),ae=l.useCallback(je=>{if(VN(je)){W(!0);return}pe(je)},[pe]),ht=l.useCallback(()=>{W(!1),pe("redacted")},[pe]),hn=l.useCallback(()=>{W(!1),pe("raw")},[pe]),Re=l.useCallback(()=>{G.current?.click()},[]),qt=l.useCallback(je=>{const qe=je.currentTarget.files?.[0];je.currentTarget.value="",!(qe===void 0||u===void 0)&&(ge(!0),te(null),z(null),u(qe).then(xt=>{const Ht=xt.skipped>0?`, skipped ${String(xt.skipped)}`:"",zl=`Imported ${String(xt.imported)} logs as ${xt.sessionId}${Ht}.`;m!==void 0?m({message:zl,tone:"success"}):z(zl)}).catch(xt=>{const Ht=xt instanceof Error?xt.message:"Failed to import logs";m!==void 0?m({message:Ht,tone:"error"}):te(Ht)}).finally(()=>{ge(!1)}))},[u,m]);l.useEffect(()=>{Q(),he(null),ne(null)},[Q,s,o]);const dt=l.useCallback(()=>{Q(),z(null),te(null),he(null),a()},[Q,a]),xs=l.useCallback(()=>{Ne(!0)},[]),Qe=l.useCallback(()=>{Q(),z(null),te(null),he(null),i!==void 0&&(le(!0),i().then(()=>{Ne(!1)}).catch(je=>{const qe=je instanceof Error?je.message:"Failed to delete stored logs";m!==void 0?m({message:qe,tone:"error"}):te(qe)}).finally(()=>{le(!1)}))},[Q,i,m]),xn=l.useCallback(()=>{c!==void 0&&(Q(),z(null),te(null),he(null),c())},[Q,c]),ih=l.useCallback(()=>{he(null)},[]),Rl=l.useCallback(()=>{ve(je=>!je)},[]),lh=l.useCallback(je=>{V.current={startX:je.clientX,startWidth:Ce,pointerId:je.pointerId},je.currentTarget.setPointerCapture(je.pointerId),Pe(!0)},[Ce]),ch=l.useCallback(je=>{const qe=V.current;qe===null||qe.pointerId!==je.pointerId||Ie(rh(qe.startWidth+qe.startX-je.clientX))},[]),Ml=l.useCallback(je=>{const qe=V.current;qe===null||qe.pointerId!==je.pointerId||(je.currentTarget.hasPointerCapture(je.pointerId)&&je.currentTarget.releasePointerCapture(je.pointerId),V.current=null,Pe(!1))},[]),dh=l.useCallback(()=>{Ie(Yn)},[]),uh=l.useCallback(()=>{Fe(je=>!je)},[]),Br=l.useMemo(()=>B===null?null:new Set(B.logIds),[B]),gn=l.useMemo(()=>Br===null?e:e.filter(je=>Br.has(je.id)),[Br,e]),Ct=l.useMemo(()=>Yj(gn),[gn]),Al=l.useMemo(()=>X_(Ct),[Ct]),bn=l.useMemo(()=>rC({pinnedSessionId:P,selectedSession:s,sessions:n,logs:e}),[e,P,s,n]),On=bn?.logs??[],gs=bn!==null&&On.length>0,{totalIn:Il,totalOut:Pl}=l.useMemo(()=>Cd(On),[On]),mh=l.useMemo(()=>Y_(On,A),[On,A]),ph=l.useMemo(()=>j4(Ct),[Ct]),qr=l.useMemo(()=>XS(Ct),[Ct]),Ll=KN(f,e.length),fh=P!==void 0,hh=e.length>0,xh=i!==void 0&&(e.length>0||s!=="__all__"),gh=s==="__all__"?"all sessions":"this session",bh=s==="__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.",vh=e.length===0?"Load":"Reload",Hr=gs&&bn!==null?kn(bn.label):s==="__all__"?"All sessions":kn(s),Ol=E4(w),Wr=R4(Ol),yh=l.useMemo(()=>oC({logs:gn,conversationGroups:Ct,isLoading:y,timeDisplayFormat:b,slowResponseThresholdSeconds:g}),[gn,Ct,y,g,b]),wh=l.useCallback(je=>{const qe=qr.get(je.id);qe!==void 0&&he([qe,je])},[qr]),Dl=P!==void 0?P:s==="__all__"?null:s;return t.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:[t.jsx(k4,{liveConnection:w,alertsAction:t.jsx(LC,{}),settingsAction:t.jsx(w3,{})}),t.jsxs("button",{type:"button",onClick:Rl,className:O("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":fe?"Show details panel":"Hide details panel",title:fe?"Show details panel":"Hide details panel",children:[t.jsx("span",{className:"absolute bottom-2 left-1 top-2 w-px rounded-full bg-border transition-colors group-hover:bg-foreground/35"}),fe?t.jsx(Og,{className:"size-3.5"}):t.jsx(Pg,{className:"size-3.5"})]}),Me&&ct&&t.jsx($o,{feature:"Inspector Pet",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(q5,{logs:e})})}),t.jsxs("div",{className:O("flex w-full min-w-0 flex-col lg:min-h-0 lg:flex-1 lg:flex-row lg:overflow-hidden",$e&&"cursor-col-resize select-none"),children:[!fe&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",className:"fixed inset-0 z-30 bg-background/70 backdrop-blur-sm lg:hidden",onClick:Rl,"aria-label":"Close details panel"}),t.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:[t.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:lh,onPointerMove:ch,onPointerUp:Ml,onPointerCancel:Ml,onDoubleClick:dh,"aria-label":"Resize details panel",title:"Drag to resize; double-click to reset",children:t.jsx("span",{className:"h-12 w-1 rounded-full bg-border transition-colors hover:bg-primary"})}),t.jsxs("div",{className:"flex min-h-full flex-col gap-4 p-4",children:[t.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:[t.jsx(Da,{label:"View",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx(vT,{}),t.jsx(wT,{preference:D,resolvedScale:$,onChange:J})]})}),t.jsx(Da,{label:"Workspace",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(nk,{labelledTrigger:!0}),t.jsx(s4,{currentSessionId:Dl,logCount:e.length,labelledTrigger:!0})]})})]}),t.jsxs(Da,{label:"Current scope",children:[t.jsxs("div",{className:"mb-2 rounded-md border border-border/50 bg-muted/25 px-3 py-2",children:[t.jsx("div",{className:"truncate font-mono text-xs font-semibold text-text-link",title:Hr,children:Hr}),t.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:fh?"Pinned session":"Live Inspector data"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx(To,{label:B===null?"Requests":"Results",value:gn.length}),t.jsx(To,{label:"Sessions",value:n.length}),t.jsx(To,{label:"Input",value:Ee(gs?Il:M)}),t.jsx(To,{label:"Output",value:Ee(gs?Pl:k)})]}),N!==void 0&&t.jsx("div",{className:"mt-2 rounded-md border border-border/50 bg-muted/25 px-2 py-2",children:t.jsx(Do,{progress:N})})]}),gs&&bn!==null&&t.jsx(MT,{label:bn.label,logs:On,totalIn:Il,totalOut:Pl,timeDisplayFormat:b,contextSummary:mh,showBackLink:bn.showBackLink}),gs&&P!==void 0&&R.length>0&&t.jsx(kd,{memberships:R}),t.jsx("div",{className:"flex-1"}),t.jsx(w4,{currentSessionId:Dl,logCount:e.length,onResultChange:ne})]})]})]}),t.jsxs("main",{className:"inspector-scrollbar order-2 min-w-0 lg:order-1 lg:h-full lg:flex-1 lg:overflow-y-auto",children:[t.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:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"min-w-[180px] flex-1",children:[t.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Logs"}),t.jsx("div",{className:"mt-0.5 font-mono text-[11px] text-muted-foreground",children:Hr})]}),t.jsx(yT,{visible:ct,onToggle:uh}),u!==void 0&&t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:G,type:"file",accept:".zip,.json,.jsonl,application/zip,application/json",className:"hidden",onChange:qt}),t.jsx("button",{type:"button",onClick:Re,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?t.jsx("span",{children:"Importing..."}):t.jsxs(t.Fragment,{children:[t.jsx(fu,{className:"size-3.5"}),t.jsx("span",{children:"Import"})]})})]}),Ll.redacted&&t.jsx("button",{type:"button",onClick:()=>{ae("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"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(Vs,{className:"size-3.5"}),t.jsx("span",{children:"Export"})]})}),Ll.raw&&t.jsx("button",{type:"button",onClick:()=>{ae("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"?t.jsx("span",{children:"Exporting..."}):t.jsxs(t.Fragment,{children:[t.jsx(H0,{className:"size-3.5"}),t.jsx("span",{children:"Raw"})]})}),c!==void 0&&t.jsxs("button",{type:"button",onClick:xn,disabled:y,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:[t.jsx(yt,{className:O("size-3.5",y&&"animate-spin motion-reduce:animate-none")}),t.jsx("span",{children:vh})]}),t.jsxs("button",{type:"button",onClick:dt,disabled:!hh,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:[t.jsx(an,{className:"size-3.5"}),t.jsx("span",{children:"Clear"})]}),i!==void 0&&t.jsxs("button",{type:"button",onClick:xs,disabled:!xh||ie,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:[t.jsx(an,{className:"size-3.5"}),t.jsx("span",{children:"Delete"})]})]}),S===void 0&&N!==void 0&&t.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:t.jsx(Do,{progress:N})}),C!==void 0&&t.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:[t.jsxs("span",{className:"min-w-0 flex-1",children:["Session logs could not be loaded. ",C," Existing logs remain visible."]}),c!==void 0&&t.jsxs("button",{type:"button",onClick:xn,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:[t.jsx(yt,{className:"size-3"}),"Retry"]})]}),B!==null&&t.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:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-xs font-medium text-cyan-50",children:B.question}),t.jsxs("div",{className:"mt-0.5 text-[10px] text-muted-foreground",children:["Showing ",String(gn.length)," loaded logs from"," ",String(B.logIds.length)," linked results"]})]}),t.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:[t.jsx(Gs,{className:"size-3"}),"All logs"]})]}),B===null&&t.jsx(_d,{logs:e,pagination:S,embedded:!0}),m===void 0&&H!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:H}),m===void 0&&oe!==null&&t.jsx("div",{className:"mt-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:oe}),m===void 0&&be!==null&&oe===null&&t.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:be}),w!==void 0&&w.status!=="live"&&v!==void 0&&j!==void 0&&t.jsx(N4,{state:w,hasLogs:e.length>0,onRetry:v,onStop:j})]}),t.jsxs("div",{className:"px-4 py-4 lg:px-5",children:[t.jsx(oT,{stats:yh}),B!==null&&gn.length===0?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.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:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:"No linked logs are loaded"}),t.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."}),t.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?s!=="__all__"?t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.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:[t.jsx("p",{className:"text-sm font-medium",children:y?"Loading session data...":C===void 0?"No logs loaded for this session":"Session logs could not be loaded"}),t.jsx("p",{className:"inline-block max-w-full rounded bg-muted px-3 py-1 font-mono text-xs break-all",children:kn(s)}),N!==void 0&&t.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:t.jsx(Do,{progress:N})}),R.length>0&&t.jsx("div",{className:"text-left",children:t.jsx(kd,{memberships:R})}),!y&&t.jsxs("div",{className:"flex flex-col items-center gap-3 text-xs",children:[t.jsx("p",{children:"Stored logs may still be available."}),t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[c!==void 0&&t.jsxs("button",{type:"button",onClick:xn,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:[t.jsx(yt,{className:"size-3.5"}),t.jsx("span",{children:"Load session"})]}),I?t.jsx("a",{href:Si("/"),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"}):t.jsx("button",{type:"button",onClick:()=>r("__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"})]})]})]})}):t.jsx("div",{className:"py-16 text-center text-muted-foreground",children:t.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:[t.jsx("p",{className:"text-sm font-medium",children:Wr.title}),t.jsx("p",{className:"mx-auto max-w-xl text-xs leading-relaxed text-muted-foreground",children:Wr.description}),Ol==="empty"&&n.length>0&&t.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."}),Wr.showConnectionCommands&&se!==null&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Cs,{command:`ANTHROPIC_BASE_URL=${se.proxy} <your-tool>`}),t.jsx(Cs,{command:`LLM_BASE_URL=${se.proxy} opencode`}),t.jsx(Cs,{command:`OPENAI_BASE_URL=${se.openAiV1} <your-tool>`}),t.jsx(Cs,{command:`base_url = "${se.openAiV1}"`}),t.jsx(Cs,{command:`MCP_URL=${se.mcp}`})]}),t.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."})]})]})}):t.jsxs("div",{ref:Be,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:[t.jsx("div",{ref:we,children:t.jsx(U4,{groups:Ct,viewMode:p,strip:h,slowResponseThresholdSeconds:g,cacheTrends:ph,onCompareWithPrevious:wh,comparisonPredecessors:qr,onClearGroup:d,defaultExpanded:Ct.length===1,timeDisplayFormat:b})}),B===null&&t.jsx("div",{className:"mt-3",children:t.jsx(_d,{logs:e,pagination:S})})]})]})]})]}),t.jsx(Pt,{open:U,onOpenChange:W,children:t.jsx(Lt,{className:H4,children:t.jsx(V4,{onCancel:()=>W(!1),onExportRedacted:ht,onConfirmRaw:hn})})}),t.jsx(Pt,{open:Se,onOpenChange:Ne,children:t.jsxs(Lt,{className:"border-red-500/20 bg-zinc-950 text-zinc-100 sm:max-w-md",children:[t.jsxs(Ft,{children:[t.jsxs(Ut,{children:["Delete ",gh," history?"]}),t.jsx(Qs,{children:"Clear only hides logs from the UI. Delete removes stored history from disk."})]}),t.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:[t.jsx("span",{className:"block font-medium",children:"This is a full history delete."}),t.jsx("span",{className:"mt-1 block text-xs text-red-200/80",children:bh})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx(ee,{type:"button",variant:"outline",size:"sm",disabled:ie,onClick:()=>Ne(!1),children:"Cancel"}),t.jsx(ee,{type:"button",variant:"destructive",size:"sm",disabled:ie,onClick:Qe,children:ie?"Deleting...":"Delete history"})]})]})}),ye!==null&&t.jsx($o,{feature:"Compare",children:t.jsx(l.Suspense,{fallback:null,children:t.jsx(B5,{left:ye[0],right:ye[1],leftDisplayNumber:Nd(ye[0],Al),rightDisplayNumber:Nd(ye[1],Al),onClose:ih})})})]})}function IT(e,n,s){return n==="__all__"&&s==="__all__"?e:e.filter(o=>!(n!=="__all__"&&o.sessionId!==n||s!=="__all__"&&o.model!==s))}function Eo(e,n){if(e.length===0)return[...n];if(n.length===0)return[...e];const s=new Map;for(const o of e)s.set(o.id,o);for(const o of n)s.set(o.id,o);return[...s.values()].toSorted((o,r)=>o.id-r.id)}function Nn(e,n){const s=new Set;for(const o of e)o!==""&&s.add(o);for(const o of n)o!==""&&s.add(o);return[...s].sort()}function PT(e){const n=new URLSearchParams({compact:"1"});e!==void 0&&n.set("sessionId",e);const s=Eh();return s.ok?Rh(s.runtime,`/api/logs/stream?${n.toString()}`):null}function LT(e){const n=PT(e);return n===null?null:new EventSource(n)}const OT=Ot([T({type:re("init"),logs:K(Is)}),T({type:re("update"),log:Is})]),DT=T({logs:K(Is),total:E().int().nonnegative(),limit:E().int().positive(),hasOlder:_e(),hasNewer:_e(),oldestLogId:E().int().positive().nullable(),newestLogId:E().int().positive().nullable()}),zT=K(x()),Md=T({success:_e(),cleared:E().int().nonnegative(),logFilesRewritten:E().int().nonnegative().optional(),chunkFilesDeleted:E().int().nonnegative(),sessionArchiveLogsDeleted:E().int().nonnegative().optional()});function $T(e,n){const s=[];for(const o of e)for(const r of o.members)r.sessionId===n&&s.push({groupId:o.id,groupTitle:o.title,groupKind:o.kind,groupStatus:o.status,groupTask:o.task,groupProject:o.project,groupEvidence:o.evidence,member:r});return s}function Ro(e){const n=new Set;for(const s of e)s.sessionId!==null&&s.sessionId!==""&&n.add(s.sessionId);return[...n]}function FT(e){const n=new Set;for(const s of e)s.model!==null&&s.model!==""&&n.add(s.model);return[...n]}const UT=100,BT=12,qT=1800,El=100,mr=500,ah=200,wi=2e4,HT=1e4,WT=3e3,VT=1e4;function KT(e,n,s=El){const o=new URLSearchParams({cursor:"1",compact:"1",limit:String(s),sessionId:e});switch(n.kind){case"oldest":o.set("anchor","oldest");break;case"older":o.set("beforeLogId",String(n.beforeLogId));break;case"newer":o.set("afterLogId",String(n.afterLogId));break}return`/api/logs?${o.toString()}`}function Qt(e){const n=new Map;for(let s=0;s<e.length;s++){const o=e[s];o!==void 0&&n.set(o.id,s)}return n}function As(e,n,s=El){return De(KT(e,n,s),DT,wi)}async function GT(e,n){const s=new Set;let o=await As(e,{kind:"oldest"},mr);for(const a of o.logs)s.add(a.id);n(s.size,1);let r=1;for(;o.hasNewer&&o.newestLogId!==null&&r<ah;){o=await As(e,{kind:"newer",afterLogId:o.newestLogId},mr);for(const a of o.logs)s.add(a.id);r+=1,n(s.size,r)}return{ids:[...s],truncated:o.hasNewer}}async function JT(){try{return{deleted:(await Ge("/api/groups",Yd,{method:"DELETE"})).deleted,ok:!0}}catch{return{deleted:0,ok:!1}}}function QT({initialSessionId:e}={}){const[n,s]=l.useState([]),[o,r]=l.useState(e??"__all__"),[a,i]=l.useState("__all__"),[c,d]=l.useState([]),{notice:m,showToast:u,dismissToast:p}=vf(),[f,h]=l.useState(T4),[g,b]=l.useState(null),[y,w]=l.useState(e!==void 0),[v,j]=l.useState(null),[S,N]=l.useState(void 0),[C,R]=l.useState([]),[,I]=l.useTransition(),P=l.useRef(null),M=l.useRef(null),k=l.useRef(null),A=l.useRef(!0),D=l.useRef(null),$=l.useRef(0),J=l.useRef(null),X=l.useRef(null),F=l.useRef(new Map),H=l.useRef([]),Y=l.useRef(null),U=l.useCallback(G=>{u({message:G,tone:"error"})},[u]),W=l.useCallback(()=>{X.current!==null&&(clearInterval(X.current),X.current=null),J.current=null,N(void 0)},[]),me=l.useCallback((G,_,L=0,V=0)=>{X.current!==null&&clearInterval(X.current);const se=Date.now();J.current=se;const ce=()=>{$.current===_&&N({label:G,elapsedMs:Date.now()-se,timeoutMs:wi,loadedLogs:L,loadedPages:V})};ce(),X.current=setInterval(ce,250)},[]),ge=l.useCallback((G,_,L,V)=>{const se=J.current;se===null||$.current!==_||N({label:G,elapsedMs:Date.now()-se,timeoutMs:wi,loadedLogs:L,loadedPages:V})},[]),be=l.useMemo(()=>IT(n,o,a),[n,o,a]),z=l.useMemo(()=>Nn(c,Ro(n)),[n,c]),oe=l.useMemo(()=>FT(n),[n]),te=l.useCallback(()=>{Ge("/api/sessions",zT).then(G=>{d(_=>Nn(_,G))}).catch(()=>{})},[]),Se=l.useCallback(()=>{Y.current=null;const G=H.current;H.current=[],G.length!==0&&I(()=>{s(_=>{const L=Eo(_,G);return F.current=Qt(L),L})})},[I]),Ne=l.useCallback(G=>{H.current.push(G),Y.current===null&&(Y.current=setTimeout(Se,UT))},[Se]),ie=l.useCallback(()=>{P.current&&P.current.close(),M.current!==null&&(clearTimeout(M.current),M.current=null),h(_=>kt(_,{type:"connect-requested"}));const G=LT(e);if(G===null){h(_=>kt(_,{type:"recoverable-error",message:"The browser runtime does not provide a valid log stream endpoint."})),U("Failed to resolve the live stream endpoint");return}P.current=G,G.onmessage=_=>{try{const L=String(_.data),V=JSON.parse(L),se=OT.safeParse(V);if(!se.success){h(Q=>kt(Q,{type:"recoverable-error",message:"The live stream returned invalid data."})),U("Failed to parse SSE data");return}const ce=se.data;ce.type==="init"?(Y.current!==null&&(clearTimeout(Y.current),Y.current=null),H.current=[],s(Q=>{const pe=Eo(Q,ce.logs);return F.current=Qt(pe),pe}),d(Q=>Nn(Q,Ro(ce.logs))),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>kt(Q,{type:"message-received",at:Date.now()})),p()):ce.type==="update"&&(d(Q=>ce.log.sessionId===null||ce.log.sessionId===""?Q:Nn(Q,[ce.log.sessionId])),Ne(ce.log),k.current!==null&&(clearTimeout(k.current),k.current=null),h(Q=>kt(Q,{type:"message-received",at:Date.now()})))}catch{h(L=>kt(L,{type:"recoverable-error",message:"The live stream returned malformed JSON."})),U("Failed to parse SSE data")}},G.onerror=()=>{const _=navigator.onLine;h(L=>kt(L,{type:"connection-lost",online:_,message:"The live stream disconnected."})),G.close(),!(!_||!A.current)&&(k.current===null&&(k.current=setTimeout(()=>{k.current=null,h(L=>kt(L,{type:"stale-timeout"}))},VT)),M.current=setTimeout(ie,WT))}},[p,e,Ne,U]),le=l.useCallback(()=>{A.current=!0,M.current!==null&&(clearTimeout(M.current),M.current=null),ie()},[ie]),fe=l.useCallback(()=>{A.current=!1,P.current?.close(),P.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(G=>kt(G,{type:"stop-retrying"}))},[]),ve=l.useCallback(G=>{if(e===void 0)return;const _=$.current+1;$.current=_,w(!0),j(null),me("Loading session logs",_),p(),As(e,G).then(L=>{if($.current!==_)return;const V=L.logs;F.current=Qt(V),s(V),b(L),r(e),w(!1),j(null),W(),p()}).catch(L=>{if($.current!==_)return;w(!1),W();const V=L instanceof Error?L.message:"Failed to load session logs";j(V),U(V)})},[p,e,U,me,W]),Ce=l.useCallback(G=>{const _=$.current+1;$.current=_,w(!0),j(null),me("Reloading full session",_),p(),(async()=>{const L=[];let V=await As(G,{kind:"oldest"},mr);L.push(...V.logs),ge("Reloading full session",_,L.length,1);let se=1;for(;V.hasNewer&&V.newestLogId!==null&&se<ah;)V=await As(G,{kind:"newer",afterLogId:V.newestLogId},mr),L.push(...V.logs),se+=1,ge("Reloading full session",_,L.length,se);$.current===_&&(s(ce=>{const Q=Eo(ce,L);return F.current=Qt(Q),Q}),d(ce=>Nn(ce,[G])),w(!1),j(null),W(),V.hasNewer?u({message:`Loaded ${String(L.length)} logs for this session. More history is available.`,tone:"success"}):p())})().catch(L=>{if($.current!==_)return;w(!1),W();const V=L instanceof Error?L.message:"Failed to reload session logs";j(V),U(V)})},[p,U,u,me,W,ge]);l.useEffect(()=>{if(e===void 0){R([]);return}let G=!1;return De("/api/groups",Qd,HT).then(_=>_.groups).then(_=>{G||_===null||R($T(_,e))}).catch(()=>{G||R([])}),()=>{G=!0}},[e]),l.useEffect(()=>{te()},[te]),l.useEffect(()=>()=>{W()},[W]),l.useEffect(()=>{e!==void 0&&ve({kind:"newest"})},[e,ve]),l.useEffect(()=>{e===void 0&&o!=="__all__"&&Ce(o)},[e,Ce,o]),l.useEffect(()=>{if(e!==void 0)return;ie();const G=()=>{P.current?.close(),P.current=null,M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),h(L=>kt(L,{type:"browser-offline"}))},_=()=>{A.current&&ie()};return window.addEventListener("offline",G),window.addEventListener("online",_),()=>{window.removeEventListener("offline",G),window.removeEventListener("online",_),P.current&&(P.current.close(),P.current=null),M.current!==null&&(clearTimeout(M.current),M.current=null),k.current!==null&&(clearTimeout(k.current),k.current=null),Y.current!==null&&(clearTimeout(Y.current),Y.current=null)}},[ie,e]),l.useEffect(()=>{const G=window.location.hash;if(!G.startsWith("#log-")||D.current===G)return;const _=G.slice(1),L=Number(_.replace(/^log-/,""));Number.isInteger(L)&&L>0&&ds({logId:L,tab:"request"});let V=!1,se=0,ce=null,Q=null;const pe=()=>{if(V)return;const ae=document.getElementById(_);if(ae!==null){D.current=G,ae.scrollIntoView({block:"center",behavior:Uf(Bf())}),ae instanceof HTMLElement&&(ce=ae,ae.setAttribute("data-deep-link-highlight","true"),Q=window.setTimeout(()=>{ae.removeAttribute("data-deep-link-highlight")},qT),ae.focus({preventScroll:!0}),ae.getAttribute("data-nav-action")==="expand"&&ae.click());return}se+=1,se<BT&&window.setTimeout(pe,100)};return pe(),()=>{V=!0,Q!==null&&window.clearTimeout(Q),ce!==null&&ce.removeAttribute("data-deep-link-highlight")}},[be.length]);const Ie=l.useCallback(()=>{const G=Ro(n);W(),w(!1),F.current.clear(),s([]),b(null),d(_=>Nn(_,G)),u({message:"Cleared the current view. Stored logs are still reloadable.",tone:"success"})},[n,u,W]),$e=l.useCallback(G=>{if(G.length===0)return;const _=new Set(G);s(L=>{const V=L.filter(ce=>_.has(ce.id)),se=L.filter(ce=>!_.has(ce.id));return d(ce=>Nn(ce,Ro(V))),F.current=Qt(se),se}),u({message:"Cleared this group from the current view.",tone:"success"})},[u]),Pe=l.useCallback(async()=>{const G=$.current+1;$.current=G,w(!0),W(),p();try{if(o==="__all__"){me("Deleting stored history",G);const Q=await Ge("/api/logs",Md,{method:"DELETE"}),pe=await JT();if($.current!==G)return;s([]),F.current.clear(),b(null),d([]),R([]),w(!1),W();const ae=pe.ok?` Cleared ${pe.deleted.toString()} group${pe.deleted===1?"":"s"}.`:" Group cleanup failed; open Groups to retry Clear.";u({message:`Deleted ${Q.cleared.toString()} stored log${Q.cleared===1?"":"s"} across all sessions.${ae}`,tone:pe.ok?"success":"error"});return}const _=o;me("Deleting session history",G);const L=await GT(_,(Q,pe)=>{ge("Deleting session history",G,Q,pe)}),V=new Set(L.ids);for(const Q of n)Q.sessionId===_&&V.add(Q.id);const se=[...V].filter(Q=>Number.isInteger(Q)&&Q>=0);if(se.length===0){if($.current!==G)return;s(Q=>{const pe=Q.filter(ae=>ae.sessionId!==_);return F.current=Qt(pe),pe}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(pe=>pe.sessionId!==_)}),d(Q=>Q.filter(pe=>pe!==_)),w(!1),W(),u({message:"No stored log records were found for this session.",tone:"success"});return}const ce=await Ge("/api/logs",Md,{method:"DELETE",headers:{"content-type":"application/json"},body:JSON.stringify({ids:se})});if($.current!==G)return;s(Q=>{const pe=Q.filter(ae=>ae.sessionId!==_);return F.current=Qt(pe),pe}),b(Q=>Q===null?null:{...Q,logs:Q.logs.filter(pe=>pe.sessionId!==_)}),d(Q=>Q.filter(pe=>pe!==_)),w(!1),W(),u({message:`Deleted ${ce.cleared.toString()} stored log${ce.cleared===1?"":"s"} for this session${L.truncated?". More history may remain.":"."}`,tone:L.truncated?"error":"success"})}finally{$.current===G&&(w(!1),W())}},[n,p,o,u,me,W,ge]),Ze=l.useCallback(()=>{if(e!==void 0){ve({kind:"newest"});return}if(o==="__all__"){te();return}Ce(o)},[e,ve,te,Ce,o]),Bt=l.useCallback(async G=>{const _=new FormData;_.set("file",G);const L=await Ge("/api/logs/import",Cx,{method:"POST",body:_});return s(V=>{const se=new Set(L.logs.map(Q=>Q.id)),ce=Eo(V.filter(Q=>!se.has(Q.id)),L.logs);return F.current=Qt(ce),ce}),r(L.sessionId),i("__all__"),b(null),p(),L},[p]),{strip:ct,captureMode:Fe,slowResponseThresholdSeconds:Me,timeDisplayFormat:Le}=Li(),B=Fe,ne=l.useCallback(()=>{ve({kind:"oldest"})},[ve]),ye=l.useCallback(()=>{ve({kind:"newest"})},[ve]),he=l.useCallback(()=>{const G=n[0],_=g?.oldestLogId??G?.id??null;_!==null&&ve({kind:"older",beforeLogId:_})},[n,ve,g]),we=l.useCallback(()=>{const G=n[n.length-1],_=g?.newestLogId??G?.id??null;_!==null&&ve({kind:"newer",afterLogId:_})},[n,ve,g]),Be=l.useMemo(()=>{if(e!==void 0)return{isLoading:y,loadProgress:S,total:g?.total??null,pageSize:g?.limit??El,hasOlder:g?.hasOlder??!1,hasNewer:g?.hasNewer??!1,oldestLogId:g?.oldestLogId??null,newestLogId:g?.newestLogId??null,onOldest:ne,onOlder:he,onNewer:we,onNewest:ye}},[e,ye,we,he,ne,g,S,y]);return t.jsxs(t.Fragment,{children:[t.jsx(yf,{notice:m,onDismiss:p}),t.jsx(_1,{}),t.jsx(AT,{logs:be,sessions:z,models:oe,selectedSession:o,selectedModel:a,onSessionChange:r,onModelChange:i,onClearAll:Ie,onDeleteCurrentView:Pe,onReloadSession:e!==void 0||o!=="__all__"?Ze:void 0,onClearGroup:$e,onNotify:u,onImportLogs:e===void 0?Bt:void 0,isLoading:e===void 0&&f.status==="connecting"&&f.lastSuccessAt===null||y,liveConnection:e===void 0?f:void 0,onRetryLiveConnection:le,onStopLiveConnection:fe,pagination:Be,sessionLoadProgress:S,sessionLoadError:v??void 0,sessionMemberships:C,viewMode:B,captureMode:Fe,strip:ct,slowResponseThresholdSeconds:Me,timeDisplayFormat:Le,hideSessionFilter:e!==void 0,pinnedSessionId:e})]})}export{rn as $,Z4 as A,ke as B,A0 as C,Pt as D,ZT as E,Ve as F,xe as G,NS as H,dg as I,XT as J,nu as K,G5 as L,cu as M,CS as N,kS as O,QT as P,In as Q,Wg as R,s_ as S,ef as T,li as U,tr as V,p4 as W,Gs as X,w0 as Y,Ps as Z,Z as _,Jj as a,Ae as a0,Dd as a1,F5 as a2,l0 as a3,Bl as b,q as c,du as d,it as e,Oe as f,Wp as g,St as h,Lt as i,Ft as j,Ut as k,mu as l,tf as m,tn as n,ut as o,vg as p,hs as q,Ds as r,et as s,tt as t,Wi as u,nt as v,ds as w,Is as x,F_ as y,Q4 as z};
|