@atlascrew/apparatus 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/apparatus.mjs +2 -0
- package/certs/server.crt +17 -0
- package/certs/server.key +28 -0
- package/dist/ai/client.js +104 -0
- package/dist/ai/client.js.map +1 -0
- package/dist/ai/personas.js +104 -0
- package/dist/ai/personas.js.map +1 -0
- package/dist/ai/redteam.js +1404 -0
- package/dist/ai/redteam.js.map +1 -0
- package/dist/ai/report-store.js +309 -0
- package/dist/ai/report-store.js.map +1 -0
- package/dist/app.js +525 -0
- package/dist/app.js.map +1 -0
- package/dist/attack-sim.js +69 -0
- package/dist/attack-sim.js.map +1 -0
- package/dist/attacker-tracker.js +276 -0
- package/dist/attacker-tracker.js.map +1 -0
- package/dist/blackhole.js +95 -0
- package/dist/blackhole.js.map +1 -0
- package/dist/chaos.js +88 -0
- package/dist/chaos.js.map +1 -0
- package/dist/cluster.js +462 -0
- package/dist/cluster.js.map +1 -0
- package/dist/config.js +61 -0
- package/dist/config.js.map +1 -0
- package/dist/deception.js +205 -0
- package/dist/deception.js.map +1 -0
- package/dist/demo-mode.js +109 -0
- package/dist/demo-mode.js.map +1 -0
- package/dist/dist-dashboard/assets/index-BsMhEnGu.js +648 -0
- package/dist/dist-dashboard/assets/index-CNOkYC_Q.css +10 -0
- package/dist/dist-dashboard/assets/index-CW2grvPC.js +648 -0
- package/dist/dist-dashboard/assets/logo/apparatus-favicon.svg +15 -0
- package/dist/dist-dashboard/assets/logo/apparatus-icon-dark.svg +24 -0
- package/dist/dist-dashboard/assets/logo/apparatus-icon-light.svg +24 -0
- package/dist/dist-dashboard/assets/logo/apparatus-logo-512.png +0 -0
- package/dist/dist-dashboard/assets/logo/apparatus-logo-dark.svg +18 -0
- package/dist/dist-dashboard/assets/logo/apparatus-logo.svg +17 -0
- package/dist/dist-dashboard/assets/logo/apple-touch-icon.png +0 -0
- package/dist/dist-dashboard/assets/logo/favicon-192.png +0 -0
- package/dist/dist-dashboard/assets/logo/favicon-32.png +0 -0
- package/dist/dist-dashboard/assets/logo/favicon.ico +0 -0
- package/dist/dist-dashboard/assets/logo/icon-192.png +0 -0
- package/dist/dist-dashboard/assets/logo/icon-512.png +0 -0
- package/dist/dist-dashboard/assets/logo/icon-light-512.png +0 -0
- package/dist/dist-dashboard/assets/react-vendor-DpRMSntD.js +1 -0
- package/dist/dist-dashboard/assets/router-DSc5pRwN.js +59 -0
- package/dist/dist-dashboard/docs-index.json +1577 -0
- package/dist/dist-dashboard/index.html +21 -0
- package/dist/dlp.js +40 -0
- package/dist/dlp.js.map +1 -0
- package/dist/drills.js +770 -0
- package/dist/drills.js.map +1 -0
- package/dist/echoHandler.js +113 -0
- package/dist/echoHandler.js.map +1 -0
- package/dist/escape/index.js +225 -0
- package/dist/escape/index.js.map +1 -0
- package/dist/escape/methods/dns.js +74 -0
- package/dist/escape/methods/dns.js.map +1 -0
- package/dist/escape/methods/http.js +81 -0
- package/dist/escape/methods/http.js.map +1 -0
- package/dist/escape/methods/icmp.js +36 -0
- package/dist/escape/methods/icmp.js.map +1 -0
- package/dist/escape/methods/tcp.js +38 -0
- package/dist/escape/methods/tcp.js.map +1 -0
- package/dist/escape/methods/udp.js +27 -0
- package/dist/escape/methods/udp.js.map +1 -0
- package/dist/escape/methods/websocket.js +37 -0
- package/dist/escape/methods/websocket.js.map +1 -0
- package/dist/forensics.js +111 -0
- package/dist/forensics.js.map +1 -0
- package/dist/generator.js +67 -0
- package/dist/generator.js.map +1 -0
- package/dist/ghosting.js +414 -0
- package/dist/ghosting.js.map +1 -0
- package/dist/graphql.js +44 -0
- package/dist/graphql.js.map +1 -0
- package/dist/history.js +40 -0
- package/dist/history.js.map +1 -0
- package/dist/imposter/creds.js +16 -0
- package/dist/imposter/creds.js.map +1 -0
- package/dist/imposter/index.js +44 -0
- package/dist/imposter/index.js.map +1 -0
- package/dist/imposter/providers/aws.js +103 -0
- package/dist/imposter/providers/aws.js.map +1 -0
- package/dist/imposter/providers/gcp.js +26 -0
- package/dist/imposter/providers/gcp.js.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/infra-debug.js +68 -0
- package/dist/infra-debug.js.map +1 -0
- package/dist/jwt-debug.js +272 -0
- package/dist/jwt-debug.js.map +1 -0
- package/dist/kv.js +22 -0
- package/dist/kv.js.map +1 -0
- package/dist/lib/generators.js +43 -0
- package/dist/lib/generators.js.map +1 -0
- package/dist/lib/json.js +26 -0
- package/dist/lib/json.js.map +1 -0
- package/dist/logger.js +9 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics.js +20 -0
- package/dist/metrics.js.map +1 -0
- package/dist/mtd.js +30 -0
- package/dist/mtd.js.map +1 -0
- package/dist/oidc.js +69 -0
- package/dist/oidc.js.map +1 -0
- package/dist/persistence/cluster-state.js +47 -0
- package/dist/persistence/cluster-state.js.map +1 -0
- package/dist/persistence/deception-history.js +65 -0
- package/dist/persistence/deception-history.js.map +1 -0
- package/dist/persistence/drill-runs.js +138 -0
- package/dist/persistence/drill-runs.js.map +1 -0
- package/dist/persistence/request-history.js +41 -0
- package/dist/persistence/request-history.js.map +1 -0
- package/dist/persistence/scenario-catalog.js +73 -0
- package/dist/persistence/scenario-catalog.js.map +1 -0
- package/dist/persistence/status.js +51 -0
- package/dist/persistence/status.js.map +1 -0
- package/dist/persistence/tarpit-state.js +47 -0
- package/dist/persistence/tarpit-state.js.map +1 -0
- package/dist/persistence/webhook-store.js +69 -0
- package/dist/persistence/webhook-store.js.map +1 -0
- package/dist/proxy.js +28 -0
- package/dist/proxy.js.map +1 -0
- package/dist/ratelimit.js +32 -0
- package/dist/ratelimit.js.map +1 -0
- package/dist/redteam.js +442 -0
- package/dist/redteam.js.map +1 -0
- package/dist/scenarios.js +229 -0
- package/dist/scenarios.js.map +1 -0
- package/dist/scripting.js +30 -0
- package/dist/scripting.js.map +1 -0
- package/dist/self-healing.js +42 -0
- package/dist/self-healing.js.map +1 -0
- package/dist/sentinel.js +50 -0
- package/dist/sentinel.js.map +1 -0
- package/dist/server-bad-ssl.js +47 -0
- package/dist/server-bad-ssl.js.map +1 -0
- package/dist/server-grpc.js +66 -0
- package/dist/server-grpc.js.map +1 -0
- package/dist/server-http1.js +5 -0
- package/dist/server-http1.js.map +1 -0
- package/dist/server-http2.js +27 -0
- package/dist/server-http2.js.map +1 -0
- package/dist/server-icap.js +46 -0
- package/dist/server-icap.js.map +1 -0
- package/dist/server-l4.js +30 -0
- package/dist/server-l4.js.map +1 -0
- package/dist/server-mqtt.js +29 -0
- package/dist/server-mqtt.js.map +1 -0
- package/dist/server-protocols.js +18 -0
- package/dist/server-protocols.js.map +1 -0
- package/dist/server-redis.js +112 -0
- package/dist/server-redis.js.map +1 -0
- package/dist/server-smtp.js +66 -0
- package/dist/server-smtp.js.map +1 -0
- package/dist/server-syslog.js +23 -0
- package/dist/server-syslog.js.map +1 -0
- package/dist/server-ws.js +18 -0
- package/dist/server-ws.js.map +1 -0
- package/dist/sidecar/chaos/engine.js +41 -0
- package/dist/sidecar/chaos/engine.js.map +1 -0
- package/dist/sidecar/index.js +98 -0
- package/dist/sidecar/index.js.map +1 -0
- package/dist/simulator/dependency-graph.js +102 -0
- package/dist/simulator/dependency-graph.js.map +1 -0
- package/dist/simulator/supply-chain.js +67 -0
- package/dist/simulator/supply-chain.js.map +1 -0
- package/dist/sink.js +24 -0
- package/dist/sink.js.map +1 -0
- package/dist/sse-broadcast.js +105 -0
- package/dist/sse-broadcast.js.map +1 -0
- package/dist/swagger.js +309 -0
- package/dist/swagger.js.map +1 -0
- package/dist/sysinfo.js +36 -0
- package/dist/sysinfo.js.map +1 -0
- package/dist/tarpit.js +126 -0
- package/dist/tarpit.js.map +1 -0
- package/dist/tool-executor.js +315 -0
- package/dist/tool-executor.js.map +1 -0
- package/dist/tui/api-client.js +341 -0
- package/dist/tui/api-client.js.map +1 -0
- package/dist/tui/core/action-handler.js +302 -0
- package/dist/tui/core/action-handler.js.map +1 -0
- package/dist/tui/core/index.js +18 -0
- package/dist/tui/core/index.js.map +1 -0
- package/dist/tui/core/keyboard.js +329 -0
- package/dist/tui/core/keyboard.js.map +1 -0
- package/dist/tui/core/modal.js +397 -0
- package/dist/tui/core/modal.js.map +1 -0
- package/dist/tui/core/screen-manager.js +262 -0
- package/dist/tui/core/screen-manager.js.map +1 -0
- package/dist/tui/core/store.js +254 -0
- package/dist/tui/core/store.js.map +1 -0
- package/dist/tui/core/widget.js +167 -0
- package/dist/tui/core/widget.js.map +1 -0
- package/dist/tui/dashboard.js +649 -0
- package/dist/tui/dashboard.js.map +1 -0
- package/dist/tui/index.js +118 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/modals/add-rule-modal.js +190 -0
- package/dist/tui/modals/add-rule-modal.js.map +1 -0
- package/dist/tui/modals/dlp-output-modal.js +102 -0
- package/dist/tui/modals/dlp-output-modal.js.map +1 -0
- package/dist/tui/modals/dns-form-modal.js +26 -0
- package/dist/tui/modals/dns-form-modal.js.map +1 -0
- package/dist/tui/modals/ghost-config-modal.js +35 -0
- package/dist/tui/modals/ghost-config-modal.js.map +1 -0
- package/dist/tui/modals/har-results-modal.js +41 -0
- package/dist/tui/modals/har-results-modal.js.map +1 -0
- package/dist/tui/modals/index.js +15 -0
- package/dist/tui/modals/index.js.map +1 -0
- package/dist/tui/modals/jwt-decode-modal.js +45 -0
- package/dist/tui/modals/jwt-decode-modal.js.map +1 -0
- package/dist/tui/modals/jwt-mint-modal.js +70 -0
- package/dist/tui/modals/jwt-mint-modal.js.map +1 -0
- package/dist/tui/modals/ping-form-modal.js +19 -0
- package/dist/tui/modals/ping-form-modal.js.map +1 -0
- package/dist/tui/modals/redteam-results-modal.js +43 -0
- package/dist/tui/modals/redteam-results-modal.js.map +1 -0
- package/dist/tui/modals/scan-form-modal.js +26 -0
- package/dist/tui/modals/scan-form-modal.js.map +1 -0
- package/dist/tui/screens/defense-screen.js +281 -0
- package/dist/tui/screens/defense-screen.js.map +1 -0
- package/dist/tui/screens/forensics-screen.js +81 -0
- package/dist/tui/screens/forensics-screen.js.map +1 -0
- package/dist/tui/screens/index.js +140 -0
- package/dist/tui/screens/index.js.map +1 -0
- package/dist/tui/screens/system-screen.js +81 -0
- package/dist/tui/screens/system-screen.js.map +1 -0
- package/dist/tui/screens/testing-screen.js +429 -0
- package/dist/tui/screens/testing-screen.js.map +1 -0
- package/dist/tui/screens/traffic-screen.js +76 -0
- package/dist/tui/screens/traffic-screen.js.map +1 -0
- package/dist/tui/sse-client.js +130 -0
- package/dist/tui/sse-client.js.map +1 -0
- package/dist/tui/state/metrics-buffer.js +195 -0
- package/dist/tui/state/metrics-buffer.js.map +1 -0
- package/dist/tui/state/metrics-buffer.test.js +102 -0
- package/dist/tui/state/metrics-buffer.test.js.map +1 -0
- package/dist/tui/theme.js +136 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/tui/types.js +6 -0
- package/dist/tui/types.js.map +1 -0
- package/dist/tui/widgets/chaos-widget.js +152 -0
- package/dist/tui/widgets/chaos-widget.js.map +1 -0
- package/dist/tui/widgets/cluster-widget.js +156 -0
- package/dist/tui/widgets/cluster-widget.js.map +1 -0
- package/dist/tui/widgets/dlp-widget.js +161 -0
- package/dist/tui/widgets/dlp-widget.js.map +1 -0
- package/dist/tui/widgets/ghost-widget.js +169 -0
- package/dist/tui/widgets/ghost-widget.js.map +1 -0
- package/dist/tui/widgets/har-widget.js +173 -0
- package/dist/tui/widgets/har-widget.js.map +1 -0
- package/dist/tui/widgets/index.js +122 -0
- package/dist/tui/widgets/index.js.map +1 -0
- package/dist/tui/widgets/jwt-widget.js +177 -0
- package/dist/tui/widgets/jwt-widget.js.map +1 -0
- package/dist/tui/widgets/kv-widget.js +261 -0
- package/dist/tui/widgets/kv-widget.js.map +1 -0
- package/dist/tui/widgets/mtd-widget.js +181 -0
- package/dist/tui/widgets/mtd-widget.js.map +1 -0
- package/dist/tui/widgets/netdiag-widget.js +155 -0
- package/dist/tui/widgets/netdiag-widget.js.map +1 -0
- package/dist/tui/widgets/oidc-widget.js +162 -0
- package/dist/tui/widgets/oidc-widget.js.map +1 -0
- package/dist/tui/widgets/pcap-widget.js +239 -0
- package/dist/tui/widgets/pcap-widget.js.map +1 -0
- package/dist/tui/widgets/redteam-widget.js +155 -0
- package/dist/tui/widgets/redteam-widget.js.map +1 -0
- package/dist/tui/widgets/rps-gauge-widget.js +124 -0
- package/dist/tui/widgets/rps-gauge-widget.js.map +1 -0
- package/dist/tui/widgets/sentinel-widget.js +171 -0
- package/dist/tui/widgets/sentinel-widget.js.map +1 -0
- package/dist/tui/widgets/sparklines-widget.js +127 -0
- package/dist/tui/widgets/sparklines-widget.js.map +1 -0
- package/dist/tui/widgets/sysinfo-widget.js +197 -0
- package/dist/tui/widgets/sysinfo-widget.js.map +1 -0
- package/dist/tui/widgets/traffic-chart-widget.js +170 -0
- package/dist/tui/widgets/traffic-chart-widget.js.map +1 -0
- package/dist/tui/widgets/webhook-widget.js +259 -0
- package/dist/tui/widgets/webhook-widget.js.map +1 -0
- package/dist/utils/ip.js +18 -0
- package/dist/utils/ip.js.map +1 -0
- package/dist/victim/index.js +71 -0
- package/dist/victim/index.js.map +1 -0
- package/dist/webhook.js +88 -0
- package/dist/webhook.js.map +1 -0
- package/package.json +90 -0
- package/proto/echo.proto +19 -0
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
var hg=Object.defineProperty;var fg=(e,t,n)=>t in e?hg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var le=(e,t,n)=>fg(e,typeof t!="symbol"?t+"":t,n);import{r as h,a as ir,N as pg,R as bi,L as Os,b as q,c as mg,g as Zu,u as Ju,d as xg,B as gg,e as yg,f as Le,O as bg}from"./router-DSc5pRwN.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var Qu={exports:{}},ya={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var vg=h,wg=Symbol.for("react.element"),Ng=Symbol.for("react.fragment"),Sg=Object.prototype.hasOwnProperty,jg=vg.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,kg={key:!0,ref:!0,__self:!0,__source:!0};function ed(e,t,n){var s,a={},o=null,i=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(i=t.ref);for(s in t)Sg.call(t,s)&&!kg.hasOwnProperty(s)&&(a[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)a[s]===void 0&&(a[s]=t[s]);return{$$typeof:wg,type:e,key:o,ref:i,props:a,_owner:jg.current}}ya.Fragment=Ng;ya.jsx=ed;ya.jsxs=ed;Qu.exports=ya;var r=Qu.exports,To={},Dl=ir;To.createRoot=Dl.createRoot,To.hydrateRoot=Dl.hydrateRoot;/**
|
|
10
|
+
* @license lucide-react v0.312.0 - ISC
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the ISC license.
|
|
13
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
+
*/var Eg={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"};/**
|
|
15
|
+
* @license lucide-react v0.312.0 - ISC
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the ISC license.
|
|
18
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/const _g=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),re=(e,t)=>{const n=h.forwardRef(({color:s="currentColor",size:a=24,strokeWidth:o=2,absoluteStrokeWidth:i,className:l="",children:u,...c},d)=>h.createElement("svg",{ref:d,...Eg,width:a,height:a,stroke:s,strokeWidth:i?Number(o)*24/Number(a):o,className:["lucide",`lucide-${_g(e)}`,l].join(" "),...c},[...t.map(([f,p])=>h.createElement(f,p)),...Array.isArray(u)?u:[u]]));return n.displayName=`${e}`,n};/**
|
|
20
|
+
* @license lucide-react v0.312.0 - ISC
|
|
21
|
+
*
|
|
22
|
+
* This source code is licensed under the ISC license.
|
|
23
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
24
|
+
*/const dt=re("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/**
|
|
25
|
+
* @license lucide-react v0.312.0 - ISC
|
|
26
|
+
*
|
|
27
|
+
* This source code is licensed under the ISC license.
|
|
28
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
29
|
+
*/const vi=re("AlertCircle",[["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"}]]);/**
|
|
30
|
+
* @license lucide-react v0.312.0 - ISC
|
|
31
|
+
*
|
|
32
|
+
* This source code is licensed under the ISC license.
|
|
33
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
34
|
+
*/const Zt=re("AlertTriangle",[["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-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
35
|
+
* @license lucide-react v0.312.0 - ISC
|
|
36
|
+
*
|
|
37
|
+
* This source code is licensed under the ISC license.
|
|
38
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
39
|
+
*/const Cg=re("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
40
|
+
* @license lucide-react v0.312.0 - ISC
|
|
41
|
+
*
|
|
42
|
+
* This source code is licensed under the ISC license.
|
|
43
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
44
|
+
*/const td=re("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
|
45
|
+
* @license lucide-react v0.312.0 - ISC
|
|
46
|
+
*
|
|
47
|
+
* This source code is licensed under the ISC license.
|
|
48
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
49
|
+
*/const lr=re("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/**
|
|
50
|
+
* @license lucide-react v0.312.0 - ISC
|
|
51
|
+
*
|
|
52
|
+
* This source code is licensed under the ISC license.
|
|
53
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
54
|
+
*/const nd=re("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/**
|
|
55
|
+
* @license lucide-react v0.312.0 - ISC
|
|
56
|
+
*
|
|
57
|
+
* This source code is licensed under the ISC license.
|
|
58
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
59
|
+
*/const rd=re("BrainCircuit",[["path",{d:"M12 4.5a2.5 2.5 0 0 0-4.96-.46 2.5 2.5 0 0 0-1.98 3 2.5 2.5 0 0 0-1.32 4.24 3 3 0 0 0 .34 5.58 2.5 2.5 0 0 0 2.96 3.08 2.5 2.5 0 0 0 4.91.05L12 20V4.5Z",key:"ixwj2a"}],["path",{d:"M16 8V5c0-1.1.9-2 2-2",key:"13dx7u"}],["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:"M20.5 8a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z",key:"1s25gz"}],["path",{d:"M16.5 13a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z",key:"127460"}],["path",{d:"M20.5 21a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z",key:"fys062"}],["path",{d:"M18.5 3a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z",key:"1vib61"}]]);/**
|
|
60
|
+
* @license lucide-react v0.312.0 - ISC
|
|
61
|
+
*
|
|
62
|
+
* This source code is licensed under the ISC license.
|
|
63
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
64
|
+
*/const sd=re("CheckCircle2",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
65
|
+
* @license lucide-react v0.312.0 - ISC
|
|
66
|
+
*
|
|
67
|
+
* This source code is licensed under the ISC license.
|
|
68
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
69
|
+
*/const Tg=re("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
70
|
+
* @license lucide-react v0.312.0 - ISC
|
|
71
|
+
*
|
|
72
|
+
* This source code is licensed under the ISC license.
|
|
73
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
74
|
+
*/const Zr=re("ChefHat",[["path",{d:"M6 13.87A4 4 0 0 1 7.41 6a5.11 5.11 0 0 1 1.05-1.54 5 5 0 0 1 7.08 0A5.11 5.11 0 0 1 16.59 6 4 4 0 0 1 18 13.87V21H6Z",key:"z3ra2g"}],["line",{x1:"6",x2:"18",y1:"17",y2:"17",key:"12q60k"}]]);/**
|
|
75
|
+
* @license lucide-react v0.312.0 - ISC
|
|
76
|
+
*
|
|
77
|
+
* This source code is licensed under the ISC license.
|
|
78
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
79
|
+
*/const Pr=re("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
80
|
+
* @license lucide-react v0.312.0 - ISC
|
|
81
|
+
*
|
|
82
|
+
* This source code is licensed under the ISC license.
|
|
83
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
84
|
+
*/const Rg=re("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
85
|
+
* @license lucide-react v0.312.0 - ISC
|
|
86
|
+
*
|
|
87
|
+
* This source code is licensed under the ISC license.
|
|
88
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
89
|
+
*/const Ro=re("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
|
|
90
|
+
* @license lucide-react v0.312.0 - ISC
|
|
91
|
+
*
|
|
92
|
+
* This source code is licensed under the ISC license.
|
|
93
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
94
|
+
*/const Ag=re("Clock3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16.5 12",key:"1aq6pp"}]]);/**
|
|
95
|
+
* @license lucide-react v0.312.0 - ISC
|
|
96
|
+
*
|
|
97
|
+
* This source code is licensed under the ISC license.
|
|
98
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
99
|
+
*/const Mg=re("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
|
|
100
|
+
* @license lucide-react v0.312.0 - ISC
|
|
101
|
+
*
|
|
102
|
+
* This source code is licensed under the ISC license.
|
|
103
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
104
|
+
*/const Ig=re("Copy",[["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"}]]);/**
|
|
105
|
+
* @license lucide-react v0.312.0 - ISC
|
|
106
|
+
*
|
|
107
|
+
* This source code is licensed under the ISC license.
|
|
108
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
109
|
+
*/const Pg=re("Cpu",[["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"9",y:"9",width:"6",height:"6",key:"o3kz5p"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
|
|
110
|
+
* @license lucide-react v0.312.0 - ISC
|
|
111
|
+
*
|
|
112
|
+
* This source code is licensed under the ISC license.
|
|
113
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
114
|
+
*/const Og=re("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
|
115
|
+
* @license lucide-react v0.312.0 - ISC
|
|
116
|
+
*
|
|
117
|
+
* This source code is licensed under the ISC license.
|
|
118
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
119
|
+
*/const Lg=re("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
120
|
+
* @license lucide-react v0.312.0 - ISC
|
|
121
|
+
*
|
|
122
|
+
* This source code is licensed under the ISC license.
|
|
123
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
124
|
+
*/const Ao=re("ExternalLink",[["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"}]]);/**
|
|
125
|
+
* @license lucide-react v0.312.0 - ISC
|
|
126
|
+
*
|
|
127
|
+
* This source code is licensed under the ISC license.
|
|
128
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
129
|
+
*/const Dg=re("EyeOff",[["path",{d:"M9.88 9.88a3 3 0 1 0 4.24 4.24",key:"1jxqfv"}],["path",{d:"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68",key:"9wicm4"}],["path",{d:"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61",key:"1jreej"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]]);/**
|
|
130
|
+
* @license lucide-react v0.312.0 - ISC
|
|
131
|
+
*
|
|
132
|
+
* This source code is licensed under the ISC license.
|
|
133
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
134
|
+
*/const $g=re("Eye",[["path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z",key:"rwhkz3"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
135
|
+
* @license lucide-react v0.312.0 - ISC
|
|
136
|
+
*
|
|
137
|
+
* This source code is licensed under the ISC license.
|
|
138
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
139
|
+
*/const ad=re("FileJson",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["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"}]]);/**
|
|
140
|
+
* @license lucide-react v0.312.0 - ISC
|
|
141
|
+
*
|
|
142
|
+
* This source code is licensed under the ISC license.
|
|
143
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
144
|
+
*/const zg=re("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
145
|
+
* @license lucide-react v0.312.0 - ISC
|
|
146
|
+
*
|
|
147
|
+
* This source code is licensed under the ISC license.
|
|
148
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
149
|
+
*/const Fg=re("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
150
|
+
* @license lucide-react v0.312.0 - ISC
|
|
151
|
+
*
|
|
152
|
+
* This source code is licensed under the ISC license.
|
|
153
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
154
|
+
*/const wi=re("Fingerprint",[["path",{d:"M2 12C2 6.5 6.5 2 12 2a10 10 0 0 1 8 4",key:"1jc9o5"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12c0-.7.12-1.37.34-2",key:"1mxgy1"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2c0 .47 0 1.17-.02 2",key:"1fgabc"}]]);/**
|
|
155
|
+
* @license lucide-react v0.312.0 - ISC
|
|
156
|
+
*
|
|
157
|
+
* This source code is licensed under the ISC license.
|
|
158
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
159
|
+
*/const Bg=re("Flame",[["path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z",key:"96xj49"}]]);/**
|
|
160
|
+
* @license lucide-react v0.312.0 - ISC
|
|
161
|
+
*
|
|
162
|
+
* This source code is licensed under the ISC license.
|
|
163
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
164
|
+
*/const Ni=re("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
|
|
165
|
+
* @license lucide-react v0.312.0 - ISC
|
|
166
|
+
*
|
|
167
|
+
* This source code is licensed under the ISC license.
|
|
168
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
169
|
+
*/const Hg=re("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
|
|
170
|
+
* @license lucide-react v0.312.0 - ISC
|
|
171
|
+
*
|
|
172
|
+
* This source code is licensed under the ISC license.
|
|
173
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
174
|
+
*/const Si=re("Ghost",[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]]);/**
|
|
175
|
+
* @license lucide-react v0.312.0 - ISC
|
|
176
|
+
*
|
|
177
|
+
* This source code is licensed under the ISC license.
|
|
178
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
179
|
+
*/const ba=re("Globe",[["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"}]]);/**
|
|
180
|
+
* @license lucide-react v0.312.0 - ISC
|
|
181
|
+
*
|
|
182
|
+
* This source code is licensed under the ISC license.
|
|
183
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
184
|
+
*/const $l=re("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/**
|
|
185
|
+
* @license lucide-react v0.312.0 - ISC
|
|
186
|
+
*
|
|
187
|
+
* This source code is licensed under the ISC license.
|
|
188
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
189
|
+
*/const Ug=re("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
|
|
190
|
+
* @license lucide-react v0.312.0 - ISC
|
|
191
|
+
*
|
|
192
|
+
* This source code is licensed under the ISC license.
|
|
193
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
194
|
+
*/const od=re("HelpCircle",[["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"}]]);/**
|
|
195
|
+
* @license lucide-react v0.312.0 - ISC
|
|
196
|
+
*
|
|
197
|
+
* This source code is licensed under the ISC license.
|
|
198
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
199
|
+
*/const Vg=re("Key",[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]]);/**
|
|
200
|
+
* @license lucide-react v0.312.0 - ISC
|
|
201
|
+
*
|
|
202
|
+
* This source code is licensed under the ISC license.
|
|
203
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
204
|
+
*/const id=re("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
|
|
205
|
+
* @license lucide-react v0.312.0 - ISC
|
|
206
|
+
*
|
|
207
|
+
* This source code is licensed under the ISC license.
|
|
208
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
209
|
+
*/const qg=re("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
210
|
+
* @license lucide-react v0.312.0 - ISC
|
|
211
|
+
*
|
|
212
|
+
* This source code is licensed under the ISC license.
|
|
213
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
214
|
+
*/const ld=re("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/**
|
|
215
|
+
* @license lucide-react v0.312.0 - ISC
|
|
216
|
+
*
|
|
217
|
+
* This source code is licensed under the ISC license.
|
|
218
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
219
|
+
*/const cd=re("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
220
|
+
* @license lucide-react v0.312.0 - ISC
|
|
221
|
+
*
|
|
222
|
+
* This source code is licensed under the ISC license.
|
|
223
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
224
|
+
*/const ud=re("Lock",[["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"}]]);/**
|
|
225
|
+
* @license lucide-react v0.312.0 - ISC
|
|
226
|
+
*
|
|
227
|
+
* This source code is licensed under the ISC license.
|
|
228
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
229
|
+
*/const Wg=re("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
230
|
+
* @license lucide-react v0.312.0 - ISC
|
|
231
|
+
*
|
|
232
|
+
* This source code is licensed under the ISC license.
|
|
233
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
234
|
+
*/const ji=re("Network",[["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"}]]);/**
|
|
235
|
+
* @license lucide-react v0.312.0 - ISC
|
|
236
|
+
*
|
|
237
|
+
* This source code is licensed under the ISC license.
|
|
238
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
239
|
+
*/const Gg=re("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
|
|
240
|
+
* @license lucide-react v0.312.0 - ISC
|
|
241
|
+
*
|
|
242
|
+
* This source code is licensed under the ISC license.
|
|
243
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
244
|
+
*/const Kg=re("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/**
|
|
245
|
+
* @license lucide-react v0.312.0 - ISC
|
|
246
|
+
*
|
|
247
|
+
* This source code is licensed under the ISC license.
|
|
248
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
249
|
+
*/const Jn=re("Pause",[["rect",{width:"4",height:"16",x:"6",y:"4",key:"iffhe4"}],["rect",{width:"4",height:"16",x:"14",y:"4",key:"sjin7j"}]]);/**
|
|
250
|
+
* @license lucide-react v0.312.0 - ISC
|
|
251
|
+
*
|
|
252
|
+
* This source code is licensed under the ISC license.
|
|
253
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
254
|
+
*/const Ke=re("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/**
|
|
255
|
+
* @license lucide-react v0.312.0 - ISC
|
|
256
|
+
*
|
|
257
|
+
* This source code is licensed under the ISC license.
|
|
258
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
259
|
+
*/const Vs=re("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
260
|
+
* @license lucide-react v0.312.0 - ISC
|
|
261
|
+
*
|
|
262
|
+
* This source code is licensed under the ISC license.
|
|
263
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
264
|
+
*/const Yg=re("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]);/**
|
|
265
|
+
* @license lucide-react v0.312.0 - ISC
|
|
266
|
+
*
|
|
267
|
+
* This source code is licensed under the ISC license.
|
|
268
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
269
|
+
*/const dd=re("RefreshCcw",[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]]);/**
|
|
270
|
+
* @license lucide-react v0.312.0 - ISC
|
|
271
|
+
*
|
|
272
|
+
* This source code is licensed under the ISC license.
|
|
273
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
274
|
+
*/const va=re("RefreshCw",[["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"}]]);/**
|
|
275
|
+
* @license lucide-react v0.312.0 - ISC
|
|
276
|
+
*
|
|
277
|
+
* This source code is licensed under the ISC license.
|
|
278
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
279
|
+
*/const hd=re("Save",[["path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z",key:"1owoqh"}],["polyline",{points:"17 21 17 13 7 13 7 21",key:"1md35c"}],["polyline",{points:"7 3 7 8 15 8",key:"8nz8an"}]]);/**
|
|
280
|
+
* @license lucide-react v0.312.0 - ISC
|
|
281
|
+
*
|
|
282
|
+
* This source code is licensed under the ISC license.
|
|
283
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
284
|
+
*/const Jr=re("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
285
|
+
* @license lucide-react v0.312.0 - ISC
|
|
286
|
+
*
|
|
287
|
+
* This source code is licensed under the ISC license.
|
|
288
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
289
|
+
*/const ki=re("Server",[["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"}]]);/**
|
|
290
|
+
* @license lucide-react v0.312.0 - ISC
|
|
291
|
+
*
|
|
292
|
+
* This source code is licensed under the ISC license.
|
|
293
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
294
|
+
*/const Xg=re("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
|
|
295
|
+
* @license lucide-react v0.312.0 - ISC
|
|
296
|
+
*
|
|
297
|
+
* This source code is licensed under the ISC license.
|
|
298
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
299
|
+
*/const Ei=re("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
300
|
+
* @license lucide-react v0.312.0 - ISC
|
|
301
|
+
*
|
|
302
|
+
* This source code is licensed under the ISC license.
|
|
303
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
304
|
+
*/const Fe=re("ShieldAlert",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]);/**
|
|
305
|
+
* @license lucide-react v0.312.0 - ISC
|
|
306
|
+
*
|
|
307
|
+
* This source code is licensed under the ISC license.
|
|
308
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
309
|
+
*/const Zg=re("ShieldBan",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"m4 5 14 12",key:"1ta6nf"}]]);/**
|
|
310
|
+
* @license lucide-react v0.312.0 - ISC
|
|
311
|
+
*
|
|
312
|
+
* This source code is licensed under the ISC license.
|
|
313
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
314
|
+
*/const Jt=re("ShieldCheck",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
315
|
+
* @license lucide-react v0.312.0 - ISC
|
|
316
|
+
*
|
|
317
|
+
* This source code is licensed under the ISC license.
|
|
318
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
319
|
+
*/const Qr=re("Shield",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}]]);/**
|
|
320
|
+
* @license lucide-react v0.312.0 - ISC
|
|
321
|
+
*
|
|
322
|
+
* This source code is licensed under the ISC license.
|
|
323
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
324
|
+
*/const fd=re("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
325
|
+
* @license lucide-react v0.312.0 - ISC
|
|
326
|
+
*
|
|
327
|
+
* This source code is licensed under the ISC license.
|
|
328
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
329
|
+
*/const pd=re("StopCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{width:"6",height:"6",x:"9",y:"9",key:"1wrtvo"}]]);/**
|
|
330
|
+
* @license lucide-react v0.312.0 - ISC
|
|
331
|
+
*
|
|
332
|
+
* This source code is licensed under the ISC license.
|
|
333
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
334
|
+
*/const Jg=re("Sun",[["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"}]]);/**
|
|
335
|
+
* @license lucide-react v0.312.0 - ISC
|
|
336
|
+
*
|
|
337
|
+
* This source code is licensed under the ISC license.
|
|
338
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
339
|
+
*/const Ir=re("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
340
|
+
* @license lucide-react v0.312.0 - ISC
|
|
341
|
+
*
|
|
342
|
+
* This source code is licensed under the ISC license.
|
|
343
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
344
|
+
*/const _i=re("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
345
|
+
* @license lucide-react v0.312.0 - ISC
|
|
346
|
+
*
|
|
347
|
+
* This source code is licensed under the ISC license.
|
|
348
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
349
|
+
*/const wa=re("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
350
|
+
* @license lucide-react v0.312.0 - ISC
|
|
351
|
+
*
|
|
352
|
+
* This source code is licensed under the ISC license.
|
|
353
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
354
|
+
*/const Qg=re("Unlock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);/**
|
|
355
|
+
* @license lucide-react v0.312.0 - ISC
|
|
356
|
+
*
|
|
357
|
+
* This source code is licensed under the ISC license.
|
|
358
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
359
|
+
*/const e0=re("Wand2",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72Z",key:"1bcowg"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/**
|
|
360
|
+
* @license lucide-react v0.312.0 - ISC
|
|
361
|
+
*
|
|
362
|
+
* This source code is licensed under the ISC license.
|
|
363
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
364
|
+
*/const t0=re("Waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);/**
|
|
365
|
+
* @license lucide-react v0.312.0 - ISC
|
|
366
|
+
*
|
|
367
|
+
* This source code is licensed under the ISC license.
|
|
368
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
369
|
+
*/const Ci=re("Webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);/**
|
|
370
|
+
* @license lucide-react v0.312.0 - ISC
|
|
371
|
+
*
|
|
372
|
+
* This source code is licensed under the ISC license.
|
|
373
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
374
|
+
*/const md=re("Wifi",[["path",{d:"M5 13a10 10 0 0 1 14 0",key:"6v8j51"}],["path",{d:"M8.5 16.5a5 5 0 0 1 7 0",key:"sej527"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["line",{x1:"12",x2:"12.01",y1:"20",y2:"20",key:"of4bc4"}]]);/**
|
|
375
|
+
* @license lucide-react v0.312.0 - ISC
|
|
376
|
+
*
|
|
377
|
+
* This source code is licensed under the ISC license.
|
|
378
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
379
|
+
*/const xd=re("XCircle",[["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"}]]);/**
|
|
380
|
+
* @license lucide-react v0.312.0 - ISC
|
|
381
|
+
*
|
|
382
|
+
* This source code is licensed under the ISC license.
|
|
383
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
384
|
+
*/const gd=re("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
385
|
+
* @license lucide-react v0.312.0 - ISC
|
|
386
|
+
*
|
|
387
|
+
* This source code is licensed under the ISC license.
|
|
388
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
389
|
+
*/const It=re("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]);function yd(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=yd(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function bd(){for(var e,t,n=0,s="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=yd(e))&&(s&&(s+=" "),s+=t);return s}const Ti="-",n0=e=>{const t=s0(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:i=>{const l=i.split(Ti);return l[0]===""&&l.length!==1&&l.shift(),vd(l,t)||r0(i)},getConflictingClassGroupIds:(i,l)=>{const u=n[i]||[];return l&&s[i]?[...u,...s[i]]:u}}},vd=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],s=t.nextPart.get(n),a=s?vd(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;const o=e.join(Ti);return(i=t.validators.find(({validator:l})=>l(o)))==null?void 0:i.classGroupId},zl=/^\[(.+)\]$/,r0=e=>{if(zl.test(e)){const t=zl.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},s0=e=>{const{theme:t,prefix:n}=e,s={nextPart:new Map,validators:[]};return o0(Object.entries(e.classGroups),n).forEach(([o,i])=>{Mo(i,s,o,t)}),s},Mo=(e,t,n,s)=>{e.forEach(a=>{if(typeof a=="string"){const o=a===""?t:Fl(t,a);o.classGroupId=n;return}if(typeof a=="function"){if(a0(a)){Mo(a(s),t,n,s);return}t.validators.push({validator:a,classGroupId:n});return}Object.entries(a).forEach(([o,i])=>{Mo(i,Fl(t,o),n,s)})})},Fl=(e,t)=>{let n=e;return t.split(Ti).forEach(s=>{n.nextPart.has(s)||n.nextPart.set(s,{nextPart:new Map,validators:[]}),n=n.nextPart.get(s)}),n},a0=e=>e.isThemeGetter,o0=(e,t)=>t?e.map(([n,s])=>{const a=s.map(o=>typeof o=="string"?t+o:typeof o=="object"?Object.fromEntries(Object.entries(o).map(([i,l])=>[t+i,l])):o);return[n,a]}):e,i0=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,s=new Map;const a=(o,i)=>{n.set(o,i),t++,t>e&&(t=0,s=n,n=new Map)};return{get(o){let i=n.get(o);if(i!==void 0)return i;if((i=s.get(o))!==void 0)return a(o,i),i},set(o,i){n.has(o)?n.set(o,i):a(o,i)}}},wd="!",l0=e=>{const{separator:t,experimentalParseClassName:n}=e,s=t.length===1,a=t[0],o=t.length,i=l=>{const u=[];let c=0,d=0,f;for(let y=0;y<l.length;y++){let b=l[y];if(c===0){if(b===a&&(s||l.slice(y,y+o)===t)){u.push(l.slice(d,y)),d=y+o;continue}if(b==="/"){f=y;continue}}b==="["?c++:b==="]"&&c--}const p=u.length===0?l:l.substring(d),x=p.startsWith(wd),g=x?p.substring(1):p,m=f&&f>d?f-d:void 0;return{modifiers:u,hasImportantModifier:x,baseClassName:g,maybePostfixModifierPosition:m}};return n?l=>n({className:l,parseClassName:i}):i},c0=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(s=>{s[0]==="["?(t.push(...n.sort(),s),n=[]):n.push(s)}),t.push(...n.sort()),t},u0=e=>({cache:i0(e.cacheSize),parseClassName:l0(e),...n0(e)}),d0=/\s+/,h0=(e,t)=>{const{parseClassName:n,getClassGroupId:s,getConflictingClassGroupIds:a}=t,o=[],i=e.trim().split(d0);let l="";for(let u=i.length-1;u>=0;u-=1){const c=i[u],{modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:x}=n(c);let g=!!x,m=s(g?p.substring(0,x):p);if(!m){if(!g){l=c+(l.length>0?" "+l:l);continue}if(m=s(p),!m){l=c+(l.length>0?" "+l:l);continue}g=!1}const y=c0(d).join(":"),b=f?y+wd:y,v=b+m;if(o.includes(v))continue;o.push(v);const N=a(m,g);for(let w=0;w<N.length;++w){const j=N[w];o.push(b+j)}l=c+(l.length>0?" "+l:l)}return l};function f0(){let e=0,t,n,s="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Nd(t))&&(s&&(s+=" "),s+=n);return s}const Nd=e=>{if(typeof e=="string")return e;let t,n="";for(let s=0;s<e.length;s++)e[s]&&(t=Nd(e[s]))&&(n&&(n+=" "),n+=t);return n};function p0(e,...t){let n,s,a,o=i;function i(u){const c=t.reduce((d,f)=>f(d),e());return n=u0(c),s=n.cache.get,a=n.cache.set,o=l,l(u)}function l(u){const c=s(u);if(c)return c;const d=h0(u,n);return a(u,d),d}return function(){return o(f0.apply(null,arguments))}}const Oe=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Sd=/^\[(?:([a-z-]+):)?(.+)\]$/i,m0=/^\d+\/\d+$/,x0=new Set(["px","full","screen"]),g0=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,y0=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,b0=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,v0=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,w0=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,_t=e=>Wn(e)||x0.has(e)||m0.test(e),zt=e=>cr(e,"length",T0),Wn=e=>!!e&&!Number.isNaN(Number(e)),Ka=e=>cr(e,"number",Wn),xr=e=>!!e&&Number.isInteger(Number(e)),N0=e=>e.endsWith("%")&&Wn(e.slice(0,-1)),xe=e=>Sd.test(e),Ft=e=>g0.test(e),S0=new Set(["length","size","percentage"]),j0=e=>cr(e,S0,jd),k0=e=>cr(e,"position",jd),E0=new Set(["image","url"]),_0=e=>cr(e,E0,A0),C0=e=>cr(e,"",R0),gr=()=>!0,cr=(e,t,n)=>{const s=Sd.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):n(s[2]):!1},T0=e=>y0.test(e)&&!b0.test(e),jd=()=>!1,R0=e=>v0.test(e),A0=e=>w0.test(e),M0=()=>{const e=Oe("colors"),t=Oe("spacing"),n=Oe("blur"),s=Oe("brightness"),a=Oe("borderColor"),o=Oe("borderRadius"),i=Oe("borderSpacing"),l=Oe("borderWidth"),u=Oe("contrast"),c=Oe("grayscale"),d=Oe("hueRotate"),f=Oe("invert"),p=Oe("gap"),x=Oe("gradientColorStops"),g=Oe("gradientColorStopPositions"),m=Oe("inset"),y=Oe("margin"),b=Oe("opacity"),v=Oe("padding"),N=Oe("saturate"),w=Oe("scale"),j=Oe("sepia"),k=Oe("skew"),_=Oe("space"),P=Oe("translate"),T=()=>["auto","contain","none"],$=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto",xe,t],D=()=>[xe,t],R=()=>["",_t,zt],S=()=>["auto",Wn,xe],C=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],E=()=>["solid","dashed","dotted","double","none"],A=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],O=()=>["start","end","center","between","around","evenly","stretch"],I=()=>["","0",xe],F=()=>["auto","avoid","all","avoid-page","page","left","right","column"],L=()=>[Wn,xe];return{cacheSize:500,separator:":",theme:{colors:[gr],spacing:[_t,zt],blur:["none","",Ft,xe],brightness:L(),borderColor:[e],borderRadius:["none","","full",Ft,xe],borderSpacing:D(),borderWidth:R(),contrast:L(),grayscale:I(),hueRotate:L(),invert:I(),gap:D(),gradientColorStops:[e],gradientColorStopPositions:[N0,zt],inset:B(),margin:B(),opacity:L(),padding:D(),saturate:L(),scale:L(),sepia:I(),skew:L(),space:D(),translate:D()},classGroups:{aspect:[{aspect:["auto","square","video",xe]}],container:["container"],columns:[{columns:[Ft]}],"break-after":[{"break-after":F()}],"break-before":[{"break-before":F()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...C(),xe]}],overflow:[{overflow:$()}],"overflow-x":[{"overflow-x":$()}],"overflow-y":[{"overflow-y":$()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",xr,xe]}],basis:[{basis:B()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",xe]}],grow:[{grow:I()}],shrink:[{shrink:I()}],order:[{order:["first","last","none",xr,xe]}],"grid-cols":[{"grid-cols":[gr]}],"col-start-end":[{col:["auto",{span:["full",xr,xe]},xe]}],"col-start":[{"col-start":S()}],"col-end":[{"col-end":S()}],"grid-rows":[{"grid-rows":[gr]}],"row-start-end":[{row:["auto",{span:[xr,xe]},xe]}],"row-start":[{"row-start":S()}],"row-end":[{"row-end":S()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",xe]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",xe]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...O()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...O(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...O(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[_]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[_]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",xe,t]}],"min-w":[{"min-w":[xe,t,"min","max","fit"]}],"max-w":[{"max-w":[xe,t,"none","full","min","max","fit","prose",{screen:[Ft]},Ft]}],h:[{h:[xe,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[xe,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[xe,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[xe,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Ft,zt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Ka]}],"font-family":[{font:[gr]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",xe]}],"line-clamp":[{"line-clamp":["none",Wn,Ka]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",_t,xe]}],"list-image":[{"list-image":["none",xe]}],"list-style-type":[{list:["none","disc","decimal",xe]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...E(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",_t,zt]}],"underline-offset":[{"underline-offset":["auto",_t,xe]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:D()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",xe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...C(),k0]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",j0]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},_0]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[x]}],"gradient-via":[{via:[x]}],"gradient-to":[{to:[x]}],rounded:[{rounded:[o]}],"rounded-s":[{"rounded-s":[o]}],"rounded-e":[{"rounded-e":[o]}],"rounded-t":[{"rounded-t":[o]}],"rounded-r":[{"rounded-r":[o]}],"rounded-b":[{"rounded-b":[o]}],"rounded-l":[{"rounded-l":[o]}],"rounded-ss":[{"rounded-ss":[o]}],"rounded-se":[{"rounded-se":[o]}],"rounded-ee":[{"rounded-ee":[o]}],"rounded-es":[{"rounded-es":[o]}],"rounded-tl":[{"rounded-tl":[o]}],"rounded-tr":[{"rounded-tr":[o]}],"rounded-br":[{"rounded-br":[o]}],"rounded-bl":[{"rounded-bl":[o]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...E(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:E()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...E()]}],"outline-offset":[{"outline-offset":[_t,xe]}],"outline-w":[{outline:[_t,zt]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:R()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[_t,zt]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ft,C0]}],"shadow-color":[{shadow:[gr]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...A(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":A()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[s]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Ft,xe]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[f]}],saturate:[{saturate:[N]}],sepia:[{sepia:[j]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[N]}],"backdrop-sepia":[{"backdrop-sepia":[j]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",xe]}],duration:[{duration:L()}],ease:[{ease:["linear","in","out","in-out",xe]}],delay:[{delay:L()}],animate:[{animate:["none","spin","ping","pulse","bounce",xe]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[w]}],"scale-x":[{"scale-x":[w]}],"scale-y":[{"scale-y":[w]}],rotate:[{rotate:[xr,xe]}],"translate-x":[{"translate-x":[P]}],"translate-y":[{"translate-y":[P]}],"skew-x":[{"skew-x":[k]}],"skew-y":[{"skew-y":[k]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",xe]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",xe]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":D()}],"scroll-mx":[{"scroll-mx":D()}],"scroll-my":[{"scroll-my":D()}],"scroll-ms":[{"scroll-ms":D()}],"scroll-me":[{"scroll-me":D()}],"scroll-mt":[{"scroll-mt":D()}],"scroll-mr":[{"scroll-mr":D()}],"scroll-mb":[{"scroll-mb":D()}],"scroll-ml":[{"scroll-ml":D()}],"scroll-p":[{"scroll-p":D()}],"scroll-px":[{"scroll-px":D()}],"scroll-py":[{"scroll-py":D()}],"scroll-ps":[{"scroll-ps":D()}],"scroll-pe":[{"scroll-pe":D()}],"scroll-pt":[{"scroll-pt":D()}],"scroll-pr":[{"scroll-pr":D()}],"scroll-pb":[{"scroll-pb":D()}],"scroll-pl":[{"scroll-pl":D()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",xe]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[_t,zt,Ka]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},I0=p0(M0);function X(...e){return I0(bd(e))}const P0={display:"type-display",heading:"type-heading",subhead:"type-subhead",body:"type-body",label:"type-label",tag:"type-tag",metric:"type-metric",metricUnit:"type-metric-unit",data:"type-data",code:"type-code",timestamp:"type-timestamp",nav:"type-nav",navActive:"type-nav-active",link:"type-link",breadcrumb:"type-breadcrumb"},Ne=e=>P0[e];class es extends Error{constructor(t,n,s){super(t),this.code=n,this.cause=s,this.name="ApparatusError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}toJSON(){var t;return{name:this.name,code:this.code,message:this.message,cause:(t=this.cause)==null?void 0:t.message}}}class Bl extends es{constructor(t,n,s){super(t,"NETWORK_ERROR",s),this.url=n,this.name="NetworkError"}}class Or extends es{constructor(t,n,s,a){super(t,`HTTP_${n}`),this.status=n,this.statusText=s,this.body=a,this.name="ApiError"}static fromResponse(t,n){return new Or(`API request failed: ${t.status} ${t.statusText}`,t.status,t.statusText,n)}get isClientError(){return this.status>=400&&this.status<500}get isServerError(){return this.status>=500}get isNotFound(){return this.status===404}get isUnauthorized(){return this.status===401}get isForbidden(){return this.status===403}get isRateLimited(){return this.status===429}}class Hl extends es{constructor(t,n){super(`Request timed out after ${t}ms`,"TIMEOUT"),this.timeoutMs=t,this.url=n,this.name="TimeoutError"}}class O0 extends es{constructor(t,n,s){super(t,"VALIDATION_ERROR"),this.field=n,this.value=s,this.name="ValidationError"}}class Ya extends es{constructor(t,n,s){super(t,"SSE_ERROR",s),this.eventType=n,this.name="SSEError"}}function L0(e){return e instanceof Or}class D0{constructor(t){le(this,"config");if(!t.baseUrl)throw new O0("baseUrl is required");let n=t.baseUrl.trim();n.endsWith("/")&&(n=n.slice(0,-1)),this.config={baseUrl:n,timeout:t.timeout??3e4,headers:{"Content-Type":"application/json",Accept:"application/json",...t.headers},debug:t.debug??!1}}async request(t,n={}){const s=this.buildUrl(t),a=n.method??"GET",o=n.timeout??this.config.timeout,i={...this.config.headers,...n.headers};let l;n.body!==void 0&&(typeof n.body=="string"?l=n.body:l=JSON.stringify(n.body)),this.config.debug&&console.log(`[Apparatus] ${a} ${s}`,{headers:i,body:l});const u=new AbortController,c=setTimeout(()=>u.abort(),o);try{const d=await fetch(s,{method:a,headers:i,body:l,signal:u.signal});if(clearTimeout(c),this.config.debug&&console.log(`[Apparatus] Response: ${d.status} ${d.statusText}`),!d.ok){let p;try{p=await d.json()}catch{p=await d.text()}throw Or.fromResponse(d,p)}if(n.raw)return d;switch(n.responseType??"json"){case"text":return await d.text();case"blob":return await d.blob();case"arrayBuffer":return await d.arrayBuffer();case"json":default:{const p=await d.text();return p?JSON.parse(p):void 0}}}catch(d){throw clearTimeout(c),d instanceof Error&&d.name==="AbortError"?new Hl(o,s):d instanceof Or||d instanceof Hl?d:d instanceof TypeError&&d.message.includes("fetch")?new Bl(`Failed to connect to ${s}: ${d.message}`,s,d):new Bl(`Request failed: ${d instanceof Error?d.message:String(d)}`,s,d instanceof Error?d:void 0)}}async get(t,n){return this.request(t,{...n,method:"GET"})}async post(t,n,s){return this.request(t,{...s,method:"POST",body:n})}async put(t,n,s){return this.request(t,{...s,method:"PUT",body:n})}async patch(t,n,s){return this.request(t,{...s,method:"PATCH",body:n})}async delete(t,n){return this.request(t,{...n,method:"DELETE"})}buildUrl(t){const n=t.startsWith("/")?t:`/${t}`;return`${this.config.baseUrl}${n}`}get baseUrl(){return this.config.baseUrl}setHeader(t,n){this.config.headers[t]=n}removeHeader(t){delete this.config.headers[t]}}class $0{constructor(t){this.http=t}async health(){return this.http.get("/healthz")}async healthPro(){return this.http.get("/health/pro")}async isHealthy(){try{return(await this.health()).status==="ok"}catch{return!1}}async echo(t="/",n){const s={...n==null?void 0:n.headers};return(n==null?void 0:n.delay)!==void 0&&(s["x-echo-delay"]=String(n.delay)),(n==null?void 0:n.status)!==void 0&&(s["x-echo-status"]=String(n.status)),this.http.request(t,{method:(n==null?void 0:n.method)??"GET",headers:s,body:n==null?void 0:n.body})}async metrics(t){const n=await this.http.get("/metrics",{responseType:"text"}),s={raw:n};return t!=null&&t.parse&&(s.parsed=this.parsePrometheusMetrics(n)),s}async history(){return this.http.get("/history")}async clearHistory(){return this.http.delete("/history")}async threatIntelStatus(){return this.http.get("/threat-intel/status")}parsePrometheusMetrics(t){const n={},s=t.split(`
|
|
390
|
+
`);for(const a of s){if(a.startsWith("#")||!a.trim())continue;const o=a.match(/^([a-zA-Z_:][a-zA-Z0-9_:]*(?:\{[^}]*\})?)\s+([0-9.eE+-]+)/);if(o){const[,i,l]=o;n[i]=parseFloat(l)}}return n}}class z0{constructor(t){this.http=t}async dns(t){return this.http.get(`/dns?hostname=${encodeURIComponent(t)}`)}async ping(t,n=80){return this.http.get(`/ping?host=${encodeURIComponent(t)}&port=${n}`)}async sysinfo(){return this.http.get("/sysinfo")}async rateLimit(){return this.http.get("/ratelimit")}async isReachable(t,n=80){try{return(await this.ping(t,n)).status==="open"}catch{return!1}}async resolve(t){return(await this.dns(t)).addresses}}class F0{constructor(t){this.http=t}async jwks(){return this.http.get("/.well-known/jwks.json")}async oidc(){return this.http.get("/.well-known/openid-configuration")}async mintToken(t){return this.http.post("/auth/token",t)}async decodeJwt(t){return this.http.post("/debug/jwt",{token:t})}async forgeToken(t){return this.http.post("/auth/forge",t)}async verifyToken(t){return this.http.post("/auth/verify",t)}async validateJwt(t){try{return(await this.decodeJwt(t)).valid}catch{return!1}}async getAccessToken(){return(await this.mintToken()).access_token}async getTokenFor(t,n){return(await this.mintToken({subject:t,audience:n})).access_token}}class B0{constructor(t){this.http=t}async redteam(t){return this.http.post("/redteam/validate",t)}async listRules(){return(await this.http.get("/sentinel/rules")).rules}async getRule(t){return this.http.get(`/sentinel/rules/${encodeURIComponent(t)}`)}async addRule(t){return this.http.post("/sentinel/rules",t)}async updateRule(t,n){return this.http.put(`/sentinel/rules/${encodeURIComponent(t)}`,n)}async deleteRule(t){return this.http.delete(`/sentinel/rules/${encodeURIComponent(t)}`)}async enableRule(t){return this.updateRule(t,{enabled:!0})}async disableRule(t){return this.updateRule(t,{enabled:!1})}async proxy(t){return this.http.post("/proxy",t)}async quickScan(t){return this.redteam({target:t})}async fullScan(t,n=6e4){return this.redteam({target:t,tests:["headers","cors","tls","csrf","cookies","xss","sqli"],timeout:n})}}class H0{constructor(t){this.http=t}async cpuSpike(t){const n=new URLSearchParams;(t==null?void 0:t.duration)!==void 0&&n.set("duration",String(t.duration)),(t==null?void 0:t.intensity)!==void 0&&n.set("intensity",String(t.intensity));const s=n.toString();return this.http.get(`/chaos/cpu${s?`?${s}`:""}`)}async memorySpike(t){const n=new URLSearchParams;(t==null?void 0:t.size)!==void 0&&n.set("size",String(t.size)),(t==null?void 0:t.duration)!==void 0&&n.set("duration",String(t.duration));const s=n.toString();return this.http.get(`/chaos/memory${s?`?${s}`:""}`)}async memoryClear(){return this.http.get("/chaos/memory?action=clear")}async crash(){return this.http.post("/chaos/crash")}async eicar(){return this.http.get("/malicious/eicar")}async stressCpu(t){return this.cpuSpike({duration:t})}async stressMemory(t,n){return this.memorySpike({size:t,duration:n})}async quickTest(){return this.cpuSpike({duration:5e3})}}class U0{constructor(t){this.http=t}async generate(t){const n=t.type==="binary"?"arrayBuffer":t.type==="json"?"json":"text";return this.http.post("/generate",t,{responseType:n})}async generateJson(t=10,n){return await this.generate({type:"json",count:t,schema:n})}async generateCsv(t=10){return await this.generate({type:"csv",count:t})}async generateXml(t=10){return await this.generate({type:"xml",count:t})}async generateBinary(t=1024){return await this.generate({type:"binary",size:t})}async sink(t){return this.http.post("/sink",t)}async upload(t,n="application/octet-stream"){return this.http.post("/sink",t,{headers:{"Content-Type":n}})}async dlpScan(t){return this.http.post("/dlp",t)}async scanForSensitiveData(t){return this.dlpScan({content:t})}async scanForTypes(t,n){return this.dlpScan({content:t,rules:n})}async containsSensitiveData(t){return(await this.scanForSensitiveData(t)).matches.length>0}}class V0{constructor(t){this.http=t}async kvGet(t){try{return await this.http.get(`/kv/${encodeURIComponent(t)}`)}catch(n){if(n.status===404)return null;throw n}}async get(t){const n=await this.kvGet(t);return n==null?void 0:n.value}async kvSet(t,n){return this.http.put(`/kv/${encodeURIComponent(t)}`,n)}async set(t,n,s){return this.kvSet(t,{value:n,ttl:s})}async kvDelete(t){return this.http.delete(`/kv/${encodeURIComponent(t)}`)}async delete(t){try{return await this.kvDelete(t),!0}catch(n){if(n.status===404)return!1;throw n}}async kvList(){return(await this.http.get("/kv")).keys}async has(t){return await this.kvGet(t)!==null}async script(t){return this.http.post("/script",t)}async runScript(t,n,s){return this.script({code:t,args:n,timeout:s})}async exec(t,n){const s=await this.runScript(t,n);if(s.error)throw new Error(s.error);return s.result}}class q0{constructor(t){this.http=t}async status(){return this.http.get("/ghosts")}async start(t){return this.http.post("/ghosts/start",t)}async stop(){return this.http.post("/ghosts/stop")}async isRunning(){return(await this.status()).running}async startWithRps(t){return this.start({rps:t})}async startForDuration(t,n){return this.start({rps:t,duration:n})}async startTargeted(t,n){return this.start({rps:t,endpoints:n})}async getStats(){return(await this.status()).stats??null}async toggle(){return(await this.status()).running?this.stop():this.start()}}class W0{constructor(t){this.http=t}async listTrapped(){return this.http.get("/tarpit")}async getTrappedCount(){return(await this.listTrapped()).count}async isTrapped(t){return(await this.listTrapped()).trapped.some(s=>s.ip===t)}async release(t){return this.http.post("/tarpit/release",{ip:t})}async releaseAll(){return this.http.post("/tarpit/release",{})}async getTrapPaths(){return(await this.listTrapped()).trapPaths}async deceptionHistory(){return this.http.get("/deception/history")}async getDeceptionEventCount(){return(await this.deceptionHistory()).count}async clearDeceptionHistory(){return this.http.delete("/deception/history")}async getRecentHoneypotHits(t=10){return(await this.deceptionHistory()).events.filter(s=>s.type==="honeypot_hit").slice(0,t)}async getShellCommandHistory(){return(await this.deceptionHistory()).events.filter(n=>n.type==="shell_command")}async getSqliProbes(){return(await this.deceptionHistory()).events.filter(n=>n.type==="sqli_probe")}}class G0{constructor(t){this.http=t}async pcap(t){const n=new URLSearchParams;(t==null?void 0:t.duration)!==void 0&&n.set("duration",String(t.duration)),(t==null?void 0:t.filter)!==void 0&&n.set("filter",t.filter),(t==null?void 0:t.maxPackets)!==void 0&&n.set("maxPackets",String(t.maxPackets));const s=n.toString();return this.http.get(`/capture.pcap${s?`?${s}`:""}`,{responseType:"arrayBuffer"})}async downloadPcap(t){const n=await this.pcap(t);return new Blob([n],{type:"application/vnd.tcpdump.pcap"})}async captureDuration(t){return this.pcap({duration:t})}async captureFiltered(t,n){return this.pcap({filter:t,duration:n})}async replay(t){return this.http.post("/replay",t)}async replayHar(t,n){return this.replay({har:t,baseUrl:n})}async replayWithDelay(t,n,s){return this.replay({har:t,baseUrl:s,delay:n})}async replayToTarget(t,n){return this.replay({har:t,baseUrl:n})}}class K0{constructor(t){this.http=t}async members(){return this.http.get("/cluster/members")}async getMemberList(){return(await this.members()).members}async getLeader(){return(await this.members()).leader}async getHealthyMembers(){return(await this.members()).members.filter(n=>n.status==="healthy")}async getMemberCount(){return(await this.members()).members.length}async isMember(t){return(await this.members()).members.some(s=>s.hostname===t)}async attack(t){return this.http.post("/cluster/attack",t)}async startAttack(t,n){return this.attack({type:t,params:n})}async attackTarget(t,n){return this.attack({type:t,target:n})}async getAttackStatus(t){return this.http.get(`/cluster/attack/${encodeURIComponent(t)}`)}async stopAttack(t){return this.http.delete(`/cluster/attack/${encodeURIComponent(t)}`)}}class Y0{constructor(t){this.http=t}async status(){return this.http.get("/mtd")}async isEnabled(){return(await this.status()).enabled}async getCurrentProfile(){return(await this.status()).currentProfile}async getNextRotation(){const t=await this.status();return new Date(t.nextRotation)}async getTimeUntilRotation(){const t=await this.getNextRotation();return Math.max(0,t.getTime()-Date.now())}async rotate(){return this.http.post("/mtd/rotate")}async enable(){return this.http.post("/mtd/enable")}async disable(){return this.http.post("/mtd/disable")}async setInterval(t){return this.http.put("/mtd/interval",{interval:t})}async toggle(){return(await this.status()).enabled?this.disable():this.enable()}}class X0{constructor(t){this.http=t}async sqli(t,n){const s=new URLSearchParams({user:t,pass:n}),a=await this.http.get(`/victim/login?${s.toString()}`);return{vulnerable:a.status==="success"&&t.includes("' OR "),query:`SELECT * FROM users WHERE user = '${t}' AND pass = '${n}'`,message:a.msg||a.error||"",...a}}async testSqli(t){return this.sqli(t,"test")}async sqliBypass(){return this.sqli("' OR '1'='1","' OR '1'='1")}async rce(t){const n=new URLSearchParams({eq:t}),s=await this.http.request(`/victim/calc?${n.toString()}`,{method:"GET",headers:{Accept:"text/plain"},responseType:"text"}),a=typeof s=="string"?s:String(s),o=a.startsWith("Error:"),i=a.replace(/^(Result|Error):\s*/,"");return{vulnerable:t.includes(";")||t.includes("require("),expression:t,result:i,output:o?void 0:i}}async testRce(t){return this.rce(t)}async execCommand(t){return this.rce(`require('child_process').execSync('${t}').toString()`)}async xss(t){const n=new URLSearchParams({msg:t}),s=await this.http.request(`/victim/guestbook?${n.toString()}`,{method:"GET",headers:{Accept:"text/html"},responseType:"text"}),a=typeof s=="string"?s:String(s);return{vulnerable:a.includes(t)&&(t.includes("<")||t.includes(">")),input:t,rendered:a}}async testXss(t){return this.xss(t)}async xssAlert(){return this.xss('<script>alert("XSS")<\/script>')}async runAllTests(){const[t,n,s]=await Promise.all([this.sqliBypass(),this.testRce("1+1"),this.xssAlert()]);return{sqli:t,rce:n,xss:s}}async checkVulnerabilities(){try{const t=await this.runAllTests();return{sqli:t.sqli.vulnerable,rce:t.rce.vulnerable,xss:t.xss.vulnerable}}catch{return{sqli:!1,rce:!1,xss:!1}}}}function Z0(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}class J0{constructor(t){this.http=t}create(){return{id:Z0()}}getUrl(t){return`${this.http.baseUrl}/hooks/${t}`}createAndGetUrl(){const t=this.create();return{id:t.id,url:this.getUrl(t.id)}}async receive(t,n,s){return this.http.request(`/hooks/${encodeURIComponent(t)}`,{method:(s==null?void 0:s.method)??"POST",headers:s==null?void 0:s.headers,body:n})}async inspect(t){const n=await this.http.get(`/hooks/${encodeURIComponent(t)}/inspect`);return Array.isArray(n)?{requests:n}:n}async getRequests(t){return(await this.inspect(t)).requests}async getLastRequest(t){const n=await this.getRequests(t);return n.length>0?n[0]:null}async getRequestCount(t){return(await this.inspect(t)).requests.length}async waitForRequest(t,n=3e4,s=500){const a=Date.now(),o=await this.getRequestCount(t);for(;Date.now()-a<n;){if(await this.getRequestCount(t)>o)return this.getLastRequest(t);await new Promise(l=>setTimeout(l,s))}return null}async delete(t){return{message:"Webhook deletion not supported by server (webhooks persist in memory)"}}async clearRequests(t){return{message:"Request clearing not supported by server",count:0}}}class Q0{constructor(t){this.http=t}async query(t){return this.http.post("/graphql",t)}async execute(t,n,s){return this.query({query:t,variables:n,operationName:s})}async request(t,n){const s=await this.execute(t,n);if(s.errors&&s.errors.length>0)throw new ey(s.errors);if(s.data===void 0)throw new Error("GraphQL response contained no data");return s.data}async getSchema(){return this.request(`
|
|
391
|
+
query IntrospectionQuery {
|
|
392
|
+
__schema {
|
|
393
|
+
queryType { name }
|
|
394
|
+
mutationType { name }
|
|
395
|
+
subscriptionType { name }
|
|
396
|
+
types {
|
|
397
|
+
...FullType
|
|
398
|
+
}
|
|
399
|
+
directives {
|
|
400
|
+
name
|
|
401
|
+
description
|
|
402
|
+
locations
|
|
403
|
+
args {
|
|
404
|
+
...InputValue
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
fragment FullType on __Type {
|
|
411
|
+
kind
|
|
412
|
+
name
|
|
413
|
+
description
|
|
414
|
+
fields(includeDeprecated: true) {
|
|
415
|
+
name
|
|
416
|
+
description
|
|
417
|
+
args {
|
|
418
|
+
...InputValue
|
|
419
|
+
}
|
|
420
|
+
type {
|
|
421
|
+
...TypeRef
|
|
422
|
+
}
|
|
423
|
+
isDeprecated
|
|
424
|
+
deprecationReason
|
|
425
|
+
}
|
|
426
|
+
inputFields {
|
|
427
|
+
...InputValue
|
|
428
|
+
}
|
|
429
|
+
interfaces {
|
|
430
|
+
...TypeRef
|
|
431
|
+
}
|
|
432
|
+
enumValues(includeDeprecated: true) {
|
|
433
|
+
name
|
|
434
|
+
description
|
|
435
|
+
isDeprecated
|
|
436
|
+
deprecationReason
|
|
437
|
+
}
|
|
438
|
+
possibleTypes {
|
|
439
|
+
...TypeRef
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
fragment InputValue on __InputValue {
|
|
444
|
+
name
|
|
445
|
+
description
|
|
446
|
+
type {
|
|
447
|
+
...TypeRef
|
|
448
|
+
}
|
|
449
|
+
defaultValue
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
fragment TypeRef on __Type {
|
|
453
|
+
kind
|
|
454
|
+
name
|
|
455
|
+
ofType {
|
|
456
|
+
kind
|
|
457
|
+
name
|
|
458
|
+
ofType {
|
|
459
|
+
kind
|
|
460
|
+
name
|
|
461
|
+
ofType {
|
|
462
|
+
kind
|
|
463
|
+
name
|
|
464
|
+
ofType {
|
|
465
|
+
kind
|
|
466
|
+
name
|
|
467
|
+
ofType {
|
|
468
|
+
kind
|
|
469
|
+
name
|
|
470
|
+
ofType {
|
|
471
|
+
kind
|
|
472
|
+
name
|
|
473
|
+
ofType {
|
|
474
|
+
kind
|
|
475
|
+
name
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
`)}async getQueryTypes(){var n;return((n=(await this.execute(`
|
|
485
|
+
query {
|
|
486
|
+
__schema {
|
|
487
|
+
queryType {
|
|
488
|
+
fields {
|
|
489
|
+
name
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
`)).data)==null?void 0:n.__schema.queryType.fields.map(s=>s.name))??[]}async echo(t="/"){return this.request(`
|
|
495
|
+
query Echo($path: String!) {
|
|
496
|
+
echo(path: $path) {
|
|
497
|
+
method
|
|
498
|
+
path
|
|
499
|
+
timestamp
|
|
500
|
+
headers
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
`,{path:t})}}class ey extends Error{constructor(t){const n=t.map(s=>s.message).join("; ");super(`GraphQL Error: ${n}`),this.errors=t,this.name="GraphQLQueryError"}get firstError(){return this.errors[0]}}class Ul{constructor(t,n={}){le(this,"baseUrl");le(this,"options");le(this,"eventSource",null);le(this,"state","disconnected");le(this,"reconnectAttempts",0);le(this,"reconnectTimeoutId",null);le(this,"listeners",{all:new Set,byType:new Map,error:new Set,state:new Set});this.baseUrl=t.endsWith("/")?t.slice(0,-1):t,this.options={autoReconnect:n.autoReconnect??!0,reconnectDelay:n.reconnectDelay??3e3,maxReconnectAttempts:n.maxReconnectAttempts??10}}connect(){if(this.eventSource)return;this.setState("connecting");const t=`${this.baseUrl}/sse`;try{this.eventSource=new EventSource(t),this.eventSource.onopen=()=>{this.reconnectAttempts=0,this.setState("connected")},this.eventSource.onerror=s=>{var o;const a=new Ya("SSE connection error",void 0,"message"in s?new Error(String(s.message)):void 0);this.notifyError(a),((o=this.eventSource)==null?void 0:o.readyState)===EventSource.CLOSED&&this.handleDisconnect()};const n=["request","deception","tarpit","health","threat-intel"];for(const s of n)this.eventSource.addEventListener(s,a=>{this.handleEvent(s,a)});this.eventSource.onmessage=s=>{try{const a=JSON.parse(s.data);a.type&&this.handleEvent(a.type,s)}catch{}}}catch(n){throw this.setState("disconnected"),new Ya("Failed to create SSE connection",void 0,n instanceof Error?n:void 0)}}disconnect(){this.clearReconnectTimeout(),this.eventSource&&(this.eventSource.onopen=null,this.eventSource.onerror=null,this.eventSource.onmessage=null,this.eventSource.close(),this.eventSource=null),this.setState("disconnected")}onEvent(t){return this.listeners.all.add(t),()=>this.listeners.all.delete(t)}on(t,n){return this.listeners.byType.has(t)||this.listeners.byType.set(t,new Set),this.listeners.byType.get(t).add(n),()=>{var s;return(s=this.listeners.byType.get(t))==null?void 0:s.delete(n)}}onRequest(t){return this.on("request",t)}onDeception(t){return this.on("deception",t)}onTarpit(t){return this.on("tarpit",t)}onHealth(t){return this.on("health",t)}onThreatIntel(t){return this.on("threat-intel",t)}onError(t){return this.listeners.error.add(t),()=>this.listeners.error.delete(t)}onStateChange(t){return this.listeners.state.add(t),()=>this.listeners.state.delete(t)}getState(){return this.state}isConnected(){return this.state==="connected"}handleEvent(t,n){try{const s=JSON.parse(n.data),a={type:t,timestamp:s.timestamp||new Date().toISOString(),data:s.data??s};for(const i of this.listeners.all)try{i(a)}catch(l){console.error("[Apparatus SSE] Handler error:",l)}const o=this.listeners.byType.get(t);if(o)for(const i of o)try{i(a)}catch(l){console.error("[Apparatus SSE] Handler error:",l)}}catch(s){this.notifyError(new Ya("Failed to parse SSE event",t,s instanceof Error?s:void 0))}}handleDisconnect(){var t;(t=this.eventSource)==null||t.close(),this.eventSource=null,this.options.autoReconnect&&this.reconnectAttempts<this.options.maxReconnectAttempts?(this.setState("reconnecting"),this.scheduleReconnect()):this.setState("disconnected")}scheduleReconnect(){this.clearReconnectTimeout();const t=Math.min(this.options.reconnectDelay*Math.pow(2,this.reconnectAttempts)+Math.random()*1e3,3e4);this.reconnectTimeoutId=setTimeout(()=>{this.reconnectAttempts++,this.eventSource=null,this.connect()},t)}clearReconnectTimeout(){this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null)}setState(t){if(this.state!==t){this.state=t;for(const n of this.listeners.state)try{n(t)}catch(s){console.error("[Apparatus SSE] State handler error:",s)}}}notifyError(t){for(const n of this.listeners.error)try{n(t)}catch(s){console.error("[Apparatus SSE] Error handler error:",s)}}}class ty{constructor(t,n={}){le(this,"client",null);le(this,"baseUrl");le(this,"options");this.baseUrl=t,this.options=n}connect(){this.client||(this.client=new Ul(this.baseUrl,this.options)),this.client.connect()}disconnect(){var t;(t=this.client)==null||t.disconnect()}isConnected(){var t;return((t=this.client)==null?void 0:t.isConnected())??!1}getState(){var t;return((t=this.client)==null?void 0:t.getState())??"disconnected"}subscribe(t){return this.ensureClient(),this.client.onEvent(t)}on(t,n){return this.ensureClient(),this.client.on(t,n)}onRequest(t){return this.ensureClient(),this.client.onRequest(t)}onDeception(t){return this.ensureClient(),this.client.onDeception(t)}onTarpit(t){return this.ensureClient(),this.client.onTarpit(t)}onHealth(t){return this.ensureClient(),this.client.onHealth(t)}onThreatIntel(t){return this.ensureClient(),this.client.onThreatIntel(t)}onError(t){return this.ensureClient(),this.client.onError(t)}onStateChange(t){return this.ensureClient(),this.client.onStateChange(t)}async waitForEvent(t=3e4){return new Promise((n,s)=>{const a=setTimeout(()=>{o(),s(new Error(`Timeout waiting for event after ${t}ms`))},t),o=this.subscribe(i=>{clearTimeout(a),o(),n(i)})})}async waitFor(t,n=3e4){return new Promise((s,a)=>{const o=setTimeout(()=>{i(),a(new Error(`Timeout waiting for ${t} event after ${n}ms`))},n),i=this.on(t,l=>{clearTimeout(o),i(),s(l)})})}async collectEvents(t){const n=[],s=this.subscribe(a=>{n.push(a)});return await new Promise(a=>setTimeout(a,t)),s(),n}async collectEventsOfType(t,n){const s=[],a=this.on(t,o=>{s.push(o)});return await new Promise(o=>setTimeout(o,n)),a(),s}ensureClient(){this.client||(this.client=new Ul(this.baseUrl,this.options))}}class ny{constructor(t){this.http=t}async list(){return this.http.get("/scenarios")}async save(t){return this.http.post("/scenarios",t)}async run(t){return this.http.post(`/scenarios/${encodeURIComponent(t)}/run`)}async status(t,n){const s=n?`?executionId=${encodeURIComponent(n)}`:"";return this.http.get(`/scenarios/${encodeURIComponent(t)}/status${s}`)}async get(t){return(await this.list()).find(s=>s.id===t)}async runAndWait(t,n=1e3,s=3e5){const{executionId:a}=await this.run(t),o=Date.now()+s;for(;Date.now()<o;){const i=await this.status(t,a);if(i.status==="completed"||i.status==="failed")return i;await new Promise(l=>setTimeout(l,n))}return this.status(t,a)}}class ry{constructor(t){this.http=t}async list(){return this.http.get("/drills")}async run(t){return this.http.post(`/drills/${encodeURIComponent(t)}/run`)}async status(t,n){const s=n?`?runId=${encodeURIComponent(n)}`:"";return this.http.get(`/drills/${encodeURIComponent(t)}/status${s}`)}async markDetected(t,n){return this.http.post(`/drills/${encodeURIComponent(t)}/mark-detected`,n?{runId:n}:void 0)}async cancel(t,n){return this.http.post(`/drills/${encodeURIComponent(t)}/cancel`,n?{runId:n}:void 0)}async debrief(t,n){const s=n?`?runId=${encodeURIComponent(n)}`:"";return this.http.get(`/drills/${encodeURIComponent(t)}/debrief${s}`)}async get(t){return(await this.list()).find(s=>s.id===t)}async isActive(t,n){const s=await this.status(t,n);return!new Set(["won","failed","cancelled"]).has(s.status)}async runAndWait(t,n=2e3,s=6e5){const{runId:a}=await this.run(t),o=new Set(["won","failed","cancelled"]),i=Date.now()+s;for(;Date.now()<i;){const l=await this.status(t,a);if(o.has(l.status))return l;await new Promise(u=>setTimeout(u,n))}return this.status(t,a)}}class sy{constructor(t){this.http=t}async config(){return this.http.get("/api/redteam/autopilot/config")}async start(t){return this.http.post("/api/redteam/autopilot/start",t)}async stop(){return this.http.post("/api/redteam/autopilot/stop")}async kill(){return this.http.post("/api/redteam/autopilot/kill")}async status(t){const n=t?`?sessionId=${encodeURIComponent(t)}`:"";return this.http.get(`/api/redteam/autopilot/status${n}`)}async reports(t){const n=t?`?sessionId=${encodeURIComponent(t)}`:"";return this.http.get(`/api/redteam/autopilot/reports${n}`)}async isRunning(){const{active:t}=await this.status();return t}async launch(t,n){return this.start({objective:t,maxIterations:n})}}class ay{constructor(t){this.http=t}async triggerSupplyChainAttack(t){return this.http.post("/api/simulator/supply-chain",{target:t})}async getDependencyGraph(){return this.http.get("/api/simulator/dependencies")}async infect(t){return this.http.post("/api/simulator/dependencies/infect",{id:t})}async reset(){return this.http.post("/api/simulator/dependencies/reset",{})}}class oy{constructor(t){le(this,"http");le(this,"baseUrl");le(this,"sseOptions");le(this,"_core");le(this,"_network");le(this,"_identity");le(this,"_security");le(this,"_chaos");le(this,"_data");le(this,"_storage");le(this,"_traffic");le(this,"_defense");le(this,"_forensics");le(this,"_cluster");le(this,"_mtd");le(this,"_victim");le(this,"_webhooks");le(this,"_graphql");le(this,"_realtime");le(this,"_scenarios");le(this,"_drills");le(this,"_autopilot");le(this,"_simulator");this.http=new D0(t),this.baseUrl=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,this.sseOptions={autoReconnect:!0,reconnectDelay:3e3,maxReconnectAttempts:10}}get core(){return this._core||(this._core=new $0(this.http)),this._core}get network(){return this._network||(this._network=new z0(this.http)),this._network}get identity(){return this._identity||(this._identity=new F0(this.http)),this._identity}get security(){return this._security||(this._security=new B0(this.http)),this._security}get chaos(){return this._chaos||(this._chaos=new H0(this.http)),this._chaos}get data(){return this._data||(this._data=new U0(this.http)),this._data}get storage(){return this._storage||(this._storage=new V0(this.http)),this._storage}get traffic(){return this._traffic||(this._traffic=new q0(this.http)),this._traffic}get defense(){return this._defense||(this._defense=new W0(this.http)),this._defense}get forensics(){return this._forensics||(this._forensics=new G0(this.http)),this._forensics}get cluster(){return this._cluster||(this._cluster=new K0(this.http)),this._cluster}get mtd(){return this._mtd||(this._mtd=new Y0(this.http)),this._mtd}get victim(){return this._victim||(this._victim=new X0(this.http)),this._victim}get webhooks(){return this._webhooks||(this._webhooks=new J0(this.http)),this._webhooks}get graphql(){return this._graphql||(this._graphql=new Q0(this.http)),this._graphql}get realtime(){return this._realtime||(this._realtime=new ty(this.baseUrl,this.sseOptions)),this._realtime}get scenarios(){return this._scenarios||(this._scenarios=new ny(this.http)),this._scenarios}get drills(){return this._drills||(this._drills=new ry(this.http)),this._drills}get autopilot(){return this._autopilot||(this._autopilot=new sy(this.http)),this._autopilot}get simulator(){return this._simulator||(this._simulator=new ay(this.http)),this._simulator}async isHealthy(){return this.core.isHealthy()}async health(){return this.core.health()}async echo(t="/"){return this.core.echo(t)}getBaseUrl(){return this.baseUrl}setHeader(t,n){this.http.setHeader(t,n)}removeHeader(t){this.http.removeHeader(t)}}const kd=h.createContext(void 0),Ed="apparatus-base-url",Vl="http://localhost:8090";function iy(){try{return localStorage.getItem(Ed)||Vl}catch{return Vl}}function ly(e){try{localStorage.setItem(Ed,e)}catch{}}function ql(e){try{const t=new URL(e);return["http:","https:"].includes(t.protocol)}catch{return!1}}function cy({children:e,defaultUrl:t}){const[n,s]=h.useState(()=>t??iy()),[a,o]=h.useState({status:"unknown"}),[i,l]=h.useState(!1),u=h.useMemo(()=>!n||!ql(n)?null:new oy({baseUrl:n}),[n]),c=h.useCallback(p=>{if(!ql(p)){console.warn("Invalid URL rejected:",p);return}s(p),ly(p)},[]);h.useEffect(()=>{if(l(!1),!u){o({status:"unknown",message:"No client configured"}),l(!0);return}const p=new AbortController;let x=null,g=!0;const m=async()=>{if(p.signal.aborted)return;o(b=>({...b,status:"checking"}));const y=performance.now();try{const b=await u.core.health();if(p.signal.aborted)return;o({status:"healthy",message:"Connected",latencyMs:Math.round(performance.now()-y),version:b.version})}catch(b){if(p.signal.aborted)return;o({status:"unhealthy",message:b instanceof Error?b.message:"Connection failed"})}finally{!p.signal.aborted&&g&&(g=!1,l(!0))}};return m(),x=setInterval(m,3e4),()=>{p.abort(),x&&clearInterval(x)}},[u]);const d=a.status==="healthy",f=h.useMemo(()=>({client:u,baseUrl:n,setBaseUrl:c,health:a,isConnected:d,hasCompletedInitialHealthCheck:i}),[u,n,c,a,d,i]);return r.jsx(kd.Provider,{value:f,children:e})}function je(){const e=h.useContext(kd);if(e===void 0)throw new Error("useApparatus must be used within a ApparatusProvider");return e}const Lr="apparatus-dashboard-hud:v1",Ri="apparatus-dashboard-hud:hidden",Io="hud-state-changed";function Po(e){return typeof e=="object"&&e!==null?e:{}}function _d(){try{const e=localStorage.getItem(Lr);return e?Po(JSON.parse(e)):{}}catch{return{}}}function Cd(){try{const e=localStorage.getItem(Ri);return e===null?!0:e==="1"}catch{return!0}}function uy(){var t,n;const e=_d();return{statsVisible:((t=e.stats)==null?void 0:t.visible)===!0,thoughtsVisible:((n=e.thoughts)==null?void 0:n.visible)===!0}}function dy(e){try{localStorage.setItem(Ri,e.hidden?"1":"0");const t=_d(),n=Po(t.stats),s=Po(t.thoughts),a={...t,stats:{...n,visible:e.statsVisible},thoughts:{...s,visible:e.thoughtsVisible}};localStorage.setItem(Lr,JSON.stringify(a))}catch{}}const hy=[{title:"Core",items:[{path:"/",label:"Overview",icon:id},{path:"/docs",label:"Docs Hub",icon:lr}]},{title:"Observe",items:[{path:"/traffic",label:"Traffic",icon:dt},{path:"/timeline",label:"Timeline",icon:ld},{path:"/fingerprints",label:"Attackers",icon:Fe}]},{title:"Defend",items:[{path:"/defense",label:"Defense",icon:Qr},{path:"/deception",label:"Deception",icon:Fg},{path:"/mtd",label:"MTD",icon:Vg},{path:"/identity",label:"Identity",icon:wi}]},{title:"Test & Attack",items:[{path:"/chaos",label:"Chaos",icon:It},{path:"/scenarios",label:"Scenarios",icon:It},{path:"/drill",label:"Breach Protocol",icon:Fe},{path:"/ghosts",label:"Ghost Mocker",icon:Si},{path:"/autopilot",label:"Autopilot",icon:nd}]},{title:"Infra",items:[{path:"/cluster",label:"Cluster",icon:ba},{path:"/network",label:"Network",icon:dt},{path:"/webhooks",label:"Webhooks",icon:Ci},{path:"/listeners",label:"Listeners",icon:ki},{path:"/dependencies",label:"Supply Chain",icon:ji},{path:"/testing",label:"Testing Lab",icon:Ni}]},{title:"Config",items:[{path:"/settings",label:"Settings",icon:Ei}]}];function Td(){const{health:e}=je(),t=e.status==="healthy",[n,s]=h.useState(!1),[a,o]=h.useState(new Set(["Core"])),[i,l]=h.useState(!1),[u,c]=h.useState(!0),[d,f]=h.useState(!1),[p,x]=h.useState(!1);h.useEffect(()=>{try{const w=localStorage.getItem("apparatus-sidebar:collapsed")==="1";s(w);const j=localStorage.getItem("apparatus-sidebar:expanded-sections");j&&o(new Set(JSON.parse(j)));const k=Cd(),_=uy();c(k),f(!k&&_.statsVisible),x(!k&&_.thoughtsVisible)}catch{}},[]);const g=()=>{const w=!n;s(w);try{localStorage.setItem("apparatus-sidebar:collapsed",w?"1":"0")}catch{}},m=w=>{const j=new Set(a);j.has(w)?j.delete(w):j.add(w),o(j);try{localStorage.setItem("apparatus-sidebar:expanded-sections",JSON.stringify([...j]))}catch{}},y=(w,j,k)=>{const _={hidden:w,statsVisible:j,thoughtsVisible:k};return dy(_),_},b=(w,j)=>{const k=!(w||j);f(w),x(j),c(k);const _=y(k,w,j);window.dispatchEvent(new CustomEvent(Io,{detail:_}))},v=()=>{b(!d,p)},N=()=>{b(d,!p)};return r.jsxs("aside",{className:"w-60 h-screen bg-neutral-950 border-r border-neutral-800/60 flex flex-col relative overflow-hidden",children:[r.jsx("div",{className:"absolute top-0 left-0 w-full h-px bg-gradient-to-r from-primary-500/60 via-primary-500/10 to-transparent"}),r.jsxs("div",{className:"h-14 flex items-center justify-between px-5 border-b border-neutral-800/40",children:[!n&&r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("img",{src:"/dashboard/assets/icons/apparatus-icon.svg",alt:"Apparatus",className:"h-9 w-auto"}),r.jsx("span",{className:X("text-lg text-neutral-200",Ne("subhead")),children:"Apparatus"})]}),r.jsx("button",{onClick:g,className:"p-1 hover:bg-neutral-800/50 rounded-sm transition-colors",title:n?"Expand sidebar":"Collapse sidebar",children:n?r.jsx(Kg,{className:"h-4 w-4 text-neutral-500"}):r.jsx(Gg,{className:"h-4 w-4 text-neutral-500"})})]}),!n&&r.jsx("nav",{className:"flex-1 overflow-y-auto py-4 px-2","aria-label":"Main navigation",children:hy.map(w=>r.jsxs("div",{className:"mb-1",children:[r.jsxs("button",{onClick:()=>m(w.title),className:X("w-full flex items-center justify-between px-3 py-2 text-[11px] text-neutral-500 hover:text-neutral-300 transition-colors uppercase",Ne("label")),children:[r.jsx("span",{children:w.title}),a.has(w.title)?r.jsx(Ro,{className:"h-3 w-3"}):r.jsx(Pr,{className:"h-3 w-3"})]}),a.has(w.title)&&r.jsx("ul",{className:"space-y-px",children:w.items.map(({path:j,label:k,icon:_})=>r.jsx("li",{children:r.jsx(pg,{to:j,end:j==="/",className:({isActive:P})=>X("flex items-center gap-2.5 px-3 py-2 text-[13px] relative rounded-[3px]","transition-all duration-150","focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary-500/40",P?`bg-primary-500/8 text-primary-300 ${Ne("navActive")}`:`text-neutral-500 hover:text-neutral-300 hover:bg-neutral-900/60 ${Ne("nav")}`),children:({isActive:P})=>r.jsxs(r.Fragment,{children:[P&&r.jsx("div",{className:"absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-primary-500 shadow-[0_0_6px_rgba(0,240,255,0.6)]"}),r.jsx(_,{className:X("h-[15px] w-[15px] flex-shrink-0",P?"text-primary-400":"text-neutral-600"),strokeWidth:1.75}),r.jsx("span",{children:k})]})})},j))})]},w.title))}),!n&&r.jsxs("div",{className:"border-t border-neutral-800/40 bg-neutral-900/20",children:[r.jsx("div",{className:"px-3 py-2",children:r.jsxs("div",{role:"group","aria-label":"HUD widget controls",className:"space-y-1.5",children:[r.jsxs("button",{onClick:v,"aria-pressed":d,className:X("w-full flex items-center justify-between gap-2 px-3 py-2 text-[11px] rounded-sm transition-colors",Ne("label"),d?"text-primary-300 bg-primary-500/10 border border-primary-500/25":"text-neutral-500 hover:text-neutral-200 hover:bg-neutral-800/50 border border-transparent"),title:d?"Hide HUD stats widget":"Show HUD stats widget",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(dt,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:"HUD Stats"})]}),r.jsx("span",{className:X("h-1.5 w-1.5 rounded-full",d?"bg-primary-400 shadow-[0_0_6px_rgba(0,240,255,0.7)]":"bg-neutral-700")})]}),r.jsxs("button",{onClick:N,"aria-pressed":p,className:X("w-full flex items-center justify-between gap-2 px-3 py-2 text-[11px] rounded-sm transition-colors",Ne("label"),p?"text-primary-300 bg-primary-500/10 border border-primary-500/25":"text-neutral-500 hover:text-neutral-200 hover:bg-neutral-800/50 border border-transparent"),title:p?"Hide AI thought widget":"Show AI thought widget",children:[r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(rd,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:"AI Thought"})]}),r.jsx("span",{className:X("h-1.5 w-1.5 rounded-full",p?"bg-primary-400 shadow-[0_0_6px_rgba(0,240,255,0.7)]":"bg-neutral-700")})]}),u&&r.jsx("div",{className:X("px-1 text-[10px] uppercase text-neutral-600",Ne("timestamp")),children:"HUD hidden"})]})}),r.jsxs("div",{className:"px-3 py-2 border-t border-neutral-800/40",children:[r.jsxs("button",{onClick:()=>l(!i),"aria-expanded":i,className:X("w-full flex items-center justify-between text-[11px] text-neutral-600 hover:text-neutral-400 transition-colors",Ne("label")),children:[r.jsx("span",{children:"Keyboard"}),i?r.jsx(Ro,{className:"h-3 w-3"}):r.jsx(Pr,{className:"h-3 w-3"})]}),i&&r.jsxs("div",{className:"mt-2.5 space-y-1.5 text-[10px] text-neutral-500",children:[r.jsxs("div",{className:"flex justify-between items-center gap-2",children:[r.jsx("span",{children:"Commands"}),r.jsx("kbd",{className:X("px-1 py-0.5 rounded bg-neutral-800/50 text-neutral-400",Ne("timestamp")),children:"⌘K"})]}),r.jsxs("div",{className:"flex justify-between items-center gap-2",children:[r.jsx("span",{children:"Help"}),r.jsx("kbd",{className:X("px-1 py-0.5 rounded bg-neutral-800/50 text-neutral-400",Ne("timestamp")),children:"⌘?"})]}),r.jsxs("div",{className:"flex justify-between items-center gap-2",children:[r.jsx("span",{children:"Close"}),r.jsx("kbd",{className:X("px-1 py-0.5 rounded bg-neutral-800/50 text-neutral-400",Ne("timestamp")),children:"Esc"})]})]})]}),r.jsxs("div",{className:"px-4 py-3 border-t border-neutral-800/40",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:X("text-[11px] text-neutral-600",Ne("label")),children:"Status"}),r.jsxs("span",{className:X("text-[10px] flex items-center gap-1.5",Ne("timestamp"),t?"text-success-500":"text-danger-400"),children:[r.jsx("span",{className:X("w-1.5 h-1.5 rounded-full",t?"bg-success-500 animate-pulse-fast":"bg-danger-500")}),t?"Online":e.status]})]}),r.jsx("div",{className:"w-full h-[3px] bg-neutral-900 rounded-full overflow-hidden",children:r.jsx("div",{className:X("h-full rounded-full transition-all duration-700",t?"bg-success-500/80 w-[98%]":"bg-danger-500/60 w-[20%]")})}),r.jsxs("div",{className:X("mt-2.5 flex justify-between text-[10px] text-neutral-700",Ne("timestamp")),children:[r.jsx("span",{children:e.version?`v${e.version}`:"v—"}),e.latencyMs!==void 0&&r.jsxs("span",{className:"text-neutral-400",children:[e.latencyMs,"ms"]})]})]})]})]})}Td.displayName="Sidebar";function Rd(){var a;const{health:e}=je(),t=e.status==="healthy",n=()=>{window.dispatchEvent(new CustomEvent("apparatus:open-command-palette"))},s=()=>{window.dispatchEvent(new CustomEvent("apparatus:open-help-modal"))};return r.jsxs("header",{className:"h-12 bg-black/80 backdrop-blur-xl border-b border-white/5 flex items-center justify-between px-5 z-10 sticky top-0",children:[r.jsxs("div",{className:X("hidden md:flex items-center gap-2 text-[10px]",Ne("breadcrumb")),children:[r.jsx("div",{className:X("w-2.5 h-2.5 rounded-[1px] transition-all duration-1000",t?"bg-primary shadow-[0_0_12px_rgba(0,196,167,0.8)]":e.status==="checking"?"bg-warning animate-pulse":"bg-danger shadow-[0_0_12px_rgba(225,29,72,0.8)]")}),r.jsx("span",{className:"text-neutral-500 uppercase",children:"System"}),r.jsx("span",{className:"text-neutral-700",children:"/"}),r.jsx("span",{className:"text-neutral-100 uppercase font-bold tracking-widest",children:((a=window.location.pathname.split("/").pop())==null?void 0:a.toUpperCase())||"OVERVIEW"})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex flex-col items-end",children:[r.jsx("span",{className:X("text-[9px] text-neutral-600 uppercase leading-none",Ne("timestamp")),children:"Status"}),r.jsx("span",{className:X("text-[10px] leading-none mt-1 uppercase",Ne("tag"),t?"text-primary":"text-danger"),children:e.status==="healthy"?"NOMINAL":e.status.toUpperCase()})]}),e.latencyMs!==void 0&&r.jsxs("div",{className:"flex flex-col items-end border-l border-white/5 pl-3",children:[r.jsx("span",{className:X("text-[9px] text-neutral-600 uppercase leading-none",Ne("timestamp")),children:"Latency"}),r.jsxs("span",{className:X("text-[10px] text-neutral-400 leading-none mt-1",Ne("tag")),children:[e.latencyMs,"ms"]})]})]}),r.jsx("div",{className:"h-5 w-px bg-white/5 mx-1"}),r.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-2 rounded-sm border border-neutral-800/80 bg-neutral-900/60 px-2.5 py-1.5 text-neutral-300 transition-colors hover:border-primary/40 hover:text-primary",title:"Open command palette (Cmd+K)","aria-label":"Open command palette",children:[r.jsx(_i,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:X("hidden lg:inline text-[10px] uppercase",Ne("tag")),children:"Commands"}),r.jsx("kbd",{className:X("rounded-[2px] border border-neutral-700 bg-neutral-950 px-1.5 py-0.5 text-[10px] text-neutral-400",Ne("timestamp")),children:"⌘K"})]}),r.jsxs("button",{type:"button",onClick:s,className:"inline-flex items-center gap-2 rounded-sm border border-neutral-800/80 bg-neutral-900/60 px-2.5 py-1.5 text-neutral-300 transition-colors hover:border-primary/40 hover:text-primary",title:"Open help (Cmd+?)","aria-label":"Open help",children:[r.jsx(od,{className:"h-3.5 w-3.5"}),r.jsx("span",{className:X("hidden lg:inline text-[10px] uppercase",Ne("tag")),children:"Help"}),r.jsx("kbd",{className:X("rounded-[2px] border border-neutral-700 bg-neutral-950 px-1.5 py-0.5 text-[10px] text-neutral-400",Ne("timestamp")),children:"⌘?"})]})]})]})}Rd.displayName="Header";function Ad({children:e,className:t}){return r.jsxs("main",{className:X("flex-1 overflow-y-auto overflow-x-hidden p-5 relative","bg-neutral-950 bg-grid-pattern bg-[length:48px_48px]",t),role:"main",children:[r.jsx("div",{className:"absolute top-0 left-0 w-[500px] h-[400px] bg-primary-500/[0.02] rounded-full blur-[100px] pointer-events-none"}),r.jsx("div",{className:"absolute bottom-0 right-0 w-[400px] h-[300px] bg-warning-500/[0.01] rounded-full blur-[100px] pointer-events-none"}),r.jsx("div",{className:"relative z-10 max-w-[1400px] mx-auto",children:e})]})}Ad.displayName="MainContent";const Md=h.createContext(void 0),Id="apparatus-theme";function Wl(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function fy(){try{const e=localStorage.getItem(Id);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"dark"}function Gl(e){try{localStorage.setItem(Id,e)}catch{}}function py({children:e,defaultTheme:t}){const[n,s]=h.useState(()=>t??fy()),[a,o]=h.useState(()=>n==="system"?Wl():n),i=h.useCallback(c=>{s(c),Gl(c)},[]),l=h.useCallback(()=>{s(c=>{const d=c==="dark"?"light":"dark";return Gl(d),d})},[]);h.useEffect(()=>{const c=()=>{const d=n==="system"?Wl():n;o(d),document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(d)};if(c(),n==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)");return d.addEventListener("change",c),()=>d.removeEventListener("change",c)}},[n]);const u=h.useMemo(()=>({theme:n,resolvedTheme:a,setTheme:i,toggleTheme:l}),[n,a,i,l]);return r.jsx(Md.Provider,{value:u,children:e})}function Pd(){const e=h.useContext(Md);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e}const Od=h.createContext(void 0);function my({children:e}){const[t,n]=h.useState(null),s=o=>{n(o)},a=()=>{n(null)};return r.jsx(Od.Provider,{value:{selectedDocId:t,openDoc:s,closeDoc:a},children:e})}function Ai(){const e=h.useContext(Od);if(!e)throw new Error("useDocViewer must be used within DocViewerProvider");return e}const Kl=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Yl=bd,Mi=(e,t)=>n=>{var s;if((t==null?void 0:t.variants)==null)return Yl(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:a,defaultVariants:o}=t,i=Object.keys(a).map(c=>{const d=n==null?void 0:n[c],f=o==null?void 0:o[c];if(d===null)return null;const p=Kl(d)||Kl(f);return a[c][p]}),l=n&&Object.entries(n).reduce((c,d)=>{let[f,p]=d;return p===void 0||(c[f]=p),c},{}),u=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((c,d)=>{let{class:f,className:p,...x}=d;return Object.entries(x).every(g=>{let[m,y]=g;return Array.isArray(y)?y.includes({...o,...l}[m]):{...o,...l}[m]===y})?[...c,f,p]:c},[]);return Yl(e,i,u,n==null?void 0:n.class,n==null?void 0:n.className)},xy=Mi("border overflow-hidden flex flex-col transition-all duration-500 ease-out",{variants:{variant:{default:"bg-card text-card-foreground border-border shadow-sm",panel:"border-ops-frame bg-ops-panel/95 shadow-[inset_0_1px_0_rgba(255,255,255,0.03),0_18px_34px_rgba(1,8,20,0.55)]",glass:"bg-black/40 backdrop-blur-xl border-white/10 shadow-inner-glow",ghost:"bg-transparent border-transparent"},glow:{none:"",primary:"border-primary/30 shadow-glow-primary",success:"border-success/30 shadow-glow-success",warning:"border-warning/30 shadow-glow-warning",danger:"border-danger/30 shadow-glow-danger",info:"border-info/30 shadow-glow-info"},kinetic:{true:"rounded-[var(--ui-radius)] skew-x-[var(--ui-skew)]",false:"rounded-sm"}},defaultVariants:{variant:"panel",glow:"none",kinetic:!1}}),se=h.forwardRef(({className:e,variant:t,glow:n,kinetic:s,...a},o)=>r.jsx("div",{ref:o,className:X(xy({variant:t,glow:n,kinetic:s,className:e})),...a}));se.displayName="Card";const ce=h.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:X("flex flex-col space-y-1.5 p-4 border-b border-ops-line bg-ops-panel-soft/55",e),...t}));ce.displayName="CardHeader";const de=h.forwardRef(({className:e,...t},n)=>r.jsx("h3",{ref:n,className:X("text-lg leading-none text-ops-text-strong",Ne("heading"),e),...t}));de.displayName="CardTitle";const Re=h.forwardRef(({className:e,...t},n)=>r.jsx("p",{ref:n,className:X("text-sm text-muted-foreground",Ne("body"),e),...t}));Re.displayName="CardDescription";const ae=h.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:X("p-6 pt-0 mt-4",e),...t}));ae.displayName="CardContent";const Ld=h.forwardRef(({className:e,...t},n)=>r.jsx("div",{ref:n,className:X("flex items-center p-6 pt-0 border-t border-border mt-auto",e),...t}));Ld.displayName="CardFooter";const gy=Mi("inline-flex items-center rounded-sm border px-2.5 py-0.5 text-[11px] transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 uppercase",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",primary:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",neutral:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",danger:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500/15 text-green-500 hover:bg-green-500/25 border-green-500/20",warning:"border-transparent bg-yellow-500/15 text-yellow-500 hover:bg-yellow-500/25 border-yellow-500/20",info:"border-transparent bg-blue-500/15 text-blue-500 hover:bg-blue-500/25 border-blue-500/20",neon:"border-primary/50 bg-primary/10 text-primary shadow-[0_0_10px_rgba(0,240,255,0.2)]",chip:"border-ops-line bg-ops-panel-soft/85 text-ops-text-muted px-2 py-1"},size:{default:"",sm:"text-[10px] px-1.5 py-0.5",md:"px-2.5 py-0.5",lg:"px-3 py-1 text-sm"}},defaultVariants:{variant:"default",size:"default"}});function ue({className:e,variant:t,size:n,dot:s,children:a,...o}){return r.jsxs("div",{className:X(gy({variant:t,size:n}),Ne("tag"),e),...o,children:[s&&r.jsx("span",{className:X("mr-1.5 flex h-1.5 w-1.5 rounded-full transition-casual",t==="destructive"||t==="danger"?"bg-danger animate-pulse":t==="success"?"bg-green-500":t==="warning"?"bg-yellow-500":"bg-primary")}),a]})}function Xl(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Qt(...e){return t=>{let n=!1;const s=e.map(a=>{const o=Xl(a,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let a=0;a<s.length;a++){const o=s[a];typeof o=="function"?o():Xl(e[a],null)}}}}function Me(...e){return h.useCallback(Qt(...e),e)}var yy=Symbol.for("react.lazy"),qs=bi[" use ".trim().toString()];function by(e){return typeof e=="object"&&e!==null&&"then"in e}function Dd(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===yy&&"_payload"in e&&by(e._payload)}function $d(e){const t=wy(e),n=h.forwardRef((s,a)=>{let{children:o,...i}=s;Dd(o)&&typeof qs=="function"&&(o=qs(o._payload));const l=h.Children.toArray(o),u=l.find(Sy);if(u){const c=u.props.children,d=l.map(f=>f===u?h.Children.count(c)>1?h.Children.only(null):h.isValidElement(c)?c.props.children:null:f);return r.jsx(t,{...i,ref:a,children:h.isValidElement(c)?h.cloneElement(c,void 0,d):null})}return r.jsx(t,{...i,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}var vy=$d("Slot");function wy(e){const t=h.forwardRef((n,s)=>{let{children:a,...o}=n;if(Dd(a)&&typeof qs=="function"&&(a=qs(a._payload)),h.isValidElement(a)){const i=ky(a),l=jy(o,a.props);return a.type!==h.Fragment&&(l.ref=s?Qt(s,i):i),h.cloneElement(a,l)}return h.Children.count(a)>1?h.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ny=Symbol("radix.slottable");function Sy(e){return h.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ny}function jy(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...l)=>{const u=o(...l);return a(...l),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function ky(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const Ey=Mi("inline-flex items-center justify-center whitespace-nowrap rounded-sm uppercase text-[11px] ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 active:scale-[0.98]",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-[0_0_15px_-5px_rgba(0,196,167,0.4)] border border-transparent",primary:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-[0_0_15px_-5px_rgba(0,196,167,0.4)] border border-transparent",destructive:"bg-danger text-white hover:bg-danger/90 shadow-[0_0_15px_-5px_rgba(225,29,72,0.4)] border border-transparent",danger:"bg-danger text-white hover:bg-danger/90 shadow-[0_0_15px_-5px_rgba(225,29,72,0.4)] border border-transparent",secondary:"bg-neutral-900/60 border border-neutral-700 text-neutral-200 hover:bg-neutral-800 hover:border-neutral-600 shadow-[0_0_10px_-3px_rgba(0,0,0,0.5)] transition-all",outline:"border border-primary/50 bg-primary/5 text-primary/90 hover:bg-primary/15 hover:border-primary/70 shadow-[0_0_8px_-3px_rgba(0,196,167,0.2)]",ghost:"hover:bg-accent hover:text-accent-foreground text-muted-foreground",link:"text-primary underline-offset-4 hover:underline",neon:"bg-primary/15 border border-primary/60 text-primary shadow-[0_0_10px_rgba(0,196,167,0.3)] hover:bg-primary/25 hover:border-primary/80 hover:shadow-[0_0_20px_rgba(0,196,167,0.5)] transition-all duration-300"},size:{default:"h-10 px-5",sm:"h-8 px-4",lg:"h-12 px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),Q=h.forwardRef(({className:e,variant:t,size:n,asChild:s=!1,isLoading:a,children:o,leftIcon:i,rightIcon:l,...u},c)=>{const d=s?vy:"button";return r.jsx(d,{className:X(Ey({variant:t,size:n}),Ne("tag"),e),ref:c,disabled:a||u.disabled,...u,children:a?r.jsxs(r.Fragment,{children:[r.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),r.jsx("span",{children:"PROCESSING..."})]}):r.jsxs(r.Fragment,{children:[i&&r.jsx("span",{className:"mr-2.5 opacity-80",children:i}),o,l&&r.jsx("span",{className:"ml-2.5 opacity-80",children:l})]})})});Q.displayName="Button";function zd(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState(!1),o=h.useCallback(async()=>{if(e)try{const u=await fetch(`${e}/sentinel/rules`);if(!u.ok)throw new Error(u.statusText);const c=await u.json();Array.isArray(c)&&n(c)}catch(u){console.error("Failed to fetch rules",u)}},[e]),i=h.useCallback(async(u,c)=>{if(e){a(!0);try{const d=await fetch(`${e}/sentinel/rules`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pattern:u,action:c})});if(!d.ok)throw new Error(d.statusText);await o()}catch(d){console.error("Failed to add rule",d)}finally{a(!1)}}},[e,o]),l=h.useCallback(async u=>{if(e)try{const c=await fetch(`${e}/sentinel/rules?id=${encodeURIComponent(u)}`,{method:"DELETE"});if(!c.ok)throw new Error(c.statusText);n(d=>d.filter(f=>f.id!==u))}catch(c){console.error("Failed to delete rule",c)}},[e]);return h.useEffect(()=>{o()},[o]),{rules:t,addRule:i,deleteRule:l,refresh:o,isLoading:s}}const _y=1e3,Cy=3e4;function ts(e,t={}){const{enabled:n=!0,maxRetries:s=5,onOpen:a,onError:o,onMaxRetriesExceeded:i}=t,[l,u]=h.useState("disconnected"),[c,d]=h.useState(0),f=h.useRef(a),p=h.useRef(o),x=h.useRef(i);h.useEffect(()=>{f.current=a,p.current=o,x.current=i},[a,o,i]);const g=h.useRef(null),m=h.useRef(null),y=h.useRef(new Map),b=h.useCallback(()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),v=h.useCallback(()=>{b(),g.current&&(g.current.close(),g.current=null),u("disconnected")},[b]),N=h.useCallback((w,j)=>{const k=y.current;if(!k.has(w)&&(k.set(w,new Set),g.current&&g.current.readyState===EventSource.OPEN)){const _=P=>{var T;try{const $=JSON.parse(P.data);(T=k.get(w))==null||T.forEach(B=>B($))}catch($){console.error(`Failed to parse SSE event "${w}"`,$)}};g.current.addEventListener(w,_)}return k.get(w).add(j),()=>{const _=k.get(w);_&&(_.delete(j),_.size===0&&k.delete(w))}},[]);return h.useEffect(()=>{var k;if(!e||!n){v();return}if(c>s){u("error"),(k=x.current)==null||k.call(x);return}let w=null;const j=()=>{v(),u("connecting");const _=new EventSource(e);g.current=_,_.onopen=()=>{var P;console.log(`[SSE] Connected to ${e}`),u("connected"),d(0),(P=f.current)==null||P.call(f),y.current.forEach((T,$)=>{_.addEventListener($,B=>{try{const D=JSON.parse(B.data);T.forEach(R=>R(D))}catch(D){console.error(`[SSE] Parse Error for ${$}`,D)}})})},_.onerror=P=>{var T;console.error(`[SSE] Connection Error for ${e}`,P),u("error"),(T=p.current)==null||T.call(p,P),_.close(),d($=>$+1)}};if(c>0){const _=Math.min(_y*Math.pow(2,c-1),Cy);w=setTimeout(j,_)}else j();return()=>{w&&clearTimeout(w),v()}},[e,n,c,s,v]),{status:l,retryCount:c,subscribe:N,close:v}}function Ii(e=50){const{baseUrl:t}=je(),[n,s]=h.useState([]),{subscribe:a,status:o}=ts(`${t}/sse`,{enabled:!!t,maxRetries:10});return h.useEffect(()=>o!=="connected"?void 0:a("request",l=>{s(u=>{const c=[l,...u];return c.length>e?c.slice(0,e):c})}),[o,a,e]),{events:n,isConnected:o==="connected"}}const Zl=["traffic","defense","deception","integrations","system"],Jl=["info","warn","error"];function Xa(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e)))return Number(e)}function qe(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function Fd(e,t,n){const s=qe(t.timestamp)??new Date().toISOString();if(e==="request"){const l=qe(t.method)??"REQUEST",u=qe(t.path)??qe(t.originalUrl)??"/",c=Xa(t.status),d=Xa(t.latencyMs),f=c!==void 0&&c>=500?"error":c!==void 0&&c>=400?"warn":"info";return{id:`${e}:${qe(t.id)??s}:${n}`,type:e,module:"traffic",severity:f,title:`${l.toUpperCase()} ${u}`,summary:`${c??"n/a"}${d!==void 0?` • ${d}ms`:""}`,timestamp:s,sourceIp:qe(t.ip),data:t}}if(e==="deception"){const l=qe(t.type)??"deception_event",u=qe(t.route)??"/",c=qe(t.ip),d=l==="shell_command"?"error":"warn";return{id:`${e}:${s}:${n}`,type:e,module:"deception",severity:d,title:l.replace(/_/g," ").toUpperCase(),summary:`${u}${c?` • ${c}`:""}`,timestamp:s,sourceIp:c,data:t}}if(e==="tarpit"){const l=qe(t.action)??"trapped",u=qe(t.ip);return{id:`${e}:${s}:${n}`,type:e,module:"defense",severity:l==="trapped"?"warn":"info",title:`TARPIT ${l.toUpperCase()}`,summary:u??"Unknown IP",timestamp:s,sourceIp:u,data:t}}if(e==="health"){const l=qe(t.status)??"unknown",u=l==="critical"||l==="unhealthy"?"error":l==="degraded"?"warn":"info";return{id:`${e}:${s}:${n}`,type:e,module:"system",severity:u,title:`SYSTEM ${l.toUpperCase()}`,summary:`Clients: ${Xa(t.clients)??0}`,timestamp:s,data:t}}const a=qe(t.ip),o=qe(t.method)??"WEBHOOK",i=qe(t.hookId)??"unknown";return{id:`${e}:${s}:${n}`,type:e,module:"integrations",severity:"info",title:`${o.toUpperCase()} hook:${i}`,summary:a??"Incoming callback",timestamp:s,sourceIp:a,data:t}}const Bd=10*60*1e3,Ql=60*60*1e3,Oo=750,ec=350;function Ws(e){return typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&e.trim()!==""&&Number.isFinite(Number(e))?Number(e):null}function Gs(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")return null;const t=Date.parse(e);return Number.isNaN(t)?null:t}function tc(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour12:!1})}function Ty(e){return e==="error"?"danger":e==="warn"?"warning":"info"}function Ry(e){return e==="deception"?"danger":e==="defense"?"warning":e==="traffic"?"info":"neutral"}function Hd(e){return e==="traffic"?"TRAFFIC":e==="defense"?"DEFENSE":e==="deception"?"DECEPTION":e==="integrations"?"INTEGRATION":"SYSTEM"}function Ay(e){return e==="error"?"bg-danger":e==="warn"?"bg-warning":"bg-info"}function My(e){if(e.module==="defense"||e.module==="deception")return!0;if(e.type==="health")return e.severity!=="info";if(e.type==="request"){const t=Ws(e.data.status),n=Ws(e.data.latencyMs),s=typeof e.data.path=="string"?e.data.path:"";if(t!==null&&t>=400||n!==null&&n>=Oo||s.startsWith("/chaos/"))return!0}return e.severity!=="info"}function Iy(e){if(e.length===0)return{throughputRps:0,errorRate:0,activeSources:0,avgLatencyMs:null};const t=Gs(e[0].timestamp),n=Gs(e[e.length-1].timestamp),s=t!==null&&n!==null?Math.max((t-n)/1e3,1):1,a=e.filter(u=>u.status>=400).length,o=e.map(u=>u.latencyMs).filter(u=>Number.isFinite(u)),i=o.length>0?Math.round(o.reduce((u,c)=>u+c,0)/o.length):null,l=new Set(e.map(u=>u.ip).filter(u=>typeof u=="string"&&u.length>0)).size;return{throughputRps:Math.round(e.length/s),errorRate:Math.round(a/e.length*100),activeSources:l,avgLatencyMs:i}}function Py(e,t=Date.now()){let n=0,s=0,a=0,o=0;const i=new Map;for(const u of e){const c=Gs(u.timestamp),d=c!==null?t-c:null;if(d!==null&&d<=Bd&&(n+=1),d!==null&&d<=Ql&&(s+=1),u.severity==="error"&&(a+=1),u.severity==="warn"&&(o+=1),d!==null&&d<=Ql&&(u.severity==="error"||u.severity==="warn")){const f=u.sourceIp??Hd(u.module);i.set(f,(i.get(f)??0)+1)}}const l=[...i.entries()].sort((u,c)=>c[1]-u[1]).slice(0,2).map(([u,c])=>({label:u,count:c}));return{last10m:n,lastHour:s,critical:a,warning:o,activeEntities:i.size,topSources:l}}function Oy(e){return e.critical>0?{label:"CRITICAL",toneClass:"text-danger"}:e.warning>0||e.last10m>0?{label:"ELEVATED",toneClass:"text-warning"}:{label:"STABLE",toneClass:"text-success-500"}}function Ly(e,t=Date.now()){return e.filter(n=>{if(n.module!=="defense")return!1;const s=Gs(n.timestamp);return s!==null&&t-s<=Bd}).length}const Dy=160,$y=8,zy=3e4,Fy=15e3,nc=["bg-ops-accent/90","bg-ops-accent-alt/85","bg-ops-magenta/80","bg-ops-warning-soft/80","bg-ops-slate/80"];function Za({title:e,icon:t,to:n,actionLabel:s}){return r.jsxs("div",{className:"mb-4 flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(t,{className:"h-3.5 w-3.5 text-ops-slate"}),r.jsx("span",{className:"text-[10px] font-mono uppercase tracking-[0.22em] text-ops-text-subtle",children:e})]}),r.jsxs(Os,{to:n,className:"group inline-flex items-center gap-1 text-[10px] font-mono uppercase tracking-[0.12em] text-ops-accent/85 transition-colors hover:text-ops-accent",children:[s,r.jsx(td,{className:"h-3 w-3 transition-transform group-hover:translate-x-0.5"})]})]})}function By({segments:e}){const t=h.useMemo(()=>e.flatMap(n=>Array.from({length:Math.max(1,n.count)},(s,a)=>({key:`${n.protocol}-${a}`,colorClass:n.colorClass}))),[e]);return t.length===0?r.jsx("div",{className:"mt-4 h-1 rounded-full bg-ops-rail"}):r.jsxs("div",{className:"mt-4",children:[r.jsx("div",{className:"flex h-1 gap-px overflow-hidden rounded-full bg-ops-rail",children:t.map(n=>r.jsx("span",{className:X("h-full flex-1",n.colorClass)},n.key))}),r.jsx("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1",children:e.map(n=>r.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-[0.08em] text-ops-text-subtle",children:[r.jsx("span",{className:X("h-1.5 w-1.5 rounded-full",n.colorClass)}),n.protocol," ",n.count]},n.protocol))})]})}function Hy(){var M;const{health:e,baseUrl:t}=je(),{rules:n,isLoading:s}=zd(),{events:a}=Ii(600),[o,i]=h.useState([]),[l,u]=h.useState({totalListeners:0,activeListeners:0,segments:[]}),[c,d]=h.useState(!0),[f,p]=h.useState(null),[x,g]=h.useState(!0),[m,y]=h.useState(0),[b,v]=h.useState(!0),N=h.useRef(0),w=h.useRef(null),{subscribe:j,status:k}=ts(`${t}/sse`,{enabled:!!t,maxRetries:10}),_=h.useCallback((z,H)=>{N.current+=1;const V=Fd(z,H,N.current);My(V)&&i(Z=>[V,...Z].slice(0,Dy))},[]);h.useEffect(()=>{N.current=0,i([])},[t]),h.useEffect(()=>{const z=window.setInterval(()=>{y(H=>H+1)},zy);return()=>{window.clearInterval(z)}},[]),h.useEffect(()=>{if(k!=="connected")return;const z=[j("request",H=>_("request",H)),j("deception",H=>_("deception",H)),j("tarpit",H=>_("tarpit",H)),j("health",H=>_("health",H))];return()=>{for(const H of z)H()}},[_,k,j]),h.useEffect(()=>{if(!t){d(!1);return}const z=new AbortController;return d(!0),(async()=>{try{const V=await fetch(`${t}/api/infra/status`,{signal:z.signal,credentials:"same-origin"});if(!V.ok)throw new Error(`Failed to fetch protocols (${V.status})`);const Z=await V.json(),G=Array.isArray(Z.servers)?Z.servers:[],J=G.filter(oe=>oe.status==="active"),ee=new Map;for(const oe of J){const ie=typeof oe.protocol=="string"&&oe.protocol.trim()!==""?oe.protocol.toUpperCase():"UNKNOWN";ee.set(ie,(ee.get(ie)??0)+1)}const te=[...ee.entries()].sort((oe,ie)=>ie[1]-oe[1]).map(([oe,ie],me)=>({protocol:oe,count:ie,colorClass:nc[me%nc.length]}));u({totalListeners:G.length,activeListeners:J.length,segments:te})}catch{if(z.signal.aborted)return;u({totalListeners:0,activeListeners:0,segments:[]})}finally{if(z.signal.aborted)return;d(!1)}})(),()=>{z.abort()}},[t]),h.useEffect(()=>{if(!t){p(null),g(!1);return}let z=!1;const H=new AbortController;g(!0);const V=async()=>{try{const G=await fetch(`${t}/chaos/status`,{signal:H.signal,credentials:"same-origin"});if(!G.ok)throw new Error(`Failed to fetch chaos status (${G.status})`);const J=await G.json();if(z)return;p({cpuSpikeRunning:J.cpuSpikeRunning===!0,memoryChunks:Math.max(0,Ws(J.memoryChunks)??0),memoryAllocatedMb:Math.max(0,Ws(J.memoryAllocatedMb)??0)})}catch{if(z)return;p(null)}finally{if(z)return;g(!1)}};V();const Z=window.setInterval(V,Fy);return()=>{z=!0,window.clearInterval(Z),H.abort()}},[t]);const P=h.useMemo(()=>Iy(a),[a]),T=h.useMemo(()=>Py(o,Date.now()),[o,m]),$=h.useMemo(()=>o.slice(0,$y),[o]),B=(M=$[0])==null?void 0:M.id;h.useEffect(()=>{if(!b)return;const z=w.current;z&&(z.scrollTop=0)},[b,B]);const D=()=>{v(z=>!z)},R=h.useMemo(()=>Ly(o,Date.now()),[o,m]),S=h.useMemo(()=>a.find(z=>z.path.startsWith("/chaos/")),[a]),C=e.status!=="unhealthy"&&e.status!=="unknown",E=!!(f!=null&&f.cpuSpikeRunning)||((f==null?void 0:f.memoryAllocatedMb)??0)>0,A=e.status==="healthy"?"text-success-500":e.status==="degraded"||e.status==="checking"?"text-warning":e.status==="critical"||e.status==="unhealthy"?"text-danger":"text-neutral-300",O=e.status==="healthy"?"NOMINAL":e.status.toUpperCase(),I=P.avgLatencyMs===null?"text-ops-text-body":P.avgLatencyMs>=Oo?"text-danger":P.avgLatencyMs>=ec?"text-warning":"text-ops-text-body",F=P.avgLatencyMs===null?"NO DATA":P.avgLatencyMs>=Oo?"CRITICAL":P.avgLatencyMs>=ec?"ELEVATED":"NOMINAL",L=h.useMemo(()=>Oy(T),[T]);return r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-end md:justify-between opacity-0 animate-terminal-in stagger-1",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"System Overview"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Incident-first real-time state."})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-4 rounded-sm border border-ops-line bg-ops-panel-soft/90 px-4 py-3 shadow-[inset_0_0_18px_rgba(56,160,255,0.05)]",children:[r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.2em] text-ops-text-subtle",children:"System"}),r.jsx("div",{className:X("text-[12px] font-mono uppercase",A),children:O})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.2em] text-ops-text-subtle",children:"Control Latency"}),r.jsx("div",{className:"text-[12px] font-mono text-ops-text-body",children:e.latencyMs!==void 0?`${e.latencyMs}ms`:"—"})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.2em] text-ops-text-subtle",children:"Request Latency"}),r.jsx("div",{className:X("text-[12px] font-mono",I),children:P.avgLatencyMs!==null?`${P.avgLatencyMs}ms`:"—"}),r.jsx("div",{className:"text-[10px] font-mono text-ops-text-quiet",children:F})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.2em] text-ops-text-subtle",children:"Incident Pressure"}),r.jsx("div",{className:X("text-[12px] font-mono uppercase",L.toneClass),children:L.label}),r.jsxs("div",{className:"text-[10px] font-mono text-ops-text-quiet",children:[T.critical,"C / ",T.warning,"W"]})]}),r.jsxs("div",{className:"text-right",children:[r.jsx("div",{className:"text-[9px] font-mono uppercase tracking-[0.2em] text-ops-text-subtle",children:"Protocols"}),r.jsx("div",{className:"text-[12px] font-mono text-ops-text-body",children:c?"...":`${l.activeListeners}/${l.totalListeners||"—"}`})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-3",children:[r.jsx(se,{variant:"panel",className:"opacity-0 animate-terminal-in stagger-2",children:r.jsxs(ae,{className:"p-4 pt-4",children:[r.jsx(Za,{title:"Traffic",icon:dt,to:"/traffic",actionLabel:"Traffic"}),r.jsxs("div",{className:"text-3xl font-display text-ops-text-strong",children:[P.throughputRps," RPS"]}),r.jsxs("div",{className:"mt-2 flex items-center justify-between text-[11px] font-mono uppercase tracking-wide text-ops-text-subtle",children:[r.jsxs("span",{children:[P.activeSources," active sources"]}),r.jsxs("span",{className:X(P.errorRate>5?"text-ops-warning-soft":"text-ops-text-subtle"),children:[P.errorRate,"% errors"]})]}),c?r.jsx("div",{className:"mt-4 h-1 animate-pulse rounded-full bg-ops-line/80"}):r.jsx(By,{segments:l.segments})]})}),r.jsx(se,{variant:"panel",glow:T.critical>0?"danger":"none",className:"opacity-0 animate-terminal-in stagger-3",children:r.jsxs(ae,{className:"p-4 pt-4",children:[r.jsx(Za,{title:"Incidents",icon:Zt,to:"/timeline",actionLabel:"Timeline"}),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.16em] text-ops-text-subtle",children:"Last 10m"}),r.jsx("div",{className:"mt-1 text-2xl font-display text-ops-text-strong",children:T.last10m})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.16em] text-ops-text-subtle",children:"Last hour"}),r.jsx("div",{className:"mt-1 text-2xl font-display text-ops-text-strong",children:T.lastHour})]})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[T.critical>0&&r.jsxs(ue,{variant:"danger",size:"sm",className:"shadow-[0_0_12px_rgba(239,68,68,0.2)]",children:[T.critical," CRITICAL"]}),T.warning>0&&r.jsxs(ue,{variant:"warning",size:"sm",children:[T.warning," WARNING"]}),T.critical===0&&T.warning===0&&r.jsx(ue,{variant:"success",size:"sm",children:"NO ACTIVE ALERTS"})]})]})}),r.jsx(se,{variant:"panel",className:"opacity-0 animate-terminal-in stagger-4",children:r.jsxs(ae,{className:"p-4 pt-4",children:[r.jsx(Za,{title:"Threats",icon:Fe,to:"/fingerprints",actionLabel:"Attackers"}),r.jsx("div",{className:"text-3xl font-display text-ops-text-strong",children:T.activeEntities}),r.jsx("div",{className:"mt-1 text-[10px] font-mono uppercase tracking-[0.16em] text-ops-text-subtle",children:"active entities (1h)"}),r.jsx("div",{className:"mt-4 space-y-2",children:T.topSources.length===0?r.jsx("div",{className:"rounded-sm border border-ops-line bg-ops-panel-soft/85 px-3 py-2 text-[11px] font-mono text-ops-text-subtle",children:"No high-risk entities recorded yet."}):T.topSources.map(z=>r.jsxs("div",{className:"flex items-center justify-between rounded-sm border border-ops-line bg-ops-panel-soft/85 px-3 py-2",children:[r.jsx("span",{className:"truncate pr-3 text-[11px] font-mono text-ops-text-body",children:z.label}),r.jsx("span",{className:"text-[10px] font-mono uppercase tracking-wider text-ops-text-quiet",children:z.count})]},z.label))})]})})]}),r.jsxs(se,{variant:"panel",className:"opacity-0 animate-terminal-in stagger-5",children:[r.jsx(ce,{className:"border-ops-line bg-ops-panel-soft/55 pb-3",children:r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs(de,{className:"flex items-center gap-2 text-[10px] font-mono uppercase tracking-[0.22em] text-ops-text-subtle",children:[r.jsx(Zt,{className:"h-3.5 w-3.5 text-ops-warning-soft"}),"Incident Feed"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Q,{type:"button",variant:"secondary",size:"sm",onClick:D,"aria-pressed":b,className:"border-ops-line bg-ops-panel-soft text-ops-accent-soft hover:bg-ops-hover hover:text-ops-text-body",children:b?r.jsxs(r.Fragment,{children:[r.jsx(Jn,{className:"mr-1.5 h-3.5 w-3.5"}),"STOP AUTO-SCROLLING"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ke,{className:"mr-1.5 h-3.5 w-3.5"}),"RESUME AUTO-SCROLLING"]})}),r.jsx(Q,{asChild:!0,variant:"secondary",size:"sm",className:"border-ops-line bg-ops-panel-soft text-ops-accent-soft hover:bg-ops-hover hover:text-ops-text-body",children:r.jsx(Os,{to:"/timeline",children:"OPEN TIMELINE"})})]})]})}),r.jsx(ae,{className:"p-0",children:$.length===0?r.jsxs("div",{className:"px-4 py-10 text-center",children:[r.jsx("div",{className:"text-[11px] font-mono uppercase tracking-[0.18em] text-ops-text-subtle",children:"Waiting for actionable incidents"}),r.jsx("p",{className:"mt-2 text-sm text-ops-text-muted",children:"Feed shows triggered, detected, and failed events only."})]}):r.jsxs("div",{className:"relative",children:[r.jsx("div",{ref:w,tabIndex:0,role:"log","aria-live":b?"polite":"off","aria-label":"Incident feed",className:"max-h-[320px] overflow-y-auto focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ops-accent/50",children:$.map(z=>r.jsxs("div",{className:"grid grid-cols-[72px_1fr_auto] items-start gap-3 border-b border-ops-line px-4 py-3 transition-colors hover:bg-ops-hover/35 last:border-b-0",children:[r.jsx("div",{className:"pt-[2px] text-[11px] font-mono text-ops-text-subtle",children:tc(z.timestamp)}),r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:X("h-1.5 w-1.5 flex-shrink-0 rounded-full",Ay(z.severity))}),r.jsx("span",{className:"truncate text-sm font-medium text-ops-text-strong",children:z.title}),r.jsx(ue,{variant:Ty(z.severity),size:"sm",className:"inline-flex",children:z.severity.toUpperCase()})]}),r.jsx("p",{className:"mt-1 truncate text-[12px] font-mono text-ops-text-muted",children:z.summary})]}),r.jsx(ue,{variant:Ry(z.module),size:"sm",className:"mt-[2px] border-ops-source-border bg-ops-source-bg text-ops-source-text",children:Hd(z.module)})]},z.id))}),r.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6 bg-gradient-to-t from-ops-panel to-transparent"})]})})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[r.jsx(se,{variant:"panel",className:"opacity-0 animate-terminal-in stagger-6",children:r.jsxs(ae,{className:"p-4 pt-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Qr,{className:"h-3.5 w-3.5 text-ops-accent/90"}),r.jsx("span",{className:"text-[10px] font-mono uppercase tracking-[0.22em] text-ops-text-subtle",children:"Defenses"})]}),r.jsx(Q,{asChild:!0,variant:"secondary",size:"sm",className:"border-ops-line bg-ops-panel-soft text-ops-accent-soft hover:bg-ops-hover hover:text-ops-text-body",children:r.jsx(Os,{to:"/defense",children:"OPEN DEFENSE"})})]}),r.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-[11px] font-mono uppercase tracking-wider text-ops-text-muted",children:[r.jsx(ue,{variant:C?"success":"warning",size:"sm",children:C?"ON":"CHECK"}),r.jsx(ue,{variant:"chip",children:s?"RULES ...":`${n.length} RULES LOADED`}),r.jsxs(ue,{variant:"chip",children:[R," TRIGGERS / 10M"]})]})]})}),r.jsx(se,{variant:"panel",className:"opacity-0 animate-terminal-in stagger-7",children:r.jsxs(ae,{className:"p-4 pt-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(It,{className:"h-3.5 w-3.5 text-ops-warning-soft/90"}),r.jsx("span",{className:"text-[10px] font-mono uppercase tracking-[0.22em] text-ops-text-subtle",children:"Chaos"})]}),r.jsx(Q,{asChild:!0,variant:"secondary",size:"sm",className:"border-ops-line bg-ops-panel-soft text-ops-accent-soft hover:bg-ops-hover hover:text-ops-text-body",children:r.jsx(Os,{to:"/chaos",children:"OPEN CHAOS"})})]}),r.jsx("div",{className:"mt-4 flex flex-wrap items-center gap-2 text-[11px] font-mono uppercase tracking-wider text-ops-text-muted",children:x?r.jsx(ue,{variant:"chip",children:"LOADING STATUS..."}):r.jsxs(r.Fragment,{children:[r.jsx(ue,{variant:E?"danger":"success",size:"sm",dot:E,children:E?"RUNNING":"IDLE"}),r.jsxs(ue,{variant:"chip",children:["CPU ",f!=null&&f.cpuSpikeRunning?"ACTIVE":"CLEAR"]}),r.jsxs(ue,{variant:"chip",children:["MEM ",(f==null?void 0:f.memoryAllocatedMb)??0,"MB"]}),S&&r.jsxs(ue,{variant:"chip",children:["LAST ",S.path.replace("/chaos/","").toUpperCase()," ",tc(S.timestamp)]}),!S&&r.jsx(ue,{variant:"chip",className:"text-ops-text-subtle",children:"NO CHAOS COMMANDS YET"})]})})]})})]})]})}function Uy(){const{baseUrl:e}=je(),[t,n]=h.useState(!1),[s,a]=h.useState(null),o=h.useCallback(async u=>{if(e){n(!0);try{const c=await fetch(`${e}/chaos/cpu`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({duration:u})});if(!c.ok)throw new Error(`Server error: ${c.status}`);const d=await c.text();a(d)}catch(c){a(`Error: ${c instanceof Error?c.message:String(c)}`)}finally{n(!1)}}},[e]),i=h.useCallback(async(u,c="allocate")=>{if(e){n(!0);try{const d=await fetch(`${e}/chaos/memory`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:u,action:c})});if(!d.ok)throw new Error(`Server error: ${d.status}`);const f=await d.text();a(f)}catch(d){a(`Error: ${d instanceof Error?d.message:String(d)}`)}finally{n(!1)}}},[e]),l=h.useCallback(async()=>{if(e&&confirm("Are you sure you want to CRASH the backend?")){n(!0);try{const u=await fetch(`${e}/chaos/crash`,{method:"POST"});if(!u.ok)throw new Error(`Server error: ${u.status}`);a("Server crashing...")}catch(u){a(`Error: ${u instanceof Error?u.message:String(u)}`)}finally{n(!1)}}},[e]);return{triggerCpuSpike:o,triggerMemorySpike:i,triggerCrash:l,isLoading:t,result:s}}function Vy(){const{triggerCpuSpike:e,triggerMemorySpike:t,triggerCrash:n,isLoading:s,result:a}=Uy();return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Chaos Laboratory"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Inject faults to test system resilience."})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[r.jsxs(se,{variant:"panel",glow:"warning",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Pg,{className:"h-4 w-4 text-warning-500"}),"CPU Stress"]}),r.jsx(Re,{children:"Lock main thread with empty loop"})]}),r.jsx(ae,{className:"space-y-4",children:r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Q,{variant:"secondary",size:"sm",onClick:()=>e(5e3),disabled:s,children:"5s Spike"}),r.jsx(Q,{variant:"secondary",size:"sm",onClick:()=>e(15e3),disabled:s,children:"15s Spike"})]})})]}),r.jsxs(se,{variant:"panel",glow:"warning",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Ug,{className:"h-4 w-4 text-primary-500"}),"Memory Leak"]}),r.jsx(Re,{children:"Allocate Buffer chunks to heap"})]}),r.jsxs(ae,{className:"space-y-4",children:[r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Q,{variant:"secondary",size:"sm",onClick:()=>t(100),disabled:s,children:"+100 MB"}),r.jsx(Q,{variant:"secondary",size:"sm",onClick:()=>t(500),disabled:s,children:"+500 MB"})]}),r.jsx(Q,{variant:"outline",size:"sm",className:"w-full",onClick:()=>t(0,"clear"),disabled:s,children:"Clear / GC"})]})]}),r.jsxs(se,{variant:"panel",glow:"danger",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2 text-danger-400",children:[r.jsx(Zt,{className:"h-4 w-4"}),"Process Failure"]}),r.jsx(Re,{children:"Force exit the node process"})]}),r.jsx(ae,{children:r.jsx(Q,{variant:"danger",className:"w-full",onClick:n,disabled:s,children:"KILL PROCESS"})})]})]}),a&&r.jsx(se,{variant:"glass",className:"font-mono text-xs",children:r.jsxs(ae,{className:"p-4 flex justify-between items-center",children:[r.jsx("span",{children:a}),r.jsx(Q,{variant:"ghost",size:"sm",onClick:()=>location.reload(),children:"Refresh"})]})})]})}function qy(){const{rules:e,addRule:t,deleteRule:n,isLoading:s}=zd(),[a,o]=h.useState(""),[i,l]=h.useState(null),u=async c=>{if(c.preventDefault(),!!a){try{new RegExp(a)}catch{l("Invalid Regex Pattern");return}l(null),await t(a,"block"),o("")}};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Active Defense"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Configure WAF rules and traffic filtering."})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsx("div",{className:"lg:col-span-2 space-y-4",children:r.jsxs(se,{variant:"panel",glow:"primary",children:[r.jsxs(ce,{className:"flex flex-row items-center justify-between",children:[r.jsxs("div",{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Qr,{className:"h-4 w-4 text-success-500"}),"Sentinel Rules"]}),r.jsx(Re,{children:"Active regex patterns blocking requests"})]}),r.jsxs(ue,{variant:"neutral",children:[e.length," Active"]})]}),r.jsx(ae,{children:r.jsx("div",{className:"space-y-2",children:e.length===0?r.jsx("div",{className:"text-center py-8 text-neutral-500 text-sm font-mono",children:"No active rules. System is open."}):e.map(c=>r.jsxs("div",{className:"flex items-center justify-between p-3 bg-neutral-900/50 border border-neutral-800 rounded-sm group hover:border-neutral-700 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ud,{className:"h-3 w-3 text-success-500"}),r.jsx("code",{className:"text-xs font-mono text-neutral-200 bg-neutral-800 px-1.5 py-0.5 rounded",children:c.pattern})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ue,{variant:c.action==="block"?"danger":"warning",size:"sm",children:c.action}),r.jsx(Q,{variant:"ghost",size:"icon",className:"h-6 w-6 text-neutral-500 hover:text-danger-400",onClick:()=>n(c.id),children:r.jsx(wa,{className:"h-3 w-3"})})]})]},c.id))})})]})}),r.jsx("div",{children:r.jsxs(se,{variant:"glass",glow:"primary",children:[r.jsx(ce,{children:r.jsx(de,{children:"Add Block Rule"})}),r.jsxs(ae,{children:[r.jsxs("form",{onSubmit:u,className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"regex-pattern",className:"text-xs font-mono text-neutral-400",children:"Regex Pattern"}),r.jsx("input",{id:"regex-pattern",type:"text",value:a,onChange:c=>{o(c.target.value),i&&l(null)},placeholder:"e.g. \\/admin|drop tables",className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500"}),i&&r.jsx("span",{className:"text-xs text-danger-500 mt-1 block",children:i})]}),r.jsxs(Q,{type:"submit",variant:"primary",className:"w-full",disabled:s||!a,children:[r.jsx(Vs,{className:"h-4 w-4"}),"Deploy Rule"]})]}),r.jsxs("div",{className:"mt-6 pt-6 border-t border-neutral-800",children:[r.jsx("h4",{className:"text-xs font-mono text-neutral-400 mb-3",children:"Quick Presets"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(Q,{variant:"secondary",size:"sm",className:"w-full justify-start font-mono text-xs",onClick:()=>t("(?i)(union|select|insert|delete|update)","block"),children:"SQL Injection"}),r.jsx(Q,{variant:"secondary",size:"sm",className:"w-full justify-start font-mono text-xs",onClick:()=>t("<script>|javascript:","block"),children:"XSS Vectors"}),r.jsx(Q,{variant:"secondary",size:"sm",className:"w-full justify-start font-mono text-xs",onClick:()=>t("/(.git|.env|config)","block"),children:"Sensitive Files"})]})]})]})]})})]})]})}function Wy(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState([]),[o,i]=h.useState(!1),l=h.useCallback(async()=>{if(e)try{const x=await fetch(`${e}/deception/history`);if(!x.ok)throw new Error("Failed to fetch deception history");const g=await x.json();n(g.events||[])}catch(x){console.error(x)}},[e]),u=h.useCallback(async()=>{if(e)try{const x=await fetch(`${e}/tarpit`);if(!x.ok)throw new Error("Failed to fetch tarpit status");const g=await x.json();a(g.trapped||[])}catch(x){console.error(x)}},[e]),c=h.useCallback(async x=>{if(e)try{await fetch(`${e}/tarpit/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip:x})}),await u()}catch(g){console.error(g)}},[e,u]),d=h.useCallback(async()=>{if(e)try{await fetch(`${e}/deception/history`,{method:"DELETE"}),n([])}catch(x){console.error(x)}},[e]),{subscribe:f,status:p}=ts(`${e}/sse`,{enabled:!!e});return h.useEffect(()=>{if(p!=="connected")return;const x=f("deception",m=>{n(y=>[m,...y].slice(0,100))}),g=f("tarpit",()=>{u()});return()=>{x(),g()}},[p,f,u]),h.useEffect(()=>{i(!0),Promise.all([l(),u()]).finally(()=>i(!1))},[l,u]),{events:t,trappedIps:s,releaseIp:c,clearHistory:d,refresh:()=>Promise.all([l(),u()]),isLoading:o,isConnected:p==="connected"}}const Gy="https://gchq.github.io/CyberChef/";function Ky(e){const t=typeof e=="string"?e:JSON.stringify(e,null,2);return btoa(unescape(encodeURIComponent(t)))}function Yy(e,t=[]){const n=new URLSearchParams;let s="";return e==null?s="":typeof e=="string"?s=e:s=JSON.stringify(e,null,2),s&&n.set("input",Ky(s)),t.length>0&&n.set("recipe",JSON.stringify(t)),`${Gy}#${n.toString()}`}function ns(e,t=[]){if(!confirm(`⚠️ Privacy Warning
|
|
504
|
+
|
|
505
|
+
You are about to send this data to a public CyberChef instance (gchq.github.io). Do not proceed if this payload contains sensitive secrets, PII, or real credentials.
|
|
506
|
+
|
|
507
|
+
Continue analysis?`))return;const n=Yy(e,t);window.open(n,"_blank","noopener,noreferrer")}function Xy(){const{events:e,trappedIps:t,releaseIp:n,clearHistory:s,isConnected:a}=Wy(),[o,i]=h.useState(null),l=()=>{confirm("Are you sure you want to clear all deception logs? This action cannot be undone.")&&s()},u=(c,d)=>`${c.timestamp}-${c.ip}-${d}`;return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{className:"flex justify-between items-end",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Deception Engine"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Live honeypot activity and intruder analysis."})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(ue,{variant:a?"success":"neutral",dot:!0,children:a?"FORENSICS_LIVE":"OFFLINE"}),r.jsxs(Q,{variant:"ghost",size:"sm",className:"text-neutral-500 hover:text-danger-400",onClick:l,children:[r.jsx(wa,{className:"h-3 w-3 mr-2"}),"Clear Logs"]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsx("div",{className:"lg:col-span-2 space-y-4",children:r.jsxs(se,{variant:"panel",glow:"warning",className:"flex flex-col h-[600px]",children:[r.jsx(ce,{className:"flex-none border-b border-neutral-800 pb-4",children:r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Si,{className:"h-4 w-4 text-primary-500"}),"Capture Feed"]}),r.jsxs("span",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-widest",children:[e.length," Events Recorded"]})]})}),r.jsx(ae,{className:"flex-1 overflow-y-auto p-0 font-mono text-xs",children:e.length===0?r.jsx("div",{className:"h-full flex items-center justify-center text-neutral-600 italic",children:"[WAITING_FOR_INTERCEPTION]"}):r.jsx("div",{className:"divide-y divide-neutral-800/50",children:e.map((c,d)=>{const f=o&&o.timestamp===c.timestamp&&o.ip===c.ip&&o.type===c.type;return r.jsxs("button",{onClick:()=>i(c),"aria-label":`Event: ${c.type} from ${c.ip} at ${c.route}`,className:X("w-full text-left p-3 transition-colors flex items-center gap-4 group border-l-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",f?"border-primary bg-primary/[0.08]":c.type==="shell_command"?"border-warning/20 bg-warning/[0.03] hover:bg-warning/[0.06]":c.type==="sqli_probe"?"border-danger/20 bg-danger/[0.03] hover:bg-danger/[0.06]":"border-transparent hover:bg-neutral-900/50"),children:[r.jsx("div",{className:"text-neutral-500 text-[10px] w-16 tabular-nums font-bold",children:new Date(c.timestamp).toLocaleTimeString([],{hour12:!1})}),r.jsx("div",{className:"w-24 overflow-hidden",children:r.jsx(ue,{variant:c.type==="shell_command"?"warning":c.type==="sqli_probe"?"danger":"primary",size:"sm",children:c.type.replace("_"," ")})}),r.jsxs("div",{className:"flex-1 truncate",children:[r.jsx("span",{className:X("font-bold mr-2",f?"text-primary":"text-neutral-300"),children:c.ip}),r.jsx("span",{className:"text-neutral-600 font-medium",children:"@"}),r.jsx("span",{className:"text-neutral-400 ml-2 italic",children:c.route})]}),r.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity pr-2",children:r.jsx($g,{className:"h-3 w-3 text-primary/60"})})]},u(c,d))})})})]})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(se,{variant:"panel",glow:"danger",className:"border-danger-900/30",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2 text-danger-400",children:[r.jsx(Fe,{className:"h-4 w-4"}),"Tarpit Monitor"]}),r.jsx(Re,{children:"IPs currently trapped in slow-responses."})]}),r.jsx(ae,{className:"max-h-48 overflow-y-auto space-y-2",children:t.length===0?r.jsx("div",{className:"text-center py-4 text-neutral-600 text-xs font-mono border border-dashed border-neutral-800 rounded-sm",children:"NO ACTIVE THREATS"}):t.map(c=>r.jsxs("div",{className:"flex items-center justify-between p-2 bg-danger-900/10 border border-danger-900/20 rounded-sm",children:[r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:"text-xs font-mono font-bold text-neutral-200",children:c.ip}),r.jsxs("span",{className:"text-[10px] font-mono text-danger-500 uppercase",children:["Trapped ",c.duration,"s ago"]})]}),r.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 text-neutral-400 hover:text-success-400",onClick:()=>n(c.ip),children:r.jsx(Qg,{className:"h-3 w-3"})})]},c.ip))}),t.length>0&&r.jsx(Ld,{className:"pt-2",children:r.jsx(Q,{variant:"outline",size:"sm",className:"w-full text-[10px]",onClick:()=>n(),children:"RELEASE ALL"})})]}),r.jsxs(se,{variant:"glass",glow:"warning",className:"flex flex-col min-h-[300px]",children:[r.jsx(ce,{className:"border-b border-white/5 pb-3",children:r.jsx(de,{className:"text-xs",children:"Event Inspector"})}),r.jsx(ae,{className:"flex-1 p-0 flex flex-col",children:o?r.jsxs("div",{className:"flex-1 flex flex-col",children:[r.jsxs("div",{className:"p-4 bg-black/40 font-mono text-[10px] space-y-2",children:[r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-neutral-500",children:"ORIGIN_IP"}),r.jsx("span",{className:"text-primary-400",children:o.ip})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-neutral-500",children:"TIMESTAMP"}),r.jsx("span",{className:"text-neutral-300",children:o.timestamp})]}),r.jsxs("div",{className:"flex justify-between",children:[r.jsx("span",{className:"text-neutral-500",children:"SESSION_ID"}),r.jsx("span",{className:"text-neutral-300 truncate ml-4",children:o.sessionId||"N/A"})]})]}),r.jsxs("div",{className:"flex-1 p-4 font-mono text-[11px]",children:[r.jsx("span",{className:"text-neutral-500 block mb-2 uppercase tracking-tighter border-b border-white/5 pb-1",children:"Payload / Details"}),r.jsxs("pre",{className:"text-neutral-300 whitespace-pre-wrap break-all bg-black/20 p-2 rounded-sm border border-white/5 max-h-64 overflow-y-auto",children:[JSON.stringify(o.details,null,2).slice(0,1e4),JSON.stringify(o.details).length>1e4&&`
|
|
508
|
+
...[TRUNCATED]...`]})]}),r.jsxs("div",{className:"p-4 mt-auto border-t border-white/5 space-y-2",children:[r.jsxs(Q,{variant:"outline",size:"sm",className:"w-full text-primary-400 border-primary-500/20 hover:bg-primary-500/5 group",onClick:()=>o.details&&ns(o.details),children:[r.jsx(Zr,{className:"h-3 w-3 mr-2"}),"Analyze in CyberChef",r.jsx(Ao,{className:"h-3 w-3 ml-auto opacity-50 group-hover:translate-x-0.5 group-hover:-translate-y-0.5 transition-transform"})]}),o.type==="shell_command"&&r.jsxs(Q,{variant:"neon",size:"sm",className:"w-full group",onClick:()=>window.open("/console","_blank","noopener"),children:[r.jsx(_i,{className:"h-3 w-3"}),"Intervene in Session",r.jsx(Ao,{className:"h-3 w-3 ml-auto opacity-50 group-hover:translate-x-0.5 group-hover:-translate-y-0.5 transition-transform"})]})]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-600 text-xs font-mono uppercase",children:"Select an event to inspect"})})]})]})]})]})}function Zy(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState(!1),[o,i]=h.useState(!1),l=h.useRef(null);h.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const u=h.useCallback(async()=>{if(e)try{const d=await fetch(`${e}/cluster/members`);if(!d.ok)throw new Error(d.statusText);const f=await d.json();Array.isArray(f)&&n(f)}catch(d){console.error("Failed to fetch cluster nodes",d)}},[e]),c=h.useCallback(async(d,f)=>{if(e){a(!0),i(!0);try{const p=await fetch(`${e}/cluster/attack`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:d,rate:f})});if(!p.ok)throw new Error(p.statusText);l.current&&clearTimeout(l.current),l.current=setTimeout(()=>i(!1),3e4)}catch(p){console.error("Failed to trigger attack",p),i(!1)}finally{a(!1)}}},[e]);return h.useEffect(()=>{u();const d=setInterval(u,5e3);return()=>clearInterval(d)},[u]),{nodes:t,triggerAttack:c,isLoading:s,isAttacking:o}}const yr={NODE_RADIUS:6,CENTER_RADIUS:12,ROTATION_SPEED:.002,IDLE_FPS:10,ACTIVE_FPS:60};function Jy({nodes:e,isAttacking:t}){const n=h.useRef(null),s=h.useRef(e),a=h.useRef(t),o=h.useRef([]);return h.useEffect(()=>{s.current=e,o.current=e.filter(i=>i.role!=="self")},[e]),h.useEffect(()=>{a.current=t},[t]),h.useEffect(()=>{const i=n.current;if(!i)return;const l=i.getContext("2d");if(!l)return;const u=window.devicePixelRatio||1,c=window.matchMedia("(prefers-reduced-motion: reduce)").matches,d=()=>{if(i.parentElement){const m=i.parentElement.clientWidth,y=i.parentElement.clientHeight;i.style.width=`${m}px`,i.style.height=`${y}px`,i.width=m*u,i.height=y*u,l.setTransform(u,0,0,u,0,0)}};window.addEventListener("resize",d),d();let f,p=0,x=0;const g=m=>{if(document.hidden){f=requestAnimationFrame(g);return}const y=a.current,v=1e3/(y&&!c?yr.ACTIVE_FPS:yr.IDLE_FPS);if(m-x<v){f=requestAnimationFrame(g);return}if(x=m,!i.parentElement){f=requestAnimationFrame(g);return}const N=i.parentElement.clientWidth,w=i.parentElement.clientHeight,j=N/2,k=w/2,_=o.current;l.clearRect(0,0,N,w);const P=Math.min(N,w)/3,T=y&&!c?Math.sin(m/500)*.5+.5:0,$=y?`rgba(0, 240, 255, ${.2+T*.3})`:"rgba(31, 38, 51, 0.5)";l.font="10px JetBrains Mono",l.textAlign="left",l.textBaseline="middle",_.forEach((B,D)=>{const R=_.length||1,S=D/R*Math.PI*2+p,C=j+Math.cos(S)*P,E=k+Math.sin(S)*P;l.beginPath(),l.moveTo(j,k),l.lineTo(C,E),l.strokeStyle=$,l.lineWidth=y?2:1,l.stroke()}),y&&!c?(l.shadowBlur=15,l.shadowColor="#00A3FF"):l.shadowBlur=0,_.forEach((B,D)=>{const R=_.length||1,S=D/R*Math.PI*2+p,C=j+Math.cos(S)*P,E=k+Math.sin(S)*P;l.fillStyle=y?"#00A3FF":"#00B140",l.beginPath(),l.arc(C,E,yr.NODE_RADIUS,0,Math.PI*2),l.fill()}),l.shadowBlur=0,l.fillStyle="#9BA9BF",_.forEach((B,D)=>{const R=_.length||1,S=D/R*Math.PI*2+p,C=j+Math.cos(S)*P,E=k+Math.sin(S)*P;l.fillText(B.ip,C+10,E+3)}),l.fillStyle="#FFFFFF",y&&!c&&(l.shadowColor="#FFFFFF",l.shadowBlur=20),l.beginPath(),l.arc(j,k,yr.CENTER_RADIUS,0,Math.PI*2),l.fill(),l.shadowBlur=0,y&&(l.strokeStyle="#00F0FF",l.lineWidth=2,l.beginPath(),l.arc(j,k,P+40,0,Math.PI*2),l.setLineDash([5,5]),l.stroke(),l.setLineDash([])),c||(p=(p+yr.ROTATION_SPEED)%(Math.PI*2)),f=requestAnimationFrame(g)};return f=requestAnimationFrame(g),()=>{window.removeEventListener("resize",d),cancelAnimationFrame(f)}},[]),r.jsxs("div",{className:"relative w-full h-full",children:[r.jsx("canvas",{ref:n,className:"w-full h-full block",role:"img","aria-label":"Cluster visualization"}),r.jsxs("span",{className:"sr-only",role:"status","aria-live":"polite",children:["Cluster status: ",t?"Load Test Running":"Idle",". ",e.length," nodes connected."]})]})}function Ks(e,[t,n]){return Math.min(n,Math.max(t,e))}function Se(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e==null||e(a),n===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function Qy(e,t){const n=h.createContext(t),s=o=>{const{children:i,...l}=o,u=h.useMemo(()=>l,Object.values(l));return r.jsx(n.Provider,{value:u,children:i})};s.displayName=e+"Provider";function a(o){const i=h.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return[s,a]}function rs(e,t=[]){let n=[];function s(o,i){const l=h.createContext(i),u=n.length;n=[...n,i];const c=f=>{var b;const{scope:p,children:x,...g}=f,m=((b=p==null?void 0:p[e])==null?void 0:b[u])||l,y=h.useMemo(()=>g,Object.values(g));return r.jsx(m.Provider,{value:y,children:x})};c.displayName=o+"Provider";function d(f,p){var m;const x=((m=p==null?void 0:p[e])==null?void 0:m[u])||l,g=h.useContext(x);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${f}\` must be used within \`${o}\``)}return[c,d]}const a=()=>{const o=n.map(i=>h.createContext(i));return function(l){const u=(l==null?void 0:l[e])||o;return h.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return a.scopeName=e,[s,eb(a,...t)]}function eb(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(o){const i=s.reduce((l,{useScope:u,scopeName:c})=>{const f=u(o)[`__scope${c}`];return{...l,...f}},{});return h.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Ue=globalThis!=null&&globalThis.document?h.useLayoutEffect:()=>{},tb=bi[" useInsertionEffect ".trim().toString()]||Ue;function Ys({prop:e,defaultProp:t,onChange:n=()=>{},caller:s}){const[a,o,i]=nb({defaultProp:t,onChange:n}),l=e!==void 0,u=l?e:a;{const d=h.useRef(e!==void 0);h.useEffect(()=>{const f=d.current;f!==l&&console.warn(`${s} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=l},[l,s])}const c=h.useCallback(d=>{var f;if(l){const p=rb(d)?d(e):d;p!==e&&((f=i.current)==null||f.call(i,p))}else o(d)},[l,e,o,i]);return[u,c]}function nb({defaultProp:e,onChange:t}){const[n,s]=h.useState(e),a=h.useRef(n),o=h.useRef(t);return tb(()=>{o.current=t},[t]),h.useEffect(()=>{var i;a.current!==n&&((i=o.current)==null||i.call(o,n),a.current=n)},[n,a]),[n,s,o]}function rb(e){return typeof e=="function"}var sb=h.createContext(void 0);function Ud(e){const t=h.useContext(sb);return e||t||"ltr"}function Vd(e){const t=h.useRef({value:e,previous:e});return h.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function qd(e){const[t,n]=h.useState(void 0);return Ue(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const o=a[0];let i,l;if("borderBoxSize"in o){const u=o.borderBoxSize,c=Array.isArray(u)?u[0]:u;i=c.inlineSize,l=c.blockSize}else i=e.offsetWidth,l=e.offsetHeight;n({width:i,height:l})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else n(void 0)},[e]),t}function Dr(e){const t=ab(e),n=h.forwardRef((s,a)=>{const{children:o,...i}=s,l=h.Children.toArray(o),u=l.find(ib);if(u){const c=u.props.children,d=l.map(f=>f===u?h.Children.count(c)>1?h.Children.only(null):h.isValidElement(c)?c.props.children:null:f);return r.jsx(t,{...i,ref:a,children:h.isValidElement(c)?h.cloneElement(c,void 0,d):null})}return r.jsx(t,{...i,ref:a,children:o})});return n.displayName=`${e}.Slot`,n}function ab(e){const t=h.forwardRef((n,s)=>{const{children:a,...o}=n;if(h.isValidElement(a)){const i=cb(a),l=lb(o,a.props);return a.type!==h.Fragment&&(l.ref=s?Qt(s,i):i),h.cloneElement(a,l)}return h.Children.count(a)>1?h.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ob=Symbol("radix.slottable");function ib(e){return h.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ob}function lb(e,t){const n={...t};for(const s in t){const a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?n[s]=(...l)=>{const u=o(...l);return a(...l),u}:a&&(n[s]=a):s==="style"?n[s]={...a,...o}:s==="className"&&(n[s]=[a,o].filter(Boolean).join(" "))}return{...e,...n}}function cb(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ub=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ke=ub.reduce((e,t)=>{const n=Dr(`Primitive.${t}`),s=h.forwardRef((a,o)=>{const{asChild:i,...l}=a,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...l,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function db(e,t){e&&ir.flushSync(()=>e.dispatchEvent(t))}function Wd(e){const t=e+"CollectionProvider",[n,s]=rs(t),[a,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=m=>{const{scope:y,children:b}=m,v=q.useRef(null),N=q.useRef(new Map).current;return r.jsx(a,{scope:y,itemMap:N,collectionRef:v,children:b})};i.displayName=t;const l=e+"CollectionSlot",u=Dr(l),c=q.forwardRef((m,y)=>{const{scope:b,children:v}=m,N=o(l,b),w=Me(y,N.collectionRef);return r.jsx(u,{ref:w,children:v})});c.displayName=l;const d=e+"CollectionItemSlot",f="data-radix-collection-item",p=Dr(d),x=q.forwardRef((m,y)=>{const{scope:b,children:v,...N}=m,w=q.useRef(null),j=Me(y,w),k=o(d,b);return q.useEffect(()=>(k.itemMap.set(w,{ref:w,...N}),()=>void k.itemMap.delete(w))),r.jsx(p,{[f]:"",ref:j,children:v})});x.displayName=d;function g(m){const y=o(e+"CollectionConsumer",m);return q.useCallback(()=>{const v=y.collectionRef.current;if(!v)return[];const N=Array.from(v.querySelectorAll(`[${f}]`));return Array.from(y.itemMap.values()).sort((k,_)=>N.indexOf(k.ref.current)-N.indexOf(_.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:x},g,s]}var Gd=["PageUp","PageDown"],Kd=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Yd={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ur="Slider",[Lo,hb,fb]=Wd(ur),[Xd]=rs(ur,[fb]),[pb,Na]=Xd(ur),Zd=h.forwardRef((e,t)=>{const{name:n,min:s=0,max:a=100,step:o=1,orientation:i="horizontal",disabled:l=!1,minStepsBetweenThumbs:u=0,defaultValue:c=[s],value:d,onValueChange:f=()=>{},onValueCommit:p=()=>{},inverted:x=!1,form:g,...m}=e,y=h.useRef(new Set),b=h.useRef(0),N=i==="horizontal"?mb:xb,[w=[],j]=Ys({prop:d,defaultProp:c,onChange:B=>{var R;(R=[...y.current][b.current])==null||R.focus(),f(B)}}),k=h.useRef(w);function _(B){const D=wb(w,B);$(B,D)}function P(B){$(B,b.current)}function T(){const B=k.current[b.current];w[b.current]!==B&&p(w)}function $(B,D,{commit:R}={commit:!1}){const S=kb(o),C=Eb(Math.round((B-s)/o)*o+s,S),E=Ks(C,[s,a]);j((A=[])=>{const O=bb(A,E,D);if(jb(O,u*o)){b.current=O.indexOf(E);const I=String(O)!==String(A);return I&&R&&p(O),I?O:A}else return A})}return r.jsx(pb,{scope:e.__scopeSlider,name:n,disabled:l,min:s,max:a,valueIndexToChangeRef:b,thumbs:y.current,values:w,orientation:i,form:g,children:r.jsx(Lo.Provider,{scope:e.__scopeSlider,children:r.jsx(Lo.Slot,{scope:e.__scopeSlider,children:r.jsx(N,{"aria-disabled":l,"data-disabled":l?"":void 0,...m,ref:t,onPointerDown:Se(m.onPointerDown,()=>{l||(k.current=w)}),min:s,max:a,inverted:x,onSlideStart:l?void 0:_,onSlideMove:l?void 0:P,onSlideEnd:l?void 0:T,onHomeKeyDown:()=>!l&&$(s,0,{commit:!0}),onEndKeyDown:()=>!l&&$(a,w.length-1,{commit:!0}),onStepKeyDown:({event:B,direction:D})=>{if(!l){const C=Gd.includes(B.key)||B.shiftKey&&Kd.includes(B.key)?10:1,E=b.current,A=w[E],O=o*C*D;$(A+O,E,{commit:!0})}}})})})})});Zd.displayName=ur;var[Jd,Qd]=Xd(ur,{startEdge:"left",endEdge:"right",size:"width",direction:1}),mb=h.forwardRef((e,t)=>{const{min:n,max:s,dir:a,inverted:o,onSlideStart:i,onSlideMove:l,onSlideEnd:u,onStepKeyDown:c,...d}=e,[f,p]=h.useState(null),x=Me(t,N=>p(N)),g=h.useRef(void 0),m=Ud(a),y=m==="ltr",b=y&&!o||!y&&o;function v(N){const w=g.current||f.getBoundingClientRect(),j=[0,w.width],_=Pi(j,b?[n,s]:[s,n]);return g.current=w,_(N-w.left)}return r.jsx(Jd,{scope:e.__scopeSlider,startEdge:b?"left":"right",endEdge:b?"right":"left",direction:b?1:-1,size:"width",children:r.jsx(eh,{dir:m,"data-orientation":"horizontal",...d,ref:x,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:N=>{const w=v(N.clientX);i==null||i(w)},onSlideMove:N=>{const w=v(N.clientX);l==null||l(w)},onSlideEnd:()=>{g.current=void 0,u==null||u()},onStepKeyDown:N=>{const j=Yd[b?"from-left":"from-right"].includes(N.key);c==null||c({event:N,direction:j?-1:1})}})})}),xb=h.forwardRef((e,t)=>{const{min:n,max:s,inverted:a,onSlideStart:o,onSlideMove:i,onSlideEnd:l,onStepKeyDown:u,...c}=e,d=h.useRef(null),f=Me(t,d),p=h.useRef(void 0),x=!a;function g(m){const y=p.current||d.current.getBoundingClientRect(),b=[0,y.height],N=Pi(b,x?[s,n]:[n,s]);return p.current=y,N(m-y.top)}return r.jsx(Jd,{scope:e.__scopeSlider,startEdge:x?"bottom":"top",endEdge:x?"top":"bottom",size:"height",direction:x?1:-1,children:r.jsx(eh,{"data-orientation":"vertical",...c,ref:f,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:m=>{const y=g(m.clientY);o==null||o(y)},onSlideMove:m=>{const y=g(m.clientY);i==null||i(y)},onSlideEnd:()=>{p.current=void 0,l==null||l()},onStepKeyDown:m=>{const b=Yd[x?"from-bottom":"from-top"].includes(m.key);u==null||u({event:m,direction:b?-1:1})}})})}),eh=h.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:s,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:i,onEndKeyDown:l,onStepKeyDown:u,...c}=e,d=Na(ur,n);return r.jsx(ke.span,{...c,ref:t,onKeyDown:Se(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(l(f),f.preventDefault()):Gd.concat(Kd).includes(f.key)&&(u(f),f.preventDefault())}),onPointerDown:Se(e.onPointerDown,f=>{const p=f.target;p.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(p)?p.focus():s(f)}),onPointerMove:Se(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Se(e.onPointerUp,f=>{const p=f.target;p.hasPointerCapture(f.pointerId)&&(p.releasePointerCapture(f.pointerId),o(f))})})}),th="SliderTrack",nh=h.forwardRef((e,t)=>{const{__scopeSlider:n,...s}=e,a=Na(th,n);return r.jsx(ke.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:t})});nh.displayName=th;var Do="SliderRange",rh=h.forwardRef((e,t)=>{const{__scopeSlider:n,...s}=e,a=Na(Do,n),o=Qd(Do,n),i=h.useRef(null),l=Me(t,i),u=a.values.length,c=a.values.map(p=>oh(p,a.min,a.max)),d=u>1?Math.min(...c):0,f=100-Math.max(...c);return r.jsx(ke.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:l,style:{...e.style,[o.startEdge]:d+"%",[o.endEdge]:f+"%"}})});rh.displayName=Do;var $o="SliderThumb",sh=h.forwardRef((e,t)=>{const n=hb(e.__scopeSlider),[s,a]=h.useState(null),o=Me(t,l=>a(l)),i=h.useMemo(()=>s?n().findIndex(l=>l.ref.current===s):-1,[n,s]);return r.jsx(gb,{...e,ref:o,index:i})}),gb=h.forwardRef((e,t)=>{const{__scopeSlider:n,index:s,name:a,...o}=e,i=Na($o,n),l=Qd($o,n),[u,c]=h.useState(null),d=Me(t,v=>c(v)),f=u?i.form||!!u.closest("form"):!0,p=qd(u),x=i.values[s],g=x===void 0?0:oh(x,i.min,i.max),m=vb(s,i.values.length),y=p==null?void 0:p[l.size],b=y?Nb(y,g,l.direction):0;return h.useEffect(()=>{if(u)return i.thumbs.add(u),()=>{i.thumbs.delete(u)}},[u,i.thumbs]),r.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[l.startEdge]:`calc(${g}% + ${b}px)`},children:[r.jsx(Lo.ItemSlot,{scope:e.__scopeSlider,children:r.jsx(ke.span,{role:"slider","aria-label":e["aria-label"]||m,"aria-valuemin":i.min,"aria-valuenow":x,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...o,ref:d,style:x===void 0?{display:"none"}:e.style,onFocus:Se(e.onFocus,()=>{i.valueIndexToChangeRef.current=s})})}),f&&r.jsx(ah,{name:a??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:x},s)]})});sh.displayName=$o;var yb="RadioBubbleInput",ah=h.forwardRef(({__scopeSlider:e,value:t,...n},s)=>{const a=h.useRef(null),o=Me(a,s),i=Vd(t);return h.useEffect(()=>{const l=a.current;if(!l)return;const u=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(u,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(l,t),l.dispatchEvent(f)}},[i,t]),r.jsx(ke.input,{style:{display:"none"},...n,ref:o,defaultValue:t})});ah.displayName=yb;function bb(e=[],t,n){const s=[...e];return s[n]=t,s.sort((a,o)=>a-o)}function oh(e,t,n){const o=100/(n-t)*(e-t);return Ks(o,[0,100])}function vb(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function wb(e,t){if(e.length===1)return 0;const n=e.map(a=>Math.abs(a-t)),s=Math.min(...n);return n.indexOf(s)}function Nb(e,t,n){const s=e/2,o=Pi([0,50],[0,s]);return(s-o(t)*n)*n}function Sb(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function jb(e,t){if(t>0){const n=Sb(e);return Math.min(...n)>=t}return!0}function Pi(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(n-e[0])}}function kb(e){return(String(e).split(".")[1]||"").length}function Eb(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var ih=Zd,_b=nh,Cb=rh,Tb=sh;const Hn=h.forwardRef(({className:e,...t},n)=>r.jsxs(ih,{ref:n,className:X("relative flex w-full touch-none select-none items-center",e),...t,children:[r.jsx(_b,{className:"relative h-2 w-full grow overflow-hidden rounded-full border border-[#26364f] bg-[#0f1828] shadow-[inset_0_1px_2px_rgba(0,0,0,0.55)]",children:r.jsx(Cb,{className:"absolute h-full rounded-full bg-[linear-gradient(90deg,#1f8dff_0%,#43c0ff_100%)] shadow-[0_0_8px_rgba(56,160,255,0.45)]"})}),r.jsx(Tb,{className:"block h-4 w-4 rounded-full border border-[#7fc2ff] bg-[#d9ecff] shadow-[0_0_10px_rgba(56,160,255,0.6)] transition-colors hover:bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#43c0ff] disabled:pointer-events-none disabled:opacity-50"})]}));Hn.displayName=ih.displayName;const Rb=e=>!!(e==="localhost"||e==="127.0.0.1"||e==="::1"||/^10\./.test(e)||/^192\.168\./.test(e)||/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(e));function Ab(){const{nodes:e,triggerAttack:t,isLoading:n,isAttacking:s}=Zy(),[a,o]=h.useState("http://example.com"),[i,l]=h.useState(10),u=h.useMemo(()=>e.length!==1?e:[...e,{ip:"10.0.0.2",role:"peer",status:"active",lastSeen:Date.now()},{ip:"10.0.0.3",role:"peer",status:"active",lastSeen:Date.now()},{ip:"10.0.0.4",role:"peer",status:"active",lastSeen:Date.now()},{ip:"10.0.0.5",role:"peer",status:"active",lastSeen:Date.now()}],[e]),c=d=>{d.preventDefault();try{const f=new URL(a);if(Rb(f.hostname)){alert("Safety Block: Targeting localhost or private IP ranges is restricted in the dashboard.");return}}catch{}confirm(`Confirm Distributed Load Test?
|
|
509
|
+
|
|
510
|
+
Target: ${a}
|
|
511
|
+
Rate: ${i} req/s/node
|
|
512
|
+
|
|
513
|
+
Ensure authorization before proceeding.`)&&t(a,i)};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{className:"flex justify-between items-end",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Cluster Operations"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2 type-body",children:"Distributed command & control network."})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex flex-col items-end",children:[r.jsx("span",{className:"text-[10px] type-tag text-neutral-500 uppercase",children:"Active Nodes"}),r.jsxs("span",{className:"text-xl type-metric text-primary-400",children:[e.length," NODES"]})]}),r.jsx("div",{className:"h-8 w-px bg-neutral-800"}),r.jsxs("div",{className:"flex flex-col items-end",children:[r.jsx("span",{className:"text-[10px] type-tag text-neutral-500 uppercase",children:"Status"}),r.jsx(ue,{variant:s?"warning":"success",dot:!0,children:s?"RUNNING":"IDLE"})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsx("div",{className:"lg:col-span-2",children:r.jsxs(se,{variant:"panel",glow:"info",className:"h-[500px] flex flex-col",children:[r.jsx(ce,{className:"flex-none border-b border-neutral-800 pb-2 mb-0",children:r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(ba,{className:"h-4 w-4 text-info-500"}),"Network Topology"]})}),r.jsxs("div",{className:"flex-1 relative bg-neutral-950 overflow-hidden",children:[r.jsx("div",{className:"absolute inset-0 opacity-20",style:{backgroundImage:"radial-gradient(#1f2633 1px, transparent 1px)",backgroundSize:"20px 20px"}}),r.jsx(Jy,{nodes:u,isAttacking:s})]})]})}),r.jsxs("div",{className:"space-y-6",children:[r.jsxs(se,{variant:"glass",glow:"primary",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(dt,{className:"h-4 w-4 text-primary-500"}),"Test Configuration"]}),r.jsx(Re,{children:"Configure distributed load test parameters."})]}),r.jsx(ae,{children:r.jsxs("form",{onSubmit:c,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"target-url",className:"text-xs font-mono text-neutral-400 uppercase",children:"Target Endpoint"}),r.jsx("input",{id:"target-url",type:"url",value:a,onChange:d=>o(d.target.value),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500 transition-colors",required:!0})]}),r.jsxs("div",{children:[r.jsxs("label",{htmlFor:"attack-rate",className:"text-xs font-mono text-neutral-400 uppercase flex justify-between mb-2",children:[r.jsx("span",{children:"Requests Per Node / sec"}),r.jsxs("span",{className:"text-primary-400",children:[i," RPS"]})]}),r.jsx(Hn,{id:"attack-rate",min:1,max:100,step:1,value:[i],onValueChange:d=>l(d[0]),"aria-label":"Requests per node per second"})]}),r.jsx("div",{className:"pt-4",children:r.jsx(Q,{type:"submit",variant:s?"secondary":"default",className:"w-full h-12 text-sm tracking-widest relative overflow-hidden group",disabled:n||s,children:s?r.jsxs(r.Fragment,{children:[r.jsx(It,{className:"h-4 w-4 mr-2 animate-pulse text-warning-500"}),"TEST RUNNING..."]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(45deg,transparent_25%,rgba(255,255,255,0.1)_50%,transparent_75%)] bg-[length:250%_250%,100%_100%] bg-[position:-100%_0,0_0] bg-no-repeat transition-[background-position_0s] duration-0 group-hover:bg-[position:200%_0,0_0] group-hover:duration-[1500ms]"}),r.jsx(It,{className:"h-4 w-4 mr-2"}),"START LOAD TEST"]})})})]})})]}),r.jsxs(se,{variant:"panel",className:"flex flex-col min-h-0",children:[r.jsx(ce,{className:"flex-none pb-2",children:r.jsx(de,{className:"text-xs uppercase tracking-widest text-neutral-500",children:"Node Cluster Status"})}),r.jsx(ae,{className:"flex-1 overflow-y-auto p-0 min-h-0",children:r.jsx("div",{className:"divide-y divide-neutral-800/50",children:u.map((d,f)=>{const p=d.status==="dead";return r.jsxs("div",{className:X("flex items-center justify-between p-3 transition-colors",p?"bg-danger/5":"hover:bg-neutral-900/30"),children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:X("w-2 h-2 rounded-full",p?"bg-danger shadow-[0_0_8px_rgba(225,29,72,0.6)]":d.role==="self"?"bg-primary shadow-[0_0_8px_rgba(0,196,167,0.6)]":"bg-success shadow-[0_0_8px_rgba(0,255,148,0.4)]")}),r.jsxs("div",{className:"flex flex-col",children:[r.jsx("span",{className:X("text-xs font-mono",p?"text-danger font-bold":"text-neutral-300"),children:d.ip}),r.jsx("span",{className:"text-[10px] text-neutral-500 uppercase",children:d.role})]})]}),p?r.jsx(ue,{variant:"danger",size:"sm",dot:!0,children:"DOWN"}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("span",{className:"text-[10px] font-mono text-neutral-600",children:[Math.floor(Math.random()*50)+10,"ms"]}),r.jsx(md,{className:X("h-3.5 w-3.5",s?"text-primary animate-pulse":"text-neutral-600")})]})]},d.ip+f)})})})]})]})]})]})}const Oi=h.forwardRef(({className:e,type:t,...n},s)=>r.jsx("input",{type:t,className:X("flex h-9 w-full rounded-sm border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",Ne("data"),e),ref:s,...n}));Oi.displayName="Input";function vn(e){const t=h.useRef(e);return h.useEffect(()=>{t.current=e}),h.useMemo(()=>(...n)=>{var s;return(s=t.current)==null?void 0:s.call(t,...n)},[])}function Mb(e,t=globalThis==null?void 0:globalThis.document){const n=vn(e);h.useEffect(()=>{const s=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[n,t])}var Ib="DismissableLayer",zo="dismissableLayer.update",Pb="dismissableLayer.pointerDownOutside",Ob="dismissableLayer.focusOutside",rc,lh=h.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Li=h.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:i,onDismiss:l,...u}=e,c=h.useContext(lh),[d,f]=h.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=h.useState({}),g=Me(t,_=>f(_)),m=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=m.indexOf(y),v=d?m.indexOf(d):-1,N=c.layersWithOutsidePointerEventsDisabled.size>0,w=v>=b,j=$b(_=>{const P=_.target,T=[...c.branches].some($=>$.contains(P));!w||T||(a==null||a(_),i==null||i(_),_.defaultPrevented||l==null||l())},p),k=zb(_=>{const P=_.target;[...c.branches].some($=>$.contains(P))||(o==null||o(_),i==null||i(_),_.defaultPrevented||l==null||l())},p);return Mb(_=>{v===c.layers.size-1&&(s==null||s(_),!_.defaultPrevented&&l&&(_.preventDefault(),l()))},p),h.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(rc=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),sc(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=rc)}},[d,p,n,c]),h.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),sc())},[d,c]),h.useEffect(()=>{const _=()=>x({});return document.addEventListener(zo,_),()=>document.removeEventListener(zo,_)},[]),r.jsx(ke.div,{...u,ref:g,style:{pointerEvents:N?w?"auto":"none":void 0,...e.style},onFocusCapture:Se(e.onFocusCapture,k.onFocusCapture),onBlurCapture:Se(e.onBlurCapture,k.onBlurCapture),onPointerDownCapture:Se(e.onPointerDownCapture,j.onPointerDownCapture)})});Li.displayName=Ib;var Lb="DismissableLayerBranch",Db=h.forwardRef((e,t)=>{const n=h.useContext(lh),s=h.useRef(null),a=Me(t,s);return h.useEffect(()=>{const o=s.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),r.jsx(ke.div,{...e,ref:a})});Db.displayName=Lb;function $b(e,t=globalThis==null?void 0:globalThis.document){const n=vn(e),s=h.useRef(!1),a=h.useRef(()=>{});return h.useEffect(()=>{const o=l=>{if(l.target&&!s.current){let u=function(){ch(Pb,n,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=u,t.addEventListener("click",a.current,{once:!0})):u()}else t.removeEventListener("click",a.current);s.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",o),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>s.current=!0}}function zb(e,t=globalThis==null?void 0:globalThis.document){const n=vn(e),s=h.useRef(!1);return h.useEffect(()=>{const a=o=>{o.target&&!s.current&&ch(Ob,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function sc(){const e=new CustomEvent(zo);document.dispatchEvent(e)}function ch(e,t,n,{discrete:s}){const a=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),s?db(a,o):a.dispatchEvent(o)}var Ja=0;function uh(){h.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ac()),document.body.insertAdjacentElement("beforeend",e[1]??ac()),Ja++,()=>{Ja===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Ja--}},[])}function ac(){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 Qa="focusScope.autoFocusOnMount",eo="focusScope.autoFocusOnUnmount",oc={bubbles:!1,cancelable:!0},Fb="FocusScope",Di=h.forwardRef((e,t)=>{const{loop:n=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...i}=e,[l,u]=h.useState(null),c=vn(a),d=vn(o),f=h.useRef(null),p=Me(t,m=>u(m)),x=h.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;h.useEffect(()=>{if(s){let m=function(N){if(x.paused||!l)return;const w=N.target;l.contains(w)?f.current=w:Ut(f.current,{select:!0})},y=function(N){if(x.paused||!l)return;const w=N.relatedTarget;w!==null&&(l.contains(w)||Ut(f.current,{select:!0}))},b=function(N){if(document.activeElement===document.body)for(const j of N)j.removedNodes.length>0&&Ut(l)};document.addEventListener("focusin",m),document.addEventListener("focusout",y);const v=new MutationObserver(b);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",y),v.disconnect()}}},[s,l,x.paused]),h.useEffect(()=>{if(l){lc.add(x);const m=document.activeElement;if(!l.contains(m)){const b=new CustomEvent(Qa,oc);l.addEventListener(Qa,c),l.dispatchEvent(b),b.defaultPrevented||(Bb(Wb(dh(l)),{select:!0}),document.activeElement===m&&Ut(l))}return()=>{l.removeEventListener(Qa,c),setTimeout(()=>{const b=new CustomEvent(eo,oc);l.addEventListener(eo,d),l.dispatchEvent(b),b.defaultPrevented||Ut(m??document.body,{select:!0}),l.removeEventListener(eo,d),lc.remove(x)},0)}}},[l,c,d,x]);const g=h.useCallback(m=>{if(!n&&!s||x.paused)return;const y=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,b=document.activeElement;if(y&&b){const v=m.currentTarget,[N,w]=Hb(v);N&&w?!m.shiftKey&&b===w?(m.preventDefault(),n&&Ut(N,{select:!0})):m.shiftKey&&b===N&&(m.preventDefault(),n&&Ut(w,{select:!0})):b===v&&m.preventDefault()}},[n,s,x.paused]);return r.jsx(ke.div,{tabIndex:-1,...i,ref:p,onKeyDown:g})});Di.displayName=Fb;function Bb(e,{select:t=!1}={}){const n=document.activeElement;for(const s of e)if(Ut(s,{select:t}),document.activeElement!==n)return}function Hb(e){const t=dh(e),n=ic(t,e),s=ic(t.reverse(),e);return[n,s]}function dh(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ic(e,t){for(const n of e)if(!Ub(n,{upTo:t}))return n}function Ub(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Vb(e){return e instanceof HTMLInputElement&&"select"in e}function Ut(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Vb(e)&&t&&e.select()}}var lc=qb();function qb(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=cc(e,t),e.unshift(t)},remove(t){var n;e=cc(e,t),(n=e[0])==null||n.resume()}}}function cc(e,t){const n=[...e],s=n.indexOf(t);return s!==-1&&n.splice(s,1),n}function Wb(e){return e.filter(t=>t.tagName!=="A")}var Gb=bi[" useId ".trim().toString()]||(()=>{}),Kb=0;function st(e){const[t,n]=h.useState(Gb());return Ue(()=>{n(s=>s??String(Kb++))},[e]),t?`radix-${t}`:""}const Yb=["top","right","bottom","left"],en=Math.min,Je=Math.max,Xs=Math.round,ds=Math.floor,vt=e=>({x:e,y:e}),Xb={left:"right",right:"left",bottom:"top",top:"bottom"},Zb={start:"end",end:"start"};function Fo(e,t,n){return Je(e,en(t,n))}function Pt(e,t){return typeof e=="function"?e(t):e}function Ot(e){return e.split("-")[0]}function dr(e){return e.split("-")[1]}function $i(e){return e==="x"?"y":"x"}function zi(e){return e==="y"?"height":"width"}const Jb=new Set(["top","bottom"]);function bt(e){return Jb.has(Ot(e))?"y":"x"}function Fi(e){return $i(bt(e))}function Qb(e,t,n){n===void 0&&(n=!1);const s=dr(e),a=Fi(e),o=zi(a);let i=a==="x"?s===(n?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(i=Zs(i)),[i,Zs(i)]}function ev(e){const t=Zs(e);return[Bo(e),t,Bo(t)]}function Bo(e){return e.replace(/start|end/g,t=>Zb[t])}const uc=["left","right"],dc=["right","left"],tv=["top","bottom"],nv=["bottom","top"];function rv(e,t,n){switch(e){case"top":case"bottom":return n?t?dc:uc:t?uc:dc;case"left":case"right":return t?tv:nv;default:return[]}}function sv(e,t,n,s){const a=dr(e);let o=rv(Ot(e),n==="start",s);return a&&(o=o.map(i=>i+"-"+a),t&&(o=o.concat(o.map(Bo)))),o}function Zs(e){return e.replace(/left|right|bottom|top/g,t=>Xb[t])}function av(e){return{top:0,right:0,bottom:0,left:0,...e}}function hh(e){return typeof e!="number"?av(e):{top:e,right:e,bottom:e,left:e}}function Js(e){const{x:t,y:n,width:s,height:a}=e;return{width:s,height:a,top:n,left:t,right:t+s,bottom:n+a,x:t,y:n}}function hc(e,t,n){let{reference:s,floating:a}=e;const o=bt(t),i=Fi(t),l=zi(i),u=Ot(t),c=o==="y",d=s.x+s.width/2-a.width/2,f=s.y+s.height/2-a.height/2,p=s[l]/2-a[l]/2;let x;switch(u){case"top":x={x:d,y:s.y-a.height};break;case"bottom":x={x:d,y:s.y+s.height};break;case"right":x={x:s.x+s.width,y:f};break;case"left":x={x:s.x-a.width,y:f};break;default:x={x:s.x,y:s.y}}switch(dr(t)){case"start":x[i]-=p*(n&&c?-1:1);break;case"end":x[i]+=p*(n&&c?-1:1);break}return x}async function ov(e,t){var n;t===void 0&&(t={});const{x:s,y:a,platform:o,rects:i,elements:l,strategy:u}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:x=0}=Pt(t,e),g=hh(x),y=l[p?f==="floating"?"reference":"floating":f],b=Js(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(y)))==null||n?y:y.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:u})),v=f==="floating"?{x:s,y:a,width:i.floating.width,height:i.floating.height}:i.reference,N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),w=await(o.isElement==null?void 0:o.isElement(N))?await(o.getScale==null?void 0:o.getScale(N))||{x:1,y:1}:{x:1,y:1},j=Js(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:N,strategy:u}):v);return{top:(b.top-j.top+g.top)/w.y,bottom:(j.bottom-b.bottom+g.bottom)/w.y,left:(b.left-j.left+g.left)/w.x,right:(j.right-b.right+g.right)/w.x}}const iv=async(e,t,n)=>{const{placement:s="bottom",strategy:a="absolute",middleware:o=[],platform:i}=n,l=o.filter(Boolean),u=await(i.isRTL==null?void 0:i.isRTL(t));let c=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:f}=hc(c,s,u),p=s,x={},g=0;for(let y=0;y<l.length;y++){var m;const{name:b,fn:v}=l[y],{x:N,y:w,data:j,reset:k}=await v({x:d,y:f,initialPlacement:s,placement:p,strategy:a,middlewareData:x,rects:c,platform:{...i,detectOverflow:(m=i.detectOverflow)!=null?m:ov},elements:{reference:e,floating:t}});d=N??d,f=w??f,x={...x,[b]:{...x[b],...j}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(p=k.placement),k.rects&&(c=k.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:a}):k.rects),{x:d,y:f}=hc(c,p,u)),y=-1)}return{x:d,y:f,placement:p,strategy:a,middlewareData:x}},lv=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:s,placement:a,rects:o,platform:i,elements:l,middlewareData:u}=t,{element:c,padding:d=0}=Pt(e,t)||{};if(c==null)return{};const f=hh(d),p={x:n,y:s},x=Fi(a),g=zi(x),m=await i.getDimensions(c),y=x==="y",b=y?"top":"left",v=y?"bottom":"right",N=y?"clientHeight":"clientWidth",w=o.reference[g]+o.reference[x]-p[x]-o.floating[g],j=p[x]-o.reference[x],k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let _=k?k[N]:0;(!_||!await(i.isElement==null?void 0:i.isElement(k)))&&(_=l.floating[N]||o.floating[g]);const P=w/2-j/2,T=_/2-m[g]/2-1,$=en(f[b],T),B=en(f[v],T),D=$,R=_-m[g]-B,S=_/2-m[g]/2+P,C=Fo(D,S,R),E=!u.arrow&&dr(a)!=null&&S!==C&&o.reference[g]/2-(S<D?$:B)-m[g]/2<0,A=E?S<D?S-D:S-R:0;return{[x]:p[x]+A,data:{[x]:C,centerOffset:S-C-A,...E&&{alignmentOffset:A}},reset:E}}}),cv=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,s;const{placement:a,middlewareData:o,rects:i,initialPlacement:l,platform:u,elements:c}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:m=!0,...y}=Pt(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const b=Ot(a),v=bt(l),N=Ot(l)===l,w=await(u.isRTL==null?void 0:u.isRTL(c.floating)),j=p||(N||!m?[Zs(l)]:ev(l)),k=g!=="none";!p&&k&&j.push(...sv(l,m,g,w));const _=[l,...j],P=await u.detectOverflow(t,y),T=[];let $=((s=o.flip)==null?void 0:s.overflows)||[];if(d&&T.push(P[b]),f){const S=Qb(a,i,w);T.push(P[S[0]],P[S[1]])}if($=[...$,{placement:a,overflows:T}],!T.every(S=>S<=0)){var B,D;const S=(((B=o.flip)==null?void 0:B.index)||0)+1,C=_[S];if(C&&(!(f==="alignment"?v!==bt(C):!1)||$.every(O=>bt(O.placement)===v?O.overflows[0]>0:!0)))return{data:{index:S,overflows:$},reset:{placement:C}};let E=(D=$.filter(A=>A.overflows[0]<=0).sort((A,O)=>A.overflows[1]-O.overflows[1])[0])==null?void 0:D.placement;if(!E)switch(x){case"bestFit":{var R;const A=(R=$.filter(O=>{if(k){const I=bt(O.placement);return I===v||I==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(I=>I>0).reduce((I,F)=>I+F,0)]).sort((O,I)=>O[1]-I[1])[0])==null?void 0:R[0];A&&(E=A);break}case"initialPlacement":E=l;break}if(a!==E)return{reset:{placement:E}}}return{}}}};function fc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pc(e){return Yb.some(t=>e[t]>=0)}const uv=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:s}=t,{strategy:a="referenceHidden",...o}=Pt(e,t);switch(a){case"referenceHidden":{const i=await s.detectOverflow(t,{...o,elementContext:"reference"}),l=fc(i,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:pc(l)}}}case"escaped":{const i=await s.detectOverflow(t,{...o,altBoundary:!0}),l=fc(i,n.floating);return{data:{escapedOffsets:l,escaped:pc(l)}}}default:return{}}}}},fh=new Set(["left","top"]);async function dv(e,t){const{placement:n,platform:s,elements:a}=e,o=await(s.isRTL==null?void 0:s.isRTL(a.floating)),i=Ot(n),l=dr(n),u=bt(n)==="y",c=fh.has(i)?-1:1,d=o&&u?-1:1,f=Pt(t,e);let{mainAxis:p,crossAxis:x,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof g=="number"&&(x=l==="end"?g*-1:g),u?{x:x*d,y:p*c}:{x:p*c,y:x*d}}const hv=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,s;const{x:a,y:o,placement:i,middlewareData:l}=t,u=await dv(t,e);return i===((n=l.offset)==null?void 0:n.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:a+u.x,y:o+u.y,data:{...u,placement:i}}}}},fv=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:s,placement:a,platform:o}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:u={fn:b=>{let{x:v,y:N}=b;return{x:v,y:N}}},...c}=Pt(e,t),d={x:n,y:s},f=await o.detectOverflow(t,c),p=bt(Ot(a)),x=$i(p);let g=d[x],m=d[p];if(i){const b=x==="y"?"top":"left",v=x==="y"?"bottom":"right",N=g+f[b],w=g-f[v];g=Fo(N,g,w)}if(l){const b=p==="y"?"top":"left",v=p==="y"?"bottom":"right",N=m+f[b],w=m-f[v];m=Fo(N,m,w)}const y=u.fn({...t,[x]:g,[p]:m});return{...y,data:{x:y.x-n,y:y.y-s,enabled:{[x]:i,[p]:l}}}}}},pv=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:s,placement:a,rects:o,middlewareData:i}=t,{offset:l=0,mainAxis:u=!0,crossAxis:c=!0}=Pt(e,t),d={x:n,y:s},f=bt(a),p=$i(f);let x=d[p],g=d[f];const m=Pt(l,t),y=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(u){const N=p==="y"?"height":"width",w=o.reference[p]-o.floating[N]+y.mainAxis,j=o.reference[p]+o.reference[N]-y.mainAxis;x<w?x=w:x>j&&(x=j)}if(c){var b,v;const N=p==="y"?"width":"height",w=fh.has(Ot(a)),j=o.reference[f]-o.floating[N]+(w&&((b=i.offset)==null?void 0:b[f])||0)+(w?0:y.crossAxis),k=o.reference[f]+o.reference[N]+(w?0:((v=i.offset)==null?void 0:v[f])||0)-(w?y.crossAxis:0);g<j?g=j:g>k&&(g=k)}return{[p]:x,[f]:g}}}},mv=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,s;const{placement:a,rects:o,platform:i,elements:l}=t,{apply:u=()=>{},...c}=Pt(e,t),d=await i.detectOverflow(t,c),f=Ot(a),p=dr(a),x=bt(a)==="y",{width:g,height:m}=o.floating;let y,b;f==="top"||f==="bottom"?(y=f,b=p===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=f,y=p==="end"?"top":"bottom");const v=m-d.top-d.bottom,N=g-d.left-d.right,w=en(m-d[y],v),j=en(g-d[b],N),k=!t.middlewareData.shift;let _=w,P=j;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=N),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(_=v),k&&!p){const $=Je(d.left,0),B=Je(d.right,0),D=Je(d.top,0),R=Je(d.bottom,0);x?P=g-2*($!==0||B!==0?$+B:Je(d.left,d.right)):_=m-2*(D!==0||R!==0?D+R:Je(d.top,d.bottom))}await u({...t,availableWidth:P,availableHeight:_});const T=await i.getDimensions(l.floating);return g!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function Sa(){return typeof window<"u"}function hr(e){return ph(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function St(e){var t;return(t=(ph(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function ph(e){return Sa()?e instanceof Node||e instanceof Qe(e).Node:!1}function ht(e){return Sa()?e instanceof Element||e instanceof Qe(e).Element:!1}function Nt(e){return Sa()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function mc(e){return!Sa()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const xv=new Set(["inline","contents"]);function ss(e){const{overflow:t,overflowX:n,overflowY:s,display:a}=ft(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+n)&&!xv.has(a)}const gv=new Set(["table","td","th"]);function yv(e){return gv.has(hr(e))}const bv=[":popover-open",":modal"];function ja(e){return bv.some(t=>{try{return e.matches(t)}catch{return!1}})}const vv=["transform","translate","scale","rotate","perspective"],wv=["transform","translate","scale","rotate","perspective","filter"],Nv=["paint","layout","strict","content"];function Bi(e){const t=Hi(),n=ht(e)?ft(e):e;return vv.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||wv.some(s=>(n.willChange||"").includes(s))||Nv.some(s=>(n.contain||"").includes(s))}function Sv(e){let t=tn(e);for(;Nt(t)&&!Qn(t);){if(Bi(t))return t;if(ja(t))return null;t=tn(t)}return null}function Hi(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const jv=new Set(["html","body","#document"]);function Qn(e){return jv.has(hr(e))}function ft(e){return Qe(e).getComputedStyle(e)}function ka(e){return ht(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tn(e){if(hr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||mc(e)&&e.host||St(e);return mc(t)?t.host:t}function mh(e){const t=tn(e);return Qn(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nt(t)&&ss(t)?t:mh(t)}function $r(e,t,n){var s;t===void 0&&(t=[]),n===void 0&&(n=!0);const a=mh(e),o=a===((s=e.ownerDocument)==null?void 0:s.body),i=Qe(a);if(o){const l=Ho(i);return t.concat(i,i.visualViewport||[],ss(a)?a:[],l&&n?$r(l):[])}return t.concat(a,$r(a,[],n))}function Ho(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function xh(e){const t=ft(e);let n=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Nt(e),o=a?e.offsetWidth:n,i=a?e.offsetHeight:s,l=Xs(n)!==o||Xs(s)!==i;return l&&(n=o,s=i),{width:n,height:s,$:l}}function Ui(e){return ht(e)?e:e.contextElement}function Gn(e){const t=Ui(e);if(!Nt(t))return vt(1);const n=t.getBoundingClientRect(),{width:s,height:a,$:o}=xh(t);let i=(o?Xs(n.width):n.width)/s,l=(o?Xs(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const kv=vt(0);function gh(e){const t=Qe(e);return!Hi()||!t.visualViewport?kv:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ev(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Qe(e)?!1:t}function wn(e,t,n,s){t===void 0&&(t=!1),n===void 0&&(n=!1);const a=e.getBoundingClientRect(),o=Ui(e);let i=vt(1);t&&(s?ht(s)&&(i=Gn(s)):i=Gn(e));const l=Ev(o,n,s)?gh(o):vt(0);let u=(a.left+l.x)/i.x,c=(a.top+l.y)/i.y,d=a.width/i.x,f=a.height/i.y;if(o){const p=Qe(o),x=s&&ht(s)?Qe(s):s;let g=p,m=Ho(g);for(;m&&s&&x!==g;){const y=Gn(m),b=m.getBoundingClientRect(),v=ft(m),N=b.left+(m.clientLeft+parseFloat(v.paddingLeft))*y.x,w=b.top+(m.clientTop+parseFloat(v.paddingTop))*y.y;u*=y.x,c*=y.y,d*=y.x,f*=y.y,u+=N,c+=w,g=Qe(m),m=Ho(g)}}return Js({width:d,height:f,x:u,y:c})}function Ea(e,t){const n=ka(e).scrollLeft;return t?t.left+n:wn(St(e)).left+n}function yh(e,t){const n=e.getBoundingClientRect(),s=n.left+t.scrollLeft-Ea(e,n),a=n.top+t.scrollTop;return{x:s,y:a}}function _v(e){let{elements:t,rect:n,offsetParent:s,strategy:a}=e;const o=a==="fixed",i=St(s),l=t?ja(t.floating):!1;if(s===i||l&&o)return n;let u={scrollLeft:0,scrollTop:0},c=vt(1);const d=vt(0),f=Nt(s);if((f||!f&&!o)&&((hr(s)!=="body"||ss(i))&&(u=ka(s)),Nt(s))){const x=wn(s);c=Gn(s),d.x=x.x+s.clientLeft,d.y=x.y+s.clientTop}const p=i&&!f&&!o?yh(i,u):vt(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-u.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-u.scrollTop*c.y+d.y+p.y}}function Cv(e){return Array.from(e.getClientRects())}function Tv(e){const t=St(e),n=ka(e),s=e.ownerDocument.body,a=Je(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),o=Je(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let i=-n.scrollLeft+Ea(e);const l=-n.scrollTop;return ft(s).direction==="rtl"&&(i+=Je(t.clientWidth,s.clientWidth)-a),{width:a,height:o,x:i,y:l}}const xc=25;function Rv(e,t){const n=Qe(e),s=St(e),a=n.visualViewport;let o=s.clientWidth,i=s.clientHeight,l=0,u=0;if(a){o=a.width,i=a.height;const d=Hi();(!d||d&&t==="fixed")&&(l=a.offsetLeft,u=a.offsetTop)}const c=Ea(s);if(c<=0){const d=s.ownerDocument,f=d.body,p=getComputedStyle(f),x=d.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(s.clientWidth-f.clientWidth-x);g<=xc&&(o-=g)}else c<=xc&&(o+=c);return{width:o,height:i,x:l,y:u}}const Av=new Set(["absolute","fixed"]);function Mv(e,t){const n=wn(e,!0,t==="fixed"),s=n.top+e.clientTop,a=n.left+e.clientLeft,o=Nt(e)?Gn(e):vt(1),i=e.clientWidth*o.x,l=e.clientHeight*o.y,u=a*o.x,c=s*o.y;return{width:i,height:l,x:u,y:c}}function gc(e,t,n){let s;if(t==="viewport")s=Rv(e,n);else if(t==="document")s=Tv(St(e));else if(ht(t))s=Mv(t,n);else{const a=gh(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Js(s)}function bh(e,t){const n=tn(e);return n===t||!ht(n)||Qn(n)?!1:ft(n).position==="fixed"||bh(n,t)}function Iv(e,t){const n=t.get(e);if(n)return n;let s=$r(e,[],!1).filter(l=>ht(l)&&hr(l)!=="body"),a=null;const o=ft(e).position==="fixed";let i=o?tn(e):e;for(;ht(i)&&!Qn(i);){const l=ft(i),u=Bi(i);!u&&l.position==="fixed"&&(a=null),(o?!u&&!a:!u&&l.position==="static"&&!!a&&Av.has(a.position)||ss(i)&&!u&&bh(e,i))?s=s.filter(d=>d!==i):a=l,i=tn(i)}return t.set(e,s),s}function Pv(e){let{element:t,boundary:n,rootBoundary:s,strategy:a}=e;const i=[...n==="clippingAncestors"?ja(t)?[]:Iv(t,this._c):[].concat(n),s],l=i[0],u=i.reduce((c,d)=>{const f=gc(t,d,a);return c.top=Je(f.top,c.top),c.right=en(f.right,c.right),c.bottom=en(f.bottom,c.bottom),c.left=Je(f.left,c.left),c},gc(t,l,a));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Ov(e){const{width:t,height:n}=xh(e);return{width:t,height:n}}function Lv(e,t,n){const s=Nt(t),a=St(t),o=n==="fixed",i=wn(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const u=vt(0);function c(){u.x=Ea(a)}if(s||!s&&!o)if((hr(t)!=="body"||ss(a))&&(l=ka(t)),s){const x=wn(t,!0,o,t);u.x=x.x+t.clientLeft,u.y=x.y+t.clientTop}else a&&c();o&&!s&&a&&c();const d=a&&!s&&!o?yh(a,l):vt(0),f=i.left+l.scrollLeft-u.x-d.x,p=i.top+l.scrollTop-u.y-d.y;return{x:f,y:p,width:i.width,height:i.height}}function to(e){return ft(e).position==="static"}function yc(e,t){if(!Nt(e)||ft(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return St(e)===n&&(n=n.ownerDocument.body),n}function vh(e,t){const n=Qe(e);if(ja(e))return n;if(!Nt(e)){let a=tn(e);for(;a&&!Qn(a);){if(ht(a)&&!to(a))return a;a=tn(a)}return n}let s=yc(e,t);for(;s&&yv(s)&&to(s);)s=yc(s,t);return s&&Qn(s)&&to(s)&&!Bi(s)?n:s||Sv(e)||n}const Dv=async function(e){const t=this.getOffsetParent||vh,n=this.getDimensions,s=await n(e.floating);return{reference:Lv(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function $v(e){return ft(e).direction==="rtl"}const zv={convertOffsetParentRelativeRectToViewportRelativeRect:_v,getDocumentElement:St,getClippingRect:Pv,getOffsetParent:vh,getElementRects:Dv,getClientRects:Cv,getDimensions:Ov,getScale:Gn,isElement:ht,isRTL:$v};function wh(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Fv(e,t){let n=null,s;const a=St(e);function o(){var l;clearTimeout(s),(l=n)==null||l.disconnect(),n=null}function i(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),o();const c=e.getBoundingClientRect(),{left:d,top:f,width:p,height:x}=c;if(l||t(),!p||!x)return;const g=ds(f),m=ds(a.clientWidth-(d+p)),y=ds(a.clientHeight-(f+x)),b=ds(d),N={rootMargin:-g+"px "+-m+"px "+-y+"px "+-b+"px",threshold:Je(0,en(1,u))||1};let w=!0;function j(k){const _=k[0].intersectionRatio;if(_!==u){if(!w)return i();_?i(!1,_):s=setTimeout(()=>{i(!1,1e-7)},1e3)}_===1&&!wh(c,e.getBoundingClientRect())&&i(),w=!1}try{n=new IntersectionObserver(j,{...N,root:a.ownerDocument})}catch{n=new IntersectionObserver(j,N)}n.observe(e)}return i(!0),o}function Bv(e,t,n,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,c=Ui(e),d=a||o?[...c?$r(c):[],...$r(t)]:[];d.forEach(b=>{a&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const f=c&&l?Fv(c,n):null;let p=-1,x=null;i&&(x=new ResizeObserver(b=>{let[v]=b;v&&v.target===c&&x&&(x.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var N;(N=x)==null||N.observe(t)})),n()}),c&&!u&&x.observe(c),x.observe(t));let g,m=u?wn(e):null;u&&y();function y(){const b=wn(e);m&&!wh(m,b)&&n(),m=b,g=requestAnimationFrame(y)}return n(),()=>{var b;d.forEach(v=>{a&&v.removeEventListener("scroll",n),o&&v.removeEventListener("resize",n)}),f==null||f(),(b=x)==null||b.disconnect(),x=null,u&&cancelAnimationFrame(g)}}const Hv=hv,Uv=fv,Vv=cv,qv=mv,Wv=uv,bc=lv,Gv=pv,Kv=(e,t,n)=>{const s=new Map,a={platform:zv,...n},o={...a.platform,_c:s};return iv(e,t,{...a,platform:o})};var Yv=typeof document<"u",Xv=function(){},Ls=Yv?h.useLayoutEffect:Xv;function Qs(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(s=n;s--!==0;)if(!Qs(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=n;s--!==0;){const o=a[s];if(!(o==="_owner"&&e.$$typeof)&&!Qs(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function Nh(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function vc(e,t){const n=Nh(e);return Math.round(t*n)/n}function no(e){const t=h.useRef(e);return Ls(()=>{t.current=e}),t}function Zv(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:s=[],platform:a,elements:{reference:o,floating:i}={},transform:l=!0,whileElementsMounted:u,open:c}=e,[d,f]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,x]=h.useState(s);Qs(p,s)||x(s);const[g,m]=h.useState(null),[y,b]=h.useState(null),v=h.useCallback(O=>{O!==k.current&&(k.current=O,m(O))},[]),N=h.useCallback(O=>{O!==_.current&&(_.current=O,b(O))},[]),w=o||g,j=i||y,k=h.useRef(null),_=h.useRef(null),P=h.useRef(d),T=u!=null,$=no(u),B=no(a),D=no(c),R=h.useCallback(()=>{if(!k.current||!_.current)return;const O={placement:t,strategy:n,middleware:p};B.current&&(O.platform=B.current),Kv(k.current,_.current,O).then(I=>{const F={...I,isPositioned:D.current!==!1};S.current&&!Qs(P.current,F)&&(P.current=F,ir.flushSync(()=>{f(F)}))})},[p,t,n,B,D]);Ls(()=>{c===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,f(O=>({...O,isPositioned:!1})))},[c]);const S=h.useRef(!1);Ls(()=>(S.current=!0,()=>{S.current=!1}),[]),Ls(()=>{if(w&&(k.current=w),j&&(_.current=j),w&&j){if($.current)return $.current(w,j,R);R()}},[w,j,R,$,T]);const C=h.useMemo(()=>({reference:k,floating:_,setReference:v,setFloating:N}),[v,N]),E=h.useMemo(()=>({reference:w,floating:j}),[w,j]),A=h.useMemo(()=>{const O={position:n,left:0,top:0};if(!E.floating)return O;const I=vc(E.floating,d.x),F=vc(E.floating,d.y);return l?{...O,transform:"translate("+I+"px, "+F+"px)",...Nh(E.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:I,top:F}},[n,l,E.floating,d.x,d.y]);return h.useMemo(()=>({...d,update:R,refs:C,elements:E,floatingStyles:A}),[d,R,C,E,A])}const Jv=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:s,padding:a}=typeof e=="function"?e(n):e;return s&&t(s)?s.current!=null?bc({element:s.current,padding:a}).fn(n):{}:s?bc({element:s,padding:a}).fn(n):{}}}},Qv=(e,t)=>({...Hv(e),options:[e,t]}),ew=(e,t)=>({...Uv(e),options:[e,t]}),tw=(e,t)=>({...Gv(e),options:[e,t]}),nw=(e,t)=>({...Vv(e),options:[e,t]}),rw=(e,t)=>({...qv(e),options:[e,t]}),sw=(e,t)=>({...Wv(e),options:[e,t]}),aw=(e,t)=>({...Jv(e),options:[e,t]});var ow="Arrow",Sh=h.forwardRef((e,t)=>{const{children:n,width:s=10,height:a=5,...o}=e;return r.jsx(ke.svg,{...o,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:r.jsx("polygon",{points:"0,0 30,0 15,10"})})});Sh.displayName=ow;var iw=Sh,Vi="Popper",[jh,kh]=rs(Vi),[lw,Eh]=jh(Vi),_h=e=>{const{__scopePopper:t,children:n}=e,[s,a]=h.useState(null);return r.jsx(lw,{scope:t,anchor:s,onAnchorChange:a,children:n})};_h.displayName=Vi;var Ch="PopperAnchor",Th=h.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:s,...a}=e,o=Eh(Ch,n),i=h.useRef(null),l=Me(t,i),u=h.useRef(null);return h.useEffect(()=>{const c=u.current;u.current=(s==null?void 0:s.current)||i.current,c!==u.current&&o.onAnchorChange(u.current)}),s?null:r.jsx(ke.div,{...a,ref:l})});Th.displayName=Ch;var qi="PopperContent",[cw,uw]=jh(qi),Rh=h.forwardRef((e,t)=>{var G,J,ee,te,oe,ie;const{__scopePopper:n,side:s="bottom",sideOffset:a=0,align:o="center",alignOffset:i=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:c=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:p=!1,updatePositionStrategy:x="optimized",onPlaced:g,...m}=e,y=Eh(qi,n),[b,v]=h.useState(null),N=Me(t,me=>v(me)),[w,j]=h.useState(null),k=qd(w),_=(k==null?void 0:k.width)??0,P=(k==null?void 0:k.height)??0,T=s+(o!=="center"?"-"+o:""),$=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},B=Array.isArray(c)?c:[c],D=B.length>0,R={padding:$,boundary:B.filter(hw),altBoundary:D},{refs:S,floatingStyles:C,placement:E,isPositioned:A,middlewareData:O}=Zv({strategy:"fixed",placement:T,whileElementsMounted:(...me)=>Bv(...me,{animationFrame:x==="always"}),elements:{reference:y.anchor},middleware:[Qv({mainAxis:a+P,alignmentAxis:i}),u&&ew({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?tw():void 0,...R}),u&&nw({...R}),rw({...R,apply:({elements:me,rects:W,availableWidth:fe,availableHeight:Ae})=>{const{width:ge,height:Y}=W.reference,Pe=me.floating.style;Pe.setProperty("--radix-popper-available-width",`${fe}px`),Pe.setProperty("--radix-popper-available-height",`${Ae}px`),Pe.setProperty("--radix-popper-anchor-width",`${ge}px`),Pe.setProperty("--radix-popper-anchor-height",`${Y}px`)}}),w&&aw({element:w,padding:l}),fw({arrowWidth:_,arrowHeight:P}),p&&sw({strategy:"referenceHidden",...R})]}),[I,F]=Ih(E),L=vn(g);Ue(()=>{A&&(L==null||L())},[A,L]);const M=(G=O.arrow)==null?void 0:G.x,z=(J=O.arrow)==null?void 0:J.y,H=((ee=O.arrow)==null?void 0:ee.centerOffset)!==0,[V,Z]=h.useState();return Ue(()=>{b&&Z(window.getComputedStyle(b).zIndex)},[b]),r.jsx("div",{ref:S.setFloating,"data-radix-popper-content-wrapper":"",style:{...C,transform:A?C.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:V,"--radix-popper-transform-origin":[(te=O.transformOrigin)==null?void 0:te.x,(oe=O.transformOrigin)==null?void 0:oe.y].join(" "),...((ie=O.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:r.jsx(cw,{scope:n,placedSide:I,onArrowChange:j,arrowX:M,arrowY:z,shouldHideArrow:H,children:r.jsx(ke.div,{"data-side":I,"data-align":F,...m,ref:N,style:{...m.style,animation:A?void 0:"none"}})})})});Rh.displayName=qi;var Ah="PopperArrow",dw={top:"bottom",right:"left",bottom:"top",left:"right"},Mh=h.forwardRef(function(t,n){const{__scopePopper:s,...a}=t,o=uw(Ah,s),i=dw[o.placedSide];return r.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:r.jsx(iw,{...a,ref:n,style:{...a.style,display:"block"}})})});Mh.displayName=Ah;function hw(e){return e!==null}var fw=e=>({name:"transformOrigin",options:e,fn(t){var y,b,v;const{placement:n,rects:s,middlewareData:a}=t,i=((y=a.arrow)==null?void 0:y.centerOffset)!==0,l=i?0:e.arrowWidth,u=i?0:e.arrowHeight,[c,d]=Ih(n),f={start:"0%",center:"50%",end:"100%"}[d],p=(((b=a.arrow)==null?void 0:b.x)??0)+l/2,x=(((v=a.arrow)==null?void 0:v.y)??0)+u/2;let g="",m="";return c==="bottom"?(g=i?f:`${p}px`,m=`${-u}px`):c==="top"?(g=i?f:`${p}px`,m=`${s.floating.height+u}px`):c==="right"?(g=`${-u}px`,m=i?f:`${x}px`):c==="left"&&(g=`${s.floating.width+u}px`,m=i?f:`${x}px`),{data:{x:g,y:m}}}});function Ih(e){const[t,n="center"]=e.split("-");return[t,n]}var pw=_h,mw=Th,xw=Rh,gw=Mh,yw="Portal",Wi=h.forwardRef((e,t)=>{var l;const{container:n,...s}=e,[a,o]=h.useState(!1);Ue(()=>o(!0),[]);const i=n||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?mg.createPortal(r.jsx(ke.div,{...s,ref:t}),i):null});Wi.displayName=yw;var Ph=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"}),bw="VisuallyHidden",vw=h.forwardRef((e,t)=>r.jsx(ke.span,{...e,ref:t,style:{...Ph,...e.style}}));vw.displayName=bw;var ww=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},An=new WeakMap,hs=new WeakMap,fs={},ro=0,Oh=function(e){return e&&(e.host||Oh(e.parentNode))},Nw=function(e,t){return t.map(function(n){if(e.contains(n))return n;var s=Oh(n);return s&&e.contains(s)?s:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},Sw=function(e,t,n,s){var a=Nw(t,Array.isArray(e)?e:[e]);fs[n]||(fs[n]=new WeakMap);var o=fs[n],i=[],l=new Set,u=new Set(a),c=function(f){!f||l.has(f)||(l.add(f),c(f.parentNode))};a.forEach(c);var d=function(f){!f||u.has(f)||Array.prototype.forEach.call(f.children,function(p){if(l.has(p))d(p);else try{var x=p.getAttribute(s),g=x!==null&&x!=="false",m=(An.get(p)||0)+1,y=(o.get(p)||0)+1;An.set(p,m),o.set(p,y),i.push(p),m===1&&g&&hs.set(p,!0),y===1&&p.setAttribute(n,"true"),g||p.setAttribute(s,"true")}catch(b){console.error("aria-hidden: cannot operate on ",p,b)}})};return d(t),l.clear(),ro++,function(){i.forEach(function(f){var p=An.get(f)-1,x=o.get(f)-1;An.set(f,p),o.set(f,x),p||(hs.has(f)||f.removeAttribute(s),hs.delete(f)),x||f.removeAttribute(n)}),ro--,ro||(An=new WeakMap,An=new WeakMap,hs=new WeakMap,fs={})}},Lh=function(e,t,n){n===void 0&&(n="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),a=ww(e);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live], script"))),Sw(s,a,n,"aria-hidden")):function(){return null}},yt=function(){return yt=Object.assign||function(t){for(var n,s=1,a=arguments.length;s<a;s++){n=arguments[s];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},yt.apply(this,arguments)};function Dh(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(n[s[a]]=e[s[a]]);return n}function jw(e,t,n){if(n||arguments.length===2)for(var s=0,a=t.length,o;s<a;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}var Ds="right-scroll-bar-position",$s="width-before-scroll-bar",kw="with-scroll-bars-hidden",Ew="--removed-body-scroll-bar-size";function so(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function _w(e,t){var n=h.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(s){var a=n.value;a!==s&&(n.value=s,n.callback(s,a))}}}})[0];return n.callback=t,n.facade}var Cw=typeof window<"u"?h.useLayoutEffect:h.useEffect,wc=new WeakMap;function Tw(e,t){var n=_w(null,function(s){return e.forEach(function(a){return so(a,s)})});return Cw(function(){var s=wc.get(n);if(s){var a=new Set(s),o=new Set(e),i=n.current;a.forEach(function(l){o.has(l)||so(l,null)}),o.forEach(function(l){a.has(l)||so(l,i)})}wc.set(n,e)},[e]),n}function Rw(e){return e}function Aw(e,t){t===void 0&&(t=Rw);var n=[],s=!1,a={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var i=t(o,s);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(o){for(s=!0;n.length;){var i=n;n=[],i.forEach(o)}n={push:function(l){return o(l)},filter:function(){return n}}},assignMedium:function(o){s=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(o),i=n}var u=function(){var d=i;i=[],d.forEach(o)},c=function(){return Promise.resolve().then(u)};c(),n={push:function(d){i.push(d),c()},filter:function(d){return i=i.filter(d),n}}}};return a}function Mw(e){e===void 0&&(e={});var t=Aw(null);return t.options=yt({async:!0,ssr:!1},e),t}var $h=function(e){var t=e.sideCar,n=Dh(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return h.createElement(s,yt({},n))};$h.isSideCarExport=!0;function Iw(e,t){return e.useMedium(t),$h}var zh=Mw(),ao=function(){},_a=h.forwardRef(function(e,t){var n=h.useRef(null),s=h.useState({onScrollCapture:ao,onWheelCapture:ao,onTouchMoveCapture:ao}),a=s[0],o=s[1],i=e.forwardProps,l=e.children,u=e.className,c=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,x=e.noRelative,g=e.noIsolation,m=e.inert,y=e.allowPinchZoom,b=e.as,v=b===void 0?"div":b,N=e.gapMode,w=Dh(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),j=p,k=Tw([n,t]),_=yt(yt({},w),a);return h.createElement(h.Fragment,null,d&&h.createElement(j,{sideCar:zh,removeScrollBar:c,shards:f,noRelative:x,noIsolation:g,inert:m,setCallbacks:o,allowPinchZoom:!!y,lockRef:n,gapMode:N}),i?h.cloneElement(h.Children.only(l),yt(yt({},_),{ref:k})):h.createElement(v,yt({},_,{className:u,ref:k}),l))});_a.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};_a.classNames={fullWidth:$s,zeroRight:Ds};var Pw=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Ow(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Pw();return t&&e.setAttribute("nonce",t),e}function Lw(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Dw(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var $w=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Ow())&&(Lw(t,n),Dw(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},zw=function(){var e=$w();return function(t,n){h.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Fh=function(){var e=zw(),t=function(n){var s=n.styles,a=n.dynamic;return e(s,a),null};return t},Fw={left:0,top:0,right:0,gap:0},oo=function(e){return parseInt(e||"",10)||0},Bw=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[oo(n),oo(s),oo(a)]},Hw=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Fw;var t=Bw(e),n=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-n+t[2]-t[0])}},Uw=Fh(),Kn="data-scroll-locked",Vw=function(e,t,n,s){var a=e.left,o=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
514
|
+
.`.concat(kw,` {
|
|
515
|
+
overflow: hidden `).concat(s,`;
|
|
516
|
+
padding-right: `).concat(l,"px ").concat(s,`;
|
|
517
|
+
}
|
|
518
|
+
body[`).concat(Kn,`] {
|
|
519
|
+
overflow: hidden `).concat(s,`;
|
|
520
|
+
overscroll-behavior: contain;
|
|
521
|
+
`).concat([t&&"position: relative ".concat(s,";"),n==="margin"&&`
|
|
522
|
+
padding-left: `.concat(a,`px;
|
|
523
|
+
padding-top: `).concat(o,`px;
|
|
524
|
+
padding-right: `).concat(i,`px;
|
|
525
|
+
margin-left:0;
|
|
526
|
+
margin-top:0;
|
|
527
|
+
margin-right: `).concat(l,"px ").concat(s,`;
|
|
528
|
+
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(s,";")].filter(Boolean).join(""),`
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
.`).concat(Ds,` {
|
|
532
|
+
right: `).concat(l,"px ").concat(s,`;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.`).concat($s,` {
|
|
536
|
+
margin-right: `).concat(l,"px ").concat(s,`;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.`).concat(Ds," .").concat(Ds,` {
|
|
540
|
+
right: 0 `).concat(s,`;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.`).concat($s," .").concat($s,` {
|
|
544
|
+
margin-right: 0 `).concat(s,`;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
body[`).concat(Kn,`] {
|
|
548
|
+
`).concat(Ew,": ").concat(l,`px;
|
|
549
|
+
}
|
|
550
|
+
`)},Nc=function(){var e=parseInt(document.body.getAttribute(Kn)||"0",10);return isFinite(e)?e:0},qw=function(){h.useEffect(function(){return document.body.setAttribute(Kn,(Nc()+1).toString()),function(){var e=Nc()-1;e<=0?document.body.removeAttribute(Kn):document.body.setAttribute(Kn,e.toString())}},[])},Ww=function(e){var t=e.noRelative,n=e.noImportant,s=e.gapMode,a=s===void 0?"margin":s;qw();var o=h.useMemo(function(){return Hw(a)},[a]);return h.createElement(Uw,{styles:Vw(o,!t,a,n?"":"!important")})},Uo=!1;if(typeof window<"u")try{var ps=Object.defineProperty({},"passive",{get:function(){return Uo=!0,!0}});window.addEventListener("test",ps,ps),window.removeEventListener("test",ps,ps)}catch{Uo=!1}var Mn=Uo?{passive:!1}:!1,Gw=function(e){return e.tagName==="TEXTAREA"},Bh=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!Gw(e)&&n[t]==="visible")},Kw=function(e){return Bh(e,"overflowY")},Yw=function(e){return Bh(e,"overflowX")},Sc=function(e,t){var n=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=Hh(e,s);if(a){var o=Uh(e,s),i=o[1],l=o[2];if(i>l)return!0}s=s.parentNode}while(s&&s!==n.body);return!1},Xw=function(e){var t=e.scrollTop,n=e.scrollHeight,s=e.clientHeight;return[t,n,s]},Zw=function(e){var t=e.scrollLeft,n=e.scrollWidth,s=e.clientWidth;return[t,n,s]},Hh=function(e,t){return e==="v"?Kw(t):Yw(t)},Uh=function(e,t){return e==="v"?Xw(t):Zw(t)},Jw=function(e,t){return e==="h"&&t==="rtl"?-1:1},Qw=function(e,t,n,s,a){var o=Jw(e,window.getComputedStyle(t).direction),i=o*s,l=n.target,u=t.contains(l),c=!1,d=i>0,f=0,p=0;do{if(!l)break;var x=Uh(e,l),g=x[0],m=x[1],y=x[2],b=m-y-o*g;(g||b)&&Hh(e,l)&&(f+=b,p+=g);var v=l.parentNode;l=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!u&&l!==document.body||u&&(t.contains(l)||t===l));return(d&&Math.abs(f)<1||!d&&Math.abs(p)<1)&&(c=!0),c},ms=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},jc=function(e){return[e.deltaX,e.deltaY]},kc=function(e){return e&&"current"in e?e.current:e},e1=function(e,t){return e[0]===t[0]&&e[1]===t[1]},t1=function(e){return`
|
|
551
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
552
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
553
|
+
`)},n1=0,In=[];function r1(e){var t=h.useRef([]),n=h.useRef([0,0]),s=h.useRef(),a=h.useState(n1++)[0],o=h.useState(Fh)[0],i=h.useRef(e);h.useEffect(function(){i.current=e},[e]),h.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var m=jw([e.lockRef.current],(e.shards||[]).map(kc),!0).filter(Boolean);return m.forEach(function(y){return y.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),m.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=h.useCallback(function(m,y){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var b=ms(m),v=n.current,N="deltaX"in m?m.deltaX:v[0]-b[0],w="deltaY"in m?m.deltaY:v[1]-b[1],j,k=m.target,_=Math.abs(N)>Math.abs(w)?"h":"v";if("touches"in m&&_==="h"&&k.type==="range")return!1;var P=window.getSelection(),T=P&&P.anchorNode,$=T?T===k||T.contains(k):!1;if($)return!1;var B=Sc(_,k);if(!B)return!0;if(B?j=_:(j=_==="v"?"h":"v",B=Sc(_,k)),!B)return!1;if(!s.current&&"changedTouches"in m&&(N||w)&&(s.current=j),!j)return!0;var D=s.current||j;return Qw(D,y,m,D==="h"?N:w)},[]),u=h.useCallback(function(m){var y=m;if(!(!In.length||In[In.length-1]!==o)){var b="deltaY"in y?jc(y):ms(y),v=t.current.filter(function(j){return j.name===y.type&&(j.target===y.target||y.target===j.shadowParent)&&e1(j.delta,b)})[0];if(v&&v.should){y.cancelable&&y.preventDefault();return}if(!v){var N=(i.current.shards||[]).map(kc).filter(Boolean).filter(function(j){return j.contains(y.target)}),w=N.length>0?l(y,N[0]):!i.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),c=h.useCallback(function(m,y,b,v){var N={name:m,delta:y,target:b,should:v,shadowParent:s1(b)};t.current.push(N),setTimeout(function(){t.current=t.current.filter(function(w){return w!==N})},1)},[]),d=h.useCallback(function(m){n.current=ms(m),s.current=void 0},[]),f=h.useCallback(function(m){c(m.type,jc(m),m.target,l(m,e.lockRef.current))},[]),p=h.useCallback(function(m){c(m.type,ms(m),m.target,l(m,e.lockRef.current))},[]);h.useEffect(function(){return In.push(o),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:p}),document.addEventListener("wheel",u,Mn),document.addEventListener("touchmove",u,Mn),document.addEventListener("touchstart",d,Mn),function(){In=In.filter(function(m){return m!==o}),document.removeEventListener("wheel",u,Mn),document.removeEventListener("touchmove",u,Mn),document.removeEventListener("touchstart",d,Mn)}},[]);var x=e.removeScrollBar,g=e.inert;return h.createElement(h.Fragment,null,g?h.createElement(o,{styles:t1(a)}):null,x?h.createElement(Ww,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function s1(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const a1=Iw(zh,r1);var Gi=h.forwardRef(function(e,t){return h.createElement(_a,yt({},e,{ref:t,sideCar:a1}))});Gi.classNames=_a.classNames;var o1=[" ","Enter","ArrowUp","ArrowDown"],i1=[" ","Enter"],Nn="Select",[Ca,Ta,l1]=Wd(Nn),[fr]=rs(Nn,[l1,kh]),Ra=kh(),[c1,rn]=fr(Nn),[u1,d1]=fr(Nn),Vh=e=>{const{__scopeSelect:t,children:n,open:s,defaultOpen:a,onOpenChange:o,value:i,defaultValue:l,onValueChange:u,dir:c,name:d,autoComplete:f,disabled:p,required:x,form:g}=e,m=Ra(t),[y,b]=h.useState(null),[v,N]=h.useState(null),[w,j]=h.useState(!1),k=Ud(c),[_,P]=Ys({prop:s,defaultProp:a??!1,onChange:o,caller:Nn}),[T,$]=Ys({prop:i,defaultProp:l,onChange:u,caller:Nn}),B=h.useRef(null),D=y?g||!!y.closest("form"):!0,[R,S]=h.useState(new Set),C=Array.from(R).map(E=>E.props.value).join(";");return r.jsx(pw,{...m,children:r.jsxs(c1,{required:x,scope:t,trigger:y,onTriggerChange:b,valueNode:v,onValueNodeChange:N,valueNodeHasChildren:w,onValueNodeHasChildrenChange:j,contentId:st(),value:T,onValueChange:$,open:_,onOpenChange:P,dir:k,triggerPointerDownPosRef:B,disabled:p,children:[r.jsx(Ca.Provider,{scope:t,children:r.jsx(u1,{scope:e.__scopeSelect,onNativeOptionAdd:h.useCallback(E=>{S(A=>new Set(A).add(E))},[]),onNativeOptionRemove:h.useCallback(E=>{S(A=>{const O=new Set(A);return O.delete(E),O})},[]),children:n})}),D?r.jsxs(mf,{"aria-hidden":!0,required:x,tabIndex:-1,name:d,autoComplete:f,value:T,onChange:E=>$(E.target.value),disabled:p,form:g,children:[T===void 0?r.jsx("option",{value:""}):null,Array.from(R)]},C):null]})})};Vh.displayName=Nn;var qh="SelectTrigger",Wh=h.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:s=!1,...a}=e,o=Ra(n),i=rn(qh,n),l=i.disabled||s,u=Me(t,i.onTriggerChange),c=Ta(n),d=h.useRef("touch"),[f,p,x]=gf(m=>{const y=c().filter(N=>!N.disabled),b=y.find(N=>N.value===i.value),v=yf(y,m,b);v!==void 0&&i.onValueChange(v.value)}),g=m=>{l||(i.onOpenChange(!0),x()),m&&(i.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return r.jsx(mw,{asChild:!0,...o,children:r.jsx(ke.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":xf(i.value)?"":void 0,...a,ref:u,onClick:Se(a.onClick,m=>{m.currentTarget.focus(),d.current!=="mouse"&&g(m)}),onPointerDown:Se(a.onPointerDown,m=>{d.current=m.pointerType;const y=m.target;y.hasPointerCapture(m.pointerId)&&y.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(g(m),m.preventDefault())}),onKeyDown:Se(a.onKeyDown,m=>{const y=f.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&p(m.key),!(y&&m.key===" ")&&o1.includes(m.key)&&(g(),m.preventDefault())})})})});Wh.displayName=qh;var Gh="SelectValue",Kh=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,children:o,placeholder:i="",...l}=e,u=rn(Gh,n),{onValueNodeHasChildrenChange:c}=u,d=o!==void 0,f=Me(t,u.onValueNodeChange);return Ue(()=>{c(d)},[c,d]),r.jsx(ke.span,{...l,ref:f,style:{pointerEvents:"none"},children:xf(u.value)?r.jsx(r.Fragment,{children:i}):o})});Kh.displayName=Gh;var h1="SelectIcon",Yh=h.forwardRef((e,t)=>{const{__scopeSelect:n,children:s,...a}=e;return r.jsx(ke.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});Yh.displayName=h1;var f1="SelectPortal",Xh=e=>r.jsx(Wi,{asChild:!0,...e});Xh.displayName=f1;var Sn="SelectContent",Zh=h.forwardRef((e,t)=>{const n=rn(Sn,e.__scopeSelect),[s,a]=h.useState();if(Ue(()=>{a(new DocumentFragment)},[]),!n.open){const o=s;return o?ir.createPortal(r.jsx(Jh,{scope:e.__scopeSelect,children:r.jsx(Ca.Slot,{scope:e.__scopeSelect,children:r.jsx("div",{children:e.children})})}),o):null}return r.jsx(Qh,{...e,ref:t})});Zh.displayName=Sn;var at=10,[Jh,sn]=fr(Sn),p1="SelectContentImpl",m1=Dr("SelectContent.RemoveScroll"),Qh=h.forwardRef((e,t)=>{const{__scopeSelect:n,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:o,onPointerDownOutside:i,side:l,sideOffset:u,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:x,sticky:g,hideWhenDetached:m,avoidCollisions:y,...b}=e,v=rn(Sn,n),[N,w]=h.useState(null),[j,k]=h.useState(null),_=Me(t,G=>w(G)),[P,T]=h.useState(null),[$,B]=h.useState(null),D=Ta(n),[R,S]=h.useState(!1),C=h.useRef(!1);h.useEffect(()=>{if(N)return Lh(N)},[N]),uh();const E=h.useCallback(G=>{const[J,...ee]=D().map(ie=>ie.ref.current),[te]=ee.slice(-1),oe=document.activeElement;for(const ie of G)if(ie===oe||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===J&&j&&(j.scrollTop=0),ie===te&&j&&(j.scrollTop=j.scrollHeight),ie==null||ie.focus(),document.activeElement!==oe))return},[D,j]),A=h.useCallback(()=>E([P,N]),[E,P,N]);h.useEffect(()=>{R&&A()},[R,A]);const{onOpenChange:O,triggerPointerDownPosRef:I}=v;h.useEffect(()=>{if(N){let G={x:0,y:0};const J=te=>{var oe,ie;G={x:Math.abs(Math.round(te.pageX)-(((oe=I.current)==null?void 0:oe.x)??0)),y:Math.abs(Math.round(te.pageY)-(((ie=I.current)==null?void 0:ie.y)??0))}},ee=te=>{G.x<=10&&G.y<=10?te.preventDefault():N.contains(te.target)||O(!1),document.removeEventListener("pointermove",J),I.current=null};return I.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",ee,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",ee,{capture:!0})}}},[N,O,I]),h.useEffect(()=>{const G=()=>O(!1);return window.addEventListener("blur",G),window.addEventListener("resize",G),()=>{window.removeEventListener("blur",G),window.removeEventListener("resize",G)}},[O]);const[F,L]=gf(G=>{const J=D().filter(oe=>!oe.disabled),ee=J.find(oe=>oe.ref.current===document.activeElement),te=yf(J,G,ee);te&&setTimeout(()=>te.ref.current.focus())}),M=h.useCallback((G,J,ee)=>{const te=!C.current&&!ee;(v.value!==void 0&&v.value===J||te)&&(T(G),te&&(C.current=!0))},[v.value]),z=h.useCallback(()=>N==null?void 0:N.focus(),[N]),H=h.useCallback((G,J,ee)=>{const te=!C.current&&!ee;(v.value!==void 0&&v.value===J||te)&&B(G)},[v.value]),V=s==="popper"?Vo:ef,Z=V===Vo?{side:l,sideOffset:u,align:c,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:x,sticky:g,hideWhenDetached:m,avoidCollisions:y}:{};return r.jsx(Jh,{scope:n,content:N,viewport:j,onViewportChange:k,itemRefCallback:M,selectedItem:P,onItemLeave:z,itemTextRefCallback:H,focusSelectedItem:A,selectedItemText:$,position:s,isPositioned:R,searchRef:F,children:r.jsx(Gi,{as:m1,allowPinchZoom:!0,children:r.jsx(Di,{asChild:!0,trapped:v.open,onMountAutoFocus:G=>{G.preventDefault()},onUnmountAutoFocus:Se(a,G=>{var J;(J=v.trigger)==null||J.focus({preventScroll:!0}),G.preventDefault()}),children:r.jsx(Li,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:i,onFocusOutside:G=>G.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:r.jsx(V,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:G=>G.preventDefault(),...b,...Z,onPlaced:()=>S(!0),ref:_,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:Se(b.onKeyDown,G=>{const J=G.ctrlKey||G.altKey||G.metaKey;if(G.key==="Tab"&&G.preventDefault(),!J&&G.key.length===1&&L(G.key),["ArrowUp","ArrowDown","Home","End"].includes(G.key)){let te=D().filter(oe=>!oe.disabled).map(oe=>oe.ref.current);if(["ArrowUp","End"].includes(G.key)&&(te=te.slice().reverse()),["ArrowUp","ArrowDown"].includes(G.key)){const oe=G.target,ie=te.indexOf(oe);te=te.slice(ie+1)}setTimeout(()=>E(te)),G.preventDefault()}})})})})})})});Qh.displayName=p1;var x1="SelectItemAlignedPosition",ef=h.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:s,...a}=e,o=rn(Sn,n),i=sn(Sn,n),[l,u]=h.useState(null),[c,d]=h.useState(null),f=Me(t,_=>d(_)),p=Ta(n),x=h.useRef(!1),g=h.useRef(!0),{viewport:m,selectedItem:y,selectedItemText:b,focusSelectedItem:v}=i,N=h.useCallback(()=>{if(o.trigger&&o.valueNode&&l&&c&&m&&y&&b){const _=o.trigger.getBoundingClientRect(),P=c.getBoundingClientRect(),T=o.valueNode.getBoundingClientRect(),$=b.getBoundingClientRect();if(o.dir!=="rtl"){const oe=$.left-P.left,ie=T.left-oe,me=_.left-ie,W=_.width+me,fe=Math.max(W,P.width),Ae=window.innerWidth-at,ge=Ks(ie,[at,Math.max(at,Ae-fe)]);l.style.minWidth=W+"px",l.style.left=ge+"px"}else{const oe=P.right-$.right,ie=window.innerWidth-T.right-oe,me=window.innerWidth-_.right-ie,W=_.width+me,fe=Math.max(W,P.width),Ae=window.innerWidth-at,ge=Ks(ie,[at,Math.max(at,Ae-fe)]);l.style.minWidth=W+"px",l.style.right=ge+"px"}const B=p(),D=window.innerHeight-at*2,R=m.scrollHeight,S=window.getComputedStyle(c),C=parseInt(S.borderTopWidth,10),E=parseInt(S.paddingTop,10),A=parseInt(S.borderBottomWidth,10),O=parseInt(S.paddingBottom,10),I=C+E+R+O+A,F=Math.min(y.offsetHeight*5,I),L=window.getComputedStyle(m),M=parseInt(L.paddingTop,10),z=parseInt(L.paddingBottom,10),H=_.top+_.height/2-at,V=D-H,Z=y.offsetHeight/2,G=y.offsetTop+Z,J=C+E+G,ee=I-J;if(J<=H){const oe=B.length>0&&y===B[B.length-1].ref.current;l.style.bottom="0px";const ie=c.clientHeight-m.offsetTop-m.offsetHeight,me=Math.max(V,Z+(oe?z:0)+ie+A),W=J+me;l.style.height=W+"px"}else{const oe=B.length>0&&y===B[0].ref.current;l.style.top="0px";const me=Math.max(H,C+m.offsetTop+(oe?M:0)+Z)+ee;l.style.height=me+"px",m.scrollTop=J-H+m.offsetTop}l.style.margin=`${at}px 0`,l.style.minHeight=F+"px",l.style.maxHeight=D+"px",s==null||s(),requestAnimationFrame(()=>x.current=!0)}},[p,o.trigger,o.valueNode,l,c,m,y,b,o.dir,s]);Ue(()=>N(),[N]);const[w,j]=h.useState();Ue(()=>{c&&j(window.getComputedStyle(c).zIndex)},[c]);const k=h.useCallback(_=>{_&&g.current===!0&&(N(),v==null||v(),g.current=!1)},[N,v]);return r.jsx(y1,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:x,onScrollButtonChange:k,children:r.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:r.jsx(ke.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});ef.displayName=x1;var g1="SelectPopperPosition",Vo=h.forwardRef((e,t)=>{const{__scopeSelect:n,align:s="start",collisionPadding:a=at,...o}=e,i=Ra(n);return r.jsx(xw,{...i,...o,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...o.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)"}})});Vo.displayName=g1;var[y1,Ki]=fr(Sn,{}),qo="SelectViewport",tf=h.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:s,...a}=e,o=sn(qo,n),i=Ki(qo,n),l=Me(t,o.onViewportChange),u=h.useRef(0);return r.jsxs(r.Fragment,{children:[r.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:s}),r.jsx(Ca.Slot,{scope:n,children:r.jsx(ke.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Se(a.onScroll,c=>{const d=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:p}=i;if(p!=null&&p.current&&f){const x=Math.abs(u.current-d.scrollTop);if(x>0){const g=window.innerHeight-at*2,m=parseFloat(f.style.minHeight),y=parseFloat(f.style.height),b=Math.max(m,y);if(b<g){const v=b+x,N=Math.min(g,v),w=v-N;f.style.height=N+"px",f.style.bottom==="0px"&&(d.scrollTop=w>0?w:0,f.style.justifyContent="flex-end")}}}u.current=d.scrollTop})})})]})});tf.displayName=qo;var nf="SelectGroup",[b1,v1]=fr(nf),w1=h.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=st();return r.jsx(b1,{scope:n,id:a,children:r.jsx(ke.div,{role:"group","aria-labelledby":a,...s,ref:t})})});w1.displayName=nf;var rf="SelectLabel",sf=h.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=v1(rf,n);return r.jsx(ke.div,{id:a.id,...s,ref:t})});sf.displayName=rf;var ea="SelectItem",[N1,af]=fr(ea),of=h.forwardRef((e,t)=>{const{__scopeSelect:n,value:s,disabled:a=!1,textValue:o,...i}=e,l=rn(ea,n),u=sn(ea,n),c=l.value===s,[d,f]=h.useState(o??""),[p,x]=h.useState(!1),g=Me(t,v=>{var N;return(N=u.itemRefCallback)==null?void 0:N.call(u,v,s,a)}),m=st(),y=h.useRef("touch"),b=()=>{a||(l.onValueChange(s),l.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(N1,{scope:n,value:s,disabled:a,textId:m,isSelected:c,onItemTextChange:h.useCallback(v=>{f(N=>N||((v==null?void 0:v.textContent)??"").trim())},[]),children:r.jsx(Ca.ItemSlot,{scope:n,value:s,disabled:a,textValue:d,children:r.jsx(ke.div,{role:"option","aria-labelledby":m,"data-highlighted":p?"":void 0,"aria-selected":c&&p,"data-state":c?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...i,ref:g,onFocus:Se(i.onFocus,()=>x(!0)),onBlur:Se(i.onBlur,()=>x(!1)),onClick:Se(i.onClick,()=>{y.current!=="mouse"&&b()}),onPointerUp:Se(i.onPointerUp,()=>{y.current==="mouse"&&b()}),onPointerDown:Se(i.onPointerDown,v=>{y.current=v.pointerType}),onPointerMove:Se(i.onPointerMove,v=>{var N;y.current=v.pointerType,a?(N=u.onItemLeave)==null||N.call(u):y.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Se(i.onPointerLeave,v=>{var N;v.currentTarget===document.activeElement&&((N=u.onItemLeave)==null||N.call(u))}),onKeyDown:Se(i.onKeyDown,v=>{var w;((w=u.searchRef)==null?void 0:w.current)!==""&&v.key===" "||(i1.includes(v.key)&&b(),v.key===" "&&v.preventDefault())})})})})});of.displayName=ea;var Cr="SelectItemText",lf=h.forwardRef((e,t)=>{const{__scopeSelect:n,className:s,style:a,...o}=e,i=rn(Cr,n),l=sn(Cr,n),u=af(Cr,n),c=d1(Cr,n),[d,f]=h.useState(null),p=Me(t,b=>f(b),u.onItemTextChange,b=>{var v;return(v=l.itemTextRefCallback)==null?void 0:v.call(l,b,u.value,u.disabled)}),x=d==null?void 0:d.textContent,g=h.useMemo(()=>r.jsx("option",{value:u.value,disabled:u.disabled,children:x},u.value),[u.disabled,u.value,x]),{onNativeOptionAdd:m,onNativeOptionRemove:y}=c;return Ue(()=>(m(g),()=>y(g)),[m,y,g]),r.jsxs(r.Fragment,{children:[r.jsx(ke.span,{id:u.textId,...o,ref:p}),u.isSelected&&i.valueNode&&!i.valueNodeHasChildren?ir.createPortal(o.children,i.valueNode):null]})});lf.displayName=Cr;var cf="SelectItemIndicator",uf=h.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return af(cf,n).isSelected?r.jsx(ke.span,{"aria-hidden":!0,...s,ref:t}):null});uf.displayName=cf;var Wo="SelectScrollUpButton",df=h.forwardRef((e,t)=>{const n=sn(Wo,e.__scopeSelect),s=Ki(Wo,e.__scopeSelect),[a,o]=h.useState(!1),i=Me(t,s.onScrollButtonChange);return Ue(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=u.scrollTop>0;o(c)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),a?r.jsx(ff,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});df.displayName=Wo;var Go="SelectScrollDownButton",hf=h.forwardRef((e,t)=>{const n=sn(Go,e.__scopeSelect),s=Ki(Go,e.__scopeSelect),[a,o]=h.useState(!1),i=Me(t,s.onScrollButtonChange);return Ue(()=>{if(n.viewport&&n.isPositioned){let l=function(){const c=u.scrollHeight-u.clientHeight,d=Math.ceil(u.scrollTop)<c;o(d)};const u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),a?r.jsx(ff,{...e,ref:i,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=n;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});hf.displayName=Go;var ff=h.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:s,...a}=e,o=sn("SelectScrollButton",n),i=h.useRef(null),l=Ta(n),u=h.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return h.useEffect(()=>()=>u(),[u]),Ue(()=>{var d;const c=l().find(f=>f.ref.current===document.activeElement);(d=c==null?void 0:c.ref.current)==null||d.scrollIntoView({block:"nearest"})},[l]),r.jsx(ke.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:Se(a.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(s,50))}),onPointerMove:Se(a.onPointerMove,()=>{var c;(c=o.onItemLeave)==null||c.call(o),i.current===null&&(i.current=window.setInterval(s,50))}),onPointerLeave:Se(a.onPointerLeave,()=>{u()})})}),S1="SelectSeparator",pf=h.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e;return r.jsx(ke.div,{"aria-hidden":!0,...s,ref:t})});pf.displayName=S1;var Ko="SelectArrow",j1=h.forwardRef((e,t)=>{const{__scopeSelect:n,...s}=e,a=Ra(n),o=rn(Ko,n),i=sn(Ko,n);return o.open&&i.position==="popper"?r.jsx(gw,{...a,...s,ref:t}):null});j1.displayName=Ko;var k1="SelectBubbleInput",mf=h.forwardRef(({__scopeSelect:e,value:t,...n},s)=>{const a=h.useRef(null),o=Me(s,a),i=Vd(t);return h.useEffect(()=>{const l=a.current;if(!l)return;const u=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(u,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(l,t),l.dispatchEvent(f)}},[i,t]),r.jsx(ke.select,{...n,style:{...Ph,...n.style},ref:o,defaultValue:t})});mf.displayName=k1;function xf(e){return e===""||e===void 0}function gf(e){const t=vn(e),n=h.useRef(""),s=h.useRef(0),a=h.useCallback(i=>{const l=n.current+i;t(l),function u(c){n.current=c,window.clearTimeout(s.current),c!==""&&(s.current=window.setTimeout(()=>u(""),1e3))}(l)},[t]),o=h.useCallback(()=>{n.current="",window.clearTimeout(s.current)},[]);return h.useEffect(()=>()=>window.clearTimeout(s.current),[]),[n,a,o]}function yf(e,t,n){const a=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let i=E1(e,Math.max(o,0));a.length===1&&(i=i.filter(c=>c!==n));const u=i.find(c=>c.textValue.toLowerCase().startsWith(a.toLowerCase()));return u!==n?u:void 0}function E1(e,t){return e.map((n,s)=>e[(t+s)%e.length])}var _1=Vh,bf=Wh,C1=Kh,T1=Yh,R1=Xh,vf=Zh,A1=tf,wf=sf,Nf=of,M1=lf,I1=uf,Sf=df,jf=hf,kf=pf;const zr=_1,Fr=C1,er=h.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(bf,{ref:s,className:X("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-sm border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",Ne("data"),e),...n,children:[t,r.jsx(T1,{asChild:!0,children:r.jsx(Pr,{className:"h-4 w-4 opacity-50"})})]}));er.displayName=bf.displayName;const Ef=h.forwardRef(({className:e,...t},n)=>r.jsx(Sf,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Ro,{className:"h-4 w-4"})}));Ef.displayName=Sf.displayName;const _f=h.forwardRef(({className:e,...t},n)=>r.jsx(jf,{ref:n,className:X("flex cursor-default items-center justify-center py-1",e),...t,children:r.jsx(Pr,{className:"h-4 w-4"})}));_f.displayName=jf.displayName;const tr=h.forwardRef(({className:e,children:t,position:n="popper",...s},a)=>r.jsx(R1,{children:r.jsxs(vf,{ref:a,className:X("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-sm border bg-popover text-popover-foreground shadow-md 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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...s,children:[r.jsx(Ef,{}),r.jsx(A1,{className:X("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),r.jsx(_f,{})]})}));tr.displayName=vf.displayName;const P1=h.forwardRef(({className:e,...t},n)=>r.jsx(wf,{ref:n,className:X("px-2 py-1.5 text-sm",Ne("label"),e),...t}));P1.displayName=wf.displayName;const Yt=h.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(Nf,{ref:s,className:X("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",Ne("data"),e),...n,children:[r.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(I1,{children:r.jsx(Tg,{className:"h-4 w-4 text-primary"})})}),r.jsx(M1,{children:t})]}));Yt.displayName=Nf.displayName;const O1=h.forwardRef(({className:e,...t},n)=>r.jsx(kf,{ref:n,className:X("-mx-1 my-1 h-px bg-muted",e),...t}));O1.displayName=kf.displayName;const L1=[{name:"Steady",intensity:10,errorRate:1,latencyBase:50,attackFrequency:2,pattern:"steady",targetPath:null},{name:"Heavy Load",intensity:80,errorRate:2,latencyBase:120,attackFrequency:5,pattern:"steady",targetPath:null},{name:"Degraded",intensity:20,errorRate:35,latencyBase:450,attackFrequency:10,pattern:"sine",targetPath:null},{name:"DDoS Attack",intensity:100,errorRate:5,latencyBase:800,attackFrequency:80,pattern:"spiky",targetPath:"/api/v1/auth"}];function D1(){const{baseUrl:e}=je(),[t,n]=h.useState(null),[s,a]=h.useState(!1),o=async()=>{try{const d=await(await fetch(`${e}/_sensor/demo`)).json();n(d)}catch(c){console.error("Failed to fetch demo config:",c)}};h.useEffect(()=>{o()},[e]);const i=async c=>{if(t){a(!0);try{const f=await(await fetch(`${e}/_sensor/demo/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})).json();n(f)}catch(d){console.error("Failed to update demo config:",d)}finally{a(!1)}}},l=async()=>{a(!0);try{const d=await(await fetch(`${e}/_sensor/demo/toggle`,{method:"POST"})).json();n(d)}catch(c){console.error("Failed to toggle demo mode:",c)}finally{a(!1)}},u=async()=>{if(!(!(t!=null&&t.attack_sim)&&!confirm(`⚠️ DANGER: Attack Simulation
|
|
554
|
+
|
|
555
|
+
This will fire REAL attack payloads (SQLi, XSS, etc.) at the target. Ensure you have authorization.
|
|
556
|
+
|
|
557
|
+
Proceed?`))){a(!0);try{const c=await fetch(`${e}/_sensor/demo/attack-sim/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intervalMs:2e3})});if(!c.ok)throw new Error(`Server error: ${c.status}`);const d=await c.json();n(f=>f?{...f,attack_sim:d.attack_sim}:null)}catch(c){console.error("Failed to toggle attack sim:",c)}finally{a(!1)}}};return t?r.jsxs(se,{variant:"panel",className:"flex h-full flex-col overflow-hidden",children:[r.jsx(ce,{className:"flex-none border-b border-neutral-800/30 pb-3 mb-0 bg-neutral-900/30",children:r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs(de,{className:"flex items-center gap-2 text-sm uppercase tracking-widest font-mono",children:[r.jsx(Ni,{className:X("h-4 w-4",t.enabled?"text-warning-500 animate-pulse":"text-neutral-500")}),"Synthetic Traffic Engine"]}),r.jsxs(Q,{variant:t.enabled?"danger":"primary",size:"sm",className:"h-7 px-4 font-mono text-[10px]",onClick:l,disabled:s,children:[t.enabled?r.jsx(fd,{className:"h-3 w-3 mr-2"}):r.jsx(Ke,{className:"h-3 w-3 mr-2"}),t.enabled?"TERMINATE":"INITIALIZE"]})]})}),r.jsxs(ae,{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsxs("label",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-widest flex items-center gap-2",children:[r.jsx(Xg,{className:"h-3 w-3"}),"Generation Presets"]}),r.jsx("div",{className:"grid grid-cols-2 gap-2",children:L1.map(c=>r.jsx(Q,{type:"button",onClick:()=>i(c),variant:t.intensity===c.intensity&&t.pattern===c.pattern?"outline":"secondary",size:"sm",className:X("h-auto justify-start px-3 py-2 text-left text-[11px] font-mono",t.intensity===c.intensity&&t.pattern===c.pattern?"text-primary-400":"text-neutral-400"),children:c.name.toUpperCase()},c.name))})]}),r.jsxs("div",{className:"space-y-3 p-3 bg-danger-950/10 border border-danger-900/20 rounded-sm",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("label",{className:"text-[10px] font-mono text-danger-500 uppercase tracking-widest flex items-center gap-2 font-bold",children:[r.jsx(Fe,{className:X("h-3.5 w-3.5",t.attack_sim&&"animate-pulse")}),"Attack Simulation"]}),r.jsx(Q,{size:"sm",variant:t.attack_sim?"danger":"outline",className:"h-6 px-3 text-[9px] font-bold",onClick:u,disabled:s,children:t.attack_sim?"ACTIVE":"INITIALIZE"})]}),r.jsx("p",{className:"text-[10px] text-neutral-500 font-mono leading-tight",children:"Fires real payloads (SQLi, XSS, CmdI) from random IPs to test WAF/Sentinel efficacy."})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("label",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-widest flex items-center gap-2",children:[r.jsx(t0,{className:"h-3 w-3"}),"Traffic Pattern"]}),r.jsxs(zr,{value:t.pattern,onValueChange:c=>i({pattern:c}),children:[r.jsx(er,{className:"h-9 border-neutral-700 bg-neutral-900/60 text-[11px] uppercase text-neutral-200",children:r.jsx(Fr,{placeholder:"Select pattern"})}),r.jsxs(tr,{children:[r.jsx(Yt,{value:"steady",children:"STEADY"}),r.jsx(Yt,{value:"sine",children:"SINE"}),r.jsx(Yt,{value:"spiky",children:"SPIKY"})]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("label",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-widest flex items-center gap-2",children:[r.jsx(Ir,{className:"h-3 w-3"}),"Target Endpoint"]}),r.jsxs("div",{className:"relative",children:[r.jsx(Oi,{type:"text",value:t.targetPath||"",placeholder:"Random endpoints (default)",onChange:c=>n({...t,targetPath:c.target.value||null}),onBlur:()=>i({targetPath:t.targetPath}),className:"h-9 border-neutral-700 bg-neutral-900/60 text-[11px] text-primary-400 placeholder:text-neutral-600"}),t.targetPath&&r.jsx(Q,{type:"button",size:"sm",variant:"ghost",onClick:()=>i({targetPath:null}),className:"absolute right-1 top-1/2 h-6 -translate-y-1/2 px-2 text-[9px] text-neutral-600 hover:text-danger-400",children:"CLEAR"})]})]}),r.jsxs("div",{className:"space-y-5",children:[r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between text-[11px] font-mono",children:[r.jsxs("span",{className:"text-neutral-400 uppercase tracking-wider flex items-center gap-2",children:[r.jsx(It,{className:"h-3 w-3 text-primary-500"}),"Throughput Intensity"]}),r.jsxs("span",{className:"text-primary-400",children:[t.intensity,"%"]})]}),r.jsx(Hn,{value:[t.intensity],min:1,max:100,step:1,onValueChange:([c])=>n({...t,intensity:c}),onValueCommit:([c])=>i({intensity:c})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between text-[11px] font-mono",children:[r.jsxs("span",{className:"text-neutral-400 uppercase tracking-wider flex items-center gap-2",children:[r.jsx(Zt,{className:"h-3 w-3 text-danger-500"}),"Error Probability"]}),r.jsxs("span",{className:"text-danger-400",children:[t.errorRate,"%"]})]}),r.jsx(Hn,{value:[t.errorRate],min:0,max:100,step:1,onValueChange:([c])=>n({...t,errorRate:c}),onValueCommit:([c])=>i({errorRate:c})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between text-[11px] font-mono",children:[r.jsxs("span",{className:"text-neutral-400 uppercase tracking-wider flex items-center gap-2",children:[r.jsx(Mg,{className:"h-3 w-3 text-warning-500"}),"Latency Base"]}),r.jsxs("span",{className:"text-warning-400",children:[t.latencyBase,"ms"]})]}),r.jsx(Hn,{value:[t.latencyBase],min:10,max:2e3,step:10,onValueChange:([c])=>n({...t,latencyBase:c}),onValueCommit:([c])=>i({latencyBase:c})})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex justify-between text-[11px] font-mono",children:[r.jsxs("span",{className:"text-neutral-400 uppercase tracking-wider flex items-center gap-2",children:[r.jsx(It,{className:"h-3 w-3 text-info-500"}),"Attack Frequency"]}),r.jsxs("span",{className:"text-info-400",children:[t.attackFrequency,"%"]})]}),r.jsx(Hn,{value:[t.attackFrequency],min:0,max:100,step:1,onValueChange:([c])=>n({...t,attackFrequency:c}),onValueCommit:([c])=>i({attackFrequency:c})})]})]})]}),r.jsx("div",{className:"p-4 border-t border-neutral-800 bg-black/20",children:r.jsxs("div",{className:"text-[10px] font-mono text-neutral-600 uppercase leading-relaxed",children:["Traffic Generator affects all SSE streams and dashboard telemetry. Mode: ",r.jsx("span",{className:"text-primary-400",children:t.pattern}),t.targetPath&&r.jsxs("span",{className:"ml-2",children:["Target: ",r.jsx("span",{className:"text-warning-400",children:t.targetPath})]})]})})]}):null}function $1(){var x;const{events:e}=Ii(500),[t,n]=h.useState(!1),[s,a]=h.useState(new Set(["2xx","3xx","4xx","5xx"])),[o,i]=h.useState(!0),l=h.useRef(null),u=g=>{const m=new Set(s);m.has(g)?m.delete(g):m.add(g),a(m)},c=h.useMemo(()=>e.filter(g=>{const m=`${Math.floor(g.status/100)}xx`;return s.has(m)}),[e,s]),d=h.useMemo(()=>{const g=e.length;if(g===0)return{rps:0,errorRate:0,avgLatency:0};const m=e.filter(w=>w.status>=400).length,y=e.reduce((w,j)=>w+(j.latencyMs||0),0),b=new Date(e[0].timestamp).getTime(),v=new Date(e[e.length-1].timestamp).getTime(),N=Math.max((b-v)/1e3,1);return{rps:Math.round(g/N),errorRate:Math.round(m/g*100),avgLatency:Math.round(y/g)}},[e]),f=(x=c[0])==null?void 0:x.id;h.useEffect(()=>{if(!o)return;const g=l.current;g&&(g.scrollTop=0)},[o,f]);const p=()=>{i(g=>{const m=!g;return m&&l.current&&(l.current.scrollTop=0),m})};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500 h-[calc(100vh-140px)] flex flex-col",children:[r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Traffic Monitor"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2 type-body",children:"Real-time HTTP telemetry and latency analysis."})]}),r.jsxs("div",{className:"flex gap-6 items-center bg-neutral-900/50 p-3 rounded-lg border border-neutral-800",children:[r.jsxs("div",{className:"text-right",children:[r.jsx("span",{className:"text-[10px] text-neutral-500 uppercase block type-tag",children:"Throughput"}),r.jsxs("span",{className:"text-xl text-primary-400 type-metric",children:[d.rps," RPS"]})]}),r.jsx("div",{className:"h-8 w-px bg-neutral-800"}),r.jsxs("div",{className:"text-right",children:[r.jsx("span",{className:"text-[10px] text-neutral-500 uppercase block type-tag",children:"Error Rate"}),r.jsxs("span",{className:X("text-xl type-metric",d.errorRate>5?"text-danger-500":"text-success-500"),children:[d.errorRate,"%"]})]}),r.jsx("div",{className:"h-8 w-px bg-neutral-800"}),r.jsxs("div",{className:"text-right",children:[r.jsx("span",{className:"text-[10px] text-neutral-500 uppercase block type-tag",children:"Avg Latency"}),r.jsxs("span",{className:"text-xl text-warning-400 type-metric",children:[d.avgLatency,"ms"]})]})]})]}),r.jsx("div",{className:"flex-none h-[320px] lg:h-[340px]",children:r.jsx(D1,{})}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 flex-1 min-h-0 overflow-hidden",children:[r.jsx("div",{className:"lg:col-span-8 h-full flex flex-col gap-4 min-h-0",children:r.jsxs(se,{variant:"panel",glow:"info",kinetic:!0,className:"flex-1 relative overflow-hidden flex flex-col min-h-0",children:[r.jsxs("div",{className:"absolute top-4 right-4 z-10 flex gap-2",children:[["2xx","3xx","4xx","5xx"].map(g=>r.jsx("button",{onClick:()=>u(g),"aria-pressed":s.has(g),"aria-label":`Filter ${g} responses`,className:X("px-2 py-1 text-[10px] type-tag rounded border transition-all",s.has(g)?g==="2xx"?"bg-success-900/30 border-success-500 text-success-400":g==="3xx"?"bg-info-900/30 border-info-500 text-info-400":g==="4xx"?"bg-warning-900/30 border-warning-500 text-warning-400":"bg-danger-900/30 border-danger-500 text-danger-400":"bg-transparent border-neutral-800 text-neutral-600"),children:g.toUpperCase()},g)),r.jsx("div",{className:"w-px h-6 bg-neutral-800 mx-2"}),r.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>n(!t),"aria-label":t?"Resume traffic stream":"Pause traffic stream",children:t?r.jsx(Ke,{className:"h-3 w-3"}):r.jsx(Jn,{className:"h-3 w-3"})})]}),r.jsx(z1,{events:t?[]:c,paused:t})]})}),r.jsxs(se,{variant:"glass",className:"lg:col-span-4 h-full flex flex-col min-h-0",children:[r.jsx(ce,{className:"flex-none border-b border-white/5 pb-3",children:r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx(de,{className:"text-xs",children:"Live Feed"}),r.jsx(Q,{type:"button",size:"sm",variant:"secondary",onClick:p,"aria-pressed":o,className:"h-7 px-2 text-[10px]",children:o?r.jsxs(r.Fragment,{children:[r.jsx(Jn,{className:"h-3 w-3 mr-1"}),"Stop Auto-Scrolling"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ke,{className:"h-3 w-3 mr-1"}),"Resume Auto-Scrolling"]})})]})}),r.jsx(ae,{ref:l,className:"flex-1 overflow-y-auto p-0 min-h-0",children:r.jsx("div",{className:"text-[11px] type-data",children:c.slice(0,50).map(g=>{const m=g.status>=500,y=g.status>=400&&g.status<500;return r.jsxs("div",{className:X("p-3 flex justify-between items-center group transition-colors relative border-b border-white/5 last:border-b-0",m?"bg-danger/5 hover:bg-danger/10":y?"bg-warning/5 hover:bg-warning/10":"hover:bg-neutral-900/50"),children:[r.jsxs("div",{className:"flex flex-col gap-1 overflow-hidden pr-8",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(ue,{size:"sm",variant:m?"danger":y?"warning":g.status>=300?"info":"success",children:[g.method," ",g.status]}),r.jsxs("span",{className:"text-neutral-400 font-medium",children:[g.latencyMs,"ms"]})]}),r.jsx("span",{className:"text-neutral-200 truncate font-medium",title:g.path,children:g.path})]}),r.jsx("button",{onClick:()=>ns(g),className:"absolute right-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity p-1 hover:bg-primary/10 rounded-sm text-primary/60 hover:text-primary outline-none focus:ring-2 focus:ring-primary/50",title:"Analyze request in CyberChef","aria-label":`Analyze request ${g.id} in CyberChef`,children:r.jsx(Zr,{className:"h-3 w-3"})})]},g.id)})})})]})]})]})}const io=1e3,lo=1e4,Ec=2e3;function z1({events:e,paused:t}){const n=h.useRef(null),s=h.useRef(e);return h.useEffect(()=>{s.current=e},[e]),h.useEffect(()=>{const a=n.current;if(!a)return;const o=a.getContext("2d");if(!o)return;const i=window.devicePixelRatio||1,l=()=>{if(a.parentElement){const{clientWidth:d,clientHeight:f}=a.parentElement;a.width=d*i,a.height=f*i,o.setTransform(i,0,0,i,0,0)}};window.addEventListener("resize",l),l();let u;const c=()=>{if(document.hidden||!a.parentElement)return;const d=a.parentElement.clientWidth,f=a.parentElement.clientHeight;o.clearRect(0,0,d,f),o.strokeStyle="rgba(31, 38, 51, 0.3)",o.lineWidth=1,o.beginPath();const p=[200,400,600,800];for(const g of p){const m=f-Math.min(g/io*f,f-20);o.moveTo(0,m),o.lineTo(d,m)}o.stroke(),o.fillStyle="rgba(112, 128, 153, 0.8)",o.font="11px JetBrains Mono";for(const g of p){const m=f-Math.min(g/io*f,f-20);o.fillText(`${g}ms`,8,m-6)}const x=Date.now();for(const g of s.current){const m=new Date(g.timestamp).getTime(),y=x-m;if(y>lo)break;const b=d-y/lo*d,v=f-Math.min(g.latencyMs/io*f,f-20);let N="#00FF94";if(g.status>=500?N="#FF0055":g.status>=400?N="#FFB800":g.status>=300&&(N="#00A3FF"),o.fillStyle=N,o.beginPath(),o.arc(b,v,2,0,Math.PI*2),o.fill(),y<Ec){const w=1-y/Ec;o.font="11px JetBrains Mono",o.shadowBlur=4,o.shadowColor="rgba(0,0,0,0.8)",o.fillStyle=`rgba(255, 255, 255, ${w})`,o.fillText(`${g.method} ${g.path}`,b+8,v+4),o.shadowBlur=0}}t||(u=requestAnimationFrame(c))};return c(),()=>{window.removeEventListener("resize",l),u&&cancelAnimationFrame(u)}},[t]),r.jsx("canvas",{ref:n,className:"w-full h-full block",role:"img","aria-label":`Traffic waterfall chart showing ${e.length} requests over the last ${lo/1e3} seconds`})}function F1(e){const{baseUrl:t}=je(),[n,s]=h.useState([]),[a,o]=h.useState(!1),i=h.useCallback(async()=>{if(!(!t||!e)){o(!0);try{const c=await fetch(`${t}/hooks/${e}/inspect`);if(c.ok){const d=await c.json();s(d)}}catch(c){console.error(c)}finally{o(!1)}}},[t,e]);h.useEffect(()=>{e?i():s([])},[i,e]);const{subscribe:l,status:u}=ts(`${t}/sse`,{enabled:!!t});return h.useEffect(()=>u!=="connected"||!e?void 0:l("webhook",d=>{d.hookId===e&&s(f=>[d,...f].slice(0,50))}),[u,l,e]),{requests:n,isLoading:a,refresh:i,isConnected:u==="connected"}}function B1(){const{baseUrl:e}=je(),[t,n]=h.useState(""),[s,a]=h.useState(null),[o,i]=h.useState(null),{requests:l,isConnected:u}=F1(s),c=h.useRef(!1);h.useEffect(()=>{if(!c.current){c.current=!0;const f=Math.random().toString(36).substring(2,10);n(f),a(f)}},[]);const d=()=>{!e||!s||navigator.clipboard.writeText(`${e}/hooks/${s}`)};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500 h-[calc(100vh-140px)] flex flex-col",children:[r.jsxs("div",{className:"flex justify-between items-end",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Webhook Inspector"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Capture and inspect HTTP callbacks."})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center bg-neutral-900 border border-neutral-800 rounded-lg p-1 pr-3 gap-2",children:[r.jsxs("div",{className:"px-3 py-1.5 bg-neutral-800 rounded text-xs font-mono text-neutral-300",children:["POST ",e,"/hooks/"]}),r.jsx("input",{type:"text",value:t,onChange:f=>n(f.target.value),className:"bg-transparent border-none text-white font-mono text-sm w-32 focus:outline-none",placeholder:"hook-id"}),r.jsx(Q,{size:"sm",variant:"ghost",onClick:()=>a(t),children:r.jsx(td,{className:"h-4 w-4"})})]}),r.jsxs(Q,{variant:"secondary",size:"sm",onClick:d,children:[r.jsx(Ig,{className:"h-4 w-4 mr-2"}),"Copy URL"]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 flex-1 min-h-0",children:[r.jsxs(se,{variant:"panel",glow:"info",className:"flex flex-col h-full",children:[r.jsx(ce,{className:"flex-none border-b border-neutral-800 pb-3",children:r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(de,{className:"text-sm font-mono uppercase",children:"Captured Requests"}),r.jsx(ue,{variant:u?"success":"neutral",dot:!0,children:u?"LIVE":"OFFLINE"})]})}),r.jsx(ae,{className:"flex-1 overflow-y-auto p-0",children:l.length===0?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-neutral-500 p-8 text-center",children:[r.jsx(Ci,{className:"h-12 w-12 mb-4 opacity-20"}),r.jsx("p",{className:"text-sm",children:"Waiting for requests..."}),r.jsxs("p",{className:"text-xs font-mono mt-2 bg-neutral-900 p-2 rounded",children:["curl -X POST ",e,"/hooks/",s," -d '",'{"hello":"world"}',"'"]})]}):r.jsx("div",{className:"divide-y divide-neutral-800/50",children:l.map((f,p)=>r.jsxs("button",{onClick:()=>i(f),className:X("w-full text-left p-3 hover:bg-neutral-900/50 transition-colors flex flex-col gap-1.5 border-l-2",o===f?"border-primary bg-primary/[0.08]":"border-transparent"),children:[r.jsxs("div",{className:"flex justify-between items-center w-full",children:[r.jsx(ue,{size:"sm",variant:f.method==="POST"?"info":"success",children:f.method}),r.jsx("span",{className:"text-[9px] font-mono text-neutral-600 font-bold uppercase tabular-nums",children:new Date(f.timestamp).toLocaleTimeString([],{hour12:!1})})]}),r.jsx("div",{className:X("text-[11px] font-mono truncate w-full",o===f?"text-primary font-bold":"text-neutral-400"),children:f.ip})]},p))})})]}),r.jsxs(se,{variant:"glass",glow:"info",className:"lg:col-span-2 h-full flex flex-col",children:[r.jsx(ce,{className:"flex-none border-b border-white/5 pb-3",children:r.jsx(de,{className:"text-sm font-mono uppercase",children:"Request Payload"})}),r.jsx(ae,{className:"flex-1 overflow-y-auto p-0 flex flex-col",children:o?r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4 p-6 border-b border-white/5 bg-black/20",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase block",children:"Timestamp"}),r.jsx("span",{className:"text-sm font-mono text-neutral-200",children:o.timestamp})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase block",children:"Source IP"}),r.jsx("span",{className:"text-sm font-mono text-primary-400",children:o.ip})]})]}),r.jsxs("div",{className:"p-6 border-b border-white/5",children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase block mb-2",children:"Headers"}),r.jsx("div",{className:"bg-black/40 rounded p-3 font-mono text-xs text-neutral-300 overflow-x-auto",children:Object.entries(o.headers).map(([f,p])=>r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("span",{className:"text-neutral-500",children:[f,":"]}),r.jsx("span",{className:"text-emerald-400",children:p})]},f))})]}),r.jsxs("div",{className:"flex-1 p-6",children:[r.jsxs("div",{className:"flex justify-between items-center mb-2",children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase block",children:"Body"}),r.jsxs(Q,{variant:"ghost",size:"sm",className:"h-6 text-[9px] text-primary-400 hover:text-primary-300",onClick:()=>o.body&&ns(o.body),children:[r.jsx(Zr,{className:"h-3 w-3 mr-1.5"}),"CyberChef",r.jsx(Ao,{className:"h-2.5 w-2.5 ml-1.5 opacity-50"})]})]}),r.jsx("pre",{className:"bg-black/40 rounded p-4 font-mono text-xs text-neutral-300 overflow-x-auto h-full border border-white/5",children:typeof o.body=="object"?JSON.stringify(o.body,null,2):o.body})]})]}):r.jsx("div",{className:"h-full flex items-center justify-center text-neutral-600 text-sm font-mono uppercase tracking-widest",children:"Select a request to inspect"})})]})]})]})}function H1(){const{baseUrl:e}=je(),[t,n]=h.useState(null),[s,a]=h.useState(!1),o=h.useCallback(async()=>{if(e)try{const u=await fetch(`${e}/mtd`);if(u.ok){const c=await u.json();n(c.currentPrefix||null)}}catch(u){console.error(u)}},[e]),i=h.useCallback(async u=>{if(e){a(!0);try{const c=await fetch(`${e}/mtd`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prefix:u})});if(c.ok){const d=await c.json();return n(d.prefix),d.prefix}}catch(c){console.error(c)}finally{a(!1)}}},[e]),l=h.useCallback(async()=>{await i("")},[i]);return h.useEffect(()=>{o()},[o]),{currentPrefix:t,isLoading:s,rotatePrefix:i,disableMTD:l,refresh:o}}function U1(){const{currentPrefix:e,rotatePrefix:t,disableMTD:n,isLoading:s}=H1(),[a,o]=h.useState(""),i=!!e,l=async()=>{await t(a||void 0),o("")};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{className:"flex justify-between items-end",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Moving Target Defense"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2 type-body",children:"Polymorphic route shifting to hide internal APIs."})]}),r.jsx(ue,{variant:i?"success":"neutral",dot:!0,children:i?"ACTIVE_DEFENSE":"MTD_DISABLED"})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[r.jsxs(se,{variant:"panel",glow:"primary",className:X("transition-colors",i?"border-primary-900/50":"border-neutral-800"),children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Qr,{className:X("h-4 w-4",i?"text-primary-500":"text-neutral-500")}),"Route Polymorphism"]}),r.jsx(Re,{children:"When active, all requests must be prefixed with a secret rotating token."})]}),r.jsxs(ae,{className:"space-y-6",children:[r.jsx("div",{className:"bg-black/40 rounded-lg p-8 flex flex-col items-center justify-center text-center border border-white/5",children:i?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-16 h-16 bg-primary-500/10 rounded-full flex items-center justify-center mb-4 border border-primary-500/30",children:r.jsx(ud,{className:"h-8 w-8 text-primary-400 animate-pulse"})}),r.jsx("span",{className:"text-xs type-tag text-neutral-500 uppercase tracking-widest mb-2",children:"Current Active Prefix"}),r.jsxs("div",{className:"text-4xl type-metric text-white tracking-tighter bg-neutral-900 px-6 py-2 rounded border border-neutral-800 select-all",children:["/",e]}),r.jsx("p",{className:"mt-4 text-xs text-neutral-400 max-w-sm",children:"All API requests without this prefix will return 404 Not Found."})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"w-16 h-16 bg-neutral-800/50 rounded-full flex items-center justify-center mb-4",children:r.jsx(Dg,{className:"h-8 w-8 text-neutral-600"})}),r.jsx("span",{className:"text-xs type-tag text-neutral-500 uppercase tracking-widest mb-2",children:"MTD is currently inactive"}),r.jsx("p",{className:"text-sm text-neutral-400 max-w-xs",children:"Activate polymorphism to scramble your API surface area."})]})}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"flex-1",children:r.jsx("input",{type:"text",value:a,onChange:u=>o(u.target.value),placeholder:"Optional custom prefix...",className:"w-full h-10 px-4 bg-neutral-900 border border-neutral-800 rounded text-sm font-mono text-white focus:outline-none focus:border-primary-500"})}),r.jsxs(Q,{variant:"primary",onClick:l,disabled:s,children:[r.jsx(va,{className:X("h-4 w-4 mr-2",s&&"animate-spin")}),i?"Rotate Prefix":"Enable MTD"]}),i&&r.jsx(Q,{variant:"outline",onClick:n,disabled:s,children:"Disable"})]})]})]}),i&&r.jsxs(se,{variant:"glass",children:[r.jsx(ce,{children:r.jsxs(de,{className:"text-xs flex items-center gap-2",children:[r.jsx(_i,{className:"h-3 w-3"}),"INTEGRATION GUIDE"]})}),r.jsx(ae,{children:r.jsxs("div",{className:"bg-black/60 p-4 rounded font-mono text-[11px] text-neutral-300",children:[r.jsx("div",{className:"text-neutral-500 mb-2",children:"// Update your client base URL"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("span",{className:"text-primary-400",children:"const"}),r.jsx("span",{className:"text-white",children:"API_URL = "}),r.jsxs("span",{className:"text-emerald-400",children:["`http://localhost:8090/",e,"`"]}),";"]}),r.jsx("div",{className:"mt-4 text-neutral-500 mb-2",children:"// All future calls:"}),r.jsxs("div",{className:"text-white",children:["fetch(",r.jsx("span",{className:"text-emerald-400",children:"`${API_URL}/history`"}),");"]})]})})]})]}),r.jsx("div",{className:"space-y-6",children:r.jsxs(se,{variant:"panel",className:"bg-primary-950/10 border-primary-900/20",children:[r.jsx(ce,{children:r.jsxs(de,{className:"flex items-center gap-2 text-primary-400",children:[r.jsx(od,{className:"h-4 w-4"}),"What is MTD?"]})}),r.jsxs(ae,{className:"text-xs text-neutral-400 space-y-3 leading-relaxed",children:[r.jsxs("p",{children:[r.jsx("strong",{className:"text-neutral-200",children:"Moving Target Defense"})," shifts the attack surface faster than an adversary can probe it."]}),r.jsx("p",{children:"By constantly changing the valid entry points (routes), automated scanners and static scripts will fail to find your real endpoints."}),r.jsxs("div",{className:"flex items-start gap-2 p-3 bg-primary-500/5 rounded border border-primary-500/10 text-[10px]",children:[r.jsx(vi,{className:"h-3 w-3 text-primary-500 shrink-0 mt-0.5"}),r.jsx("span",{children:"This requires client-side synchronization. Your dashboard will attempt to auto-reconnect using the new prefix."})]})]})]})})]})]})}function V1(){const{baseUrl:e}=je(),[t,n]=h.useState(!1),[s,a]=h.useState(null);return{runScan:h.useCallback(async i=>{if(e){n(!0);try{const l=await fetch(`${e}/api/escape/scan`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!l.ok)throw new Error(l.statusText);const u=await l.json();a(u)}catch(l){console.error(l)}finally{n(!1)}}},[e]),lastResult:s,isLoading:t}}function q1(){const{baseUrl:e}=je(),[t,n]=h.useState(!1),[s,a]=h.useState(null),[o,i]=h.useState(null),l=h.useCallback(async()=>{try{return(await(await fetch(`${e}/api/lab/k6/scenarios`)).json()).scenarios||[]}catch(f){return console.error("Failed to list k6 scenarios:",f),[]}},[e]),u=h.useCallback(async()=>{try{return(await(await fetch(`${e}/api/lab/nuclei/templates`)).json()).templates||[]}catch(f){return console.error("Failed to list nuclei templates:",f),[]}},[e]),c=h.useCallback(async f=>{n(!0),i(null),a(null);try{const p=await fetch(`${e}/scenarios/k6-run/run`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:"k6-run",name:"K6 Load Test",steps:[{id:"1",action:"k6.run",params:f}]})});if(!p.ok)throw new Error("Failed to start k6 run");const x=await p.json();a(x)}catch(p){i(p.message)}finally{n(!1)}},[e]),d=h.useCallback(async f=>{n(!0),i(null),a(null);try{const p=await fetch(`${e}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Nuclei Scan",steps:[{id:"1",action:"nuclei.run",params:f}]})});if(!p.ok)throw new Error("Failed to create nuclei scenario");const x=await p.json(),m=await(await fetch(`${e}/scenarios/${x.id}/run`,{method:"POST"})).json();a(m)}catch(p){i(p.message)}finally{n(!1)}},[e]);return{listK6Scenarios:l,listNucleiTemplates:u,runK6:c,runNuclei:d,isLoading:t,result:s,error:o}}function W1(){const{baseUrl:e}=je(),[t,n]=h.useState(!1),[s,a]=h.useState(null),[o,i]=h.useState(null);return{runFuzzer:h.useCallback(async u=>{if(!e)return i("No base URL configured."),null;n(!0),i(null);try{const c=await fetch(`${e}/api/redteam/fuzzer/run`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),d=await c.json();if(!c.ok){const f=typeof(d==null?void 0:d.error)=="string"?d.error:`Request failed (${c.status})`;return i(f),null}return a(d),d}catch(c){const d=c instanceof Error?c.message:"Request failed";return i(d),null}finally{n(!1)}},[e]),lastResult:s,isLoading:t,error:o}}const _c=6e4;function Cc(e,t){const n=e.trim();if(n.length===0)return;let s;try{s=JSON.parse(n)}catch{throw new Error(`${t} must be valid JSON object syntax.`)}if(typeof s!="object"||s===null||Array.isArray(s))throw new Error(`${t} must be a JSON object.`);return s}function G1(e){if(!e)return;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string")throw new Error(`Header "${n}" must be a string value.`);t[n]=s}return t}function K1(e){if(!e)return;const t={};for(const[n,s]of Object.entries(e)){if(typeof s!="string"&&typeof s!="number"&&typeof s!="boolean")throw new Error(`Query "${n}" must be string, number, or boolean.`);t[n]=s}return t}function Y1(e,t){const n=e.trim();if(n.length!==0){if(t==="json")try{return JSON.parse(n)}catch{throw new Error("Body must be valid JSON when mode is JSON.")}return e}}function X1(e){const t=e.trim();if(t.length===0)return;const n=Number(t);if(Number.isNaN(n)||!Number.isFinite(n)||n<=0)throw new Error("Timeout must be a positive number.");const s=Math.round(n);if(s<=0)throw new Error("Timeout must be a positive number.");if(n>_c)throw new Error(`Timeout must be ${_c}ms or lower.`);return s}function Z1(e){const t=e.trim();if(t.length===0)return;if(!/^https?:\/\//i.test(t))throw new Error("Target must start with http:// or https://");let n;try{n=new URL(t)}catch{throw new Error("Target must be a valid http:// or https:// URL.")}if(!n.hostname)throw new Error("Target must include a hostname.");return t}function J1(e){const t=Cc(e.headersText,"Headers"),n=Cc(e.queryText,"Query");return{target:Z1(e.target),path:e.path.trim()||"/echo",method:e.method,headers:G1(t),query:K1(n),body:Y1(e.bodyText,e.bodyMode),timeoutMs:X1(e.timeoutText)}}const Tc={target:"",path:"/echo",method:"GET",headersText:`{
|
|
558
|
+
"X-Payload": "<script>alert(1)<\/script>"
|
|
559
|
+
}`,queryText:`{
|
|
560
|
+
"q": "<script>alert(1)<\/script>"
|
|
561
|
+
}`,bodyText:`{
|
|
562
|
+
"probe": "xss"
|
|
563
|
+
}`,bodyMode:"json",timeoutText:"5000"};function Q1(){const{runFuzzer:e,lastResult:t,isLoading:n,error:s}=W1(),[a,o]=h.useState(Tc),[i,l]=h.useState(null),u=(p,x)=>{o(g=>({...g,[p]:x}))},c=()=>{o(Tc),l(null)},d=p=>{/^\d*$/.test(p)&&u("timeoutText",p)},f=async p=>{if(p.preventDefault(),!n){l(null);try{const x=J1(a);await e(x)}catch(x){const g=x instanceof Error?x.message:"Invalid fuzzer request input.";l(g)}}};return r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsx("div",{children:r.jsxs(se,{variant:"glass",glow:"primary",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Ir,{"aria-hidden":"true",className:"h-4 w-4 text-primary-500"}),"Live Payload Fuzzer"]}),r.jsx(Re,{children:"Build one request, execute it, and inspect normalized response telemetry."})]}),r.jsx(ae,{children:r.jsxs("form",{onSubmit:f,className:"space-y-3","aria-label":"Live Payload Fuzzer",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fuzzer-target",className:"text-xs font-mono text-neutral-400 uppercase",children:"Target URL (Optional)"}),r.jsx("input",{id:"fuzzer-target",type:"text","aria-describedby":"fuzzer-target-hint",value:a.target,onChange:p=>u("target",p.target.value),placeholder:"http://127.0.0.1:8090",className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500"}),r.jsx("p",{id:"fuzzer-target-hint",className:"text-[10px] text-neutral-500 mt-1",children:"Targets are restricted server-side to localhost or APPARATUS_FUZZER_ALLOWED_TARGETS."})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fuzzer-method",className:"text-xs font-mono text-neutral-400 uppercase",children:"Method"}),r.jsxs(zr,{value:a.method,onValueChange:p=>u("method",p),children:[r.jsx(er,{id:"fuzzer-method",className:"w-full bg-neutral-900 border-neutral-800 text-neutral-300 h-9 font-mono text-xs mt-1",children:r.jsx(Fr,{placeholder:"Method"})}),r.jsx(tr,{className:"bg-neutral-900 border-neutral-800",children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(p=>r.jsx(Yt,{value:p,className:"text-neutral-300 hover:bg-neutral-800 cursor-pointer font-mono text-xs",children:p},p))})]})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fuzzer-timeout",className:"text-xs font-mono text-neutral-400 uppercase",children:"Timeout (ms)"}),r.jsx("input",{id:"fuzzer-timeout",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:a.timeoutText,onChange:p=>d(p.target.value),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500"}),r.jsx("p",{className:"text-[10px] text-neutral-500 mt-1",children:"Leave blank to use default timeout."})]})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fuzzer-path",className:"text-xs font-mono text-neutral-400 uppercase",children:"Path"}),r.jsx("input",{id:"fuzzer-path",type:"text",value:a.path,onChange:p=>u("path",p.target.value),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fuzzer-headers",className:"text-xs font-mono text-neutral-400 uppercase",children:"Headers (JSON Object)"}),r.jsx("textarea",{id:"fuzzer-headers","aria-describedby":"fuzzer-headers-hint",value:a.headersText,onChange:p=>u("headersText",p.target.value),rows:4,maxLength:16384,className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-xs font-mono text-white focus:outline-none focus:border-primary-500"}),r.jsxs("p",{id:"fuzzer-headers-hint",className:"text-[10px] text-neutral-500 mt-1",children:["Example: ",'{ "X-Test": "value" }']})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"fuzzer-query",className:"text-xs font-mono text-neutral-400 uppercase",children:"Query (JSON Object)"}),r.jsx("textarea",{id:"fuzzer-query","aria-describedby":"fuzzer-query-hint",value:a.queryText,onChange:p=>u("queryText",p.target.value),rows:4,maxLength:16384,className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-xs font-mono text-white focus:outline-none focus:border-primary-500"}),r.jsx("p",{id:"fuzzer-query-hint",className:"text-[10px] text-neutral-500 mt-1",children:"Values must be string, number, or boolean."})]}),r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("label",{htmlFor:"fuzzer-body",className:"text-xs font-mono text-neutral-400 uppercase",children:"Body"}),r.jsxs("div",{className:"flex items-center gap-2",role:"group","aria-label":"Body format",children:[r.jsx("button",{type:"button","aria-pressed":a.bodyMode==="json",onClick:()=>u("bodyMode","json"),className:`text-[10px] font-mono uppercase px-2 py-1 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 ${a.bodyMode==="json"?"border-primary-500 text-primary-300":"border-neutral-700 text-neutral-400"}`,children:"JSON"}),r.jsx("button",{type:"button","aria-pressed":a.bodyMode==="raw",onClick:()=>u("bodyMode","raw"),className:`text-[10px] font-mono uppercase px-2 py-1 rounded-sm border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 ${a.bodyMode==="raw"?"border-primary-500 text-primary-300":"border-neutral-700 text-neutral-400"}`,children:"Raw"})]})]}),r.jsx("textarea",{id:"fuzzer-body","aria-describedby":"fuzzer-body-hint",value:a.bodyText,onChange:p=>u("bodyText",p.target.value),rows:5,maxLength:65536,className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-xs font-mono text-white focus:outline-none focus:border-primary-500"}),r.jsx("p",{id:"fuzzer-body-hint",className:"text-[10px] text-neutral-500 mt-1",children:"JSON mode parses object/array values. Raw mode sends the exact string."})]}),(i||s)&&r.jsxs("div",{role:"alert",className:"rounded-sm border border-destructive-500/40 bg-destructive-500/10 p-2 text-xs text-destructive-300 flex items-start gap-2",children:[r.jsx(Zt,{"aria-hidden":"true",className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),r.jsx("span",{children:i||s})]}),r.jsxs("div",{className:"pt-2 flex gap-2",children:[r.jsx(Q,{type:"button",variant:"secondary",className:"w-28",onClick:c,disabled:n,children:"RESET"}),r.jsxs(Q,{type:"submit",variant:"default",className:"flex-1",isLoading:n,children:[n?"Executing...":"Run Payload",!n&&r.jsx(Ke,{className:"h-4 w-4 ml-2","aria-hidden":"true"})]})]})]})})]})}),r.jsx("div",{className:"lg:col-span-2",children:r.jsxs(se,{variant:"panel",className:"h-full min-h-[540px] flex flex-col",children:[r.jsx(ce,{className:"flex-none border-b border-neutral-800 pb-3",children:r.jsx(de,{children:"Live Fuzzer Result"})}),r.jsx(ae,{className:"flex-1 overflow-y-auto p-0","aria-live":"polite",children:n?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-neutral-500 p-8 text-center space-y-4",children:[r.jsx(Ir,{"aria-hidden":"true",className:"h-12 w-12 opacity-25 animate-pulse"}),r.jsx("p",{className:"text-xs font-mono uppercase tracking-wide",children:"Executing Payload..."})]}):t?r.jsxs("div",{className:"space-y-4 p-4 text-xs font-mono",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(ue,{variant:"secondary",children:t.request.method}),r.jsx(ue,{variant:"secondary",children:t.response.status==null?"NO STATUS":`HTTP ${t.response.status}`}),r.jsx(ue,{variant:t.response.blocked?"destructive":"secondary",children:t.response.blocked?"BLOCKED":"PASSED"}),r.jsx(ue,{variant:"secondary",children:`${t.response.durationMs}ms`}),r.jsx(ue,{variant:"secondary",children:`${t.response.bodyBytes} bytes`})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-neutral-400 uppercase text-[10px]",children:"Resolved Request"}),r.jsx("p",{className:"text-neutral-300 break-all",children:t.request.url}),r.jsxs("p",{className:"text-neutral-500",children:["timeout=",t.request.timeoutMs,"ms body=",t.request.hasBody?"yes":"no"]})]}),t.response.error&&r.jsxs("div",{className:"rounded-sm border border-destructive-500/40 bg-destructive-500/10 p-2 text-destructive-300",children:[r.jsx("p",{className:"uppercase text-[10px] mb-1",children:"Upstream Error"}),r.jsx("p",{children:t.response.error}),t.response.errorCode&&r.jsx("p",{className:"text-destructive-400 mt-1",children:`code=${t.response.errorCode}`})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("p",{className:"text-neutral-400 uppercase text-[10px]",children:"Response Headers"}),r.jsx("pre",{className:"p-2 bg-neutral-900/60 rounded-sm text-[11px] overflow-x-auto text-neutral-300 whitespace-pre-wrap break-all",children:JSON.stringify(t.response.headers??{},null,2)})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsxs("p",{className:"text-neutral-400 uppercase text-[10px]",children:["Body Preview ",t.response.bodyTruncated?"(truncated)":""]}),r.jsx("pre",{className:"p-2 bg-neutral-900/60 rounded-sm text-[11px] overflow-x-auto text-neutral-300 whitespace-pre-wrap break-all",children:t.response.bodyPreview||"[empty response body]"})]})]}):r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-neutral-600 p-8 text-center space-y-4",children:[r.jsx(Ir,{"aria-hidden":"true",className:"h-16 w-16 opacity-20"}),r.jsxs("div",{className:"max-w-md",children:[r.jsx("p",{className:"text-sm font-medium text-neutral-400",children:"Ready for One-Shot Payload Testing"}),r.jsx("p",{className:"text-xs text-neutral-600 mt-1",children:"Build a request on the left and execute it to inspect response status, block classification, latency, and captured body preview."})]})]})})]})})]})}function eN(){const{baseUrl:e}=je(),[t,n]=h.useState("/echo"),[s,a]=h.useState("GET"),[o,i]=h.useState(null),[l,u]=h.useState(!1),[c,d]=h.useState(new Set),f=async()=>{u(!0);try{const g=new URL(`${e}/redteam/validate`);g.searchParams.set("path",t),g.searchParams.set("method",s);const y=await(await fetch(g.toString())).json();i(y);const b=new Set;y.details.forEach(v=>{v.blocked||b.add(v.category)}),d(b)}catch(g){console.error("Validation failed:",g)}finally{u(!1)}},p=g=>{const m=new Set(c);m.has(g)?m.delete(g):m.add(g),d(m)},x=o?o.details.reduce((g,m)=>(g[m.category]||(g[m.category]=[]),g[m.category].push(m),g),{}):{};return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsxs(se,{variant:"glass",glow:"primary",children:[r.jsx(ce,{children:r.jsx(de,{className:"text-sm",children:"Validator Configuration"})}),r.jsxs(ae,{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase",children:"Target Path"}),r.jsx("input",{type:"text",value:t,onChange:g=>n(g.target.value),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase",children:"Method"}),r.jsx("select",{value:s,onChange:g=>a(g.target.value),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500",children:["GET","POST","PUT","DELETE"].map(g=>r.jsx("option",{value:g,children:g},g))})]}),r.jsxs(Q,{variant:"primary",className:"w-full",onClick:f,isLoading:l,children:[r.jsx(Jt,{className:"h-4 w-4 mr-2"}),"Scan Attack Surface"]})]})]}),r.jsx("div",{className:"lg:col-span-2",children:r.jsxs(se,{variant:"panel",className:"h-full flex flex-col",children:[r.jsx(ce,{className:"border-b border-white/5 bg-white/[0.01]",children:r.jsx(de,{className:"text-sm",children:"Validation Summary"})}),r.jsx(ae,{className:"flex-1 flex items-center justify-around p-6",children:o?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-3xl font-display font-bold text-white",children:o.summary.total}),r.jsx("div",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-widest",children:"Total Payloads"})]}),r.jsx("div",{className:"h-12 w-px bg-neutral-800"}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-3xl font-display font-bold text-success-500",children:o.summary.blocked}),r.jsx("div",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-widest",children:"Blocked (Secure)"})]}),r.jsx("div",{className:"h-12 w-px bg-neutral-800"}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-3xl font-display font-bold text-danger-500",children:o.summary.passed}),r.jsx("div",{className:"text-[10px] font-mono text-neutral-500 uppercase tracking-widest",children:"Passed (Vulnerable)"})]})]}):r.jsx("div",{className:"text-neutral-600 text-xs font-mono italic",children:"AWAITING_SCAN_INITIALIZATION"})})]})})]}),o&&r.jsx("div",{className:"space-y-3",children:Object.entries(x).map(([g,m])=>{const y=c.has(g),b=m.filter(v=>!v.blocked).length;return r.jsxs(se,{variant:"panel",className:X("border-l-4",b>0?"border-l-danger-500":"border-l-success-500"),children:[r.jsxs("button",{onClick:()=>p(g),className:"w-full flex items-center justify-between p-4 hover:bg-white/[0.02] transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[y?r.jsx(Pr,{className:"h-4 w-4 text-neutral-500"}):r.jsx(Rg,{className:"h-4 w-4 text-neutral-500"}),r.jsx("span",{className:"font-bold text-sm text-neutral-200 uppercase tracking-tight",children:g.replace("_"," ")}),r.jsx(ue,{variant:b>0?"danger":"success",size:"sm",children:b>0?`${b} VULNERABILITIES`:"SECURE"})]}),r.jsxs("span",{className:"text-[10px] font-mono text-neutral-600",children:[m.length," Payloads"]})]}),y&&r.jsx("div",{className:"border-t border-white/5 bg-black/20 overflow-x-auto",children:r.jsxs("table",{className:"w-full text-left font-mono text-xs",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-white/5 text-neutral-500",children:[r.jsx("th",{className:"p-3 pl-12 font-medium uppercase tracking-tighter",children:"Payload"}),r.jsx("th",{className:"p-3 font-medium uppercase tracking-tighter",children:"Status"}),r.jsx("th",{className:"p-3 font-medium uppercase tracking-tighter",children:"Result"}),r.jsx("th",{className:"p-3 text-right"})]})}),r.jsx("tbody",{className:"divide-y divide-white/5",children:m.map((v,N)=>r.jsxs("tr",{className:"hover:bg-white/[0.03] transition-colors group",children:[r.jsx("td",{className:"p-3 pl-12",children:r.jsx("code",{className:"bg-neutral-900 px-1.5 py-0.5 rounded text-neutral-300",children:v.payload})}),r.jsx("td",{className:"p-3 text-neutral-400",children:v.status}),r.jsx("td",{className:"p-3",children:r.jsx("span",{className:v.blocked?"text-success-500":"text-danger-500 font-bold",children:v.blocked?"BLOCKED":"BREACHED"})}),r.jsx("td",{className:"p-3 text-right",children:r.jsx(Q,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity h-7 text-primary-400",onClick:()=>ns(v.payload),children:r.jsx(Zr,{className:"h-3 w-3"})})})]},N))})]})})]},g)})})]})}function tN(){const{runScan:e,lastResult:t,isLoading:n}=V1(),{listK6Scenarios:s,listNucleiTemplates:a,runK6:o,runNuclei:i,isLoading:l,result:u,error:c}=q1(),[d,f]=h.useState(""),p="manual",[x,g]=h.useState([]),[m,y]=h.useState([]),[b,v]=h.useState(""),[N,w]=h.useState(""),j="http://localhost:8090";h.useEffect(()=>{s().then(g).catch(T=>console.error(T)),a().then(y).catch(T=>console.error(T))},[s,a]);const k=T=>{T.preventDefault(),e({target:d||void 0,dlpType:p})},_=T=>{T.preventDefault(),b&&o({script:b,vus:10,duration:"10s",target:j})},P=T=>{T.preventDefault(),N&&i({template:N,target:j})};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl text-neutral-100 type-heading flex items-center gap-2 ml-2",children:[r.jsx(Ni,{className:"h-6 w-6 text-primary-400"}),"Vulnerability Lab"]}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Egress filtering validation, load testing, and automated security scanning."})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsxs("div",{className:"space-y-6",children:[r.jsxs(se,{variant:"glass",glow:"primary",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2 text-sm",children:[r.jsx(Fe,{className:"h-4 w-4 text-danger-400"}),"Escape Artist"]}),r.jsx(Re,{children:"Egress channel validation."})]}),r.jsx(ae,{children:r.jsxs("form",{onSubmit:k,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase",children:"Target Host"}),r.jsx("input",{type:"text",value:d,onChange:T=>f(T.target.value),placeholder:"e.g. evil.com",className:"w-full mt-1 px-3 py-2 bg-neutral-900/60 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500/40"})]}),r.jsx("div",{className:"pt-2",children:r.jsxs(Q,{type:"submit",variant:"default",className:"w-full h-9",isLoading:n,children:[r.jsx(Ke,{className:"h-3.5 w-3.5 mr-2"}),"Run Egress Scan"]})})]})})]}),r.jsxs(se,{variant:"glass",glow:"warning",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2 text-sm",children:[r.jsx(It,{className:"h-4 w-4 text-warning-400"}),"Load Lab (k6)"]}),r.jsx(Re,{children:"Simulate high-concurrency traffic."})]}),r.jsx(ae,{children:r.jsxs("form",{onSubmit:_,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase",children:"Scenario"}),r.jsxs(zr,{value:b,onValueChange:v,children:[r.jsx(er,{className:"w-full mt-1 bg-neutral-900 border-neutral-800 text-neutral-300 h-9 font-mono text-xs",children:r.jsx(Fr,{placeholder:"Select script"})}),r.jsx(tr,{className:"bg-neutral-900 border-neutral-800",children:x.map(T=>r.jsx(Yt,{value:T.name,className:"font-mono text-xs",children:T.name},T.name))})]})]}),r.jsx("div",{className:"pt-2",children:r.jsxs(Q,{type:"submit",variant:"primary",className:"w-full h-9",disabled:!b,isLoading:l,children:[r.jsx(Ke,{className:"h-3.5 w-3.5 mr-2"}),"Initialize Load"]})})]})})]}),r.jsxs(se,{variant:"glass",glow:"danger",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2 text-sm",children:[r.jsx(Jt,{className:"h-4 w-4 text-primary-400"}),"Vulnerability Scan (Nuclei)"]}),r.jsx(Re,{children:"Automated template-based scanning."})]}),r.jsx(ae,{children:r.jsxs("form",{onSubmit:P,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-[10px] font-mono text-neutral-500 uppercase",children:"Template"}),r.jsxs(zr,{value:N,onValueChange:w,children:[r.jsx(er,{className:"w-full mt-1 bg-neutral-900 border-neutral-800 text-neutral-300 h-9 font-mono text-xs",children:r.jsx(Fr,{placeholder:"Select template"})}),r.jsx(tr,{className:"bg-neutral-900 border-neutral-800",children:m.map(T=>r.jsx(Yt,{value:T.name,className:"font-mono text-xs",children:T.name},T.name))})]})]}),r.jsx("div",{className:"pt-2",children:r.jsxs(Q,{type:"submit",variant:"destructive",className:"w-full h-9",disabled:!N,isLoading:l,children:[r.jsx(Fe,{className:"h-3.5 w-3.5 mr-2"}),"Deploy Scanner"]})})]})})]})]}),r.jsx("div",{className:"lg:col-span-2 space-y-6",children:r.jsxs(se,{variant:"panel",glow:"info",className:"min-h-[600px] flex flex-col",children:[r.jsx(ce,{className:"flex-none border-b border-white/5 bg-white/[0.01]",children:r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx(de,{className:"text-sm",children:"Lab Operations Output"}),l&&r.jsx(cd,{className:"h-4 w-4 animate-spin text-primary-400"})]})}),r.jsxs(ae,{className:"flex-1 overflow-y-auto p-0",children:[!t&&!u&&r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-neutral-600 p-8 text-center space-y-4",children:[r.jsx(Jt,{className:"h-16 w-16 opacity-20"}),r.jsxs("div",{className:"max-w-sm",children:[r.jsx("p",{className:"text-sm font-bold text-neutral-400 uppercase tracking-widest",children:"Awaiting Lab Execution"}),r.jsx("p",{className:"text-xs text-neutral-600 mt-2 font-mono leading-relaxed",children:"Select a scanner or load scenario from the left panel to begin testing infrastructure resilience and security posture."})]})]}),u&&r.jsxs("div",{className:"p-6 font-mono text-xs animate-in slide-in-from-bottom-2",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-primary-500/10 border border-primary-500/20 rounded-sm",children:[r.jsx("div",{className:X("w-2 h-2 rounded-full",u.status==="completed"?"bg-success-500 shadow-glow-success":"bg-warning-500 animate-pulse")}),r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"text-primary-400 font-bold uppercase tracking-widest",children:[u.scenarioName," Execution"]}),r.jsxs("div",{className:"text-[10px] text-neutral-500 mt-0.5",children:["ID: ",u.executionId," | Status: ",u.status]})]})]}),u.error?r.jsxs("div",{className:"p-4 bg-danger-900/20 border border-danger-900/40 text-danger-400 rounded-sm",children:[r.jsx("div",{className:"font-bold mb-1",children:"EXECUTION_ERROR"}),u.error]}):r.jsx("div",{className:"space-y-4",children:r.jsx("div",{className:"p-4 bg-black/40 border border-white/5 rounded-sm whitespace-pre-wrap leading-relaxed text-neutral-300",children:u.status==="running"?"[RUNNING_LAB_PROCESS... MONITORING_OUTPUT...]":"Scan/Load Test completed successfully. Review logs for findings."})})]}),c&&!u&&r.jsx("div",{className:"p-6 font-mono text-xs animate-in slide-in-from-bottom-2",children:r.jsxs("div",{className:"p-4 bg-danger-900/20 border border-danger-900/40 text-danger-400 rounded-sm",children:[r.jsx("div",{className:"font-bold mb-1",children:"LAB_ERROR"}),c]})}),t&&r.jsx("div",{className:"divide-y divide-white/5 animate-in fade-in",children:t.checks.map((T,$)=>{const B=T.checks||[T];return r.jsxs("div",{className:"p-6",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[r.jsx(ue,{variant:"secondary",className:"font-mono text-[10px]",children:T.protocol.toUpperCase()}),r.jsx("span",{className:"h-px flex-1 bg-white/5"})]}),r.jsx("div",{className:"space-y-3",children:B.map((D,R)=>{const S=D.status==="success"||D.status==="likely_success";return r.jsxs("div",{className:"flex items-start gap-4 bg-neutral-900/40 p-3 rounded-sm border border-white/5 group hover:border-white/10 transition-colors",children:[S?r.jsx(xd,{className:"h-4 w-4 text-danger-500 mt-0.5 shrink-0"}):r.jsx(sd,{className:"h-4 w-4 text-success-500 mt-0.5 shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex justify-between items-center mb-1",children:[r.jsx("span",{className:"text-neutral-200 font-bold text-xs truncate",children:D.target||"Egress Channel"}),r.jsx("span",{className:X("text-[10px] font-bold px-1.5 py-0.5 rounded-sm",S?"bg-danger-500/10 text-danger-400":"bg-success-500/10 text-success-400"),children:S?"BREACHED":"BLOCKED"})]}),(D.error||D.details)&&r.jsx("div",{className:"text-[10px] text-neutral-500 font-mono mt-1.5 leading-relaxed opacity-80",children:D.error||D.details})]})]},R)})})]},$)})})]})]})})]}),r.jsxs("div",{className:"space-y-6 mt-12",children:[r.jsxs("h2",{className:"text-xl font-bold text-neutral-100 font-mono flex items-center gap-2",children:[r.jsx(Fe,{className:"h-5 w-5 text-primary-400"}),"Automated Red Team Validator"]}),r.jsx(eN,{})]}),r.jsxs("div",{className:"mt-12",children:[r.jsxs("h2",{className:"text-xl font-bold text-neutral-100 font-mono flex items-center gap-2 mb-6",children:[r.jsx(Ir,{className:"h-5 w-5 text-primary-400"}),"One-Shot Payload Fuzzer"]}),r.jsx(Q1,{})]})]})}function nN(){const{baseUrl:e}=je(),[t,n]=h.useState(!1),[s,a]=h.useState(null),o=h.useCallback((l="eth0",u=10)=>{if(!e)return;n(!0);const c=`${e}/capture.pcap?iface=${encodeURIComponent(l)}&duration=${encodeURIComponent(u)}`,d=document.createElement("a");d.href=c,d.download=`capture-${Date.now()}.pcap`,document.body.appendChild(d),d.click(),document.body.removeChild(d),setTimeout(()=>n(!1),u*1e3)},[e]),i=h.useCallback(async l=>{if(!e)return;n(!0);const u=new FileReader;u.onload=async c=>{var d;try{const f=JSON.parse((d=c.target)==null?void 0:d.result),x=await(await fetch(`${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json();a(x)}catch(f){console.error(f),a({error:"Failed to parse or replay HAR"})}finally{n(!1)}},u.readAsText(l)},[e]);return{startCapture:o,replayHar:i,isCapturing:t,replayResult:s}}function rN(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState(!1),[o,i]=h.useState(""),l=h.useRef(null),u=()=>{l.current&&l.current.close();const d=new URL(`${e}/api/forensics/live`);o&&d.searchParams.append("filter",o);const f=new EventSource(d.toString());l.current=f,a(!0),f.onmessage=p=>{const x=JSON.parse(p.data);n(g=>[x,...g].slice(0,100))},f.onerror=()=>{c()}},c=()=>{l.current&&(l.current.close(),l.current=null),a(!1)};return h.useEffect(()=>()=>{l.current&&l.current.close()},[]),r.jsxs(se,{variant:"panel",glow:"primary",className:"h-full flex flex-col",children:[r.jsx(ce,{className:"flex-none border-b border-white/5 bg-white/[0.02] py-3",children:r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs(de,{className:"flex items-center gap-2 text-[11px] font-mono tracking-widest",children:[r.jsx(md,{className:X("h-3.5 w-3.5",s?"text-primary animate-pulse":"text-neutral-500")}),"Live Packet Monitor"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[s?r.jsxs(Q,{variant:"danger",size:"sm",className:"h-7 text-[9px]",onClick:c,children:[r.jsx(pd,{className:"h-3 w-3 mr-1.5"}),"STOP_CAPTURE"]}):r.jsxs(Q,{variant:"primary",size:"sm",className:"h-7 text-[9px]",onClick:u,children:[r.jsx(Ke,{className:"h-3 w-3 mr-1.5"}),"INITIALIZE"]}),r.jsx(Q,{variant:"ghost",size:"icon",className:"h-7 w-7 text-neutral-600 hover:text-danger-400",onClick:()=>n([]),children:r.jsx(wa,{className:"h-3 w-3"})})]})]})}),r.jsx("div",{className:"p-3 border-b border-white/5 bg-black/40",children:r.jsxs("div",{className:"relative",children:[r.jsx(Jr,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-neutral-600"}),r.jsx("input",{type:"text",value:o,onChange:d=>i(d.target.value),placeholder:"Berkeley Packet Filter (e.g. tcp port 80)...",className:"w-full bg-neutral-900/50 border border-white/10 rounded-sm pl-7 pr-3 py-1.5 text-[10px] font-mono text-primary-400 placeholder:text-neutral-700 focus:outline-none focus:border-primary-500/30"})]})}),r.jsx(ae,{className:"flex-1 overflow-y-auto p-0 font-mono text-[10px]",children:t.length===0?r.jsx("div",{className:"h-full flex flex-col items-center justify-center text-neutral-600 italic py-12",children:s?"[SCANNING_INFRASTRUCTURE...]":"[AWAITING_INITIALIZATION]"}):r.jsx("div",{className:"divide-y divide-white/[0.03]",children:t.map((d,f)=>r.jsxs("div",{className:"p-2 hover:bg-white/[0.02] transition-colors group relative",children:[r.jsxs("div",{className:"flex gap-3 items-start pr-10",children:[r.jsx("span",{className:"text-neutral-700 font-bold shrink-0",children:d.timestamp.split("T")[1].split(".")[0]}),r.jsx("span",{className:"text-neutral-300 break-all leading-relaxed",children:d.raw})]}),r.jsx("button",{onClick:()=>ns(d.raw),className:"absolute right-2 top-2 opacity-0 group-hover:opacity-100 transition-opacity p-1 hover:bg-primary/10 rounded-sm text-primary/60 hover:text-primary",title:"Analyze packet in CyberChef",children:r.jsx(Zr,{className:"h-3 w-3"})})]},f))})}),r.jsxs("div",{className:"p-2 border-t border-white/5 bg-black/60 flex justify-between items-center px-4",children:[r.jsx("div",{className:"text-[9px] font-mono text-neutral-600 uppercase tracking-widest",children:s?"Stream Active":"Stream Suspended"}),r.jsxs("div",{className:"text-[9px] font-mono text-neutral-500",children:["Buffer: ",t.length,"/100"]})]})]})}function sN(){const{startCapture:e,replayHar:t,isCapturing:n,replayResult:s}=nN(),[a,o]=h.useState("eth0"),[i,l]=h.useState(10),u=()=>{e(a,i)},c=d=>{var p;const f=(p=d.target.files)==null?void 0:p[0];f&&t(f)};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500 h-[calc(100vh-140px)] flex flex-col",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Network Forensics"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Packet capture, live monitoring, and traffic replay analysis."})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 flex-1 min-h-0",children:[r.jsx("div",{className:"lg:col-span-8 h-full min-h-0",children:r.jsx(rN,{})}),r.jsxs("div",{className:"lg:col-span-4 space-y-6 overflow-y-auto pr-1",children:[r.jsxs(se,{variant:"panel",glow:"info",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(ji,{className:"h-4 w-4 text-info-500"}),"PCAP Recorder"]}),r.jsx(Re,{children:"Capture live traffic to a .pcap file."})]}),r.jsxs(ae,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs font-mono text-neutral-400",children:"Interface"}),r.jsx("input",{type:"text",value:a,onChange:d=>o(d.target.value),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500/40"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-xs font-mono text-neutral-400",children:"Duration (sec)"}),r.jsx("input",{type:"number",value:i,onChange:d=>l(parseInt(d.target.value,10)||10),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500/40"})]})]}),r.jsxs(Q,{variant:"primary",className:"w-full",onClick:u,disabled:n,children:[n?"Recording...":"Start Capture",!n&&r.jsx(Lg,{className:"h-4 w-4 ml-2"})]})]})]}),r.jsxs(se,{variant:"panel",glow:"warning",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Ke,{className:"h-4 w-4 text-warning-500"}),"Traffic Replay"]}),r.jsx(Re,{children:"Replay requests from a HAR file."})]}),r.jsxs(ae,{className:"space-y-4",children:[r.jsxs("div",{className:"border-2 border-dashed border-neutral-800 rounded-lg p-8 flex flex-col items-center justify-center hover:border-neutral-700 transition-colors bg-neutral-900/30",children:[r.jsx(ad,{className:"h-8 w-8 text-neutral-600 mb-2"}),r.jsxs("label",{className:"cursor-pointer",children:[r.jsx("span",{className:"text-sm text-primary-400 font-medium hover:underline",children:"Upload HAR File"}),r.jsx("input",{type:"file",accept:".har,.json",className:"hidden",onChange:c,disabled:n})]}),r.jsx("span",{className:"text-xs text-neutral-500 mt-1",children:"or drag and drop"})]}),s&&r.jsx("div",{className:"bg-black/40 p-3 rounded border border-white/5 max-h-32 overflow-y-auto font-mono text-xs",children:r.jsx("pre",{className:"text-neutral-300 whitespace-pre-wrap",children:JSON.stringify(s,null,2)})})]})]}),r.jsxs(se,{variant:"glass",glow:"danger",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Fe,{className:"h-4 w-4 text-danger-400"}),"Forensic Intel"]}),r.jsx(Re,{children:"Suspicious network patterns detected."})]}),r.jsx(ae,{children:r.jsx("div",{className:"text-[10px] font-mono text-neutral-600 italic py-4 border border-dashed border-neutral-800 rounded-sm text-center",children:"NO_THREATS_DETECTED"})})]})]})]})]})}function aN(){const{client:e}=je();return e}const Yo=new TextEncoder,oN=new TextDecoder,iN=[{value:"none",label:"No Attack"},{value:"none_alg",label:"None Algorithm"},{value:"weak_key",label:"Weak HMAC Key"},{value:"key_confusion",label:"RS256 → HS256 Confusion"}];function fn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Cf(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Un(e){return Cf(Yo.encode(e))}function Rc(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.length%4===0?"":"=".repeat(4-t.length%4),s=atob(t+n),a=Uint8Array.from(s,o=>o.charCodeAt(0));return oN.decode(a)}function lN(e){const t=e.trim().split(".");if(t.length<2)return null;try{const n=JSON.parse(Rc(t[0])),s=JSON.parse(Rc(t[1]));return!fn(n)||!fn(s)?null:{header:n,payload:s,signature:t[2]??""}}catch{return null}}async function Ac(e,t,n){var u;if(!((u=globalThis.crypto)!=null&&u.subtle))throw new Error("Browser crypto.subtle is unavailable");const s=Un(JSON.stringify(e)),a=Un(JSON.stringify(t)),o=`${s}.${a}`,i=await crypto.subtle.importKey("raw",Yo.encode(n),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),l=new Uint8Array(await crypto.subtle.sign("HMAC",i,Yo.encode(o)));return`${o}.${Cf(l)}`}function Mc(e){return JSON.stringify(e,null,2)}function cN(e){return e?e.message:"No verification run yet."}function uN(){var D;const e=aN(),[t,n]=h.useState(""),[s,a]=h.useState("{}"),[o,i]=h.useState("{}"),[l,u]=h.useState(""),[c,d]=h.useState("none"),[f,p]=h.useState("secret"),[x,g]=h.useState(""),[m,y]=h.useState(!0),[b,v]=h.useState(null),[N,w]=h.useState(!1),[j,k]=h.useState(null),_=h.useMemo(()=>l.trim()||t.trim(),[l,t]),P=R=>{const S=lN(R);if(!S){v("Token is not valid JWT format (header.payload.signature).");return}a(Mc(S.header)),i(Mc(S.payload)),u(R),v(null)},T=async()=>{if(!e){v("Connect to an Apparatus server before minting tokens.");return}w(!0),v(null);try{const R=await e.identity.forgeToken();n(R.token),u(R.token),p(R.hints.weakKeys[0]??"secret"),g(R.hints.publicKey??""),k(null),P(R.token)}catch(R){v(R instanceof Error?R.message:"Failed to mint token")}finally{w(!1)}},$=async()=>{v(null);let R,S;try{const C=JSON.parse(s),E=JSON.parse(o);if(!fn(C)||!fn(E))throw new Error("Header and payload must be JSON objects.");R={...C},S={...E}}catch(C){v(C instanceof Error?C.message:"Invalid JSON in header/payload editor");return}try{let C="";const E=t.split(".")[2]??"";if(c==="none"){const A=Un(JSON.stringify(R)),O=Un(JSON.stringify(S));C=`${A}.${O}.${E}`}if(c==="none_alg"){R.alg="none";const A=Un(JSON.stringify(R)),O=Un(JSON.stringify(S));C=`${A}.${O}.`}if(c==="weak_key"&&(R.alg="HS256",C=await Ac(R,S,f||"secret")),c==="key_confusion"){R.alg="HS256";const A=x.trim();if(!A)throw new Error("Public key secret is required for key confusion attack mode.");C=await Ac(R,S,A)}u(C),k(null)}catch(C){v(C instanceof Error?C.message:"Failed to forge token")}},B=async()=>{if(!e){v("Connect to an Apparatus server before verifying tokens.");return}if(!_){v("Provide or forge a token first.");return}w(!0),v(null);const R={allowNoneAlg:m&&c==="none_alg",allowWeakKey:m&&c==="weak_key",allowKeyConfusion:m&&c==="key_confusion"};try{const S=await e.identity.verifyToken({token:_,vulnerabilities:R});k(S)}catch(S){if(L0(S)&&fn(S.body)){const C=S.body;k({valid:C.valid===!0,bypassed:C.bypassed===!0,mode:typeof C.mode=="string"?C.mode:"invalid",message:typeof C.message=="string"?C.message:S.message,header:fn(C.header)?C.header:void 0,payload:fn(C.payload)?C.payload:void 0,matchedKey:typeof C.matchedKey=="string"?C.matchedKey:void 0})}else v(S instanceof Error?S.message:"Verification failed")}finally{w(!1)}};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl text-neutral-100 type-heading flex items-center gap-2 ml-2",children:[r.jsx(wi,{className:"h-6 w-6 text-primary-400"}),"Identity Token Forge"]}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Decode, mutate, and test JWTs against secure and intentionally vulnerable verification paths."})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(Q,{variant:"secondary",onClick:()=>P(t),disabled:!t.trim()||N,children:"Load Token"}),r.jsx(Q,{variant:"default",onClick:T,isLoading:N,leftIcon:r.jsx(va,{className:"h-4 w-4"}),children:"Mint Starter Token"})]})]}),b&&r.jsx("div",{className:"text-danger-300 border border-danger-500/30 bg-danger-900/20 px-3 py-2 rounded-[3px] text-xs font-mono",children:b}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[r.jsxs(se,{variant:"glass",glow:"primary",children:[r.jsxs(ce,{children:[r.jsx(de,{children:"Token Builder"}),r.jsx(Re,{children:"Paste any JWT, edit header/payload JSON, then apply an attack mode."})]}),r.jsxs(ae,{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono uppercase text-neutral-500 mb-1",children:"Raw JWT"}),r.jsx("textarea",{value:t,onChange:R=>n(R.target.value),placeholder:"eyJhbGciOi...",className:"w-full min-h-[96px] bg-neutral-900/60 border border-neutral-800/70 rounded-[3px] px-3 py-2 text-xs text-neutral-100 font-mono focus:outline-none focus:border-primary-500/40"})]}),r.jsxs("div",{className:"grid grid-cols-1 gap-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono uppercase text-neutral-500 mb-1",children:"Header JSON"}),r.jsx("textarea",{value:s,onChange:R=>a(R.target.value),className:"w-full min-h-[140px] bg-black/35 border border-neutral-800/70 rounded-[3px] px-3 py-2 text-xs text-cyan-100 font-mono focus:outline-none focus:border-primary-500/40"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono uppercase text-neutral-500 mb-1",children:"Payload JSON"}),r.jsx("textarea",{value:o,onChange:R=>i(R.target.value),className:"w-full min-h-[160px] bg-black/35 border border-neutral-800/70 rounded-[3px] px-3 py-2 text-xs text-emerald-100 font-mono focus:outline-none focus:border-primary-500/40"})]})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono uppercase text-neutral-500 mb-1",children:"Attack Mode"}),r.jsxs(zr,{value:c,onValueChange:R=>d(R),children:[r.jsx(er,{className:"w-full bg-neutral-900 border-neutral-800 text-neutral-300 h-9 font-mono text-xs",children:r.jsx(Fr,{placeholder:"Select attack mode"})}),r.jsx(tr,{className:"bg-neutral-900 border-neutral-800",children:iN.map(R=>r.jsx(Yt,{value:R.value,className:"text-neutral-300 hover:bg-neutral-800 cursor-pointer font-mono text-xs",children:R.label},R.value))})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono uppercase text-neutral-500 mb-1",children:"Weak Key"}),r.jsx("input",{value:f,onChange:R=>p(R.target.value),className:"w-full h-9 bg-neutral-900 border border-neutral-800 rounded-[3px] px-3 text-xs text-neutral-100 font-mono focus:outline-none focus:border-primary-500/40",placeholder:"secret"})]})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono uppercase text-neutral-500 mb-1",children:"Public Key (for key confusion mode)"}),r.jsx("textarea",{value:x,onChange:R=>g(R.target.value),className:"w-full min-h-[100px] bg-neutral-900/60 border border-neutral-800/70 rounded-[3px] px-3 py-2 text-[11px] text-neutral-300 font-mono focus:outline-none focus:border-primary-500/40"})]}),r.jsx("div",{className:"flex flex-wrap items-center gap-3",children:r.jsxs("label",{className:"flex items-center gap-2 text-xs font-mono text-neutral-300",children:[r.jsx("input",{type:"checkbox",checked:m,onChange:R=>y(R.target.checked)}),"Enable vulnerable verification mode for selected attack"]})}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(Q,{variant:"neon",onClick:$,leftIcon:r.jsx(e0,{className:"h-4 w-4"}),children:"Forge Attack Token"}),r.jsx(Q,{variant:"default",onClick:B,isLoading:N,leftIcon:r.jsx(Jt,{className:"h-4 w-4"}),children:"Test Token"})]})]})]}),r.jsxs(se,{variant:"panel",glow:"primary",children:[r.jsxs(ce,{children:[r.jsx(de,{children:"Analysis & Verification"}),r.jsx(Re,{children:"Generated token output and backend verification response."})]}),r.jsxs(ae,{className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono uppercase text-neutral-500 mb-1",children:"Active Token"}),r.jsx("textarea",{value:_,readOnly:!0,className:"w-full min-h-[120px] bg-black/35 border border-neutral-800/70 rounded-[3px] px-3 py-2 text-[11px] text-neutral-200 font-mono"})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] uppercase text-neutral-500 font-mono",children:"Verification State"}),r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[j!=null&&j.valid?r.jsx(Jt,{className:"h-4 w-4 text-success-500"}):r.jsx(Fe,{className:"h-4 w-4 text-danger-400"}),r.jsx("span",{className:"text-sm font-mono text-neutral-100",children:j?j.valid?"ACCEPTED":"REJECTED":"NOT RUN"})]})]}),r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] uppercase text-neutral-500 font-mono",children:"Mode"}),r.jsx("div",{className:"mt-2 text-sm font-mono text-neutral-100",children:((D=j==null?void 0:j.mode)==null?void 0:D.toUpperCase())??"—"})]})]}),r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-black/30",children:[r.jsx("div",{className:"text-[11px] uppercase text-neutral-500 font-mono",children:"Message"}),r.jsx("div",{className:"mt-2 text-xs text-neutral-300 font-mono leading-relaxed",children:cN(j)})]}),j&&r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-black/30",children:[r.jsx("div",{className:"text-[11px] uppercase text-neutral-500 font-mono mb-2",children:"Verification Payload"}),r.jsx("pre",{className:"text-[11px] text-neutral-300 font-mono whitespace-pre-wrap break-words",children:JSON.stringify(j.payload??{},null,2)})]})]})]})]})]})}function dN(){const{baseUrl:e,setBaseUrl:t,isConnected:n,health:s}=je(),{resolvedTheme:a,toggleTheme:o}=Pd(),[i,l]=h.useState(e),[u,c]=h.useState(!1),[d,f]=h.useState(!1);h.useEffect(()=>{e&&fetch(`${e}/_sensor/demo`).then(g=>g.json()).then(g=>c(g.enabled)).catch(()=>{})},[e]);const p=g=>{g.preventDefault(),t(i)},x=async()=>{if(e){f(!0);try{const m=await(await fetch(`${e}/_sensor/demo/toggle`,{method:"POST"})).json();c(m.enabled)}catch(g){console.error(g)}finally{f(!1)}}};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"System Settings"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Dashboard configuration and connection preferences."})]}),r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[r.jsxs(se,{variant:"panel",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Yg,{className:"h-4 w-4 text-primary-500"}),"Connection"]}),r.jsx(Re,{children:"Configure the Apparatus backend URL."})]}),r.jsx(ae,{children:r.jsxs("form",{onSubmit:p,className:"space-y-4",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-xs font-mono text-neutral-400",children:"Base URL"}),r.jsx("input",{type:"url",value:i,onChange:g=>l(g.target.value),className:"w-full mt-1 px-3 py-2 bg-neutral-900 border border-neutral-800 rounded-sm text-sm font-mono text-white focus:outline-none focus:border-primary-500"})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:`w-2 h-2 rounded-full ${n?"bg-success-500":"bg-danger-500"}`,"aria-hidden":"true"}),r.jsx("span",{className:"text-xs font-mono text-neutral-300",children:n?`CONNECTED (v${s.version||"?"})`:"DISCONNECTED"})]}),r.jsxs(Q,{type:"submit",variant:"secondary",size:"sm",children:[r.jsx(hd,{className:"h-4 w-4 mr-2"}),"Save"]})]})]})})]}),r.jsxs(se,{variant:"panel",className:u?"border-warning-500/50":"",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(dt,{className:"h-4 w-4 text-warning-500"}),"Simulation Mode"]}),r.jsx(Re,{children:"Generate synthetic traffic and events."})]}),r.jsx(ae,{children:r.jsxs("div",{className:"flex items-center justify-between p-4 bg-neutral-900/50 rounded-sm border border-neutral-800",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx("span",{className:"text-sm font-bold text-neutral-200",children:"Demo Traffic"}),u&&r.jsx(ue,{variant:"warning",dot:!0,children:"ACTIVE"})]}),r.jsx("p",{className:"text-xs text-neutral-500",children:"Automatically generates HTTP requests, honeypot hits, and webhooks for demonstration."})]}),r.jsx(Q,{variant:u?"destructive":"default",size:"sm",onClick:x,isLoading:d,children:u?"Stop Simulation":"Start Simulation"})]})})]}),r.jsxs(se,{variant:"panel",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Ei,{className:"h-4 w-4 text-neutral-400"}),"Appearance"]}),r.jsx(Re,{children:"Customize the dashboard look and feel."})]}),r.jsx(ae,{children:r.jsxs("div",{className:"flex items-center justify-between p-3 bg-neutral-900/50 rounded-sm border border-neutral-800",children:[r.jsx("span",{className:"text-sm text-neutral-300",children:"Theme Mode"}),r.jsx(Q,{variant:"outline",size:"sm",onClick:o,children:a==="dark"?"Dark Mode":"Light Mode"})]})})]})]})]})}function Be(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=Be(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Tf={exports:{}},Rf={},Af={exports:{}},Mf={};/**
|
|
564
|
+
* @license React
|
|
565
|
+
* use-sync-external-store-shim.production.js
|
|
566
|
+
*
|
|
567
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
568
|
+
*
|
|
569
|
+
* This source code is licensed under the MIT license found in the
|
|
570
|
+
* LICENSE file in the root directory of this source tree.
|
|
571
|
+
*/var nr=h;function hN(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var fN=typeof Object.is=="function"?Object.is:hN,pN=nr.useState,mN=nr.useEffect,xN=nr.useLayoutEffect,gN=nr.useDebugValue;function yN(e,t){var n=t(),s=pN({inst:{value:n,getSnapshot:t}}),a=s[0].inst,o=s[1];return xN(function(){a.value=n,a.getSnapshot=t,co(a)&&o({inst:a})},[e,n,t]),mN(function(){return co(a)&&o({inst:a}),e(function(){co(a)&&o({inst:a})})},[e]),gN(n),n}function co(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!fN(e,n)}catch{return!0}}function bN(e,t){return t()}var vN=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?bN:yN;Mf.useSyncExternalStore=nr.useSyncExternalStore!==void 0?nr.useSyncExternalStore:vN;Af.exports=Mf;var wN=Af.exports;/**
|
|
572
|
+
* @license React
|
|
573
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
574
|
+
*
|
|
575
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
576
|
+
*
|
|
577
|
+
* This source code is licensed under the MIT license found in the
|
|
578
|
+
* LICENSE file in the root directory of this source tree.
|
|
579
|
+
*/var Aa=h,NN=wN;function SN(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var jN=typeof Object.is=="function"?Object.is:SN,kN=NN.useSyncExternalStore,EN=Aa.useRef,_N=Aa.useEffect,CN=Aa.useMemo,TN=Aa.useDebugValue;Rf.useSyncExternalStoreWithSelector=function(e,t,n,s,a){var o=EN(null);if(o.current===null){var i={hasValue:!1,value:null};o.current=i}else i=o.current;o=CN(function(){function u(x){if(!c){if(c=!0,d=x,x=s(x),a!==void 0&&i.hasValue){var g=i.value;if(a(g,x))return f=g}return f=x}if(g=f,jN(d,x))return g;var m=s(x);return a!==void 0&&a(g,m)?(d=x,g):(d=x,f=m)}var c=!1,d,f,p=n===void 0?null:n;return[function(){return u(t())},p===null?void 0:function(){return u(p())}]},[t,n,s,a]);var l=kN(e,o[0],o[1]);return _N(function(){i.hasValue=!0,i.value=l},[l]),TN(l),l};Tf.exports=Rf;var RN=Tf.exports;const AN=Zu(RN),MN={},Ic=e=>{let t;const n=new Set,s=(d,f)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const x=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(g=>g(t,x))}},a=()=>t,u={setState:s,getState:a,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(MN?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(s,a,u);return u},IN=e=>e?Ic(e):Ic,{useDebugValue:PN}=q,{useSyncExternalStoreWithSelector:ON}=AN,LN=e=>e;function If(e,t=LN,n){const s=ON(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return PN(s),s}const Pc=(e,t)=>{const n=IN(e),s=(a,o=t)=>If(n,a,o);return Object.assign(s,n),s},DN=(e,t)=>e?Pc(e,t):Pc;function ze(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,a]of e)if(!Object.is(a,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}var $N={value:()=>{}};function Ma(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new zs(n)}function zs(e){this._=e}function zN(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",a=n.indexOf(".");if(a>=0&&(s=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}zs.prototype=Ma.prototype={constructor:zs,on:function(e,t){var n=this._,s=zN(e+"",n),a,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((a=(e=s[o]).type)&&(a=FN(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<i;)if(a=(e=s[o]).type)n[a]=Oc(n[a],e.name,t);else if(t==null)for(a in n)n[a]=Oc(n[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new zs(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),s=0,a,o;s<a;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],s=0,a=o.length;s<a;++s)o[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],a=0,o=s.length;a<o;++a)s[a].value.apply(t,n)}};function FN(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function Oc(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=$N,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Xo="http://www.w3.org/1999/xhtml";const Lc={svg:"http://www.w3.org/2000/svg",xhtml:Xo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ia(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Lc.hasOwnProperty(t)?{space:Lc[t],local:e}:e}function BN(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Xo&&t.documentElement.namespaceURI===Xo?t.createElement(e):t.createElementNS(n,e)}}function HN(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Pf(e){var t=Ia(e);return(t.local?HN:BN)(t)}function UN(){}function Yi(e){return e==null?UN:function(){return this.querySelector(e)}}function VN(e){typeof e!="function"&&(e=Yi(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,l=s[a]=new Array(i),u,c,d=0;d<i;++d)(u=o[d])&&(c=e.call(u,u.__data__,d,o))&&("__data__"in u&&(c.__data__=u.__data__),l[d]=c);return new et(s,this._parents)}function qN(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function WN(){return[]}function Of(e){return e==null?WN:function(){return this.querySelectorAll(e)}}function GN(e){return function(){return qN(e.apply(this,arguments))}}function KN(e){typeof e=="function"?e=GN(e):e=Of(e);for(var t=this._groups,n=t.length,s=[],a=[],o=0;o<n;++o)for(var i=t[o],l=i.length,u,c=0;c<l;++c)(u=i[c])&&(s.push(e.call(u,u.__data__,c,i)),a.push(u));return new et(s,a)}function Lf(e){return function(){return this.matches(e)}}function Df(e){return function(t){return t.matches(e)}}var YN=Array.prototype.find;function XN(e){return function(){return YN.call(this.children,e)}}function ZN(){return this.firstElementChild}function JN(e){return this.select(e==null?ZN:XN(typeof e=="function"?e:Df(e)))}var QN=Array.prototype.filter;function eS(){return Array.from(this.children)}function tS(e){return function(){return QN.call(this.children,e)}}function nS(e){return this.selectAll(e==null?eS:tS(typeof e=="function"?e:Df(e)))}function rS(e){typeof e!="function"&&(e=Lf(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,l=s[a]=[],u,c=0;c<i;++c)(u=o[c])&&e.call(u,u.__data__,c,o)&&l.push(u);return new et(s,this._parents)}function $f(e){return new Array(e.length)}function sS(){return new et(this._enter||this._groups.map($f),this._parents)}function ta(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ta.prototype={constructor:ta,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function aS(e){return function(){return e}}function oS(e,t,n,s,a,o){for(var i=0,l,u=t.length,c=o.length;i<c;++i)(l=t[i])?(l.__data__=o[i],s[i]=l):n[i]=new ta(e,o[i]);for(;i<u;++i)(l=t[i])&&(a[i]=l)}function iS(e,t,n,s,a,o,i){var l,u,c=new Map,d=t.length,f=o.length,p=new Array(d),x;for(l=0;l<d;++l)(u=t[l])&&(p[l]=x=i.call(u,u.__data__,l,t)+"",c.has(x)?a[l]=u:c.set(x,u));for(l=0;l<f;++l)x=i.call(e,o[l],l,o)+"",(u=c.get(x))?(s[l]=u,u.__data__=o[l],c.delete(x)):n[l]=new ta(e,o[l]);for(l=0;l<d;++l)(u=t[l])&&c.get(p[l])===u&&(a[l]=u)}function lS(e){return e.__data__}function cS(e,t){if(!arguments.length)return Array.from(this,lS);var n=t?iS:oS,s=this._parents,a=this._groups;typeof e!="function"&&(e=aS(e));for(var o=a.length,i=new Array(o),l=new Array(o),u=new Array(o),c=0;c<o;++c){var d=s[c],f=a[c],p=f.length,x=uS(e.call(d,d&&d.__data__,c,s)),g=x.length,m=l[c]=new Array(g),y=i[c]=new Array(g),b=u[c]=new Array(p);n(d,f,m,y,b,x,t);for(var v=0,N=0,w,j;v<g;++v)if(w=m[v]){for(v>=N&&(N=v+1);!(j=y[N])&&++N<g;);w._next=j||null}}return i=new et(i,s),i._enter=l,i._exit=u,i}function uS(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function dS(){return new et(this._exit||this._groups.map($f),this._parents)}function hS(e,t,n){var s=this.enter(),a=this,o=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),n==null?o.remove():n(o),s&&a?s.merge(a).order():a}function fS(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,a=n.length,o=s.length,i=Math.min(a,o),l=new Array(a),u=0;u<i;++u)for(var c=n[u],d=s[u],f=c.length,p=l[u]=new Array(f),x,g=0;g<f;++g)(x=c[g]||d[g])&&(p[g]=x);for(;u<a;++u)l[u]=n[u];return new et(l,this._parents)}function pS(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],a=s.length-1,o=s[a],i;--a>=0;)(i=s[a])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function mS(e){e||(e=xS);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var n=this._groups,s=n.length,a=new Array(s),o=0;o<s;++o){for(var i=n[o],l=i.length,u=a[o]=new Array(l),c,d=0;d<l;++d)(c=i[d])&&(u[d]=c);u.sort(t)}return new et(a,this._parents).order()}function xS(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gS(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function yS(){return Array.from(this)}function bS(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,o=s.length;a<o;++a){var i=s[a];if(i)return i}return null}function vS(){let e=0;for(const t of this)++e;return e}function wS(){return!this.node()}function NS(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var a=t[n],o=0,i=a.length,l;o<i;++o)(l=a[o])&&e.call(l,l.__data__,o,a);return this}function SS(e){return function(){this.removeAttribute(e)}}function jS(e){return function(){this.removeAttributeNS(e.space,e.local)}}function kS(e,t){return function(){this.setAttribute(e,t)}}function ES(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function _S(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function CS(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function TS(e,t){var n=Ia(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?jS:SS:typeof t=="function"?n.local?CS:_S:n.local?ES:kS)(n,t))}function zf(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function RS(e){return function(){this.style.removeProperty(e)}}function AS(e,t,n){return function(){this.style.setProperty(e,t,n)}}function MS(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function IS(e,t,n){return arguments.length>1?this.each((t==null?RS:typeof t=="function"?MS:AS)(e,t,n??"")):rr(this.node(),e)}function rr(e,t){return e.style.getPropertyValue(t)||zf(e).getComputedStyle(e,null).getPropertyValue(t)}function PS(e){return function(){delete this[e]}}function OS(e,t){return function(){this[e]=t}}function LS(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function DS(e,t){return arguments.length>1?this.each((t==null?PS:typeof t=="function"?LS:OS)(e,t)):this.node()[e]}function Ff(e){return e.trim().split(/^|\s+/)}function Xi(e){return e.classList||new Bf(e)}function Bf(e){this._node=e,this._names=Ff(e.getAttribute("class")||"")}Bf.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Hf(e,t){for(var n=Xi(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function Uf(e,t){for(var n=Xi(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function $S(e){return function(){Hf(this,e)}}function zS(e){return function(){Uf(this,e)}}function FS(e,t){return function(){(t.apply(this,arguments)?Hf:Uf)(this,e)}}function BS(e,t){var n=Ff(e+"");if(arguments.length<2){for(var s=Xi(this.node()),a=-1,o=n.length;++a<o;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?FS:t?$S:zS)(n,t))}function HS(){this.textContent=""}function US(e){return function(){this.textContent=e}}function VS(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function qS(e){return arguments.length?this.each(e==null?HS:(typeof e=="function"?VS:US)(e)):this.node().textContent}function WS(){this.innerHTML=""}function GS(e){return function(){this.innerHTML=e}}function KS(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function YS(e){return arguments.length?this.each(e==null?WS:(typeof e=="function"?KS:GS)(e)):this.node().innerHTML}function XS(){this.nextSibling&&this.parentNode.appendChild(this)}function ZS(){return this.each(XS)}function JS(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function QS(){return this.each(JS)}function ej(e){var t=typeof e=="function"?e:Pf(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function tj(){return null}function nj(e,t){var n=typeof e=="function"?e:Pf(e),s=t==null?tj:typeof t=="function"?t:Yi(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function rj(){var e=this.parentNode;e&&e.removeChild(this)}function sj(){return this.each(rj)}function aj(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function oj(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function ij(e){return this.select(e?oj:aj)}function lj(e){return arguments.length?this.property("__data__",e):this.node().__data__}function cj(e){return function(t){e.call(this,t,this.__data__)}}function uj(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function dj(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,a=t.length,o;n<a;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++s]=o;++s?t.length=s:delete this.__on}}}function hj(e,t,n){return function(){var s=this.__on,a,o=cj(t);if(s){for(var i=0,l=s.length;i<l;++i)if((a=s[i]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=o,a.options=n),a.value=t;return}}this.addEventListener(e.type,o,n),a={type:e.type,name:e.name,value:t,listener:o,options:n},s?s.push(a):this.__on=[a]}}function fj(e,t,n){var s=uj(e+""),a,o=s.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,c=l.length,d;u<c;++u)for(a=0,d=l[u];a<o;++a)if((i=s[a]).type===d.type&&i.name===d.name)return d.value}return}for(l=t?hj:dj,a=0;a<o;++a)this.each(l(s[a],t,n));return this}function Vf(e,t,n){var s=zf(e),a=s.CustomEvent;typeof a=="function"?a=new a(t,n):(a=s.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function pj(e,t){return function(){return Vf(this,e,t)}}function mj(e,t){return function(){return Vf(this,e,t.apply(this,arguments))}}function xj(e,t){return this.each((typeof t=="function"?mj:pj)(e,t))}function*gj(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,o=s.length,i;a<o;++a)(i=s[a])&&(yield i)}var qf=[null];function et(e,t){this._groups=e,this._parents=t}function as(){return new et([[document.documentElement]],qf)}function yj(){return this}et.prototype=as.prototype={constructor:et,select:VN,selectAll:KN,selectChild:JN,selectChildren:nS,filter:rS,data:cS,enter:sS,exit:dS,join:hS,merge:fS,selection:yj,order:pS,sort:mS,call:gS,nodes:yS,node:bS,size:vS,empty:wS,each:NS,attr:TS,style:IS,property:DS,classed:BS,text:qS,html:YS,raise:ZS,lower:QS,append:ej,insert:nj,remove:sj,clone:ij,datum:lj,on:fj,dispatch:xj,[Symbol.iterator]:gj};function nt(e){return typeof e=="string"?new et([[document.querySelector(e)]],[document.documentElement]):new et([[e]],qf)}function bj(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ot(e,t){if(e=bj(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const vj={passive:!1},Br={capture:!0,passive:!1};function uo(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function Wf(e){var t=e.document.documentElement,n=nt(e).on("dragstart.drag",Yn,Br);"onselectstart"in t?n.on("selectstart.drag",Yn,Br):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Gf(e,t){var n=e.document.documentElement,s=nt(e).on("dragstart.drag",null);t&&(s.on("click.drag",Yn,Br),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const xs=e=>()=>e;function Zo(e,{sourceEvent:t,subject:n,target:s,identifier:a,active:o,x:i,y:l,dx:u,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}Zo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function wj(e){return!e.ctrlKey&&!e.button}function Nj(){return this.parentNode}function Sj(e,t){return t??{x:e.x,y:e.y}}function jj(){return navigator.maxTouchPoints||"ontouchstart"in this}function kj(){var e=wj,t=Nj,n=Sj,s=jj,a={},o=Ma("start","drag","end"),i=0,l,u,c,d,f=0;function p(w){w.on("mousedown.drag",x).filter(s).on("touchstart.drag",y).on("touchmove.drag",b,vj).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(w,j){if(!(d||!e.call(this,w,j))){var k=N(this,t.call(this,w,j),w,j,"mouse");k&&(nt(w.view).on("mousemove.drag",g,Br).on("mouseup.drag",m,Br),Wf(w.view),uo(w),c=!1,l=w.clientX,u=w.clientY,k("start",w))}}function g(w){if(Yn(w),!c){var j=w.clientX-l,k=w.clientY-u;c=j*j+k*k>f}a.mouse("drag",w)}function m(w){nt(w.view).on("mousemove.drag mouseup.drag",null),Gf(w.view,c),Yn(w),a.mouse("end",w)}function y(w,j){if(e.call(this,w,j)){var k=w.changedTouches,_=t.call(this,w,j),P=k.length,T,$;for(T=0;T<P;++T)($=N(this,_,w,j,k[T].identifier,k[T]))&&(uo(w),$("start",w,k[T]))}}function b(w){var j=w.changedTouches,k=j.length,_,P;for(_=0;_<k;++_)(P=a[j[_].identifier])&&(Yn(w),P("drag",w,j[_]))}function v(w){var j=w.changedTouches,k=j.length,_,P;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),_=0;_<k;++_)(P=a[j[_].identifier])&&(uo(w),P("end",w,j[_]))}function N(w,j,k,_,P,T){var $=o.copy(),B=ot(T||k,j),D,R,S;if((S=n.call(w,new Zo("beforestart",{sourceEvent:k,target:p,identifier:P,active:i,x:B[0],y:B[1],dx:0,dy:0,dispatch:$}),_))!=null)return D=S.x-B[0]||0,R=S.y-B[1]||0,function C(E,A,O){var I=B,F;switch(E){case"start":a[P]=C,F=i++;break;case"end":delete a[P],--i;case"drag":B=ot(O||A,j),F=i;break}$.call(E,w,new Zo(E,{sourceEvent:A,subject:S,target:p,identifier:P,active:F,x:B[0]+D,y:B[1]+R,dx:B[0]-I[0],dy:B[1]-I[1],dispatch:$}),_)}}return p.filter=function(w){return arguments.length?(e=typeof w=="function"?w:xs(!!w),p):e},p.container=function(w){return arguments.length?(t=typeof w=="function"?w:xs(w),p):t},p.subject=function(w){return arguments.length?(n=typeof w=="function"?w:xs(w),p):n},p.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:xs(!!w),p):s},p.on=function(){var w=o.on.apply(o,arguments);return w===o?p:w},p.clickDistance=function(w){return arguments.length?(f=(w=+w)*w,p):Math.sqrt(f)},p}function Zi(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Kf(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function os(){}var Hr=.7,na=1/Hr,Xn="\\s*([+-]?\\d+)\\s*",Ur="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ej=/^#([0-9a-f]{3,8})$/,_j=new RegExp(`^rgb\\(${Xn},${Xn},${Xn}\\)$`),Cj=new RegExp(`^rgb\\(${wt},${wt},${wt}\\)$`),Tj=new RegExp(`^rgba\\(${Xn},${Xn},${Xn},${Ur}\\)$`),Rj=new RegExp(`^rgba\\(${wt},${wt},${wt},${Ur}\\)$`),Aj=new RegExp(`^hsl\\(${Ur},${wt},${wt}\\)$`),Mj=new RegExp(`^hsla\\(${Ur},${wt},${wt},${Ur}\\)$`),Dc={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Zi(os,Vr,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$c,formatHex:$c,formatHex8:Ij,formatHsl:Pj,formatRgb:zc,toString:zc});function $c(){return this.rgb().formatHex()}function Ij(){return this.rgb().formatHex8()}function Pj(){return Yf(this).formatHsl()}function zc(){return this.rgb().formatRgb()}function Vr(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Ej.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Fc(t):n===3?new Ye(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?gs(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?gs(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=_j.exec(e))?new Ye(t[1],t[2],t[3],1):(t=Cj.exec(e))?new Ye(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Tj.exec(e))?gs(t[1],t[2],t[3],t[4]):(t=Rj.exec(e))?gs(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Aj.exec(e))?Uc(t[1],t[2]/100,t[3]/100,1):(t=Mj.exec(e))?Uc(t[1],t[2]/100,t[3]/100,t[4]):Dc.hasOwnProperty(e)?Fc(Dc[e]):e==="transparent"?new Ye(NaN,NaN,NaN,0):null}function Fc(e){return new Ye(e>>16&255,e>>8&255,e&255,1)}function gs(e,t,n,s){return s<=0&&(e=t=n=NaN),new Ye(e,t,n,s)}function Oj(e){return e instanceof os||(e=Vr(e)),e?(e=e.rgb(),new Ye(e.r,e.g,e.b,e.opacity)):new Ye}function Jo(e,t,n,s){return arguments.length===1?Oj(e):new Ye(e,t,n,s??1)}function Ye(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Zi(Ye,Jo,Kf(os,{brighter(e){return e=e==null?na:Math.pow(na,e),new Ye(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Hr:Math.pow(Hr,e),new Ye(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ye(gn(this.r),gn(this.g),gn(this.b),ra(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Bc,formatHex:Bc,formatHex8:Lj,formatRgb:Hc,toString:Hc}));function Bc(){return`#${mn(this.r)}${mn(this.g)}${mn(this.b)}`}function Lj(){return`#${mn(this.r)}${mn(this.g)}${mn(this.b)}${mn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hc(){const e=ra(this.opacity);return`${e===1?"rgb(":"rgba("}${gn(this.r)}, ${gn(this.g)}, ${gn(this.b)}${e===1?")":`, ${e})`}`}function ra(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function mn(e){return e=gn(e),(e<16?"0":"")+e.toString(16)}function Uc(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ct(e,t,n,s)}function Yf(e){if(e instanceof ct)return new ct(e.h,e.s,e.l,e.opacity);if(e instanceof os||(e=Vr(e)),!e)return new ct;if(e instanceof ct)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,a=Math.min(t,n,s),o=Math.max(t,n,s),i=NaN,l=o-a,u=(o+a)/2;return l?(t===o?i=(n-s)/l+(n<s)*6:n===o?i=(s-t)/l+2:i=(t-n)/l+4,l/=u<.5?o+a:2-o-a,i*=60):l=u>0&&u<1?0:i,new ct(i,l,u,e.opacity)}function Dj(e,t,n,s){return arguments.length===1?Yf(e):new ct(e,t,n,s??1)}function ct(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Zi(ct,Dj,Kf(os,{brighter(e){return e=e==null?na:Math.pow(na,e),new ct(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Hr:Math.pow(Hr,e),new ct(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,s=n+(n<.5?n:1-n)*t,a=2*n-s;return new Ye(ho(e>=240?e-240:e+120,a,s),ho(e,a,s),ho(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new ct(Vc(this.h),ys(this.s),ys(this.l),ra(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ra(this.opacity);return`${e===1?"hsl(":"hsla("}${Vc(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Vc(e){return e=(e||0)%360,e<0?e+360:e}function ys(e){return Math.max(0,Math.min(1,e||0))}function ho(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Xf=e=>()=>e;function $j(e,t){return function(n){return e+n*t}}function zj(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(s){return Math.pow(e+s*t,n)}}function Fj(e){return(e=+e)==1?Zf:function(t,n){return n-t?zj(t,n,e):Xf(isNaN(t)?n:t)}}function Zf(e,t){var n=t-e;return n?$j(e,n):Xf(isNaN(e)?t:e)}const qc=function e(t){var n=Fj(t);function s(a,o){var i=n((a=Jo(a)).r,(o=Jo(o)).r),l=n(a.g,o.g),u=n(a.b,o.b),c=Zf(a.opacity,o.opacity);return function(d){return a.r=i(d),a.g=l(d),a.b=u(d),a.opacity=c(d),a+""}}return s.gamma=e,s}(1);function Vt(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Qo=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,fo=new RegExp(Qo.source,"g");function Bj(e){return function(){return e}}function Hj(e){return function(t){return e(t)+""}}function Uj(e,t){var n=Qo.lastIndex=fo.lastIndex=0,s,a,o,i=-1,l=[],u=[];for(e=e+"",t=t+"";(s=Qo.exec(e))&&(a=fo.exec(t));)(o=a.index)>n&&(o=t.slice(n,o),l[i]?l[i]+=o:l[++i]=o),(s=s[0])===(a=a[0])?l[i]?l[i]+=a:l[++i]=a:(l[++i]=null,u.push({i,x:Vt(s,a)})),n=fo.lastIndex;return n<t.length&&(o=t.slice(n),l[i]?l[i]+=o:l[++i]=o),l.length<2?u[0]?Hj(u[0].x):Bj(t):(t=u.length,function(c){for(var d=0,f;d<t;++d)l[(f=u[d]).i]=f.x(c);return l.join("")})}var Wc=180/Math.PI,ei={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Jf(e,t,n,s,a,o){var i,l,u;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(u=e*n+t*s)&&(n-=e*u,s-=t*u),(l=Math.sqrt(n*n+s*s))&&(n/=l,s/=l,u/=l),e*s<t*n&&(e=-e,t=-t,u=-u,i=-i),{translateX:a,translateY:o,rotate:Math.atan2(t,e)*Wc,skewX:Math.atan(u)*Wc,scaleX:i,scaleY:l}}var bs;function Vj(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ei:Jf(t.a,t.b,t.c,t.d,t.e,t.f)}function qj(e){return e==null||(bs||(bs=document.createElementNS("http://www.w3.org/2000/svg","g")),bs.setAttribute("transform",e),!(e=bs.transform.baseVal.consolidate()))?ei:(e=e.matrix,Jf(e.a,e.b,e.c,e.d,e.e,e.f))}function Qf(e,t,n,s){function a(c){return c.length?c.pop()+" ":""}function o(c,d,f,p,x,g){if(c!==f||d!==p){var m=x.push("translate(",null,t,null,n);g.push({i:m-4,x:Vt(c,f)},{i:m-2,x:Vt(d,p)})}else(f||p)&&x.push("translate("+f+t+p+n)}function i(c,d,f,p){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),p.push({i:f.push(a(f)+"rotate(",null,s)-2,x:Vt(c,d)})):d&&f.push(a(f)+"rotate("+d+s)}function l(c,d,f,p){c!==d?p.push({i:f.push(a(f)+"skewX(",null,s)-2,x:Vt(c,d)}):d&&f.push(a(f)+"skewX("+d+s)}function u(c,d,f,p,x,g){if(c!==f||d!==p){var m=x.push(a(x)+"scale(",null,",",null,")");g.push({i:m-4,x:Vt(c,f)},{i:m-2,x:Vt(d,p)})}else(f!==1||p!==1)&&x.push(a(x)+"scale("+f+","+p+")")}return function(c,d){var f=[],p=[];return c=e(c),d=e(d),o(c.translateX,c.translateY,d.translateX,d.translateY,f,p),i(c.rotate,d.rotate,f,p),l(c.skewX,d.skewX,f,p),u(c.scaleX,c.scaleY,d.scaleX,d.scaleY,f,p),c=d=null,function(x){for(var g=-1,m=p.length,y;++g<m;)f[(y=p[g]).i]=y.x(x);return f.join("")}}}var Wj=Qf(Vj,"px, ","px)","deg)"),Gj=Qf(qj,", ",")",")"),Kj=1e-12;function Gc(e){return((e=Math.exp(e))+1/e)/2}function Yj(e){return((e=Math.exp(e))-1/e)/2}function Xj(e){return((e=Math.exp(2*e))-1)/(e+1)}const Zj=function e(t,n,s){function a(o,i){var l=o[0],u=o[1],c=o[2],d=i[0],f=i[1],p=i[2],x=d-l,g=f-u,m=x*x+g*g,y,b;if(m<Kj)b=Math.log(p/c)/t,y=function(_){return[l+_*x,u+_*g,c*Math.exp(t*_*b)]};else{var v=Math.sqrt(m),N=(p*p-c*c+s*m)/(2*c*n*v),w=(p*p-c*c-s*m)/(2*p*n*v),j=Math.log(Math.sqrt(N*N+1)-N),k=Math.log(Math.sqrt(w*w+1)-w);b=(k-j)/t,y=function(_){var P=_*b,T=Gc(j),$=c/(n*v)*(T*Xj(t*P+j)-Yj(j));return[l+$*x,u+$*g,c*T/Gc(t*P+j)]}}return y.duration=b*1e3*t/Math.SQRT2,y}return a.rho=function(o){var i=Math.max(.001,+o),l=i*i,u=l*l;return e(i,l,u)},a}(Math.SQRT2,2,4);var sr=0,Tr=0,br=0,ep=1e3,sa,Rr,aa=0,jn=0,Pa=0,qr=typeof performance=="object"&&performance.now?performance:Date,tp=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ji(){return jn||(tp(Jj),jn=qr.now()+Pa)}function Jj(){jn=0}function oa(){this._call=this._time=this._next=null}oa.prototype=np.prototype={constructor:oa,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Ji():+n)+(t==null?0:+t),!this._next&&Rr!==this&&(Rr?Rr._next=this:sa=this,Rr=this),this._call=e,this._time=n,ti()},stop:function(){this._call&&(this._call=null,this._time=1/0,ti())}};function np(e,t,n){var s=new oa;return s.restart(e,t,n),s}function Qj(){Ji(),++sr;for(var e=sa,t;e;)(t=jn-e._time)>=0&&e._call.call(void 0,t),e=e._next;--sr}function Kc(){jn=(aa=qr.now())+Pa,sr=Tr=0;try{Qj()}finally{sr=0,tk(),jn=0}}function ek(){var e=qr.now(),t=e-aa;t>ep&&(Pa-=t,aa=e)}function tk(){for(var e,t=sa,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:sa=n);Rr=e,ti(s)}function ti(e){if(!sr){Tr&&(Tr=clearTimeout(Tr));var t=e-jn;t>24?(e<1/0&&(Tr=setTimeout(Kc,e-qr.now()-Pa)),br&&(br=clearInterval(br))):(br||(aa=qr.now(),br=setInterval(ek,ep)),sr=1,tp(Kc))}}function Yc(e,t,n){var s=new oa;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var nk=Ma("start","end","cancel","interrupt"),rk=[],rp=0,Xc=1,ni=2,Fs=3,Zc=4,ri=5,Bs=6;function Oa(e,t,n,s,a,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;sk(e,n,{name:t,index:s,group:a,on:nk,tween:rk,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:rp})}function Qi(e,t){var n=pt(e,t);if(n.state>rp)throw new Error("too late; already scheduled");return n}function jt(e,t){var n=pt(e,t);if(n.state>Fs)throw new Error("too late; already running");return n}function pt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function sk(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=np(o,0,n.time);function o(c){n.state=Xc,n.timer.restart(i,n.delay,n.time),n.delay<=c&&i(c-n.delay)}function i(c){var d,f,p,x;if(n.state!==Xc)return u();for(d in s)if(x=s[d],x.name===n.name){if(x.state===Fs)return Yc(i);x.state===Zc?(x.state=Bs,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[d]):+d<t&&(x.state=Bs,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[d])}if(Yc(function(){n.state===Fs&&(n.state=Zc,n.timer.restart(l,n.delay,n.time),l(c))}),n.state=ni,n.on.call("start",e,e.__data__,n.index,n.group),n.state===ni){for(n.state=Fs,a=new Array(p=n.tween.length),d=0,f=-1;d<p;++d)(x=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(a[++f]=x);a.length=f+1}}function l(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(u),n.state=ri,1),f=-1,p=a.length;++f<p;)a[f].call(e,d);n.state===ri&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Bs,n.timer.stop(),delete s[t];for(var c in s)return;delete e.__transition}}function Hs(e,t){var n=e.__transition,s,a,o=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((s=n[i]).name!==t){o=!1;continue}a=s.state>ni&&s.state<ri,s.state=Bs,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function ak(e){return this.each(function(){Hs(this,e)})}function ok(e,t){var n,s;return function(){var a=jt(this,e),o=a.tween;if(o!==n){s=n=o;for(var i=0,l=s.length;i<l;++i)if(s[i].name===t){s=s.slice(),s.splice(i,1);break}}a.tween=s}}function ik(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var o=jt(this,e),i=o.tween;if(i!==s){a=(s=i).slice();for(var l={name:t,value:n},u=0,c=a.length;u<c;++u)if(a[u].name===t){a[u]=l;break}u===c&&a.push(l)}o.tween=a}}function lk(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=pt(this.node(),n).tween,a=0,o=s.length,i;a<o;++a)if((i=s[a]).name===e)return i.value;return null}return this.each((t==null?ok:ik)(n,e,t))}function el(e,t,n){var s=e._id;return e.each(function(){var a=jt(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return pt(a,s).value[t]}}function sp(e,t){var n;return(typeof t=="number"?Vt:t instanceof Vr?qc:(n=Vr(t))?(t=n,qc):Uj)(e,t)}function ck(e){return function(){this.removeAttribute(e)}}function uk(e){return function(){this.removeAttributeNS(e.space,e.local)}}function dk(e,t,n){var s,a=n+"",o;return function(){var i=this.getAttribute(e);return i===a?null:i===s?o:o=t(s=i,n)}}function hk(e,t,n){var s,a=n+"",o;return function(){var i=this.getAttributeNS(e.space,e.local);return i===a?null:i===s?o:o=t(s=i,n)}}function fk(e,t,n){var s,a,o;return function(){var i,l=n(this),u;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),u=l+"",i===u?null:i===s&&u===a?o:(a=u,o=t(s=i,l)))}}function pk(e,t,n){var s,a,o;return function(){var i,l=n(this),u;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),u=l+"",i===u?null:i===s&&u===a?o:(a=u,o=t(s=i,l)))}}function mk(e,t){var n=Ia(e),s=n==="transform"?Gj:sp;return this.attrTween(e,typeof t=="function"?(n.local?pk:fk)(n,s,el(this,"attr."+e,t)):t==null?(n.local?uk:ck)(n):(n.local?hk:dk)(n,s,t))}function xk(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function gk(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function yk(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&gk(e,o)),n}return a._value=t,a}function bk(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&xk(e,o)),n}return a._value=t,a}function vk(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var s=Ia(e);return this.tween(n,(s.local?yk:bk)(s,t))}function wk(e,t){return function(){Qi(this,e).delay=+t.apply(this,arguments)}}function Nk(e,t){return t=+t,function(){Qi(this,e).delay=t}}function Sk(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?wk:Nk)(t,e)):pt(this.node(),t).delay}function jk(e,t){return function(){jt(this,e).duration=+t.apply(this,arguments)}}function kk(e,t){return t=+t,function(){jt(this,e).duration=t}}function Ek(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?jk:kk)(t,e)):pt(this.node(),t).duration}function _k(e,t){if(typeof t!="function")throw new Error;return function(){jt(this,e).ease=t}}function Ck(e){var t=this._id;return arguments.length?this.each(_k(t,e)):pt(this.node(),t).ease}function Tk(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;jt(this,e).ease=n}}function Rk(e){if(typeof e!="function")throw new Error;return this.each(Tk(this._id,e))}function Ak(e){typeof e!="function"&&(e=Lf(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,l=s[a]=[],u,c=0;c<i;++c)(u=o[c])&&e.call(u,u.__data__,c,o)&&l.push(u);return new Lt(s,this._parents,this._name,this._id)}function Mk(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,a=n.length,o=Math.min(s,a),i=new Array(s),l=0;l<o;++l)for(var u=t[l],c=n[l],d=u.length,f=i[l]=new Array(d),p,x=0;x<d;++x)(p=u[x]||c[x])&&(f[x]=p);for(;l<s;++l)i[l]=t[l];return new Lt(i,this._parents,this._name,this._id)}function Ik(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Pk(e,t,n){var s,a,o=Ik(t)?Qi:jt;return function(){var i=o(this,e),l=i.on;l!==s&&(a=(s=l).copy()).on(t,n),i.on=a}}function Ok(e,t){var n=this._id;return arguments.length<2?pt(this.node(),n).on.on(e):this.each(Pk(n,e,t))}function Lk(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Dk(){return this.on("end.remove",Lk(this._id))}function $k(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Yi(e));for(var s=this._groups,a=s.length,o=new Array(a),i=0;i<a;++i)for(var l=s[i],u=l.length,c=o[i]=new Array(u),d,f,p=0;p<u;++p)(d=l[p])&&(f=e.call(d,d.__data__,p,l))&&("__data__"in d&&(f.__data__=d.__data__),c[p]=f,Oa(c[p],t,n,p,c,pt(d,n)));return new Lt(o,this._parents,t,n)}function zk(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Of(e));for(var s=this._groups,a=s.length,o=[],i=[],l=0;l<a;++l)for(var u=s[l],c=u.length,d,f=0;f<c;++f)if(d=u[f]){for(var p=e.call(d,d.__data__,f,u),x,g=pt(d,n),m=0,y=p.length;m<y;++m)(x=p[m])&&Oa(x,t,n,m,p,g);o.push(p),i.push(d)}return new Lt(o,i,t,n)}var Fk=as.prototype.constructor;function Bk(){return new Fk(this._groups,this._parents)}function Hk(e,t){var n,s,a;return function(){var o=rr(this,e),i=(this.style.removeProperty(e),rr(this,e));return o===i?null:o===n&&i===s?a:a=t(n=o,s=i)}}function ap(e){return function(){this.style.removeProperty(e)}}function Uk(e,t,n){var s,a=n+"",o;return function(){var i=rr(this,e);return i===a?null:i===s?o:o=t(s=i,n)}}function Vk(e,t,n){var s,a,o;return function(){var i=rr(this,e),l=n(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),rr(this,e))),i===u?null:i===s&&u===a?o:(a=u,o=t(s=i,l))}}function qk(e,t){var n,s,a,o="style."+t,i="end."+o,l;return function(){var u=jt(this,e),c=u.on,d=u.value[o]==null?l||(l=ap(t)):void 0;(c!==n||a!==d)&&(s=(n=c).copy()).on(i,a=d),u.on=s}}function Wk(e,t,n){var s=(e+="")=="transform"?Wj:sp;return t==null?this.styleTween(e,Hk(e,s)).on("end.style."+e,ap(e)):typeof t=="function"?this.styleTween(e,Vk(e,s,el(this,"style."+e,t))).each(qk(this._id,e)):this.styleTween(e,Uk(e,s,t),n).on("end.style."+e,null)}function Gk(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Kk(e,t,n){var s,a;function o(){var i=t.apply(this,arguments);return i!==a&&(s=(a=i)&&Gk(e,i,n)),s}return o._value=t,o}function Yk(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,Kk(e,t,n??""))}function Xk(e){return function(){this.textContent=e}}function Zk(e){return function(){var t=e(this);this.textContent=t??""}}function Jk(e){return this.tween("text",typeof e=="function"?Zk(el(this,"text",e)):Xk(e==null?"":e+""))}function Qk(e){return function(t){this.textContent=e.call(this,t)}}function eE(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&Qk(a)),t}return s._value=e,s}function tE(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,eE(e))}function nE(){for(var e=this._name,t=this._id,n=op(),s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],l=i.length,u,c=0;c<l;++c)if(u=i[c]){var d=pt(u,t);Oa(u,e,n,c,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Lt(s,this._parents,e,n)}function rE(){var e,t,n=this,s=n._id,a=n.size();return new Promise(function(o,i){var l={value:i},u={value:function(){--a===0&&o()}};n.each(function(){var c=jt(this,s),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),c.on=t}),a===0&&o()})}var sE=0;function Lt(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function op(){return++sE}var Ct=as.prototype;Lt.prototype={constructor:Lt,select:$k,selectAll:zk,selectChild:Ct.selectChild,selectChildren:Ct.selectChildren,filter:Ak,merge:Mk,selection:Bk,transition:nE,call:Ct.call,nodes:Ct.nodes,node:Ct.node,size:Ct.size,empty:Ct.empty,each:Ct.each,on:Ok,attr:mk,attrTween:vk,style:Wk,styleTween:Yk,text:Jk,textTween:tE,remove:Dk,tween:lk,delay:Sk,duration:Ek,ease:Ck,easeVarying:Rk,end:rE,[Symbol.iterator]:Ct[Symbol.iterator]};function aE(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var oE={time:null,delay:0,duration:250,ease:aE};function iE(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function lE(e){var t,n;e instanceof Lt?(t=e._id,e=e._name):(t=op(),(n=oE).time=Ji(),e=e==null?null:e+"");for(var s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],l=i.length,u,c=0;c<l;++c)(u=i[c])&&Oa(u,e,t,c,i,n||iE(u,t));return new Lt(s,this._parents,e,t)}as.prototype.interrupt=ak;as.prototype.transition=lE;const vs=e=>()=>e;function cE(e,{sourceEvent:t,target:n,transform:s,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:a}})}function At(e,t,n){this.k=e,this.x=t,this.y=n}At.prototype={constructor:At,scale:function(e){return e===1?this:new At(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new At(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Mt=new At(1,0,0);At.prototype;function po(e){e.stopImmediatePropagation()}function vr(e){e.preventDefault(),e.stopImmediatePropagation()}function uE(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function dE(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Jc(){return this.__zoom||Mt}function hE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function fE(){return navigator.maxTouchPoints||"ontouchstart"in this}function pE(e,t,n){var s=e.invertX(t[0][0])-n[0][0],a=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function ip(){var e=uE,t=dE,n=pE,s=hE,a=fE,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,u=Zj,c=Ma("start","zoom","end"),d,f,p,x=500,g=150,m=0,y=10;function b(S){S.property("__zoom",Jc).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",$).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(S,C,E,A){var O=S.selection?S.selection():S;O.property("__zoom",Jc),S!==O?j(S,C,E,A):O.interrupt().each(function(){k(this,arguments).event(A).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},b.scaleBy=function(S,C,E,A){b.scaleTo(S,function(){var O=this.__zoom.k,I=typeof C=="function"?C.apply(this,arguments):C;return O*I},E,A)},b.scaleTo=function(S,C,E,A){b.transform(S,function(){var O=t.apply(this,arguments),I=this.__zoom,F=E==null?w(O):typeof E=="function"?E.apply(this,arguments):E,L=I.invert(F),M=typeof C=="function"?C.apply(this,arguments):C;return n(N(v(I,M),F,L),O,i)},E,A)},b.translateBy=function(S,C,E,A){b.transform(S,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof E=="function"?E.apply(this,arguments):E),t.apply(this,arguments),i)},null,A)},b.translateTo=function(S,C,E,A,O){b.transform(S,function(){var I=t.apply(this,arguments),F=this.__zoom,L=A==null?w(I):typeof A=="function"?A.apply(this,arguments):A;return n(Mt.translate(L[0],L[1]).scale(F.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof E=="function"?-E.apply(this,arguments):-E),I,i)},A,O)};function v(S,C){return C=Math.max(o[0],Math.min(o[1],C)),C===S.k?S:new At(C,S.x,S.y)}function N(S,C,E){var A=C[0]-E[0]*S.k,O=C[1]-E[1]*S.k;return A===S.x&&O===S.y?S:new At(S.k,A,O)}function w(S){return[(+S[0][0]+ +S[1][0])/2,(+S[0][1]+ +S[1][1])/2]}function j(S,C,E,A){S.on("start.zoom",function(){k(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(A).end()}).tween("zoom",function(){var O=this,I=arguments,F=k(O,I).event(A),L=t.apply(O,I),M=E==null?w(L):typeof E=="function"?E.apply(O,I):E,z=Math.max(L[1][0]-L[0][0],L[1][1]-L[0][1]),H=O.__zoom,V=typeof C=="function"?C.apply(O,I):C,Z=u(H.invert(M).concat(z/H.k),V.invert(M).concat(z/V.k));return function(G){if(G===1)G=V;else{var J=Z(G),ee=z/J[2];G=new At(ee,M[0]-J[0]*ee,M[1]-J[1]*ee)}F.zoom(null,G)}})}function k(S,C,E){return!E&&S.__zooming||new _(S,C)}function _(S,C){this.that=S,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(S,C),this.taps=0}_.prototype={event:function(S){return S&&(this.sourceEvent=S),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(S,C){return this.mouse&&S!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&S!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&S!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(S){var C=nt(this.that).datum();c.call(S,this.that,new cE(S,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:c}),C)}};function P(S,...C){if(!e.apply(this,arguments))return;var E=k(this,C).event(S),A=this.__zoom,O=Math.max(o[0],Math.min(o[1],A.k*Math.pow(2,s.apply(this,arguments)))),I=ot(S);if(E.wheel)(E.mouse[0][0]!==I[0]||E.mouse[0][1]!==I[1])&&(E.mouse[1]=A.invert(E.mouse[0]=I)),clearTimeout(E.wheel);else{if(A.k===O)return;E.mouse=[I,A.invert(I)],Hs(this),E.start()}vr(S),E.wheel=setTimeout(F,g),E.zoom("mouse",n(N(v(A,O),E.mouse[0],E.mouse[1]),E.extent,i));function F(){E.wheel=null,E.end()}}function T(S,...C){if(p||!e.apply(this,arguments))return;var E=S.currentTarget,A=k(this,C,!0).event(S),O=nt(S.view).on("mousemove.zoom",M,!0).on("mouseup.zoom",z,!0),I=ot(S,E),F=S.clientX,L=S.clientY;Wf(S.view),po(S),A.mouse=[I,this.__zoom.invert(I)],Hs(this),A.start();function M(H){if(vr(H),!A.moved){var V=H.clientX-F,Z=H.clientY-L;A.moved=V*V+Z*Z>m}A.event(H).zoom("mouse",n(N(A.that.__zoom,A.mouse[0]=ot(H,E),A.mouse[1]),A.extent,i))}function z(H){O.on("mousemove.zoom mouseup.zoom",null),Gf(H.view,A.moved),vr(H),A.event(H).end()}}function $(S,...C){if(e.apply(this,arguments)){var E=this.__zoom,A=ot(S.changedTouches?S.changedTouches[0]:S,this),O=E.invert(A),I=E.k*(S.shiftKey?.5:2),F=n(N(v(E,I),A,O),t.apply(this,C),i);vr(S),l>0?nt(this).transition().duration(l).call(j,F,A,S):nt(this).call(b.transform,F,A,S)}}function B(S,...C){if(e.apply(this,arguments)){var E=S.touches,A=E.length,O=k(this,C,S.changedTouches.length===A).event(S),I,F,L,M;for(po(S),F=0;F<A;++F)L=E[F],M=ot(L,this),M=[M,this.__zoom.invert(M),L.identifier],O.touch0?!O.touch1&&O.touch0[2]!==M[2]&&(O.touch1=M,O.taps=0):(O.touch0=M,I=!0,O.taps=1+!!d);d&&(d=clearTimeout(d)),I&&(O.taps<2&&(f=M[0],d=setTimeout(function(){d=null},x)),Hs(this),O.start())}}function D(S,...C){if(this.__zooming){var E=k(this,C).event(S),A=S.changedTouches,O=A.length,I,F,L,M;for(vr(S),I=0;I<O;++I)F=A[I],L=ot(F,this),E.touch0&&E.touch0[2]===F.identifier?E.touch0[0]=L:E.touch1&&E.touch1[2]===F.identifier&&(E.touch1[0]=L);if(F=E.that.__zoom,E.touch1){var z=E.touch0[0],H=E.touch0[1],V=E.touch1[0],Z=E.touch1[1],G=(G=V[0]-z[0])*G+(G=V[1]-z[1])*G,J=(J=Z[0]-H[0])*J+(J=Z[1]-H[1])*J;F=v(F,Math.sqrt(G/J)),L=[(z[0]+V[0])/2,(z[1]+V[1])/2],M=[(H[0]+Z[0])/2,(H[1]+Z[1])/2]}else if(E.touch0)L=E.touch0[0],M=E.touch0[1];else return;E.zoom("touch",n(N(F,L,M),E.extent,i))}}function R(S,...C){if(this.__zooming){var E=k(this,C).event(S),A=S.changedTouches,O=A.length,I,F;for(po(S),p&&clearTimeout(p),p=setTimeout(function(){p=null},x),I=0;I<O;++I)F=A[I],E.touch0&&E.touch0[2]===F.identifier?delete E.touch0:E.touch1&&E.touch1[2]===F.identifier&&delete E.touch1;if(E.touch1&&!E.touch0&&(E.touch0=E.touch1,delete E.touch1),E.touch0)E.touch0[1]=this.__zoom.invert(E.touch0[0]);else if(E.end(),E.taps===2&&(F=ot(F,this),Math.hypot(f[0]-F[0],f[1]-F[1])<y)){var L=nt(this).on("dblclick.zoom");L&&L.apply(this,arguments)}}}return b.wheelDelta=function(S){return arguments.length?(s=typeof S=="function"?S:vs(+S),b):s},b.filter=function(S){return arguments.length?(e=typeof S=="function"?S:vs(!!S),b):e},b.touchable=function(S){return arguments.length?(a=typeof S=="function"?S:vs(!!S),b):a},b.extent=function(S){return arguments.length?(t=typeof S=="function"?S:vs([[+S[0][0],+S[0][1]],[+S[1][0],+S[1][1]]]),b):t},b.scaleExtent=function(S){return arguments.length?(o[0]=+S[0],o[1]=+S[1],b):[o[0],o[1]]},b.translateExtent=function(S){return arguments.length?(i[0][0]=+S[0][0],i[1][0]=+S[1][0],i[0][1]=+S[0][1],i[1][1]=+S[1][1],b):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},b.constrain=function(S){return arguments.length?(n=S,b):n},b.duration=function(S){return arguments.length?(l=+S,b):l},b.interpolate=function(S){return arguments.length?(u=S,b):u},b.on=function(){var S=c.on.apply(c,arguments);return S===c?b:S},b.clickDistance=function(S){return arguments.length?(m=(S=+S)*S,b):Math.sqrt(m)},b.tapDistance=function(S){return arguments.length?(y=+S,b):y},b}const La=h.createContext(null),mE=La.Provider,Dt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},lp=Dt.error001();function Ie(e,t){const n=h.useContext(La);if(n===null)throw new Error(lp);return If(n,e,t)}const $e=()=>{const e=h.useContext(La);if(e===null)throw new Error(lp);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},xE=e=>e.userSelectionActive?"none":"all";function tl({position:e,children:t,className:n,style:s,...a}){const o=Ie(xE),i=`${e}`.split("-");return q.createElement("div",{className:Be(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...a},t)}function gE({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:q.createElement(tl,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},q.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const yE=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:u,className:c,...d})=>{const f=h.useRef(null),[p,x]=h.useState({x:0,y:0,width:0,height:0}),g=Be(["react-flow__edge-textwrapper",c]);return h.useEffect(()=>{if(f.current){const m=f.current.getBBox();x({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),typeof n>"u"||!n?null:q.createElement("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:g,visibility:p.width?"visible":"hidden",...d},a&&q.createElement("rect",{width:p.width+2*i[0],x:-i[0],y:-i[1],height:p.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),q.createElement("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:f,style:s},n),u)};var bE=h.memo(yE);const nl=e=>({width:e.offsetWidth,height:e.offsetHeight}),ar=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),rl=(e={x:0,y:0},t)=>({x:ar(e.x,t[0][0],t[1][0]),y:ar(e.y,t[0][1],t[1][1])}),Qc=(e,t,n)=>e<t?ar(Math.abs(e-t),1,50)/50:e>n?-ar(Math.abs(e-n),1,50)/50:0,cp=(e,t)=>{const n=Qc(e.x,35,t.width-35)*20,s=Qc(e.y,35,t.height-35)*20;return[n,s]},up=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},dp=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Wr=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),hp=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),eu=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),vE=(e,t)=>hp(dp(Wr(e),Wr(t))),si=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},wE=e=>rt(e.width)&&rt(e.height)&&rt(e.x)&&rt(e.y),rt=e=>!isNaN(e)&&isFinite(e),De=Symbol.for("internals"),fp=["Enter"," ","Escape"],NE=(e,t)=>{},SE=e=>"nativeEvent"in e;function ai(e){var a,o;const t=SE(e)?e.nativeEvent:e,n=((o=(a=t.composedPath)==null?void 0:a.call(t))==null?void 0:o[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const pp=e=>"clientX"in e,Xt=(e,t)=>{var o,i;const n=pp(e),s=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},ia=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},is=({id:e,path:t,labelX:n,labelY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:c,style:d,markerEnd:f,markerStart:p,interactionWidth:x=20})=>q.createElement(q.Fragment,null,q.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:p}),x&&q.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),a&&rt(n)&&rt(s)?q.createElement(bE,{x:n,y:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:c}):null);is.displayName="BaseEdge";function wr(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(o=>o.id===e);a&&n(s,{...a})}}function mp({sourceX:e,sourceY:t,targetX:n,targetY:s}){const a=Math.abs(n-e)/2,o=n<e?n+a:n-a,i=Math.abs(s-t)/2,l=s<t?s+i:s-i;return[o,l,a,i]}function xp({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:a,sourceControlY:o,targetControlX:i,targetControlY:l}){const u=e*.125+a*.375+i*.375+n*.125,c=t*.125+o*.375+l*.375+s*.125,d=Math.abs(u-e),f=Math.abs(c-t);return[u,c,d,f]}var kn;(function(e){e.Strict="strict",e.Loose="loose"})(kn||(kn={}));var xn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(xn||(xn={}));var Gr;(function(e){e.Partial="partial",e.Full="full"})(Gr||(Gr={}));var Wt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Wt||(Wt={}));var la;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(la||(la={}));var he;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(he||(he={}));function tu({pos:e,x1:t,y1:n,x2:s,y2:a}){return e===he.Left||e===he.Right?[.5*(t+s),n]:[t,.5*(n+a)]}function gp({sourceX:e,sourceY:t,sourcePosition:n=he.Bottom,targetX:s,targetY:a,targetPosition:o=he.Top}){const[i,l]=tu({pos:n,x1:e,y1:t,x2:s,y2:a}),[u,c]=tu({pos:o,x1:s,y1:a,x2:e,y2:t}),[d,f,p,x]=xp({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:i,sourceControlY:l,targetControlX:u,targetControlY:c});return[`M${e},${t} C${i},${l} ${u},${c} ${s},${a}`,d,f,p,x]}const sl=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=he.Bottom,targetPosition:o=he.Top,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:x,markerStart:g,interactionWidth:m})=>{const[y,b,v]=gp({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o});return q.createElement(is,{path:y,labelX:b,labelY:v,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:x,markerStart:g,interactionWidth:m})});sl.displayName="SimpleBezierEdge";const nu={[he.Left]:{x:-1,y:0},[he.Right]:{x:1,y:0},[he.Top]:{x:0,y:-1},[he.Bottom]:{x:0,y:1}},jE=({source:e,sourcePosition:t=he.Bottom,target:n})=>t===he.Left||t===he.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},ru=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function kE({source:e,sourcePosition:t=he.Bottom,target:n,targetPosition:s=he.Top,center:a,offset:o}){const i=nu[t],l=nu[s],u={x:e.x+i.x*o,y:e.y+i.y*o},c={x:n.x+l.x*o,y:n.y+l.y*o},d=jE({source:u,sourcePosition:t,target:c}),f=d.x!==0?"x":"y",p=d[f];let x=[],g,m;const y={x:0,y:0},b={x:0,y:0},[v,N,w,j]=mp({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[f]*l[f]===-1){g=a.x??v,m=a.y??N;const _=[{x:g,y:u.y},{x:g,y:c.y}],P=[{x:u.x,y:m},{x:c.x,y:m}];i[f]===p?x=f==="x"?_:P:x=f==="x"?P:_}else{const _=[{x:u.x,y:c.y}],P=[{x:c.x,y:u.y}];if(f==="x"?x=i.x===p?P:_:x=i.y===p?_:P,t===s){const R=Math.abs(e[f]-n[f]);if(R<=o){const S=Math.min(o-1,o-R);i[f]===p?y[f]=(u[f]>e[f]?-1:1)*S:b[f]=(c[f]>n[f]?-1:1)*S}}if(t!==s){const R=f==="x"?"y":"x",S=i[f]===l[R],C=u[R]>c[R],E=u[R]<c[R];(i[f]===1&&(!S&&C||S&&E)||i[f]!==1&&(!S&&E||S&&C))&&(x=f==="x"?_:P)}const T={x:u.x+y.x,y:u.y+y.y},$={x:c.x+b.x,y:c.y+b.y},B=Math.max(Math.abs(T.x-x[0].x),Math.abs($.x-x[0].x)),D=Math.max(Math.abs(T.y-x[0].y),Math.abs($.y-x[0].y));B>=D?(g=(T.x+$.x)/2,m=x[0].y):(g=x[0].x,m=(T.y+$.y)/2)}return[[e,{x:u.x+y.x,y:u.y+y.y},...x,{x:c.x+b.x,y:c.y+b.y},n],g,m,w,j]}function EE(e,t,n,s){const a=Math.min(ru(e,t)/2,ru(t,n)/2,s),{x:o,y:i}=t;if(e.x===o&&o===n.x||e.y===i&&i===n.y)return`L${o} ${i}`;if(e.y===i){const c=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${o+a*c},${i}Q ${o},${i} ${o},${i+a*d}`}const l=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${o},${i+a*u}Q ${o},${i} ${o+a*l},${i}`}function oi({sourceX:e,sourceY:t,sourcePosition:n=he.Bottom,targetX:s,targetY:a,targetPosition:o=he.Top,borderRadius:i=5,centerX:l,centerY:u,offset:c=20}){const[d,f,p,x,g]=kE({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:o,center:{x:l,y:u},offset:c});return[d.reduce((y,b,v)=>{let N="";return v>0&&v<d.length-1?N=EE(d[v-1],b,d[v+1],i):N=`${v===0?"M":"L"}${b.x} ${b.y}`,y+=N,y},""),f,p,x,g]}const Da=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:c,style:d,sourcePosition:f=he.Bottom,targetPosition:p=he.Top,markerEnd:x,markerStart:g,pathOptions:m,interactionWidth:y})=>{const[b,v,N]=oi({sourceX:e,sourceY:t,sourcePosition:f,targetX:n,targetY:s,targetPosition:p,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset});return q.createElement(is,{path:b,labelX:v,labelY:N,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:c,style:d,markerEnd:x,markerStart:g,interactionWidth:y})});Da.displayName="SmoothStepEdge";const al=h.memo(e=>{var t;return q.createElement(Da,{...e,pathOptions:h.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});al.displayName="StepEdge";function _E({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,o,i,l]=mp({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,o,i,l]}const ol=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:c,style:d,markerEnd:f,markerStart:p,interactionWidth:x})=>{const[g,m,y]=_E({sourceX:e,sourceY:t,targetX:n,targetY:s});return q.createElement(is,{path:g,labelX:m,labelY:y,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:c,style:d,markerEnd:f,markerStart:p,interactionWidth:x})});ol.displayName="StraightEdge";function ws(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function su({pos:e,x1:t,y1:n,x2:s,y2:a,c:o}){switch(e){case he.Left:return[t-ws(t-s,o),n];case he.Right:return[t+ws(s-t,o),n];case he.Top:return[t,n-ws(n-a,o)];case he.Bottom:return[t,n+ws(a-n,o)]}}function yp({sourceX:e,sourceY:t,sourcePosition:n=he.Bottom,targetX:s,targetY:a,targetPosition:o=he.Top,curvature:i=.25}){const[l,u]=su({pos:n,x1:e,y1:t,x2:s,y2:a,c:i}),[c,d]=su({pos:o,x1:s,y1:a,x2:e,y2:t,c:i}),[f,p,x,g]=xp({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:l,sourceControlY:u,targetControlX:c,targetControlY:d});return[`M${e},${t} C${l},${u} ${c},${d} ${s},${a}`,f,p,x,g]}const ca=h.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=he.Bottom,targetPosition:o=he.Top,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:x,markerStart:g,pathOptions:m,interactionWidth:y})=>{const[b,v,N]=yp({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:m==null?void 0:m.curvature});return q.createElement(is,{path:b,labelX:v,labelY:N,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:x,markerStart:g,interactionWidth:y})});ca.displayName="BezierEdge";const il=h.createContext(null),CE=il.Provider;il.Consumer;const TE=()=>h.useContext(il),RE=e=>"id"in e&&"source"in e&&"target"in e,AE=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,ii=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,ME=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),bp=(e,t)=>{if(!e.source||!e.target)return t;let n;return RE(e)?n={...e}:n={...e,id:AE(e)},ME(n,t)?t:t.concat(n)},li=({x:e,y:t},[n,s,a],o,[i,l])=>{const u={x:(e-n)/a,y:(t-s)/a};return o?{x:i*Math.round(u.x/i),y:l*Math.round(u.y/l)}:u},vp=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),yn=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],s=(e.height??0)*t[1],a={x:e.position.x-n,y:e.position.y-s};return{...a,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-s}:a}},$a=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,a)=>{const{x:o,y:i}=yn(a,t).positionAbsolute;return dp(s,Wr({x:o,y:i,width:a.width||0,height:a.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return hp(n)},wp=(e,t,[n,s,a]=[0,0,1],o=!1,i=!1,l=[0,0])=>{const u={x:(t.x-n)/a,y:(t.y-s)/a,width:t.width/a,height:t.height/a},c=[];return e.forEach(d=>{const{width:f,height:p,selectable:x=!0,hidden:g=!1}=d;if(i&&!x||g)return!1;const{positionAbsolute:m}=yn(d,l),y={x:m.x,y:m.y,width:f||0,height:p||0},b=si(u,y),v=typeof f>"u"||typeof p>"u"||f===null||p===null,N=o&&b>0,w=(f||0)*(p||0);(v||N||b>=w||d.dragging)&&c.push(d)}),c},Np=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},Sp=(e,t,n,s,a,o=.1)=>{const i=t/(e.width*(1+o)),l=n/(e.height*(1+o)),u=Math.min(i,l),c=ar(u,s,a),d=e.x+e.width/2,f=e.y+e.height/2,p=t/2-d*c,x=n/2-f*c;return{x:p,y:x,zoom:c}},hn=(e,t=0)=>e.transition().duration(t);function au(e,t,n,s){return(t[n]||[]).reduce((a,o)=>{var i,l;return`${e.id}-${o.id}-${n}`!==s&&a.push({id:o.id||null,type:n,nodeId:e.id,x:(((i=e.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((l=e.positionAbsolute)==null?void 0:l.y)??0)+o.y+o.height/2}),a},[])}function IE(e,t,n,s,a,o){const{x:i,y:l}=Xt(e),c=t.elementsFromPoint(i,l).find(g=>g.classList.contains("react-flow__handle"));if(c){const g=c.getAttribute("data-nodeid");if(g){const m=ll(void 0,c),y=c.getAttribute("data-handleid"),b=o({nodeId:g,id:y,type:m});if(b){const v=a.find(N=>N.nodeId===g&&N.type===m&&N.id===y);return{handle:{id:y,type:m,nodeId:g,x:(v==null?void 0:v.x)||n.x,y:(v==null?void 0:v.y)||n.y},validHandleResult:b}}}}let d=[],f=1/0;if(a.forEach(g=>{const m=Math.sqrt((g.x-n.x)**2+(g.y-n.y)**2);if(m<=s){const y=o(g);m<=f&&(m<f?d=[{handle:g,validHandleResult:y}]:m===f&&d.push({handle:g,validHandleResult:y}),f=m)}}),!d.length)return{handle:null,validHandleResult:jp()};if(d.length===1)return d[0];const p=d.some(({validHandleResult:g})=>g.isValid),x=d.some(({handle:g})=>g.type==="target");return d.find(({handle:g,validHandleResult:m})=>x?g.type==="target":p?m.isValid:!0)||d[0]}const PE={source:null,target:null,sourceHandle:null,targetHandle:null},jp=()=>({handleDomNode:null,isValid:!1,connection:PE,endHandle:null});function kp(e,t,n,s,a,o,i){const l=a==="target",u=i.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),c={...jp(),handleDomNode:u};if(u){const d=ll(void 0,u),f=u.getAttribute("data-nodeid"),p=u.getAttribute("data-handleid"),x=u.classList.contains("connectable"),g=u.classList.contains("connectableend"),m={source:l?f:n,sourceHandle:l?p:s,target:l?n:f,targetHandle:l?s:p};c.connection=m,x&&g&&(t===kn.Strict?l&&d==="source"||!l&&d==="target":f!==n||p!==s)&&(c.endHandle={nodeId:f,handleId:p,type:d},c.isValid=o(m))}return c}function OE({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((a,o)=>{if(o[De]){const{handleBounds:i}=o[De];let l=[],u=[];i&&(l=au(o,i,"source",`${t}-${n}-${s}`),u=au(o,i,"target",`${t}-${n}-${s}`)),a.push(...l,...u)}return a},[])}function ll(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function mo(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function LE(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function Ep({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:o,setState:i,isValidConnection:l,edgeUpdaterType:u,onReconnectEnd:c}){const d=up(e.target),{connectionMode:f,domNode:p,autoPanOnConnect:x,connectionRadius:g,onConnectStart:m,panBy:y,getNodes:b,cancelConnection:v}=o();let N=0,w;const{x:j,y:k}=Xt(e),_=d==null?void 0:d.elementFromPoint(j,k),P=ll(u,_),T=p==null?void 0:p.getBoundingClientRect();if(!T||!P)return;let $,B=Xt(e,T),D=!1,R=null,S=!1,C=null;const E=OE({nodes:b(),nodeId:n,handleId:t,handleType:P}),A=()=>{if(!x)return;const[F,L]=cp(B,T);y({x:F,y:L}),N=requestAnimationFrame(A)};i({connectionPosition:B,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:P,connectionStartHandle:{nodeId:n,handleId:t,type:P},connectionEndHandle:null}),m==null||m(e,{nodeId:n,handleId:t,handleType:P});function O(F){const{transform:L}=o();B=Xt(F,T);const{handle:M,validHandleResult:z}=IE(F,d,li(B,L,!1,[1,1]),g,E,H=>kp(H,f,n,t,a?"target":"source",l,d));if(w=M,D||(A(),D=!0),C=z.handleDomNode,R=z.connection,S=z.isValid,i({connectionPosition:w&&S?vp({x:w.x,y:w.y},L):B,connectionStatus:LE(!!w,S),connectionEndHandle:z.endHandle}),!w&&!S&&!C)return mo($);R.source!==R.target&&C&&(mo($),$=C,C.classList.add("connecting","react-flow__handle-connecting"),C.classList.toggle("valid",S),C.classList.toggle("react-flow__handle-valid",S))}function I(F){var L,M;(w||C)&&R&&S&&(s==null||s(R)),(M=(L=o()).onConnectEnd)==null||M.call(L,F),u&&(c==null||c(F)),mo($),v(),cancelAnimationFrame(N),D=!1,S=!1,R=null,C=null,d.removeEventListener("mousemove",O),d.removeEventListener("mouseup",I),d.removeEventListener("touchmove",O),d.removeEventListener("touchend",I)}d.addEventListener("mousemove",O),d.addEventListener("mouseup",I),d.addEventListener("touchmove",O),d.addEventListener("touchend",I)}const ou=()=>!0,DE=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),$E=(e,t,n)=>s=>{const{connectionStartHandle:a,connectionEndHandle:o,connectionClickStartHandle:i}=s;return{connecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.type)===n||(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n}},_p=h.forwardRef(({type:e="source",position:t=he.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:i,onConnect:l,children:u,className:c,onMouseDown:d,onTouchStart:f,...p},x)=>{var T,$;const g=i||null,m=e==="target",y=$e(),b=TE(),{connectOnClick:v,noPanClassName:N}=Ie(DE,ze),{connecting:w,clickConnecting:j}=Ie($E(b,g,e),ze);b||($=(T=y.getState()).onError)==null||$.call(T,"010",Dt.error010());const k=B=>{const{defaultEdgeOptions:D,onConnect:R,hasDefaultEdges:S}=y.getState(),C={...D,...B};if(S){const{edges:E,setEdges:A}=y.getState();A(bp(C,E))}R==null||R(C),l==null||l(C)},_=B=>{if(!b)return;const D=pp(B);a&&(D&&B.button===0||!D)&&Ep({event:B,handleId:g,nodeId:b,onConnect:k,isTarget:m,getState:y.getState,setState:y.setState,isValidConnection:n||y.getState().isValidConnection||ou}),D?d==null||d(B):f==null||f(B)},P=B=>{const{onClickConnectStart:D,onClickConnectEnd:R,connectionClickStartHandle:S,connectionMode:C,isValidConnection:E}=y.getState();if(!b||!S&&!a)return;if(!S){D==null||D(B,{nodeId:b,handleId:g,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:g}});return}const A=up(B.target),O=n||E||ou,{connection:I,isValid:F}=kp({nodeId:b,id:g,type:e},C,S.nodeId,S.handleId||null,S.type,O,A);F&&k(I),R==null||R(B),y.setState({connectionClickStartHandle:null})};return q.createElement("div",{"data-handleid":g,"data-nodeid":b,"data-handlepos":t,"data-id":`${b}-${g}-${e}`,className:Be(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,c,{source:!m,target:m,connectable:s,connectablestart:a,connectableend:o,connecting:j,connectionindicator:s&&(a&&!w||o&&w)}]),onMouseDown:_,onTouchStart:_,onClick:v?P:void 0,ref:x,...p},u)});_p.displayName="Handle";var ua=h.memo(_p);const Cp=({data:e,isConnectable:t,targetPosition:n=he.Top,sourcePosition:s=he.Bottom})=>q.createElement(q.Fragment,null,q.createElement(ua,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,q.createElement(ua,{type:"source",position:s,isConnectable:t}));Cp.displayName="DefaultNode";var ci=h.memo(Cp);const Tp=({data:e,isConnectable:t,sourcePosition:n=he.Bottom})=>q.createElement(q.Fragment,null,e==null?void 0:e.label,q.createElement(ua,{type:"source",position:n,isConnectable:t}));Tp.displayName="InputNode";var Rp=h.memo(Tp);const Ap=({data:e,isConnectable:t,targetPosition:n=he.Top})=>q.createElement(q.Fragment,null,q.createElement(ua,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);Ap.displayName="OutputNode";var Mp=h.memo(Ap);const cl=()=>null;cl.displayName="GroupNode";const zE=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Ns=e=>e.id;function FE(e,t){return ze(e.selectedNodes.map(Ns),t.selectedNodes.map(Ns))&&ze(e.selectedEdges.map(Ns),t.selectedEdges.map(Ns))}const Ip=h.memo(({onSelectionChange:e})=>{const t=$e(),{selectedNodes:n,selectedEdges:s}=Ie(zE,FE);return h.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(o=>o(a))},[n,s,e]),null});Ip.displayName="SelectionListener";const BE=e=>!!e.onSelectionChange;function HE({onSelectionChange:e}){const t=Ie(BE);return e||t?q.createElement(Ip,{onSelectionChange:e}):null}const UE=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Pn(e,t){h.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function ye(e,t,n){h.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const VE=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:a,onConnectStart:o,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:u,nodesDraggable:c,nodesConnectable:d,nodesFocusable:f,edgesFocusable:p,edgesUpdatable:x,elevateNodesOnSelect:g,minZoom:m,maxZoom:y,nodeExtent:b,onNodesChange:v,onEdgesChange:N,elementsSelectable:w,connectionMode:j,snapGrid:k,snapToGrid:_,translateExtent:P,connectOnClick:T,defaultEdgeOptions:$,fitView:B,fitViewOptions:D,onNodesDelete:R,onEdgesDelete:S,onNodeDrag:C,onNodeDragStart:E,onNodeDragStop:A,onSelectionDrag:O,onSelectionDragStart:I,onSelectionDragStop:F,noPanClassName:L,nodeOrigin:M,rfId:z,autoPanOnConnect:H,autoPanOnNodeDrag:V,onError:Z,connectionRadius:G,isValidConnection:J,nodeDragThreshold:ee})=>{const{setNodes:te,setEdges:oe,setDefaultNodesAndEdges:ie,setMinZoom:me,setMaxZoom:W,setTranslateExtent:fe,setNodeExtent:Ae,reset:ge}=Ie(UE,ze),Y=$e();return h.useEffect(()=>{const Pe=s==null?void 0:s.map(Te=>({...Te,...$}));return ie(n,Pe),()=>{ge()}},[]),ye("defaultEdgeOptions",$,Y.setState),ye("connectionMode",j,Y.setState),ye("onConnect",a,Y.setState),ye("onConnectStart",o,Y.setState),ye("onConnectEnd",i,Y.setState),ye("onClickConnectStart",l,Y.setState),ye("onClickConnectEnd",u,Y.setState),ye("nodesDraggable",c,Y.setState),ye("nodesConnectable",d,Y.setState),ye("nodesFocusable",f,Y.setState),ye("edgesFocusable",p,Y.setState),ye("edgesUpdatable",x,Y.setState),ye("elementsSelectable",w,Y.setState),ye("elevateNodesOnSelect",g,Y.setState),ye("snapToGrid",_,Y.setState),ye("snapGrid",k,Y.setState),ye("onNodesChange",v,Y.setState),ye("onEdgesChange",N,Y.setState),ye("connectOnClick",T,Y.setState),ye("fitViewOnInit",B,Y.setState),ye("fitViewOnInitOptions",D,Y.setState),ye("onNodesDelete",R,Y.setState),ye("onEdgesDelete",S,Y.setState),ye("onNodeDrag",C,Y.setState),ye("onNodeDragStart",E,Y.setState),ye("onNodeDragStop",A,Y.setState),ye("onSelectionDrag",O,Y.setState),ye("onSelectionDragStart",I,Y.setState),ye("onSelectionDragStop",F,Y.setState),ye("noPanClassName",L,Y.setState),ye("nodeOrigin",M,Y.setState),ye("rfId",z,Y.setState),ye("autoPanOnConnect",H,Y.setState),ye("autoPanOnNodeDrag",V,Y.setState),ye("onError",Z,Y.setState),ye("connectionRadius",G,Y.setState),ye("isValidConnection",J,Y.setState),ye("nodeDragThreshold",ee,Y.setState),Pn(e,te),Pn(t,oe),Pn(m,me),Pn(y,W),Pn(P,fe),Pn(b,Ae),null},iu={display:"none"},qE={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pp="react-flow__node-desc",Op="react-flow__edge-desc",WE="react-flow__aria-live",GE=e=>e.ariaLiveMessage;function KE({rfId:e}){const t=Ie(GE);return q.createElement("div",{id:`${WE}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:qE},t)}function YE({rfId:e,disableKeyboardA11y:t}){return q.createElement(q.Fragment,null,q.createElement("div",{id:`${Pp}-${e}`,style:iu},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),q.createElement("div",{id:`${Op}-${e}`,style:iu},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&q.createElement(KE,{rfId:e}))}var Kr=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=h.useState(!1),a=h.useRef(!1),o=h.useRef(new Set([])),[i,l]=h.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.split("+")),d=c.reduce((f,p)=>f.concat(...p),[]);return[c,d]}return[[],[]]},[e]);return h.useEffect(()=>{const u=typeof document<"u"?document:null,c=(t==null?void 0:t.target)||u;if(e!==null){const d=x=>{if(a.current=x.ctrlKey||x.metaKey||x.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&ai(x))return!1;const m=cu(x.code,l);o.current.add(x[m]),lu(i,o.current,!1)&&(x.preventDefault(),s(!0))},f=x=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&ai(x))return!1;const m=cu(x.code,l);lu(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(x[m]),x.key==="Meta"&&o.current.clear(),a.current=!1},p=()=>{o.current.clear(),s(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",f),window.addEventListener("blur",p),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",f),window.removeEventListener("blur",p)}}},[e,s]),n};function lu(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function cu(e,t){return t.includes(e)?"code":"key"}function Lp(e,t,n,s){var l,u;const a=e.parentNode||e.parentId;if(!a)return n;const o=t.get(a),i=yn(o,s);return Lp(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((l=o[De])==null?void 0:l.z)??0)>(n.z??0)?((u=o[De])==null?void 0:u.z)??0:n.z??0},s)}function Dp(e,t,n){e.forEach(s=>{var o;const a=s.parentNode||s.parentId;if(a&&!e.has(a))throw new Error(`Parent node ${a} not found`);if(a||n!=null&&n[s.id]){const{x:i,y:l,z:u}=Lp(s,e,{...s.position,z:((o=s[De])==null?void 0:o.z)??0},t);s.positionAbsolute={x:i,y:l},s[De].z=u,n!=null&&n[s.id]&&(s[De].isParent=!0)}})}function xo(e,t,n,s){const a=new Map,o={},i=s?1e3:0;return e.forEach(l=>{var x;const u=(rt(l.zIndex)?l.zIndex:0)+(l.selected?i:0),c=t.get(l.id),d={...l,positionAbsolute:{x:l.position.x,y:l.position.y}},f=l.parentNode||l.parentId;f&&(o[f]=!0);const p=(c==null?void 0:c.type)&&(c==null?void 0:c.type)!==l.type;Object.defineProperty(d,De,{enumerable:!1,value:{handleBounds:p||(x=c==null?void 0:c[De])==null?void 0:x.handleBounds,z:u}}),a.set(l.id,d)}),Dp(a,n,o),a}function $p(e,t={}){const{getNodes:n,width:s,height:a,minZoom:o,maxZoom:i,d3Zoom:l,d3Selection:u,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:f}=e(),p=t.initial&&!c&&d;if(l&&u&&(p||!t.initial)){const g=n().filter(y=>{var v;const b=t.includeHiddenNodes?y.width&&y.height:!y.hidden;return(v=t.nodes)!=null&&v.length?b&&t.nodes.some(N=>N.id===y.id):b}),m=g.every(y=>y.width&&y.height);if(g.length>0&&m){const y=$a(g,f),{x:b,y:v,zoom:N}=Sp(y,s,a,t.minZoom??o,t.maxZoom??i,t.padding??.1),w=Mt.translate(b,v).scale(N);return typeof t.duration=="number"&&t.duration>0?l.transform(hn(u,t.duration),w):l.transform(u,w),!0}}return!1}function XE(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[De]:s[De],selected:n.selected})}),new Map(t)}function ZE(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function Ss({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:a,edges:o,onNodesChange:i,onEdgesChange:l,hasDefaultNodes:u,hasDefaultEdges:c}=n();e!=null&&e.length&&(u&&s({nodeInternals:XE(e,a)}),i==null||i(e)),t!=null&&t.length&&(c&&s({edges:ZE(t,o)}),l==null||l(t))}const On=()=>{},JE={zoomIn:On,zoomOut:On,zoomTo:On,getZoom:()=>1,setViewport:On,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:On,fitBounds:On,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},QE=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),e2=()=>{const e=$e(),{d3Zoom:t,d3Selection:n}=Ie(QE,ze);return h.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(hn(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(hn(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,o)=>t.scaleTo(hn(n,o==null?void 0:o.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,o)=>{const[i,l,u]=e.getState().transform,c=Mt.translate(a.x??i,a.y??l).scale(a.zoom??u);t.transform(hn(n,o==null?void 0:o.duration),c)},getViewport:()=>{const[a,o,i]=e.getState().transform;return{x:a,y:o,zoom:i}},fitView:a=>$p(e.getState,a),setCenter:(a,o,i)=>{const{width:l,height:u,maxZoom:c}=e.getState(),d=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:c,f=l/2-a*d,p=u/2-o*d,x=Mt.translate(f,p).scale(d);t.transform(hn(n,i==null?void 0:i.duration),x)},fitBounds:(a,o)=>{const{width:i,height:l,minZoom:u,maxZoom:c}=e.getState(),{x:d,y:f,zoom:p}=Sp(a,i,l,u,c,(o==null?void 0:o.padding)??.1),x=Mt.translate(d,f).scale(p);t.transform(hn(n,o==null?void 0:o.duration),x)},project:a=>{const{transform:o,snapToGrid:i,snapGrid:l}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),li(a,o,i,l)},screenToFlowPosition:a=>{const{transform:o,snapToGrid:i,snapGrid:l,domNode:u}=e.getState();if(!u)return a;const{x:c,y:d}=u.getBoundingClientRect(),f={x:a.x-c,y:a.y-d};return li(f,o,i,l)},flowToScreenPosition:a=>{const{transform:o,domNode:i}=e.getState();if(!i)return a;const{x:l,y:u}=i.getBoundingClientRect(),c=vp(a,o);return{x:c.x+l,y:c.y+u}},viewportInitialized:!0}:JE,[t,n])};function ul(){const e=e2(),t=$e(),n=h.useCallback(()=>t.getState().getNodes().map(m=>({...m})),[]),s=h.useCallback(m=>t.getState().nodeInternals.get(m),[]),a=h.useCallback(()=>{const{edges:m=[]}=t.getState();return m.map(y=>({...y}))},[]),o=h.useCallback(m=>{const{edges:y=[]}=t.getState();return y.find(b=>b.id===m)},[]),i=h.useCallback(m=>{const{getNodes:y,setNodes:b,hasDefaultNodes:v,onNodesChange:N}=t.getState(),w=y(),j=typeof m=="function"?m(w):m;if(v)b(j);else if(N){const k=j.length===0?w.map(_=>({type:"remove",id:_.id})):j.map(_=>({item:_,type:"reset"}));N(k)}},[]),l=h.useCallback(m=>{const{edges:y=[],setEdges:b,hasDefaultEdges:v,onEdgesChange:N}=t.getState(),w=typeof m=="function"?m(y):m;if(v)b(w);else if(N){const j=w.length===0?y.map(k=>({type:"remove",id:k.id})):w.map(k=>({item:k,type:"reset"}));N(j)}},[]),u=h.useCallback(m=>{const y=Array.isArray(m)?m:[m],{getNodes:b,setNodes:v,hasDefaultNodes:N,onNodesChange:w}=t.getState();if(N){const k=[...b(),...y];v(k)}else if(w){const j=y.map(k=>({item:k,type:"add"}));w(j)}},[]),c=h.useCallback(m=>{const y=Array.isArray(m)?m:[m],{edges:b=[],setEdges:v,hasDefaultEdges:N,onEdgesChange:w}=t.getState();if(N)v([...b,...y]);else if(w){const j=y.map(k=>({item:k,type:"add"}));w(j)}},[]),d=h.useCallback(()=>{const{getNodes:m,edges:y=[],transform:b}=t.getState(),[v,N,w]=b;return{nodes:m().map(j=>({...j})),edges:y.map(j=>({...j})),viewport:{x:v,y:N,zoom:w}}},[]),f=h.useCallback(({nodes:m,edges:y})=>{const{nodeInternals:b,getNodes:v,edges:N,hasDefaultNodes:w,hasDefaultEdges:j,onNodesDelete:k,onEdgesDelete:_,onNodesChange:P,onEdgesChange:T}=t.getState(),$=(m||[]).map(C=>C.id),B=(y||[]).map(C=>C.id),D=v().reduce((C,E)=>{const A=E.parentNode||E.parentId,O=!$.includes(E.id)&&A&&C.find(F=>F.id===A);return(typeof E.deletable=="boolean"?E.deletable:!0)&&($.includes(E.id)||O)&&C.push(E),C},[]),R=N.filter(C=>typeof C.deletable=="boolean"?C.deletable:!0),S=R.filter(C=>B.includes(C.id));if(D||S){const C=Np(D,R),E=[...S,...C],A=E.reduce((O,I)=>(O.includes(I.id)||O.push(I.id),O),[]);if((j||w)&&(j&&t.setState({edges:N.filter(O=>!A.includes(O.id))}),w&&(D.forEach(O=>{b.delete(O.id)}),t.setState({nodeInternals:new Map(b)}))),A.length>0&&(_==null||_(E),T&&T(A.map(O=>({id:O,type:"remove"})))),D.length>0&&(k==null||k(D),P)){const O=D.map(I=>({id:I.id,type:"remove"}));P(O)}}},[]),p=h.useCallback(m=>{const y=wE(m),b=y?null:t.getState().nodeInternals.get(m.id);return!y&&!b?[null,null,y]:[y?m:eu(b),b,y]},[]),x=h.useCallback((m,y=!0,b)=>{const[v,N,w]=p(m);return v?(b||t.getState().getNodes()).filter(j=>{if(!w&&(j.id===N.id||!j.positionAbsolute))return!1;const k=eu(j),_=si(k,v);return y&&_>0||_>=v.width*v.height}):[]},[]),g=h.useCallback((m,y,b=!0)=>{const[v]=p(m);if(!v)return!1;const N=si(v,y);return b&&N>0||N>=v.width*v.height},[]);return h.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:a,getEdge:o,setNodes:i,setEdges:l,addNodes:u,addEdges:c,toObject:d,deleteElements:f,getIntersectingNodes:x,isNodeIntersecting:g}),[e,n,s,a,o,i,l,u,c,d,f,x,g])}const t2={actInsideInputWithModifier:!1};var n2=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=$e(),{deleteElements:s}=ul(),a=Kr(e,t2),o=Kr(t);h.useEffect(()=>{if(a){const{edges:i,getNodes:l}=n.getState(),u=l().filter(d=>d.selected),c=i.filter(d=>d.selected);s({nodes:u,edges:c}),n.setState({nodesSelectionActive:!1})}},[a]),h.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function r2(e){const t=$e();h.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const a=nl(e.current);(a.height===0||a.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",Dt.error004())),t.setState({width:a.width||500,height:a.height||500})};return s(),window.addEventListener("resize",s),e.current&&(n=new ResizeObserver(()=>s()),n.observe(e.current)),()=>{window.removeEventListener("resize",s),n&&e.current&&n.unobserve(e.current)}},[])}const dl={position:"absolute",width:"100%",height:"100%",top:0,left:0},s2=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,js=e=>({x:e.x,y:e.y,zoom:e.k}),Ln=(e,t)=>e.target.closest(`.${t}`),uu=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),du=e=>{const t=e.ctrlKey&&ia()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},a2=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),o2=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:u=xn.Free,zoomOnDoubleClick:c=!0,elementsSelectable:d,panOnDrag:f=!0,defaultViewport:p,translateExtent:x,minZoom:g,maxZoom:m,zoomActivationKeyCode:y,preventScrolling:b=!0,children:v,noWheelClassName:N,noPanClassName:w})=>{const j=h.useRef(),k=$e(),_=h.useRef(!1),P=h.useRef(!1),T=h.useRef(null),$=h.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:D,d3ZoomHandler:R,userSelectionActive:S}=Ie(a2,ze),C=Kr(y),E=h.useRef(0),A=h.useRef(!1),O=h.useRef();return r2(T),h.useEffect(()=>{if(T.current){const I=T.current.getBoundingClientRect(),F=ip().scaleExtent([g,m]).translateExtent(x),L=nt(T.current).call(F),M=Mt.translate(p.x,p.y).scale(ar(p.zoom,g,m)),z=[[0,0],[I.width,I.height]],H=F.constrain()(M,z,x);F.transform(L,H),F.wheelDelta(du),k.setState({d3Zoom:F,d3Selection:L,d3ZoomHandler:L.on("wheel.zoom"),transform:[H.x,H.y,H.k],domNode:T.current.closest(".react-flow")})}},[]),h.useEffect(()=>{D&&B&&(i&&!C&&!S?D.on("wheel.zoom",I=>{if(Ln(I,N))return!1;I.preventDefault(),I.stopImmediatePropagation();const F=D.property("__zoom").k||1;if(I.ctrlKey&&o){const J=ot(I),ee=du(I),te=F*Math.pow(2,ee);B.scaleTo(D,te,J,I);return}const L=I.deltaMode===1?20:1;let M=u===xn.Vertical?0:I.deltaX*L,z=u===xn.Horizontal?0:I.deltaY*L;!ia()&&I.shiftKey&&u!==xn.Vertical&&(M=I.deltaY*L,z=0),B.translateBy(D,-(M/F)*l,-(z/F)*l,{internal:!0});const H=js(D.property("__zoom")),{onViewportChangeStart:V,onViewportChange:Z,onViewportChangeEnd:G}=k.getState();clearTimeout(O.current),A.current||(A.current=!0,t==null||t(I,H),V==null||V(H)),A.current&&(e==null||e(I,H),Z==null||Z(H),O.current=setTimeout(()=>{n==null||n(I,H),G==null||G(H),A.current=!1},150))},{passive:!1}):typeof R<"u"&&D.on("wheel.zoom",function(I,F){if(!b&&I.type==="wheel"&&!I.ctrlKey||Ln(I,N))return null;I.preventDefault(),R.call(this,I,F)},{passive:!1}))},[S,i,u,D,B,R,C,o,b,N,t,e,n]),h.useEffect(()=>{B&&B.on("start",I=>{var M,z;if(!I.sourceEvent||I.sourceEvent.internal)return null;E.current=(M=I.sourceEvent)==null?void 0:M.button;const{onViewportChangeStart:F}=k.getState(),L=js(I.transform);_.current=!0,$.current=L,((z=I.sourceEvent)==null?void 0:z.type)==="mousedown"&&k.setState({paneDragging:!0}),F==null||F(L),t==null||t(I.sourceEvent,L)})},[B,t]),h.useEffect(()=>{B&&(S&&!_.current?B.on("zoom",null):S||B.on("zoom",I=>{var L;const{onViewportChange:F}=k.getState();if(k.setState({transform:[I.transform.x,I.transform.y,I.transform.k]}),P.current=!!(s&&uu(f,E.current??0)),(e||F)&&!((L=I.sourceEvent)!=null&&L.internal)){const M=js(I.transform);F==null||F(M),e==null||e(I.sourceEvent,M)}}))},[S,B,e,f,s]),h.useEffect(()=>{B&&B.on("end",I=>{if(!I.sourceEvent||I.sourceEvent.internal)return null;const{onViewportChangeEnd:F}=k.getState();if(_.current=!1,k.setState({paneDragging:!1}),s&&uu(f,E.current??0)&&!P.current&&s(I.sourceEvent),P.current=!1,(n||F)&&s2($.current,I.transform)){const L=js(I.transform);$.current=L,clearTimeout(j.current),j.current=setTimeout(()=>{F==null||F(L),n==null||n(I.sourceEvent,L)},i?150:0)}})},[B,i,f,n,s]),h.useEffect(()=>{B&&B.filter(I=>{const F=C||a,L=o&&I.ctrlKey;if((f===!0||Array.isArray(f)&&f.includes(1))&&I.button===1&&I.type==="mousedown"&&(Ln(I,"react-flow__node")||Ln(I,"react-flow__edge")))return!0;if(!f&&!F&&!i&&!c&&!o||S||!c&&I.type==="dblclick"||Ln(I,N)&&I.type==="wheel"||Ln(I,w)&&(I.type!=="wheel"||i&&I.type==="wheel"&&!C)||!o&&I.ctrlKey&&I.type==="wheel"||!F&&!i&&!L&&I.type==="wheel"||!f&&(I.type==="mousedown"||I.type==="touchstart")||Array.isArray(f)&&!f.includes(I.button)&&I.type==="mousedown")return!1;const M=Array.isArray(f)&&f.includes(I.button)||!I.button||I.button<=1;return(!I.ctrlKey||I.type==="wheel")&&M})},[S,B,a,o,i,c,f,d,C]),q.createElement("div",{className:"react-flow__renderer",ref:T,style:dl},v)},i2=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function l2(){const{userSelectionActive:e,userSelectionRect:t}=Ie(i2,ze);return e&&t?q.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function hu(e,t){const n=t.parentNode||t.parentId,s=e.find(a=>a.id===n);if(s){const a=t.position.x+t.width-s.width,o=t.position.y+t.height-s.height;if(a>0||o>0||t.position.x<0||t.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,a>0&&(s.style.width+=a),o>0&&(s.style.height+=o),t.position.x<0){const i=Math.abs(t.position.x);s.position.x=s.position.x-i,s.style.width+=i,t.position.x=0}if(t.position.y<0){const i=Math.abs(t.position.y);s.position.y=s.position.y-i,s.style.height+=i,t.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function zp(e,t){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const n=e.filter(s=>s.type==="add").map(s=>s.item);return t.reduce((s,a)=>{const o=e.filter(l=>l.id===a.id);if(o.length===0)return s.push(a),s;const i={...a};for(const l of o)if(l)switch(l.type){case"select":{i.selected=l.selected;break}case"position":{typeof l.position<"u"&&(i.position=l.position),typeof l.positionAbsolute<"u"&&(i.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(i.dragging=l.dragging),i.expandParent&&hu(s,i);break}case"dimensions":{typeof l.dimensions<"u"&&(i.width=l.dimensions.width,i.height=l.dimensions.height),typeof l.updateStyle<"u"&&(i.style={...i.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(i.resizing=l.resizing),i.expandParent&&hu(s,i);break}case"remove":return s}return s.push(i),s},n)}function Fp(e,t){return zp(e,t)}function c2(e,t){return zp(e,t)}const qt=(e,t)=>({id:e,type:"select",selected:t});function Vn(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(qt(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(qt(s.id,!1))),n},[])}const go=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},u2=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),Bp=h.memo(({isSelecting:e,selectionMode:t=Gr.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:a,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:u,onPaneMouseMove:c,onPaneMouseLeave:d,children:f})=>{const p=h.useRef(null),x=$e(),g=h.useRef(0),m=h.useRef(0),y=h.useRef(),{userSelectionActive:b,elementsSelectable:v,dragging:N}=Ie(u2,ze),w=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,m.current=0},j=R=>{o==null||o(R),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},k=R=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){R.preventDefault();return}i==null||i(R)},_=l?R=>l(R):void 0,P=R=>{const{resetSelectedElements:S,domNode:C}=x.getState();if(y.current=C==null?void 0:C.getBoundingClientRect(),!v||!e||R.button!==0||R.target!==p.current||!y.current)return;const{x:E,y:A}=Xt(R,y.current);S(),x.setState({userSelectionRect:{width:0,height:0,startX:E,startY:A,x:E,y:A}}),s==null||s(R)},T=R=>{const{userSelectionRect:S,nodeInternals:C,edges:E,transform:A,onNodesChange:O,onEdgesChange:I,nodeOrigin:F,getNodes:L}=x.getState();if(!e||!y.current||!S)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const M=Xt(R,y.current),z=S.startX??0,H=S.startY??0,V={...S,x:M.x<z?M.x:z,y:M.y<H?M.y:H,width:Math.abs(M.x-z),height:Math.abs(M.y-H)},Z=L(),G=wp(C,V,A,t===Gr.Partial,!0,F),J=Np(G,E).map(te=>te.id),ee=G.map(te=>te.id);if(g.current!==ee.length){g.current=ee.length;const te=Vn(Z,ee);te.length&&(O==null||O(te))}if(m.current!==J.length){m.current=J.length;const te=Vn(E,J);te.length&&(I==null||I(te))}x.setState({userSelectionRect:V})},$=R=>{if(R.button!==0)return;const{userSelectionRect:S}=x.getState();!b&&S&&R.target===p.current&&(j==null||j(R)),x.setState({nodesSelectionActive:g.current>0}),w(),a==null||a(R)},B=R=>{b&&(x.setState({nodesSelectionActive:g.current>0}),a==null||a(R)),w()},D=v&&(e||b);return q.createElement("div",{className:Be(["react-flow__pane",{dragging:N,selection:e}]),onClick:D?void 0:go(j,p),onContextMenu:go(k,p),onWheel:go(_,p),onMouseEnter:D?void 0:u,onMouseDown:D?P:void 0,onMouseMove:D?T:c,onMouseUp:D?$:void 0,onMouseLeave:D?B:d,ref:p,style:dl},f,q.createElement(l2,null))});Bp.displayName="Pane";function Hp(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:Hp(s,t):!1}function fu(e,t,n){let s=e;do{if(s!=null&&s.matches(t))return!0;if(s===n.current)return!1;s=s.parentElement}while(s);return!1}function d2(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!Hp(a,e))&&(a.draggable||t&&typeof a.draggable>"u")).map(a=>{var o,i;return{id:a.id,position:a.position||{x:0,y:0},positionAbsolute:a.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=a.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=a.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:a.extent,parentNode:a.parentNode||a.parentId,parentId:a.parentNode||a.parentId,width:a.width,height:a.height,expandParent:a.expandParent}})}function h2(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function Up(e,t,n,s,a=[0,0],o){const i=h2(e,e.extent||s);let l=i;const u=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(u&&e.width&&e.height){const f=n.get(u),{x:p,y:x}=yn(f,a).positionAbsolute;l=f&&rt(p)&&rt(x)&&rt(f.width)&&rt(f.height)?[[p+e.width*a[0],x+e.height*a[1]],[p+f.width-e.width+e.width*a[0],x+f.height-e.height+e.height*a[1]]]:l}else o==null||o("005",Dt.error005()),l=i;else if(e.extent&&u&&e.extent!=="parent"){const f=n.get(u),{x:p,y:x}=yn(f,a).positionAbsolute;l=[[e.extent[0][0]+p,e.extent[0][1]+x],[e.extent[1][0]+p,e.extent[1][1]+x]]}let c={x:0,y:0};if(u){const f=n.get(u);c=yn(f,a).positionAbsolute}const d=l&&l!=="parent"?rl(t,l):t;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function yo({nodeId:e,dragItems:t,nodeInternals:n}){const s=t.map(a=>({...n.get(a.id),position:a.position,positionAbsolute:a.positionAbsolute}));return[e?s.find(a=>a.id===e):s[0],s]}const pu=(e,t,n,s)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const o=Array.from(a),i=t.getBoundingClientRect(),l={x:i.width*s[0],y:i.height*s[1]};return o.map(u=>{const c=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),position:u.getAttribute("data-handlepos"),x:(c.left-i.left-l.x)/n,y:(c.top-i.top-l.y)/n,...nl(u)}})};function Nr(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function ui({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:l,onError:u}=t.getState(),c=l.get(e);if(!c){u==null||u("012",Dt.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(o({nodes:[c],edges:[]}),requestAnimationFrame(()=>{var d;return(d=s==null?void 0:s.current)==null?void 0:d.blur()})):a([e])}function f2(){const e=$e();return h.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:a,snapToGrid:o}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,u={x:(i-s[0])/s[2],y:(l-s[1])/s[2]};return{xSnapped:o?a[0]*Math.round(u.x/a[0]):u.x,ySnapped:o?a[1]*Math.round(u.y/a[1]):u.y,...u}},[])}function bo(e){return(t,n,s)=>e==null?void 0:e(t,s)}function Vp({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:o,selectNodesOnDrag:i}){const l=$e(),[u,c]=h.useState(!1),d=h.useRef([]),f=h.useRef({x:null,y:null}),p=h.useRef(0),x=h.useRef(null),g=h.useRef({x:0,y:0}),m=h.useRef(null),y=h.useRef(!1),b=h.useRef(!1),v=h.useRef(!1),N=f2();return h.useEffect(()=>{if(e!=null&&e.current){const w=nt(e.current),j=({x:P,y:T})=>{const{nodeInternals:$,onNodeDrag:B,onSelectionDrag:D,updateNodePositions:R,nodeExtent:S,snapGrid:C,snapToGrid:E,nodeOrigin:A,onError:O}=l.getState();f.current={x:P,y:T};let I=!1,F={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&S){const M=$a(d.current,A);F=Wr(M)}if(d.current=d.current.map(M=>{const z={x:P-M.distance.x,y:T-M.distance.y};E&&(z.x=C[0]*Math.round(z.x/C[0]),z.y=C[1]*Math.round(z.y/C[1]));const H=[[S[0][0],S[0][1]],[S[1][0],S[1][1]]];d.current.length>1&&S&&!M.extent&&(H[0][0]=M.positionAbsolute.x-F.x+S[0][0],H[1][0]=M.positionAbsolute.x+(M.width??0)-F.x2+S[1][0],H[0][1]=M.positionAbsolute.y-F.y+S[0][1],H[1][1]=M.positionAbsolute.y+(M.height??0)-F.y2+S[1][1]);const V=Up(M,z,$,H,A,O);return I=I||M.position.x!==V.position.x||M.position.y!==V.position.y,M.position=V.position,M.positionAbsolute=V.positionAbsolute,M}),!I)return;R(d.current,!0,!0),c(!0);const L=a?B:bo(D);if(L&&m.current){const[M,z]=yo({nodeId:a,dragItems:d.current,nodeInternals:$});L(m.current,M,z)}},k=()=>{if(!x.current)return;const[P,T]=cp(g.current,x.current);if(P!==0||T!==0){const{transform:$,panBy:B}=l.getState();f.current.x=(f.current.x??0)-P/$[2],f.current.y=(f.current.y??0)-T/$[2],B({x:P,y:T})&&j(f.current)}p.current=requestAnimationFrame(k)},_=P=>{var A;const{nodeInternals:T,multiSelectionActive:$,nodesDraggable:B,unselectNodesAndEdges:D,onNodeDragStart:R,onSelectionDragStart:S}=l.getState();b.current=!0;const C=a?R:bo(S);(!i||!o)&&!$&&a&&((A=T.get(a))!=null&&A.selected||D()),a&&o&&i&&ui({id:a,store:l,nodeRef:e});const E=N(P);if(f.current=E,d.current=d2(T,B,E,a),C&&d.current){const[O,I]=yo({nodeId:a,dragItems:d.current,nodeInternals:T});C(P.sourceEvent,O,I)}};if(t)w.on(".drag",null);else{const P=kj().on("start",T=>{const{domNode:$,nodeDragThreshold:B}=l.getState();B===0&&_(T),v.current=!1;const D=N(T);f.current=D,x.current=($==null?void 0:$.getBoundingClientRect())||null,g.current=Xt(T.sourceEvent,x.current)}).on("drag",T=>{var R,S;const $=N(T),{autoPanOnNodeDrag:B,nodeDragThreshold:D}=l.getState();if(T.sourceEvent.type==="touchmove"&&T.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!y.current&&b.current&&B&&(y.current=!0,k()),!b.current){const C=$.xSnapped-(((R=f==null?void 0:f.current)==null?void 0:R.x)??0),E=$.ySnapped-(((S=f==null?void 0:f.current)==null?void 0:S.y)??0);Math.sqrt(C*C+E*E)>D&&_(T)}(f.current.x!==$.xSnapped||f.current.y!==$.ySnapped)&&d.current&&b.current&&(m.current=T.sourceEvent,g.current=Xt(T.sourceEvent,x.current),j($))}}).on("end",T=>{if(!(!b.current||v.current)&&(c(!1),y.current=!1,b.current=!1,cancelAnimationFrame(p.current),d.current)){const{updateNodePositions:$,nodeInternals:B,onNodeDragStop:D,onSelectionDragStop:R}=l.getState(),S=a?D:bo(R);if($(d.current,!1,!1),S){const[C,E]=yo({nodeId:a,dragItems:d.current,nodeInternals:B});S(T.sourceEvent,C,E)}}}).filter(T=>{const $=T.target;return!T.button&&(!n||!fu($,`.${n}`,e))&&(!s||fu($,s,e))});return w.call(P),()=>{w.on(".drag",null)}}}},[e,t,n,s,o,l,a,i,N]),u}function qp(){const e=$e();return h.useCallback(n=>{const{nodeInternals:s,nodeExtent:a,updateNodePositions:o,getNodes:i,snapToGrid:l,snapGrid:u,onError:c,nodesDraggable:d}=e.getState(),f=i().filter(v=>v.selected&&(v.draggable||d&&typeof v.draggable>"u")),p=l?u[0]:5,x=l?u[1]:5,g=n.isShiftPressed?4:1,m=n.x*p*g,y=n.y*x*g,b=f.map(v=>{if(v.positionAbsolute){const N={x:v.positionAbsolute.x+m,y:v.positionAbsolute.y+y};l&&(N.x=u[0]*Math.round(N.x/u[0]),N.y=u[1]*Math.round(N.y/u[1]));const{positionAbsolute:w,position:j}=Up(v,N,s,a,void 0,c);v.position=j,v.positionAbsolute=w}return v});o(b,!0,!1)},[])}const Zn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Sr=e=>{const t=({id:n,type:s,data:a,xPos:o,yPos:i,xPosOrigin:l,yPosOrigin:u,selected:c,onClick:d,onMouseEnter:f,onMouseMove:p,onMouseLeave:x,onContextMenu:g,onDoubleClick:m,style:y,className:b,isDraggable:v,isSelectable:N,isConnectable:w,isFocusable:j,selectNodesOnDrag:k,sourcePosition:_,targetPosition:P,hidden:T,resizeObserver:$,dragHandle:B,zIndex:D,isParent:R,noDragClassName:S,noPanClassName:C,initialized:E,disableKeyboardA11y:A,ariaLabel:O,rfId:I,hasHandleBounds:F})=>{const L=$e(),M=h.useRef(null),z=h.useRef(null),H=h.useRef(_),V=h.useRef(P),Z=h.useRef(s),G=N||v||d||f||p||x,J=qp(),ee=Nr(n,L.getState,f),te=Nr(n,L.getState,p),oe=Nr(n,L.getState,x),ie=Nr(n,L.getState,g),me=Nr(n,L.getState,m),W=ge=>{const{nodeDragThreshold:Y}=L.getState();if(N&&(!k||!v||Y>0)&&ui({id:n,store:L,nodeRef:M}),d){const Pe=L.getState().nodeInternals.get(n);Pe&&d(ge,{...Pe})}},fe=ge=>{if(!ai(ge)&&!A)if(fp.includes(ge.key)&&N){const Y=ge.key==="Escape";ui({id:n,store:L,unselect:Y,nodeRef:M})}else v&&c&&Object.prototype.hasOwnProperty.call(Zn,ge.key)&&(L.setState({ariaLiveMessage:`Moved selected node ${ge.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),J({x:Zn[ge.key].x,y:Zn[ge.key].y,isShiftPressed:ge.shiftKey}))};h.useEffect(()=>()=>{z.current&&($==null||$.unobserve(z.current),z.current=null)},[]),h.useEffect(()=>{if(M.current&&!T){const ge=M.current;(!E||!F||z.current!==ge)&&(z.current&&($==null||$.unobserve(z.current)),$==null||$.observe(ge),z.current=ge)}},[T,E,F]),h.useEffect(()=>{const ge=Z.current!==s,Y=H.current!==_,Pe=V.current!==P;M.current&&(ge||Y||Pe)&&(ge&&(Z.current=s),Y&&(H.current=_),Pe&&(V.current=P),L.getState().updateNodeDimensions([{id:n,nodeElement:M.current,forceUpdate:!0}]))},[n,s,_,P]);const Ae=Vp({nodeRef:M,disabled:T||!v,noDragClassName:S,handleSelector:B,nodeId:n,isSelectable:N,selectNodesOnDrag:k});return T?null:q.createElement("div",{className:Be(["react-flow__node",`react-flow__node-${s}`,{[C]:v},b,{selected:c,selectable:N,parent:R,dragging:Ae}]),ref:M,style:{zIndex:D,transform:`translate(${l}px,${u}px)`,pointerEvents:G?"all":"none",visibility:E?"visible":"hidden",...y},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ee,onMouseMove:te,onMouseLeave:oe,onContextMenu:ie,onClick:W,onDoubleClick:me,onKeyDown:j?fe:void 0,tabIndex:j?0:void 0,role:j?"button":void 0,"aria-describedby":A?void 0:`${Pp}-${I}`,"aria-label":O},q.createElement(CE,{value:n},q.createElement(e,{id:n,data:a,type:s,xPos:o,yPos:i,selected:c,isConnectable:w,sourcePosition:_,targetPosition:P,dragging:Ae,dragHandle:B,zIndex:D})))};return t.displayName="NodeWrapper",h.memo(t)};const p2=e=>{const t=e.getNodes().filter(n=>n.selected);return{...$a(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function m2({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=$e(),{width:a,height:o,x:i,y:l,transformString:u,userSelectionActive:c}=Ie(p2,ze),d=qp(),f=h.useRef(null);if(h.useEffect(()=>{var g;n||(g=f.current)==null||g.focus({preventScroll:!0})},[n]),Vp({nodeRef:f}),c||!a||!o)return null;const p=e?g=>{const m=s.getState().getNodes().filter(y=>y.selected);e(g,m)}:void 0,x=g=>{Object.prototype.hasOwnProperty.call(Zn,g.key)&&d({x:Zn[g.key].x,y:Zn[g.key].y,isShiftPressed:g.shiftKey})};return q.createElement("div",{className:Be(["react-flow__nodesselection","react-flow__container",t]),style:{transform:u}},q.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:x,style:{width:a,height:o,top:l,left:i}}))}var x2=h.memo(m2);const g2=e=>e.nodesSelectionActive,Wp=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:l,onMove:u,onMoveStart:c,onMoveEnd:d,selectionKeyCode:f,selectionOnDrag:p,selectionMode:x,onSelectionStart:g,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:N,zoomOnScroll:w,zoomOnPinch:j,panOnScroll:k,panOnScrollSpeed:_,panOnScrollMode:P,zoomOnDoubleClick:T,panOnDrag:$,defaultViewport:B,translateExtent:D,minZoom:R,maxZoom:S,preventScrolling:C,onSelectionContextMenu:E,noWheelClassName:A,noPanClassName:O,disableKeyboardA11y:I})=>{const F=Ie(g2),L=Kr(f),M=Kr(b),z=M||$,H=M||k,V=L||p&&z!==!0;return n2({deleteKeyCode:l,multiSelectionKeyCode:y}),q.createElement(o2,{onMove:u,onMoveStart:c,onMoveEnd:d,onPaneContextMenu:o,elementsSelectable:N,zoomOnScroll:w,zoomOnPinch:j,panOnScroll:H,panOnScrollSpeed:_,panOnScrollMode:P,zoomOnDoubleClick:T,panOnDrag:!L&&z,defaultViewport:B,translateExtent:D,minZoom:R,maxZoom:S,zoomActivationKeyCode:v,preventScrolling:C,noWheelClassName:A,noPanClassName:O},q.createElement(Bp,{onSelectionStart:g,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:z,isSelecting:!!V,selectionMode:x},e,F&&q.createElement(x2,{onSelectionContextMenu:E,noPanClassName:O,disableKeyboardA11y:I})))};Wp.displayName="FlowRenderer";var y2=h.memo(Wp);function b2(e){return Ie(h.useCallback(n=>e?wp(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function v2(e){const t={input:Sr(e.input||Rp),default:Sr(e.default||ci),output:Sr(e.output||Mp),group:Sr(e.group||cl)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,o)=>(a[o]=Sr(e[o]||ci),a),n);return{...t,...s}}const w2=({x:e,y:t,width:n,height:s,origin:a})=>!n||!s?{x:e,y:t}:a[0]<0||a[1]<0||a[0]>1||a[1]>1?{x:e,y:t}:{x:e-n*a[0],y:t-s*a[1]},N2=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Gp=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:o,onError:i}=Ie(N2,ze),l=b2(e.onlyRenderVisibleElements),u=h.useRef(),c=h.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const d=new ResizeObserver(f=>{const p=f.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));o(p)});return u.current=d,d},[]);return h.useEffect(()=>()=>{var d;(d=u==null?void 0:u.current)==null||d.disconnect()},[]),q.createElement("div",{className:"react-flow__nodes",style:dl},l.map(d=>{var j,k,_;let f=d.type||"default";e.nodeTypes[f]||(i==null||i("003",Dt.error003(f)),f="default");const p=e.nodeTypes[f]||e.nodeTypes.default,x=!!(d.draggable||t&&typeof d.draggable>"u"),g=!!(d.selectable||a&&typeof d.selectable>"u"),m=!!(d.connectable||n&&typeof d.connectable>"u"),y=!!(d.focusable||s&&typeof d.focusable>"u"),b=e.nodeExtent?rl(d.positionAbsolute,e.nodeExtent):d.positionAbsolute,v=(b==null?void 0:b.x)??0,N=(b==null?void 0:b.y)??0,w=w2({x:v,y:N,width:d.width??0,height:d.height??0,origin:e.nodeOrigin});return q.createElement(p,{key:d.id,id:d.id,className:d.className,style:d.style,type:f,data:d.data,sourcePosition:d.sourcePosition||he.Bottom,targetPosition:d.targetPosition||he.Top,hidden:d.hidden,xPos:v,yPos:N,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!d.selected,isDraggable:x,isSelectable:g,isConnectable:m,isFocusable:y,resizeObserver:c,dragHandle:d.dragHandle,zIndex:((j=d[De])==null?void 0:j.z)??0,isParent:!!((k=d[De])!=null&&k.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!d.width&&!!d.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:d.ariaLabel,hasHandleBounds:!!((_=d[De])!=null&&_.handleBounds)})}))};Gp.displayName="NodeRenderer";var S2=h.memo(Gp);const j2=(e,t,n)=>n===he.Left?e-t:n===he.Right?e+t:e,k2=(e,t,n)=>n===he.Top?e-t:n===he.Bottom?e+t:e,mu="react-flow__edgeupdater",xu=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:a,onMouseEnter:o,onMouseOut:i,type:l})=>q.createElement("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:i,className:Be([mu,`${mu}-${l}`]),cx:j2(t,s,e),cy:k2(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),E2=()=>!0;var Dn=e=>{const t=({id:n,className:s,type:a,data:o,onClick:i,onEdgeDoubleClick:l,selected:u,animated:c,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:m,style:y,source:b,target:v,sourceX:N,sourceY:w,targetX:j,targetY:k,sourcePosition:_,targetPosition:P,elementsSelectable:T,hidden:$,sourceHandleId:B,targetHandleId:D,onContextMenu:R,onMouseEnter:S,onMouseMove:C,onMouseLeave:E,reconnectRadius:A,onReconnect:O,onReconnectStart:I,onReconnectEnd:F,markerEnd:L,markerStart:M,rfId:z,ariaLabel:H,isFocusable:V,isReconnectable:Z,pathOptions:G,interactionWidth:J,disableKeyboardA11y:ee})=>{const te=h.useRef(null),[oe,ie]=h.useState(!1),[me,W]=h.useState(!1),fe=$e(),Ae=h.useMemo(()=>`url('#${ii(M,z)}')`,[M,z]),ge=h.useMemo(()=>`url('#${ii(L,z)}')`,[L,z]);if($)return null;const Y=_e=>{var xt;const{edges:Ze,addSelectedEdges:kt,unselectNodesAndEdges:ln,multiSelectionActive:cn}=fe.getState(),Et=Ze.find(pr=>pr.id===n);Et&&(T&&(fe.setState({nodesSelectionActive:!1}),Et.selected&&cn?(ln({nodes:[],edges:[Et]}),(xt=te.current)==null||xt.blur()):kt([n])),i&&i(_e,Et))},Pe=wr(n,fe.getState,l),Te=wr(n,fe.getState,R),be=wr(n,fe.getState,S),Xe=wr(n,fe.getState,C),He=wr(n,fe.getState,E),Ve=(_e,Ze)=>{if(_e.button!==0)return;const{edges:kt,isValidConnection:ln}=fe.getState(),cn=Ze?v:b,Et=(Ze?D:B)||null,xt=Ze?"target":"source",pr=ln||E2,qa=Ze,mr=kt.find(un=>un.id===n);W(!0),I==null||I(_e,mr,xt);const Wa=un=>{W(!1),F==null||F(un,mr,xt)};Ep({event:_e,handleId:Et,nodeId:cn,onConnect:un=>O==null?void 0:O(mr,un),isTarget:qa,getState:fe.getState,setState:fe.setState,isValidConnection:pr,edgeUpdaterType:xt,onReconnectEnd:Wa})},tt=_e=>Ve(_e,!0),U=_e=>Ve(_e,!1),K=()=>ie(!0),ne=()=>ie(!1),pe=!T&&!i,Ee=_e=>{var Ze;if(!ee&&fp.includes(_e.key)&&T){const{unselectNodesAndEdges:kt,addSelectedEdges:ln,edges:cn}=fe.getState();_e.key==="Escape"?((Ze=te.current)==null||Ze.blur(),kt({edges:[cn.find(xt=>xt.id===n)]})):ln([n])}};return q.createElement("g",{className:Be(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:u,animated:c,inactive:pe,updating:oe}]),onClick:Y,onDoubleClick:Pe,onContextMenu:Te,onMouseEnter:be,onMouseMove:Xe,onMouseLeave:He,onKeyDown:V?Ee:void 0,tabIndex:V?0:void 0,role:V?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":H===null?void 0:H||`Edge from ${b} to ${v}`,"aria-describedby":V?`${Op}-${z}`:void 0,ref:te},!me&&q.createElement(e,{id:n,source:b,target:v,selected:u,animated:c,label:d,labelStyle:f,labelShowBg:p,labelBgStyle:x,labelBgPadding:g,labelBgBorderRadius:m,data:o,style:y,sourceX:N,sourceY:w,targetX:j,targetY:k,sourcePosition:_,targetPosition:P,sourceHandleId:B,targetHandleId:D,markerStart:Ae,markerEnd:ge,pathOptions:G,interactionWidth:J}),Z&&q.createElement(q.Fragment,null,(Z==="source"||Z===!0)&&q.createElement(xu,{position:_,centerX:N,centerY:w,radius:A,onMouseDown:tt,onMouseEnter:K,onMouseOut:ne,type:"source"}),(Z==="target"||Z===!0)&&q.createElement(xu,{position:P,centerX:j,centerY:k,radius:A,onMouseDown:U,onMouseEnter:K,onMouseOut:ne,type:"target"})))};return t.displayName="EdgeWrapper",h.memo(t)};function _2(e){const t={default:Dn(e.default||ca),straight:Dn(e.bezier||ol),step:Dn(e.step||al),smoothstep:Dn(e.step||Da),simplebezier:Dn(e.simplebezier||sl)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,o)=>(a[o]=Dn(e[o]||ca),a),n);return{...t,...s}}function gu(e,t,n=null){const s=((n==null?void 0:n.x)||0)+t.x,a=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,i=(n==null?void 0:n.height)||t.height;switch(e){case he.Top:return{x:s+o/2,y:a};case he.Right:return{x:s+o,y:a+i/2};case he.Bottom:return{x:s+o/2,y:a+i};case he.Left:return{x:s,y:a+i/2}}}function yu(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const C2=(e,t,n,s,a,o)=>{const i=gu(n,e,t),l=gu(o,s,a);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function T2({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:a,targetHeight:o,width:i,height:l,transform:u}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+a),y2:Math.max(e.y+s,t.y+o)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d=Wr({x:(0-u[0])/u[2],y:(0-u[1])/u[2],width:i/u[2],height:l/u[2]}),f=Math.max(0,Math.min(d.x2,c.x2)-Math.max(d.x,c.x)),p=Math.max(0,Math.min(d.y2,c.y2)-Math.max(d.y,c.y));return Math.ceil(f*p)>0}function bu(e){var s,a,o,i,l;const t=((s=e==null?void 0:e[De])==null?void 0:s.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)||0,y:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const R2=[{level:0,isMaxLevel:!0,edges:[]}];function A2(e,t,n=!1){let s=-1;const a=e.reduce((i,l)=>{var d,f;const u=rt(l.zIndex);let c=u?l.zIndex:0;if(n){const p=t.get(l.target),x=t.get(l.source),g=l.selected||(p==null?void 0:p.selected)||(x==null?void 0:x.selected),m=Math.max(((d=x==null?void 0:x[De])==null?void 0:d.z)||0,((f=p==null?void 0:p[De])==null?void 0:f.z)||0,1e3);c=(u?l.zIndex:0)+(g?m:0)}return i[c]?i[c].push(l):i[c]=[l],s=c>s?c:s,i},{}),o=Object.entries(a).map(([i,l])=>{const u=+i;return{edges:l,level:u,isMaxLevel:u===s}});return o.length===0?R2:o}function M2(e,t,n){const s=Ie(h.useCallback(a=>e?a.edges.filter(o=>{const i=t.get(o.source),l=t.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&T2({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:l.width,targetHeight:l.height,width:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return A2(s,t,n)}const I2=({color:e="none",strokeWidth:t=1})=>q.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),P2=({color:e="none",strokeWidth:t=1})=>q.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),vu={[la.Arrow]:I2,[la.ArrowClosed]:P2};function O2(e){const t=$e();return h.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(vu,e)?vu[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",Dt.error009(e)),null)},[e])}const L2=({id:e,type:t,color:n,width:s=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const u=O2(t);return u?q.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0"},q.createElement(u,{color:n,strokeWidth:i})):null},D2=({defaultColor:e,rfId:t})=>n=>{const s=[];return n.edges.reduce((a,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const l=ii(i,t);s.includes(l)||(a.push({id:l,color:i.color||e,...i}),s.push(l))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))},Kp=({defaultColor:e,rfId:t})=>{const n=Ie(h.useCallback(D2({defaultColor:e,rfId:t}),[e,t]),(s,a)=>!(s.length!==a.length||s.some((o,i)=>o.id!==a[i].id)));return q.createElement("defs",null,n.map(s=>q.createElement(L2,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};Kp.displayName="MarkerDefinitions";var $2=h.memo(Kp);const z2=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Yp=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:a,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:u,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:f,onReconnect:p,onReconnectStart:x,onReconnectEnd:g,reconnectRadius:m,children:y,disableKeyboardA11y:b})=>{const{edgesFocusable:v,edgesUpdatable:N,elementsSelectable:w,width:j,height:k,connectionMode:_,nodeInternals:P,onError:T}=Ie(z2,ze),$=M2(t,P,n);return j?q.createElement(q.Fragment,null,$.map(({level:B,edges:D,isMaxLevel:R})=>q.createElement("svg",{key:B,style:{zIndex:B},width:j,height:k,className:"react-flow__edges react-flow__container"},R&&q.createElement($2,{defaultColor:e,rfId:s}),q.createElement("g",null,D.map(S=>{const[C,E,A]=bu(P.get(S.source)),[O,I,F]=bu(P.get(S.target));if(!A||!F)return null;let L=S.type||"default";a[L]||(T==null||T("011",Dt.error011(L)),L="default");const M=a[L]||a.default,z=_===kn.Strict?I.target:(I.target??[]).concat(I.source??[]),H=yu(E.source,S.sourceHandle),V=yu(z,S.targetHandle),Z=(H==null?void 0:H.position)||he.Bottom,G=(V==null?void 0:V.position)||he.Top,J=!!(S.focusable||v&&typeof S.focusable>"u"),ee=S.reconnectable||S.updatable,te=typeof p<"u"&&(ee||N&&typeof ee>"u");if(!H||!V)return T==null||T("008",Dt.error008(H,S)),null;const{sourceX:oe,sourceY:ie,targetX:me,targetY:W}=C2(C,H,Z,O,V,G);return q.createElement(M,{key:S.id,id:S.id,className:Be([S.className,o]),type:L,data:S.data,selected:!!S.selected,animated:!!S.animated,hidden:!!S.hidden,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,style:S.style,source:S.source,target:S.target,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerEnd:S.markerEnd,markerStart:S.markerStart,sourceX:oe,sourceY:ie,targetX:me,targetY:W,sourcePosition:Z,targetPosition:G,elementsSelectable:w,onContextMenu:i,onMouseEnter:l,onMouseMove:u,onMouseLeave:c,onClick:d,onEdgeDoubleClick:f,onReconnect:p,onReconnectStart:x,onReconnectEnd:g,reconnectRadius:m,rfId:s,ariaLabel:S.ariaLabel,isFocusable:J,isReconnectable:te,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth,disableKeyboardA11y:b})})))),y):null};Yp.displayName="EdgeRenderer";var F2=h.memo(Yp);const B2=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function H2({children:e}){const t=Ie(B2);return q.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function U2(e){const t=ul(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const V2={[he.Left]:he.Right,[he.Right]:he.Left,[he.Top]:he.Bottom,[he.Bottom]:he.Top},Xp=({nodeId:e,handleType:t,style:n,type:s=Wt.Bezier,CustomComponent:a,connectionStatus:o})=>{var k,_,P;const{fromNode:i,handleId:l,toX:u,toY:c,connectionMode:d}=Ie(h.useCallback(T=>({fromNode:T.nodeInternals.get(e),handleId:T.connectionHandleId,toX:(T.connectionPosition.x-T.transform[0])/T.transform[2],toY:(T.connectionPosition.y-T.transform[1])/T.transform[2],connectionMode:T.connectionMode}),[e]),ze),f=(k=i==null?void 0:i[De])==null?void 0:k.handleBounds;let p=f==null?void 0:f[t];if(d===kn.Loose&&(p=p||(f==null?void 0:f[t==="source"?"target":"source"])),!i||!p)return null;const x=l?p.find(T=>T.id===l):p[0],g=x?x.x+x.width/2:(i.width??0)/2,m=x?x.y+x.height/2:i.height??0,y=(((_=i.positionAbsolute)==null?void 0:_.x)??0)+g,b=(((P=i.positionAbsolute)==null?void 0:P.y)??0)+m,v=x==null?void 0:x.position,N=v?V2[v]:null;if(!v||!N)return null;if(a)return q.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:x,fromX:y,fromY:b,toX:u,toY:c,fromPosition:v,toPosition:N,connectionStatus:o});let w="";const j={sourceX:y,sourceY:b,sourcePosition:v,targetX:u,targetY:c,targetPosition:N};return s===Wt.Bezier?[w]=yp(j):s===Wt.Step?[w]=oi({...j,borderRadius:0}):s===Wt.SmoothStep?[w]=oi(j):s===Wt.SimpleBezier?[w]=gp(j):w=`M${y},${b} ${u},${c}`,q.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};Xp.displayName="ConnectionLine";const q2=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function W2({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:o,nodesConnectable:i,width:l,height:u,connectionStatus:c}=Ie(q2,ze);return!(a&&o&&l&&i)?null:q.createElement("svg",{style:e,width:l,height:u,className:"react-flow__edges react-flow__connectionline react-flow__container"},q.createElement("g",{className:Be(["react-flow__connection",c])},q.createElement(Xp,{nodeId:a,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:c})))}function wu(e,t){return h.useRef(null),$e(),h.useMemo(()=>t(e),[e])}const Zp=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:a,onInit:o,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:x,onSelectionContextMenu:g,onSelectionStart:m,onSelectionEnd:y,connectionLineType:b,connectionLineStyle:v,connectionLineComponent:N,connectionLineContainerStyle:w,selectionKeyCode:j,selectionOnDrag:k,selectionMode:_,multiSelectionKeyCode:P,panActivationKeyCode:T,zoomActivationKeyCode:$,deleteKeyCode:B,onlyRenderVisibleElements:D,elementsSelectable:R,selectNodesOnDrag:S,defaultViewport:C,translateExtent:E,minZoom:A,maxZoom:O,preventScrolling:I,defaultMarkerColor:F,zoomOnScroll:L,zoomOnPinch:M,panOnScroll:z,panOnScrollSpeed:H,panOnScrollMode:V,zoomOnDoubleClick:Z,panOnDrag:G,onPaneClick:J,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:oe,onPaneScroll:ie,onPaneContextMenu:me,onEdgeContextMenu:W,onEdgeMouseEnter:fe,onEdgeMouseMove:Ae,onEdgeMouseLeave:ge,onReconnect:Y,onReconnectStart:Pe,onReconnectEnd:Te,reconnectRadius:be,noDragClassName:Xe,noWheelClassName:He,noPanClassName:Ve,elevateEdgesOnSelect:tt,disableKeyboardA11y:U,nodeOrigin:K,nodeExtent:ne,rfId:pe})=>{const Ee=wu(e,v2),_e=wu(t,_2);return U2(o),q.createElement(y2,{onPaneClick:J,onPaneMouseEnter:ee,onPaneMouseMove:te,onPaneMouseLeave:oe,onPaneContextMenu:me,onPaneScroll:ie,deleteKeyCode:B,selectionKeyCode:j,selectionOnDrag:k,selectionMode:_,onSelectionStart:m,onSelectionEnd:y,multiSelectionKeyCode:P,panActivationKeyCode:T,zoomActivationKeyCode:$,elementsSelectable:R,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:L,zoomOnPinch:M,zoomOnDoubleClick:Z,panOnScroll:z,panOnScrollSpeed:H,panOnScrollMode:V,panOnDrag:G,defaultViewport:C,translateExtent:E,minZoom:A,maxZoom:O,onSelectionContextMenu:g,preventScrolling:I,noDragClassName:Xe,noWheelClassName:He,noPanClassName:Ve,disableKeyboardA11y:U},q.createElement(H2,null,q.createElement(F2,{edgeTypes:_e,onEdgeClick:l,onEdgeDoubleClick:c,onlyRenderVisibleElements:D,onEdgeContextMenu:W,onEdgeMouseEnter:fe,onEdgeMouseMove:Ae,onEdgeMouseLeave:ge,onReconnect:Y,onReconnectStart:Pe,onReconnectEnd:Te,reconnectRadius:be,defaultMarkerColor:F,noPanClassName:Ve,elevateEdgesOnSelect:!!tt,disableKeyboardA11y:U,rfId:pe},q.createElement(W2,{style:v,type:b,component:N,containerStyle:w})),q.createElement("div",{className:"react-flow__edgelabel-renderer"}),q.createElement(S2,{nodeTypes:Ee,onNodeClick:i,onNodeDoubleClick:u,onNodeMouseEnter:d,onNodeMouseMove:f,onNodeMouseLeave:p,onNodeContextMenu:x,selectNodesOnDrag:S,onlyRenderVisibleElements:D,noPanClassName:Ve,noDragClassName:Xe,disableKeyboardA11y:U,nodeOrigin:K,nodeExtent:ne,rfId:pe})))};Zp.displayName="GraphView";var G2=h.memo(Zp);const di=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Bt={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:di,nodeExtent:di,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:kn.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:NE,isValidConnection:void 0},K2=()=>DN((e,t)=>({...Bt,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:o}=t();e({nodeInternals:xo(n,s,a,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:s={}}=t();e({edges:n.map(a=>({...s,...a}))})},setDefaultNodesAndEdges:(n,s)=>{const a=typeof n<"u",o=typeof s<"u",i=a?xo(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:o?s:[],hasDefaultNodes:a,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:s,nodeInternals:a,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:l,domNode:u,nodeOrigin:c}=t(),d=u==null?void 0:u.querySelector(".react-flow__viewport");if(!d)return;const f=window.getComputedStyle(d),{m22:p}=new window.DOMMatrixReadOnly(f.transform),x=n.reduce((m,y)=>{const b=a.get(y.id);if(b!=null&&b.hidden)a.set(b.id,{...b,[De]:{...b[De],handleBounds:void 0}});else if(b){const v=nl(y.nodeElement);!!(v.width&&v.height&&(b.width!==v.width||b.height!==v.height||y.forceUpdate))&&(a.set(b.id,{...b,[De]:{...b[De],handleBounds:{source:pu(".source",y.nodeElement,p,c),target:pu(".target",y.nodeElement,p,c)}},...v}),m.push({id:b.id,type:"dimensions",dimensions:v}))}return m},[]);Dp(a,c);const g=i||o&&!i&&$p(t,{initial:!0,...l});e({nodeInternals:new Map(a),fitViewOnInitDone:g}),(x==null?void 0:x.length)>0&&(s==null||s(x))},updateNodePositions:(n,s=!0,a=!1)=>{const{triggerNodeChanges:o}=t(),i=n.map(l=>{const u={id:l.id,type:"position",dragging:a};return s&&(u.positionAbsolute=l.positionAbsolute,u.position=l.position),u});o(i)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:a,hasDefaultNodes:o,nodeOrigin:i,getNodes:l,elevateNodesOnSelect:u}=t();if(n!=null&&n.length){if(o){const c=Fp(n,l()),d=xo(c,a,i,u);e({nodeInternals:d})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,l=null;s?i=n.map(u=>qt(u,!0)):(i=Vn(o(),n),l=Vn(a,[])),Ss({changedNodes:i,changedEdges:l,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,l=null;s?i=n.map(u=>qt(u,!0)):(i=Vn(a,n),l=Vn(o(),[])),Ss({changedNodes:l,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:a,getNodes:o}=t(),i=n||o(),l=s||a,u=i.map(d=>(d.selected=!1,qt(d.id,!1))),c=l.map(d=>qt(d.id,!1));Ss({changedNodes:u,changedEdges:c,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:s,maxZoom:a}=t();s==null||s.scaleExtent([n,a]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:s,minZoom:a}=t();s==null||s.scaleExtent([a,n]),e({maxZoom:n})},setTranslateExtent:n=>{var s;(s=t().d3Zoom)==null||s.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:s}=t(),o=s().filter(l=>l.selected).map(l=>qt(l.id,!1)),i=n.filter(l=>l.selected).map(l=>qt(l.id,!1));Ss({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=rl(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:a,height:o,d3Zoom:i,d3Selection:l,translateExtent:u}=t();if(!i||!l||!n.x&&!n.y)return!1;const c=Mt.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),d=[[0,0],[a,o]],f=i==null?void 0:i.constrain()(c,d,u);return i.transform(l,f),s[0]!==f.x||s[1]!==f.y||s[2]!==f.k},cancelConnection:()=>e({connectionNodeId:Bt.connectionNodeId,connectionHandleId:Bt.connectionHandleId,connectionHandleType:Bt.connectionHandleType,connectionStatus:Bt.connectionStatus,connectionStartHandle:Bt.connectionStartHandle,connectionEndHandle:Bt.connectionEndHandle}),reset:()=>e({...Bt})}),Object.is),Jp=({children:e})=>{const t=h.useRef(null);return t.current||(t.current=K2()),q.createElement(mE,{value:t.current},e)};Jp.displayName="ReactFlowProvider";const Qp=({children:e})=>h.useContext(La)?q.createElement(q.Fragment,null,e):q.createElement(Jp,null,e);Qp.displayName="ReactFlowWrapper";const Y2={input:Rp,default:ci,output:Mp,group:cl},X2={default:ca,straight:ol,step:al,smoothstep:Da,simplebezier:sl},Z2=[0,0],J2=[15,15],Q2={x:0,y:0,zoom:1},e_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},em=h.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:o=Y2,edgeTypes:i=X2,onNodeClick:l,onEdgeClick:u,onInit:c,onMove:d,onMoveStart:f,onMoveEnd:p,onConnect:x,onConnectStart:g,onConnectEnd:m,onClickConnectStart:y,onClickConnectEnd:b,onNodeMouseEnter:v,onNodeMouseMove:N,onNodeMouseLeave:w,onNodeContextMenu:j,onNodeDoubleClick:k,onNodeDragStart:_,onNodeDrag:P,onNodeDragStop:T,onNodesDelete:$,onEdgesDelete:B,onSelectionChange:D,onSelectionDragStart:R,onSelectionDrag:S,onSelectionDragStop:C,onSelectionContextMenu:E,onSelectionStart:A,onSelectionEnd:O,connectionMode:I=kn.Strict,connectionLineType:F=Wt.Bezier,connectionLineStyle:L,connectionLineComponent:M,connectionLineContainerStyle:z,deleteKeyCode:H="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:Z=!1,selectionMode:G=Gr.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:ee=ia()?"Meta":"Control",zoomActivationKeyCode:te=ia()?"Meta":"Control",snapToGrid:oe=!1,snapGrid:ie=J2,onlyRenderVisibleElements:me=!1,selectNodesOnDrag:W=!0,nodesDraggable:fe,nodesConnectable:Ae,nodesFocusable:ge,nodeOrigin:Y=Z2,edgesFocusable:Pe,edgesUpdatable:Te,elementsSelectable:be,defaultViewport:Xe=Q2,minZoom:He=.5,maxZoom:Ve=2,translateExtent:tt=di,preventScrolling:U=!0,nodeExtent:K,defaultMarkerColor:ne="#b1b1b7",zoomOnScroll:pe=!0,zoomOnPinch:Ee=!0,panOnScroll:_e=!1,panOnScrollSpeed:Ze=.5,panOnScrollMode:kt=xn.Free,zoomOnDoubleClick:ln=!0,panOnDrag:cn=!0,onPaneClick:Et,onPaneMouseEnter:xt,onPaneMouseMove:pr,onPaneMouseLeave:qa,onPaneScroll:mr,onPaneContextMenu:Wa,children:Il,onEdgeContextMenu:un,onEdgeDoubleClick:Ix,onEdgeMouseEnter:Px,onEdgeMouseMove:Ox,onEdgeMouseLeave:Lx,onEdgeUpdate:Dx,onEdgeUpdateStart:$x,onEdgeUpdateEnd:zx,onReconnect:Fx,onReconnectStart:Bx,onReconnectEnd:Hx,reconnectRadius:Ux=10,edgeUpdaterRadius:Vx=10,onNodesChange:qx,onEdgesChange:Wx,noDragClassName:Gx="nodrag",noWheelClassName:Kx="nowheel",noPanClassName:Pl="nopan",fitView:Yx=!1,fitViewOptions:Xx,connectOnClick:Zx=!0,attributionPosition:Jx,proOptions:Qx,defaultEdgeOptions:eg,elevateNodesOnSelect:tg=!0,elevateEdgesOnSelect:ng=!1,disableKeyboardA11y:Ol=!1,autoPanOnConnect:rg=!0,autoPanOnNodeDrag:sg=!0,connectionRadius:ag=20,isValidConnection:og,onError:ig,style:lg,id:Ll,nodeDragThreshold:cg,...ug},dg)=>{const Ga=Ll||"1";return q.createElement("div",{...ug,style:{...lg,...e_},ref:dg,className:Be(["react-flow",a]),"data-testid":"rf__wrapper",id:Ll},q.createElement(Qp,null,q.createElement(G2,{onInit:c,onMove:d,onMoveStart:f,onMoveEnd:p,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:v,onNodeMouseMove:N,onNodeMouseLeave:w,onNodeContextMenu:j,onNodeDoubleClick:k,nodeTypes:o,edgeTypes:i,connectionLineType:F,connectionLineStyle:L,connectionLineComponent:M,connectionLineContainerStyle:z,selectionKeyCode:V,selectionOnDrag:Z,selectionMode:G,deleteKeyCode:H,multiSelectionKeyCode:ee,panActivationKeyCode:J,zoomActivationKeyCode:te,onlyRenderVisibleElements:me,selectNodesOnDrag:W,defaultViewport:Xe,translateExtent:tt,minZoom:He,maxZoom:Ve,preventScrolling:U,zoomOnScroll:pe,zoomOnPinch:Ee,zoomOnDoubleClick:ln,panOnScroll:_e,panOnScrollSpeed:Ze,panOnScrollMode:kt,panOnDrag:cn,onPaneClick:Et,onPaneMouseEnter:xt,onPaneMouseMove:pr,onPaneMouseLeave:qa,onPaneScroll:mr,onPaneContextMenu:Wa,onSelectionContextMenu:E,onSelectionStart:A,onSelectionEnd:O,onEdgeContextMenu:un,onEdgeDoubleClick:Ix,onEdgeMouseEnter:Px,onEdgeMouseMove:Ox,onEdgeMouseLeave:Lx,onReconnect:Fx??Dx,onReconnectStart:Bx??$x,onReconnectEnd:Hx??zx,reconnectRadius:Ux??Vx,defaultMarkerColor:ne,noDragClassName:Gx,noWheelClassName:Kx,noPanClassName:Pl,elevateEdgesOnSelect:ng,rfId:Ga,disableKeyboardA11y:Ol,nodeOrigin:Y,nodeExtent:K}),q.createElement(VE,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:x,onConnectStart:g,onConnectEnd:m,onClickConnectStart:y,onClickConnectEnd:b,nodesDraggable:fe,nodesConnectable:Ae,nodesFocusable:ge,edgesFocusable:Pe,edgesUpdatable:Te,elementsSelectable:be,elevateNodesOnSelect:tg,minZoom:He,maxZoom:Ve,nodeExtent:K,onNodesChange:qx,onEdgesChange:Wx,snapToGrid:oe,snapGrid:ie,connectionMode:I,translateExtent:tt,connectOnClick:Zx,defaultEdgeOptions:eg,fitView:Yx,fitViewOptions:Xx,onNodesDelete:$,onEdgesDelete:B,onNodeDragStart:_,onNodeDrag:P,onNodeDragStop:T,onSelectionDrag:S,onSelectionDragStart:R,onSelectionDragStop:C,noPanClassName:Pl,nodeOrigin:Y,rfId:Ga,autoPanOnConnect:rg,autoPanOnNodeDrag:sg,onError:ig,connectionRadius:ag,isValidConnection:og,nodeDragThreshold:cg}),q.createElement(HE,{onSelectionChange:D}),Il,q.createElement(gE,{proOptions:Qx,position:Jx}),q.createElement(YE,{rfId:Ga,disableKeyboardA11y:Ol})))});em.displayName="ReactFlow";function tm(e){return t=>{const[n,s]=h.useState(t),a=h.useCallback(o=>s(i=>e(o,i)),[]);return[n,s,a]}}const t_=tm(Fp),n_=tm(c2),nm=({id:e,x:t,y:n,width:s,height:a,style:o,color:i,strokeColor:l,strokeWidth:u,className:c,borderRadius:d,shapeRendering:f,onClick:p,selected:x})=>{const{background:g,backgroundColor:m}=o||{},y=i||g||m;return q.createElement("rect",{className:Be(["react-flow__minimap-node",{selected:x},c]),x:t,y:n,rx:d,ry:d,width:s,height:a,fill:y,stroke:l,strokeWidth:u,shapeRendering:f,onClick:p?b=>p(b,e):void 0})};nm.displayName="MiniMapNode";var r_=h.memo(nm);const s_=e=>e.nodeOrigin,a_=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),vo=e=>e instanceof Function?e:()=>e;function o_({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o=r_,onClick:i}){const l=Ie(a_,ze),u=Ie(s_),c=vo(t),d=vo(e),f=vo(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return q.createElement(q.Fragment,null,l.map(x=>{const{x:g,y:m}=yn(x,u).positionAbsolute;return q.createElement(o,{key:x.id,x:g,y:m,width:x.width,height:x.height,style:x.style,selected:x.selected,className:f(x),color:c(x),borderRadius:s,strokeColor:d(x),strokeWidth:a,shapeRendering:p,onClick:i,id:x.id})}))}var i_=h.memo(o_);const l_=200,c_=150,u_=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?vE($a(t,e.nodeOrigin),n):n,rfId:e.rfId}},d_="react-flow__minimap-desc";function rm({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:l,maskColor:u="rgb(240, 240, 240, 0.6)",maskStrokeColor:c="none",maskStrokeWidth:d=1,position:f="bottom-right",onClick:p,onNodeClick:x,pannable:g=!1,zoomable:m=!1,ariaLabel:y="React Flow mini map",inversePan:b=!1,zoomStep:v=10,offsetScale:N=5}){const w=$e(),j=h.useRef(null),{boundingRect:k,viewBB:_,rfId:P}=Ie(u_,ze),T=(e==null?void 0:e.width)??l_,$=(e==null?void 0:e.height)??c_,B=k.width/T,D=k.height/$,R=Math.max(B,D),S=R*T,C=R*$,E=N*R,A=k.x-(S-k.width)/2-E,O=k.y-(C-k.height)/2-E,I=S+E*2,F=C+E*2,L=`${d_}-${P}`,M=h.useRef(0);M.current=R,h.useEffect(()=>{if(j.current){const V=nt(j.current),Z=ee=>{const{transform:te,d3Selection:oe,d3Zoom:ie}=w.getState();if(ee.sourceEvent.type!=="wheel"||!oe||!ie)return;const me=-ee.sourceEvent.deltaY*(ee.sourceEvent.deltaMode===1?.05:ee.sourceEvent.deltaMode?1:.002)*v,W=te[2]*Math.pow(2,me);ie.scaleTo(oe,W)},G=ee=>{const{transform:te,d3Selection:oe,d3Zoom:ie,translateExtent:me,width:W,height:fe}=w.getState();if(ee.sourceEvent.type!=="mousemove"||!oe||!ie)return;const Ae=M.current*Math.max(1,te[2])*(b?-1:1),ge={x:te[0]-ee.sourceEvent.movementX*Ae,y:te[1]-ee.sourceEvent.movementY*Ae},Y=[[0,0],[W,fe]],Pe=Mt.translate(ge.x,ge.y).scale(te[2]),Te=ie.constrain()(Pe,Y,me);ie.transform(oe,Te)},J=ip().on("zoom",g?G:null).on("zoom.wheel",m?Z:null);return V.call(J),()=>{V.on("zoom",null)}}},[g,m,b,v]);const z=p?V=>{const Z=ot(V);p(V,{x:Z[0],y:Z[1]})}:void 0,H=x?(V,Z)=>{const G=w.getState().nodeInternals.get(Z);x(V,G)}:void 0;return q.createElement(tl,{position:f,style:e,className:Be(["react-flow__minimap",t]),"data-testid":"rf__minimap"},q.createElement("svg",{width:T,height:$,viewBox:`${A} ${O} ${I} ${F}`,role:"img","aria-labelledby":L,ref:j,onClick:z},y&&q.createElement("title",{id:L},y),q.createElement(i_,{onClick:H,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:i,nodeComponent:l}),q.createElement("path",{className:"react-flow__minimap-mask",d:`M${A-E},${O-E}h${I+E*2}v${F+E*2}h${-I-E*2}z
|
|
580
|
+
M${_.x},${_.y}h${_.width}v${_.height}h${-_.width}z`,fill:u,fillRule:"evenodd",stroke:c,strokeWidth:d,pointerEvents:"none"})))}rm.displayName="MiniMap";var h_=h.memo(rm);function f_(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},q.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function p_(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},q.createElement("path",{d:"M0 0h32v4.2H0z"}))}function m_(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},q.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function x_(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},q.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function g_(){return q.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},q.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const Ar=({children:e,className:t,...n})=>q.createElement("button",{type:"button",className:Be(["react-flow__controls-button",t]),...n},e);Ar.displayName="ControlButton";const y_=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),sm=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:i,onFitView:l,onInteractiveChange:u,className:c,children:d,position:f="bottom-left"})=>{const p=$e(),[x,g]=h.useState(!1),{isInteractive:m,minZoomReached:y,maxZoomReached:b}=Ie(y_,ze),{zoomIn:v,zoomOut:N,fitView:w}=ul();if(h.useEffect(()=>{g(!0)},[]),!x)return null;const j=()=>{v(),o==null||o()},k=()=>{N(),i==null||i()},_=()=>{w(a),l==null||l()},P=()=>{p.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),u==null||u(!m)};return q.createElement(tl,{className:Be(["react-flow__controls",c]),position:f,style:e,"data-testid":"rf__controls"},t&&q.createElement(q.Fragment,null,q.createElement(Ar,{onClick:j,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},q.createElement(f_,null)),q.createElement(Ar,{onClick:k,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:y},q.createElement(p_,null))),n&&q.createElement(Ar,{className:"react-flow__controls-fitview",onClick:_,title:"fit view","aria-label":"fit view"},q.createElement(m_,null)),s&&q.createElement(Ar,{className:"react-flow__controls-interactive",onClick:P,title:"toggle interactivity","aria-label":"toggle interactivity"},m?q.createElement(g_,null):q.createElement(x_,null)),d)};sm.displayName="Controls";var b_=h.memo(sm),ut;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ut||(ut={}));function v_({color:e,dimensions:t,lineWidth:n}){return q.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function w_({color:e,radius:t}){return q.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const N_={[ut.Dots]:"#91919a",[ut.Lines]:"#eee",[ut.Cross]:"#e2e2e2"},S_={[ut.Dots]:1,[ut.Lines]:1,[ut.Cross]:6},j_=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function am({id:e,variant:t=ut.Dots,gap:n=20,size:s,lineWidth:a=1,offset:o=2,color:i,style:l,className:u}){const c=h.useRef(null),{transform:d,patternId:f}=Ie(j_,ze),p=i||N_[t],x=s||S_[t],g=t===ut.Dots,m=t===ut.Cross,y=Array.isArray(n)?n:[n,n],b=[y[0]*d[2]||1,y[1]*d[2]||1],v=x*d[2],N=m?[v,v]:b,w=g?[v/o,v/o]:[N[0]/o,N[1]/o];return q.createElement("svg",{className:Be(["react-flow__background",u]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:c,"data-testid":"rf__background"},q.createElement("pattern",{id:f+e,x:d[0]%b[0],y:d[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},g?q.createElement(w_,{color:p,radius:v/o}):q.createElement(v_,{dimensions:N,color:p,lineWidth:a})),q.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}am.displayName="Background";var k_=h.memo(am);function E_(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState(!1),o=h.useCallback(async()=>{if(e)try{const c=await fetch(`${e}/scenarios`);if(c.ok){const d=await c.json();n(d)}}catch(c){console.error(c)}},[e]),i=h.useCallback(async c=>{if(!e)throw new Error("Scenario API base URL is unavailable.");a(!0);try{const d=await fetch(`${e}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw new Error(`Failed to save scenario (${d.status})`);const f=await d.json();return await o(),f}catch(d){throw console.error(d),d}finally{a(!1)}},[e,o]),l=h.useCallback(async c=>{if(!e)throw new Error("Scenario API base URL is unavailable.");const d=await fetch(`${e}/scenarios/${c}/run`,{method:"POST"});if(!d.ok)throw new Error(`Failed to run scenario (${d.status})`);return await d.json()},[e]),u=h.useCallback(async(c,d)=>{if(!e)throw new Error("Scenario API base URL is unavailable.");const f=d?`?executionId=${encodeURIComponent(d)}`:"",p=await fetch(`${e}/scenarios/${c}/status${f}`);if(!p.ok)throw new Error(`Failed to fetch scenario status (${p.status})`);return await p.json()},[e]);return h.useEffect(()=>{o()},[o]),{scenarios:t,saveScenario:i,runScenario:l,getScenarioRunStatus:u,isLoading:s}}const __=()=>"rgba(56, 189, 248, 0.9)";function C_({nodes:e,edges:t,onNodesChange:n,onEdgesChange:s,onConnect:a,onDrop:o,onDragOver:i,onInit:l,hasValidationErrors:u}){return r.jsxs(se,{variant:"glass",glow:"primary",className:"xl:col-span-6 flex flex-col min-h-0",children:[r.jsx(ce,{className:"flex-none border-b border-white/5 pb-3",children:r.jsx(de,{className:"flex items-center gap-2",children:"Attack/Chaos Architect Canvas"})}),r.jsxs(ae,{className:"mt-0 p-0 flex-1 min-h-0",children:[r.jsx("div",{role:"region","aria-label":"Scenario flow canvas","aria-roledescription":"Drag-and-drop scenario builder canvas","aria-invalid":u,"aria-errormessage":u?"scenario-canvas-validation-error":void 0,className:X("w-full h-full min-h-[420px] bg-[radial-gradient(circle_at_top,_rgba(56,189,248,0.15),_rgba(2,6,23,0.95)_52%)]",u?"ring-2 ring-danger-500/60 ring-inset":""),children:r.jsxs(em,{nodes:e,edges:t,onNodesChange:n,onEdgesChange:s,onConnect:a,onDrop:o,onDragOver:i,onInit:l,fitView:!0,children:[r.jsx(k_,{color:"rgba(148,163,184,0.25)",gap:20,size:1}),r.jsx(h_,{pannable:!0,zoomable:!0,nodeColor:__,style:{background:"rgba(2, 6, 23, 0.85)",border:"1px solid rgba(56, 189, 248, 0.3)"}}),r.jsx(b_,{})]})}),r.jsxs("div",{className:"px-3 py-2 text-[11px] text-neutral-500 font-mono border-t border-neutral-800/60",children:["Tip: select a node or edge and press ",r.jsx("span",{className:"text-neutral-300",children:"Delete"})," to remove it."]}),u&&r.jsx("div",{id:"scenario-canvas-validation-error",role:"alert",className:"px-3 py-2 text-[11px] text-danger-400 font-mono border-t border-danger-900/40",children:"Invalid execution flow detected. Resolve validation errors before saving."})]})]})}const Nu={x:120,y:100},Su={x:40,y:28},ls=[{action:"chaos.cpu",label:"Chaos Spike",description:"Trigger a CPU spike for resilience pressure.",defaults:{duration:5e3},delayMs:1e3,className:"ring-danger-500/30"},{action:"chaos.memory",label:"Memory Surge",description:"Allocate memory stress in MB.",defaults:{action:"allocate",amount:100},delayMs:1e3,className:"ring-warning-500/30"},{action:"cluster.attack",label:"Attack Cluster",description:"Coordinate distributed attack traffic.",defaults:{target:"http://example.com",rate:50},className:"ring-primary-500/30"},{action:"mtd.rotate",label:"MTD Rotation",description:"Rotate moving-target defense controls.",defaults:{},className:"ring-info-500/30"},{action:"delay",label:"Network Delay",description:"Insert a pause between scenario steps.",defaults:{duration:1e3},className:"ring-neutral-500/40"}],we={postStepDelayMs:{min:0,max:12e4},chaosCpuDurationMs:{min:250,max:12e4},chaosMemoryAmountMb:{min:1,max:4096},clusterAttackRate:{min:1,max:2e3},delayDurationMs:{min:10,max:12e4},mtdPrefixMaxLength:48};function om(e){return ls.some(t=>t.action===e)}function im(e){const t=ls.find(n=>n.action===e);return{action:e,label:(t==null?void 0:t.label)??e,params:{...(t==null?void 0:t.defaults)??{}},delayMs:t==null?void 0:t.delayMs}}function lm(e,t){if(e==="chaos.memory"){if((t.action==="clear"?"clear":"allocate")==="clear")return{action:"clear"};const s=cm(t.amount??t.mb);return{action:"allocate",amount:s!==null?Math.trunc(s):100}}if(e==="mtd.rotate"){if(typeof t.prefix=="string"){const n=t.prefix.trim();if(n.length===0){const{prefix:s,...a}=t;return a}return{...t,prefix:n}}if(t.prefix!==void 0){const{prefix:n,...s}=t;return s}}return{...t}}function T_(e){return{x:Nu.x+e*Su.x,y:Nu.y+e*Su.y}}function R_(e){return e.map(t=>`${t.source}->${t.target}`).sort().join("|")}function ks(e,t){return JSON.stringify({payload:e,edgeSignature:R_(t)})}function A_(e,t){if(e.length===0)return[];const n=new Set,s=new Set(e.map(g=>g.id)),a=new Map(e.map(g=>[g.id,0])),o=new Map(e.map(g=>[g.id,[]]));let i=0;for(const g of t){if(!s.has(g.source)||!s.has(g.target)){n.add("Graph contains invalid edge references.");continue}i+=1,a.set(g.target,(a.get(g.target)??0)+1);const m=o.get(g.source)??[];m.push(g.target),o.set(g.source,m)}Array.from(a.values()).some(g=>g>1)&&n.add("Sequential mode allows only one incoming edge per step."),Array.from(o.values()).some(g=>g.length>1)&&n.add("Sequential mode allows only one outgoing edge per step.");const c=e.filter(g=>(a.get(g.id)??0)===0);c.length!==1&&n.add("Graph must have exactly one starting step."),i!==e.length-1&&n.add("Graph must connect all steps in a single execution chain.");const d=new Set,f=new Set,p=g=>{if(f.has(g))return!0;if(d.has(g))return!1;d.add(g),f.add(g);const m=o.get(g)??[];for(const y of m)if(p(y))return!0;return f.delete(g),!1};if(e.some(g=>p(g.id))&&n.add("Graph cannot contain execution cycles."),c.length===1){const g=new Set;let m=c[0].id;for(;m&&!g.has(m);)g.add(m),m=(o.get(m)??[])[0];g.size!==e.length&&n.add("Graph contains disconnected steps.")}return Array.from(n)}function cm(e){const t=Number(e);return Number.isFinite(t)?t:null}function jr(e,t,n){const s=cm(e);return s!==null&&Number.isInteger(s)&&s>=t&&s<=n}function M_(e){if(typeof e!="string"||e.trim().length===0)return!1;try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function um(e,t,n){const s=lm(e,t),a=[];switch(n!==void 0&&!jr(n,we.postStepDelayMs.min,we.postStepDelayMs.max)&&a.push(`Post-step delay must be an integer between ${we.postStepDelayMs.min} and ${we.postStepDelayMs.max} ms.`),e){case"chaos.cpu":jr(s.duration,we.chaosCpuDurationMs.min,we.chaosCpuDurationMs.max)||a.push(`CPU duration must be an integer between ${we.chaosCpuDurationMs.min} and ${we.chaosCpuDurationMs.max} ms.`);break;case"chaos.memory":{(s.action==="clear"?"clear":"allocate")==="allocate"&&!jr(s.amount,we.chaosMemoryAmountMb.min,we.chaosMemoryAmountMb.max)&&a.push(`Memory amount must be an integer between ${we.chaosMemoryAmountMb.min} and ${we.chaosMemoryAmountMb.max} MB.`);break}case"cluster.attack":M_(s.target)||a.push("Cluster target must be a valid http/https URL."),jr(s.rate,we.clusterAttackRate.min,we.clusterAttackRate.max)||a.push(`Cluster rate must be an integer between ${we.clusterAttackRate.min} and ${we.clusterAttackRate.max}.`);break;case"mtd.rotate":s.prefix!==void 0&&(typeof s.prefix!="string"||s.prefix.trim().length===0?a.push("MTD prefix must be a non-empty string when provided."):s.prefix.length>we.mtdPrefixMaxLength&&a.push(`MTD prefix must be at most ${we.mtdPrefixMaxLength} characters.`));break;case"delay":jr(s.duration,we.delayDurationMs.min,we.delayDurationMs.max)||a.push(`Delay duration must be an integer between ${we.delayDurationMs.min} and ${we.delayDurationMs.max} ms.`);break}return a}function I_(e){const t=[];for(const n of e){const s=um(n.data.action,n.data.params,n.data.delayMs);for(const a of s)t.push(`${n.data.label} (${n.id}): ${a}`)}return t}const dm={borderRadius:10,borderWidth:1,borderStyle:"solid",borderColor:"rgba(148, 163, 184, 0.4)",backgroundColor:"rgba(15, 23, 42, 0.9)",color:"rgba(226, 232, 240, 1)",padding:"12px 14px",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"13px",fontWeight:600,lineHeight:1.4,minWidth:240,minHeight:72,boxShadow:"0 0 0 1px rgba(14, 116, 144, 0.1), 0 10px 20px -15px rgba(14, 116, 144, 0.6)"};function P_(){return`node-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}function O_(e){return ls.find(t=>t.action===e)}function L_(e,t){return{id:P_(),type:"default",position:t,data:im(e),style:dm}}function wo(e){var d;const t=[...e.nodes].sort((f,p)=>f.position.x!==p.position.x?f.position.x-p.position.x:f.position.y-p.position.y),n=new Map(t.map(f=>[f.id,f])),s=(e.edges??[]).filter(f=>n.has(f.source)&&n.has(f.target)),a=new Map(t.map(f=>[f.id,0])),o=new Map;for(const f of s){a.set(f.target,(a.get(f.target)??0)+1);const p=o.get(f.source)??[];p.push(f.target),o.set(f.source,p)}for(const[f,p]of o.entries())p.sort((x,g)=>{const m=n.get(x),y=n.get(g);return!m||!y?0:m.position.x!==y.position.x?m.position.x-y.position.x:m.position.y-y.position.y}),o.set(f,p);const i=[],l=new Set,u=t.map(f=>f.id).filter(f=>(a.get(f)??0)===0),c=u.length>0?u:t.map(f=>f.id);for(const f of c){let p=f;for(;p&&!l.has(p);){const x=n.get(p);if(!x)break;i.push(x),l.add(p),p=(o.get(p)??[]).find(m=>!l.has(m))}}for(const f of t)l.has(f.id)||(i.push(f),l.add(f.id));return{id:e.id,name:e.name.trim(),description:((d=e.description)==null?void 0:d.trim())||void 0,steps:i.map(f=>({id:f.id,action:f.data.action,params:f.data.params,delayMs:f.data.delayMs}))}}function No(e){const t=e.steps.map((s,a)=>{var o;return{id:s.id,type:"default",position:{x:110+a*280,y:130+a%2*120},data:{action:s.action,label:((o=O_(s.action))==null?void 0:o.label)??s.action,params:lm(s.action,s.params),delayMs:s.delayMs},style:dm}}),n=[];for(let s=0;s<t.length-1;s+=1)n.push({id:`e-${t[s].id}-${t[s+1].id}`,source:t[s].id,target:t[s+1].id,animated:!0,style:{stroke:"rgba(0, 170, 255, 0.7)"}});return{nodes:t,edges:n}}const Tt="w-full rounded-sm border border-neutral-700/80 bg-neutral-950/70 p-2 text-xs text-neutral-200 font-mono focus:outline-none focus:ring-1 focus:ring-primary-500/60";function D_({scenarioName:e,scenarioDescription:t,validationErrors:n,jsonPreview:s,selectedNode:a,hasMultiSelection:o,selectedNodeErrors:i,onScenarioNameChange:l,onScenarioDescriptionChange:u,onSelectedActionChange:c,onSelectedDelayMsChange:d,onSelectedParamChange:f,onSelectedMemoryModeChange:p}){const x=a==null?void 0:a.data.action,g=(a==null?void 0:a.data.params)??{};return r.jsxs(se,{variant:"panel",glow:"none",className:"xl:col-span-3 flex flex-col min-h-0",children:[r.jsx(ce,{className:"flex-none border-b border-neutral-800 pb-3",children:r.jsxs(de,{className:"flex items-center gap-2 text-sm",children:[r.jsx(ad,{className:"h-4 w-4 text-primary-500"}),"Scenario Config + JSON"]})}),r.jsxs(ae,{className:"mt-0 p-4 space-y-4 flex-1 min-h-0 overflow-y-auto",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"scenario-name",className:"text-[11px] uppercase tracking-widest text-neutral-500 font-mono",children:"Scenario Name"}),r.jsx(Oi,{id:"scenario-name",value:e,onChange:m=>l(m.target.value),placeholder:"Scenario name"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{htmlFor:"scenario-description",className:"text-[11px] uppercase tracking-widest text-neutral-500 font-mono",children:"Description"}),r.jsx("textarea",{id:"scenario-description","aria-label":"Scenario description",className:"w-full min-h-[72px] rounded-sm border border-neutral-700/80 bg-neutral-950/70 p-2 text-xs text-neutral-200 font-mono focus:outline-none focus:ring-1 focus:ring-primary-500/60",value:t,onChange:m=>u(m.target.value),placeholder:"Describe this scenario"})]}),r.jsxs("div",{className:"space-y-2 border border-neutral-800/70 rounded-sm p-3 bg-neutral-950/40",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-widest text-neutral-500 font-mono",children:"Selected Step"}),o&&r.jsx("div",{role:"status","aria-live":"polite",className:"text-[11px] text-warning-400",children:"Multiple nodes selected. Select one node to edit parameters."}),!o&&!a&&r.jsx("div",{role:"status","aria-live":"polite",className:"text-[11px] text-neutral-500",children:"Select a node on the canvas to edit its parameters."}),a&&r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"text-xs text-neutral-300 font-mono",children:[a.data.label," · ",a.id]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-action",className:"text-[11px] text-neutral-500 font-mono",children:"Action"}),r.jsx("select",{id:"selected-node-action",className:Tt,value:x,onChange:m=>{const y=m.target.value;om(y)&&c(y)},children:ls.map(m=>r.jsxs("option",{value:m.action,children:[m.label," (",m.action,")"]},m.action))})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-delay-ms",className:"text-[11px] text-neutral-500 font-mono",children:"Post-Step Delay (ms)"}),r.jsx("input",{id:"selected-node-delay-ms",type:"number",min:we.postStepDelayMs.min,max:we.postStepDelayMs.max,value:Number(a.data.delayMs??0),className:Tt,onChange:m=>d(Number(m.target.value))})]}),x==="chaos.cpu"&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-cpu-duration",className:"text-[11px] text-neutral-500 font-mono",children:"CPU Duration (ms)"}),r.jsx("input",{id:"selected-node-cpu-duration",type:"number",min:we.chaosCpuDurationMs.min,max:we.chaosCpuDurationMs.max,value:Number(g.duration??5e3),className:Tt,onChange:m=>f("duration",Number(m.target.value))})]}),x==="chaos.memory"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-memory-mode",className:"text-[11px] text-neutral-500 font-mono",children:"Memory Mode"}),r.jsxs("select",{id:"selected-node-memory-mode",className:Tt,value:g.action==="clear"?"clear":"allocate",onChange:m=>p(m.target.value==="clear"?"clear":"allocate"),children:[r.jsx("option",{value:"allocate",children:"allocate"}),r.jsx("option",{value:"clear",children:"clear"})]})]}),g.action!=="clear"&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-memory-amount",className:"text-[11px] text-neutral-500 font-mono",children:"Memory Amount (MB)"}),r.jsx("input",{id:"selected-node-memory-amount",type:"number",min:we.chaosMemoryAmountMb.min,max:we.chaosMemoryAmountMb.max,value:Number(g.amount??100),className:Tt,onChange:m=>f("amount",Number(m.target.value))})]})]}),x==="cluster.attack"&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-cluster-target",className:"text-[11px] text-neutral-500 font-mono",children:"Target URL"}),r.jsx("input",{id:"selected-node-cluster-target",type:"url",value:String(g.target??""),className:Tt,onChange:m=>f("target",m.target.value)})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-cluster-rate",className:"text-[11px] text-neutral-500 font-mono",children:"Rate"}),r.jsx("input",{id:"selected-node-cluster-rate",type:"number",min:we.clusterAttackRate.min,max:we.clusterAttackRate.max,value:Number(g.rate??100),className:Tt,onChange:m=>f("rate",Number(m.target.value))})]})]}),x==="mtd.rotate"&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-prefix",className:"text-[11px] text-neutral-500 font-mono",children:"Prefix (optional)"}),r.jsx("input",{id:"selected-node-prefix",type:"text",maxLength:we.mtdPrefixMaxLength,value:String(g.prefix??""),className:Tt,onChange:m=>f("prefix",m.target.value)})]}),x==="delay"&&r.jsxs("div",{className:"space-y-1",children:[r.jsx("label",{htmlFor:"selected-node-delay-duration",className:"text-[11px] text-neutral-500 font-mono",children:"Delay Duration (ms)"}),r.jsx("input",{id:"selected-node-delay-duration",type:"number",min:we.delayDurationMs.min,max:we.delayDurationMs.max,value:Number(g.duration??1e3),className:Tt,onChange:m=>f("duration",Number(m.target.value))})]}),i.length>0&&r.jsx("div",{className:"space-y-1","aria-live":"polite",children:i.map((m,y)=>r.jsx("div",{className:"text-[11px] text-danger-400",children:m},`${y}-${m}`))})]})]}),r.jsxs("div",{className:"space-y-2","aria-live":"polite",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-widest text-neutral-500 font-mono",children:"Validation"}),n.length===0&&r.jsx("div",{className:"text-[11px] text-success-400",children:"Ready to save."}),n.map((m,y)=>r.jsx("div",{className:"text-[11px] text-danger-400",children:m},`${y}-${m}`))]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-widest text-neutral-500 font-mono",children:"Live JSON Preview"}),r.jsx("pre",{"aria-label":"Scenario JSON preview",className:"rounded-sm border border-neutral-800 bg-black/50 p-3 text-[11px] text-neutral-200 overflow-auto max-h-[320px]",children:s})]})]})]})}function $_({scenarios:e,selectedId:t,onSelectScenario:n,onRunScenario:s,onAddNode:a,onPaletteDragStart:o}){return r.jsxs(se,{variant:"panel",glow:"primary",className:"flex flex-col xl:col-span-3 min-h-0",children:[r.jsx(ce,{className:"flex-none border-b border-neutral-800 pb-3",children:r.jsx(de,{className:"text-sm font-mono",children:"Library + Tool Blocks"})}),r.jsxs(ae,{className:"mt-0 p-0 flex-1 overflow-y-auto",children:[r.jsxs("div",{className:"p-4 border-b border-neutral-800/80 space-y-3",children:[r.jsx("div",{className:"text-[11px] uppercase tracking-widest text-neutral-500 font-mono",children:"Palette"}),r.jsx("div",{className:"space-y-2",children:ls.map(i=>r.jsx("div",{draggable:!0,onDragStart:l=>o(l,i.action),role:"button",tabIndex:0,"aria-label":`Drag or add ${i.label}`,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),a(i.action))},className:X("rounded-sm border border-neutral-700/80 bg-neutral-900/70 p-3 cursor-grab active:cursor-grabbing hover:border-primary-500/60 transition-colors",i.className),children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-xs font-bold text-neutral-200 font-mono",children:i.label}),r.jsx("div",{className:"text-[11px] text-neutral-500 mt-1",children:i.description}),r.jsx("div",{className:"text-[10px] text-primary-400 mt-2 font-mono",children:i.action})]}),r.jsx(Q,{size:"sm",variant:"ghost","aria-label":`Add ${i.label} block`,onClick:()=>a(i.action),children:"Add"})]})},i.action))})]}),r.jsxs("div",{className:"divide-y divide-neutral-800/50",children:[e.map(i=>r.jsxs("div",{role:"button",tabIndex:0,className:X("p-4 hover:bg-neutral-900/50 flex justify-between items-center group cursor-pointer transition-colors border-l-2",t===i.id?"bg-neutral-900/80 border-primary-500":"border-transparent"),onClick:()=>n(i),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),n(i))},children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:X("font-bold text-sm",t===i.id?"text-primary-400":"text-neutral-300"),children:i.name}),r.jsxs("div",{className:"text-xs text-neutral-500",children:[i.steps.length," steps"]})]}),r.jsx(Q,{size:"icon",variant:"ghost",onClick:l=>{l.stopPropagation(),s(i.id)},children:r.jsx(Ke,{className:"h-4 w-4 text-success-500"})})]},i.id)),e.length===0&&r.jsx("div",{className:"p-8 text-center text-neutral-500 text-xs font-mono",children:"No scenarios saved."})]})]})]})}const Ht={name:"New Attack Plan",description:"Describe your attack sequence...",steps:[{id:"step-1",action:"chaos.cpu",params:{duration:5e3},delayMs:1e3},{id:"step-2",action:"cluster.attack",params:{target:"http://example.com",rate:50},delayMs:0}]},ju="application/apparatus-scenario-action",z_=1500,F_={running:{borderColor:"rgba(56, 189, 248, 0.95)",boxShadow:"0 0 0 2px rgba(56, 189, 248, 0.6), 0 0 28px rgba(56, 189, 248, 0.35)"},completed:{borderColor:"rgba(34, 197, 94, 0.95)",boxShadow:"0 0 0 2px rgba(34, 197, 94, 0.6), 0 0 28px rgba(34, 197, 94, 0.35)"},failed:{borderColor:"rgba(244, 63, 94, 0.95)",boxShadow:"0 0 0 2px rgba(244, 63, 94, 0.6), 0 0 28px rgba(244, 63, 94, 0.35)"}};function B_(){const{scenarios:e,saveScenario:t,runScenario:n,getScenarioRunStatus:s,isLoading:a}=E_(),o=h.useMemo(()=>No(Ht),[]),i=h.useMemo(()=>wo({name:Ht.name,description:Ht.description,nodes:o.nodes,edges:o.edges}),[o.edges,o.nodes]),[l,u,c]=t_(o.nodes),[d,f,p]=n_(o.edges),[x,g]=h.useState(null),[m,y]=h.useState(Ht.name),[b,v]=h.useState(Ht.description??""),[N,w]=h.useState(null),[j,k]=h.useState(null),[_,P]=h.useState(null),[T,$]=h.useState(null),[B,D]=h.useState(null),[R,S]=h.useState(()=>ks(i,o.edges)),C=h.useMemo(()=>wo({id:x??void 0,name:m,description:b,nodes:l,edges:d}),[d,l,b,m,x]),A=h.useMemo(()=>ks(C,d),[d,C])!==R,O=h.useMemo(()=>JSON.stringify(C,null,2),[C]),I=h.useMemo(()=>l.filter(U=>U.selected),[l]),F=I.length===1?I[0]:null,L=I.length>1,M=(F==null?void 0:F.id)??null,z=F==null?void 0:F.data,H=h.useMemo(()=>z?um(z.action,z.params,z.delayMs):[],[z]),V=h.useMemo(()=>{if(!(T!=null&&T.currentStepId))return l;const U=F_[T.status];return l.map(K=>K.id!==T.currentStepId?K:{...K,style:{...K.style,...U}})},[l,T]),Z=h.useMemo(()=>A_(l,d),[d,l]),G=h.useMemo(()=>I_(l),[l]),J=h.useMemo(()=>{const U=[];return m.trim()||U.push("Scenario name is required."),l.length===0&&U.push("Add at least one tool block to the canvas."),U.push(...Z),U.push(...G),U},[Z,l,G,m]),ee=h.useCallback(()=>A?window.confirm("Discard unsaved scenario builder changes?"):!0,[A]),te=h.useCallback(U=>{g(U.selectedId),y(U.payload.name),v(U.payload.description??""),u(U.nodes),f(U.edges),S(ks(U.payload,U.edges)),P(null),$(null),w(null),k(null)},[f,u]),oe=h.useCallback((U,K)=>{u(ne=>[...ne,L_(U,K??T_(ne.length))])},[u]),ie=h.useCallback(()=>{if(!ee())return;const U=No(Ht),K=wo({name:Ht.name,description:Ht.description,nodes:U.nodes,edges:U.edges});te({selectedId:null,payload:K,nodes:U.nodes,edges:U.edges})},[te,ee]),me=h.useCallback(async()=>{if(w(null),k(null),J.length>0){w(J[0]);return}try{const U=await t(C),K=(U==null?void 0:U.id)??C.id;K&&g(K),S(ks({...C,id:K},d)),k("Scenario saved successfully.")}catch(U){console.error(U),w("Failed to save scenario.")}},[d,C,t,b,m,J]),W=h.useCallback(async U=>{var K;w(null),k(null);try{const ne=await n(U),pe=((K=e.find(Ee=>Ee.id===U))==null?void 0:K.name)??m;P(U),$({executionId:ne.executionId,scenarioId:U,scenarioName:pe,status:"running",startedAt:new Date().toISOString()}),k(`Scenario started (${ne.executionId}). Tracking execution graph.`)}catch(ne){console.error(ne),w("Failed to start scenario.")}},[n,m,e]),fe=h.useCallback(()=>{if(!x){w("Save and select a scenario from the library before running.");return}W(x)},[W,x]),Ae=h.useCallback(U=>{var K;if(ee())try{const ne={id:U.id,name:U.name.trim(),description:((K=U.description)==null?void 0:K.trim())||void 0,steps:U.steps},pe=No(ne);te({selectedId:U.id,payload:ne,nodes:pe.nodes,edges:pe.edges})}catch(ne){console.error(ne),w("Failed to load scenario graph. The saved payload may be malformed.")}},[te,ee]),ge=h.useCallback(U=>{f(K=>bp({...U,animated:!0,style:{stroke:"rgba(56, 189, 248, 0.75)",strokeWidth:1.5}},K))},[f]),Y=h.useCallback(U=>{M&&u(K=>K.map(ne=>ne.id!==M?ne:U(ne)))},[M,u]),Pe=h.useCallback(U=>{Y(K=>{const ne=im(U);return{...K,data:{...ne,delayMs:K.data.delayMs??ne.delayMs}}})},[Y]),Te=h.useCallback(U=>{Y(K=>({...K,data:{...K.data,delayMs:Number.isFinite(U)?Math.max(0,Math.trunc(U)):0}}))},[Y]),be=h.useCallback((U,K)=>{Y(ne=>{const pe={...ne.data.params};if(U==="prefix"&&typeof K=="string"&&K.trim().length===0)delete pe.prefix;else{const Ee=typeof K=="number"&&Number.isFinite(K)?Math.trunc(K):K;pe[U]=Ee}return{...ne,data:{...ne.data,params:pe}}})},[Y]),Xe=h.useCallback(U=>{Y(K=>({...K,data:{...K.data,params:U==="clear"?{action:"clear"}:{action:"allocate",amount:typeof K.data.params.amount=="number"?K.data.params.amount:100}}}))},[Y]),He=h.useCallback((U,K)=>{U.dataTransfer.setData(ju,K),U.dataTransfer.effectAllowed="move"},[]),Ve=h.useCallback(U=>{U.preventDefault(),U.dataTransfer.dropEffect="move"},[]),tt=h.useCallback(U=>{U.preventDefault();const K=U.dataTransfer.getData(ju);if(!om(K)||!B)return;const ne=B.screenToFlowPosition({x:U.clientX,y:U.clientY});oe(K,ne)},[oe,B]);return h.useEffect(()=>{if(!_||!T||T.status!=="running")return;const{executionId:U}=T;let K=!1;const ne=async()=>{try{const Ee=await s(_,U);K||$(Ee)}catch(Ee){if(console.error(Ee),K)return;$(_e=>_e&&{..._e,status:"failed",error:"Status polling failed before execution reached a terminal state."})}};ne();const pe=window.setInterval(()=>{ne()},z_);return()=>{K=!0,window.clearInterval(pe)}},[_,T==null?void 0:T.executionId,T==null?void 0:T.status,s]),h.useEffect(()=>{if(!(!T||T.status==="running")){if(T.status==="completed"){k(`Scenario completed (${T.executionId})${T.currentStepId?` at ${T.currentStepId}`:""}.`);return}w(T.error?`Scenario failed (${T.executionId}): ${T.error}`:`Scenario failed (${T.executionId}).`)}},[T]),r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500 h-[calc(100vh-140px)] flex flex-col",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Scenario Engine"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Visual Attack/Chaos Architect for drag-and-drop scenario design."}),N&&r.jsx("div",{role:"alert","aria-live":"assertive",className:"mt-2 text-danger-400 text-xs font-mono bg-danger-900/20 p-2 rounded border border-danger-900/50",children:N}),j&&r.jsx("div",{role:"alert","aria-live":"polite",className:"mt-2 text-success-400 text-xs font-mono bg-success-900/20 p-2 rounded border border-success-900/50",children:j})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Q,{size:"sm",variant:"ghost",onClick:ie,children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),"New"]}),r.jsxs(Q,{size:"sm",variant:"primary",onClick:()=>void me(),disabled:a,children:[r.jsx(hd,{className:"h-4 w-4 mr-2"}),"Save"]}),r.jsxs(Q,{size:"sm",variant:"secondary",onClick:fe,disabled:!x,children:[r.jsx(Ke,{className:"h-4 w-4 mr-2"}),"Run Selected"]})]}),!x&&r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Save and select a scenario from the library to enable running."}),A&&r.jsx("div",{className:"text-[11px] text-warning-400 font-mono",children:"Unsaved changes in builder."}),T&&r.jsxs("div",{role:T.status==="failed"?"alert":"status","aria-live":T.status==="running"?"polite":"assertive",className:T.status==="failed"?"text-[11px] text-danger-300 font-mono bg-danger-900/20 p-2 rounded border border-danger-900/50":T.status==="completed"?"text-[11px] text-success-300 font-mono bg-success-900/20 p-2 rounded border border-success-900/50":"text-[11px] text-primary-300 font-mono bg-primary-900/20 p-2 rounded border border-primary-900/50",children:[r.jsxs("div",{children:["Execution `",T.executionId,"` for ",T.scenarioName,": ",T.status]}),T.currentStepId&&r.jsxs("div",{children:["Current step: ",T.currentStepId]}),T.error&&r.jsxs("div",{children:["Error: ",T.error]})]}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-6 flex-1 min-h-0",children:[r.jsx($_,{scenarios:e,selectedId:x,onSelectScenario:Ae,onRunScenario:W,onAddNode:oe,onPaletteDragStart:He}),r.jsx(C_,{nodes:V,edges:d,onNodesChange:c,onEdgesChange:p,onConnect:ge,onDrop:tt,onDragOver:Ve,onInit:D,hasValidationErrors:Z.length>0}),r.jsx(D_,{scenarioName:m,scenarioDescription:b,validationErrors:J,jsonPreview:O,selectedNode:F,hasMultiSelection:L,selectedNodeErrors:H,onScenarioNameChange:y,onScenarioDescriptionChange:v,onSelectedActionChange:Pe,onSelectedDelayMsChange:Te,onSelectedParamChange:be,onSelectedMemoryModeChange:Xe})]})]})}function H_(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState(null),[o,i]=h.useState(null),[l,u]=h.useState(!1),[c,d]=h.useState(null),f=h.useRef(null),p=h.useCallback(()=>{f.current&&(clearInterval(f.current),f.current=null)},[]),x=h.useCallback(async()=>{if(e)try{const j=await fetch(`${e}/drills`);if(!j.ok)throw new Error(`Failed to fetch drills: ${j.status}`);const k=await j.json();n(k)}catch(j){const k=j instanceof Error?j.message:String(j);d(k)}},[e]),g=h.useCallback(async(j,k)=>{if(!e)return null;const _=await fetch(`${e}/drills/${encodeURIComponent(j)}/status?runId=${encodeURIComponent(k)}`);if(!_.ok)throw new Error(`Failed to fetch drill status: ${_.status}`);const P=await _.json();return a(P),P},[e]),m=h.useCallback(async(j,k)=>{if(!e)return null;const _=await fetch(`${e}/drills/${encodeURIComponent(j)}/debrief?runId=${encodeURIComponent(k)}`);if(!_.ok)throw new Error(`Failed to fetch debrief: ${_.status}`);const P=await _.json();return i(P),P},[e]),y=h.useCallback((j,k)=>{p(),f.current=setInterval(async()=>{try{const _=await g(j,k);if(!_)return;(_.status==="won"||_.status==="failed"||_.status==="cancelled")&&(p(),await m(j,k))}catch(_){p();const P=_ instanceof Error?_.message:String(_);d(P)}},1e3)},[p,m,g]),b=h.useCallback(async j=>{if(e){d(null),i(null),u(!0);try{const k=await fetch(`${e}/drills/${encodeURIComponent(j)}/run`,{method:"POST"});if(!k.ok)throw new Error(`Failed to start drill: ${k.status}`);const _=await k.json();await g(j,_.runId)&&y(j,_.runId)}catch(k){const _=k instanceof Error?k.message:String(k);d(_)}finally{u(!1)}}},[e,g,y]),v=h.useCallback(async()=>{if(!(!e||!s))try{const j=await fetch(`${e}/drills/${encodeURIComponent(s.drillId)}/mark-detected`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runId:s.runId})});if(!j.ok)throw new Error(`Failed to mark detection: ${j.status}`);await g(s.drillId,s.runId)}catch(j){const k=j instanceof Error?j.message:String(j);d(k)}},[s,e,g]),N=h.useCallback(async()=>{if(!(!e||!s))try{const j=await fetch(`${e}/drills/${encodeURIComponent(s.drillId)}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({runId:s.runId})});if(!j.ok)throw new Error(`Failed to cancel drill: ${j.status}`);p();const k=await g(s.drillId,s.runId);k&&await m(k.drillId,k.runId)}catch(j){const k=j instanceof Error?j.message:String(j);d(k)}},[s,e,p,m,g]);h.useEffect(()=>(x(),()=>p()),[p,x]);const w=h.useMemo(()=>s&&t.find(j=>j.id===s.drillId)||null,[s,t]);return{drills:t,activeRun:s,activeDrill:w,debrief:o,isLoading:l,error:c,fetchDrills:x,fetchDebrief:m,startDrill:b,markDetected:v,cancelRun:N}}function U_(e){switch(e){case"won":return"success";case"failed":return"danger";case"cancelled":return"warning";case"active":case"stabilizing":case"arming":return"primary";default:return"neutral"}}function V_(){var d,f;const{drills:e,activeRun:t,activeDrill:n,debrief:s,isLoading:a,error:o,startDrill:i,markDetected:l,cancelRun:u}=H_(),c=t?t.status==="won"||t.status==="failed"||t.status==="cancelled":!1;return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl text-neutral-100 type-heading flex items-center gap-2 ml-2",children:[r.jsx(Fe,{className:"h-5 w-5 text-danger-400"}),"Breach Protocol"]}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Run timed incident drills and practice response under pressure."})]}),t&&r.jsx(ue,{variant:U_(t.status),children:t.status})]}),o&&r.jsx("div",{className:"rounded border border-danger-900/60 bg-danger-950/20 px-3 py-2 text-xs text-danger-300 font-mono",children:o}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[r.jsxs(se,{variant:"panel",className:"lg:col-span-1",children:[r.jsxs(ce,{children:[r.jsx(de,{className:"text-sm font-mono",children:"Lobby"}),r.jsx(Re,{children:"Select and start a drill scenario"})]}),r.jsxs(ae,{className:"space-y-3",children:[e.length===0&&r.jsx("div",{className:"text-xs text-neutral-500 font-mono",children:"No drills available."}),e.map(p=>{const x=(t==null?void 0:t.drillId)===p.id;return r.jsxs("div",{className:X("rounded border px-3 py-3 transition-colors",x?"border-primary-500/60 bg-primary-500/10":"border-neutral-800 bg-neutral-900/30"),children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("div",{className:"text-sm text-neutral-100 font-semibold",children:p.name}),r.jsx(ue,{variant:"neutral",children:p.difficulty})]}),r.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:p.description}),r.jsxs(Q,{variant:"primary",size:"sm",className:"mt-3 w-full",disabled:a||!!t&&!c,onClick:()=>i(p.id),children:[r.jsx(Fe,{className:"h-4 w-4"}),"Start Shift"]})]},p.id)})]})]}),r.jsxs(se,{variant:"glass",glow:"danger",className:"lg:col-span-2",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center justify-between gap-2",children:[r.jsx("span",{className:"font-mono text-sm",children:"Incident Console"}),t?r.jsxs("span",{className:"text-xs font-mono text-neutral-400 flex items-center gap-1",children:[r.jsx(Ag,{className:"h-3.5 w-3.5"}),t.elapsedSec,"s"]}):null]}),r.jsx(Re,{children:n?n.briefing:"Start a drill to begin incident response simulation."})]}),r.jsxs(ae,{className:"space-y-4",children:[!t&&r.jsx("div",{className:"rounded border border-neutral-800 bg-neutral-900/40 p-4 text-sm text-neutral-400",children:"No active run."}),t&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-3",children:[r.jsxs("div",{className:"rounded border border-neutral-800 bg-neutral-900/40 p-3",children:[r.jsx("div",{className:"text-[11px] tracking-wide text-neutral-500",children:"CPU"}),r.jsx("div",{className:"mt-1 text-lg font-mono text-neutral-200",children:t.lastSnapshot?`${t.lastSnapshot.cpuPercent.toFixed(2)}%`:"—"})]}),r.jsxs("div",{className:"rounded border border-neutral-800 bg-neutral-900/40 p-3",children:[r.jsx("div",{className:"text-[11px] tracking-wide text-neutral-500",children:"Error Rate"}),r.jsx("div",{className:"mt-1 text-lg font-mono text-neutral-200",children:t.lastSnapshot?`${(t.lastSnapshot.errorRate*100).toFixed(2)}%`:"—"})]}),r.jsxs("div",{className:"rounded border border-neutral-800 bg-neutral-900/40 p-3",children:[r.jsx("div",{className:"text-[11px] tracking-wide text-neutral-500",children:"Blocked SQLi"}),r.jsx("div",{className:"mt-1 text-lg font-mono text-neutral-200",children:t.lastSnapshot?`${(t.lastSnapshot.blockedSqliRatio*100).toFixed(2)}%`:"—"})]})]}),r.jsxs("div",{className:"flex flex-wrap gap-2 text-[11px] font-mono tracking-wide text-neutral-400",children:[r.jsxs("span",{className:"rounded border border-neutral-800 bg-neutral-900/40 px-2 py-1",children:["Ghost: ",(d=t.lastSnapshot)!=null&&d.ghostTrafficActive?"Active":"Idle"]}),r.jsxs("span",{className:"rounded border border-neutral-800 bg-neutral-900/40 px-2 py-1",children:["Cluster Attack: ",(f=t.lastSnapshot)!=null&&f.clusterAttackActive?"Active":"Idle"]})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsxs(Q,{size:"sm",variant:"secondary",onClick:l,disabled:c||!!t.detectedAt,children:[r.jsx(sd,{className:"h-4 w-4"}),t.detectedAt?"Detection Marked":"Mark Detected"]}),r.jsxs(Q,{size:"sm",variant:"danger",onClick:u,disabled:c,children:[r.jsx(pd,{className:"h-4 w-4"}),"Cancel Run"]})]}),r.jsxs("div",{className:"rounded border border-neutral-800 bg-black/30",children:[r.jsx("div",{className:"border-b border-neutral-800 px-3 py-2 text-[11px] uppercase tracking-wide text-neutral-500 font-mono",children:"Timeline"}),r.jsxs("div",{className:"max-h-64 overflow-y-auto px-3 py-2 space-y-2",children:[t.timeline.length===0&&r.jsx("div",{className:"text-xs text-neutral-500 font-mono",children:"No timeline events yet."}),[...t.timeline].reverse().map((p,x)=>r.jsxs("div",{className:"text-xs font-mono text-neutral-300",children:[r.jsxs("span",{className:"text-neutral-500",children:["[",new Date(p.at).toLocaleTimeString(),"]"]})," ",r.jsx("span",{className:"text-primary-300",children:p.type})," ",p.message]},`${p.at}-${x}`))]})]}),s&&r.jsxs("div",{className:"rounded border border-primary-700/40 bg-primary-950/20 p-3",children:[r.jsxs("div",{className:"text-xs font-mono uppercase tracking-wide text-primary-300 flex items-center gap-1",children:[r.jsx(Zt,{className:"h-3.5 w-3.5"}),"Debrief"]}),r.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-2 text-xs font-mono",children:[r.jsxs("div",{className:"text-neutral-300",children:["Score: ",r.jsx("span",{className:"text-primary-300",children:s.score.total})]}),r.jsxs("div",{className:"text-neutral-300",children:["TTD: ",r.jsxs("span",{className:"text-neutral-100",children:[s.score.ttdSec,"s"]})]}),r.jsxs("div",{className:"text-neutral-300",children:["TTM: ",r.jsxs("span",{className:"text-neutral-100",children:[s.score.ttmSec,"s"]})]}),r.jsxs("div",{className:"text-neutral-300",children:["TTR: ",r.jsxs("span",{className:"text-neutral-100",children:[s.score.ttrSec,"s"]})]})]})]})]})]})]})]})]})}function q_(){const{baseUrl:e}=je(),[t,n]=h.useState(null),[s,a]=h.useState(!1),o=h.useCallback(async()=>{if(e)try{const u=await fetch(`${e}/api/simulator/dependencies`);if(u.ok){const c=await u.json();n(c)}}catch(u){console.error(u)}},[e]),i=h.useCallback(async u=>{if(e){a(!0);try{await fetch(`${e}/api/simulator/dependencies/infect`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:u})}),await o()}catch(c){console.error(c)}finally{a(!1)}}},[e,o]),l=h.useCallback(async()=>{if(e){a(!0);try{await fetch(`${e}/api/simulator/dependencies/reset`,{method:"POST"}),await o()}catch(u){console.error(u)}finally{a(!1)}}},[e,o]);return h.useEffect(()=>{o()},[o]),{graph:t,injectMalware:i,resetGraph:l,isLoading:s}}const Rt={NODE_RADIUS:5,APP_RADIUS:10,REPULSION:100,SPRING_LENGTH:50,SPRING_STRENGTH:.05,DAMPING:.9};function W_({nodes:e,onNodeClick:t}){const n=h.useRef(null),s=h.useRef([]),a=h.useRef(e),o=h.useRef({x:0,y:0,clicked:!1});return h.useEffect(()=>{const i=e.map(l=>{const u=s.current.find(c=>c.id===l.id);return{...l,x:(u==null?void 0:u.x)||Math.random()*800,y:(u==null?void 0:u.y)||Math.random()*600,vx:(u==null?void 0:u.vx)||0,vy:(u==null?void 0:u.vy)||0}});s.current=i,a.current=e},[e]),h.useEffect(()=>{const i=n.current;if(!i)return;const l=i.getContext("2d");if(!l)return;const u=window.devicePixelRatio||1,c=()=>{if(i.parentElement){const g=i.parentElement.clientWidth,m=i.parentElement.clientHeight;i.style.width=`${g}px`,i.style.height=`${m}px`,i.width=g*u,i.height=m*u,l.setTransform(u,0,0,u,0,0)}};window.addEventListener("resize",c),c();const d=g=>{const m=i.getBoundingClientRect();o.current.x=g.clientX-m.left,o.current.y=g.clientY-m.top},f=()=>{const g=o.current.x,m=o.current.y,y=s.current.find(b=>{const v=b.x-g,N=b.y-m;return Math.sqrt(v*v+N*N)<(b.type==="app"?Rt.APP_RADIUS:Rt.NODE_RADIUS)+5});y&&t(a.current.find(b=>b.id===y.id))};i.addEventListener("mousemove",d),i.addEventListener("click",f);let p;const x=()=>{if(document.hidden){p=requestAnimationFrame(x);return}if(!i.parentElement)return;const g=i.parentElement.clientWidth,m=i.parentElement.clientHeight,y=s.current;for(let b=0;b<y.length;b++)for(let v=b+1;v<y.length;v++){const N=y[b],w=y[v],j=N.x-w.x,k=N.y-w.y,_=Math.sqrt(j*j+k*k)||1;if(_<200){const P=Rt.REPULSION/(_*_),T=j/_*P,$=k/_*P;N.vx+=T,N.vy+=$,w.vx-=T,w.vy-=$}}y.forEach(b=>{b.dependencies.forEach(v=>{const N=y.find(w=>w.id===v);if(N){const w=N.x-b.x,j=N.y-b.y,k=Math.sqrt(w*w+j*j)||1,_=(k-Rt.SPRING_LENGTH)*Rt.SPRING_STRENGTH,P=w/k*_,T=j/k*_;b.vx+=P,b.vy+=T,N.vx-=P,N.vy-=T}})}),y.forEach(b=>{b.vx+=(g/2-b.x)*5e-4,b.vy+=(m/2-b.y)*5e-4,b.vx*=Rt.DAMPING,b.vy*=Rt.DAMPING,b.x+=b.vx,b.y+=b.vy}),l.clearRect(0,0,g,m),l.lineWidth=1,y.forEach(b=>{b.dependencies.forEach(v=>{const N=y.find(w=>w.id===v);if(N){l.beginPath(),l.moveTo(b.x,b.y),l.lineTo(N.x,N.y);const w=N.status!=="clean";l.strokeStyle=w?"#FF0055":"#323C4D",l.globalAlpha=w?.8:.3,l.stroke(),l.globalAlpha=1}})}),y.forEach(b=>{const v=b.type==="app"?Rt.APP_RADIUS:Rt.NODE_RADIUS;l.beginPath(),l.arc(b.x,b.y,v,0,Math.PI*2),b.status==="clean"?l.fillStyle="#4D5B70":b.status==="infected"?l.fillStyle="#FF0055":l.fillStyle="#FFB800",b.type==="app"?(l.shadowBlur=15,l.shadowColor=l.fillStyle,b.status!=="clean"?l.fillStyle="#FF0055":l.fillStyle="#00F0FF"):l.shadowBlur=0,l.fill(),l.shadowBlur=0;const N=o.current.x-b.x,w=o.current.y-b.y;(Math.sqrt(N*N+w*w)<v+10||b.status!=="clean"||b.type==="app")&&(l.font="10px JetBrains Mono",l.fillStyle="#FFFFFF",l.fillText(b.name,b.x+8,b.y+3))}),p=requestAnimationFrame(x)};return x(),()=>{window.removeEventListener("resize",c),i.removeEventListener("mousemove",d),i.removeEventListener("click",f),cancelAnimationFrame(p)}},[]),r.jsx("canvas",{ref:n,className:"w-full h-full block cursor-crosshair",role:"img","aria-label":"Dependency graph visualization"})}function G_(){var d;const{graph:e,injectMalware:t,resetGraph:n,isLoading:s}=q_();if(!e)return r.jsx("div",{className:"p-8 text-center text-neutral-500",children:"Loading Graph..."});const a=Object.values(e.nodes),o=a.length,i=a.filter(f=>f.status==="infected").length,l=a.filter(f=>f.status==="compromised").length,u=o-i-l,c=((d=e.nodes["app-root"])==null?void 0:d.status)||"clean";return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500 h-[calc(100vh-140px)] flex flex-col",children:[r.jsxs("div",{className:"flex justify-between items-end",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Supply Chain Radar"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2 type-body",children:"Software Bill of Materials (SBOM) Infection Simulator."})]}),r.jsxs("div",{className:"flex gap-4",children:[r.jsxs("div",{className:"flex flex-col items-end",children:[r.jsx("span",{className:"text-[10px] type-tag text-neutral-500 uppercase",children:"Health"}),r.jsxs("span",{className:"text-xl type-metric text-neutral-300",children:[Math.round(u/o*100),"%"]})]}),r.jsx("div",{className:"h-8 w-px bg-neutral-800"}),r.jsxs("div",{className:"flex flex-col items-end",children:[r.jsx("span",{className:"text-[10px] type-tag text-neutral-500 uppercase",children:"App Status"}),r.jsx(ue,{variant:c==="clean"?"success":"danger",dot:!0,children:c.toUpperCase()})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 flex-1 min-h-0",children:[r.jsx("div",{className:"lg:col-span-3",children:r.jsxs(se,{variant:"panel",className:"h-full flex flex-col relative overflow-hidden",children:[r.jsx("div",{className:"absolute top-4 right-4 z-10",children:r.jsxs(Q,{size:"sm",variant:"secondary",onClick:n,disabled:s,children:[r.jsx(va,{className:"h-3 w-3 mr-2"}),"Reset Simulation"]})}),r.jsxs("div",{className:"absolute bottom-4 left-4 z-10 bg-black/60 p-2 rounded text-[10px] font-mono text-neutral-400 border border-white/5",children:[r.jsx("div",{children:"Right-click a node to simulate malware injection."}),r.jsxs("div",{className:"flex gap-2 mt-1",children:[r.jsx("span",{className:"text-neutral-500",children:"● Clean"}),r.jsx("span",{className:"text-danger-500",children:"● Infected (Patient 0)"}),r.jsx("span",{className:"text-warning-500",children:"● Compromised (Upstream)"})]})]}),r.jsx("div",{className:"flex-1 bg-neutral-950",children:r.jsx(W_,{nodes:a,onNodeClick:f=>{confirm(`Inject malware into package '${f.name}'?`)&&t(f.id)}})})]})}),r.jsxs(se,{variant:"glass",glow:"danger",className:"h-full flex flex-col",children:[r.jsx(ce,{className:"flex-none border-b border-white/5 pb-3",children:r.jsx(de,{className:"text-sm font-mono uppercase",children:"Impact Analysis"})}),r.jsx(ae,{className:"flex-1 overflow-y-auto p-0",children:r.jsxs("div",{className:"p-4 space-y-4",children:[r.jsxs("div",{className:"bg-danger-900/20 border border-danger-900/50 p-3 rounded-sm",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2 text-danger-400 font-mono text-xs font-bold",children:[r.jsx(Zt,{className:"h-3 w-3"}),"BLAST RADIUS"]}),r.jsx("div",{className:"text-2xl type-metric text-white",children:l+i}),r.jsx("div",{className:"text-[10px] text-neutral-400",children:"Total Affected Packages"})]}),i>0&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-mono text-neutral-500 uppercase block mb-2",children:"Vectors (Patient Zero)"}),r.jsx("div",{className:"space-y-1",children:a.filter(f=>f.status==="infected").map(f=>r.jsxs("div",{className:"text-xs font-mono text-danger-400 bg-danger-900/10 px-2 py-1 rounded",children:[f.name," v",f.version]},f.id))})]}),l>0&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-mono text-neutral-500 uppercase block mb-2",children:"Compromised Upstream"}),r.jsx("div",{className:"space-y-1",children:a.filter(f=>f.status==="compromised").map(f=>r.jsx("div",{className:"text-xs font-mono text-warning-400",children:f.name},f.id))})]}),l===0&&i===0&&r.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-neutral-600",children:[r.jsx(Jt,{className:"h-12 w-12 mb-2 opacity-20"}),r.jsx("span",{className:"text-xs font-mono",children:"Supply Chain Secure"})]})]})})]})]})]})}function hm(){const{baseUrl:e}=je(),[t,n]=h.useState(null),[s,a]=h.useState(null),[o,i]=h.useState(!1),[l,u]=h.useState(!1),[c,d]=h.useState(null),[f,p]=h.useState(null),x=h.useRef(null),g=h.useCallback(async()=>{var w;if(!e)return;const N=new URL("/api/redteam/autopilot/status",e);x.current&&N.searchParams.set("sessionId",x.current);try{const j=await fetch(N.toString());if(!j.ok)throw new Error(`Status failed (${j.status})`);const k=await j.json();n(k.session),a(k.latestReport),i(!!k.active),(w=k.session)!=null&&w.id&&(x.current=k.session.id)}catch(j){d(j instanceof Error?j.message:String(j))}},[e]),m=h.useCallback(async()=>{if(e)try{const N=await fetch(`${e}/api/redteam/autopilot/config`);if(!N.ok)throw new Error(`Config failed (${N.status})`);const w=await N.json();p(w)}catch(N){d(N instanceof Error?N.message:String(N))}},[e]),y=h.useCallback(async N=>{if(e){d(null),u(!0);try{const w=await fetch(`${e}/api/redteam/autopilot/start`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!w.ok){const k=await w.json().catch(()=>({}));throw new Error(k.error||`Start failed (${w.status})`)}const j=await w.json();x.current=j.sessionId,n(j.session),i(!0),await g()}catch(w){d(w instanceof Error?w.message:String(w))}finally{u(!1)}}},[e,g]),b=h.useCallback(async()=>{if(e){d(null),u(!0);try{const N=await fetch(`${e}/api/redteam/autopilot/stop`,{method:"POST"});if(!N.ok){const w=await N.json().catch(()=>({}));throw new Error(w.error||`Stop failed (${N.status})`)}await g()}catch(N){d(N instanceof Error?N.message:String(N))}finally{u(!1)}}},[e,g]),v=h.useCallback(async()=>{if(e){d(null),u(!0);try{const N=await fetch(`${e}/api/redteam/autopilot/kill`,{method:"POST"});if(!N.ok){const w=await N.json().catch(()=>({}));throw new Error(w.error||`Kill failed (${N.status})`)}await g()}catch(N){d(N instanceof Error?N.message:String(N))}finally{u(!1)}}},[e,g]);return h.useEffect(()=>{if(g(),m(),!e)return;const N=setInterval(()=>{g()},1500);return()=>clearInterval(N)},[e,m,g]),{session:t,latestReport:s,active:o,isLoading:l,error:c,config:f,fetchStatus:g,fetchConfig:m,start:y,stop:b,kill:v}}const K_=14,Y_=16;function qn(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function X_(e){return e?e==="running"?"primary":e==="stopping"?"warning":e==="failed"?"danger":e==="completed"?"success":e==="stopped"?"warning":"neutral":"neutral"}function Z_(e,t){if(e.includes(t)){const n=e.filter(s=>s!==t);return n.length>0?n:e}return[...e,t]}function J_(e){return Math.max(1,Math.min(30,Number(e)||1))}function Q_(e){return Math.max(0,Math.min(3e4,Number(e)||0))}function eC(e,t){return e||!t.trim()}function tC(e){const t=(e==null?void 0:e.assets)||[],n=(e==null?void 0:e.relations)||[],s=e==null?void 0:e.objectiveProgress;return{acquiredAssets:[...t].sort((a,o)=>qn(o.lastSeenAt)-qn(a.lastSeenAt)).slice(0,K_),relationStrip:[...n].sort((a,o)=>qn(o.lastSeenAt)-qn(a.lastSeenAt)).slice(0,Y_),breakSignals:(s==null?void 0:s.breakSignals)||[],openedPaths:(s==null?void 0:s.openedPaths)||[],preconditions:(s==null?void 0:s.preconditionsMet)||[]}}function ku(e){const t=e.trim();if(!t.startsWith("defense-signal:"))return null;const n=t.slice(15).trim();return n||null}function nC(e){const t=e.breakSignals||[],n=e.actions||[],s=t.map(ku).filter(u=>!!u).length,a=Array.from(new Set(t.map(ku).filter(u=>!!u))),o=[...n].filter(u=>!!u.maneuver).map(u=>{var c,d,f;return{countermeasure:typeof((c=u.maneuver)==null?void 0:c.countermeasure)=="string"&&u.maneuver.countermeasure.trim()?u.maneuver.countermeasure.trim():null,id:u.id,at:u.at,ok:u.ok,tool:u.tool,triggerSignal:((d=u.maneuver)==null?void 0:d.triggerSignal)||"unknown",rationale:((f=u.maneuver)==null?void 0:f.rationale)||"No rationale provided."}}).sort((u,c)=>qn(c.at)-qn(u.at)),i=o.filter(u=>u.countermeasure!==null&&u.ok).length,l=o.filter(u=>u.countermeasure===null||!u.ok).length;return{blockedSignals:a,blockedSignalEvents:s,evasionManeuvers:o,successfulEvasions:i,stalledEvasions:l}}function rC(e){if(!e)return"n/a";const t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleTimeString():"n/a"}function Eu(e){const t=e.replace(/^asset:/,"");return t.length<=52?t:`${t.slice(0,49)}...`}const sC=[{id:"cluster.attack",label:"Cluster Attack"},{id:"chaos.cpu",label:"CPU Chaos"},{id:"chaos.memory",label:"Memory Chaos"},{id:"mtd.rotate",label:"MTD Rotate"},{id:"delay",label:"Delay"},{id:"chaos.crash",label:"Crash Process"}],aC=[{id:"script_kiddie",label:"Script Kiddie",description:"Noisy and fast with low stealth discipline.",tags:["LOW_STEALTH","HIGH_NOISE","FAST_LOOP"]},{id:"researcher",label:"Researcher",description:"Methodical and evidence-first with lower impact pacing.",tags:["METHODICAL","LOW_IMPACT","EVIDENCE_FIRST"]},{id:"apt",label:"APT",description:"Stealth-oriented and adaptive with evasive posture.",tags:["HIGH_STEALTH","ADAPTIVE","PERSISTENT"]}],oC={analyze:"ANALYZE",decide:"DECIDE",act:"ACT",verify:"VERIFY",report:"REPORT",system:"SYSTEM"};function iC(){var oe,ie,me;const{session:e,latestReport:t,active:n,isLoading:s,error:a,config:o,start:i,stop:l,kill:u}=hm(),[c,d]=h.useState("Find the breaking point of the /checkout API"),[f,p]=h.useState(12),[x,g]=h.useState(1500),[m,y]=h.useState("script_kiddie"),[b,v]=h.useState(!0),[N,w]=h.useState(["cluster.attack","chaos.cpu","chaos.memory","mtd.rotate","delay"]),j=h.useRef(null),k=h.useRef(null),[_,P]=h.useState(!0),[T,$]=h.useState(!0),B=h.useMemo(()=>b?N.filter(W=>W!=="chaos.crash"):N,[N,b]),D=h.useMemo(()=>{var W;return(W=o==null?void 0:o.personas)!=null&&W.length?o.personas:[...aC]},[o==null?void 0:o.personas]),R=h.useMemo(()=>D.some(W=>W.id===m),[D,m]),S=h.useMemo(()=>R?D.find(W=>W.id===m):D[0],[R,D,m]),C=(e==null?void 0:e.thoughts)||[],E=(e==null?void 0:e.actions)||[],A=e==null?void 0:e.sessionContext,{acquiredAssets:O,relationStrip:I,breakSignals:F,openedPaths:L,preconditions:M}=h.useMemo(()=>tC(A),[A]),{blockedSignals:z,blockedSignalEvents:H,evasionManeuvers:V,successfulEvasions:Z,stalledEvasions:G}=h.useMemo(()=>nC({breakSignals:F,actions:E}),[E,F]);h.useEffect(()=>{if(!_)return;const W=j.current;W&&(W.scrollTop=W.scrollHeight)},[_,C.length]),h.useEffect(()=>{if(!T)return;const W=k.current;W&&(W.scrollTop=W.scrollHeight)},[T,E.length]),h.useEffect(()=>{var fe;const W=(o==null?void 0:o.defaultPersona)||((fe=D[0])==null?void 0:fe.id)||"script_kiddie";R||y(W)},[o==null?void 0:o.defaultPersona,R,D]);const J=h.useMemo(()=>{const W=(e==null?void 0:e.state)||"idle",fe=e?`${e.iteration}/${e.maxIterations}`:"0/0";return{status:W,step:fe}},[e]),ee=W=>{w(fe=>Z_(fe,W))},te=async()=>{await i({objective:c,maxIterations:f,intervalMs:x,persona:m,scope:{allowedTools:B,forbidCrash:b}})};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsxs("h1",{className:"text-2xl text-neutral-100 type-heading flex items-center gap-2 ml-2",children:[r.jsx(nd,{className:"h-6 w-6 text-primary-400"}),"Autopilot Console"]}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Autonomous red-team loop: analyze, decide, act, verify, report."})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ue,{variant:X_(J.status),dot:!0,children:J.status}),r.jsxs(ue,{variant:"neutral",children:["Iteration ",J.step]})]})]}),a&&r.jsx("div",{className:"text-danger-300 border border-danger-500/30 bg-danger-900/20 px-3 py-2 rounded-[3px] text-xs font-mono",children:a}),r.jsxs(se,{variant:"glass",glow:"danger",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Fe,{className:"h-4 w-4 text-primary-400"}),"Mission Control"]}),r.jsx(Re,{children:"Define objective, tool scope, and execution profile before engaging autopilot."})]}),r.jsxs(ae,{className:"space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:[r.jsxs("div",{className:"lg:col-span-3",children:[r.jsx("label",{className:"block text-[11px] font-mono text-neutral-500 mb-1",children:"Objective"}),r.jsx("input",{value:c,onChange:W=>d(W.target.value),className:"w-full h-10 bg-neutral-900/60 border border-neutral-800/70 rounded-[3px] px-3 text-sm text-neutral-100 focus:outline-none focus:border-primary-500/40",placeholder:"Find the breaking point of the /checkout API"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono text-neutral-500 mb-1",children:"Max Iterations"}),r.jsx("input",{type:"number",min:1,max:30,value:f,onChange:W=>p(J_(Number(W.target.value))),className:"w-full h-10 bg-neutral-900/60 border border-neutral-800/70 rounded-[3px] px-3 text-sm text-neutral-100 focus:outline-none focus:border-primary-500/40"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-[11px] font-mono text-neutral-500 mb-1",children:"Interval (ms)"}),r.jsx("input",{type:"number",min:0,max:3e4,value:x,onChange:W=>g(Q_(Number(W.target.value))),className:"w-full h-10 bg-neutral-900/60 border border-neutral-800/70 rounded-[3px] px-3 text-sm text-neutral-100 focus:outline-none focus:border-primary-500/40"})]}),r.jsxs("div",{children:[r.jsx("label",{htmlFor:"autopilot-persona",className:"block text-[11px] font-mono text-neutral-500 mb-1",children:"Persona"}),r.jsx("select",{id:"autopilot-persona",value:m,onChange:W=>y(W.target.value),className:"w-full h-10 bg-neutral-900/60 border border-neutral-800/70 rounded-[3px] px-3 text-sm text-neutral-100 focus:outline-none focus:border-primary-500/40",children:D.map(W=>r.jsx("option",{value:W.id,children:W.label},W.id))})]}),r.jsx("div",{className:"flex items-end",children:r.jsxs("label",{className:"flex items-center gap-2 h-10 px-3 border border-neutral-800/70 rounded-[3px] bg-neutral-900/60 w-full text-xs font-mono text-neutral-300",children:[r.jsx("input",{type:"checkbox",checked:b,onChange:W=>v(W.target.checked)}),"Forbid Crash Tool"]})})]}),r.jsxs("div",{className:"rounded-[3px] border border-neutral-800/70 bg-neutral-900/45 p-2.5",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-mono text-neutral-500",children:"Persona Profile"}),r.jsx("span",{className:"text-xs font-mono text-neutral-100",children:(S==null?void 0:S.label)||"Unknown"}),(oe=S==null?void 0:S.tags)==null?void 0:oe.map(W=>r.jsx(ue,{size:"sm",variant:"warning",children:W},W))]}),r.jsx("div",{className:"mt-1 text-[11px] text-neutral-400 font-mono",children:(S==null?void 0:S.description)||"No persona metadata available."})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] font-mono text-neutral-500 mb-2",children:"Scope Limits"}),r.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:sC.map(W=>{const fe=B.includes(W.id),Ae=b&&W.id==="chaos.crash";return r.jsxs("label",{className:X("flex items-center gap-2 h-9 px-2.5 rounded-[3px] border text-xs font-mono",fe?"bg-primary-500/10 border-primary-500/40 text-primary-200":"bg-neutral-900/50 border-neutral-800/70 text-neutral-400",Ae&&"opacity-50"),children:[r.jsx("input",{type:"checkbox",checked:fe&&!Ae,disabled:Ae,onChange:()=>ee(W.id)}),r.jsx("span",{children:W.label})]},W.id)})})]}),r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(Q,{variant:"neon",size:"lg",onClick:te,disabled:eC(n,c),isLoading:s&&!n,leftIcon:r.jsx(Ke,{className:"h-4 w-4"}),children:"Engage Autopilot"}),r.jsx(Q,{variant:"secondary",size:"lg",onClick:l,disabled:!n,isLoading:s&&n,leftIcon:r.jsx(fd,{className:"h-4 w-4"}),children:"Soft Stop"}),r.jsx(Q,{variant:"danger",size:"lg",onClick:u,leftIcon:r.jsx(xd,{className:"h-4 w-4"}),children:"Kill Switch"})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-4",children:[r.jsxs(se,{variant:"panel",glow:"primary",className:"xl:col-span-2",children:[r.jsxs(ce,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(dt,{className:"h-4 w-4 text-primary-400"}),"Live Thought Stream"]}),r.jsx(Q,{type:"button",size:"sm",variant:"secondary",onClick:()=>P(W=>!W),className:"h-7 px-2 text-[10px] font-mono uppercase tracking-wider","aria-pressed":_,children:_?r.jsxs(r.Fragment,{children:[r.jsx(Jn,{className:"mr-1 h-3 w-3"}),"Stop Auto-Scrolling"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ke,{className:"mr-1 h-3 w-3"}),"Resume Auto-Scrolling"]})})]}),r.jsx(Re,{children:"Internal reasoning trace from the autonomous loop."})]}),r.jsx(ae,{children:r.jsxs("div",{ref:j,className:"h-[320px] overflow-y-auto rounded-[3px] border border-neutral-800/60 bg-black/35 p-3 space-y-2",children:[C.length===0&&r.jsx("div",{className:"text-xs text-neutral-600 font-mono",children:"Awaiting mission activity..."}),C.map(W=>r.jsxs("div",{className:"text-xs font-mono text-neutral-300 leading-relaxed group",children:[r.jsxs("span",{className:"text-neutral-600",children:["[",new Date(W.at).toLocaleTimeString(),"]"]})," ",r.jsx("span",{className:"text-primary-400 font-bold",children:oC[W.phase]||W.phase.toUpperCase()})," ",r.jsx("span",{className:"rec-casual rec-slant text-neutral-200 group-hover:text-primary transition-colors",children:W.message})]},W.id))]})})]}),r.jsxs(se,{variant:"panel",glow:"primary",children:[r.jsxs(ce,{children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Hg,{className:"h-4 w-4 text-warning-400"}),"Action Log"]}),r.jsx(Q,{type:"button",size:"sm",variant:"secondary",onClick:()=>$(W=>!W),className:"h-7 px-2 text-[10px] font-mono uppercase tracking-wider","aria-pressed":T,children:T?r.jsxs(r.Fragment,{children:[r.jsx(Jn,{className:"mr-1 h-3 w-3"}),"Stop Auto-Scrolling"]}):r.jsxs(r.Fragment,{children:[r.jsx(Ke,{className:"mr-1 h-3 w-3"}),"Resume Auto-Scrolling"]})})]}),r.jsx(Re,{children:"Tools executed during this mission."})]}),r.jsx(ae,{children:r.jsxs("div",{ref:k,className:"h-[320px] overflow-y-auto space-y-2 pr-1",children:[E.length===0&&r.jsx("div",{className:"text-xs text-neutral-600 font-mono",children:"No tool executions yet."}),E.map(W=>r.jsxs("div",{className:"p-2 rounded-[3px] border border-neutral-800/70 bg-neutral-900/40",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsx("div",{className:"text-xs font-mono text-neutral-100",children:W.tool}),r.jsx(ue,{size:"sm",variant:W.ok?"success":"danger",children:W.ok?"ok":"error"})]}),r.jsx("div",{className:"mt-1 text-[11px] text-neutral-500 font-mono",children:W.message}),W.maneuver&&r.jsxs("div",{className:"mt-1 text-[11px] font-mono text-warning-300",children:["signal=",W.maneuver.triggerSignal," | counter=",W.maneuver.countermeasure]})]},W.id))]})})]})]}),r.jsxs(se,{variant:"glass",children:[r.jsxs(ce,{children:[r.jsx(de,{children:"Report Card"}),r.jsx(Re,{children:"Session summary and detected breaking conditions."})]}),r.jsxs(ae,{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Status"}),r.jsx("div",{className:"mt-1 text-lg font-display text-neutral-100",children:(e==null?void 0:e.state)||"idle"})]}),r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Breaking Point"}),r.jsx("div",{className:"mt-1 text-lg font-display text-neutral-100",children:(ie=e==null?void 0:e.summary)!=null&&ie.breakingPointRps?`${e.summary.breakingPointRps.toFixed(1)} RPS`:"Not found"})]}),r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Last Verification"}),r.jsx("div",{className:"mt-1 text-sm font-mono text-neutral-200",children:(t==null?void 0:t.verification.notes)||((me=e==null?void 0:e.summary)==null?void 0:me.failureReason)||"No verification events yet."})]})]})]}),r.jsxs(se,{variant:"glass",children:[r.jsxs(ce,{children:[r.jsx(de,{children:"Defense Telemetry"}),r.jsx(Re,{children:"Blocked-vs-evaded signal tracking for recent autopilot maneuvers."})]}),r.jsxs(ae,{className:"space-y-3",children:[r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3",children:[r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Blocked Events"}),r.jsx("div",{className:"mt-1 text-lg font-display text-danger-200",children:H})]}),r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Distinct Signals"}),r.jsx("div",{className:"mt-1 text-lg font-display text-neutral-100",children:z.length})]}),r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Successful Evasions"}),r.jsx("div",{className:"mt-1 text-lg font-display text-success-200",children:Z})]}),r.jsxs("div",{className:"p-3 rounded-[3px] border border-neutral-800/70 bg-neutral-900/50",children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Stalled Evasions"}),r.jsx("div",{className:"mt-1 text-lg font-display text-warning-200",children:G})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Detected Defense Signals"}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:z.length===0?r.jsx("span",{className:"text-[11px] text-neutral-600 font-mono",children:"none"}):z.slice(-8).map(W=>r.jsx(ue,{size:"sm",variant:"danger",children:W},W))})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Recent Evasion Maneuvers"}),r.jsx("div",{className:"mt-1 h-[170px] overflow-y-auto rounded-[3px] border border-neutral-800/60 bg-black/25 p-2 space-y-2",role:"log","aria-label":"Recent evasion maneuvers",tabIndex:0,children:s&&!e?r.jsx("div",{className:"text-xs text-neutral-600 font-mono",children:"Loading telemetry..."}):V.length===0?r.jsx("div",{className:"text-xs text-neutral-600 font-mono",children:e?"No evasion maneuvers recorded yet.":"Start a mission to stream telemetry."}):V.map(W=>r.jsxs("div",{className:"rounded-[3px] border border-neutral-800/70 bg-neutral-900/40 p-2",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"text-xs text-neutral-200 font-mono",children:[W.triggerSignal," ",r.jsx("span",{className:"text-neutral-500",children:"->"})," ",W.countermeasure||"none"]}),r.jsx(ue,{size:"sm",variant:W.ok?"success":"warning",children:W.ok?"evaded":"blocked"})]}),r.jsx("div",{className:"mt-1 text-xs text-neutral-500 font-mono",children:W.rationale})]},W.id))})]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-4",children:[r.jsxs(se,{variant:"panel",glow:"primary",className:"xl:col-span-2",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(Og,{className:"h-4 w-4 text-primary-400"}),"Acquired Assets"]}),r.jsx(Re,{children:"Session memory of discovered assets with source attribution and recency."})]}),r.jsx(ae,{children:r.jsxs("div",{className:"h-[240px] overflow-y-auto space-y-2 pr-1",children:[O.length===0&&r.jsx("div",{className:"text-xs text-neutral-600 font-mono",children:"No assets captured yet."}),O.map(W=>r.jsxs("div",{className:"p-2 rounded-[3px] border border-neutral-800/70 bg-neutral-900/40",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(ue,{size:"sm",variant:"neutral",children:W.type}),r.jsx("div",{className:"text-xs font-mono text-neutral-100 truncate",title:W.value,children:W.value})]}),r.jsxs(ue,{size:"sm",variant:"primary",children:[Math.round(W.confidence*100),"%"]})]}),r.jsxs("div",{className:"mt-1 text-[11px] text-neutral-500 font-mono",children:["src ",W.source," | seen ",rC(W.lastSeenAt)," | x",W.occurrences]})]},W.id))]})})]}),r.jsxs(se,{variant:"panel",glow:"primary",children:[r.jsxs(ce,{children:[r.jsxs(de,{className:"flex items-center gap-2",children:[r.jsx(qg,{className:"h-4 w-4 text-primary-400"}),"Relation Strip"]}),r.jsx(Re,{children:"Compact objective progress and memory relationship map."})]}),r.jsxs(ae,{className:"space-y-3",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Break Signals"}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:F.length===0?r.jsx("span",{className:"text-[11px] text-neutral-600 font-mono",children:"none"}):F.slice(-4).map(W=>r.jsx(ue,{size:"sm",variant:"danger",children:W},W))})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Opened Paths"}),r.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:L.length===0?r.jsx("span",{className:"text-[11px] text-neutral-600 font-mono",children:"none"}):L.slice(-4).map(W=>r.jsx(ue,{size:"sm",variant:"primary",children:W},W))})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] text-neutral-500 font-mono",children:"Relation Links"}),r.jsxs("div",{className:"mt-1 h-[150px] overflow-y-auto space-y-1 rounded-[3px] border border-neutral-800/60 bg-black/25 p-2",children:[I.length===0&&r.jsx("div",{className:"text-[11px] text-neutral-600 font-mono",children:"No relations captured yet."}),I.map(W=>r.jsxs("div",{className:"text-[11px] font-mono text-neutral-300",children:[r.jsx("span",{className:"text-primary-300",children:Eu(W.fromAssetId)})," ",r.jsxs("span",{className:"text-neutral-500",children:["[",W.type,"]"]})," ",r.jsx("span",{className:"text-primary-300",children:Eu(W.toAssetId)})]},W.id))]})]}),r.jsxs("div",{className:"text-[11px] text-neutral-500 font-mono",children:["Preconditions: ",M.length>0?M.slice(-2).join(", "):"none"]})]})]})]})]})}function lC(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState(!1),[o,i]=h.useState(null),l=h.useCallback(async()=>{a(!0);try{const d=await fetch(`${e}/ghosts`);if(!d.ok)throw new Error(`Failed to fetch ghosts: ${d.status}`);const f=await d.json();Array.isArray(f)?n(f):Array.isArray(f==null?void 0:f.ghosts)?n(f.ghosts):n([]),i(null)}catch(d){i((d==null?void 0:d.message)||"Failed to fetch ghosts")}finally{a(!1)}},[e]),u=h.useCallback(async d=>{const f=await fetch(`${e}/ghosts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),p=await f.json();if(!f.ok)throw new Error((p==null?void 0:p.error)||"Failed to create ghost");return await l(),p},[e,l]),c=h.useCallback(async d=>{const f=await fetch(`${e}/ghosts/${encodeURIComponent(d)}`,{method:"DELETE"}),p=await f.json();if(!f.ok)throw new Error((p==null?void 0:p.error)||"Failed to delete ghost");await l()},[e,l]);return h.useEffect(()=>{l()},[l]),{ghosts:t,isLoading:s,error:o,fetchGhosts:l,createGhost:u,deleteGhost:c}}const cC=["GET","POST","PUT","PATCH","DELETE"];function uC(){const{ghosts:e,isLoading:t,error:n,fetchGhosts:s,createGhost:a,deleteGhost:o}=lC(),[i,l]=h.useState("/api/checkout"),[u,c]=h.useState("POST"),[d,f]=h.useState(`{
|
|
581
|
+
"ok": true,
|
|
582
|
+
"message": "checkout simulated"
|
|
583
|
+
}`),[p,x]=h.useState("fixed"),[g,m]=h.useState(120),[y,b]=h.useState(80),[v,N]=h.useState(220),[w,j]=h.useState(0),[k,_]=h.useState(null),[P,T]=h.useState(!1),[$,B]=h.useState(null),D=h.useMemo(()=>[...e].sort((C,E)=>Date.parse(E.createdAt)-Date.parse(C.createdAt)),[e]),R=async()=>{_(null);let C;try{C=JSON.parse(d)}catch{_("Response body must be valid JSON");return}T(!0);try{await a({route:i,method:u,responseBody:C,behavior:p==="fixed"?{latencyMs:g,errorRate:w}:{jitterMs:{min:y,max:v},errorRate:w}})}catch(E){_((E==null?void 0:E.message)||"Failed to create ghost")}finally{T(!1)}},S=async C=>{B(C);try{await o(C)}finally{B(null)}};return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500 h-[calc(100vh-140px)] flex flex-col",children:[r.jsxs("div",{className:"flex items-end justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Ghost API Mocker"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Virtualize dependency APIs with configurable latency and error behavior."})]}),r.jsxs(Q,{variant:"secondary",size:"sm",onClick:s,children:[r.jsx(va,{className:"h-4 w-4 mr-2"}),"Refresh"]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6 flex-1 min-h-0",children:[r.jsxs(se,{variant:"panel",className:"flex flex-col h-full",children:[r.jsx(ce,{className:"border-b border-neutral-800/40",children:r.jsxs(de,{className:"text-sm font-mono uppercase flex items-center gap-2",children:[r.jsx(Vs,{className:"h-4 w-4 text-primary-400"}),"Create Ghost"]})}),r.jsxs(ae,{className:"space-y-4 overflow-y-auto",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Route"}),r.jsx("input",{value:i,onChange:C=>l(C.target.value),className:"w-full bg-neutral-900 border border-neutral-700 rounded-md px-3 py-2 text-sm font-mono text-neutral-100",placeholder:"/api/checkout"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Method"}),r.jsx("select",{value:u,onChange:C=>c(C.target.value),className:"w-full bg-neutral-900 border border-neutral-700 rounded-md px-3 py-2 text-sm font-mono text-neutral-100",children:cC.map(C=>r.jsx("option",{value:C,children:C},C))})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Response Body (JSON)"}),r.jsx("textarea",{value:d,onChange:C=>f(C.target.value),rows:7,className:"w-full bg-neutral-900 border border-neutral-700 rounded-md px-3 py-2 text-xs font-mono text-neutral-100"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Latency Mode"}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(Q,{variant:p==="fixed"?"primary":"secondary",size:"sm",onClick:()=>x("fixed"),children:"Fixed"}),r.jsx(Q,{variant:p==="jitter"?"primary":"secondary",size:"sm",onClick:()=>x("jitter"),children:"Jitter"})]})]}),p==="fixed"?r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Latency (ms)"}),r.jsx("input",{type:"number",min:0,max:3e4,value:g,onChange:C=>m(Number(C.target.value)),className:"w-full bg-neutral-900 border border-neutral-700 rounded-md px-3 py-2 text-sm font-mono text-neutral-100"})]}):r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Jitter Min (ms)"}),r.jsx("input",{type:"number",min:0,max:3e4,value:y,onChange:C=>b(Number(C.target.value)),className:"w-full bg-neutral-900 border border-neutral-700 rounded-md px-3 py-2 text-sm font-mono text-neutral-100"})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Jitter Max (ms)"}),r.jsx("input",{type:"number",min:0,max:3e4,value:v,onChange:C=>N(Number(C.target.value)),className:"w-full bg-neutral-900 border border-neutral-700 rounded-md px-3 py-2 text-sm font-mono text-neutral-100"})]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("label",{className:"text-xs text-neutral-400 font-mono uppercase",children:"Error Rate (%)"}),r.jsx("input",{type:"number",min:0,max:100,value:w,onChange:C=>j(Number(C.target.value)),className:"w-full bg-neutral-900 border border-neutral-700 rounded-md px-3 py-2 text-sm font-mono text-neutral-100"})]}),(k||n)&&r.jsx("div",{className:"text-sm text-red-400 font-mono",children:k||n}),r.jsxs(Q,{variant:"primary",onClick:R,disabled:P,className:"w-full",children:[r.jsx(Vs,{className:"h-4 w-4 mr-2"}),P?"Creating...":"Create Ghost"]})]})]}),r.jsxs(se,{variant:"panel",className:"flex flex-col h-full",children:[r.jsx(ce,{className:"border-b border-neutral-800/40",children:r.jsxs(de,{className:"text-sm font-mono uppercase flex items-center gap-2",children:[r.jsx(Si,{className:"h-4 w-4 text-primary-400"}),"Active Ghosts"]})}),r.jsx(ae,{className:"overflow-y-auto",children:t?r.jsx("div",{className:"text-sm text-neutral-400 font-mono",children:"Loading ghosts..."}):D.length===0?r.jsx("div",{className:"text-sm text-neutral-500 font-mono",children:"No virtual ghosts active."}):r.jsx("div",{className:"space-y-3",children:D.map(C=>r.jsx("div",{className:"border border-neutral-800 rounded-md p-3 bg-neutral-900/40",children:r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ue,{variant:"info",children:C.method}),r.jsx("span",{className:"font-mono text-sm text-neutral-100 truncate",children:C.route})]}),r.jsxs("div",{className:"text-xs text-neutral-400 font-mono mt-2",children:["hits=",C.requestCount," errorRate=",C.behavior.errorRate.toFixed(1),"%"]}),r.jsxs("div",{className:"text-xs text-neutral-500 font-mono mt-1",children:["latency=",C.behavior.latency.mode==="fixed"?`${C.behavior.latency.ms}ms`:`${C.behavior.latency.minMs}-${C.behavior.latency.maxMs}ms`]})]}),r.jsxs(Q,{variant:"danger",size:"sm",onClick:()=>S(C.id),disabled:$===C.id,children:[r.jsx(wa,{className:"h-4 w-4 mr-1"}),$===C.id?"Deleting...":"Delete"]})]})},C.id))})})]})]})]})}function dC({glow:e,variant:t="panel"}){const{baseUrl:n}=je(),[s,a]=h.useState([]),[o,i]=h.useState(!0);return h.useEffect(()=>{fetch(`${n}/api/infra/status`).then(l=>l.json()).then(l=>{a(l.servers),i(!1)}).catch(l=>{console.error("Failed to fetch infra status:",l),i(!1)})},[n]),o?r.jsxs(se,{variant:t,glow:e,className:"animate-pulse",children:[r.jsx(ce,{className:"pb-2",children:r.jsx(de,{className:"text-[11px] font-mono tracking-widest text-neutral-500",children:"Scanning Infrastructure..."})}),r.jsx(ae,{className:"h-48"})]}):r.jsxs(se,{variant:t,glow:e,className:"h-full flex flex-col",children:[r.jsx(ce,{className:"pb-3 border-b border-white/5 bg-white/[0.02]",children:r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsxs(de,{className:"flex items-center gap-2 text-[11px] font-mono tracking-widest",children:[r.jsx(ki,{className:"h-3.5 w-3.5 text-primary/70"}),"Protocol Surface Area"]}),r.jsxs(ue,{variant:"neutral",size:"sm",children:[s.length," Listeners"]})]})}),r.jsx(ae,{className:"p-0 overflow-y-auto flex-1",children:r.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-px bg-white/5",children:s.map(l=>r.jsxs("div",{className:"bg-neutral-900/50 p-3 flex items-center justify-between hover:bg-white/[0.03] transition-colors group",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:X("w-1.5 h-1.5 rounded-full transition-all duration-500",l.status==="active"?"bg-primary shadow-[0_0_8px_rgba(0,240,255,0.5)]":"bg-neutral-700")}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[11px] font-bold text-neutral-200 tracking-tight group-hover:text-primary transition-colors",children:l.name}),r.jsxs("div",{className:"text-[9px] font-mono text-neutral-500 flex items-center gap-1.5 mt-0.5",children:[r.jsx("span",{className:"text-neutral-600",children:l.protocol}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-neutral-800"}),r.jsxs("span",{className:"text-primary/60 font-bold",children:["Port ",l.port]}),l.path&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-neutral-800"}),r.jsx("span",{className:"text-neutral-600",children:l.path})]})]})]})]}),r.jsx("div",{className:"flex items-center gap-2",children:l.status==="active"?r.jsx(Jt,{className:"h-3 w-3 text-primary/40 opacity-0 group-hover:opacity-100 transition-opacity"}):r.jsx(dt,{className:"h-3 w-3 text-neutral-700"})})]},l.name))})}),r.jsx("div",{className:"p-2 border-t border-white/5 bg-black/40",children:r.jsx("div",{className:"text-[9px] font-mono text-neutral-600 text-center tracking-tighter",children:"Infrastructure state is immutable for this session."})})]})}function hC(){return r.jsxs("div",{className:"space-y-6 animate-in fade-in duration-500",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Infrastructure Listeners"}),r.jsx("p",{className:"text-neutral-400 text-sm mt-1 ml-2",children:"Real-time status of multi-protocol surface area and open ports."})]}),r.jsx("div",{className:"grid grid-cols-1 gap-6",children:r.jsx("div",{className:"h-[600px]",children:r.jsx(dC,{glow:"primary"})})})]})}const So=1e3,fC=250;function pC(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function Es(e,t){const n=Date.parse(e);return Number.isNaN(n)?t:n}function mC(e){return e==="error"?"danger":e==="warn"?"warning":"info"}function xC(e){return e==="traffic"?"info":e==="deception"?"danger":e==="defense"?"warning":"neutral"}function fm(){const{baseUrl:e}=je(),[t,n]=h.useState([]),[s,a]=h.useState(null),[o,i]=h.useState(new Set(Zl)),[l,u]=h.useState(new Set(Jl)),[c,d]=h.useState(""),[f,p]=h.useState(""),[x,g]=h.useState(!1),[m,y]=h.useState("Timeline ready"),b=h.useRef(x),v=h.useRef(0),N=h.useRef([]),w=h.useRef(null),j=h.useRef(0),k=c.trim().toLowerCase(),_=f.trim().toLowerCase(),{subscribe:P,status:T}=ts(`${e}/sse`,{enabled:!!e,maxRetries:10});h.useEffect(()=>{b.current=x},[x]);const $=h.useCallback(()=>{if(w.current=null,N.current.length===0)return;const L=N.current;N.current=[];const M=Date.now(),z=[...L].sort((H,V)=>{const Z=Es(H.timestamp,M);return Es(V.timestamp,M)-Z});n(H=>[...z,...H].slice(0,So))},[]),B=h.useCallback(()=>{w.current===null&&(w.current=window.requestAnimationFrame($))},[$]),D=h.useCallback((L,M)=>{v.current+=1;const z=Fd(L,M,v.current);if(N.current.push(z),N.current.length>So){const H=Date.now();N.current=[...N.current].sort((V,Z)=>Es(Z.timestamp,H)-Es(V.timestamp,H)).slice(0,So)}b.current||B()},[B]);h.useEffect(()=>{x||B()},[x,B]),h.useEffect(()=>()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),N.current=[]},[]),h.useEffect(()=>{if(T!=="connected")return;const L=[P("request",M=>D("request",M)),P("deception",M=>D("deception",M)),P("tarpit",M=>D("tarpit",M)),P("health",M=>D("health",M)),P("webhook",M=>D("webhook",M))];return()=>{for(const M of L)M()}},[T,P,D]);const R=h.useMemo(()=>t.filter(L=>!(!o.has(L.module)||!l.has(L.severity)||k&&!(L.sourceIp??"").toLowerCase().includes(k)||_&&!`${L.title} ${L.summary} ${L.type}`.toLowerCase().includes(_))),[t,o,l,k,_]),S=h.useMemo(()=>R.slice(0,fC),[R]),C=h.useMemo(()=>S.length===0?null:s?S.find(L=>L.id===s)??S[0]:S[0],[S,s]),E=h.useMemo(()=>C?S.findIndex(L=>L.id===C.id):-1,[S,C]),A=h.useMemo(()=>{let L=0,M=0,z=0;for(const H of t)H.module==="traffic"&&(L+=1),(H.module==="defense"||H.module==="deception")&&(M+=1),H.severity==="error"&&(z+=1);return{traffic:L,defensive:M,errors:z}},[t]);h.useEffect(()=>{if(A.errors>j.current){const L=A.errors-j.current;y(L===1?"1 new error event recorded":`${L} new error events recorded`)}else t.length===0&&y("Timeline cleared");j.current=A.errors},[A.errors,t.length]);const O=L=>{i(M=>{const z=new Set(M);return z.has(L)?z.delete(L):z.add(L),z})},I=L=>{u(M=>{const z=new Set(M);return z.has(L)?z.delete(L):z.add(L),z})},F=L=>{if(S.length===0)return;let M=E>=0?E:0;if(L.key==="ArrowDown")L.preventDefault(),M=Math.min(M+1,S.length-1);else if(L.key==="ArrowUp")L.preventDefault(),M=Math.max(M-1,0);else if(L.key==="Home")L.preventDefault(),M=0;else if(L.key==="End")L.preventDefault(),M=S.length-1;else return;const z=S[M].id;a(z),requestAnimationFrame(()=>{var H;(H=document.getElementById(`incident-event-${z}`))==null||H.scrollIntoView({block:"nearest"})})};return r.jsxs("div",{className:"space-y-5 animate-in fade-in duration-500 h-[calc(100vh-140px)] flex flex-col",children:[r.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Incident Timeline"}),r.jsx("p",{className:"text-sm text-neutral-400 mt-1 ml-2",children:"Unified flight recorder for traffic, defense, deception, webhook, and health events."})]}),r.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[r.jsx(ue,{variant:T==="connected"?"success":"warning",dot:!0,children:T==="connected"?"Live Connected":"Reconnecting"}),r.jsxs(Q,{size:"sm",variant:"outline",onClick:()=>g(L=>!L),className:"h-8 px-3 text-[11px] uppercase tracking-wider",children:[x?r.jsx(Ke,{className:"mr-1.5 h-3.5 w-3.5"}):r.jsx(Jn,{className:"mr-1.5 h-3.5 w-3.5"}),x?"Resume Feed":"Pause Feed"]}),r.jsxs(Q,{size:"sm",variant:"ghost",onClick:()=>n([]),className:"h-8 px-3 text-[11px] uppercase tracking-wider",children:[r.jsx(dd,{className:"mr-1.5 h-3.5 w-3.5"}),"Clear"]})]})]}),r.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4 flex-1 min-h-0",children:[r.jsxs(se,{variant:"panel",glow:"info",className:"lg:col-span-8 min-h-0 flex flex-col",children:[r.jsxs(ce,{className:"pb-4",children:[r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-3",children:[r.jsxs("div",{className:"relative",children:[r.jsx("label",{htmlFor:"timeline-search",className:"sr-only",children:"Search timeline events"}),r.jsx(Jr,{className:"h-3.5 w-3.5 text-neutral-600 absolute left-2.5 top-1/2 -translate-y-1/2"}),r.jsx("input",{id:"timeline-search",type:"text",value:f,onChange:L=>p(L.target.value),placeholder:"Search event text...",className:"h-8 w-full rounded-sm border border-neutral-700 bg-neutral-900/70 pl-8 pr-2 text-xs text-neutral-200 placeholder:text-neutral-600 focus:outline-none focus:border-primary/60"})]}),r.jsx("label",{htmlFor:"timeline-ip-filter",className:"sr-only",children:"Filter timeline by source IP"}),r.jsx("input",{id:"timeline-ip-filter",type:"text",value:c,onChange:L=>d(L.target.value),placeholder:"Filter by source IP...",className:"h-8 w-full rounded-sm border border-neutral-700 bg-neutral-900/70 px-2 text-xs text-neutral-200 placeholder:text-neutral-600 focus:outline-none focus:border-primary/60"}),r.jsxs("div",{className:"text-xs text-neutral-400 flex items-center justify-start xl:justify-end gap-4",children:[r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(dt,{className:"h-3.5 w-3.5 text-info-400"}),A.traffic," traffic"]}),r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(Fe,{className:"h-3.5 w-3.5 text-warning-400"}),A.defensive," defensive"]}),r.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[r.jsx(ba,{className:"h-3.5 w-3.5 text-danger-400"}),A.errors," errors"]})]})]}),r.jsxs("div",{className:"pt-3 border-t border-neutral-800/50 flex flex-col gap-2",children:[r.jsx("div",{role:"group","aria-label":"Filter by module",className:"flex flex-wrap gap-1.5",children:Zl.map(L=>r.jsx("button",{type:"button",onClick:()=>O(L),"aria-pressed":o.has(L),className:X("px-2 py-1 rounded-sm border text-[10px] font-mono uppercase tracking-wider transition-colors",o.has(L)?"border-primary/40 bg-primary/12 text-primary-300":"border-neutral-700 bg-neutral-900/50 text-neutral-500 hover:text-neutral-300"),children:L},L))}),r.jsx("div",{role:"group","aria-label":"Filter by severity",className:"flex flex-wrap gap-1.5",children:Jl.map(L=>r.jsx("button",{type:"button",onClick:()=>I(L),"aria-pressed":l.has(L),className:X("px-2 py-1 rounded-sm border text-[10px] font-mono uppercase tracking-wider transition-colors",l.has(L)?L==="error"?"border-danger-500/40 bg-danger-500/15 text-danger-300":L==="warn"?"border-warning-500/40 bg-warning-500/15 text-warning-300":"border-info-500/40 bg-info-500/15 text-info-300":"border-neutral-700 bg-neutral-900/50 text-neutral-500 hover:text-neutral-300"),children:L},L))})]})]}),r.jsxs(ae,{className:"pt-0 mt-0 flex-1 min-h-0 overflow-hidden",children:[r.jsxs("div",{role:"listbox","aria-label":"Incident events","aria-controls":"event-inspector","aria-activedescendant":C?`incident-event-${C.id}`:void 0,tabIndex:0,onKeyDown:F,className:"h-full overflow-y-auto border border-neutral-800/70 rounded-sm bg-neutral-950/70 divide-y divide-neutral-800/60 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/60",children:[R.length===0&&r.jsx("div",{className:"h-full min-h-52 flex items-center justify-center text-sm text-neutral-500",children:"No events match current filters."}),S.map(L=>{const M=L.id===(C==null?void 0:C.id);return r.jsx("button",{id:`incident-event-${L.id}`,type:"button",role:"option","aria-selected":M,onClick:()=>a(L.id),className:X("w-full px-3 py-2 text-left transition-colors",M?"bg-primary/10":"hover:bg-neutral-900/70"),children:r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx("span",{className:"text-[11px] font-mono text-neutral-400",children:pC(L.timestamp)}),r.jsx(ue,{size:"sm",variant:xC(L.module),children:L.module}),r.jsx(ue,{size:"sm",variant:mC(L.severity),children:L.severity})]}),r.jsx("div",{className:"text-sm text-neutral-100 mt-1 truncate",children:L.title}),r.jsx("div",{className:"text-xs text-neutral-400 mt-1 truncate",children:L.summary})]}),r.jsx("div",{className:"text-[10px] font-mono uppercase tracking-wider text-neutral-600",children:L.type})]})},L.id)}),R.length>S.length&&r.jsxs("div",{className:"px-3 py-2 text-[11px] text-neutral-500 border-t border-neutral-800/60",children:["Showing newest ",S.length," of ",R.length," filtered events."]})]}),r.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:m})]})]}),r.jsxs(se,{variant:"panel",className:"lg:col-span-4 min-h-0 flex flex-col",children:[r.jsx(ce,{children:r.jsx(de,{className:"text-sm",children:"Event Inspector"})}),r.jsxs(ae,{id:"event-inspector",className:"pt-0 mt-0 flex-1 min-h-0 overflow-hidden",children:[!C&&r.jsx("div",{className:"h-full min-h-52 flex items-center justify-center text-sm text-neutral-500",children:"Select an event to inspect metadata."}),C&&r.jsxs("div",{className:"h-full overflow-y-auto space-y-3",children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-xs text-neutral-500 uppercase tracking-widest",children:"Title"}),r.jsx("div",{className:"text-sm text-neutral-100",children:C.title})]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[r.jsxs("div",{className:"rounded-sm border border-neutral-800 bg-neutral-900/60 p-2",children:[r.jsx("div",{className:"text-neutral-500 uppercase tracking-wider",children:"Module"}),r.jsx("div",{className:"text-neutral-100 mt-1",children:C.module})]}),r.jsxs("div",{className:"rounded-sm border border-neutral-800 bg-neutral-900/60 p-2",children:[r.jsx("div",{className:"text-neutral-500 uppercase tracking-wider",children:"Severity"}),r.jsx("div",{className:"text-neutral-100 mt-1",children:C.severity})]}),r.jsxs("div",{className:"rounded-sm border border-neutral-800 bg-neutral-900/60 p-2",children:[r.jsx("div",{className:"text-neutral-500 uppercase tracking-wider",children:"Timestamp"}),r.jsx("div",{className:"text-neutral-100 mt-1",children:C.timestamp})]}),r.jsxs("div",{className:"rounded-sm border border-neutral-800 bg-neutral-900/60 p-2",children:[r.jsx("div",{className:"text-neutral-500 uppercase tracking-wider",children:"Source IP"}),r.jsx("div",{className:"text-neutral-100 mt-1",children:C.sourceIp??"n/a"})]})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("div",{className:"text-xs text-neutral-500 uppercase tracking-widest",children:"Raw Metadata"}),r.jsx("pre",{className:"max-h-80 overflow-auto rounded-sm border border-neutral-800 bg-neutral-950 p-3 text-[11px] leading-relaxed text-neutral-300 font-mono",children:JSON.stringify(C.data,null,2)})]})]})]})]})]})]})}fm.displayName="IncidentTimeline";const gC=4e3;function yC(e,t=gC){const{baseUrl:n}=je(),[s,a]=h.useState([]),[o,i]=h.useState(0),[l,u]=h.useState([]),[c,d]=h.useState([]),[f,p]=h.useState(!1),[x,g]=h.useState(null),m=h.useMemo(()=>{const _=new URLSearchParams;return e.q&&_.set("q",e.q),typeof e.minRisk=="number"&&_.set("minRisk",String(e.minRisk)),e.category&&_.set("category",e.category),typeof e.limit=="number"&&_.set("limit",String(e.limit)),_.toString()},[e.q,e.minRisk,e.category,e.limit]),y=h.useCallback(async()=>{if(n){p(!0),g(null);try{const[_,P,T]=await Promise.all([fetch(`${n}/api/attackers${m?`?${m}`:""}`),fetch(`${n}/blackhole`),fetch(`${n}/tarpit`)]);if(!_.ok)throw new Error("Failed to load attacker profiles");if(!P.ok)throw new Error("Failed to load blackhole state");if(!T.ok)throw new Error("Failed to load tarpit state");const $=await _.json(),B=await P.json(),D=await T.json();a($.profiles||[]),i($.tracked||0),u(B.blocked||[]),d(D.trapped||[])}catch(_){const P=_ instanceof Error?_.message:"Unknown attacker fetch error";g(P)}finally{p(!1)}}},[n,m]);h.useEffect(()=>{if(y(),t<=0)return;const _=setInterval(y,t);return()=>clearInterval(_)},[t,y]);const b=h.useMemo(()=>new Set(l.map(_=>_.ip)),[l]),v=h.useMemo(()=>new Set(c.map(_=>_.ip)),[c]),N=h.useCallback(async _=>!n||!(await fetch(`${n}/tarpit/trap`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip:_})})).ok?!1:(await y(),!0),[n,y]),w=h.useCallback(async _=>!n||!(await fetch(`${n}/tarpit/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip:_})})).ok?!1:(await y(),!0),[n,y]),j=h.useCallback(async _=>!n||!(await fetch(`${n}/blackhole`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip:_})})).ok?!1:(await y(),!0),[n,y]),k=h.useCallback(async _=>!n||!(await fetch(`${n}/blackhole/release`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip:_})})).ok?!1:(await y(),!0),[n,y]);return{profiles:s,trackedCount:o,blackholedIps:b,tarpittedIps:v,isLoading:f,error:x,refresh:y,trapIp:N,releaseTarpit:w,blackholeIp:j,releaseBlackhole:k}}const bC=[{value:"all",label:"All Sources"},{value:"internal",label:"Internal"},{value:"known_bot",label:"Known Bot"},{value:"unknown_external",label:"Unknown External"}],vC={internal:"Internal",known_bot:"Known Bot",unknown_external:"Unknown External"};function _u(e){return e>=80?"danger":e>=40?"warning":"success"}function Cu(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function wC(e){return e<=0?"bg-neutral-950 text-neutral-700":e<.25?"bg-warning-500/15 text-warning-200":e<.6?"bg-warning-500/30 text-warning-100":"bg-danger-500/45 text-danger-50"}function NC(){const[e,t]=h.useState(""),[n,s]=h.useState(0),[a,o]=h.useState("all"),[i,l]=h.useState(null),[u,c]=h.useState(null),d=h.useMemo(()=>({q:e.trim()||void 0,minRisk:n>0?n:void 0,category:a==="all"?void 0:a,limit:150}),[e,n,a]),{profiles:f,trackedCount:p,blackholedIps:x,tarpittedIps:g,isLoading:m,error:y,refresh:b,trapIp:v,releaseTarpit:N,blackholeIp:w,releaseBlackhole:j}=yC(d,4e3);h.useEffect(()=>{if(f.length===0){l(null);return}(!i||!f.some(R=>R.ip===i))&&l(f[0].ip)},[f,i]);const k=h.useMemo(()=>f.find(R=>R.ip===i)??f[0]??null,[f,i]),_=h.useMemo(()=>f.filter(R=>R.riskScore>=80).length,[f]),P=h.useMemo(()=>f.filter(R=>x.has(R.ip)||g.has(R.ip)).length,[f,x,g]),T=h.useMemo(()=>{const R=new Map;for(const S of f)for(const[C,E]of Object.entries(S.protocols))R.set(C,(R.get(C)||0)+E);return Array.from(R.entries()).sort((S,C)=>C[1]-S[1]).slice(0,8).map(([S])=>S)},[f]),$=h.useMemo(()=>f.slice(0,12),[f]),B=h.useMemo(()=>{let R=1;for(const S of $)for(const C of T)R=Math.max(R,S.protocols[C]||0);return R},[$,T]),D=async(R,S)=>{c(R);try{await S()}finally{c(null)}};return r.jsxs("div",{className:"space-y-5 animate-in fade-in duration-500",children:[r.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[r.jsxs("div",{children:[r.jsx("h1",{className:"text-2xl text-neutral-100 ml-2 type-heading",children:"Attacker Fingerprinting"}),r.jsx("p",{className:"text-sm text-neutral-400 mt-1 ml-2",children:"Persistent attacker identities, risk scoring, protocol heatmap, and one-click containment."})]}),r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsxs(ue,{variant:"info",dot:!0,children:[p," tracked"]}),r.jsxs(ue,{variant:"danger",dot:!0,children:[_," high risk"]}),r.jsxs(ue,{variant:"warning",dot:!0,children:[P," contained"]}),r.jsxs(Q,{variant:"outline",size:"sm",className:"h-8 px-3 text-[11px] uppercase tracking-wider",onClick:b,disabled:m,children:[r.jsx(dd,{className:"h-3.5 w-3.5 mr-1.5"}),"Refresh"]})]})]}),r.jsx(se,{variant:"panel",className:"border-neutral-800/70",children:r.jsx(ae,{className:"p-4 pt-4",children:r.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[r.jsxs("label",{className:"relative",children:[r.jsx(Jr,{className:"h-3.5 w-3.5 text-neutral-600 absolute left-2.5 top-1/2 -translate-y-1/2"}),r.jsx("input",{type:"text",value:e,onChange:R=>t(R.target.value),placeholder:"Search source IP...",className:"h-9 w-full rounded-sm border border-neutral-700 bg-neutral-900/70 pl-8 pr-2 text-xs text-neutral-200 placeholder:text-neutral-600 focus:outline-none focus:border-primary/60"})]}),r.jsxs("label",{children:[r.jsx("span",{className:"sr-only",children:"Filter by category"}),r.jsx("select",{value:a,onChange:R=>o(R.target.value),className:"h-9 w-full rounded-sm border border-neutral-700 bg-neutral-900/70 px-2 text-xs text-neutral-200 focus:outline-none focus:border-primary/60",children:bC.map(R=>r.jsx("option",{value:R.value,children:R.label},R.value))})]}),r.jsxs("label",{className:"flex items-center gap-3 px-2 h-9 rounded-sm border border-neutral-700 bg-neutral-900/70",children:[r.jsx("span",{className:"text-[11px] text-neutral-500 uppercase tracking-wider",children:"Min Risk"}),r.jsx("input",{type:"range",min:0,max:150,step:5,value:n,onChange:R=>s(Number(R.target.value)),className:"w-full accent-danger-500"}),r.jsx("span",{className:"text-[11px] font-mono text-neutral-300 w-8 text-right",children:n})]})]})})}),y&&r.jsx(se,{variant:"panel",className:"border-danger-500/40 bg-danger-500/5",children:r.jsxs(ae,{className:"p-3 pt-3 text-xs text-danger-300 flex items-center gap-2",children:[r.jsx(Zt,{className:"h-3.5 w-3.5"}),y]})}),r.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-12 gap-4 h-[620px] min-h-0",children:[r.jsxs(se,{variant:"panel",glow:"danger",className:"xl:col-span-7 h-full min-h-0 flex flex-col",children:[r.jsx(ce,{className:"pb-3",children:r.jsxs(de,{className:"text-sm uppercase tracking-wider flex items-center gap-2",children:[r.jsx(Bg,{className:"h-4 w-4 text-danger-400"}),"Attacker Registry"]})}),r.jsx(ae,{className:"pt-0 px-0 flex-1 min-h-0 overflow-y-auto",children:r.jsxs("div",{className:"divide-y divide-neutral-800/70",children:[f.length===0&&r.jsx("div",{className:"p-4 text-xs text-neutral-500",children:"No attacker profiles match current filters."}),f.map(R=>{const S=(k==null?void 0:k.ip)===R.ip,C=g.has(R.ip),E=x.has(R.ip),A=`${R.ip}:tarpit`,O=`${R.ip}:blackhole`;return r.jsx("button",{type:"button",onClick:()=>l(R.ip),className:X("w-full p-3 text-left transition-colors",S?"bg-primary-500/10":"hover:bg-neutral-900/60"),children:r.jsxs("div",{className:"flex items-start justify-between gap-2",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-sm font-mono text-neutral-100",children:R.ip}),r.jsxs(ue,{variant:_u(R.riskScore),size:"sm",children:["RISK ",R.riskScore]}),r.jsx(ue,{variant:"neutral",size:"sm",children:vC[R.geoCategory]}),E&&r.jsx(ue,{variant:"danger",size:"sm",dot:!0,children:"BLACKHOLED"}),C&&r.jsx(ue,{variant:"warning",size:"sm",dot:!0,children:"TARPITTED"})]}),r.jsxs("div",{className:"mt-2 text-[11px] text-neutral-500 flex flex-wrap gap-3 font-mono",children:[r.jsxs("span",{children:["REQ ",R.counters.requests]}),r.jsxs("span",{children:["BLOCK ",R.counters.blocked]}),r.jsxs("span",{children:["DECEPTION ",R.counters.deception]}),r.jsxs("span",{children:["LAST ",Cu(R.lastSeen)]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(Q,{variant:C?"outline":"secondary",size:"sm",className:"h-7 px-2 text-[10px]",disabled:u===A,onClick:I=>{I.stopPropagation(),D(A,()=>C?N(R.ip):v(R.ip))},children:[C?r.jsx(Jt,{className:"h-3 w-3 mr-1"}):r.jsx(Fe,{className:"h-3 w-3 mr-1"}),C?"RELEASE":"TARPIT"]}),r.jsxs(Q,{variant:E?"outline":"danger",size:"sm",className:"h-7 px-2 text-[10px]",disabled:u===O,onClick:I=>{I.stopPropagation(),D(O,()=>E?j(R.ip):w(R.ip))},children:[r.jsx(Zg,{className:"h-3 w-3 mr-1"}),E?"UNBLOCK":"BLACKHOLE"]})]})]})},R.ip)})]})})]}),r.jsxs("div",{className:"xl:col-span-5 grid grid-rows-2 gap-4 h-full min-h-0",children:[r.jsxs(se,{variant:"panel",glow:"warning",className:"h-full min-h-0 flex flex-col",children:[r.jsx(ce,{className:"pb-3",children:r.jsx(de,{className:"text-sm uppercase tracking-wider",children:"Kill Chain Timeline"})}),r.jsxs(ae,{className:"pt-0 px-0 flex-1 min-h-0 overflow-y-auto",children:[!k&&r.jsx("div",{className:"p-4 text-xs text-neutral-500",children:"Select an attacker to inspect timeline events."}),k&&r.jsx("div",{className:"divide-y divide-neutral-800/60",children:k.timeline.slice(0,25).map((R,S)=>r.jsxs("div",{className:"px-4 py-2.5",children:[r.jsxs("div",{className:"flex items-center justify-between gap-2 text-[11px] font-mono",children:[r.jsx("span",{className:"text-neutral-400 uppercase",children:R.kind}),r.jsx("span",{className:"text-neutral-600",children:Cu(R.timestamp)})]}),r.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[r.jsx(ue,{variant:"neutral",size:"sm",children:R.stage}),r.jsxs("span",{className:X("text-xs font-mono",R.scoreDelta>0?"text-danger-300":"text-neutral-500"),children:["+",R.scoreDelta]})]}),"path"in R.detail&&r.jsx("div",{className:"mt-1 text-[11px] text-neutral-500 font-mono",children:R.detail.path||""})]},`${k.ip}-${R.timestamp}-${S}`))})]})]}),r.jsxs(se,{variant:"panel",glow:"danger",className:"h-full min-h-0 flex flex-col",children:[r.jsx(ce,{className:"pb-3",children:r.jsx(de,{className:"text-sm uppercase tracking-wider",children:"Risk Posture"})}),r.jsxs(ae,{className:"pt-0 space-y-2 text-xs text-neutral-400",children:[r.jsxs("div",{className:"flex items-center justify-between border border-neutral-800 bg-neutral-900/60 px-3 py-2",children:[r.jsx("span",{children:"Selected Source"}),r.jsx("span",{className:"font-mono text-neutral-200",children:(k==null?void 0:k.ip)||"—"})]}),r.jsxs("div",{className:"flex items-center justify-between border border-neutral-800 bg-neutral-900/60 px-3 py-2",children:[r.jsx("span",{children:"Current Risk"}),r.jsx(ue,{variant:k?_u(k.riskScore):"neutral",children:k?k.riskScore:0})]}),r.jsxs("div",{className:"flex items-center justify-between border border-neutral-800 bg-neutral-900/60 px-3 py-2",children:[r.jsx("span",{children:"Blocked Requests"}),r.jsx("span",{className:"font-mono text-danger-300",children:(k==null?void 0:k.counters.blocked)||0})]}),r.jsxs("div",{className:"flex items-center justify-between border border-neutral-800 bg-neutral-900/60 px-3 py-2",children:[r.jsx("span",{children:"Deception Hits"}),r.jsx("span",{className:"font-mono text-warning-300",children:(k==null?void 0:k.counters.deception)||0})]})]})]})]})]}),r.jsxs(se,{variant:"panel",glow:"danger",children:[r.jsx(ce,{className:"pb-3",children:r.jsx(de,{className:"text-sm uppercase tracking-wider",children:"Attacker Heatmap"})}),r.jsx(ae,{className:"pt-0 overflow-x-auto",children:$.length===0||T.length===0?r.jsx("div",{className:"text-xs text-neutral-500 py-4",children:"No protocol activity yet."}):r.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-xs",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"text-neutral-500",children:[r.jsx("th",{className:"text-left py-2 px-2 border-b border-neutral-800",children:"Source IP"}),T.map(R=>r.jsx("th",{className:"text-center py-2 px-2 border-b border-neutral-800 uppercase font-mono",children:R},R))]})}),r.jsx("tbody",{children:$.map(R=>r.jsxs("tr",{className:"border-b border-neutral-900",children:[r.jsx("td",{className:"py-2 px-2 font-mono text-neutral-300",children:R.ip}),T.map(S=>{const C=R.protocols[S]||0,E=C/B;return r.jsx("td",{className:"py-1.5 px-1.5",children:r.jsx("div",{className:X("h-7 rounded-sm flex items-center justify-center font-mono",wC(E)),children:C})},`${R.ip}-${S}`)})]},`heat-${R.ip}`))})]})})]})]})}var Tu=1,SC=.9,jC=.8,kC=.17,jo=.1,ko=.999,EC=.9999,_C=.99,CC=/[\\\/_+.#"@\[\(\{&]/,TC=/[\\\/_+.#"@\[\(\{&]/g,RC=/[\s-]/,pm=/[\s-]/g;function hi(e,t,n,s,a,o,i){if(o===t.length)return a===e.length?Tu:_C;var l=`${a},${o}`;if(i[l]!==void 0)return i[l];for(var u=s.charAt(o),c=n.indexOf(u,a),d=0,f,p,x,g;c>=0;)f=hi(e,t,n,s,c+1,o+1,i),f>d&&(c===a?f*=Tu:CC.test(e.charAt(c-1))?(f*=jC,x=e.slice(a,c-1).match(TC),x&&a>0&&(f*=Math.pow(ko,x.length))):RC.test(e.charAt(c-1))?(f*=SC,g=e.slice(a,c-1).match(pm),g&&a>0&&(f*=Math.pow(ko,g.length))):(f*=kC,a>0&&(f*=Math.pow(ko,c-a))),e.charAt(c)!==t.charAt(o)&&(f*=EC)),(f<jo&&n.charAt(c-1)===s.charAt(o+1)||s.charAt(o+1)===s.charAt(o)&&n.charAt(c-1)!==s.charAt(o))&&(p=hi(e,t,n,s,c+1,o+2,i),p*jo>f&&(f=p*jo)),f>d&&(d=f),c=n.indexOf(u,c+1);return i[l]=d,d}function Ru(e){return e.toLowerCase().replace(pm," ")}function AC(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,hi(e,t,Ru(e),Ru(t),0,0,{})}function MC(e,t){return h.useReducer((n,s)=>t[n][s]??n,e)}var za=e=>{const{present:t,children:n}=e,s=IC(t),a=typeof n=="function"?n({present:s.isPresent}):h.Children.only(n),o=Me(s.ref,PC(a));return typeof n=="function"||s.isPresent?h.cloneElement(a,{ref:o}):null};za.displayName="Presence";function IC(e){const[t,n]=h.useState(),s=h.useRef(null),a=h.useRef(e),o=h.useRef("none"),i=e?"mounted":"unmounted",[l,u]=MC(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return h.useEffect(()=>{const c=_s(s.current);o.current=l==="mounted"?c:"none"},[l]),Ue(()=>{const c=s.current,d=a.current;if(d!==e){const p=o.current,x=_s(c);e?u("MOUNT"):x==="none"||(c==null?void 0:c.display)==="none"?u("UNMOUNT"):u(d&&p!==x?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,u]),Ue(()=>{if(t){let c;const d=t.ownerDocument.defaultView??window,f=x=>{const m=_s(s.current).includes(CSS.escape(x.animationName));if(x.target===t&&m&&(u("ANIMATION_END"),!a.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",c=d.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},p=x=>{x.target===t&&(o.current=_s(s.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{d.clearTimeout(c),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else u("ANIMATION_END")},[t,u]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:h.useCallback(c=>{s.current=c?getComputedStyle(c):null,n(c)},[])}}function _s(e){return(e==null?void 0:e.animationName)||"none"}function PC(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Fa="Dialog",[mm]=rs(Fa),[OC,mt]=mm(Fa),xm=e=>{const{__scopeDialog:t,children:n,open:s,defaultOpen:a,onOpenChange:o,modal:i=!0}=e,l=h.useRef(null),u=h.useRef(null),[c,d]=Ys({prop:s,defaultProp:a??!1,onChange:o,caller:Fa});return r.jsx(OC,{scope:t,triggerRef:l,contentRef:u,contentId:st(),titleId:st(),descriptionId:st(),open:c,onOpenChange:d,onOpenToggle:h.useCallback(()=>d(f=>!f),[d]),modal:i,children:n})};xm.displayName=Fa;var gm="DialogTrigger",LC=h.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=mt(gm,n),o=Me(t,a.triggerRef);return r.jsx(ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":pl(a.open),...s,ref:o,onClick:Se(e.onClick,a.onOpenToggle)})});LC.displayName=gm;var hl="DialogPortal",[DC,ym]=mm(hl,{forceMount:void 0}),bm=e=>{const{__scopeDialog:t,forceMount:n,children:s,container:a}=e,o=mt(hl,t);return r.jsx(DC,{scope:t,forceMount:n,children:h.Children.map(s,i=>r.jsx(za,{present:n||o.open,children:r.jsx(Wi,{asChild:!0,container:a,children:i})}))})};bm.displayName=hl;var da="DialogOverlay",vm=h.forwardRef((e,t)=>{const n=ym(da,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=mt(da,e.__scopeDialog);return o.modal?r.jsx(za,{present:s||o.open,children:r.jsx(zC,{...a,ref:t})}):null});vm.displayName=da;var $C=Dr("DialogOverlay.RemoveScroll"),zC=h.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=mt(da,n);return r.jsx(Gi,{as:$C,allowPinchZoom:!0,shards:[a.contentRef],children:r.jsx(ke.div,{"data-state":pl(a.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),En="DialogContent",wm=h.forwardRef((e,t)=>{const n=ym(En,e.__scopeDialog),{forceMount:s=n.forceMount,...a}=e,o=mt(En,e.__scopeDialog);return r.jsx(za,{present:s||o.open,children:o.modal?r.jsx(FC,{...a,ref:t}):r.jsx(BC,{...a,ref:t})})});wm.displayName=En;var FC=h.forwardRef((e,t)=>{const n=mt(En,e.__scopeDialog),s=h.useRef(null),a=Me(t,n.contentRef,s);return h.useEffect(()=>{const o=s.current;if(o)return Lh(o)},[]),r.jsx(Nm,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Se(e.onCloseAutoFocus,o=>{var i;o.preventDefault(),(i=n.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Se(e.onPointerDownOutside,o=>{const i=o.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&o.preventDefault()}),onFocusOutside:Se(e.onFocusOutside,o=>o.preventDefault())})}),BC=h.forwardRef((e,t)=>{const n=mt(En,e.__scopeDialog),s=h.useRef(!1),a=h.useRef(!1);return r.jsx(Nm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,o),o.defaultPrevented||(s.current||(l=n.triggerRef.current)==null||l.focus(),o.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:o=>{var u,c;(u=e.onInteractOutside)==null||u.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const i=o.target;((c=n.triggerRef.current)==null?void 0:c.contains(i))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&a.current&&o.preventDefault()}})}),Nm=h.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:o,...i}=e,l=mt(En,n),u=h.useRef(null),c=Me(t,u);return uh(),r.jsxs(r.Fragment,{children:[r.jsx(Di,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:o,children:r.jsx(Li,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":pl(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(HC,{titleId:l.titleId}),r.jsx(VC,{contentRef:u,descriptionId:l.descriptionId})]})]})}),fl="DialogTitle",Sm=h.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=mt(fl,n);return r.jsx(ke.h2,{id:a.titleId,...s,ref:t})});Sm.displayName=fl;var jm="DialogDescription",km=h.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=mt(jm,n);return r.jsx(ke.p,{id:a.descriptionId,...s,ref:t})});km.displayName=jm;var Em="DialogClose",_m=h.forwardRef((e,t)=>{const{__scopeDialog:n,...s}=e,a=mt(Em,n);return r.jsx(ke.button,{type:"button",...s,ref:t,onClick:Se(e.onClick,()=>a.onOpenChange(!1))})});_m.displayName=Em;function pl(e){return e?"open":"closed"}var Cm="DialogTitleWarning",[WA,Tm]=Qy(Cm,{contentName:En,titleName:fl,docsSlug:"dialog"}),HC=({titleId:e})=>{const t=Tm(Cm),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
584
|
+
|
|
585
|
+
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
586
|
+
|
|
587
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return h.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},UC="DialogDescriptionWarning",VC=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Tm(UC).contentName}}.`;return h.useEffect(()=>{var o;const a=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Rm=xm,Am=bm,ml=vm,xl=wm,Mm=Sm,Im=km,qC=_m,WC=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],an=WC.reduce((e,t)=>{const n=$d(`Primitive.${t}`),s=h.forwardRef((a,o)=>{const{asChild:i,...l}=a,u=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),r.jsx(u,{...l,ref:o})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{}),kr='[cmdk-group=""]',Eo='[cmdk-group-items=""]',GC='[cmdk-group-heading=""]',Pm='[cmdk-item=""]',Au=`${Pm}:not([aria-disabled="true"])`,fi="cmdk-item-select",Fn="data-value",KC=(e,t,n)=>AC(e,t,n),Om=h.createContext(void 0),cs=()=>h.useContext(Om),Lm=h.createContext(void 0),gl=()=>h.useContext(Lm),Dm=h.createContext(void 0),$m=h.forwardRef((e,t)=>{let n=Bn(()=>{var M,z;return{search:"",value:(z=(M=e.value)!=null?M:e.defaultValue)!=null?z:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),s=Bn(()=>new Set),a=Bn(()=>new Map),o=Bn(()=>new Map),i=Bn(()=>new Set),l=zm(e),{label:u,children:c,value:d,onValueChange:f,filter:p,shouldFilter:x,loop:g,disablePointerSelection:m=!1,vimBindings:y=!0,...b}=e,v=st(),N=st(),w=st(),j=h.useRef(null),k=aT();_n(()=>{if(d!==void 0){let M=d.trim();n.current.value=M,_.emit()}},[d]),_n(()=>{k(6,R)},[]);let _=h.useMemo(()=>({subscribe:M=>(i.current.add(M),()=>i.current.delete(M)),snapshot:()=>n.current,setState:(M,z,H)=>{var V,Z,G,J;if(!Object.is(n.current[M],z)){if(n.current[M]=z,M==="search")D(),$(),k(1,B);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ee=document.getElementById(w);ee?ee.focus():(V=document.getElementById(v))==null||V.focus()}if(k(7,()=>{var ee;n.current.selectedItemId=(ee=S())==null?void 0:ee.id,_.emit()}),H||k(5,R),((Z=l.current)==null?void 0:Z.value)!==void 0){let ee=z??"";(J=(G=l.current).onValueChange)==null||J.call(G,ee);return}}_.emit()}},emit:()=>{i.current.forEach(M=>M())}}),[]),P=h.useMemo(()=>({value:(M,z,H)=>{var V;z!==((V=o.current.get(M))==null?void 0:V.value)&&(o.current.set(M,{value:z,keywords:H}),n.current.filtered.items.set(M,T(z,H)),k(2,()=>{$(),_.emit()}))},item:(M,z)=>(s.current.add(M),z&&(a.current.has(z)?a.current.get(z).add(M):a.current.set(z,new Set([M]))),k(3,()=>{D(),$(),n.current.value||B(),_.emit()}),()=>{o.current.delete(M),s.current.delete(M),n.current.filtered.items.delete(M);let H=S();k(4,()=>{D(),(H==null?void 0:H.getAttribute("id"))===M&&B(),_.emit()})}),group:M=>(a.current.has(M)||a.current.set(M,new Set),()=>{o.current.delete(M),a.current.delete(M)}),filter:()=>l.current.shouldFilter,label:u||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:v,inputId:w,labelId:N,listInnerRef:j}),[]);function T(M,z){var H,V;let Z=(V=(H=l.current)==null?void 0:H.filter)!=null?V:KC;return M?Z(M,n.current.search,z):0}function $(){if(!n.current.search||l.current.shouldFilter===!1)return;let M=n.current.filtered.items,z=[];n.current.filtered.groups.forEach(V=>{let Z=a.current.get(V),G=0;Z.forEach(J=>{let ee=M.get(J);G=Math.max(ee,G)}),z.push([V,G])});let H=j.current;C().sort((V,Z)=>{var G,J;let ee=V.getAttribute("id"),te=Z.getAttribute("id");return((G=M.get(te))!=null?G:0)-((J=M.get(ee))!=null?J:0)}).forEach(V=>{let Z=V.closest(Eo);Z?Z.appendChild(V.parentElement===Z?V:V.closest(`${Eo} > *`)):H.appendChild(V.parentElement===H?V:V.closest(`${Eo} > *`))}),z.sort((V,Z)=>Z[1]-V[1]).forEach(V=>{var Z;let G=(Z=j.current)==null?void 0:Z.querySelector(`${kr}[${Fn}="${encodeURIComponent(V[0])}"]`);G==null||G.parentElement.appendChild(G)})}function B(){let M=C().find(H=>H.getAttribute("aria-disabled")!=="true"),z=M==null?void 0:M.getAttribute(Fn);_.setState("value",z||void 0)}function D(){var M,z,H,V;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=s.current.size;return}n.current.filtered.groups=new Set;let Z=0;for(let G of s.current){let J=(z=(M=o.current.get(G))==null?void 0:M.value)!=null?z:"",ee=(V=(H=o.current.get(G))==null?void 0:H.keywords)!=null?V:[],te=T(J,ee);n.current.filtered.items.set(G,te),te>0&&Z++}for(let[G,J]of a.current)for(let ee of J)if(n.current.filtered.items.get(ee)>0){n.current.filtered.groups.add(G);break}n.current.filtered.count=Z}function R(){var M,z,H;let V=S();V&&(((M=V.parentElement)==null?void 0:M.firstChild)===V&&((H=(z=V.closest(kr))==null?void 0:z.querySelector(GC))==null||H.scrollIntoView({block:"nearest"})),V.scrollIntoView({block:"nearest"}))}function S(){var M;return(M=j.current)==null?void 0:M.querySelector(`${Pm}[aria-selected="true"]`)}function C(){var M;return Array.from(((M=j.current)==null?void 0:M.querySelectorAll(Au))||[])}function E(M){let z=C()[M];z&&_.setState("value",z.getAttribute(Fn))}function A(M){var z;let H=S(),V=C(),Z=V.findIndex(J=>J===H),G=V[Z+M];(z=l.current)!=null&&z.loop&&(G=Z+M<0?V[V.length-1]:Z+M===V.length?V[0]:V[Z+M]),G&&_.setState("value",G.getAttribute(Fn))}function O(M){let z=S(),H=z==null?void 0:z.closest(kr),V;for(;H&&!V;)H=M>0?rT(H,kr):sT(H,kr),V=H==null?void 0:H.querySelector(Au);V?_.setState("value",V.getAttribute(Fn)):A(M)}let I=()=>E(C().length-1),F=M=>{M.preventDefault(),M.metaKey?I():M.altKey?O(1):A(1)},L=M=>{M.preventDefault(),M.metaKey?E(0):M.altKey?O(-1):A(-1)};return h.createElement(an.div,{ref:t,tabIndex:-1,...b,"cmdk-root":"",onKeyDown:M=>{var z;(z=b.onKeyDown)==null||z.call(b,M);let H=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||H))switch(M.key){case"n":case"j":{y&&M.ctrlKey&&F(M);break}case"ArrowDown":{F(M);break}case"p":case"k":{y&&M.ctrlKey&&L(M);break}case"ArrowUp":{L(M);break}case"Home":{M.preventDefault(),E(0);break}case"End":{M.preventDefault(),I();break}case"Enter":{M.preventDefault();let V=S();if(V){let Z=new Event(fi);V.dispatchEvent(Z)}}}}},h.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:iT},u),Ba(e,M=>h.createElement(Lm.Provider,{value:_},h.createElement(Om.Provider,{value:P},M))))}),YC=h.forwardRef((e,t)=>{var n,s;let a=st(),o=h.useRef(null),i=h.useContext(Dm),l=cs(),u=zm(e),c=(s=(n=u.current)==null?void 0:n.forceMount)!=null?s:i==null?void 0:i.forceMount;_n(()=>{if(!c)return l.item(a,i==null?void 0:i.id)},[c]);let d=Fm(a,o,[e.value,e.children,o],e.keywords),f=gl(),p=nn(k=>k.value&&k.value===d.current),x=nn(k=>c||l.filter()===!1?!0:k.search?k.filtered.items.get(a)>0:!0);h.useEffect(()=>{let k=o.current;if(!(!k||e.disabled))return k.addEventListener(fi,g),()=>k.removeEventListener(fi,g)},[x,e.onSelect,e.disabled]);function g(){var k,_;m(),(_=(k=u.current).onSelect)==null||_.call(k,d.current)}function m(){f.setState("value",d.current,!0)}if(!x)return null;let{disabled:y,value:b,onSelect:v,forceMount:N,keywords:w,...j}=e;return h.createElement(an.div,{ref:Qt(o,t),...j,id:a,"cmdk-item":"",role:"option","aria-disabled":!!y,"aria-selected":!!p,"data-disabled":!!y,"data-selected":!!p,onPointerMove:y||l.getDisablePointerSelection()?void 0:m,onClick:y?void 0:g},e.children)}),XC=h.forwardRef((e,t)=>{let{heading:n,children:s,forceMount:a,...o}=e,i=st(),l=h.useRef(null),u=h.useRef(null),c=st(),d=cs(),f=nn(x=>a||d.filter()===!1?!0:x.search?x.filtered.groups.has(i):!0);_n(()=>d.group(i),[]),Fm(i,l,[e.value,e.heading,u]);let p=h.useMemo(()=>({id:i,forceMount:a}),[a]);return h.createElement(an.div,{ref:Qt(l,t),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&h.createElement("div",{ref:u,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Ba(e,x=>h.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},h.createElement(Dm.Provider,{value:p},x))))}),ZC=h.forwardRef((e,t)=>{let{alwaysRender:n,...s}=e,a=h.useRef(null),o=nn(i=>!i.search);return!n&&!o?null:h.createElement(an.div,{ref:Qt(a,t),...s,"cmdk-separator":"",role:"separator"})}),JC=h.forwardRef((e,t)=>{let{onValueChange:n,...s}=e,a=e.value!=null,o=gl(),i=nn(c=>c.search),l=nn(c=>c.selectedItemId),u=cs();return h.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),h.createElement(an.input,{ref:t,...s,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":u.listId,"aria-labelledby":u.labelId,"aria-activedescendant":l,id:u.inputId,type:"text",value:a?e.value:i,onChange:c=>{a||o.setState("search",c.target.value),n==null||n(c.target.value)}})}),QC=h.forwardRef((e,t)=>{let{children:n,label:s="Suggestions",...a}=e,o=h.useRef(null),i=h.useRef(null),l=nn(c=>c.selectedItemId),u=cs();return h.useEffect(()=>{if(i.current&&o.current){let c=i.current,d=o.current,f,p=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let x=c.offsetHeight;d.style.setProperty("--cmdk-list-height",x.toFixed(1)+"px")})});return p.observe(c),()=>{cancelAnimationFrame(f),p.unobserve(c)}}},[]),h.createElement(an.div,{ref:Qt(o,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":s,id:u.listId},Ba(e,c=>h.createElement("div",{ref:Qt(i,u.listInnerRef),"cmdk-list-sizer":""},c)))}),eT=h.forwardRef((e,t)=>{let{open:n,onOpenChange:s,overlayClassName:a,contentClassName:o,container:i,...l}=e;return h.createElement(Rm,{open:n,onOpenChange:s},h.createElement(Am,{container:i},h.createElement(ml,{"cmdk-overlay":"",className:a}),h.createElement(xl,{"aria-label":e.label,"cmdk-dialog":"",className:o},h.createElement($m,{ref:t,...l}))))}),tT=h.forwardRef((e,t)=>nn(n=>n.filtered.count===0)?h.createElement(an.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),nT=h.forwardRef((e,t)=>{let{progress:n,children:s,label:a="Loading...",...o}=e;return h.createElement(an.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Ba(e,i=>h.createElement("div",{"aria-hidden":!0},i)))}),on=Object.assign($m,{List:QC,Item:YC,Input:JC,Group:XC,Separator:ZC,Dialog:eT,Empty:tT,Loading:nT});function rT(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function sT(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function zm(e){let t=h.useRef(e);return _n(()=>{t.current=e}),t}var _n=typeof window>"u"?h.useEffect:h.useLayoutEffect;function Bn(e){let t=h.useRef();return t.current===void 0&&(t.current=e()),t}function nn(e){let t=gl(),n=()=>e(t.snapshot());return h.useSyncExternalStore(t.subscribe,n,n)}function Fm(e,t,n,s=[]){let a=h.useRef(),o=cs();return _n(()=>{var i;let l=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():a.current}})(),u=s.map(c=>c.trim());o.value(e,l,u),(i=t.current)==null||i.setAttribute(Fn,l),a.current=l}),a}var aT=()=>{let[e,t]=h.useState(),n=Bn(()=>new Map);return _n(()=>{n.current.forEach(s=>s()),n.current=new Map},[e]),(s,a)=>{n.current.set(s,a),t({})}};function oT(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Ba({asChild:e,children:t},n){return e&&h.isValidElement(t)?h.cloneElement(oT(t),{ref:t.ref},n(t.props.children)):n(t)}var iT={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const lT=Rm,cT=Am,Bm=h.forwardRef(({className:e,...t},n)=>r.jsx(ml,{ref:n,className:X("fixed inset-0 z-[10000] bg-black/90 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));Bm.displayName=ml.displayName;const Hm=h.forwardRef(({className:e,children:t,...n},s)=>r.jsxs(cT,{children:[r.jsx(Bm,{}),r.jsxs(xl,{ref:s,className:X("fixed left-[50%] top-[50%] z-[10001] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-neutral-700/80 bg-popover p-6 shadow-[0_30px_80px_rgba(0,0,0,0.75)] 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%] sm:rounded-lg",e),...n,children:[t,r.jsxs(qC,{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:[r.jsx(gd,{className:"h-4 w-4"}),r.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Hm.displayName=xl.displayName;const Um=h.forwardRef(({className:e,...t},n)=>r.jsx(Mm,{ref:n,className:X("text-lg font-semibold leading-none tracking-tight",e),...t}));Um.displayName=Mm.displayName;const Vm=h.forwardRef(({className:e,...t},n)=>r.jsx(Im,{ref:n,className:X("text-sm text-muted-foreground",e),...t}));Vm.displayName=Im.displayName;const qm=h.forwardRef(({className:e,...t},n)=>r.jsx(on,{ref:n,className:X("flex h-full w-full flex-col overflow-hidden rounded-md border border-neutral-700/80 bg-neutral-950 text-popover-foreground",e),...t}));qm.displayName=on.displayName;const Wm=({children:e,title:t="Command dialog",description:n="Search and select available commands.",...s})=>r.jsx(lT,{...s,children:r.jsxs(Hm,{className:"overflow-hidden border-neutral-700/80 bg-neutral-950 p-0 shadow-[0_35px_90px_rgba(0,0,0,0.8)]",children:[r.jsx(Um,{className:"sr-only",children:t}),r.jsx(Vm,{className:"sr-only",children:n}),r.jsx(qm,{className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})]})}),Gm=h.forwardRef(({className:e,...t},n)=>r.jsxs("div",{className:"flex items-center border-b border-neutral-700/80 bg-neutral-950 px-3","cmdk-input-wrapper":"",children:[r.jsx(Jr,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),r.jsx(on.Input,{ref:n,className:X("flex h-10 w-full rounded-md bg-transparent py-3 text-sm text-neutral-100 outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})),Km=h.forwardRef(({className:e,...t},n)=>r.jsx(on.List,{ref:n,className:X("max-h-[300px] overflow-y-auto overflow-x-hidden bg-neutral-950",e),...t})),Ym=h.forwardRef((e,t)=>r.jsx(on.Empty,{ref:t,className:"py-6 text-center text-sm text-neutral-300",...e})),Gt=h.forwardRef(({className:e,...t},n)=>r.jsx(on.Group,{ref:n,className:X("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t})),uT=h.forwardRef(({className:e,...t},n)=>r.jsx(on.Separator,{ref:n,className:X("-mx-1 h-px bg-border",e),...t})),We=h.forwardRef(({className:e,...t},n)=>r.jsx(on.Item,{ref:n,className:X("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-neutral-800/90 aria-selected:text-neutral-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t})),Mu=({className:e,...t})=>r.jsx("span",{className:X("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});let Cs=null,Iu=null;function dT(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem("apparatus-base-url");return e?e.replace(/\/+$/,""):null}catch{return null}}function hT(){const e=dT();return e?`${e}/api/docs-index`:"/api/docs-index"}async function yl(){const e=hT();if(Cs!==null&&Iu===e)return Cs;try{const t=await fetch(e);if(!t.ok)throw new Error("Failed to load docs index");const n=await t.json();if(!Array.isArray(n))throw new Error("Invalid docs index payload");return Cs=n,Iu=e,Cs}catch(t){return console.error("Failed to load docs index:",t),[]}}function Ts(e,t){const n=e.toLowerCase(),s=t.toLowerCase();if(s===n)return 100;if(s.startsWith(n))return 80;if(s.match(new RegExp(`\\b${n}`,"i")))return 60;if(s.includes(n))return 40;let a=0,o=0;for(let i=0;i<s.length&&o<n.length;i++)s[i]===n[o]&&(a++,o++);return o===n.length?Math.max(10,Math.round(a/s.length*30)):0}async function Xm(e){const t=await yl()||[];if(!e.trim())return t.map(s=>({...s,score:0,matchType:"title"}));const n=[];for(const s of t){let a=0,o="content";const i=Ts(e,s.title);i>0&&(a=Math.max(a,i+30),o="title");for(const d of s.headings){const f=Ts(e,d);f>0&&(a=Math.max(a,f+15),o="heading")}const l=Ts(e,s.excerpt),u=Ts(e,s.content),c=Math.max(l,u);c>0&&a===0&&(a=c,o="content"),a>0&&n.push({...s,score:a,matchType:o})}return n.sort((s,a)=>a.score-s.score),n.slice(0,10)}const $n="apparatus:search-analytics",fT=100;function Zm(){const e=h.useCallback((o,i,l,u)=>{try{const c=JSON.parse(localStorage.getItem($n)||"[]"),f=[{query:o,timestamp:Date.now(),resultsFound:i,category:u,source:l},...c].slice(0,fT);localStorage.setItem($n,JSON.stringify(f))}catch(c){console.warn("Failed to track search analytics:",c)}},[]),t=h.useCallback((o,i)=>{try{const l=JSON.parse(localStorage.getItem($n)||"[]");l.length>0&&(l[0].viewedDocId=o,l[0].viewDuration=i,localStorage.setItem($n,JSON.stringify(l)))}catch(l){console.warn("Failed to track doc view:",l)}},[]),n=h.useCallback(()=>{try{return JSON.parse(localStorage.getItem($n)||"[]")}catch{return[]}},[]),s=h.useCallback(()=>{const o=n();if(o.length===0)return{totalSearches:0,avgResultsFound:0,emptySearchResults:0,emptySearchRate:0,topQueries:[],topCategories:[],sourceBreakdown:{"command-palette":0,"help-modal":0},avgViewDuration:0};const i=o.length,l=o.filter(y=>y.resultsFound===0).length,u=o.reduce((y,b)=>y+b.resultsFound,0)/i,c=new Map;o.forEach(y=>{c.set(y.query,(c.get(y.query)||0)+1)});const d=Array.from(c.entries()).sort((y,b)=>b[1]-y[1]).slice(0,5).map(([y,b])=>({query:y,count:b})),f=new Map;o.forEach(y=>{y.category&&f.set(y.category,(f.get(y.category)||0)+1)});const p=Array.from(f.entries()).sort((y,b)=>b[1]-y[1]).map(([y,b])=>({category:y,count:b})),x={"command-palette":o.filter(y=>y.source==="command-palette").length,"help-modal":o.filter(y=>y.source==="help-modal").length},g=o.filter(y=>y.viewDuration),m=g.length>0?g.reduce((y,b)=>y+(b.viewDuration||0),0)/g.length:0;return{totalSearches:i,avgResultsFound:Math.round(u*10)/10,emptySearchResults:l,emptySearchRate:Math.round(l/i*100),topQueries:d,topCategories:p,sourceBreakdown:x,avgViewDuration:Math.round(m)}},[n]),a=h.useCallback(()=>{try{localStorage.removeItem($n)}catch(o){console.warn("Failed to clear analytics:",o)}},[]);return{trackSearch:e,trackDocView:t,getAnalytics:n,getStats:s,clearAnalytics:a}}function pT({query:e,onSelect:t}){const[n,s]=h.useState([]),[a,o]=h.useState(!1),[i,l]=h.useState(null),{trackSearch:u}=Zm();return h.useEffect(()=>{if(!e.trim()){s([]);return}o(!0),l(null),Xm(e).then(c=>{const d=c;s(d),u(e,d.length,"command-palette")}).catch(c=>{console.error("Search error:",c),l("Failed to search documentation"),u(e,0,"command-palette")}).finally(()=>{o(!1)})},[e]),e.trim()?a?r.jsx(Gt,{heading:"Help",children:r.jsx("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:"Searching documentation..."})}):i?r.jsx(Gt,{heading:"Help",children:r.jsxs("div",{className:"px-2 py-2 text-sm text-destructive flex items-center gap-2",children:[r.jsx(vi,{className:"h-4 w-4"}),i]})}):n.length===0?r.jsx(Gt,{heading:"Help",children:r.jsxs("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:['No documentation found for "',e,'"']})}):r.jsx(Gt,{heading:`Help (${n.length} result${n.length!==1?"s":""})`,children:n.map(c=>r.jsxs(We,{value:`${c.id} ${c.title} ${c.category} ${e}`,onSelect:()=>{console.log("Help result selected:",c.id,c.title),t==null||t(c.id)},onClick:()=>{console.log("Help result clicked:",c.id,c.title),t==null||t(c.id)},className:"flex flex-col items-start gap-1 py-3 cursor-pointer hover:bg-neutral-800/50",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsx(lr,{className:"h-4 w-4 flex-shrink-0 text-blue-500"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"font-medium truncate",children:c.title}),r.jsx("div",{className:"text-xs text-muted-foreground",children:c.category})]}),c.matchType==="title"&&r.jsx("span",{className:"text-xs bg-blue-100 dark:bg-blue-900 text-blue-900 dark:text-blue-100 px-2 py-0.5 rounded",children:"Title match"})]}),r.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 w-full",children:c.excerpt})]},c.id))}):r.jsx(Gt,{heading:"Help",children:r.jsxs("div",{className:"px-2 py-2 text-sm text-muted-foreground",children:["Type ",r.jsx("span",{className:"font-mono text-neutral-300",children:"help <topic>"}),", e.g."," ",r.jsx("span",{className:"font-mono text-neutral-300",children:"help chaos"})]})})}function mT(){var p;const[e,t]=h.useState(!1),[n,s]=h.useState(""),a=Ju(),{toggleTheme:o}=Pd(),{openDoc:i}=Ai(),l=n.trimStart().match(/^\/?help(?:\s+(.*))?$/i),u=!!l,c=((p=l==null?void 0:l[1])==null?void 0:p.trim())??"";h.useEffect(()=>{const x=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),t(y=>!y))},g=()=>t(!0);return document.addEventListener("keydown",x),window.addEventListener("apparatus:open-command-palette",g),()=>{document.removeEventListener("keydown",x),window.removeEventListener("apparatus:open-command-palette",g)}},[]);const d=h.useCallback(x=>{t(!1),x()},[]),f=x=>{s(""),t(!1),i(x)};return r.jsxs(Wm,{open:e,onOpenChange:x=>{t(x),x||s("")},title:"Command palette",description:"Search and run dashboard navigation and system commands.",children:[r.jsx(Gm,{placeholder:"Type a command or search... (try 'help chaos')",value:n,onValueChange:s}),r.jsxs(Km,{children:[!u&&r.jsx(Ym,{children:"No results found."}),u&&r.jsx(pT,{query:c,onSelect:f}),!u&&r.jsxs(r.Fragment,{children:[r.jsxs(Gt,{heading:"Navigation",children:[r.jsxs(We,{onSelect:()=>d(()=>a("/")),children:[r.jsx(id,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Overview"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/docs")),children:[r.jsx(lr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Documentation Hub"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/traffic")),children:[r.jsx(dt,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Traffic Console"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/fingerprints")),children:[r.jsx(Fe,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Attacker Fingerprints"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/defense")),children:[r.jsx(Qr,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Defense Rules"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/chaos")),children:[r.jsx(It,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Chaos Lab"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/cluster")),children:[r.jsx(ba,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Cluster Map"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/dependencies")),children:[r.jsx(ji,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Supply Chain"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/identity")),children:[r.jsx(wi,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Identity Token Forge"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/webhooks")),children:[r.jsx(Ci,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Webhook Inspector"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/listeners")),children:[r.jsx(ki,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Infrastructure Listeners"})]})]}),r.jsx(uT,{}),r.jsxs(Gt,{heading:"System",children:[r.jsxs(We,{onSelect:()=>d(()=>o()),children:[r.jsx(Jg,{className:"mr-2 h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),r.jsx(Wg,{className:"absolute mr-2 h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),r.jsx("span",{children:"Toggle Theme"}),r.jsx(Mu,{children:"⌘T"})]}),r.jsxs(We,{onSelect:()=>d(()=>a("/settings")),children:[r.jsx(Ei,{className:"mr-2 h-4 w-4"}),r.jsx("span",{children:"Settings"}),r.jsx(Mu,{children:"⌘S"})]})]})]})]})]})}function xT(e){if(!e.metaKey&&!e.ctrlKey)return!1;const t=e.key.toLowerCase();return t==="?"||t==="/"||e.code==="Slash"}function gT({open:e,onOpenChange:t,onSelectDoc:n}){const[s,a]=h.useState(""),[o,i]=h.useState([]),[l,u]=h.useState([]),[c,d]=h.useState(!1),[f,p]=h.useState(null),[x,g]=h.useState([]),{openDoc:m}=Ai(),{trackSearch:y}=Zm();h.useEffect(()=>{const v=()=>t(!0),N=w=>{xT(w)&&(w.preventDefault(),t(!0))};return document.addEventListener("keydown",N,!0),window.addEventListener("apparatus:open-help-modal",v),()=>{document.removeEventListener("keydown",N,!0),window.removeEventListener("apparatus:open-help-modal",v)}},[t]),h.useEffect(()=>{e||(a(""),p(null))},[e]),h.useEffect(()=>{if(!s.trim()){u([]),i([]),g([]),p(null);return}d(!0);const v=setTimeout(()=>{Xm(s).then(N=>{const w=N;u(w),i(w),y(s,w.length,"help-modal");const j=Array.from(new Set(w.map(k=>k.category))).sort();g(j)}).catch(N=>{console.error("Search error:",N),u([]),i([]),g([]),y(s,0,"help-modal")}).finally(()=>{d(!1)})},150);return()=>clearTimeout(v)},[s]),h.useEffect(()=>{i(f?l.filter(v=>v.category===f):l)},[f,l]);const b=v=>{m(v.id),n==null||n(v.id),t(!1)};return r.jsxs(Wm,{open:e,onOpenChange:t,title:"Documentation search",description:"Search and open dashboard documentation pages.",children:[r.jsx(Gm,{placeholder:"Search documentation...",value:s,onValueChange:a}),x.length>0&&r.jsxs("div",{className:"flex flex-wrap gap-1.5 p-3 border-b border-neutral-700/80 bg-neutral-950",children:[r.jsx("button",{onClick:()=>p(null),className:`text-[10px] font-mono uppercase tracking-widest px-2 py-1 border rounded-[1px] transition-all ${f===null?"bg-primary border-primary text-primary-foreground font-bold shadow-glow-primary":"bg-neutral-900/85 border-neutral-700 text-neutral-300 hover:text-neutral-100 hover:bg-neutral-800 hover:border-neutral-500"}`,children:"All"}),x.map(v=>r.jsx("button",{onClick:()=>p(v),className:`text-[10px] font-mono uppercase tracking-widest px-2 py-1 border rounded-[1px] transition-all ${f===v?"bg-primary border-primary text-primary-foreground font-bold shadow-glow-primary":"bg-neutral-900/85 border-neutral-700 text-neutral-300 hover:text-neutral-100 hover:bg-neutral-800 hover:border-neutral-500"}`,children:v},v))]}),r.jsxs(Km,{className:"max-h-[60vh]",children:[c&&r.jsxs("div",{className:"flex items-center justify-center gap-3 py-12 text-muted-foreground font-mono text-xs uppercase tracking-widest",children:[r.jsx(cd,{className:"h-4 w-4 animate-spin text-primary"}),r.jsx("span",{children:"Retrieving Knowledge Base..."})]}),s.trim()&&r.jsxs(Ym,{className:"py-12 text-center",children:[r.jsxs("p",{className:"text-sm text-neutral-300",children:['No documentation found for "',s,'"']}),r.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono uppercase tracking-widest",children:"Try searching for: chaos, scenarios, defense"})]}),!c&&o.length>0&&r.jsx(Gt,{heading:`Knowledge Base (${o.length} result${o.length!==1?"s":""})`,children:o.map(v=>r.jsxs(We,{value:`${v.id} ${v.title} ${v.category} ${s}`,onSelect:()=>b(v),className:"flex flex-col items-start gap-1 py-4 px-4 cursor-pointer",children:[r.jsxs("div",{className:"flex items-center gap-2 w-full",children:[r.jsx(lr,{className:"h-4 w-4 flex-shrink-0 text-primary/70"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"font-bold text-sm text-neutral-100 uppercase tracking-tight",children:v.title}),r.jsx("div",{className:"text-[10px] text-muted-foreground font-mono uppercase tracking-widest",children:v.category})]}),v.matchType==="title"&&r.jsx("span",{className:"text-[9px] font-mono bg-primary/10 text-primary border border-primary/20 px-1.5 py-0.5 rounded-[1px] uppercase tracking-tighter",children:"Title match"})]}),r.jsx("p",{className:"text-xs text-neutral-400 line-clamp-2 w-full mt-1 leading-relaxed",children:v.excerpt})]},v.id))}),!c&&!s&&r.jsxs("div",{className:"py-12 text-center text-muted-foreground border-t border-neutral-700/40 bg-neutral-950",children:[r.jsx("p",{className:"text-xs font-mono uppercase tracking-widest",children:"Awaiting search query..."}),r.jsxs("div",{className:"mt-6 space-y-3",children:[r.jsx("p",{className:"text-[10px] uppercase tracking-[0.2em] text-neutral-600",children:"Common Subjects"}),r.jsx("div",{className:"flex justify-center gap-2 flex-wrap px-8",children:["chaos","scenarios","defense","webhooks","architecture"].map(v=>r.jsx("button",{onClick:()=>a(v),className:"px-2 py-1 text-[10px] font-mono uppercase border border-neutral-700 bg-neutral-900/85 text-neutral-300 hover:text-primary hover:border-primary/50 hover:bg-neutral-800 transition-all rounded-[1px]",children:v},v))})]})]})]}),r.jsx("div",{className:"border-t border-neutral-700/50 px-4 py-2 text-[10px] font-mono text-neutral-500 flex items-center justify-between uppercase tracking-widest bg-neutral-950",children:r.jsxs("div",{className:"flex gap-4",children:[r.jsxs("span",{children:[r.jsx("span",{className:"text-neutral-400",children:"↑↓"})," Navigate"]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-neutral-400",children:"Enter"})," Select"]}),r.jsxs("span",{children:[r.jsx("span",{className:"text-neutral-400",children:"Esc"})," Close"]})]})})]})}function Jm(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach(t=>{const n=e[t],s=typeof n;(s==="object"||s==="function")&&!Object.isFrozen(n)&&Jm(n)}),e}class Pu{constructor(t){t.data===void 0&&(t.data={}),this.data=t.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function Qm(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Kt(e,...t){const n=Object.create(null);for(const s in e)n[s]=e[s];return t.forEach(function(s){for(const a in s)n[a]=s[a]}),n}const yT="</span>",Ou=e=>!!e.scope,bT=(e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const n=e.split(".");return[`${t}${n.shift()}`,...n.map((s,a)=>`${s}${"_".repeat(a+1)}`)].join(" ")}return`${t}${e}`};class vT{constructor(t,n){this.buffer="",this.classPrefix=n.classPrefix,t.walk(this)}addText(t){this.buffer+=Qm(t)}openNode(t){if(!Ou(t))return;const n=bT(t.scope,{prefix:this.classPrefix});this.span(n)}closeNode(t){Ou(t)&&(this.buffer+=yT)}value(){return this.buffer}span(t){this.buffer+=`<span class="${t}">`}}const Lu=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class bl{constructor(){this.rootNode=Lu(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(t){this.top.children.push(t)}openNode(t){const n=Lu({scope:t});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(t){return this.constructor._walk(t,this.rootNode)}static _walk(t,n){return typeof n=="string"?t.addText(n):n.children&&(t.openNode(n),n.children.forEach(s=>this._walk(t,s)),t.closeNode(n)),t}static _collapse(t){typeof t!="string"&&t.children&&(t.children.every(n=>typeof n=="string")?t.children=[t.children.join("")]:t.children.forEach(n=>{bl._collapse(n)}))}}class wT extends bl{constructor(t){super(),this.options=t}addText(t){t!==""&&this.add(t)}startScope(t){this.openNode(t)}endScope(){this.closeNode()}__addSublanguage(t,n){const s=t.root;n&&(s.scope=`language:${n}`),this.add(s)}toHTML(){return new vT(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function Yr(e){return e?typeof e=="string"?e:e.source:null}function ex(e){return Tn("(?=",e,")")}function NT(e){return Tn("(?:",e,")*")}function ST(e){return Tn("(?:",e,")?")}function Tn(...e){return e.map(n=>Yr(n)).join("")}function jT(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function vl(...e){return"("+(jT(e).capture?"":"?:")+e.map(s=>Yr(s)).join("|")+")"}function tx(e){return new RegExp(e.toString()+"|").exec("").length-1}function kT(e,t){const n=e&&e.exec(t);return n&&n.index===0}const ET=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function wl(e,{joinWith:t}){let n=0;return e.map(s=>{n+=1;const a=n;let o=Yr(s),i="";for(;o.length>0;){const l=ET.exec(o);if(!l){i+=o;break}i+=o.substring(0,l.index),o=o.substring(l.index+l[0].length),l[0][0]==="\\"&&l[1]?i+="\\"+String(Number(l[1])+a):(i+=l[0],l[0]==="("&&n++)}return i}).map(s=>`(${s})`).join(t)}const _T=/\b\B/,nx="[a-zA-Z]\\w*",Nl="[a-zA-Z_]\\w*",rx="\\b\\d+(\\.\\d+)?",sx="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",ax="\\b(0b[01]+)",CT="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",TT=(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=Tn(t,/.*\b/,e.binary,/\b.*/)),Kt({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(n,s)=>{n.index!==0&&s.ignoreMatch()}},e)},Xr={begin:"\\\\[\\s\\S]",relevance:0},RT={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Xr]},AT={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Xr]},MT={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Ha=function(e,t,n={}){const s=Kt({scope:"comment",begin:e,end:t,contains:[]},n);s.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const a=vl("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return s.contains.push({begin:Tn(/[ ]+/,"(",a,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),s},IT=Ha("//","$"),PT=Ha("/\\*","\\*/"),OT=Ha("#","$"),LT={scope:"number",begin:rx,relevance:0},DT={scope:"number",begin:sx,relevance:0},$T={scope:"number",begin:ax,relevance:0},zT={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Xr,{begin:/\[/,end:/\]/,relevance:0,contains:[Xr]}]},FT={scope:"title",begin:nx,relevance:0},BT={scope:"title",begin:Nl,relevance:0},HT={begin:"\\.\\s*"+Nl,relevance:0},UT=function(e){return Object.assign(e,{"on:begin":(t,n)=>{n.data._beginMatch=t[1]},"on:end":(t,n)=>{n.data._beginMatch!==t[1]&&n.ignoreMatch()}})};var Rs=Object.freeze({__proto__:null,APOS_STRING_MODE:RT,BACKSLASH_ESCAPE:Xr,BINARY_NUMBER_MODE:$T,BINARY_NUMBER_RE:ax,COMMENT:Ha,C_BLOCK_COMMENT_MODE:PT,C_LINE_COMMENT_MODE:IT,C_NUMBER_MODE:DT,C_NUMBER_RE:sx,END_SAME_AS_BEGIN:UT,HASH_COMMENT_MODE:OT,IDENT_RE:nx,MATCH_NOTHING_RE:_T,METHOD_GUARD:HT,NUMBER_MODE:LT,NUMBER_RE:rx,PHRASAL_WORDS_MODE:MT,QUOTE_STRING_MODE:AT,REGEXP_MODE:zT,RE_STARTERS_RE:CT,SHEBANG:TT,TITLE_MODE:FT,UNDERSCORE_IDENT_RE:Nl,UNDERSCORE_TITLE_MODE:BT});function VT(e,t){e.input[e.index-1]==="."&&t.ignoreMatch()}function qT(e,t){e.className!==void 0&&(e.scope=e.className,delete e.className)}function WT(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=VT,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,e.relevance===void 0&&(e.relevance=0))}function GT(e,t){Array.isArray(e.illegal)&&(e.illegal=vl(...e.illegal))}function KT(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function YT(e,t){e.relevance===void 0&&(e.relevance=1)}const XT=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const n=Object.assign({},e);Object.keys(e).forEach(s=>{delete e[s]}),e.keywords=n.keywords,e.begin=Tn(n.beforeMatch,ex(n.begin)),e.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},e.relevance=0,delete n.beforeMatch},ZT=["of","and","for","in","not","or","if","then","parent","list","value"],JT="keyword";function ox(e,t,n=JT){const s=Object.create(null);return typeof e=="string"?a(n,e.split(" ")):Array.isArray(e)?a(n,e):Object.keys(e).forEach(function(o){Object.assign(s,ox(e[o],t,o))}),s;function a(o,i){t&&(i=i.map(l=>l.toLowerCase())),i.forEach(function(l){const u=l.split("|");s[u[0]]=[o,QT(u[0],u[1])]})}}function QT(e,t){return t?Number(t):eR(e)?0:1}function eR(e){return ZT.includes(e.toLowerCase())}const Du={},bn=e=>{console.error(e)},$u=(e,...t)=>{console.log(`WARN: ${e}`,...t)},zn=(e,t)=>{Du[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),Du[`${e}/${t}`]=!0)},ha=new Error;function ix(e,t,{key:n}){let s=0;const a=e[n],o={},i={};for(let l=1;l<=t.length;l++)i[l+s]=a[l],o[l+s]=!0,s+=tx(t[l-1]);e[n]=i,e[n]._emit=o,e[n]._multi=!0}function tR(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw bn("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ha;if(typeof e.beginScope!="object"||e.beginScope===null)throw bn("beginScope must be object"),ha;ix(e,e.begin,{key:"beginScope"}),e.begin=wl(e.begin,{joinWith:""})}}function nR(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw bn("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ha;if(typeof e.endScope!="object"||e.endScope===null)throw bn("endScope must be object"),ha;ix(e,e.end,{key:"endScope"}),e.end=wl(e.end,{joinWith:""})}}function rR(e){e.scope&&typeof e.scope=="object"&&e.scope!==null&&(e.beginScope=e.scope,delete e.scope)}function sR(e){rR(e),typeof e.beginScope=="string"&&(e.beginScope={_wrap:e.beginScope}),typeof e.endScope=="string"&&(e.endScope={_wrap:e.endScope}),tR(e),nR(e)}function aR(e){function t(i,l){return new RegExp(Yr(i),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(l?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(l,u){u.position=this.position++,this.matchIndexes[this.matchAt]=u,this.regexes.push([u,l]),this.matchAt+=tx(l)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const l=this.regexes.map(u=>u[1]);this.matcherRe=t(wl(l,{joinWith:"|"}),!0),this.lastIndex=0}exec(l){this.matcherRe.lastIndex=this.lastIndex;const u=this.matcherRe.exec(l);if(!u)return null;const c=u.findIndex((f,p)=>p>0&&f!==void 0),d=this.matchIndexes[c];return u.splice(0,c),Object.assign(u,d)}}class s{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(l){if(this.multiRegexes[l])return this.multiRegexes[l];const u=new n;return this.rules.slice(l).forEach(([c,d])=>u.addRule(c,d)),u.compile(),this.multiRegexes[l]=u,u}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(l,u){this.rules.push([l,u]),u.type==="begin"&&this.count++}exec(l){const u=this.getMatcher(this.regexIndex);u.lastIndex=this.lastIndex;let c=u.exec(l);if(this.resumingScanAtSamePosition()&&!(c&&c.index===this.lastIndex)){const d=this.getMatcher(0);d.lastIndex=this.lastIndex+1,c=d.exec(l)}return c&&(this.regexIndex+=c.position+1,this.regexIndex===this.count&&this.considerAll()),c}}function a(i){const l=new s;return i.contains.forEach(u=>l.addRule(u.begin,{rule:u,type:"begin"})),i.terminatorEnd&&l.addRule(i.terminatorEnd,{type:"end"}),i.illegal&&l.addRule(i.illegal,{type:"illegal"}),l}function o(i,l){const u=i;if(i.isCompiled)return u;[qT,KT,sR,XT].forEach(d=>d(i,l)),e.compilerExtensions.forEach(d=>d(i,l)),i.__beforeBegin=null,[WT,GT,YT].forEach(d=>d(i,l)),i.isCompiled=!0;let c=null;return typeof i.keywords=="object"&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords),c=i.keywords.$pattern,delete i.keywords.$pattern),c=c||/\w+/,i.keywords&&(i.keywords=ox(i.keywords,e.case_insensitive)),u.keywordPatternRe=t(c,!0),l&&(i.begin||(i.begin=/\B|\b/),u.beginRe=t(u.begin),!i.end&&!i.endsWithParent&&(i.end=/\B|\b/),i.end&&(u.endRe=t(u.end)),u.terminatorEnd=Yr(u.end)||"",i.endsWithParent&&l.terminatorEnd&&(u.terminatorEnd+=(i.end?"|":"")+l.terminatorEnd)),i.illegal&&(u.illegalRe=t(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map(function(d){return oR(d==="self"?i:d)})),i.contains.forEach(function(d){o(d,u)}),i.starts&&o(i.starts,l),u.matcher=a(u),u}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=Kt(e.classNameAliases||{}),o(e)}function lx(e){return e?e.endsWithParent||lx(e.starts):!1}function oR(e){return e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map(function(t){return Kt(e,{variants:null},t)})),e.cachedVariants?e.cachedVariants:lx(e)?Kt(e,{starts:e.starts?Kt(e.starts):null}):Object.isFrozen(e)?Kt(e):e}var iR="11.11.1";class lR extends Error{constructor(t,n){super(t),this.name="HTMLInjectionError",this.html=n}}const _o=Qm,zu=Kt,Fu=Symbol("nomatch"),cR=7,cx=function(e){const t=Object.create(null),n=Object.create(null),s=[];let a=!0;const o="Could not find the language '{}', did you forget to load/include a language module?",i={disableAutodetect:!0,name:"Plain text",contains:[]};let l={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:wT};function u(E){return l.noHighlightRe.test(E)}function c(E){let A=E.className+" ";A+=E.parentNode?E.parentNode.className:"";const O=l.languageDetectRe.exec(A);if(O){const I=P(O[1]);return I||($u(o.replace("{}",O[1])),$u("Falling back to no-highlight mode for this block.",E)),I?O[1]:"no-highlight"}return A.split(/\s+/).find(I=>u(I)||P(I))}function d(E,A,O){let I="",F="";typeof A=="object"?(I=E,O=A.ignoreIllegals,F=A.language):(zn("10.7.0","highlight(lang, code, ...args) has been deprecated."),zn("10.7.0",`Please use highlight(code, options) instead.
|
|
588
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),F=E,I=A),O===void 0&&(O=!0);const L={code:I,language:F};S("before:highlight",L);const M=L.result?L.result:f(L.language,L.code,O);return M.code=L.code,S("after:highlight",M),M}function f(E,A,O,I){const F=Object.create(null);function L(U,K){return U.keywords[K]}function M(){if(!Y.keywords){Te.addText(be);return}let U=0;Y.keywordPatternRe.lastIndex=0;let K=Y.keywordPatternRe.exec(be),ne="";for(;K;){ne+=be.substring(U,K.index);const pe=fe.case_insensitive?K[0].toLowerCase():K[0],Ee=L(Y,pe);if(Ee){const[_e,Ze]=Ee;if(Te.addText(ne),ne="",F[pe]=(F[pe]||0)+1,F[pe]<=cR&&(Xe+=Ze),_e.startsWith("_"))ne+=K[0];else{const kt=fe.classNameAliases[_e]||_e;V(K[0],kt)}}else ne+=K[0];U=Y.keywordPatternRe.lastIndex,K=Y.keywordPatternRe.exec(be)}ne+=be.substring(U),Te.addText(ne)}function z(){if(be==="")return;let U=null;if(typeof Y.subLanguage=="string"){if(!t[Y.subLanguage]){Te.addText(be);return}U=f(Y.subLanguage,be,!0,Pe[Y.subLanguage]),Pe[Y.subLanguage]=U._top}else U=x(be,Y.subLanguage.length?Y.subLanguage:null);Y.relevance>0&&(Xe+=U.relevance),Te.__addSublanguage(U._emitter,U.language)}function H(){Y.subLanguage!=null?z():M(),be=""}function V(U,K){U!==""&&(Te.startScope(K),Te.addText(U),Te.endScope())}function Z(U,K){let ne=1;const pe=K.length-1;for(;ne<=pe;){if(!U._emit[ne]){ne++;continue}const Ee=fe.classNameAliases[U[ne]]||U[ne],_e=K[ne];Ee?V(_e,Ee):(be=_e,M(),be=""),ne++}}function G(U,K){return U.scope&&typeof U.scope=="string"&&Te.openNode(fe.classNameAliases[U.scope]||U.scope),U.beginScope&&(U.beginScope._wrap?(V(be,fe.classNameAliases[U.beginScope._wrap]||U.beginScope._wrap),be=""):U.beginScope._multi&&(Z(U.beginScope,K),be="")),Y=Object.create(U,{parent:{value:Y}}),Y}function J(U,K,ne){let pe=kT(U.endRe,ne);if(pe){if(U["on:end"]){const Ee=new Pu(U);U["on:end"](K,Ee),Ee.isMatchIgnored&&(pe=!1)}if(pe){for(;U.endsParent&&U.parent;)U=U.parent;return U}}if(U.endsWithParent)return J(U.parent,K,ne)}function ee(U){return Y.matcher.regexIndex===0?(be+=U[0],1):(tt=!0,0)}function te(U){const K=U[0],ne=U.rule,pe=new Pu(ne),Ee=[ne.__beforeBegin,ne["on:begin"]];for(const _e of Ee)if(_e&&(_e(U,pe),pe.isMatchIgnored))return ee(K);return ne.skip?be+=K:(ne.excludeBegin&&(be+=K),H(),!ne.returnBegin&&!ne.excludeBegin&&(be=K)),G(ne,U),ne.returnBegin?0:K.length}function oe(U){const K=U[0],ne=A.substring(U.index),pe=J(Y,U,ne);if(!pe)return Fu;const Ee=Y;Y.endScope&&Y.endScope._wrap?(H(),V(K,Y.endScope._wrap)):Y.endScope&&Y.endScope._multi?(H(),Z(Y.endScope,U)):Ee.skip?be+=K:(Ee.returnEnd||Ee.excludeEnd||(be+=K),H(),Ee.excludeEnd&&(be=K));do Y.scope&&Te.closeNode(),!Y.skip&&!Y.subLanguage&&(Xe+=Y.relevance),Y=Y.parent;while(Y!==pe.parent);return pe.starts&&G(pe.starts,U),Ee.returnEnd?0:K.length}function ie(){const U=[];for(let K=Y;K!==fe;K=K.parent)K.scope&&U.unshift(K.scope);U.forEach(K=>Te.openNode(K))}let me={};function W(U,K){const ne=K&&K[0];if(be+=U,ne==null)return H(),0;if(me.type==="begin"&&K.type==="end"&&me.index===K.index&&ne===""){if(be+=A.slice(K.index,K.index+1),!a){const pe=new Error(`0 width match regex (${E})`);throw pe.languageName=E,pe.badRule=me.rule,pe}return 1}if(me=K,K.type==="begin")return te(K);if(K.type==="illegal"&&!O){const pe=new Error('Illegal lexeme "'+ne+'" for mode "'+(Y.scope||"<unnamed>")+'"');throw pe.mode=Y,pe}else if(K.type==="end"){const pe=oe(K);if(pe!==Fu)return pe}if(K.type==="illegal"&&ne==="")return be+=`
|
|
589
|
+
`,1;if(Ve>1e5&&Ve>K.index*3)throw new Error("potential infinite loop, way more iterations than matches");return be+=ne,ne.length}const fe=P(E);if(!fe)throw bn(o.replace("{}",E)),new Error('Unknown language: "'+E+'"');const Ae=aR(fe);let ge="",Y=I||Ae;const Pe={},Te=new l.__emitter(l);ie();let be="",Xe=0,He=0,Ve=0,tt=!1;try{if(fe.__emitTokens)fe.__emitTokens(A,Te);else{for(Y.matcher.considerAll();;){Ve++,tt?tt=!1:Y.matcher.considerAll(),Y.matcher.lastIndex=He;const U=Y.matcher.exec(A);if(!U)break;const K=A.substring(He,U.index),ne=W(K,U);He=U.index+ne}W(A.substring(He))}return Te.finalize(),ge=Te.toHTML(),{language:E,value:ge,relevance:Xe,illegal:!1,_emitter:Te,_top:Y}}catch(U){if(U.message&&U.message.includes("Illegal"))return{language:E,value:_o(A),illegal:!0,relevance:0,_illegalBy:{message:U.message,index:He,context:A.slice(He-100,He+100),mode:U.mode,resultSoFar:ge},_emitter:Te};if(a)return{language:E,value:_o(A),illegal:!1,relevance:0,errorRaised:U,_emitter:Te,_top:Y};throw U}}function p(E){const A={value:_o(E),illegal:!1,relevance:0,_top:i,_emitter:new l.__emitter(l)};return A._emitter.addText(E),A}function x(E,A){A=A||l.languages||Object.keys(t);const O=p(E),I=A.filter(P).filter($).map(H=>f(H,E,!1));I.unshift(O);const F=I.sort((H,V)=>{if(H.relevance!==V.relevance)return V.relevance-H.relevance;if(H.language&&V.language){if(P(H.language).supersetOf===V.language)return 1;if(P(V.language).supersetOf===H.language)return-1}return 0}),[L,M]=F,z=L;return z.secondBest=M,z}function g(E,A,O){const I=A&&n[A]||O;E.classList.add("hljs"),E.classList.add(`language-${I}`)}function m(E){let A=null;const O=c(E);if(u(O))return;if(S("before:highlightElement",{el:E,language:O}),E.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",E);return}if(E.children.length>0&&(l.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(E)),l.throwUnescapedHTML))throw new lR("One of your code blocks includes unescaped HTML.",E.innerHTML);A=E;const I=A.textContent,F=O?d(I,{language:O,ignoreIllegals:!0}):x(I);E.innerHTML=F.value,E.dataset.highlighted="yes",g(E,O,F.language),E.result={language:F.language,re:F.relevance,relevance:F.relevance},F.secondBest&&(E.secondBest={language:F.secondBest.language,relevance:F.secondBest.relevance}),S("after:highlightElement",{el:E,result:F,text:I})}function y(E){l=zu(l,E)}const b=()=>{w(),zn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function v(){w(),zn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let N=!1;function w(){function E(){w()}if(document.readyState==="loading"){N||window.addEventListener("DOMContentLoaded",E,!1),N=!0;return}document.querySelectorAll(l.cssSelector).forEach(m)}function j(E,A){let O=null;try{O=A(e)}catch(I){if(bn("Language definition for '{}' could not be registered.".replace("{}",E)),a)bn(I);else throw I;O=i}O.name||(O.name=E),t[E]=O,O.rawDefinition=A.bind(null,e),O.aliases&&T(O.aliases,{languageName:E})}function k(E){delete t[E];for(const A of Object.keys(n))n[A]===E&&delete n[A]}function _(){return Object.keys(t)}function P(E){return E=(E||"").toLowerCase(),t[E]||t[n[E]]}function T(E,{languageName:A}){typeof E=="string"&&(E=[E]),E.forEach(O=>{n[O.toLowerCase()]=A})}function $(E){const A=P(E);return A&&!A.disableAutodetect}function B(E){E["before:highlightBlock"]&&!E["before:highlightElement"]&&(E["before:highlightElement"]=A=>{E["before:highlightBlock"](Object.assign({block:A.el},A))}),E["after:highlightBlock"]&&!E["after:highlightElement"]&&(E["after:highlightElement"]=A=>{E["after:highlightBlock"](Object.assign({block:A.el},A))})}function D(E){B(E),s.push(E)}function R(E){const A=s.indexOf(E);A!==-1&&s.splice(A,1)}function S(E,A){const O=E;s.forEach(function(I){I[O]&&I[O](A)})}function C(E){return zn("10.7.0","highlightBlock will be removed entirely in v12.0"),zn("10.7.0","Please use highlightElement now."),m(E)}Object.assign(e,{highlight:d,highlightAuto:x,highlightAll:w,highlightElement:m,highlightBlock:C,configure:y,initHighlighting:b,initHighlightingOnLoad:v,registerLanguage:j,unregisterLanguage:k,listLanguages:_,getLanguage:P,registerAliases:T,autoDetection:$,inherit:zu,addPlugin:D,removePlugin:R}),e.debugMode=function(){a=!1},e.safeMode=function(){a=!0},e.versionString=iR,e.regex={concat:Tn,lookahead:ex,either:vl,optional:ST,anyNumberOfTimes:NT};for(const E in Rs)typeof Rs[E]=="object"&&Jm(Rs[E]);return Object.assign(e,Rs),e},or=cx({});or.newInstance=()=>cx({});var uR=or;or.HighlightJS=or;or.default=or;const fa=Zu(uR);function dR(e){const t=e.regex,n={},s={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},s]});const a={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},o=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),i={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,a]};a.contains.push(l);const u={match:/\\"/},c={className:"string",begin:/'/,end:/'/},d={match:/\\'/},f={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},p=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=e.SHEBANG({binary:`(${p.join("|")})`,relevance:10}),g={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},v=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],w=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],j=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:y,built_in:[...v,...N,"set","shopt",...w,...j]},contains:[x,e.SHEBANG(),g,f,o,i,b,l,u,c,d,n]}}const Bu="[A-Za-z$_][0-9A-Za-z$_]*",hR=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],fR=["true","false","null","undefined","NaN","Infinity"],ux=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],dx=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],hx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],pR=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],mR=[].concat(hx,ux,dx);function xR(e){const t=e.regex,n=(O,{after:I})=>{const F="</"+O[0].slice(1);return O.input.indexOf(F,I)!==-1},s=Bu,a={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(O,I)=>{const F=O[0].length+O.index,L=O.input[F];if(L==="<"||L===","){I.ignoreMatch();return}L===">"&&(n(O,{after:F})||I.ignoreMatch());let M;const z=O.input.substring(F);if(M=z.match(/^\s*=/)){I.ignoreMatch();return}if((M=z.match(/^\s+extends\s+/))&&M.index===0){I.ignoreMatch();return}}},l={$pattern:Bu,keyword:hR,literal:fR,built_in:mR,"variable.language":pR},u="[0-9](_?[0-9])*",c=`\\.(${u})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${u})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:s+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,g,m,y,{match:/\$\d+/},f];p.contains=N.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(N)});const w=[].concat(v,p.contains),j=w.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(w)}]),k={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:j},_={variants:[{match:[/class/,/\s+/,s,/\s+/,/extends/,/\s+/,t.concat(s,"(",t.concat(/\./,s),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,s],scope:{1:"keyword",3:"title.class"}}]},P={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...ux,...dx]}},T={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},$={variants:[{match:[/function/,/\s+/,s,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[k],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function D(O){return t.concat("(?!",O.join("|"),")")}const R={match:t.concat(/\b/,D([...hx,"super","import"].map(O=>`${O}\\s*\\(`)),s,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},S={begin:t.concat(/\./,t.lookahead(t.concat(s,/(?![0-9A-Za-z$_(])/))),end:s,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},C={match:[/get|set/,/\s+/,s,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},k]},E="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",A={match:[/const|var|let/,/\s+/,s,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(E)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[k]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:j,CLASS_REFERENCE:P},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,g,m,y,v,{match:/\$\d+/},f,P,{scope:"attr",match:s+t.lookahead(":"),relevance:0},A,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:E,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:j}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:a.begin,end:a.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},$,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[k,e.inherit(e.TITLE_MODE,{begin:s,className:"title.function"})]},{match:/\.\.\./,relevance:0},S,{match:"\\$"+s,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[k]},R,B,_,C,{match:/\$[(.]/}]}}function gR(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},s=["true","false","null"],a={scope:"literal",beginKeywords:s.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:s},contains:[t,n,e.QUOTE_STRING_MODE,a,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function yR(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},s={begin:"^[-\\*]{3,}",end:"$"},a={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},o={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},i={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},l=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,l,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},c={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},d={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},f=e.inherit(c,{contains:[]}),p=e.inherit(d,{contains:[]});c.contains.push(p),d.contains.push(f);let x=[n,u];return[c,d,f,p].forEach(b=>{b.contains=b.contains.concat(x)}),x=x.concat(c,d),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},n,o,c,d,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},a,s,u,i,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function bR(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),s=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:s,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},c={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},d={begin:/\{\{/,relevance:0},f={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,d,c]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,d,c]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},p="[0-9](_?[0-9])*",x=`(\\b(${p}))?\\.(${p})|\\b(${p})\\.`,g=`\\b|${s.join("|")}`,m={className:"number",relevance:0,variants:[{begin:`(\\b(${p})|(${x}))[eE][+-]?(${p})[jJ]?(?=${g})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${g})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${g})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${g})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${g})`},{begin:`\\b(${p})[jJ](?=${g})`}]},y={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",u,m,f,e.HASH_COMMENT_MODE]}]};return c.contains=[f,m,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[u,m,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},f,y,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,b,f]}]}}function vR(e){const t=e.regex,n=e.COMMENT("--","$"),s={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},a={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],i=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],u=["add","asc","collation","desc","final","first","last","view"],c=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],f=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],p=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],x=d,g=[...c,...u].filter(j=>!d.includes(j)),m={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function v(j){return t.concat(/\b/,t.either(...j.map(k=>k.replace(/\s+/,"\\s+"))),/\b/)}const N={scope:"keyword",match:v(p),relevance:0};function w(j,{exceptions:k,when:_}={}){const P=_;return k=k||[],j.map(T=>T.match(/\|\d+$/)||k.includes(T)?T:P(T)?`${T}|0`:T)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:w(g,{when:j=>j.length<3}),literal:o,type:l,built_in:f},contains:[{scope:"type",match:v(i)},N,b,m,s,a,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,y]}}const pa="[A-Za-z$_][0-9A-Za-z$_]*",fx=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],px=["true","false","null","undefined","NaN","Infinity"],mx=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],xx=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],gx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],yx=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],bx=[].concat(gx,mx,xx);function wR(e){const t=e.regex,n=(O,{after:I})=>{const F="</"+O[0].slice(1);return O.input.indexOf(F,I)!==-1},s=pa,a={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(O,I)=>{const F=O[0].length+O.index,L=O.input[F];if(L==="<"||L===","){I.ignoreMatch();return}L===">"&&(n(O,{after:F})||I.ignoreMatch());let M;const z=O.input.substring(F);if(M=z.match(/^\s*=/)){I.ignoreMatch();return}if((M=z.match(/^\s+extends\s+/))&&M.index===0){I.ignoreMatch();return}}},l={$pattern:pa,keyword:fx,literal:px,built_in:bx,"variable.language":yx},u="[0-9](_?[0-9])*",c=`\\.(${u})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",f={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${u})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},g={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:s+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,g,m,y,{match:/\$\d+/},f];p.contains=N.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(N)});const w=[].concat(v,p.contains),j=w.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(w)}]),k={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:j},_={variants:[{match:[/class/,/\s+/,s,/\s+/,/extends/,/\s+/,t.concat(s,"(",t.concat(/\./,s),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,s],scope:{1:"keyword",3:"title.class"}}]},P={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...mx,...xx]}},T={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},$={variants:[{match:[/function/,/\s+/,s,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[k],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function D(O){return t.concat("(?!",O.join("|"),")")}const R={match:t.concat(/\b/,D([...gx,"super","import"].map(O=>`${O}\\s*\\(`)),s,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},S={begin:t.concat(/\./,t.lookahead(t.concat(s,/(?![0-9A-Za-z$_(])/))),end:s,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},C={match:[/get|set/,/\s+/,s,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},k]},E="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",A={match:[/const|var|let/,/\s+/,s,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(E)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[k]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:j,CLASS_REFERENCE:P},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,g,m,y,v,{match:/\$\d+/},f,P,{scope:"attr",match:s+t.lookahead(":"),relevance:0},A,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:E,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:j}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:a.begin,end:a.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},$,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[k,e.inherit(e.TITLE_MODE,{begin:s,className:"title.function"})]},{match:/\.\.\./,relevance:0},S,{match:"\\$"+s,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[k]},R,B,_,C,{match:/\$[(.]/}]}}function NR(e){const t=e.regex,n=wR(e),s=pa,a=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},i={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:a},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],c={$pattern:pa,keyword:fx.concat(u),literal:px,built_in:bx.concat(a),"variable.language":yx},d={className:"meta",begin:"@"+s},f=(m,y,b)=>{const v=m.contains.findIndex(N=>N.label===y);if(v===-1)throw new Error("can not find mode to replace");m.contains.splice(v,1,b)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(d);const p=n.contains.find(m=>m.scope==="attr"),x=Object.assign({},p,{match:t.concat(s,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,p,x]),n.contains=n.contains.concat([d,o,i,x]),f(n,"shebang",e.SHEBANG()),f(n,"use_strict",l);const g=n.contains.find(m=>m.label==="func.def");return g.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function SR(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),s=/[\p{L}0-9._:-]+/u,a={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},i=e.inherit(o,{begin:/\(/,end:/\)/}),l=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),c={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:s,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[a]},{begin:/'/,end:/'/,contains:[a]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,u,l,i,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,i,u,l]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},a,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[c],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[c],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:c}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function jR(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",s={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},a={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},o={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},i={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,a]},l=e.inherit(i,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),p={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},x={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},g={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},m={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},y=[s,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},p,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},g,m,o,i],b=[...y];return b.pop(),b.push(l),x.contains=b,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:y}}function Sl(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Rn=Sl();function vx(e){Rn=e}var pn={exec:()=>null};function ve(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(a,o)=>{let i=typeof o=="string"?o:o.source;return i=i.replace(Ge.caret,"$1"),n=n.replace(a,i),s},getRegex:()=>new RegExp(n,t)};return s}var kR=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Ge={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},ER=/^(?:[ \t]*(?:\n|$))+/,_R=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,CR=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,us=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,TR=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jl=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wx=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Nx=ve(wx).replace(/bull/g,jl).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),RR=ve(wx).replace(/bull/g,jl).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),kl=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,AR=/^[^\n]+/,El=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,MR=ve(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",El).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),IR=ve(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,jl).getRegex(),Ua="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",_l=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,PR=ve("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",_l).replace("tag",Ua).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Sx=ve(kl).replace("hr",us).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ua).getRegex(),OR=ve(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Sx).getRegex(),Cl={blockquote:OR,code:_R,def:MR,fences:CR,heading:TR,hr:us,html:PR,lheading:Nx,list:IR,newline:ER,paragraph:Sx,table:pn,text:AR},Hu=ve("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",us).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ua).getRegex(),LR={...Cl,lheading:RR,table:Hu,paragraph:ve(kl).replace("hr",us).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Hu).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ua).getRegex()},DR={...Cl,html:ve(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",_l).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:pn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:ve(kl).replace("hr",us).replace("heading",` *#{1,6} *[^
|
|
590
|
+
]`).replace("lheading",Nx).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},$R=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,zR=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,jx=/^( {2,}|\\)\n(?!\s*$)/,FR=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Va=/[\p{P}\p{S}]/u,Tl=/[\s\p{P}\p{S}]/u,kx=/[^\s\p{P}\p{S}]/u,BR=ve(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Tl).getRegex(),Ex=/(?!~)[\p{P}\p{S}]/u,HR=/(?!~)[\s\p{P}\p{S}]/u,UR=/(?:[^\s\p{P}\p{S}]|~)/u,_x=/(?![*_])[\p{P}\p{S}]/u,VR=/(?![*_])[\s\p{P}\p{S}]/u,qR=/(?:[^\s\p{P}\p{S}]|[*_])/u,WR=ve(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",kR?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Cx=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,GR=ve(Cx,"u").replace(/punct/g,Va).getRegex(),KR=ve(Cx,"u").replace(/punct/g,Ex).getRegex(),Tx="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",YR=ve(Tx,"gu").replace(/notPunctSpace/g,kx).replace(/punctSpace/g,Tl).replace(/punct/g,Va).getRegex(),XR=ve(Tx,"gu").replace(/notPunctSpace/g,UR).replace(/punctSpace/g,HR).replace(/punct/g,Ex).getRegex(),ZR=ve("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,kx).replace(/punctSpace/g,Tl).replace(/punct/g,Va).getRegex(),JR=ve(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,_x).getRegex(),QR="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",eA=ve(QR,"gu").replace(/notPunctSpace/g,qR).replace(/punctSpace/g,VR).replace(/punct/g,_x).getRegex(),tA=ve(/\\(punct)/,"gu").replace(/punct/g,Va).getRegex(),nA=ve(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),rA=ve(_l).replace("(?:-->|$)","-->").getRegex(),sA=ve("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",rA).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),ma=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,aA=ve(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",ma).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Rx=ve(/^!?\[(label)\]\[(ref)\]/).replace("label",ma).replace("ref",El).getRegex(),Ax=ve(/^!?\[(ref)\](?:\[\])?/).replace("ref",El).getRegex(),oA=ve("reflink|nolink(?!\\()","g").replace("reflink",Rx).replace("nolink",Ax).getRegex(),Uu=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Rl={_backpedal:pn,anyPunctuation:tA,autolink:nA,blockSkip:WR,br:jx,code:zR,del:pn,delLDelim:pn,delRDelim:pn,emStrongLDelim:GR,emStrongRDelimAst:YR,emStrongRDelimUnd:ZR,escape:$R,link:aA,nolink:Ax,punctuation:BR,reflink:Rx,reflinkSearch:oA,tag:sA,text:FR,url:pn},iA={...Rl,link:ve(/^!?\[(label)\]\((.*?)\)/).replace("label",ma).getRegex(),reflink:ve(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",ma).getRegex()},pi={...Rl,emStrongRDelimAst:XR,emStrongLDelim:KR,delLDelim:JR,delRDelim:eA,url:ve(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Uu).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:ve(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Uu).getRegex()},lA={...pi,br:ve(jx).replace("{2,}","*").getRegex(),text:ve(pi.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},As={normal:Cl,gfm:LR,pedantic:DR},Er={normal:Rl,gfm:pi,breaks:lA,pedantic:iA},cA={"&":"&","<":"<",">":">",'"':""","'":"'"},Vu=e=>cA[e];function gt(e,t){if(t){if(Ge.escapeTest.test(e))return e.replace(Ge.escapeReplace,Vu)}else if(Ge.escapeTestNoEncode.test(e))return e.replace(Ge.escapeReplaceNoEncode,Vu);return e}function qu(e){try{e=encodeURI(e).replace(Ge.percentDecode,"%")}catch{return null}return e}function Wu(e,t){var o;let n=e.replace(Ge.findPipe,(i,l,u)=>{let c=!1,d=l;for(;--d>=0&&u[d]==="\\";)c=!c;return c?"|":" |"}),s=n.split(Ge.splitPipe),a=0;if(s[0].trim()||s.shift(),s.length>0&&!((o=s.at(-1))!=null&&o.trim())&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;a<s.length;a++)s[a]=s[a].trim().replace(Ge.slashPipe,"|");return s}function _r(e,t,n){let s=e.length;if(s===0)return"";let a=0;for(;a<s&&e.charAt(s-a-1)===t;)a++;return e.slice(0,s-a)}function uA(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function dA(e,t=0){let n=t,s="";for(let a of e)if(a===" "){let o=4-n%4;s+=" ".repeat(o),n+=o}else s+=a,n++;return s}function Gu(e,t,n,s,a){let o=t.href,i=t.title||null,l=e[1].replace(a.other.outputLinkReplace,"$1");s.state.inLink=!0;let u={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:i,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,u}function hA(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let a=s[1];return t.split(`
|
|
591
|
+
`).map(o=>{let i=o.match(n.other.beginningSpace);if(i===null)return o;let[l]=i;return l.length>=a.length?o.slice(a.length):o}).join(`
|
|
592
|
+
`)}var xa=class{constructor(e){le(this,"options");le(this,"rules");le(this,"lexer");this.options=e||Rn}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:_r(n,`
|
|
593
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=hA(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=_r(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:_r(t[0],`
|
|
594
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=_r(t[0],`
|
|
595
|
+
`).split(`
|
|
596
|
+
`),s="",a="",o=[];for(;n.length>0;){let i=!1,l=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))l.push(n[u]),i=!0;else if(!i)l.push(n[u]);else break;n=n.slice(u);let c=l.join(`
|
|
597
|
+
`),d=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
598
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
|
|
599
|
+
${c}`:c,a=a?`${a}
|
|
600
|
+
${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,o,!0),this.lexer.state.top=f,n.length===0)break;let p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let x=p,g=x.raw+`
|
|
601
|
+
`+n.join(`
|
|
602
|
+
`),m=this.blockquote(g);o[o.length-1]=m,s=s.substring(0,s.length-x.raw.length)+m.raw,a=a.substring(0,a.length-x.text.length)+m.text;break}else if((p==null?void 0:p.type)==="list"){let x=p,g=x.raw+`
|
|
603
|
+
`+n.join(`
|
|
604
|
+
`),m=this.list(g);o[o.length-1]=m,s=s.substring(0,s.length-p.raw.length)+m.raw,a=a.substring(0,a.length-x.raw.length)+m.raw,n=g.substring(o.at(-1).raw.length).split(`
|
|
605
|
+
`);continue}}return{type:"blockquote",raw:s,tokens:o,text:a}}}list(e){var n,s;let t=this.rules.block.list.exec(e);if(t){let a=t[1].trim(),o=a.length>1,i={type:"list",raw:"",ordered:o,start:o?+a.slice(0,-1):"",loose:!1,items:[]};a=o?`\\d{1,9}\\${a.slice(-1)}`:`\\${a}`,this.options.pedantic&&(a=o?a:"[*+-]");let l=this.rules.other.listItemRegex(a),u=!1;for(;e;){let d=!1,f="",p="";if(!(t=l.exec(e))||this.rules.block.hr.test(e))break;f=t[0],e=e.substring(f.length);let x=dA(t[2].split(`
|
|
606
|
+
`,1)[0],t[1].length),g=e.split(`
|
|
607
|
+
`,1)[0],m=!x.trim(),y=0;if(this.options.pedantic?(y=2,p=x.trimStart()):m?y=t[1].length+1:(y=x.search(this.rules.other.nonSpaceChar),y=y>4?1:y,p=x.slice(y),y+=t[1].length),m&&this.rules.other.blankLine.test(g)&&(f+=g+`
|
|
608
|
+
`,e=e.substring(g.length+1),d=!0),!d){let b=this.rules.other.nextBulletRegex(y),v=this.rules.other.hrRegex(y),N=this.rules.other.fencesBeginRegex(y),w=this.rules.other.headingBeginRegex(y),j=this.rules.other.htmlBeginRegex(y),k=this.rules.other.blockquoteBeginRegex(y);for(;e;){let _=e.split(`
|
|
609
|
+
`,1)[0],P;if(g=_,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),P=g):P=g.replace(this.rules.other.tabCharGlobal," "),N.test(g)||w.test(g)||j.test(g)||k.test(g)||b.test(g)||v.test(g))break;if(P.search(this.rules.other.nonSpaceChar)>=y||!g.trim())p+=`
|
|
610
|
+
`+P.slice(y);else{if(m||x.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(x)||w.test(x)||v.test(x))break;p+=`
|
|
611
|
+
`+g}m=!g.trim(),f+=_+`
|
|
612
|
+
`,e=e.substring(_.length+1),x=P.slice(y)}}i.loose||(u?i.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(u=!0)),i.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(p),loose:!1,text:p,tokens:[]}),i.raw+=f}let c=i.items.at(-1);if(c)c.raw=c.raw.trimEnd(),c.text=c.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let d of i.items){if(this.lexer.state.top=!1,d.tokens=this.lexer.blockTokens(d.text,[]),d.task){if(d.text=d.text.replace(this.rules.other.listReplaceTask,""),((n=d.tokens[0])==null?void 0:n.type)==="text"||((s=d.tokens[0])==null?void 0:s.type)==="paragraph"){d.tokens[0].raw=d.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),d.tokens[0].text=d.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let p=this.lexer.inlineQueue.length-1;p>=0;p--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[p].src)){this.lexer.inlineQueue[p].src=this.lexer.inlineQueue[p].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(d.raw);if(f){let p={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};d.checked=p.checked,i.loose?d.tokens[0]&&["paragraph","text"].includes(d.tokens[0].type)&&"tokens"in d.tokens[0]&&d.tokens[0].tokens?(d.tokens[0].raw=p.raw+d.tokens[0].raw,d.tokens[0].text=p.raw+d.tokens[0].text,d.tokens[0].tokens.unshift(p)):d.tokens.unshift({type:"paragraph",raw:p.raw,text:p.raw,tokens:[p]}):d.tokens.unshift(p)}}if(!i.loose){let f=d.tokens.filter(x=>x.type==="space"),p=f.length>0&&f.some(x=>this.rules.other.anyLine.test(x.raw));i.loose=p}}if(i.loose)for(let d of i.items){d.loose=!0;for(let f of d.tokens)f.type==="text"&&(f.type="paragraph")}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:a}}}table(e){var i;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Wu(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),a=(i=t[3])!=null&&i.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
613
|
+
`):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let l of s)this.rules.other.tableAlignRight.test(l)?o.align.push("right"):this.rules.other.tableAlignCenter.test(l)?o.align.push("center"):this.rules.other.tableAlignLeft.test(l)?o.align.push("left"):o.align.push(null);for(let l=0;l<n.length;l++)o.header.push({text:n[l],tokens:this.lexer.inline(n[l]),header:!0,align:o.align[l]});for(let l of a)o.rows.push(Wu(l,o.header.length).map((u,c)=>({text:u,tokens:this.lexer.inline(u),header:!1,align:o.align[c]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
614
|
+
`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=_r(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=uA(t[2],"()");if(o===-2)return;if(o>-1){let i=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,i).trim(),t[3]=""}}let s=t[2],a="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],a=o[3])}else a=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),Gu(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),a=t[s.toLowerCase()];if(!a){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return Gu(n,a,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[2])||!n||this.rules.inline.punctuation.exec(n))){let a=[...s[0]].length-1,o,i,l=a,u=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+a);(s=c.exec(t))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(i=[...o].length,s[3]||s[4]){l+=i;continue}else if((s[5]||s[6])&&a%3&&!((a+i)%3)){u+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+u);let d=[...s[0]][0].length,f=e.slice(0,a+s.index+d+i);if(Math.min(a,i)%2){let x=f.slice(1,-1);return{type:"em",raw:f,text:x,tokens:this.lexer.inlineTokens(x)}}let p=f.slice(2,-2);return{type:"strong",raw:f,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),a=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&a&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(s&&(!s[1]||!n||this.rules.inline.punctuation.exec(n))){let a=[...s[0]].length-1,o,i,l=a,u=this.rules.inline.delRDelim;for(u.lastIndex=0,t=t.slice(-1*e.length+a);(s=u.exec(t))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(i=[...o].length,i!==a))continue;if(s[3]||s[4]){l+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l);let c=[...s[0]][0].length,d=e.slice(0,a+s.index+c+i),f=d.slice(a,-a);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let s,a;if(t[2]==="@")s=t[0],a="mailto:"+s;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);s=t[0],t[1]==="www."?a="http://"+t[0]:a=t[0]}return{type:"link",raw:t[0],text:s,href:a,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},it=class mi{constructor(t){le(this,"tokens");le(this,"options");le(this,"state");le(this,"inlineQueue");le(this,"tokenizer");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Rn,this.options.tokenizer=this.options.tokenizer||new xa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Ge,block:As.normal,inline:Er.normal};this.options.pedantic?(n.block=As.pedantic,n.inline=Er.pedantic):this.options.gfm&&(n.block=As.gfm,this.options.breaks?n.inline=Er.breaks:n.inline=Er.gfm),this.tokenizer.rules=n}static get rules(){return{block:As,inline:Er}}static lex(t,n){return new mi(n).lex(t)}static lexInline(t,n){return new mi(n).inlineTokens(t)}lex(t){t=t.replace(Ge.carriageReturn,`
|
|
615
|
+
`),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){var a,o,i;for(this.options.pedantic&&(t=t.replace(Ge.tabCharGlobal," ").replace(Ge.spaceLine,""));t;){let l;if((o=(a=this.options.extensions)==null?void 0:a.block)!=null&&o.some(c=>(l=c.call({lexer:this},t,n))?(t=t.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.space(t)){t=t.substring(l.raw.length);let c=n.at(-1);l.raw.length===1&&c!==void 0?c.raw+=`
|
|
616
|
+
`:n.push(l);continue}if(l=this.tokenizer.code(t)){t=t.substring(l.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
617
|
+
`)?"":`
|
|
618
|
+
`)+l.raw,c.text+=`
|
|
619
|
+
`+l.text,this.inlineQueue.at(-1).src=c.text):n.push(l);continue}if(l=this.tokenizer.fences(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.heading(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.hr(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.blockquote(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.list(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.html(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.def(t)){t=t.substring(l.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="paragraph"||(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
620
|
+
`)?"":`
|
|
621
|
+
`)+l.raw,c.text+=`
|
|
622
|
+
`+l.raw,this.inlineQueue.at(-1).src=c.text):this.tokens.links[l.tag]||(this.tokens.links[l.tag]={href:l.href,title:l.title},n.push(l));continue}if(l=this.tokenizer.table(t)){t=t.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.lheading(t)){t=t.substring(l.raw.length),n.push(l);continue}let u=t;if((i=this.options.extensions)!=null&&i.startBlock){let c=1/0,d=t.slice(1),f;this.options.extensions.startBlock.forEach(p=>{f=p.call({lexer:this},d),typeof f=="number"&&f>=0&&(c=Math.min(c,f))}),c<1/0&&c>=0&&(u=t.substring(0,c+1))}if(this.state.top&&(l=this.tokenizer.paragraph(u))){let c=n.at(-1);s&&(c==null?void 0:c.type)==="paragraph"?(c.raw+=(c.raw.endsWith(`
|
|
623
|
+
`)?"":`
|
|
624
|
+
`)+l.raw,c.text+=`
|
|
625
|
+
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(l),s=u.length!==t.length,t=t.substring(l.raw.length);continue}if(l=this.tokenizer.text(t)){t=t.substring(l.raw.length);let c=n.at(-1);(c==null?void 0:c.type)==="text"?(c.raw+=(c.raw.endsWith(`
|
|
626
|
+
`)?"":`
|
|
627
|
+
`)+l.raw,c.text+=`
|
|
628
|
+
`+l.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=c.text):n.push(l);continue}if(t){let c="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var u,c,d,f,p;let s=t,a=null;if(this.tokens.links){let x=Object.keys(this.tokens.links);if(x.length>0)for(;(a=this.tokenizer.rules.inline.reflinkSearch.exec(s))!=null;)x.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,a.index)+"["+"a".repeat(a[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(a=this.tokenizer.rules.inline.anyPunctuation.exec(s))!=null;)s=s.slice(0,a.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(a=this.tokenizer.rules.inline.blockSkip.exec(s))!=null;)o=a[2]?a[2].length:0,s=s.slice(0,a.index+o)+"["+"a".repeat(a[0].length-o-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=((c=(u=this.options.hooks)==null?void 0:u.emStrongMask)==null?void 0:c.call({lexer:this},s))??s;let i=!1,l="";for(;t;){i||(l=""),i=!1;let x;if((f=(d=this.options.extensions)==null?void 0:d.inline)!=null&&f.some(m=>(x=m.call({lexer:this},t,n))?(t=t.substring(x.raw.length),n.push(x),!0):!1))continue;if(x=this.tokenizer.escape(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.tag(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.link(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(x.raw.length);let m=n.at(-1);x.type==="text"&&(m==null?void 0:m.type)==="text"?(m.raw+=x.raw,m.text+=x.text):n.push(x);continue}if(x=this.tokenizer.emStrong(t,s,l)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.codespan(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.br(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.del(t,s,l)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.autolink(t)){t=t.substring(x.raw.length),n.push(x);continue}if(!this.state.inLink&&(x=this.tokenizer.url(t))){t=t.substring(x.raw.length),n.push(x);continue}let g=t;if((p=this.options.extensions)!=null&&p.startInline){let m=1/0,y=t.slice(1),b;this.options.extensions.startInline.forEach(v=>{b=v.call({lexer:this},y),typeof b=="number"&&b>=0&&(m=Math.min(m,b))}),m<1/0&&m>=0&&(g=t.substring(0,m+1))}if(x=this.tokenizer.inlineText(g)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(l=x.raw.slice(-1)),i=!0;let m=n.at(-1);(m==null?void 0:m.type)==="text"?(m.raw+=x.raw,m.text+=x.text):n.push(x);continue}if(t){let m="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(m);break}else throw new Error(m)}}return n}},ga=class{constructor(e){le(this,"options");le(this,"parser");this.options=e||Rn}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let s=(o=(t||"").match(Ge.notSpaceStart))==null?void 0:o[0],a=e.replace(Ge.endingNewline,"")+`
|
|
629
|
+
`;return s?'<pre><code class="language-'+gt(s)+'">'+(n?a:gt(a,!0))+`</code></pre>
|
|
630
|
+
`:"<pre><code>"+(n?a:gt(a,!0))+`</code></pre>
|
|
631
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
632
|
+
${this.parser.parse(e)}</blockquote>
|
|
633
|
+
`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
634
|
+
`}hr(e){return`<hr>
|
|
635
|
+
`}list(e){let t=e.ordered,n=e.start,s="";for(let i=0;i<e.items.length;i++){let l=e.items[i];s+=this.listitem(l)}let a=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+a+o+`>
|
|
636
|
+
`+s+"</"+a+`>
|
|
637
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
638
|
+
`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
639
|
+
`}table(e){let t="",n="";for(let a=0;a<e.header.length;a++)n+=this.tablecell(e.header[a]);t+=this.tablerow({text:n});let s="";for(let a=0;a<e.rows.length;a++){let o=e.rows[a];n="";for(let i=0;i<o.length;i++)n+=this.tablecell(o[i]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
|
|
640
|
+
<thead>
|
|
641
|
+
`+t+`</thead>
|
|
642
|
+
`+s+`</table>
|
|
643
|
+
`}tablerow({text:e}){return`<tr>
|
|
644
|
+
${e}</tr>
|
|
645
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
646
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${gt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),a=qu(e);if(a===null)return s;e=a;let o='<a href="'+e+'"';return t&&(o+=' title="'+gt(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let a=qu(e);if(a===null)return gt(n);e=a;let o=`<img src="${e}" alt="${gt(n)}"`;return t&&(o+=` title="${gt(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:gt(e.text)}},Al=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},lt=class xi{constructor(t){le(this,"options");le(this,"renderer");le(this,"textRenderer");this.options=t||Rn,this.options.renderer=this.options.renderer||new ga,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Al}static parse(t,n){return new xi(n).parse(t)}static parseInline(t,n){return new xi(n).parseInline(t)}parse(t){var s,a;let n="";for(let o=0;o<t.length;o++){let i=t[o];if((a=(s=this.options.extensions)==null?void 0:s.renderers)!=null&&a[i.type]){let u=i,c=this.options.extensions.renderers[u.type].call({parser:this},u);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(u.type)){n+=c||"";continue}}let l=i;switch(l.type){case"space":{n+=this.renderer.space(l);break}case"hr":{n+=this.renderer.hr(l);break}case"heading":{n+=this.renderer.heading(l);break}case"code":{n+=this.renderer.code(l);break}case"table":{n+=this.renderer.table(l);break}case"blockquote":{n+=this.renderer.blockquote(l);break}case"list":{n+=this.renderer.list(l);break}case"checkbox":{n+=this.renderer.checkbox(l);break}case"html":{n+=this.renderer.html(l);break}case"def":{n+=this.renderer.def(l);break}case"paragraph":{n+=this.renderer.paragraph(l);break}case"text":{n+=this.renderer.text(l);break}default:{let u='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(u),"";throw new Error(u)}}}return n}parseInline(t,n=this.renderer){var a,o;let s="";for(let i=0;i<t.length;i++){let l=t[i];if((o=(a=this.options.extensions)==null?void 0:a.renderers)!=null&&o[l.type]){let c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(l.type)){s+=c||"";continue}}let u=l;switch(u.type){case"escape":{s+=n.text(u);break}case"html":{s+=n.html(u);break}case"link":{s+=n.link(u);break}case"image":{s+=n.image(u);break}case"checkbox":{s+=n.checkbox(u);break}case"strong":{s+=n.strong(u);break}case"em":{s+=n.em(u);break}case"codespan":{s+=n.codespan(u);break}case"br":{s+=n.br(u);break}case"del":{s+=n.del(u);break}case"text":{s+=n.text(u);break}default:{let c='Token with "'+u.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return s}},Ps,Mr=(Ps=class{constructor(e){le(this,"options");le(this,"block");this.options=e||Rn}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?it.lex:it.lexInline}provideParser(){return this.block?lt.parse:lt.parseInline}},le(Ps,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),le(Ps,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Ps),fA=class{constructor(...e){le(this,"defaults",Sl());le(this,"options",this.setOptions);le(this,"parse",this.parseMarkdown(!0));le(this,"parseInline",this.parseMarkdown(!1));le(this,"Parser",lt);le(this,"Renderer",ga);le(this,"TextRenderer",Al);le(this,"Lexer",it);le(this,"Tokenizer",xa);le(this,"Hooks",Mr);this.use(...e)}walkTokens(e,t){var s,a;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let i=o;for(let l of i.header)n=n.concat(this.walkTokens(l.tokens,t));for(let l of i.rows)for(let u of l)n=n.concat(this.walkTokens(u.tokens,t));break}case"list":{let i=o;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=o;(a=(s=this.defaults.extensions)==null?void 0:s.childTokens)!=null&&a[i.type]?this.defaults.extensions.childTokens[i.type].forEach(l=>{let u=i[l].flat(1/0);n=n.concat(this.walkTokens(u,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(a=>{if(!a.name)throw new Error("extension name required");if("renderer"in a){let o=t.renderers[a.name];o?t.renderers[a.name]=function(...i){let l=a.renderer.apply(this,i);return l===!1&&(l=o.apply(this,i)),l}:t.renderers[a.name]=a.renderer}if("tokenizer"in a){if(!a.level||a.level!=="block"&&a.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[a.level];o?o.unshift(a.tokenizer):t[a.level]=[a.tokenizer],a.start&&(a.level==="block"?t.startBlock?t.startBlock.push(a.start):t.startBlock=[a.start]:a.level==="inline"&&(t.startInline?t.startInline.push(a.start):t.startInline=[a.start]))}"childTokens"in a&&a.childTokens&&(t.childTokens[a.name]=a.childTokens)}),s.extensions=t),n.renderer){let a=this.defaults.renderer||new ga(this.defaults);for(let o in n.renderer){if(!(o in a))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let i=o,l=n.renderer[i],u=a[i];a[i]=(...c)=>{let d=l.apply(a,c);return d===!1&&(d=u.apply(a,c)),d||""}}s.renderer=a}if(n.tokenizer){let a=this.defaults.tokenizer||new xa(this.defaults);for(let o in n.tokenizer){if(!(o in a))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let i=o,l=n.tokenizer[i],u=a[i];a[i]=(...c)=>{let d=l.apply(a,c);return d===!1&&(d=u.apply(a,c)),d}}s.tokenizer=a}if(n.hooks){let a=this.defaults.hooks||new Mr;for(let o in n.hooks){if(!(o in a))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let i=o,l=n.hooks[i],u=a[i];Mr.passThroughHooks.has(o)?a[i]=c=>{if(this.defaults.async&&Mr.passThroughHooksRespectAsync.has(o))return(async()=>{let f=await l.call(a,c);return u.call(a,f)})();let d=l.call(a,c);return u.call(a,d)}:a[i]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await l.apply(a,c);return f===!1&&(f=await u.apply(a,c)),f})();let d=l.apply(a,c);return d===!1&&(d=u.apply(a,c)),d}}s.hooks=a}if(n.walkTokens){let a=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(i){let l=[];return l.push(o.call(this,i)),a&&(l=l.concat(a.call(this,i))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return it.lex(e,t??this.defaults)}parser(e,t){return lt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},a={...this.defaults,...s},o=this.onError(!!a.silent,!!a.async);if(this.defaults.async===!0&&s.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(a.hooks&&(a.hooks.options=a,a.hooks.block=e),a.async)return(async()=>{let i=a.hooks?await a.hooks.preprocess(t):t,l=await(a.hooks?await a.hooks.provideLexer():e?it.lex:it.lexInline)(i,a),u=a.hooks?await a.hooks.processAllTokens(l):l;a.walkTokens&&await Promise.all(this.walkTokens(u,a.walkTokens));let c=await(a.hooks?await a.hooks.provideParser():e?lt.parse:lt.parseInline)(u,a);return a.hooks?await a.hooks.postprocess(c):c})().catch(o);try{a.hooks&&(t=a.hooks.preprocess(t));let i=(a.hooks?a.hooks.provideLexer():e?it.lex:it.lexInline)(t,a);a.hooks&&(i=a.hooks.processAllTokens(i)),a.walkTokens&&this.walkTokens(i,a.walkTokens);let l=(a.hooks?a.hooks.provideParser():e?lt.parse:lt.parseInline)(i,a);return a.hooks&&(l=a.hooks.postprocess(l)),l}catch(i){return o(i)}}}onError(e,t){return n=>{if(n.message+=`
|
|
647
|
+
Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+gt(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},Cn=new fA;function Ce(e,t){return Cn.parse(e,t)}Ce.options=Ce.setOptions=function(e){return Cn.setOptions(e),Ce.defaults=Cn.defaults,vx(Ce.defaults),Ce};Ce.getDefaults=Sl;Ce.defaults=Rn;Ce.use=function(...e){return Cn.use(...e),Ce.defaults=Cn.defaults,vx(Ce.defaults),Ce};Ce.walkTokens=function(e,t){return Cn.walkTokens(e,t)};Ce.parseInline=Cn.parseInline;Ce.Parser=lt;Ce.parser=lt.parse;Ce.Renderer=ga;Ce.TextRenderer=Al;Ce.Lexer=it;Ce.lexer=it.lex;Ce.Tokenizer=xa;Ce.Hooks=Mr;Ce.parse=Ce;Ce.options;Ce.setOptions;Ce.use;Ce.walkTokens;Ce.parseInline;lt.parse;it.lex;const pA={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",sh:"bash",shell:"bash",zsh:"bash",yml:"yaml",html:"xml"};function $t(e,t){fa.getLanguage(e)||fa.registerLanguage(e,t)}$t("bash",dR);$t("javascript",xR);$t("json",gR);$t("markdown",yR);$t("python",bR);$t("sql",vR);$t("typescript",NR);$t("xml",SR);$t("yaml",jR);function Co(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function mA(e){if(!e)return"";const t=e.trim().toLowerCase();return pA[t]??t}function xA(e){try{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}function Ml({content:e,className:t}){const n=h.useRef(null),s=h.useMemo(()=>{try{const a=new Ce.Renderer;return a.code=o=>{const i=o.text??"",l=mA(o.lang),u=l&&fa.getLanguage(l),c=u?l:"text",d=u?fa.highlight(i,{language:l,ignoreIllegals:!0}).value:Co(i),f=encodeURIComponent(i);return['<div class="md-code-block not-prose my-4 overflow-hidden rounded border border-neutral-800 bg-neutral-950">',' <div class="flex items-center justify-between border-b border-neutral-800 bg-neutral-900/80 px-3 py-2">',` <span class="text-[10px] font-semibold uppercase tracking-wider text-neutral-400">${Co(c)}</span>`,' <button type="button" data-copy-code="'+f+'" class="rounded border border-neutral-700 bg-neutral-900 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-neutral-300 transition-colors hover:border-neutral-500 hover:text-neutral-100">'," Copy"," </button>"," </div>",' <pre class="m-0 overflow-x-auto p-4"><code class="hljs language-'+Co(c)+'">'+d+"</code></pre>","</div>"].join(`
|
|
648
|
+
`)},Ce.parse(e,{breaks:!0,gfm:!0,renderer:a})}catch(a){return console.error("Markdown parse error:",a),"<p>Error parsing content</p>"}},[e]);return h.useEffect(()=>{const a=n.current;if(!a)return;const o=async i=>{var x;const l=i.target,u=l==null?void 0:l.closest("button[data-copy-code]");if(!u||!a.contains(u))return;const c=u.getAttribute("data-copy-code");if(!c)return;const d=decodeURIComponent(c),f=u.textContent||"Copy";let p=!1;try{(x=navigator.clipboard)!=null&&x.writeText&&(await navigator.clipboard.writeText(d),p=!0)}catch{p=!1}p||(p=xA(d)),u.textContent=p?"Copied":"Failed",u.disabled=!0,window.setTimeout(()=>{u.textContent=f,u.disabled=!1},1500)};return a.addEventListener("click",o),()=>{a.removeEventListener("click",o)}},[s]),r.jsx("div",{ref:n,className:X("prose prose-invert max-w-none","space-y-4 text-neutral-300","[&_h1]:text-2xl [&_h1]:font-bold [&_h1]:text-neutral-100 [&_h1]:mt-6 [&_h1]:mb-3","[&_h2]:text-xl [&_h2]:font-semibold [&_h2]:text-neutral-100 [&_h2]:mt-5 [&_h2]:mb-2","[&_h3]:text-lg [&_h3]:font-semibold [&_h3]:text-neutral-200 [&_h3]:mt-4 [&_h3]:mb-2","[&_h4]:text-base [&_h4]:font-semibold [&_h4]:text-neutral-200 [&_h4]:mt-3 [&_h4]:mb-1","[&_p]:leading-relaxed [&_p]:text-neutral-300","[&_a]:text-blue-400 [&_a]:hover:text-blue-300 [&_a]:underline","[&_code]:bg-neutral-950 [&_code]:text-neutral-200 [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:font-mono [&_code]:text-sm","[&_pre]:bg-neutral-950 [&_pre]:border [&_pre]:border-neutral-800 [&_pre]:rounded [&_pre]:p-4 [&_pre]:overflow-x-auto","[&_pre_code]:text-neutral-300 [&_pre_code]:text-sm [&_pre_code]:font-mono [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:rounded-none","[&_ul]:list-disc [&_ul]:ml-5 [&_ul]:space-y-1","[&_ol]:list-decimal [&_ol]:ml-5 [&_ol]:space-y-1","[&_li]:text-neutral-300","[&_blockquote]:border-l-4 [&_blockquote]:border-neutral-700 [&_blockquote]:pl-4 [&_blockquote]:italic [&_blockquote]:text-neutral-400","[&_table]:w-full [&_table]:border-collapse","[&_table_th]:text-left [&_table_th]:bg-neutral-900 [&_table_th]:text-neutral-200 [&_table_th]:font-semibold [&_table_th]:px-3 [&_table_th]:py-2 [&_table_th]:border [&_table_th]:border-neutral-700","[&_table_td]:px-3 [&_table_td]:py-2 [&_table_td]:border [&_table_td]:border-neutral-800 [&_table_td]:text-neutral-300","[&_.hljs]:bg-transparent [&_.hljs]:p-0","[&_hr]:border-neutral-800 [&_hr]:my-6",t),dangerouslySetInnerHTML:{__html:s}})}Ml.displayName="MarkdownContent";function Mx({docId:e,onClose:t}){const[n,s]=h.useState(null),[a,o]=h.useState(!1),[i,l]=h.useState(null);return h.useEffect(()=>{if(!e){s(null);return}o(!0),l(null),yl().then(u=>{const c=u.find(d=>d.id===e);c?s(c):l("Document not found")}).catch(u=>{console.error("Error loading doc:",u),l("Failed to load document")}).finally(()=>{o(!1)})},[e]),e?r.jsx("div",{className:X("fixed inset-0 bg-black/60 backdrop-blur-sm transition-opacity z-50",e?"opacity-100":"opacity-0 pointer-events-none"),onClick:t,children:r.jsxs("div",{className:X("absolute right-0 top-0 bottom-0 w-full max-w-2xl bg-card border-l border-border shadow-2xl transition-transform flex flex-col",e?"translate-x-0":"translate-x-full"),onClick:u=>u.stopPropagation(),children:[r.jsxs("div",{className:"h-14 border-b border-border flex items-center justify-between px-6 flex-shrink-0 bg-background/95 backdrop-blur-lg",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[r.jsx(lr,{className:"h-4 w-4 text-primary flex-shrink-0"}),r.jsx("div",{className:"min-w-0",children:a?r.jsx("div",{className:"text-sm text-muted-foreground animate-pulse font-mono uppercase tracking-widest",children:"Loading..."}):n?r.jsxs("div",{children:[r.jsx("h2",{className:"text-sm font-semibold text-neutral-100 truncate uppercase tracking-tight",children:n.title}),r.jsx("p",{className:"text-[10px] text-muted-foreground font-mono uppercase tracking-widest",children:n.category})]}):null})]}),r.jsx(Q,{variant:"ghost",size:"icon",onClick:t,className:"h-8 w-8 text-neutral-500 hover:text-neutral-100 hover:bg-neutral-900/70 flex-shrink-0",children:r.jsx(gd,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 overflow-y-auto bg-card/50",children:[i&&r.jsxs("div",{className:"p-8 flex items-start gap-3 bg-destructive/5 m-6 border border-destructive/20 rounded-sm",children:[r.jsx(vi,{className:"h-5 w-5 text-destructive flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("h3",{className:"font-medium text-destructive",children:i}),r.jsx("p",{className:"text-sm text-destructive/70 mt-1",children:"Please try again later or contact support if the issue persists."})]})]}),n&&r.jsxs("div",{className:"p-8",children:[r.jsx(Ml,{content:n.content}),n.headings&&n.headings.length>0&&r.jsxs("div",{className:"mt-12 pt-8 border-t border-border/50",children:[r.jsx("h3",{className:"text-[11px] font-bold text-muted-foreground mb-4 uppercase tracking-widest font-mono",children:"Document Outline"}),r.jsx("ul",{className:"space-y-2 text-sm text-muted-foreground",children:n.headings.map((u,c)=>r.jsxs("li",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-1 h-1 rounded-full bg-primary/40"}),u]},c))})]})]})]})]})}):null}Mx.displayName="DocViewer";const gA="other";function Ms(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function yA(e){return e.category.trim().toLowerCase()!==gA}function Ku(){const e=Ju(),{docId:t}=xg(),[n,s]=h.useState([]),[a,o]=h.useState(""),[i,l]=h.useState(!0),[u,c]=h.useState(null),[d,f]=h.useState(null),p=h.useRef(null);h.useEffect(()=>{l(!0),yl().then(v=>{s(v.filter(yA)),c(null)}).catch(v=>{console.error("Failed to load docs for hub:",v),c("Failed to load documentation index")}).finally(()=>l(!1))},[]);const x=h.useMemo(()=>{const v=a.trim().toLowerCase();return v?n.filter(N=>[N.title,N.category,N.excerpt,N.content].some(w=>w.toLowerCase().includes(v))).sort((N,w)=>N.title.localeCompare(w.title)):[...n].sort((N,w)=>N.title.localeCompare(w.title))},[n,a]),g=h.useMemo(()=>{const v=new Map;for(const N of x){const w=v.get(N.category)??[];w.push(N),v.set(N.category,w)}return Array.from(v.entries()).sort(([N],[w])=>N.localeCompare(w)).map(([N,w])=>({category:N,entries:w.sort((j,k)=>j.title.localeCompare(k.title))}))},[x]),m=h.useMemo(()=>!t||n.length===0?null:n.find(v=>v.id===t)??null,[n,t]),y=!t;h.useEffect(()=>{t&&!i&&!m&&e("/docs",{replace:!0})},[t,i,m,e]),h.useEffect(()=>{var v;f(null),(v=p.current)==null||v.scrollTo({top:0,behavior:"auto"})},[m==null?void 0:m.id]),h.useEffect(()=>{if(!m)return;const v=p.current;if(!v)return;const N=Array.from(v.querySelectorAll("h1, h2, h3, h4"));if(N.length===0)return;const w=new IntersectionObserver(j=>{var _;const k=j.filter(P=>P.isIntersecting).sort((P,T)=>T.intersectionRatio-P.intersectionRatio);if(k.length>0){const P=(_=k[0].target.textContent)==null?void 0:_.trim();P&&f(P)}},{root:v,rootMargin:"-15% 0px -70% 0px",threshold:[0,.25,.5,1]});for(const j of N)w.observe(j);return()=>w.disconnect()},[m==null?void 0:m.id]);const b=v=>{const N=p.current;if(!N)return;const w=Ms(v),j=Array.from(N.querySelectorAll("h1, h2, h3, h4")).find(k=>Ms(k.textContent??"")===w);j&&(j.scrollIntoView({behavior:"smooth",block:"start"}),f(v))};return r.jsxs("div",{className:"flex h-screen bg-neutral-950 text-neutral-100 overflow-hidden",children:[r.jsxs("aside",{className:"w-[22rem] border-r border-neutral-800/60 bg-neutral-950/95 flex flex-col",children:[r.jsxs("div",{className:"px-4 py-4 border-b border-neutral-800/60 space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lr,{className:"h-4 w-4 text-primary"}),r.jsx("h1",{className:"text-sm font-bold tracking-wide uppercase",children:"Documentation Hub"})]}),r.jsxs(Q,{size:"sm",variant:"outline",onClick:()=>e("/"),className:"h-7 px-2 text-[10px]",children:[r.jsx(Cg,{className:"h-3 w-3 mr-1"}),"Dashboard"]})]}),r.jsx("p",{className:"text-xs text-neutral-500",children:"Browse large documentation files with quick section navigation."}),r.jsxs("div",{className:"relative",children:[r.jsx(Jr,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-neutral-600"}),r.jsx("input",{type:"text",value:a,onChange:v=>o(v.target.value),placeholder:"Search docs...",className:"h-8 w-full rounded-sm border border-neutral-700 bg-neutral-900/70 pl-8 pr-2 text-xs text-neutral-200 placeholder:text-neutral-600 focus:outline-none focus:border-primary/50"})]})]}),r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[r.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-3 py-3",children:[r.jsxs("div",{className:"text-[10px] font-mono uppercase tracking-widest text-neutral-600 mb-2",children:["Documents (",x.length,")"]}),!i&&g.length===0&&r.jsx("div",{className:"text-xs text-neutral-500 py-4",children:"No documents match your search."}),g.map(v=>r.jsxs("div",{className:"mb-4",children:[r.jsx("div",{className:"text-[10px] font-mono uppercase tracking-widest text-neutral-500 mb-1.5",children:v.category}),r.jsx("div",{className:"space-y-1",children:v.entries.map(N=>{const w=(m==null?void 0:m.id)===N.id;return r.jsx("button",{type:"button",onClick:()=>e(`/docs/${N.id}`),className:X("w-full rounded-sm border px-3 py-3 min-h-[72px] text-left transition-colors",w?"border-primary/40 bg-primary/10":"border-neutral-800 bg-neutral-900/40 hover:bg-neutral-900/70 hover:border-neutral-700"),children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(zg,{className:"h-3.5 w-3.5 mt-0.5 text-neutral-500"}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-neutral-100 line-clamp-1",children:N.title}),r.jsx("div",{className:"text-xs text-neutral-500 mt-1 line-clamp-1",children:N.excerpt})]})]})},N.id)})})]},v.category))]}),r.jsxs("div",{className:"h-60 border-t border-neutral-800/60 px-3 py-3 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-widest text-neutral-600 mb-2",children:[r.jsx(ld,{className:"h-3 w-3"}),y?"Quick Links":"Outline"]}),y&&x.length===0&&r.jsx("div",{className:"text-xs text-neutral-500",children:"No public docs available."}),y&&x.length>0&&r.jsx("div",{className:"space-y-1",children:x.slice(0,14).map(v=>r.jsx("button",{type:"button",onClick:()=>e(`/docs/${v.id}`),className:"w-full text-left text-xs rounded-sm px-2 py-1 border border-transparent text-neutral-400 hover:text-neutral-200 hover:bg-neutral-900/60 transition-colors",children:v.title},v.id))}),!y&&!m&&r.jsx("div",{className:"text-xs text-neutral-500",children:"Select a document."}),!y&&m&&m.headings.length===0&&r.jsx("div",{className:"text-xs text-neutral-500",children:"No sections detected."}),!y&&m&&m.headings.length>0&&r.jsx("div",{className:"space-y-1",children:m.headings.map(v=>{const N=d!==null&&Ms(d)===Ms(v);return r.jsx("button",{type:"button",onClick:()=>b(v),className:X("w-full text-left text-xs rounded-sm px-2 py-1 border transition-colors",N?"border-primary/40 bg-primary/10 text-primary-200":"border-transparent text-neutral-400 hover:text-neutral-200 hover:bg-neutral-900/60"),children:v},v)})})]})]})]}),r.jsxs("main",{className:"flex-1 min-w-0 flex flex-col",children:[r.jsxs("div",{className:"h-14 border-b border-neutral-800/60 px-6 flex items-center justify-between bg-neutral-950/80",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-[10px] font-mono uppercase tracking-[0.18em] text-neutral-600",children:(m==null?void 0:m.category)??"Documentation"}),r.jsx("div",{className:"text-sm font-semibold text-neutral-100 truncate",children:(m==null?void 0:m.title)??"Apparatus Documentation Hub"})]}),m&&r.jsx("div",{className:"text-[10px] font-mono uppercase tracking-widest text-neutral-500 truncate max-w-[22rem]",children:m.file})]}),r.jsxs("div",{ref:p,className:"flex-1 overflow-y-auto px-8 py-6",children:[i&&r.jsx("div",{className:"text-sm text-neutral-500",children:"Loading documentation…"}),u&&!i&&r.jsx("div",{className:"text-sm text-danger",children:u}),!i&&!u&&!m&&r.jsxs("div",{className:"max-w-5xl space-y-8",children:[r.jsxs("section",{className:"space-y-2",children:[r.jsx("h2",{className:"text-2xl font-semibold text-neutral-100",children:"Apparatus Documentation Hub"}),r.jsx("p",{className:"text-sm text-neutral-400",children:"Browse public documentation by category and jump directly to the page you need."})]}),g.length===0&&r.jsx("div",{className:"text-sm text-neutral-500",children:"No public documentation available."}),g.map(v=>r.jsxs("section",{className:"space-y-3",children:[r.jsx("h3",{className:"text-xs font-mono uppercase tracking-widest text-neutral-500",children:v.category}),r.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-2",children:v.entries.map(N=>r.jsx("button",{type:"button",onClick:()=>e(`/docs/${N.id}`),className:"rounded-sm border border-neutral-800 bg-neutral-900/50 hover:border-neutral-700 hover:bg-neutral-900/80 transition-colors px-4 py-4 min-h-[112px] text-left flex items-center",children:r.jsxs("div",{className:"space-y-1 min-w-0",children:[r.jsx("div",{className:"text-base font-medium text-neutral-100 line-clamp-1",children:N.title}),r.jsx("div",{className:"text-sm text-neutral-400 line-clamp-1",children:N.excerpt})]})},N.id))})]},v.category))]}),!i&&!u&&m&&r.jsx("div",{className:"max-w-4xl",children:r.jsx(Ml,{content:m.content})})]})]})]})}const bA=15e3,vA=80,Is=12;function Yu(e,t,n){return Math.min(n,Math.max(t,e))}function gi(e){return e==="stats"?{width:248,height:138}:{width:340,height:196}}function wA(e,t){const n=gi("stats"),s=gi("thoughts");return{stats:{x:Math.max(12,e-n.width-16),y:16,visible:!1},thoughts:{x:16,y:Math.max(16,t-s.height-16),visible:!1}}}function Us(e,t,n){const{width:s,height:a}=gi(e),o=Math.max(12,window.innerWidth-s-12),i=Math.max(12,window.innerHeight-a-12);return{x:Yu(t,12,o),y:Yu(n,12,i)}}function NA(){const e=wA(window.innerWidth,window.innerHeight);try{const t=localStorage.getItem(Lr);if(!t)return e;const n=JSON.parse(t),s={...e};return["stats","thoughts"].forEach(a=>{const o=n[a];if(!o)return;const i=o.visible!==!1,{x:l,y:u}=Us(a,o.x??s[a].x,o.y??s[a].y);s[a]={x:l,y:u,visible:i}}),s}catch{return e}}function SA(){const{health:e}=je(),{events:t}=Ii(240),{session:n}=hm(),[s,a]=h.useState(!1),[o,i]=h.useState(null),[l,u]=h.useState(!0),c=h.useRef(null),d=h.useRef(null),f=h.useMemo(()=>((n==null?void 0:n.thoughts)??[]).slice(-3).reverse(),[n==null?void 0:n.thoughts]),p=h.useMemo(()=>{if(t.length===0)return{rps:0,activeThreats:0};const y=Date.now(),b=t.filter(_=>y-new Date(_.timestamp).getTime()<=bA),v=b.length>0?b:t.slice(0,vA),N=v.map(_=>new Date(_.timestamp).getTime()),w=Math.max(...N),j=Math.min(...N),k=Math.max((w-j)/1e3,1);return{rps:Math.round(v.length/k),activeThreats:v.filter(_=>_.status>=500||[401,403,429].includes(_.status)).length}},[t]);h.useEffect(()=>{a(!0),i(NA()),u(Cd())},[]),h.useEffect(()=>{const y=b=>{if(!(b instanceof CustomEvent))return;const v=b.detail;if(!v||typeof v.hidden!="boolean"||typeof v.statsVisible!="boolean"||typeof v.thoughtsVisible!="boolean")return;const N=v.hidden,w=v.statsVisible,j=v.thoughtsVisible;u(N),i(k=>k&&{...k,stats:{...k.stats,visible:w},thoughts:{...k.thoughts,visible:j}})};return window.addEventListener(Io,y),()=>{window.removeEventListener(Io,y)}},[]),h.useEffect(()=>{d.current=o},[o]),h.useEffect(()=>{if(o&&!c.current)try{localStorage.setItem(Lr,JSON.stringify(o))}catch{}},[o]),h.useEffect(()=>{try{localStorage.setItem(Ri,l?"1":"0")}catch{}},[l]),h.useEffect(()=>{const y=()=>{i(b=>{if(!b)return b;const v={...b};let N=!1;return["stats","thoughts"].forEach(w=>{const j=Us(w,v[w].x,v[w].y);(v[w].x!==j.x||v[w].y!==j.y)&&(v[w]={...v[w],...j},N=!0)}),N?v:b})};return window.addEventListener("resize",y),()=>window.removeEventListener("resize",y)},[]),h.useEffect(()=>{const y=v=>{const N=c.current;if(!N)return;const w=v.clientX-N.offsetX,j=v.clientY-N.offsetY,k=Us(N.widgetId,w,j);i(_=>{if(!_)return _;const P=_[N.widgetId];return P.x===k.x&&P.y===k.y?_:{..._,[N.widgetId]:{...P,...k}}})},b=()=>{c.current=null;const v=d.current;if(v)try{localStorage.setItem(Lr,JSON.stringify(v))}catch{}};return window.addEventListener("pointermove",y),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",b)}},[]);const x=h.useCallback((y,b)=>{if(!o)return;b.preventDefault();const v=o[y];c.current={widgetId:y,offsetX:b.clientX-v.x,offsetY:b.clientY-v.y}},[o]),g=h.useCallback((y,b,v)=>{i(N=>{if(!N)return N;const w=N[y],j=Us(y,w.x+b,w.y+v);return{...N,[y]:{...w,...j}}})},[]),m=h.useCallback((y,b)=>{b.key==="ArrowLeft"?(b.preventDefault(),g(y,-Is,0)):b.key==="ArrowRight"?(b.preventDefault(),g(y,Is,0)):b.key==="ArrowUp"?(b.preventDefault(),g(y,0,-Is)):b.key==="ArrowDown"&&(b.preventDefault(),g(y,0,Is))},[g]);return!s||!o||l?null:ir.createPortal(r.jsxs("div",{className:"fixed inset-0 z-[9000] pointer-events-none select-none",role:"complementary","aria-label":"HUD overlay",children:[o.stats.visible&&r.jsxs("div",{className:"pointer-events-auto fixed w-[248px] rounded-md bg-neutral-950/65 px-3 py-2.5 backdrop-blur-sm shadow-[0_18px_45px_rgba(0,0,0,0.55)]",style:{left:o.stats.x,top:o.stats.y},children:[r.jsx("div",{className:"mb-2 flex items-center justify-between cursor-move",onPointerDown:y=>x("stats",y),onKeyDown:y=>m("stats",y),tabIndex:0,role:"button","aria-roledescription":"drag handle","aria-description":"Use arrow keys to reposition","aria-label":"Drag HUD stats widget",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-widest text-primary/80",children:[r.jsx($l,{className:"h-3 w-3"}),"HUD Stats"]})}),r.jsxs("div",{className:"space-y-1.5 text-[11px] font-mono",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"flex items-center gap-1.5 text-neutral-400",children:[r.jsx(dt,{className:"h-3.5 w-3.5 text-primary/80"}),"Throughput"]}),r.jsxs("span",{className:"text-primary drop-shadow-[0_0_8px_rgba(0,196,167,0.6)]",children:[p.rps," RPS"]})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"flex items-center gap-1.5 text-neutral-400",children:[r.jsx(Fe,{className:"h-3.5 w-3.5 text-danger/80"}),"Active threats"]}),r.jsx("span",{className:X("drop-shadow-[0_0_8px_rgba(255,63,114,0.45)]",p.activeThreats>0?"text-danger-400":"text-neutral-300"),children:p.activeThreats})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-neutral-400",children:"System health"}),r.jsx("span",{className:X("uppercase",e.status==="healthy"?"text-success-500 drop-shadow-[0_0_8px_rgba(16,185,129,0.45)]":"text-danger-400 drop-shadow-[0_0_8px_rgba(255,63,114,0.45)]"),children:e.status})]})]})]}),o.thoughts.visible&&r.jsxs("div",{className:"pointer-events-auto fixed w-[340px] rounded-md bg-neutral-950/65 px-3 py-2.5 backdrop-blur-sm shadow-[0_20px_50px_rgba(0,0,0,0.55)]",style:{left:o.thoughts.x,top:o.thoughts.y},children:[r.jsx("div",{className:"mb-2 flex items-center justify-between cursor-move",onPointerDown:y=>x("thoughts",y),onKeyDown:y=>m("thoughts",y),tabIndex:0,role:"button","aria-roledescription":"drag handle","aria-description":"Use arrow keys to reposition","aria-label":"Drag AI thought widget",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono uppercase tracking-widest text-primary/80",children:[r.jsx($l,{className:"h-3 w-3"}),"AI Thought Stream"]})}),r.jsx("div",{className:"space-y-1.5",children:f.length===0?r.jsx("p",{className:"text-[11px] font-mono text-neutral-500",children:"Awaiting autopilot thoughts..."}):f.map(y=>r.jsxs("div",{className:"rounded-sm bg-black/30 px-2 py-1.5",children:[r.jsxs("div",{className:"mb-0.5 flex items-center justify-between text-[10px] font-mono text-neutral-500",children:[r.jsx("span",{className:"uppercase",children:y.phase}),r.jsx("span",{children:new Date(y.at).toLocaleTimeString()})]}),r.jsxs("p",{className:"text-[11px] text-neutral-200 leading-relaxed",children:[r.jsx(rd,{className:"mr-1 inline h-3.5 w-3.5 text-primary/80"}),y.message]})]},y.id))})]})]}),document.body)}function yi({className:e,backdrop:t=!0,children:n,...s}){return r.jsxs("div",{className:X("relative isolate space-y-6 overflow-hidden rounded-sm pb-2 animate-in fade-in duration-500",e),...s,children:[t&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"pointer-events-none absolute inset-0 -z-10 bg-[radial-gradient(circle_at_12%_0%,rgba(56,160,255,0.14),transparent_42%),radial-gradient(circle_at_88%_80%,rgba(56,160,255,0.08),transparent_38%)]"}),r.jsx("div",{className:"pointer-events-none absolute inset-0 -z-10 opacity-40 bg-[repeating-linear-gradient(0deg,transparent_0px,transparent_3px,rgba(5,9,20,0.55)_4px)]"})]}),n]})}function jA(){return r.jsx("svg",{"aria-hidden":"true",className:"absolute h-0 w-0 overflow-hidden",focusable:"false",children:r.jsxs("defs",{children:[r.jsx("filter",{id:"crt-noise-filter-lite",x:"-5%",y:"-5%",width:"110%",height:"110%",children:r.jsx("feColorMatrix",{in:"SourceGraphic",type:"matrix",values:"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0.72 0"})}),r.jsx("filter",{id:"crt-chromatic-filter-lite",x:"-5%",y:"-5%",width:"110%",height:"110%",children:r.jsxs("feComponentTransfer",{children:[r.jsx("feFuncR",{type:"linear",slope:"1.02",intercept:"0"}),r.jsx("feFuncG",{type:"linear",slope:"0.98",intercept:"0"}),r.jsx("feFuncB",{type:"linear",slope:"1.03",intercept:"0"})]})})]})})}function kA(){const[e,t]=h.useState(!1);return h.useEffect(()=>{const n=window.matchMedia("(prefers-reduced-motion: reduce)"),s=a=>{t(a.matches)};return t(n.matches),typeof n.addEventListener=="function"?(n.addEventListener("change",s),()=>n.removeEventListener("change",s)):(n.addListener(s),()=>n.removeListener(s))},[]),e}const EA=1500,_A=250,CA=450,TA=0,RA=6500,AA=1600,MA=2200,IA=300;function PA(e,t){return e?t?TA:CA:t?_A:EA}function OA(e){return e?AA:RA}function LA(e){return e?IA:MA}function DA(e){return e.hasExitedBoot||e.dismissed?!1:e.minimumBootElapsed?e.providerReady?!1:!e.maxWaitElapsed||!e.timeoutNoticeElapsed:!0}function $A(e,t,n){var u;if(n.length===0)return 100;const s=Math.max(0,Math.min(e,n.length)),a=Math.min(s,n.length),o=((u=n[s])==null?void 0:u.length)??0,i=o>0?Math.max(0,t)/o:0,l=Math.min(n.length,a+i);return Math.round(l/n.length*100)}function zA(e){const t=Math.max(0,Math.min(e,100));return Math.floor(t/25)*25}function FA(e){const t=Math.max(0,Math.min(e,100));return`${Math.max(8,t)}%`}const dn=["Mounting gRPC listeners... OK","Syncing deception profiles... OK","Connecting to cluster nodes... OK","Calibrating threat telemetry... OK","Hydrating tactical dashboard... OK"],Xu="apparatus-terminal-boot-seen";function BA({children:e}){var E;const t=kA(),{health:n,hasCompletedInitialHealthCheck:s}=je(),[a,o]=h.useState(()=>{try{return sessionStorage.getItem(Xu)==="1"}catch{return!1}}),[i,l]=h.useState(!1),[u,c]=h.useState(!1),[d,f]=h.useState(!1),[p,x]=h.useState(!1),[g,m]=h.useState(!1),[y,b]=h.useState(0),[v,N]=h.useState(0),w=h.useRef(null),j=h.useRef(null),k=h.useRef(null),_=PA(t,a),P=OA(t),T=s;h.useEffect(()=>{if(i)return;const A=window.setTimeout(()=>{l(!0)},_);return()=>window.clearTimeout(A)},[_,i]),h.useEffect(()=>{if(u)return;const A=window.setTimeout(()=>{c(!0)},P);return()=>window.clearTimeout(A)},[P,u]),h.useEffect(()=>{if(!u||T)return;const A=window.setTimeout(()=>{f(!0)},LA(t));return()=>window.clearTimeout(A)},[u,T,t]),h.useEffect(()=>{if(y>=dn.length)return;const A=dn[y];if(v<A.length){const F=t?4:18,L=window.setTimeout(()=>{N(M=>M+1)},F);return()=>window.clearTimeout(L)}const O=t?24:160,I=window.setTimeout(()=>{b(F=>F+1),N(0)},O);return()=>window.clearTimeout(I)},[y,v,t]),h.useEffect(()=>{if(p)return;const A=O=>{O.key==="Escape"&&m(!0)};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[p]);const $=DA({hasExitedBoot:p,dismissed:g,minimumBootElapsed:i,providerReady:T,maxWaitElapsed:u,timeoutNoticeElapsed:d});h.useEffect(()=>{var A;$&&((A=k.current)==null||A.focus())},[$]);const B=n.status==="healthy"?"ONLINE":n.status.toUpperCase(),D=h.useMemo(()=>$A(y,v,dn),[y,v]),R=h.useMemo(()=>zA(D),[D]),S=dn.slice(0,Math.min(y,dn.length)),C=((E=dn[y])==null?void 0:E.slice(0,v))??"";return h.useEffect(()=>{var A;if(j.current===null){j.current=$;return}if(!$){try{sessionStorage.setItem(Xu,"1")}catch{}o(!0),x(!0)}j.current&&!$&&((A=w.current)==null||A.focus()),j.current=$},[$]),$?r.jsxs("section",{className:"crt-shell relative flex min-h-screen items-center justify-center overflow-hidden bg-neutral-950 px-6 text-neutral-100 animate-fade-in","aria-label":"Application loading sequence",children:[r.jsx("div",{"aria-hidden":!0,className:"crt-chromatic-layer"}),r.jsxs("div",{className:"relative z-10 w-full max-w-3xl rounded-sm border border-primary/25 bg-black/65 px-5 py-5 shadow-panel backdrop-blur-sm md:px-7 md:py-6",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsx("p",{className:"text-[0.62rem] uppercase tracking-[0.28em] text-primary/80 font-mono terminal-flicker",children:"Cybersecurity Lab Initialization Sequence"}),r.jsx("button",{type:"button",onClick:()=>m(!0),"aria-label":"Skip boot sequence (Escape)",ref:k,className:"rounded-sm border border-white/20 px-2 py-1 text-[0.58rem] font-mono uppercase tracking-[0.14em] text-neutral-300 transition-colors hover:border-primary/60 hover:text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary",children:"Skip Boot"})]}),r.jsxs("div",{className:"mt-4 space-y-1 rounded-sm border border-white/5 bg-black/40 p-4 font-mono text-[0.76rem] leading-relaxed text-neutral-300 md:text-[0.8rem]",children:[S.map(A=>r.jsxs("p",{children:[r.jsx("span",{className:"text-primary/80",children:"[ok]"})," ",A]},A)),y<dn.length?r.jsxs("p",{className:"text-neutral-200",children:[r.jsx("span",{className:"text-primary/80",children:"[~]"})," ",C,r.jsx("span",{className:"terminal-caret","aria-hidden":!0,children:"_"})]}):T?null:r.jsxs("p",{className:"text-neutral-400",children:[r.jsx("span",{className:"text-warning",children:"[wait]"})," Awaiting telemetry heartbeat..."]})]}),r.jsxs("div",{className:"mt-4 flex items-center justify-between gap-4 border-t border-white/10 pt-3 font-mono text-[0.62rem] uppercase tracking-[0.2em] text-neutral-500",children:[r.jsxs("span",{children:["Status:"," ",r.jsx("span",{className:"terminal-flicker text-primary",children:B})]}),r.jsxs("span",{children:["Boot ",D,"%"]})]}),r.jsx("div",{className:"mt-2 h-1.5 rounded-full bg-neutral-900",children:r.jsx("div",{className:"h-full rounded-full bg-primary/80 shadow-[0_0_10px_rgba(0,196,167,0.45)] transition-[width] duration-200 ease-out",style:{width:FA(D)},role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":D,"aria-label":"Boot progress"})}),r.jsxs("p",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:["Loading application: ",R,"% complete."]}),u&&!T&&r.jsx("p",{className:"mt-3 text-[0.65rem] font-mono text-warning","aria-live":"polite",children:"Server connection pending. Dashboard will reconnect automatically."})]})]}):r.jsxs("div",{className:t?"":"animate-fade-in",ref:w,tabIndex:-1,children:[e,!T&&r.jsx("p",{className:"sr-only","aria-live":"polite","aria-atomic":"true",children:"Server connection pending. Dashboard will reconnect automatically."})]})}function HA(){const[e,t]=h.useState(!1),{selectedDocId:n,closeDoc:s}=Ai(),{health:a}=je(),o=a.status==="healthy"?"8px":a.status==="degraded"?"2px":a.status==="critical"||a.status==="unhealthy"?"0px":"6px";return h.useEffect(()=>{const i=l=>{(l.metaKey||l.ctrlKey)&&l.shiftKey&&l.key==="?"&&(l.preventDefault(),t(!0))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[]),r.jsx(BA,{children:r.jsxs("div",{className:"crt-shell type-body flex h-screen bg-neutral-950 text-neutral-100 font-sans antialiased selection:bg-primary-500/30 overflow-hidden",style:{"--ui-radius":o},children:[r.jsx("div",{"aria-hidden":!0,className:"crt-chromatic-layer"}),r.jsx(mT,{}),r.jsx(gT,{open:e,onOpenChange:t,onSelectDoc:()=>{t(!1)}}),r.jsx(Mx,{docId:n,onClose:s}),r.jsx(Td,{}),r.jsxs("div",{className:"flex flex-col flex-1 min-w-0 relative",children:[r.jsx(Rd,{}),r.jsx(Ad,{children:r.jsx(yi,{children:r.jsx(bg,{})})})]})]})})}function UA(){return r.jsx(gg,{basename:"/dashboard",children:r.jsx(py,{children:r.jsx(cy,{children:r.jsxs(my,{children:[r.jsx(jA,{}),r.jsx(SA,{}),r.jsxs(yg,{children:[r.jsx(Le,{path:"docs",element:r.jsx(yi,{children:r.jsx(Ku,{})})}),r.jsx(Le,{path:"docs/:docId",element:r.jsx(yi,{children:r.jsx(Ku,{})})}),r.jsxs(Le,{path:"/",element:r.jsx(HA,{}),children:[r.jsx(Le,{index:!0,element:r.jsx(Hy,{})}),r.jsx(Le,{path:"traffic",element:r.jsx($1,{})}),r.jsx(Le,{path:"timeline",element:r.jsx(fm,{})}),r.jsx(Le,{path:"fingerprints",element:r.jsx(NC,{})}),r.jsx(Le,{path:"defense",element:r.jsx(qy,{})}),r.jsx(Le,{path:"deception",element:r.jsx(Xy,{})}),r.jsx(Le,{path:"chaos",element:r.jsx(Vy,{})}),r.jsx(Le,{path:"cluster",element:r.jsx(Ab,{})}),r.jsx(Le,{path:"webhooks",element:r.jsx(B1,{})}),r.jsx(Le,{path:"mtd",element:r.jsx(U1,{})}),r.jsx(Le,{path:"testing",element:r.jsx(tN,{})}),r.jsx(Le,{path:"network",element:r.jsx(sN,{})}),r.jsx(Le,{path:"identity",element:r.jsx(uN,{})}),r.jsx(Le,{path:"scenarios",element:r.jsx(B_,{})}),r.jsx(Le,{path:"drill",element:r.jsx(V_,{})}),r.jsx(Le,{path:"ghosts",element:r.jsx(uC,{})}),r.jsx(Le,{path:"autopilot",element:r.jsx(iC,{})}),r.jsx(Le,{path:"settings",element:r.jsx(dN,{})}),r.jsx(Le,{path:"dependencies",element:r.jsx(G_,{})}),r.jsx(Le,{path:"listeners",element:r.jsx(hC,{})})]})]})]})})})})}To.createRoot(document.getElementById("root")).render(r.jsx(q.StrictMode,{children:r.jsx(UA,{})}));
|