diff --git a/.dockerignore b/.dockerignore index e64e9b5..fc01fc8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -15,6 +15,14 @@ configs frontend/node_modules frontend/dist gensui +!gensui/ +!gensui/** +gensui/.env +gensui/certs +gensui/data +gensui/logs +gensui/frontend/node_modules +gensui/frontend/dist tests certs *.db diff --git a/.env.example b/.env.example index 3bc5e37..0780dde 100644 --- a/.env.example +++ b/.env.example @@ -22,6 +22,16 @@ QDRANT_PATH=./data/qdrant # Security SECRET_KEY=change-me-to-a-random-64-char-string VAULT_ENCRYPTION_KEY=change-me-to-a-fernet-base64-key +SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN= + +# Outbound A2A/Gensui destination policy +A2A_DESTINATION_POLICY=private_allowed +GENSUI_DESTINATION_POLICY=loopback_allowed +OUTBOUND_ALLOWLIST= +ALLOW_HTTP_ON_PRIVATE_NETWORK=true +ALLOW_HTTP_ON_PUBLIC_NETWORK=false +A2A_ALLOWED_PORTS= +GENSUI_ALLOWED_PORTS= # Storage VAULT_PATH=./vault diff --git a/.env.server.example b/.env.server.example index d7df310..c491935 100644 --- a/.env.server.example +++ b/.env.server.example @@ -10,6 +10,16 @@ POSTGRES_PASSWORD=change-me-postgres-password SECRET_KEY=change-me-to-a-random-64-char-string VAULT_ENCRYPTION_KEY=change-me-to-an-independent-random-64-char-string +SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN=change-me-to-an-independent-infrastructure-admin-token + +# Outbound federation policy. Metadata and link-local addresses are always blocked. +A2A_DESTINATION_POLICY=private_allowed +GENSUI_DESTINATION_POLICY=private_allowed +OUTBOUND_ALLOWLIST= +ALLOW_HTTP_ON_PRIVATE_NETWORK=true +ALLOW_HTTP_ON_PUBLIC_NETWORK=false +A2A_ALLOWED_PORTS= +GENSUI_ALLOWED_PORTS= # Optional communication channels. They can also be configured in The Tenshu. TELEGRAM_BOT_TOKEN= diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..103bb65 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: /frontend + schedule: + interval: weekly + - package-ecosystem: npm + directory: /gensui/frontend + schedule: + interval: weekly + - package-ecosystem: pip + directory: / + schedule: + interval: weekly + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..68f3ce1 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,27 @@ +name: CodeQL + +on: + pull_request: + push: + branches: [main] + schedule: + - cron: "41 3 1 * *" + workflow_dispatch: + +permissions: + contents: read + security-events: write + +jobs: + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + language: [python, javascript-typescript] + steps: + - uses: actions/checkout@v6 + - uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + - uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/security-hardening.yml b/.github/workflows/security-hardening.yml new file mode 100644 index 0000000..36ac29c --- /dev/null +++ b/.github/workflows/security-hardening.yml @@ -0,0 +1,194 @@ +name: Security hardening + +on: + pull_request: + push: + branches: [main] + schedule: + - cron: "23 4 * * 1" + workflow_dispatch: + +permissions: + contents: read + +jobs: + python: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 + with: + python-version: "3.12" + cache: pip + - name: Install CPU runtime and development dependencies + run: | + python -m pip install --upgrade pip + python -m pip install --index-url https://download.pytorch.org/whl/cpu "torch>=2.4.0" + python -m pip install -e ".[dev,office]" + - name: Import and lint + run: | + python -c "import shogun.app; import gensui.app" + # Full-tree lint has substantial pre-existing debt. Gate the security + # boundary and deployment-path files introduced by this remediation. + python -m ruff check \ + shogun/api/a2a.py \ + shogun/api/gensui_config.py \ + shogun/api/infrastructure_auth.py \ + shogun/config.py \ + shogun/integrations/a2a_client.py \ + shogun/services/ssrf_guard.py \ + gensui/app.py \ + gensui/config.py \ + tests/test_ssrf_guard.py \ + tests/test_gensui_frontend.py + - name: Security regression tests + # The repository-wide suite has unrelated pre-existing failures. Keep + # this required gate scoped to the remediation's 39 regression cases. + run: python -m pytest -q tests/test_ssrf_guard.py tests/test_gensui_frontend.py + + frontends: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - name: Tenshu + directory: frontend + lockfile: frontend/package-lock.json + - name: Gensui + directory: gensui/frontend + lockfile: gensui/frontend/package-lock.json + name: Frontend - ${{ matrix.name }} + defaults: + run: + working-directory: ${{ matrix.directory }} + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: "22" + cache: npm + cache-dependency-path: ${{ matrix.lockfile }} + package-manager-cache: true + - run: npm ci + - name: High/Critical dependency gate + run: npm run audit:security + # The repository has pre-existing full-tree lint debt. Keep the complete + # lint command available while gating newly added security boundary code. + - run: npm run lint:security + - run: npm run build + - name: XSS regression tests + if: matrix.directory == 'frontend' + run: npm run test:security + + repository-security: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Trivy repository, secret, and misconfiguration scan + uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 + with: + scan-type: fs + scan-ref: . + scanners: vuln,secret,misconfig + severity: HIGH,CRITICAL + ignore-unfixed: true + trivyignores: .trivyignore.yaml + exit-code: "1" + + gensui-container: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v6 + - name: Build Gensui + run: docker build --file gensui/Dockerfile --tag shogun-gensui:ci . + - name: Scan Gensui image + uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 + with: + image-ref: shogun-gensui:ci + severity: HIGH,CRITICAL + ignore-unfixed: true + exit-code: "1" + - name: Run hardened Gensui smoke test + run: | + docker volume create gensui-ci-data + docker volume create gensui-ci-logs + docker run -d --name gensui-ci \ + --read-only --tmpfs /tmp:rw,noexec,nosuid,size=256m \ + --cap-drop ALL --security-opt no-new-privileges:true \ + -e GENSUI_JWT_SECRET=ci-only-random-jwt-secret-0123456789 \ + -e GENSUI_ADMIN_PASSWORD=ci-only-random-admin-password \ + -p 127.0.0.1:8787:8787 \ + -v gensui-ci-data:/app/data -v gensui-ci-logs:/app/logs \ + shogun-gensui:ci + for attempt in $(seq 1 60); do + curl --fail --silent http://127.0.0.1:8787/api/gensui/health && break + sleep 2 + done + curl --fail --silent http://127.0.0.1:8787/ + curl --fail --silent http://127.0.0.1:8787/agents + login_json="$(curl --fail --silent \ + -H 'Content-Type: application/json' \ + -d '{"email":"admin@gensui.local","password":"ci-only-random-admin-password"}' \ + http://127.0.0.1:8787/api/gensui/auth/login)" + admin_token="$(python -c 'import json,sys; print(json.load(sys.stdin)["token"])' <<<"$login_json")" + curl --fail --silent \ + -H "Authorization: Bearer $admin_token" \ + http://127.0.0.1:8787/api/gensui/dashboard + test "$(docker exec gensui-ci whoami)" = "gensui" + docker exec gensui-ci sh -c "grep -R '/api/gensui' /app/frontend/dist/assets >/dev/null" + if docker exec gensui-ci sh -c "grep -R '/api/v1' /app/frontend/dist/assets >/dev/null"; then + echo "Gensui bundle unexpectedly references the Tenshu API prefix" >&2 + exit 1 + fi + - name: Gensui logs + if: failure() + run: docker logs gensui-ci || true + - name: Clean up Gensui + if: always() + run: | + docker rm -f gensui-ci || true + docker volume rm gensui-ci-data gensui-ci-logs || true + + shogun-server-container: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v6 + - name: Build Shogun Server + run: docker build --tag shogun-server:ci . + - name: Prepare Shogun Server environment + run: | + cp .env.server.example .env.server + sed -i 's/change-me-postgres-password/ci-postgres-password/' .env.server + sed -i 's/change-me-to-a-random-64-char-string/ci-application-secret-0123456789/' .env.server + sed -i 's/change-me-to-an-independent-random-64-char-string/ci-vault-secret-0123456789/' .env.server + sed -i 's/change-me-to-an-independent-infrastructure-admin-token/ci-infrastructure-token-0123456789/' .env.server + - name: Scan Shogun image + uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 + with: + image-ref: shogun-server:ci + severity: HIGH,CRITICAL + ignore-unfixed: true + exit-code: "1" + - name: Start Shogun Server profile + run: | + docker tag shogun-server:ci shogun-server:local + docker compose --env-file .env.server -f docker-compose.server.yml up -d --no-build + for attempt in $(seq 1 120); do + curl --fail --silent http://127.0.0.1:8000/api/v1/health && break + sleep 2 + done + curl --fail --silent http://127.0.0.1:8000/ + curl --fail --silent http://127.0.0.1:8000/setup + test "$(docker exec shogun-server whoami)" = "shogun" + - name: Launch Mado Chromium as the runtime user + run: | + docker exec shogun-server python -c "import asyncio; from playwright.async_api import async_playwright; exec('async def smoke():\n async with async_playwright() as p:\n browser = await p.chromium.launch(headless=True)\n page = await browser.new_page()\n await page.set_content(\"mado-smoke\")\n assert await page.title() == \"mado-smoke\"\n await browser.close()\nasyncio.run(smoke())')" + - name: Shogun Server logs + if: failure() + run: docker compose --env-file .env.server -f docker-compose.server.yml logs + - name: Clean up Shogun Server + if: always() + run: docker compose --env-file .env.server -f docker-compose.server.yml down --volumes diff --git a/.gitignore b/.gitignore index 814e66e..ee37695 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,8 @@ qdrant_data/ # ── Local-only assets ──────────────────────────────────────── Blueprints and Requirement specs/ Assets/ +!frontend/public/assets/ +!frontend/public/assets/** docker-compose.yml scratch/ diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +22 diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..2bd5a0a --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +22 diff --git a/.trivyignore.yaml b/.trivyignore.yaml new file mode 100644 index 0000000..9329419 --- /dev/null +++ b/.trivyignore.yaml @@ -0,0 +1,10 @@ +vulnerabilities: + - id: GHSA-qwww-vcr4-c8h2 + paths: + - "frontend/package-lock.json" + - "gensui/frontend/package-lock.json" + expired_at: 2026-08-31 + statement: >- + The advisory affects unstable React Server Components APIs, which these + Vite SPAs do not use. No patched react-router-dom 7.x release exists; + reassess the React Router 8 migration before this exception expires. diff --git a/Dockerfile b/Dockerfile index 965cbcb..12357d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,11 @@ COPY shogun/ ./shogun/ COPY migrations/ ./migrations/ RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu "torch>=2.4.0" \ - && pip install --no-cache-dir ".[postgres,office]" \ + && pip install --no-cache-dir ".[server]" \ + && pip install --no-cache-dir --upgrade \ + "jaraco.context>=6.1.0" \ + "setuptools>=78.1.1" \ + "wheel>=0.46.2" \ && python -m playwright install --with-deps chromium \ && rm -rf /var/lib/apt/lists/* /root/.cache @@ -43,7 +47,9 @@ RUN groupadd --gid 10001 shogun \ && mkdir -p /app/data /app/vault /app/logs /app/configs /app/tmp \ && touch /app/.env \ && chmod 0755 /usr/local/bin/shogun-entrypoint \ - && chown -R shogun:shogun /app /ms-playwright + && chown -R shogun:shogun \ + /app/data /app/vault /app/logs /app/configs /app/tmp /app/.env \ + && chmod -R a+rX /ms-playwright USER shogun diff --git a/Gensui-Docker-Install.bat b/Gensui-Docker-Install.bat index 1bf8cad..4f3362b 100644 --- a/Gensui-Docker-Install.bat +++ b/Gensui-Docker-Install.bat @@ -119,9 +119,11 @@ cd /d "%INSTALL_DIR%" if not exist ".env" ( copy ".env.example" ".env" >nul 2>&1 :: Generate random JWT secret using PowerShell - for /f "usebackq tokens=*" %%i in (`powershell -NoProfile -Command "[Convert]::ToBase64String([Guid]::NewGuid().ToByteArray() + [Guid]::NewGuid().ToByteArray() + [Guid]::NewGuid().ToByteArray()).Replace('=', '').Replace('+', '').Replace('/', '')"`) do set JWT_SECRET=%%i - powershell -NoProfile -Command "(Get-Content .env) -replace 'change-me-to-a-random-64-char-string', '%JWT_SECRET%' | Set-Content .env" - echo [OK] .env created with secure random JWT secret. + for /f "usebackq tokens=*" %%i in (`powershell -NoProfile -Command "$b=New-Object byte[] 48; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($b); [Convert]::ToBase64String($b).Replace('=', '').Replace('+', '').Replace('/', '')"`) do set JWT_SECRET=%%i + for /f "usebackq tokens=*" %%i in (`powershell -NoProfile -Command "$b=New-Object byte[] 32; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($b); [Convert]::ToBase64String($b).Replace('=', '').Replace('+', '').Replace('/', '')"`) do set ADMIN_SECRET=%%i + powershell -NoProfile -Command "$c=Get-Content -Raw .env; $c=$c.Replace('change-me-to-a-random-64-char-string','%JWT_SECRET%').Replace('change-me-to-a-random-admin-password','%ADMIN_SECRET%'); Set-Content -Encoding Ascii .env $c" + echo [OK] .env created with secure random JWT and admin secrets. + echo [i] The generated admin password is stored in %INSTALL_DIR%\.env. ) else ( echo [OK] .env already exists — keeping existing config. ) diff --git a/Gensui-Docker-Install.sh b/Gensui-Docker-Install.sh index c2b5b82..624e3d4 100644 --- a/Gensui-Docker-Install.sh +++ b/Gensui-Docker-Install.sh @@ -156,12 +156,17 @@ if [ ! -f ".env" ]; then # Generate random JWT secret JWT_SECRET=$(openssl rand -base64 48 | tr -d '\n' | tr -d '=' | tr -d '+' | tr -d '/') + ADMIN_SECRET=$(openssl rand -base64 36 | tr -d '\n' | tr -d '=' | tr -d '+' | tr -d '/') if [[ "$OSTYPE" == "darwin"* ]]; then sed -i '' "s/change-me-to-a-random-64-char-string/$JWT_SECRET/" .env + sed -i '' "s/change-me-to-a-random-admin-password/$ADMIN_SECRET/" .env else sed -i "s/change-me-to-a-random-64-char-string/$JWT_SECRET/" .env + sed -i "s/change-me-to-a-random-admin-password/$ADMIN_SECRET/" .env fi - echo -e " ${GREEN}✅ .env created with secure random JWT secret.${NC}" + echo -e " ${GREEN}✅ .env created with secure random JWT and admin secrets.${NC}" + echo -e " ${GRAY}The generated admin password is stored in $INSTALL_DIR/.env (mode 600).${NC}" + chmod 600 .env else echo -e " ${GREEN}✅ .env already exists — keeping existing config.${NC}" fi diff --git a/README.md b/README.md index 6bd4b7b..e75e850 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,8 @@ Download one installer from the [latest GitHub release](https://github.com/Alpha The installer downloads Shogun, creates the Python environment, installs dependencies, builds The Tenshu, creates a desktop shortcut, and opens the Setup Wizard. -Shogun requires **Python 3.10+** and **Node.js 20.19+** (or 22.12+). The installer checks that both runtimes are available and provides installation links when they are missing. +Shogun requires **Python 3.10+**. Frontend builds and CI use **Node.js 22.12+**; +`.nvmrc` and `.node-version` pin the supported major. ### Complete the Setup Wizard @@ -94,7 +95,8 @@ Server mode runs Shogun and The Tenshu continuously in containers with dedicated The Server installer: -- Generates independent application, vault-encryption, and PostgreSQL secrets. +- Generates independent application, vault-encryption, infrastructure-admin, + and PostgreSQL secrets. - Builds Shogun and The Tenshu as a non-root container. - Starts PostgreSQL and Qdrant on an internal Docker network. - Stores application data, memories, configuration, vault content, and logs in named volumes. @@ -104,12 +106,20 @@ The Server installer: After installation, the Primary Admin opens [http://127.0.0.1:8000/setup](http://127.0.0.1:8000/setup) on the server and selects Single-user or Team mode. Team members communicate through Telegram or Microsoft Teams; they do not receive access to The Tenshu. +Privileged Gensui connection and Nexus peer-invitation actions require the +generated infrastructure token in Server mode. Paste it into the corresponding +Tenshu field; it is kept only for the browser-tab session. See the +[outbound destination security guide](docs/security/outbound-destination-policy.md). + > **Secure by default:** Do not change `SHOGUN_BIND_ADDRESS` to a public interface without placing The Tenshu behind an authenticated HTTPS reverse proxy. For remote administration, prefer a VPN or SSH tunnel. > **Important — Ronin does not work in Server mode:** A container cannot safely access the server's physical desktop. Ronin screenshots, mouse and keyboard control, native application control, and host-desktop sessions are therefore disabled and rejected by the server. Selecting the Torii posture named RONIN does not override this container boundary. Use a normal desktop installation when Ronin Desktop Control is required. Mado browser automation still works because its managed Chromium browser runs inside the container. Agent Flows, Flow Stacking, Telegram, Teams, Nexus, memory, ToolGate, HARAKIRI, and externally hosted local-model services such as Ollama remain available. +See the [Docker capability matrix and migration guide](docs/deployment/docker.md) +for the complete native-versus-headless scope. +
Start Server mode from a source checkout @@ -257,7 +267,9 @@ Download one installer from the [latest GitHub release](https://github.com/Alpha | **Linux/macOS Docker server** | [⬇️ Gensui-Docker-Install.sh](https://github.com/AlphaHorizon-AI/Shogun/releases/latest/download/Gensui-Docker-Install.sh) | Run `bash Gensui-Docker-Install.sh` | | **Windows Docker server** | [⬇️ Gensui-Docker-Install.bat](https://github.com/AlphaHorizon-AI/Shogun/releases/latest/download/Gensui-Docker-Install.bat) | Double-click the downloaded file | -Gensui opens at [http://localhost:8787](http://localhost:8787). Change the default administrator password immediately after first login. +Gensui opens at [http://localhost:8787](http://localhost:8787). The Docker +installers generate a random initial administrator password in the protected +`.env` file; rotate it after first login.
Developer installation for Gensui diff --git a/RELEASE_NOTES_SECURITY_HARDENING.md b/RELEASE_NOTES_SECURITY_HARDENING.md new file mode 100644 index 0000000..70a4322 --- /dev/null +++ b/RELEASE_NOTES_SECURITY_HARDENING.md @@ -0,0 +1,50 @@ +# Unreleased — Security and deployment hardening + +This release accepts and remediates the public findings in issues #3–#11. + +## Security + +- Escapes user-controlled Kaizen mandate content before the supported Markdown + subset is converted to HTML, preventing stored script/HTML execution. +- Adds policy-based outbound destination controls for A2A and Gensui with + permanent metadata/link-local blocking, all-address DNS checks, disabled + redirects, scheme and port controls, allowlists, and structured security logs. +- Restricts infrastructure-changing routes to the local Primary Admin in + desktop mode or a secret infrastructure token in server mode. +- Refreshes both frontend dependency trees. One non-reachable React Router RSC + advisory has a narrow, machine-enforced temporary exception documented in + `docs/security/frontend-dependency-exceptions.md`. + +## Gensui Docker + +- Declares the bcrypt and PyJWT runtime dependencies. +- Uses a canonical configurable frontend distribution path and always builds the + Gensui UI from the repository-root Docker context. +- Adds the official local-only Compose profile, generated secrets, health + ordering, a non-root runtime, read-only application filesystem, dropped + capabilities, and `no-new-privileges`. +- Existing root-owned volumes must be backed up and changed to UID/GID 1000. + Full migration and rollback commands are in `docs/deployment/docker.md`. + +## Shogun Server / Headless + +- Documents the production container as a Server / Headless profile rather than + native-feature parity. +- Validates non-root Playwright installation, health, persistent state, local + binding, and explicit Ronin/Office limitations in CI. + +## Prevention + +- Adds Python, frontend, dependency, CodeQL, Docker smoke, secret, + misconfiguration, and image scan gates. +- Pins Node 22 as the supported build major and adds weekly dependency and + container checks. + +## Security contributors + +Special thanks to [@wstlima](https://github.com/wstlima) for the valuable, +well-documented security, dependency, Docker, and deployment review behind +issues #3–#11 and pull requests #12–#20. Alpha Horizon reviewed and accepted the +findings; the original straightforward pull requests were merged so the +contribution remains visibly attached to Shogun's history. PRs #18 and #20 were +accepted through architecture-adjusted replacement implementations. diff --git a/Shogun-Server-Install.bat b/Shogun-Server-Install.bat index 477027d..ee9544c 100644 --- a/Shogun-Server-Install.bat +++ b/Shogun-Server-Install.bat @@ -61,10 +61,11 @@ cd /d "%INSTALL_DIR%" echo [3/5] Configuring secrets... if not exist ".env.server" ( copy /y ".env.server.example" ".env.server" >nul - for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "-join ((1..64) | ForEach-Object { '{0:x}' -f (Get-Random -Maximum 16) })"`) do set "POSTGRES_SECRET=%%i" - for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "-join ((1..64) | ForEach-Object { '{0:x}' -f (Get-Random -Maximum 16) })"`) do set "APPLICATION_SECRET=%%i" - for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "-join ((1..64) | ForEach-Object { '{0:x}' -f (Get-Random -Maximum 16) })"`) do set "VAULT_SECRET=%%i" - powershell -NoProfile -ExecutionPolicy Bypass -Command "$p='.env.server'; $c=Get-Content -Raw -LiteralPath $p; $c=$c.Replace('change-me-postgres-password','!POSTGRES_SECRET!').Replace('change-me-to-a-random-64-char-string','!APPLICATION_SECRET!').Replace('change-me-to-an-independent-random-64-char-string','!VAULT_SECRET!'); Set-Content -LiteralPath $p -Value $c -Encoding utf8" + for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "$b=New-Object byte[] 32; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($b); -join ($b | ForEach-Object { $_.ToString('x2') })"`) do set "POSTGRES_SECRET=%%i" + for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "$b=New-Object byte[] 32; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($b); -join ($b | ForEach-Object { $_.ToString('x2') })"`) do set "APPLICATION_SECRET=%%i" + for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "$b=New-Object byte[] 32; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($b); -join ($b | ForEach-Object { $_.ToString('x2') })"`) do set "VAULT_SECRET=%%i" + for /f "usebackq delims=" %%i in (`powershell -NoProfile -Command "$b=New-Object byte[] 32; [Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($b); -join ($b | ForEach-Object { $_.ToString('x2') })"`) do set "INFRASTRUCTURE_SECRET=%%i" + powershell -NoProfile -ExecutionPolicy Bypass -Command "$p='.env.server'; $c=Get-Content -Raw -LiteralPath $p; $c=$c.Replace('change-me-postgres-password','!POSTGRES_SECRET!').Replace('change-me-to-a-random-64-char-string','!APPLICATION_SECRET!').Replace('change-me-to-an-independent-random-64-char-string','!VAULT_SECRET!').Replace('change-me-to-an-independent-infrastructure-admin-token','!INFRASTRUCTURE_SECRET!'); Set-Content -LiteralPath $p -Value $c -Encoding utf8" ) else ( echo Existing .env.server retained. ) diff --git a/Shogun-Server-Install.sh b/Shogun-Server-Install.sh index c68630a..f4fb296 100644 --- a/Shogun-Server-Install.sh +++ b/Shogun-Server-Install.sh @@ -69,14 +69,17 @@ if [ ! -f .env.server ]; then POSTGRES_SECRET="$(openssl rand -hex 32)" APPLICATION_SECRET="$(openssl rand -hex 32)" VAULT_SECRET="$(openssl rand -hex 32)" + INFRASTRUCTURE_SECRET="$(openssl rand -hex 32)" if [ "$(uname -s)" = "Darwin" ]; then sed -i '' "s/change-me-postgres-password/$POSTGRES_SECRET/" .env.server sed -i '' "s/change-me-to-a-random-64-char-string/$APPLICATION_SECRET/" .env.server sed -i '' "s/change-me-to-an-independent-random-64-char-string/$VAULT_SECRET/" .env.server + sed -i '' "s/change-me-to-an-independent-infrastructure-admin-token/$INFRASTRUCTURE_SECRET/" .env.server else sed -i "s/change-me-postgres-password/$POSTGRES_SECRET/" .env.server sed -i "s/change-me-to-a-random-64-char-string/$APPLICATION_SECRET/" .env.server sed -i "s/change-me-to-an-independent-random-64-char-string/$VAULT_SECRET/" .env.server + sed -i "s/change-me-to-an-independent-infrastructure-admin-token/$INFRASTRUCTURE_SECRET/" .env.server fi chmod 600 .env.server else diff --git a/docker-compose.server.yml b/docker-compose.server.yml index 62ee43a..e1b6d3d 100644 --- a/docker-compose.server.yml +++ b/docker-compose.server.yml @@ -19,6 +19,14 @@ services: SHOGUN_NO_BROWSER: "true" SECRET_KEY: ${SECRET_KEY} VAULT_ENCRYPTION_KEY: ${VAULT_ENCRYPTION_KEY} + SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN: ${SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN} + A2A_DESTINATION_POLICY: ${A2A_DESTINATION_POLICY:-private_allowed} + GENSUI_DESTINATION_POLICY: ${GENSUI_DESTINATION_POLICY:-private_allowed} + OUTBOUND_ALLOWLIST: ${OUTBOUND_ALLOWLIST:-} + ALLOW_HTTP_ON_PRIVATE_NETWORK: ${ALLOW_HTTP_ON_PRIVATE_NETWORK:-true} + ALLOW_HTTP_ON_PUBLIC_NETWORK: ${ALLOW_HTTP_ON_PUBLIC_NETWORK:-false} + A2A_ALLOWED_PORTS: ${A2A_ALLOWED_PORTS:-} + GENSUI_ALLOWED_PORTS: ${GENSUI_ALLOWED_PORTS:-} DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-shogun}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-shogun} QDRANT_URL: http://qdrant:6333 QDRANT_PATH: /app/data/qdrant diff --git a/docs/deployment/docker.md b/docs/deployment/docker.md new file mode 100644 index 0000000..74cfb8e --- /dev/null +++ b/docs/deployment/docker.md @@ -0,0 +1,78 @@ +# Docker deployment and migration + +Both official profiles bind only to localhost unless an operator explicitly +changes the binding. + +## Shogun Server / Headless profile + +```bash +cp .env.server.example .env.server +# Replace every change-me value. +docker compose --env-file .env.server -f docker-compose.server.yml up -d --build +``` + +The profile runs as UID/GID 10001 with a read-only root filesystem, all Linux +capabilities dropped, `no-new-privileges`, dedicated PostgreSQL and Qdrant +services, and persistent application, vault, log, and configuration volumes. +Playwright browsers are installed at `/ms-playwright` and are executable by the +runtime user. + +| Capability | Native Windows | Native Linux | Native macOS | Server / Headless Docker | +|---|---:|---:|---:|---:| +| Core runtime and Tenshu UI | Yes | Yes | Yes | Yes | +| Team Mode, Agent Flows, stacks | Yes | Yes | Yes | Yes | +| Gensui, Nexus, Telegram, Teams | Yes | Yes | Yes | Yes | +| Mado headless Chromium | Yes | Yes | Yes | Yes | +| Mado visible browser | Yes | Environment-dependent | Environment-dependent | No by default | +| Office App Mode / Windows COM | Yes | No | No | No | +| Ronin host-desktop control | Yes | Environment-dependent | Environment-dependent | No | +| Host or LAN model server | Yes | Yes | Yes | Yes, with explicit network configuration | + +Do not describe this profile as native-feature parity. Use native Windows when +Office COM or full Ronin desktop control is required. + +## Gensui + +The Gensui Dockerfile must be built from the repository root: + +```bash +docker build -f gensui/Dockerfile . +cd gensui +cp .env.example .env +# Replace both change-me secrets. +docker compose up -d --build +``` + +The default publishes `127.0.0.1:8787`, runs as UID/GID 1000, drops every +capability, enables `no-new-privileges`, uses a read-only root filesystem, and +writes only to `/app/data`, `/app/logs`, and `/tmp`. The optional `server` +profile starts Nginx for operator-supplied TLS certificates. + +The one-click installers generate both the JWT secret and initial administrator +password. The password is stored in the protected `.env` file and must be +rotated after first login. + +## Existing Gensui volume migration + +Back up before changing ownership: + +```bash +docker compose down +docker run --rm -v gensui_data:/data -v "$PWD:/backup" alpine \ + tar czf /backup/gensui-data-backup.tgz -C /data . +docker run --rm -v gensui_logs:/logs -v "$PWD:/backup" alpine \ + tar czf /backup/gensui-logs-backup.tgz -C /logs . +``` + +Repair volumes created by the former root container: + +```bash +docker run --rm -v gensui_data:/data alpine chown -R 1000:1000 /data +docker run --rm -v gensui_logs:/logs alpine chown -R 1000:1000 /logs +docker compose up -d +``` + +Verify `docker exec gensui whoami`, the health endpoint, login, database writes, +and logs. To roll back, stop the new container, restore the backup archives into +the named volumes, and start the previously pinned image. Do not delete volumes +until the migrated deployment has been verified. diff --git a/docs/reference/environment.md b/docs/reference/environment.md new file mode 100644 index 0000000..e94ed82 --- /dev/null +++ b/docs/reference/environment.md @@ -0,0 +1,19 @@ +# Security and deployment environment variables + +| Variable | Default | Purpose | +|---|---|---| +| `SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN` | empty on desktop; required in server mode | Authorizes A2A peer invitations and Gensui connect/test/disconnect operations | +| `A2A_DESTINATION_POLICY` | `private_allowed` | A2A outbound policy | +| `GENSUI_DESTINATION_POLICY` | `loopback_allowed` on desktop; `private_allowed` in server Compose | Gensui outbound policy | +| `OUTBOUND_ALLOWLIST` | empty | Comma-separated exact hosts, `*.domain` wildcards, IPs, and CIDRs | +| `ALLOW_HTTP_ON_PRIVATE_NETWORK` | `true` | Permit HTTP for private/loopback destinations | +| `ALLOW_HTTP_ON_PUBLIC_NETWORK` | `false` | Permit unencrypted HTTP for public destinations | +| `A2A_ALLOWED_PORTS` | empty | Optional comma-separated A2A port allowlist | +| `GENSUI_ALLOWED_PORTS` | empty | Optional comma-separated Gensui port allowlist | +| `GENSUI_FRONTEND_DIST` | `gensui/frontend/dist` | Canonical Gensui frontend distribution directory | +| `GENSUI_DATA_PATH` | `gensui/data` | Gensui writable data directory | +| `GENSUI_LOG_PATH` | `gensui/logs` | Gensui writable log directory | + +See [Outbound destination security](../security/outbound-destination-policy.md) +for policy semantics and [Docker deployment](../deployment/docker.md) for +container values and migration steps. diff --git a/docs/security/frontend-dependency-exceptions.md b/docs/security/frontend-dependency-exceptions.md new file mode 100644 index 0000000..97c2154 --- /dev/null +++ b/docs/security/frontend-dependency-exceptions.md @@ -0,0 +1,27 @@ +# Frontend dependency security exceptions + +## GHSA-qwww-vcr4-c8h2 — React Router RSC Mode CSRF bypass + +- **Status:** Temporary approved exception +- **Reviewed:** 2026-07-25 +- **Expires:** 2026-08-31 +- **Affected lockfiles:** `frontend/package-lock.json`, `gensui/frontend/package-lock.json` +- **Review owner:** Alpha Horizon + +At review time, npm's advisory ranges leave no React Router 7.x version that +clears every High advisory: versions through 7.17.0 are covered by earlier +router advisories, while GHSA-qwww-vcr4-c8h2 begins at 7.12.0 and has no +compatible patched 7.x release. Downgrading would reintroduce the older XSS, +open-redirect, denial-of-service, and deserialization findings. + +Shogun and Gensui use React Router as browser-only single-page applications. +They do not enable React Server Components, SSR, Framework Mode server actions, +route actions, or RSC action endpoints. The vulnerable RSC request path is +therefore not reachable in either shipped frontend. + +The CI audit gate permits only the exact advisory URL +`https://github.com/advisories/GHSA-qwww-vcr4-c8h2`. Any other High or Critical +finding fails the build. Remove this exception as soon as a compatible patched +React Router release is available. Otherwise reassess migration from +`react-router-dom` 7 to React Router 8 before the expiration date, then +regenerate both lockfiles. diff --git a/docs/security/outbound-destination-policy.md b/docs/security/outbound-destination-policy.md new file mode 100644 index 0000000..8763a4e --- /dev/null +++ b/docs/security/outbound-destination-policy.md @@ -0,0 +1,64 @@ +# Outbound destination security + +Shogun applies one policy decision immediately before each user-configured A2A +or Gensui HTTP request. Every A and AAAA answer must pass. Automatic redirects +are disabled, URL credentials and ambiguous numeric hosts are rejected, and +cloud metadata, link-local, multicast, unspecified, and reserved addresses are +always blocked. + +## Policies + +| Policy | Intended use | Allowed destinations | +|---|---|---| +| `public_only` | Internet-only federation | Public addresses only | +| `private_allowed` | LAN, VPN, container DNS, on-premises Gensui/Nexus | Public, RFC 1918, and IPv6 ULA; no loopback | +| `loopback_allowed` | Explicit same-host desktop deployment | Public, private, and loopback | +| `allowlist_only` | Controlled enterprise deployment | Only configured hostnames, wildcard domains, IPs, and CIDRs | + +Desktop Gensui defaults to `loopback_allowed` because the documented local +server is `http://localhost:8787`. The Shogun Server profile defaults both A2A +and Gensui to `private_allowed`. Use `allowlist_only` for the tightest enterprise +deployment. + +## Configuration + +```env +A2A_DESTINATION_POLICY=private_allowed +GENSUI_DESTINATION_POLICY=private_allowed +OUTBOUND_ALLOWLIST=gensui.internal,*.shogun.corp,10.40.0.0/16,fd42::/48 +ALLOW_HTTP_ON_PRIVATE_NETWORK=true +ALLOW_HTTP_ON_PUBLIC_NETWORK=false +A2A_ALLOWED_PORTS=443,8000 +GENSUI_ALLOWED_PORTS=443,8787 +``` + +An empty port list allows any TCP port that otherwise passes policy. Restrict +ports when operators do not need custom service ports. Public HTTP is disabled +by default; private HTTP remains available for local and air-gapped deployments. + +`allowlist_only` does not override the permanent metadata and link-local block. +If DNS returns a mixture of allowed and blocked addresses, the request fails. + +## Infrastructure authorization + +Server mode requires `SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN`. Paste that value into +the Infrastructure Admin Token field in the Gensui or Nexus screen. The browser +keeps it in `sessionStorage`, so it disappears when that tab session ends. +Desktop mode without a configured token accepts these privileged operations only +from a loopback client. + +Blocked requests emit a structured `outbound_request_blocked` security log with +the actor, endpoint class, normalized hostname, policy, reason, and correlation +fields. Tokens, URL credentials, and query strings are not logged. + +## DNS rebinding protection + +Shogun resolves and validates every returned address immediately before opening +the request, then connects directly to one of those validated IP addresses. The +original hostname is retained in the HTTP `Host` header and TLS SNI extension, +so certificate and virtual-host validation continue to use the configured +hostname without a second DNS lookup. Redirect following and environment proxy +discovery are disabled for these guarded requests. + +For high-assurance deployments, `allowlist_only`, controlled DNS, an egress +firewall, or a service mesh remain useful defense-in-depth controls. diff --git a/frontend/dist/assets/Archives-05skDH2r.js b/frontend/dist/assets/Archives-05skDH2r.js new file mode 100644 index 0000000..eea96f7 --- /dev/null +++ b/frontend/dist/assets/Archives-05skDH2r.js @@ -0,0 +1,6 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./archive-BOJnkAd3.js";import{t as n}from"./book-BRn0Wicm.js";import{t as r}from"./brain-Bs0UzUvy.js";import{t as i}from"./calendar-Cad5gZZR.js";import{t as ee}from"./chart-column-DrS4GaUq.js";import{t as te}from"./chevron-right-CVeYaFvJ.js";import{t as ne}from"./clock-DQ9Dz1_z.js";import{t as re}from"./code-xml-DLPBFEaQ.js";import{t as ie}from"./funnel-BkXG8UUQ.js";import{t as ae}from"./info-D6evxaHJ.js";import{t as oe}from"./layers-PPVhckft.js";import{t as a}from"./pin-Trq2cvHx.js";import{t as se}from"./plus-Cxx0HjpF.js";import{t as o}from"./refresh-cw-Dm6S5UAJ.js";import{t as ce}from"./rotate-ccw-B4t0zm9t.js";import{t as le}from"./search-DuRUeriq.js";import{t as s}from"./sparkles-DyLIKWW0.js";import{t as ue}from"./star-DhgMUt17.js";import{t as de}from"./trash-2-DqRUHXwV.js";import{t as c}from"./upload-NSOxRjZn.js";import{t as fe}from"./zap-CQy--vuS.js";import{T as l,a as u,b as d,c as pe,i as f,j as p,o as me,p as he,r as ge,t as m,u as _e,x as ve}from"./index-Dy1E248t.js";import{t as h}from"./axios-BGmZl9Qd.js";var ye=l(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),be=l(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),xe=l(`package-check`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16 17 2 2 4-4`,key:`uh5qu3`}],[`path`,{d:`M21 11.127V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.32-.753`,key:`kpkbpo`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),Se=l(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),g=e(p(),1),_=m(),v=`/api/v1/memory`,Ce=`/api/v1/agents`;function y(){let{t:e}=ge(),[l,p]=(0,g.useState)(!0),[m,y]=(0,g.useState)(null),[we,Te]=(0,g.useState)(!1),[Ee,b]=(0,g.useState)([]),[De,x]=(0,g.useState)([]),[S,Oe]=(0,g.useState)(null),[C,ke]=(0,g.useState)([]),[w,Ae]=(0,g.useState)(``),[T,je]=(0,g.useState)(`all`),[E,Me]=(0,g.useState)(`all`),[D,Ne]=(0,g.useState)(`all`),[O,Pe]=(0,g.useState)(`created_at`),[k,A]=(0,g.useState)(null),[Fe,j]=(0,g.useState)(!1),[Ie,M]=(0,g.useState)(!1),[Le,N]=(0,g.useState)(!1),[P,Re]=(0,g.useState)([]),[F,I]=(0,g.useState)(null),[ze,Be]=(0,g.useState)([]),[L,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)({agent_id:``,source_type:`openclaw`,folder_path:``,default_memory_type:`semantic`,default_importance:5,default_decay_type:`medium`,duplicate_policy:`skip_exact`,conflict_policy:`skip`}),[V,Ve]=(0,g.useState)(null),[He,Ue]=(0,g.useState)([]),[H,We]=(0,g.useState)(null),[Ge,Ke]=(0,g.useState)(!1),[U,qe]=(0,g.useState)(!1),[W,G]=(0,g.useState)({scope:`all`,project_id:``,agent_id:``,memory_types:[],date_from:``,date_to:``,include_archives:!0,include_private:!0,include_sticky:!0,include_analysis:!0,include_raw_json:!1,include_secrets:!1,package_as_zip:!0,min_importance:0}),[K,q]=(0,g.useState)(null),[J,Y]=(0,g.useState)({title:``,content:``,memory_type:`semantic`,importance_score:.5,decay_class:`medium`,agent_id:``}),X=(0,g.useCallback)(async()=>{if(p(!0),y(null),T===`skills`)try{await h.post(`${v}/skills/sync`)}catch(e){console.error(`Skill memory synchronization failed:`,e)}let e=new URLSearchParams;T!==`all`&&T!==`programming`&&e.set(`memory_type`,T),E!==`all`&&T!==`programming`&&e.set(`decay_class`,E),D!==`all`&&e.set(`agent_id`,D),e.set(`sort_by`,O);let t=T===`programming`?`${v}/programming?${e}`:`${v}?${e}`,[n,r,i]=await Promise.allSettled([h.get(Ce),h.get(`${v}/stats`),h.get(t)]);n.status===`fulfilled`?ke(n.value.data.data||[]):console.error(`Error fetching agents:`,n.reason),r.status===`fulfilled`?Oe(r.value.data.data):console.error(`Error fetching memory statistics:`,r.reason),i.status===`fulfilled`?b(i.value.data.data||[]):(console.error(`Error fetching memory fragments:`,i.reason),b([]),y(`Memory fragments could not be loaded. Shogun may need to repair the local memory schema.`)),p(!1)},[T,E,D,O]);(0,g.useEffect)(()=>{X()},[X]),(0,g.useEffect)(()=>{let e=setTimeout(async()=>{if(w.trim().length>2){Te(!0);try{if(T===`programming`){let e=new URLSearchParams({query:w,sort_by:O});D!==`all`&&e.set(`agent_id`,D);let t=await h.get(`${v}/programming?${e}`);x(t.data.data||[]);return}let e=await h.post(`${v}/search`,{query:w,agent_id:D===`all`?null:D,memory_types:T===`all`?null:[T],filters:E===`all`?null:{decay_class:E},limit:20});x(e.data.data||[])}catch(e){console.error(`Search error:`,e)}finally{Te(!1)}}else x([])},500);return()=>clearTimeout(e)},[w,D,T,E,O]);let Je=async(e,t)=>{t?.stopPropagation();try{let t=T===`programming`||k?.memory_type===`programming`;if(t&&!window.confirm(`Delete this project programming memory permanently?`))return;t?await h.delete(`${v}/programming/${e}`):await h.post(`${v}/${e}/forget`),b(t=>t.filter(t=>t.id!==e)),x(t=>t.filter(t=>t.id!==e)),k?.id===e&&A(null),q({type:`success`,text:t?`Programming memory deleted.`:`Memory archived.`}),Qe()}catch{q({type:`error`,text:`Failed to archive memory.`})}setTimeout(()=>q(null),3e3)},Ye=async(e,t)=>{t?.stopPropagation();try{let t=(await h.post(`${v}/${e}/pin`)).data.data;b(n=>n.map(n=>n.id===e?t:n)),x(n=>n.map(n=>n.id===e?{...n,is_pinned:t.is_pinned}:n)),k?.id===e&&A(e=>e?{...e,is_pinned:t.is_pinned}:null),q({type:`success`,text:t.is_pinned?`Memory pinned.`:`Memory unpinned.`}),Qe()}catch{q({type:`error`,text:`Failed to toggle pin.`})}setTimeout(()=>q(null),3e3)},Xe=async()=>{if(!J.title||!J.content||!J.agent_id){q({type:`error`,text:`Please fill required fields.`});return}try{let e=await h.post(v,J);b(t=>[e.data.data,...t]),j(!1),Y({...J,title:``,content:``}),q({type:`success`,text:`Memory inscribed successfully.`}),Qe()}catch{q({type:`error`,text:`Failed to inscribe memory.`})}setTimeout(()=>q(null),3e3)},Ze=async()=>{try{p(!0),await h.post(`${v}/reindex`),q({type:`success`,text:`Vector index rebuilt.`}),X()}catch{q({type:`error`,text:`Reindexing failed.`}),p(!1)}setTimeout(()=>q(null),3e3)},Qe=async()=>{try{let e=await h.get(`${v}/stats`);Oe(e.data.data)}catch{}},$e=(e=!1)=>({...W,project_id:W.project_id.trim()||null,agent_id:W.agent_id||null,date_from:W.date_from?`${W.date_from}T00:00:00Z`:null,date_to:W.date_to?`${W.date_to}T23:59:59Z`:null,min_importance:W.min_importance||null,private_export_confirmed:e}),et=async()=>{try{let e=await h.get(`${v}/export/history`);Ue(e.data.data||[])}catch(e){console.error(`Export history error:`,e)}},tt=async()=>{try{let e=await h.post(`${v}/export/preview`,$e(!1));Ve(e.data.data)}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Export preview failed.`})}},nt=()=>{M(!0),qe(!1),Ve(null),We(null),et()},rt=async()=>{if((W.include_private||W.include_secrets)&&!U){q({type:`error`,text:`Confirm the sensitive-memory warning before exporting.`});return}Ke(!0);try{let e=(await h.post(`${v}/export`,$e(U))).data.data;We(e);for(let t=0;t<60&&[`pending`,`running`].includes(e.status);t+=1)await new Promise(e=>setTimeout(e,500)),e=(await h.get(`${v}/export/${e.export_id}`)).data.data,We(e);e.status===`completed`||e.status===`completed_with_warnings`?q({type:`success`,text:`Export completed with ${e.records_exported} Markdown files.`}):e.status===`failed`&&q({type:`error`,text:e.error?.message||`Memory export failed.`}),await et()}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Memory export failed.`})}finally{Ke(!1)}},it=e=>{G(t=>({...t,memory_types:t.memory_types.includes(e)?t.memory_types.filter(t=>t!==e):[...t.memory_types,e]}))},Z=async()=>{try{let e=await h.get(`${v}/import/batches`);Be(e.data.data||[])}catch(e){console.error(`Import history error:`,e)}},at=()=>{N(!0),I(null),Re([]),B(e=>({...e,agent_id:e.agent_id||C[0]?.id||``})),Z()},ot=async()=>{if(!z.agent_id||P.length===0&&!z.folder_path.trim()){q({type:`error`,text:`Select a target agent and Markdown/ZIP input or local folder.`});return}R(!0);try{let e=new FormData;P.forEach(t=>e.append(`files`,t)),z.folder_path.trim()&&e.append(`folder_path`,z.folder_path.trim()),e.append(`agent_id`,z.agent_id),e.append(`source_type`,z.source_type),e.append(`default_memory_type`,z.default_memory_type),e.append(`default_importance`,String(z.default_importance)),e.append(`default_decay_type`,z.default_decay_type);let t=await h.post(`${v}/import/openclaw/preview`,e);I(t.data.data),await Z()}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Memory import preview failed.`})}finally{R(!1)}},st=async()=>{if(F){R(!0);try{let e=await h.post(`${v}/import/openclaw/confirm`,{batch_preview_id:F.batch_id,duplicate_policy:z.duplicate_policy,conflict_policy:z.conflict_policy});I(e.data.data),q({type:`success`,text:`Imported ${e.data.data.imported_count} memories; ${e.data.data.embedded_count} embedded.`}),await Promise.all([Z(),X()])}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Memory import failed.`})}finally{R(!1)}}},ct=async e=>{if(window.confirm(`Rollback this import batch? Only memories created by this batch will be removed.`)){R(!0);try{let t=await h.post(`${v}/import/batches/${e}/rollback`);I(t.data.data),q({type:`success`,text:`Import batch rolled back.`}),await Promise.all([Z(),X()])}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Rollback failed.`})}finally{R(!1)}}},lt=async e=>{R(!0);try{let t=await h.post(`${v}/import/batches/${e}/retry-embeddings`);I(t.data.data),await Z()}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Embedding retry failed.`})}finally{R(!1)}},ut=e=>{switch(e.toLowerCase()){case`episodic`:return(0,_.jsx)(i,{className:`w-4 h-4`});case`semantic`:return(0,_.jsx)(n,{className:`w-4 h-4`});case`procedural`:return(0,_.jsx)(r,{className:`w-4 h-4`});case`persona`:return(0,_.jsx)(_e,{className:`w-4 h-4`});case`skills`:return(0,_.jsx)(fe,{className:`w-4 h-4`});case`programming`:return(0,_.jsx)(re,{className:`w-4 h-4`});default:return(0,_.jsx)(ve,{className:`w-4 h-4`})}},Q=e=>{switch(e.toLowerCase()){case`episodic`:return`text-purple-400`;case`semantic`:return`text-shogun-blue`;case`procedural`:return`text-green-400`;case`persona`:return`text-shogun-gold`;case`skills`:return`text-orange-400`;case`programming`:return`text-cyan-400`;default:return`text-shogun-subdued`}},dt=e=>{if(!e)return`Never`;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`Just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`},ft=[`all`,`episodic`,`semantic`,`procedural`,`persona`,`skills`,`programming`],$=w.trim().length>2?De:Ee;return(0,_.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-7xl mx-auto pb-12`,children:[(0,_.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`archives.title`,`Archives`),` `,(0,_.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Memory Core`})]}),(0,_.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`archives.subtitle`,`SOTA semantic retrieval and salience-weighted persistent knowledge store.`)})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsxs)(`button`,{onClick:at,className:`flex items-center gap-2 px-4 py-2 bg-green-500/10 text-green-400 border border-green-500/20 rounded-lg text-sm font-bold uppercase tracking-widest hover:bg-green-500/20 transition-all`,children:[(0,_.jsx)(c,{className:`w-4 h-4`}),` Import Memories`]}),(0,_.jsxs)(`button`,{onClick:nt,className:`flex items-center gap-2 px-4 py-2 bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20 rounded-lg text-sm font-bold uppercase tracking-widest hover:bg-shogun-blue/20 transition-all`,children:[(0,_.jsx)(d,{className:`w-4 h-4`}),` Export Memory`]}),(0,_.jsxs)(`button`,{onClick:()=>j(!0),className:`flex items-center gap-2 px-4 py-2 bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/20 rounded-lg text-sm font-bold uppercase tracking-widest hover:bg-shogun-gold/20 transition-all`,children:[(0,_.jsx)(se,{className:`w-4 h-4`}),` `,e(`archives.inscribe`,`Inscribe Memory`)]}),(0,_.jsx)(`button`,{onClick:Ze,title:`Rebuild Vector Index`,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-blue transition-colors`,children:(0,_.jsx)(o,{className:f(`w-4 h-4`,l&&`animate-spin`)})})]})]}),K&&(0,_.jsxs)(`div`,{className:f(`p-3 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2 text-sm font-bold uppercase tracking-widest`,K.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[K.type===`success`?(0,_.jsx)(s,{className:`w-4 h-4`}):(0,_.jsx)(ae,{className:`w-4 h-4`}),K.text]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-6`,children:[(0,_.jsxs)(`div`,{className:`lg:col-span-3 space-y-6`,children:[(0,_.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-3 flex items-center gap-2`,children:[(0,_.jsx)(_e,{className:`w-3 h-3`}),` Decay Type`]}),(0,_.jsxs)(`select`,{value:E,onChange:e=>Me(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-xs text-shogun-text focus:border-shogun-blue outline-none`,children:[(0,_.jsx)(`option`,{value:`all`,children:`All decay types`}),[`fast`,`medium`,`slow`,`sticky`,`pinned`].map(e=>(0,_.jsx)(`option`,{value:e,children:e},e))]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-3 flex items-center gap-2`,children:[(0,_.jsx)(ie,{className:`w-3 h-3`}),` Agent Context`]}),(0,_.jsxs)(`select`,{value:D,onChange:e=>Ne(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-xs text-shogun-text focus:border-shogun-blue outline-none`,children:[(0,_.jsx)(`option`,{value:`all`,children:`Global / All Agents`}),C.map(e=>(0,_.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.agent_type,`)`]},e.id))]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2 flex items-center gap-2`,children:[(0,_.jsx)(he,{className:`w-3 h-3`}),` Categorization`]}),ft.map(e=>(0,_.jsxs)(`button`,{onClick:()=>je(e),className:f(`w-full flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-all`,T===e?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/30 font-bold`:`text-shogun-subdued hover:bg-shogun-bg hover:text-shogun-text`),children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3 capitalize`,children:[ut(e),e]}),(0,_.jsx)(`span`,{className:`text-[9px] font-mono opacity-50`,children:e===`all`?S?.total_active:S?.type_counts?.[e]||0})]},e))]}),(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-3 flex items-center gap-2`,children:[(0,_.jsx)(ye,{className:`w-3 h-3`}),` Sort Ordinance`]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:[{id:`created_at`,label:`Chronological`},{id:`relevance`,label:`Salience`},{id:`importance`,label:`Importance`}].map(e=>(0,_.jsx)(`button`,{onClick:()=>Pe(e.id),className:f(`px-3 py-2 rounded-lg text-left text-[10px] uppercase font-bold tracking-widest transition-all`,O===e.id?`bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/30`:`text-shogun-subdued hover:bg-shogun-bg border border-transparent`),children:e.label},e.id))})]})]}),(0,_.jsxs)(`div`,{className:`shogun-card !bg-gradient-to-br from-shogun-card to-[#0a0e1a]`,children:[(0,_.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest flex items-center gap-2 mb-4`,children:[(0,_.jsx)(ue,{className:`w-3 h-3`}),` Salience Metrics`]}),(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`p-3 bg-shogun-bg/50 border border-shogun-border rounded-xl`,children:[(0,_.jsx)(`span`,{className:`text-[9px] text-shogun-subdued uppercase block mb-1`,children:`Retention`}),(0,_.jsxs)(`span`,{className:`text-sm font-bold text-green-500`,children:[S?.retention_rate,`%`]})]}),(0,_.jsxs)(`div`,{className:`p-3 bg-shogun-bg/50 border border-shogun-border rounded-xl`,children:[(0,_.jsx)(`span`,{className:`text-[9px] text-shogun-subdued uppercase block mb-1`,children:e(`archives.pinned`,`Pinned`)}),(0,_.jsx)(`span`,{className:`text-sm font-bold text-shogun-gold`,children:S?.pinned_count})]})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between items-center text-[10px] uppercase font-bold`,children:[(0,_.jsx)(`span`,{className:`text-shogun-subdued`,children:`Avg Relevance`}),(0,_.jsx)(`span`,{className:`text-shogun-blue`,children:(S?.avg_relevance||0).toFixed(3)})]}),(0,_.jsx)(`div`,{className:`h-1.5 bg-shogun-bg border border-shogun-border rounded-full overflow-hidden`,children:(0,_.jsx)(`div`,{className:`h-full bg-shogun-blue`,style:{width:`${(S?.avg_relevance||0)*100}%`}})})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between items-center text-[10px] uppercase font-bold`,children:[(0,_.jsx)(`span`,{className:`text-shogun-subdued`,children:`Avg Importance`}),(0,_.jsx)(`span`,{className:`text-shogun-gold`,children:(S?.avg_importance||0).toFixed(3)})]}),(0,_.jsx)(`div`,{className:`h-1.5 bg-shogun-bg border border-shogun-border rounded-full overflow-hidden`,children:(0,_.jsx)(`div`,{className:`h-full bg-shogun-gold`,style:{width:`${(S?.avg_importance||0)*100}%`}})})]}),S?.qdrant&&(0,_.jsxs)(`div`,{className:`pt-2 border-t border-shogun-border/50`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] text-shogun-subdued mb-1 uppercase tracking-tighter`,children:[(0,_.jsx)(oe,{className:`w-3 h-3 text-shogun-blue`}),` Vector Index: `,S.qdrant.status]}),S.qdrant.error&&(0,_.jsx)(`p`,{className:`text-[8px] text-red-500/70 italic leading-tight`,children:S.qdrant.error})]})]})]})]}),(0,_.jsx)(`div`,{className:`lg:col-span-9 space-y-6`,children:(0,_.jsxs)(`div`,{className:`shogun-card !p-0 overflow-hidden border-shogun-blue/20`,children:[(0,_.jsxs)(`div`,{className:`p-4 bg-shogun-blue/5 border-b border-shogun-border flex items-center gap-4 relative`,children:[(0,_.jsxs)(`div`,{className:`relative flex-1`,children:[(0,_.jsx)(le,{className:f(`absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 transition-colors`,we?`text-shogun-blue animate-pulse`:`text-shogun-subdued`)}),(0,_.jsx)(`input`,{type:`text`,placeholder:e(`archives.search_placeholder`,`Enter semantic query or keyword segment...`),value:w,onChange:e=>Ae(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-xl pl-12 pr-4 py-3 text-sm focus:border-shogun-blue outline-none transition-all shadow-inner placeholder:text-shogun-subdued/50`}),w.length>0&&(0,_.jsx)(`button`,{onClick:()=>Ae(``),className:`absolute right-4 top-1/2 -translate-y-1/2 p-1 hover:bg-shogun-card rounded-md`,children:(0,_.jsx)(u,{className:`w-3 h-3 text-shogun-subdued`})})]}),w.trim().length>2&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold text-shogun-blue uppercase tracking-widest whitespace-nowrap`,children:[(0,_.jsx)(s,{className:`w-3 h-3`}),` Semantic Rank Active`]})]}),(0,_.jsx)(`div`,{className:`min-h-[500px] max-h-[800px] overflow-y-auto custom-scrollbar divide-y divide-shogun-border/50 bg-[#050508]/30`,children:l&&$.length===0?(0,_.jsxs)(`div`,{className:`h-[500px] flex flex-col items-center justify-center opacity-50 gap-4`,children:[(0,_.jsx)(o,{className:`w-10 h-10 animate-spin text-shogun-blue`}),(0,_.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.3em] shogun-title`,children:`Synchronizing Memory...`})]}):m?(0,_.jsxs)(`div`,{className:`h-[500px] flex flex-col items-center justify-center text-shogun-subdued gap-6`,children:[(0,_.jsx)(pe,{className:`w-12 h-12 text-red-400`}),(0,_.jsxs)(`div`,{className:`text-center space-y-3 max-w-lg px-8`,children:[(0,_.jsx)(`p`,{className:`text-sm font-bold text-red-300`,children:`Memory Fragments Failed to Load`}),(0,_.jsx)(`p`,{className:`text-xs leading-relaxed opacity-80`,children:m}),(0,_.jsx)(`button`,{onClick:X,className:`px-4 py-2 rounded-lg border border-shogun-border bg-shogun-card text-xs font-bold hover:border-shogun-blue transition-colors`,children:`Retry Memory Load`})]})]}):$.length===0?(0,_.jsxs)(`div`,{className:`h-[500px] flex flex-col items-center justify-center text-shogun-subdued gap-6`,children:[(0,_.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-card border border-shogun-border flex items-center justify-center animate-pulse`,children:(0,_.jsx)(ve,{className:`w-8 h-8 opacity-20`})}),(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(`p`,{className:`text-sm font-bold shogun-title mb-2`,children:`No Fragments Discovered`}),(0,_.jsx)(`p`,{className:`text-xs max-w-md px-12 leading-relaxed opacity-60`,children:`The persistent knowledge stream contains no fragments matching your criteria. Try adjusting filters or entering a more descriptive semantic query.`})]})]}):(0,_.jsx)(`div`,{className:`divide-y divide-shogun-border/50`,children:$.map(e=>{let t=`scores`in e,n=e;return(0,_.jsxs)(`div`,{onClick:()=>A(n),className:`p-5 hover:bg-shogun-blue/[0.03] transition-all cursor-pointer group flex items-start gap-6 relative overflow-hidden`,children:[t&&(0,_.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-1 bg-shogun-blue opacity-30 group-hover:opacity-100 transition-opacity`}),(0,_.jsxs)(`div`,{className:f(`w-12 h-12 rounded-2xl bg-shogun-card border border-shogun-border flex flex-col items-center justify-center gap-0.5 shrink-0 transition-all`,Q(n.memory_type),`group-hover:border-shogun-blue/30 group-hover:shadow-[0_0_15px_rgba(74,140,199,0.1)]`),children:[ut(n.memory_type),(0,_.jsx)(`span`,{className:`text-[7px] font-bold uppercase opacity-60`,children:n.importance_score>.8?`Vital`:`Rec`})]}),(0,_.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3 overflow-hidden`,children:[(0,_.jsx)(`span`,{className:f(`text-[10px] font-bold uppercase tracking-wider`,Q(n.memory_type)),children:n.memory_type}),n.memory_type===`programming`&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`text-[9px] text-cyan-300 bg-cyan-500/10 border border-cyan-500/20 px-2 py-0.5 rounded-full truncate max-w-[180px]`,children:n.workspace_name||`Unknown project`}),(0,_.jsx)(`span`,{className:`text-[9px] text-green-300 bg-green-500/10 border border-green-500/20 px-2 py-0.5 rounded-full`,children:(n.validation_status||`unverified`).replaceAll(`_`,` `)})]}),n.is_pinned&&(0,_.jsx)(a,{className:`w-3 h-3 text-shogun-gold`}),(0,_.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued flex items-center gap-1.5 border-l border-shogun-border pl-3`,children:[(0,_.jsx)(ne,{className:`w-3.5 h-3.5`}),` `,dt(n.created_at)]}),t&&(0,_.jsxs)(`span`,{className:`text-[10px] bg-shogun-blue/10 text-shogun-blue px-2 py-0.5 rounded-full font-bold flex items-center gap-1`,children:[(0,_.jsx)(s,{className:`w-2.5 h-2.5`}),` Final: `,n.scores.final.toFixed(3)]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity shrink-0 translate-x-2 group-hover:translate-x-0 transition-all`,children:[n.memory_type!==`programming`&&(0,_.jsx)(`button`,{onClick:e=>Ye(n.id,e),className:`p-1.5 hover:bg-shogun-bg border border-transparent hover:border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-all`,children:n.is_pinned?(0,_.jsx)(Se,{className:`w-4 h-4`}):(0,_.jsx)(a,{className:`w-4 h-4`})}),(0,_.jsx)(`button`,{onClick:e=>Je(n.id,e),className:`p-1.5 hover:bg-shogun-bg border border-transparent hover:border-shogun-border rounded-lg text-shogun-subdued hover:text-red-500 transition-all`,children:(0,_.jsx)(de,{className:`w-4 h-4`})})]})]}),(0,_.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text group-hover:text-shogun-blue transition-colors line-clamp-1`,children:n.title}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued/80 leading-relaxed line-clamp-2 italic`,children:n.summary||n.content.slice(0,200)+`...`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-4 gap-4 items-center pt-2`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between text-[8px] uppercase font-bold text-shogun-subdued`,children:[(0,_.jsx)(`span`,{children:`Similarity`}),(0,_.jsxs)(`span`,{className:`text-shogun-text font-mono`,children:[t?(n.scores.semantic_similarity*100).toFixed(0):`—`,`%`]})]}),(0,_.jsx)(`div`,{className:`h-1 bg-shogun-bg rounded-full overflow-hidden`,children:(0,_.jsx)(`div`,{className:`h-full bg-white opacity-20`,style:{width:`${(t?n.scores.semantic_similarity:0)*100}%`}})})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between text-[8px] uppercase font-bold text-shogun-subdued`,children:[(0,_.jsx)(`span`,{children:`Salience`}),(0,_.jsxs)(`span`,{className:`text-shogun-blue font-mono`,children:[((t?n.scores.relevance_score:n.relevance_score)*100).toFixed(0),`%`]})]}),(0,_.jsx)(`div`,{className:`h-1 bg-shogun-bg rounded-full overflow-hidden`,children:(0,_.jsx)(`div`,{className:`h-full bg-shogun-blue`,style:{width:`${(t?n.scores.relevance_score:n.relevance_score)*100}%`}})})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between text-[8px] uppercase font-bold text-shogun-subdued`,children:[(0,_.jsx)(`span`,{children:`Importance`}),(0,_.jsxs)(`span`,{className:`text-shogun-gold font-mono`,children:[((t?n.scores.importance_score:n.importance_score)*100).toFixed(0),`%`]})]}),(0,_.jsx)(`div`,{className:`h-1 bg-shogun-bg rounded-full overflow-hidden`,children:(0,_.jsx)(`div`,{className:`h-full bg-shogun-gold`,style:{width:`${(t?n.scores.importance_score:n.importance_score)*100}%`}})})]}),(0,_.jsx)(`div`,{className:`flex flex-col items-end`,children:(0,_.jsx)(`span`,{className:f(`text-[8px] font-bold uppercase px-2 py-0.5 rounded-md tracking-tighter`,n.decay_class===`pinned`?`bg-purple-500/10 text-purple-400`:n.decay_class===`sticky`?`bg-shogun-blue/10 text-shogun-blue`:`bg-shogun-card border border-shogun-border text-shogun-subdued`),children:n.decay_class})})]})]}),(0,_.jsx)(te,{className:`w-5 h-5 text-shogun-border self-center transition-all group-hover:translate-x-1 group-hover:text-shogun-blue opacity-50`})]},n.id)})})})]})})]}),Le&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md`,children:(0,_.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-6xl max-h-[94vh] rounded-2xl shadow-2xl overflow-hidden flex flex-col`,children:[(0,_.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-11 h-11 rounded-xl bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-400`,children:(0,_.jsx)(c,{className:`w-6 h-6`})}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-xl font-bold shogun-title`,children:`Import OpenClaw Memories`}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued uppercase tracking-widest font-bold`,children:`Validated Markdown into native Shogun Archives`})]})]}),(0,_.jsx)(`button`,{onClick:()=>N(!1),className:`p-2 hover:bg-shogun-bg rounded-lg`,children:(0,_.jsx)(u,{className:`w-6 h-6 text-shogun-subdued`})})]}),(0,_.jsxs)(`div`,{className:`p-6 overflow-y-auto grid grid-cols-1 lg:grid-cols-5 gap-6`,children:[(0,_.jsxs)(`div`,{className:`lg:col-span-2 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold text-green-400 uppercase tracking-widest`,children:`Input & Native Defaults`}),(0,_.jsxs)(`label`,{className:`block p-4 border border-dashed border-green-500/30 rounded-xl bg-green-500/5 cursor-pointer text-center`,children:[(0,_.jsx)(c,{className:`w-6 h-6 text-green-400 mx-auto mb-2`}),(0,_.jsx)(`span`,{className:`text-xs font-bold`,children:`Select Markdown or ZIP files`}),(0,_.jsx)(`span`,{className:`block text-[9px] text-shogun-subdued mt-1`,children:`Multiple .md files and nested ZIP bundles supported`}),(0,_.jsx)(`input`,{type:`file`,accept:`.md,.zip,text/markdown,application/zip`,multiple:!0,className:`hidden`,onChange:e=>Re(Array.from(e.target.files||[]))})]}),P.length>0&&(0,_.jsxs)(`p`,{className:`text-[10px] text-green-300`,children:[P.length,` file`,P.length===1?``:`s`,` selected: `,P.map(e=>e.name).join(`, `)]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued block`,children:[`Or local folder path`,(0,_.jsx)(`input`,{value:z.folder_path,onChange:e=>B({...z,folder_path:e.target.value}),placeholder:`C:\\OpenClaw\\memory-export`,className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text normal-case`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Target agent`,(0,_.jsxs)(`select`,{value:z.agent_id,onChange:e=>B({...z,agent_id:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,_.jsx)(`option`,{value:``,children:`Select agent`}),C.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Source`,(0,_.jsxs)(`select`,{value:z.source_type,onChange:e=>B({...z,source_type:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,_.jsx)(`option`,{value:`openclaw`,children:`OpenClaw`}),(0,_.jsx)(`option`,{value:`shogun_export`,children:`Shogun Export`}),(0,_.jsx)(`option`,{value:`generic_markdown`,children:`Generic Markdown`})]})]})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,_.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Default type`,(0,_.jsx)(`select`,{value:z.default_memory_type,onChange:e=>B({...z,default_memory_type:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[`semantic`,`episodic`,`procedural`,`persona`,`skills`].map(e=>(0,_.jsx)(`option`,{children:e},e))})]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Importance`,(0,_.jsx)(`input`,{type:`number`,min:`1`,max:`10`,value:z.default_importance,onChange:e=>B({...z,default_importance:Number(e.target.value)}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`})]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Decay`,(0,_.jsx)(`select`,{value:z.default_decay_type,onChange:e=>B({...z,default_decay_type:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[`medium`,`fast`,`slow`,`sticky`,`pinned`].map(e=>(0,_.jsx)(`option`,{children:e},e))})]})]})]}),(0,_.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest`,children:`Duplicate & Conflict Policy`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Exact duplicates`,(0,_.jsxs)(`select`,{value:z.duplicate_policy,onChange:e=>B({...z,duplicate_policy:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,_.jsx)(`option`,{value:`skip_exact`,children:`Skip exact`}),(0,_.jsx)(`option`,{value:`import_as_new`,children:`Import as new`})]})]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Conflicts`,(0,_.jsxs)(`select`,{value:z.conflict_policy,onChange:e=>B({...z,conflict_policy:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,_.jsx)(`option`,{value:`skip`,children:`Skip`}),(0,_.jsx)(`option`,{value:`import_as_new`,children:`Import as new`})]})]})]}),(0,_.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:`Existing memories are never overwritten. Preview is mandatory before import.`})]}),(0,_.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold uppercase text-shogun-subdued`,children:`Import History`}),(0,_.jsx)(`button`,{onClick:Z,children:(0,_.jsx)(o,{className:`w-3 h-3`})})]}),(0,_.jsx)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto`,children:ze.length===0?(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No import batches yet.`}):ze.map(e=>(0,_.jsxs)(`button`,{onClick:async()=>{let t=await h.get(`${v}/import/batches/${e.batch_id}`);I(t.data.data)},className:`w-full text-left p-3 bg-shogun-bg border border-shogun-border rounded-lg`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,_.jsx)(`span`,{className:`text-[9px] font-mono truncate`,children:e.batch_id}),(0,_.jsx)(`span`,{className:`text-[8px] uppercase`,children:e.status.replaceAll(`_`,` `)})]}),(0,_.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[e.imported_count,` imported · `,e.failed_count,` failed`]})]},e.batch_id))})]})]}),(0,_.jsxs)(`div`,{className:`lg:col-span-3 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold text-green-400 uppercase tracking-widest`,children:`Validated Preview`}),(0,_.jsx)(`button`,{onClick:ot,disabled:L,className:`px-3 py-1.5 text-[9px] uppercase font-bold border border-green-500/30 text-green-400 rounded-lg disabled:opacity-40`,children:L?`Working…`:`Parse & Preview`})]}),F?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`grid grid-cols-6 gap-2`,children:[[`files`,F.total_files],[`valid`,F.valid_count],[`duplicates`,F.items?.filter(e=>e.status===`duplicate`).length||0],[`imported`,F.imported_count],[`embedded`,F.embedded_count],[`failed`,F.failed_count]].map(([e,t])=>(0,_.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-lg p-2`,children:[(0,_.jsx)(`p`,{className:`text-[7px] uppercase text-shogun-subdued`,children:e}),(0,_.jsx)(`p`,{className:`text-lg font-bold`,children:t})]},String(e)))}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.entries(F.report?.memory_type_distribution||{}).map(([e,t])=>(0,_.jsxs)(`span`,{className:`px-2 py-1 rounded border border-shogun-border text-[9px]`,children:[e,`: `,String(t)]},e))}),(0,_.jsx)(`div`,{className:`space-y-2 max-h-[42vh] overflow-y-auto`,children:(F.items||[]).map(e=>(0,_.jsxs)(`div`,{className:f(`p-3 border rounded-lg`,e.status===`invalid`||e.status===`failed`?`border-red-500/30 bg-red-500/5`:e.status===`duplicate`||e.status===`skipped`?`border-amber-500/30 bg-amber-500/5`:`border-shogun-border bg-shogun-bg`),children:[(0,_.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs font-bold truncate`,children:e.title||e.source_file}),(0,_.jsx)(`p`,{className:`text-[9px] font-mono text-shogun-subdued truncate`,children:e.source_file})]}),(0,_.jsx)(`span`,{className:`text-[8px] font-bold uppercase shrink-0`,children:e.status.replaceAll(`_`,` `)})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 mt-2 text-[8px] uppercase`,children:[(0,_.jsx)(`span`,{children:e.memory_type}),(0,_.jsxs)(`span`,{children:[`importance `,e.importance]}),(0,_.jsx)(`span`,{children:e.decay_type}),e.tags.map(e=>(0,_.jsxs)(`span`,{className:`text-shogun-blue`,children:[`#`,e]},e))]}),(0,_.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-2 line-clamp-2 whitespace-pre-wrap`,children:e.body_excerpt}),e.warnings.map(e=>(0,_.jsxs)(`p`,{className:`text-[9px] text-amber-300 mt-1`,children:[`• `,e]},e)),e.error?.message&&(0,_.jsxs)(`p`,{className:`text-[9px] text-red-400 mt-1`,children:[`• `,e.error.message]}),e.embedding_error&&(0,_.jsxs)(`p`,{className:`text-[9px] text-red-400 mt-1`,children:[`Embedding: `,e.embedding_error]})]},e.item_id))})]}):(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Files are parsed as inert data. Nothing enters Archives until you review and confirm this preview.`})]}),F&&(0,_.jsxs)(`div`,{className:`shogun-card flex flex-wrap items-center justify-between gap-3`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[10px] font-mono`,children:F.batch_id}),(0,_.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase`,children:F.status.replaceAll(`_`,` `)})]}),(0,_.jsxs)(`div`,{className:`flex gap-2`,children:[(0,_.jsxs)(`a`,{href:`${v}/import/batches/${F.batch_id}/report`,className:`px-3 py-2 border border-shogun-border rounded-lg text-[9px] font-bold uppercase`,children:[(0,_.jsx)(d,{className:`w-3 h-3 inline mr-1`}),` Report`]}),F.failed_count>0&&F.imported_count>0&&(0,_.jsx)(`button`,{onClick:()=>lt(F.batch_id),disabled:L,className:`px-3 py-2 border border-amber-500/30 text-amber-300 rounded-lg text-[9px] font-bold uppercase`,children:`Retry embeddings`}),[`completed`,`completed_with_warnings`].includes(F.status)&&(0,_.jsxs)(`button`,{onClick:()=>ct(F.batch_id),disabled:L,className:`px-3 py-2 border border-red-500/30 text-red-400 rounded-lg text-[9px] font-bold uppercase`,children:[(0,_.jsx)(ce,{className:`w-3 h-3 inline mr-1`}),` Rollback`]})]})]})]})]}),(0,_.jsxs)(`div`,{className:`p-5 border-t border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,_.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued flex items-center gap-2`,children:[(0,_.jsx)(_e,{className:`w-4 h-4 text-green-400`}),` ZIP traversal blocked · Markdown never executed · imported memory remains auditable`]}),(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(`button`,{onClick:()=>N(!1),className:`px-5 py-2 border border-shogun-border rounded-lg text-xs font-bold text-shogun-subdued`,children:`Close`}),(0,_.jsx)(`button`,{onClick:st,disabled:L||F?.status!==`previewed`,className:`px-6 py-2 bg-green-600 text-white rounded-lg text-xs font-bold uppercase tracking-widest disabled:opacity-40`,children:`Import Valid Memories`})]})]})]})}),Ie&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-[110] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md`,children:(0,_.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-5xl max-h-[92vh] rounded-2xl shadow-2xl overflow-hidden flex flex-col`,children:[(0,_.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-11 h-11 rounded-xl bg-shogun-blue/10 border border-shogun-blue/20 flex items-center justify-center text-shogun-blue`,children:(0,_.jsx)(be,{className:`w-6 h-6`})}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-xl font-bold shogun-title`,children:`Export Memory`}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued uppercase tracking-widest font-bold`,children:`OpenClaw-compatible Markdown bundle`})]})]}),(0,_.jsx)(`button`,{onClick:()=>M(!1),className:`p-2 hover:bg-shogun-bg rounded-lg`,children:(0,_.jsx)(u,{className:`w-6 h-6 text-shogun-subdued`})})]}),(0,_.jsxs)(`div`,{className:`p-6 overflow-y-auto grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,_.jsxs)(`div`,{className:`space-y-5`,children:[(0,_.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Export Scope & Filters`}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Scope`,(0,_.jsxs)(`select`,{value:W.scope,onChange:e=>G({...W,scope:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,_.jsx)(`option`,{value:`all`,children:`All memory`}),(0,_.jsx)(`option`,{value:`agent`,children:`Selected agent`}),(0,_.jsx)(`option`,{value:`project`,children:`Selected project`}),(0,_.jsx)(`option`,{value:`archives`,children:`Archives only`})]})]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Agent`,(0,_.jsxs)(`select`,{value:W.agent_id,onChange:e=>G({...W,agent_id:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,_.jsx)(`option`,{value:``,children:`All agents`}),C.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),W.scope===`project`&&(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued block`,children:[`Project identifier`,(0,_.jsx)(`input`,{value:W.project_id,onChange:e=>G({...W,project_id:e.target.value}),placeholder:`Project slug or UUID`,className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text normal-case`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`From`,(0,_.jsx)(`input`,{type:`date`,value:W.date_from,onChange:e=>G({...W,date_from:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`})]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`To`,(0,_.jsx)(`input`,{type:`date`,value:W.date_to,onChange:e=>G({...W,date_to:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`})]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[10px] uppercase font-bold text-shogun-subdued mb-2`,children:`Memory types (none means all)`}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ft.filter(e=>e!==`all`).map(e=>(0,_.jsx)(`button`,{onClick:()=>it(e),className:f(`px-3 py-1.5 rounded-lg border text-[9px] uppercase font-bold`,W.memory_types.includes(e)?`border-shogun-blue bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued`),children:e},e))})]}),(0,_.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued block`,children:[`Minimum importance: `,Math.round(W.min_importance*100),`%`,(0,_.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:W.min_importance,onChange:e=>G({...W,min_importance:Number(e.target.value)}),className:`w-full accent-shogun-blue`})]})]}),(0,_.jsx)(`div`,{className:`shogun-card grid grid-cols-2 gap-3`,children:[[`include_archives`,`Include archives`],[`include_private`,`Include private`],[`include_sticky`,`Include sticky`],[`include_analysis`,`Include analysis`],[`include_raw_json`,`Include raw JSON`],[`include_secrets`,`Include secret-classified`],[`package_as_zip`,`Package as ZIP`]].map(([e,t])=>(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-shogun-text cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:W[e],onChange:t=>G({...W,[e]:t.target.checked}),className:`accent-shogun-blue`}),` `,t]},e))}),(W.include_private||W.include_secrets)&&(0,_.jsxs)(`div`,{className:`p-4 rounded-xl bg-amber-500/10 border border-amber-500/30 text-amber-300 space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(pe,{className:`w-5 h-5 shrink-0`}),(0,_.jsx)(`p`,{className:`text-xs leading-relaxed`,children:`This export may contain private or secret-classified context, preferences, project information, and operational memory. Store it securely.`})]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-bold`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:U,onChange:e=>qe(e.target.checked),className:`accent-amber-400`}),` I understand and confirm this sensitive export.`]})]}),W.include_secrets&&(0,_.jsx)(`p`,{className:`text-[10px] text-red-400 border border-red-500/30 bg-red-500/10 rounded-lg p-3`,children:`Secret-classified memory is explicitly included. Review and protect the resulting bundle.`})]}),(0,_.jsxs)(`div`,{className:`space-y-5`,children:[(0,_.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest`,children:`Export Preview`}),(0,_.jsx)(`button`,{onClick:tt,className:`px-3 py-1.5 text-[9px] font-bold uppercase border border-shogun-gold/30 text-shogun-gold rounded-lg`,children:`Refresh preview`})]}),V?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:[`memories`,`archives`,`sticky`,`analysis`,`private`,`total`].map(e=>(0,_.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-lg p-3`,children:[(0,_.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:e}),(0,_.jsx)(`p`,{className:`text-lg font-bold`,children:V.estimated_counts[e]||0})]},e))}),(0,_.jsx)(`div`,{children:V.warnings.map(e=>(0,_.jsxs)(`p`,{className:`text-[10px] text-amber-300`,children:[`• `,e]},e))})]}):(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Preview the selected filters before generating the bundle.`})]}),H&&(0,_.jsxs)(`div`,{className:`shogun-card border-shogun-blue/30 space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold uppercase text-shogun-blue`,children:`Current Export`}),(0,_.jsx)(`span`,{className:`text-[9px] uppercase font-bold`,children:H.status.replaceAll(`_`,` `)})]}),(0,_.jsx)(`p`,{className:`text-[10px] font-mono text-shogun-subdued`,children:H.export_id}),(0,_.jsxs)(`p`,{className:`text-xs`,children:[H.records_exported,` Markdown files generated`]}),H.download_url&&(0,_.jsxs)(`a`,{href:H.download_url,className:`flex items-center justify-center gap-2 w-full py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold uppercase`,children:[(0,_.jsx)(d,{className:`w-4 h-4`}),` Download ZIP`]})]}),(0,_.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold uppercase text-shogun-subdued`,children:`Export History`}),(0,_.jsx)(`button`,{onClick:et,children:(0,_.jsx)(o,{className:`w-3 h-3 text-shogun-subdued`})})]}),(0,_.jsx)(`div`,{className:`space-y-2 max-h-52 overflow-y-auto`,children:He.length===0?(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No exports yet.`}):He.map(e=>(0,_.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg flex items-center justify-between gap-2`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-[10px] font-mono truncate`,children:e.export_id}),(0,_.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[new Date(e.requested_at).toLocaleString(),` · `,e.records_exported,` files`]})]}),e.download_url?(0,_.jsx)(`a`,{title:`Download export`,href:e.download_url,children:(0,_.jsx)(d,{className:`w-4 h-4 text-shogun-blue`})}):(0,_.jsx)(`span`,{className:`text-[8px] uppercase text-shogun-subdued`,children:e.status})]},e.export_id))})]})]})]}),(0,_.jsxs)(`div`,{className:`p-5 border-t border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,_.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued flex items-center gap-2`,children:[(0,_.jsx)(xe,{className:`w-4 h-4 text-green-400`}),` Files remain local in Shogun-controlled storage.`]}),(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(`button`,{onClick:()=>M(!1),className:`px-5 py-2 border border-shogun-border rounded-lg text-xs font-bold text-shogun-subdued`,children:`Close`}),(0,_.jsx)(`button`,{onClick:rt,disabled:Ge||(W.include_private||W.include_secrets)&&!U,className:`px-6 py-2 bg-shogun-blue text-white rounded-lg text-xs font-bold uppercase tracking-widest disabled:opacity-40`,children:Ge?`Exporting…`:`Generate Export`})]})]})]})}),Fe&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md animate-in fade-in duration-300`,children:(0,_.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-2xl rounded-2xl shadow-2xl overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-shogun-gold/10 border border-shogun-gold/20 flex items-center justify-center text-shogun-gold`,children:(0,_.jsx)(se,{className:`w-6 h-6`})}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-xl font-bold shogun-title`,children:`Inscribe Memory`}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued uppercase tracking-widest font-bold`,children:`Manual Fragment Injection`})]})]}),(0,_.jsx)(`button`,{onClick:()=>j(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,_.jsx)(u,{className:`w-6 h-6 text-shogun-subdued`})})]}),(0,_.jsxs)(`div`,{className:`p-8 space-y-6`,children:[(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.memory_type`,`Memory Type`)}),(0,_.jsx)(`select`,{value:J.memory_type,onChange:e=>Y({...J,memory_type:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all`,children:ft.filter(e=>e!==`all`).map(e=>(0,_.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.agent_attribution`,`Agent Attribution`)}),(0,_.jsxs)(`select`,{value:J.agent_id,onChange:e=>Y({...J,agent_id:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all`,children:[(0,_.jsx)(`option`,{value:``,children:`Select Agent...`}),C.map(e=>(0,_.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.agent_type,`)`]},e.id))]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.memory_title`,`Memory Title`)}),(0,_.jsx)(`input`,{type:`text`,placeholder:`E.g. Operational Guidelines for Project Alpha`,value:J.title,onChange:e=>Y({...J,title:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all`})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.content_payload`,`Content Payload`)}),(0,_.jsx)(`textarea`,{rows:5,placeholder:`Paste fragment content here...`,value:J.content,onChange:e=>Y({...J,content:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all resize-none font-mono`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-6 items-center`,children:[(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between text-[10px] font-bold uppercase tracking-widest`,children:[(0,_.jsx)(`span`,{className:`text-shogun-subdued`,children:`Intrinsic Importance`}),(0,_.jsxs)(`span`,{className:`text-shogun-gold`,children:[Math.round(J.importance_score*100),`%`]})]}),(0,_.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:J.importance_score,onChange:e=>Y({...J,importance_score:parseFloat(e.target.value)}),className:`w-full h-2 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-shogun-gold`})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.decay_class`,`Decay Class`)}),(0,_.jsx)(`div`,{className:`flex gap-2`,children:[`fast`,`medium`,`slow`,`sticky`,`pinned`].map(e=>(0,_.jsx)(`button`,{onClick:()=>Y({...J,decay_class:e}),className:f(`px-2 py-1 rounded border text-[8px] font-bold uppercase transition-all flex-1`,J.decay_class===e?`bg-shogun-blue/20 border-shogun-blue text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:e},e))})]})]})]}),(0,_.jsxs)(`div`,{className:`p-6 bg-shogun-card border-t border-shogun-border mt-auto flex justify-end gap-3`,children:[(0,_.jsx)(`button`,{onClick:()=>j(!1),className:`px-6 py-2.5 rounded-xl border border-shogun-border text-sm font-bold text-shogun-subdued hover:bg-shogun-bg transition-all`,children:`Cancel`}),(0,_.jsx)(`button`,{onClick:Xe,className:`px-8 py-2.5 rounded-xl bg-shogun-blue text-white text-sm font-bold uppercase tracking-widest hover:brightness-110 transition-all shadow-[0_0_20px_rgba(74,140,199,0.3)]`,children:`Create Fragment`})]})]})}),k&&(0,_.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md animate-in fade-in duration-300`,onClick:()=>A(null),children:(0,_.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-4xl rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300`,onClick:e=>e.stopPropagation(),children:[(0,_.jsxs)(`div`,{className:`p-8 border-b border-shogun-border bg-shogun-card flex justify-between items-start`,children:[(0,_.jsxs)(`div`,{className:`flex items-start gap-5`,children:[(0,_.jsx)(`div`,{className:f(`w-14 h-14 rounded-2xl bg-[#050508] border border-shogun-border flex items-center justify-center`,Q(k.memory_type)),children:ut(k.memory_type)}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-2xl font-bold shogun-title mb-1`,children:k.title}),(0,_.jsxs)(`div`,{className:`flex items-center gap-4 text-xs font-bold uppercase tracking-widest mt-1`,children:[(0,_.jsx)(`span`,{className:f(Q(k.memory_type)),children:k.memory_type}),(0,_.jsx)(`span`,{className:`text-shogun-subdued opacity-30`,children:`/`}),(0,_.jsxs)(`span`,{className:`text-shogun-subdued`,children:[`GUID: `,k.id]}),k.is_pinned&&(0,_.jsxs)(`span`,{className:`flex items-center gap-1.5 text-shogun-gold bg-shogun-gold/10 px-2.5 py-1 rounded-full`,children:[(0,_.jsx)(a,{className:`w-3 h-3`}),` Pinned`]})]})]})]}),(0,_.jsx)(`button`,{onClick:()=>A(null),className:`p-2 hover:bg-[#0a0e1a] rounded-xl transition-colors`,children:(0,_.jsx)(u,{className:`w-8 h-8 text-shogun-subdued hover:text-shogun-text`})})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-12 max-h-[75vh] overflow-y-auto`,children:[(0,_.jsxs)(`div`,{className:`col-span-8 p-8 border-r border-shogun-border space-y-8 bg-[#050508]/20`,children:[(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,_.jsx)(oe,{className:`w-3.5 h-3.5`}),` `,k.memory_type===`programming`?`Verified Solution`:k.memory_type===`skills`?`Full Canonical SKILL.md`:`Intelligence Payload`]}),(0,_.jsx)(`div`,{className:`bg-shogun-bg border border-shogun-border p-6 rounded-2xl text-[13px] leading-relaxed text-shogun-text font-mono whitespace-pre-wrap break-words shadow-inner min-h-[300px]`,children:k.solution||k.content||`(Fragment empty)`})]}),k.memory_type===`programming`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,_.jsxs)(`div`,{className:`shogun-card !p-4`,children:[(0,_.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-cyan-400 mb-2`,children:`Problem`}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-text whitespace-pre-wrap`,children:k.problem||k.summary})]}),(0,_.jsxs)(`div`,{className:`shogun-card !p-4`,children:[(0,_.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-green-400 mb-2`,children:`Validation Evidence`}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-text whitespace-pre-wrap`,children:k.evidence||`No evidence recorded.`})]})]}),(0,_.jsxs)(`div`,{className:`shogun-card !p-4 space-y-3`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-shogun-subdued mb-1`,children:`Files`}),(0,_.jsx)(`p`,{className:`text-xs font-mono text-shogun-text`,children:k.files?.join(`, `)||`No files recorded`})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-shogun-subdued mb-1`,children:`Languages`}),(0,_.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(k.languages||[]).map(e=>(0,_.jsx)(`span`,{className:`px-2 py-1 rounded bg-cyan-500/10 border border-cyan-500/20 text-[9px] text-cyan-300`,children:e},e))})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-shogun-subdued mb-1`,children:`Sources`}),(0,_.jsx)(`div`,{className:`space-y-1`,children:(k.source_urls||[]).map(e=>(0,_.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`block text-[10px] text-shogun-blue hover:underline break-all`,children:e},e))})]})]})]}),`scores`in k&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,_.jsx)(ee,{className:`w-3.5 h-3.5`}),` Semantic Score Analysis`]}),(0,_.jsx)(`div`,{className:`grid grid-cols-5 gap-3`,children:[{label:`Similarity`,val:k.scores.semantic_similarity,color:`shogun-blue`},{label:`Salience`,val:k.scores.relevance_score,color:`shogun-blue`},{label:`Importance`,val:k.scores.importance_score,color:`shogun-gold`},{label:`Confidence`,val:k.scores.confidence_score,color:`green-500`},{label:`Recency`,val:k.scores.recency_boost,color:`purple-400`}].map(e=>(0,_.jsxs)(`div`,{className:`shogun-card !p-3 text-center transition-transform hover:scale-105`,children:[(0,_.jsx)(`span`,{className:`text-[8px] text-shogun-subdued uppercase font-bold block mb-2`,children:e.label}),(0,_.jsxs)(`div`,{className:f(`text-xl font-bold font-mono tracking-tighter text-`+e.color),children:[Math.round(e.val*100),`%`]})]},e.label))})]})]}),(0,_.jsxs)(`div`,{className:`col-span-4 p-8 bg-shogun-card/50 space-y-8`,children:[(0,_.jsxs)(`div`,{className:`space-y-5`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em]`,children:`Operational Health`}),(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between items-center bg-shogun-bg/50 p-3 border border-shogun-border rounded-xl`,children:[(0,_.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold`,children:k.memory_type===`programming`?`Validation`:`Decay State`}),(0,_.jsx)(`span`,{className:f(`text-[9px] font-bold uppercase px-2 py-1 rounded-md`,k.decay_class===`pinned`?`bg-purple-500/10 text-purple-400`:`bg-shogun-blue/10 text-shogun-blue`),children:k.memory_type===`programming`?k.validation_status?.replaceAll(`_`,` `):k.decay_class})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between text-[10px] text-shogun-subdued uppercase font-bold px-1`,children:[(0,_.jsx)(`span`,{children:`Utilization Pattern`}),(0,_.jsxs)(`span`,{className:`text-shogun-text font-mono truncate max-w-[100px]`,children:[k.successful_use_count,` of `,k.access_count]})]}),(0,_.jsx)(`div`,{className:`h-2 bg-shogun-bg border border-shogun-border rounded-full overflow-hidden`,children:(0,_.jsx)(`div`,{className:`h-full bg-green-500 transition-all`,style:{width:`${k.successful_use_count/Math.max(1,k.access_count)*100}%`}})})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-5`,children:[(0,_.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em]`,children:`Provenance Detail`}),(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,_.jsx)(ne,{className:`w-4 h-4 text-shogun-blue`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Inscribed At`}),(0,_.jsx)(`p`,{className:`text-shogun-text font-bold`,children:k.created_at?new Date(k.created_at).toLocaleString():`Just now`})]})]}),k.memory_type===`programming`&&(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,_.jsx)(re,{className:`w-4 h-4 text-cyan-400`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Project Workspace`}),(0,_.jsx)(`p`,{className:`text-shogun-text font-bold`,children:k.workspace_name||`Unknown project`}),(0,_.jsx)(`p`,{className:`text-[8px] font-mono text-shogun-subdued truncate max-w-[190px]`,children:k.workspace_key})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,_.jsx)(me,{className:`w-4 h-4 text-shogun-gold`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Attributed Agent`}),(0,_.jsx)(`p`,{className:`text-shogun-text font-bold`,children:C.find(e=>e.id===k.agent_id)?.name||`System Initializer`})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs opacity-50`,children:[(0,_.jsx)(o,{className:`w-4 h-4 text-shogun-subdued`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Last Reinforcement`}),(0,_.jsx)(`p`,{className:`text-shogun-text font-bold`,children:dt(k.last_confirmed_at)})]})]})]})]}),(0,_.jsxs)(`div`,{className:`pt-8 space-y-3`,children:[k.memory_type!==`programming`&&(0,_.jsx)(`button`,{onClick:()=>Ye(k.id),className:`w-full py-3 bg-shogun-bg border border-shogun-border rounded-xl text-xs font-bold uppercase tracking-widest hover:text-shogun-gold hover:border-shogun-gold transition-all flex items-center justify-center gap-3 group`,children:k.is_pinned?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Se,{className:`w-4 h-4 group-hover:scale-110`}),` Unpin Fragment`]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(a,{className:`w-4 h-4 group-hover:scale-110`}),` Pin for Retrieval`]})}),(0,_.jsxs)(`button`,{onClick:()=>Je(k.id),className:`w-full py-3 bg-shogun-bg border border-shogun-border rounded-xl text-xs font-bold uppercase tracking-widest hover:text-red-500 hover:border-red-500 transition-all flex items-center justify-center gap-3 group`,children:[(0,_.jsx)(t,{className:`w-4 h-4 group-hover:scale-110`}),` `,k.memory_type===`programming`?`Delete Programming Memory`:`Move to Archive`]})]})]})]})]})}),(0,_.jsx)(`style`,{children:` + .custom-scrollbar::-webkit-scrollbar { width: 4px; } + .custom-scrollbar::-webkit-scrollbar-track { background: transparent; } + .custom-scrollbar::-webkit-scrollbar-thumb { background: #1a2235; border-radius: 10px; } + .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #4a8cc7; } + `})]})}export{y as Archives}; \ No newline at end of file diff --git a/frontend/dist/assets/Archives-Dedx20mD.js b/frontend/dist/assets/Archives-Dedx20mD.js deleted file mode 100644 index 83bd2f7..0000000 --- a/frontend/dist/assets/Archives-Dedx20mD.js +++ /dev/null @@ -1,6 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{t as i}from"./archive-CCh8OMBK.js";import{t as a}from"./book-c3cQ6ocr.js";import{t as ee}from"./brain-3sva6MW8.js";import{t as te}from"./calendar-DL2fCMC-.js";import{t as ne}from"./chart-column-gDy__4Qa.js";import{t as re}from"./chevron-right-BzAY5P9l.js";import{t as ie}from"./clock-B8iyCT3M.js";import{t as ae}from"./code-xml-CCdcZbQg.js";import{t as oe}from"./database-B_RLhoAx.js";import{t as o}from"./download-OoiqiOHD.js";import{t as se}from"./funnel-BttEh0de.js";import{t as ce}from"./info-CXnsqgVr.js";import{t as le}from"./layers-4dQLphXM.js";import{t as ue}from"./network-RTAno7O_.js";import{t as s}from"./pin-BLXugO8S.js";import{t as de}from"./plus-DFW_DMbT.js";import{t as c}from"./refresh-cw-CCrS0Omg.js";import{t as fe}from"./rotate-ccw-DsOLVoka.js";import{t as pe}from"./search-CCF8DUSp.js";import{t as l}from"./shield-B_MY4jWU.js";import{t as u}from"./sparkles-DddBjN-5.js";import{t as me}from"./star-HhdEV9Ok.js";import{t as he}from"./trash-2-Cid5DKqF.js";import{t as ge}from"./triangle-alert-BwzZbklP.js";import{t as d}from"./upload-D8ecl32P.js";import{t as _e}from"./users-D7R1ctQe.js";import{t as f}from"./x-Bu7rztmN.js";import{t as ve}from"./zap-BMpqZS6N.js";import{t as p}from"./utils-wrb6h48Y.js";import{r as ye}from"./i18n-FxgwkwP0.js";import{t as m}from"./axios-BPyV2soB.js";var be=e(`arrow-up-down`,[[`path`,{d:`m21 16-4 4-4-4`,key:`f6ql7i`}],[`path`,{d:`M17 20V4`,key:`1ejh1v`}],[`path`,{d:`m3 8 4-4 4 4`,key:`11wl7u`}],[`path`,{d:`M7 4v16`,key:`1glfcx`}]]),xe=e(`file-archive`,[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]),Se=e(`package-check`,[[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m16 17 2 2 4-4`,key:`uh5qu3`}],[`path`,{d:`M21 11.127V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.729l7 4a2 2 0 0 0 2 .001l1.32-.753`,key:`kpkbpo`}],[`path`,{d:`M3.29 7 12 12l8.71-5`,key:`19ckod`}],[`path`,{d:`m7.5 4.27 8.997 5.148`,key:`9yrvtv`}]]),Ce=e(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),h=t(n(),1),g=r(),_=`/api/v1/memory`,we=`/api/v1/agents`;function v(){let{t:e}=ye(),[t,n]=(0,h.useState)(!0),[r,v]=(0,h.useState)(null),[Te,Ee]=(0,h.useState)(!1),[De,y]=(0,h.useState)([]),[Oe,b]=(0,h.useState)([]),[x,ke]=(0,h.useState)(null),[S,Ae]=(0,h.useState)([]),[C,je]=(0,h.useState)(``),[w,Me]=(0,h.useState)(`all`),[T,Ne]=(0,h.useState)(`all`),[E,Pe]=(0,h.useState)(`all`),[D,Fe]=(0,h.useState)(`created_at`),[O,k]=(0,h.useState)(null),[Ie,A]=(0,h.useState)(!1),[Le,j]=(0,h.useState)(!1),[Re,M]=(0,h.useState)(!1),[N,ze]=(0,h.useState)([]),[P,F]=(0,h.useState)(null),[Be,Ve]=(0,h.useState)([]),[I,L]=(0,h.useState)(!1),[R,z]=(0,h.useState)({agent_id:``,source_type:`openclaw`,folder_path:``,default_memory_type:`semantic`,default_importance:5,default_decay_type:`medium`,duplicate_policy:`skip_exact`,conflict_policy:`skip`}),[B,He]=(0,h.useState)(null),[Ue,We]=(0,h.useState)([]),[V,Ge]=(0,h.useState)(null),[Ke,qe]=(0,h.useState)(!1),[H,Je]=(0,h.useState)(!1),[U,W]=(0,h.useState)({scope:`all`,project_id:``,agent_id:``,memory_types:[],date_from:``,date_to:``,include_archives:!0,include_private:!0,include_sticky:!0,include_analysis:!0,include_raw_json:!1,include_secrets:!1,package_as_zip:!0,min_importance:0}),[G,K]=(0,h.useState)(null),[q,J]=(0,h.useState)({title:``,content:``,memory_type:`semantic`,importance_score:.5,decay_class:`medium`,agent_id:``}),Y=(0,h.useCallback)(async()=>{if(n(!0),v(null),w===`skills`)try{await m.post(`${_}/skills/sync`)}catch(e){console.error(`Skill memory synchronization failed:`,e)}let e=new URLSearchParams;w!==`all`&&w!==`programming`&&e.set(`memory_type`,w),T!==`all`&&w!==`programming`&&e.set(`decay_class`,T),E!==`all`&&e.set(`agent_id`,E),e.set(`sort_by`,D);let t=w===`programming`?`${_}/programming?${e}`:`${_}?${e}`,[r,i,a]=await Promise.allSettled([m.get(we),m.get(`${_}/stats`),m.get(t)]);r.status===`fulfilled`?Ae(r.value.data.data||[]):console.error(`Error fetching agents:`,r.reason),i.status===`fulfilled`?ke(i.value.data.data):console.error(`Error fetching memory statistics:`,i.reason),a.status===`fulfilled`?y(a.value.data.data||[]):(console.error(`Error fetching memory fragments:`,a.reason),y([]),v(`Memory fragments could not be loaded. Shogun may need to repair the local memory schema.`)),n(!1)},[w,T,E,D]);(0,h.useEffect)(()=>{Y()},[Y]),(0,h.useEffect)(()=>{let e=setTimeout(async()=>{if(C.trim().length>2){Ee(!0);try{if(w===`programming`){let e=new URLSearchParams({query:C,sort_by:D});E!==`all`&&e.set(`agent_id`,E),b((await m.get(`${_}/programming?${e}`)).data.data||[]);return}b((await m.post(`${_}/search`,{query:C,agent_id:E===`all`?null:E,memory_types:w===`all`?null:[w],filters:T===`all`?null:{decay_class:T},limit:20})).data.data||[])}catch(e){console.error(`Search error:`,e)}finally{Ee(!1)}}else b([])},500);return()=>clearTimeout(e)},[C,E,w,T,D]);let Ye=async(e,t)=>{t?.stopPropagation();try{let t=w===`programming`||O?.memory_type===`programming`;if(t&&!window.confirm(`Delete this project programming memory permanently?`))return;t?await m.delete(`${_}/programming/${e}`):await m.post(`${_}/${e}/forget`),y(t=>t.filter(t=>t.id!==e)),b(t=>t.filter(t=>t.id!==e)),O?.id===e&&k(null),K({type:`success`,text:t?`Programming memory deleted.`:`Memory archived.`}),$e()}catch{K({type:`error`,text:`Failed to archive memory.`})}setTimeout(()=>K(null),3e3)},Xe=async(e,t)=>{t?.stopPropagation();try{let t=(await m.post(`${_}/${e}/pin`)).data.data;y(n=>n.map(n=>n.id===e?t:n)),b(n=>n.map(n=>n.id===e?{...n,is_pinned:t.is_pinned}:n)),O?.id===e&&k(e=>e?{...e,is_pinned:t.is_pinned}:null),K({type:`success`,text:t.is_pinned?`Memory pinned.`:`Memory unpinned.`}),$e()}catch{K({type:`error`,text:`Failed to toggle pin.`})}setTimeout(()=>K(null),3e3)},Ze=async()=>{if(!q.title||!q.content||!q.agent_id){K({type:`error`,text:`Please fill required fields.`});return}try{let e=await m.post(_,q);y(t=>[e.data.data,...t]),A(!1),J({...q,title:``,content:``}),K({type:`success`,text:`Memory inscribed successfully.`}),$e()}catch{K({type:`error`,text:`Failed to inscribe memory.`})}setTimeout(()=>K(null),3e3)},Qe=async()=>{try{n(!0),await m.post(`${_}/reindex`),K({type:`success`,text:`Vector index rebuilt.`}),Y()}catch{K({type:`error`,text:`Reindexing failed.`}),n(!1)}setTimeout(()=>K(null),3e3)},$e=async()=>{try{ke((await m.get(`${_}/stats`)).data.data)}catch{}},et=(e=!1)=>({...U,project_id:U.project_id.trim()||null,agent_id:U.agent_id||null,date_from:U.date_from?`${U.date_from}T00:00:00Z`:null,date_to:U.date_to?`${U.date_to}T23:59:59Z`:null,min_importance:U.min_importance||null,private_export_confirmed:e}),tt=async()=>{try{We((await m.get(`${_}/export/history`)).data.data||[])}catch(e){console.error(`Export history error:`,e)}},nt=async()=>{try{He((await m.post(`${_}/export/preview`,et(!1))).data.data)}catch(e){K({type:`error`,text:e?.response?.data?.detail||`Export preview failed.`})}},rt=()=>{j(!0),Je(!1),He(null),Ge(null),tt()},it=async()=>{if((U.include_private||U.include_secrets)&&!H){K({type:`error`,text:`Confirm the sensitive-memory warning before exporting.`});return}qe(!0);try{let e=(await m.post(`${_}/export`,et(H))).data.data;Ge(e);for(let t=0;t<60&&[`pending`,`running`].includes(e.status);t+=1)await new Promise(e=>setTimeout(e,500)),e=(await m.get(`${_}/export/${e.export_id}`)).data.data,Ge(e);e.status===`completed`||e.status===`completed_with_warnings`?K({type:`success`,text:`Export completed with ${e.records_exported} Markdown files.`}):e.status===`failed`&&K({type:`error`,text:e.error?.message||`Memory export failed.`}),await tt()}catch(e){K({type:`error`,text:e?.response?.data?.detail||`Memory export failed.`})}finally{qe(!1)}},at=e=>{W(t=>({...t,memory_types:t.memory_types.includes(e)?t.memory_types.filter(t=>t!==e):[...t.memory_types,e]}))},X=async()=>{try{Ve((await m.get(`${_}/import/batches`)).data.data||[])}catch(e){console.error(`Import history error:`,e)}},ot=()=>{M(!0),F(null),ze([]),z(e=>({...e,agent_id:e.agent_id||S[0]?.id||``})),X()},st=async()=>{if(!R.agent_id||N.length===0&&!R.folder_path.trim()){K({type:`error`,text:`Select a target agent and Markdown/ZIP input or local folder.`});return}L(!0);try{let e=new FormData;N.forEach(t=>e.append(`files`,t)),R.folder_path.trim()&&e.append(`folder_path`,R.folder_path.trim()),e.append(`agent_id`,R.agent_id),e.append(`source_type`,R.source_type),e.append(`default_memory_type`,R.default_memory_type),e.append(`default_importance`,String(R.default_importance)),e.append(`default_decay_type`,R.default_decay_type),F((await m.post(`${_}/import/openclaw/preview`,e)).data.data),await X()}catch(e){K({type:`error`,text:e?.response?.data?.detail||`Memory import preview failed.`})}finally{L(!1)}},ct=async()=>{if(P){L(!0);try{let e=await m.post(`${_}/import/openclaw/confirm`,{batch_preview_id:P.batch_id,duplicate_policy:R.duplicate_policy,conflict_policy:R.conflict_policy});F(e.data.data),K({type:`success`,text:`Imported ${e.data.data.imported_count} memories; ${e.data.data.embedded_count} embedded.`}),await Promise.all([X(),Y()])}catch(e){K({type:`error`,text:e?.response?.data?.detail||`Memory import failed.`})}finally{L(!1)}}},lt=async e=>{if(window.confirm(`Rollback this import batch? Only memories created by this batch will be removed.`)){L(!0);try{F((await m.post(`${_}/import/batches/${e}/rollback`)).data.data),K({type:`success`,text:`Import batch rolled back.`}),await Promise.all([X(),Y()])}catch(e){K({type:`error`,text:e?.response?.data?.detail||`Rollback failed.`})}finally{L(!1)}}},ut=async e=>{L(!0);try{F((await m.post(`${_}/import/batches/${e}/retry-embeddings`)).data.data),await X()}catch(e){K({type:`error`,text:e?.response?.data?.detail||`Embedding retry failed.`})}finally{L(!1)}},dt=e=>{switch(e.toLowerCase()){case`episodic`:return(0,g.jsx)(te,{className:`w-4 h-4`});case`semantic`:return(0,g.jsx)(a,{className:`w-4 h-4`});case`procedural`:return(0,g.jsx)(ee,{className:`w-4 h-4`});case`persona`:return(0,g.jsx)(l,{className:`w-4 h-4`});case`skills`:return(0,g.jsx)(ve,{className:`w-4 h-4`});case`programming`:return(0,g.jsx)(ae,{className:`w-4 h-4`});default:return(0,g.jsx)(oe,{className:`w-4 h-4`})}},Z=e=>{switch(e.toLowerCase()){case`episodic`:return`text-purple-400`;case`semantic`:return`text-shogun-blue`;case`procedural`:return`text-green-400`;case`persona`:return`text-shogun-gold`;case`skills`:return`text-orange-400`;case`programming`:return`text-cyan-400`;default:return`text-shogun-subdued`}},ft=e=>{if(!e)return`Never`;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`Just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`},Q=[`all`,`episodic`,`semantic`,`procedural`,`persona`,`skills`,`programming`],$=C.trim().length>2?Oe:De;return(0,g.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-7xl mx-auto pb-12`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`archives.title`,`Archives`),` `,(0,g.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Memory Core`})]}),(0,g.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`archives.subtitle`,`SOTA semantic retrieval and salience-weighted persistent knowledge store.`)})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsxs)(`button`,{onClick:ot,className:`flex items-center gap-2 px-4 py-2 bg-green-500/10 text-green-400 border border-green-500/20 rounded-lg text-sm font-bold uppercase tracking-widest hover:bg-green-500/20 transition-all`,children:[(0,g.jsx)(d,{className:`w-4 h-4`}),` Import Memories`]}),(0,g.jsxs)(`button`,{onClick:rt,className:`flex items-center gap-2 px-4 py-2 bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20 rounded-lg text-sm font-bold uppercase tracking-widest hover:bg-shogun-blue/20 transition-all`,children:[(0,g.jsx)(o,{className:`w-4 h-4`}),` Export Memory`]}),(0,g.jsxs)(`button`,{onClick:()=>A(!0),className:`flex items-center gap-2 px-4 py-2 bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/20 rounded-lg text-sm font-bold uppercase tracking-widest hover:bg-shogun-gold/20 transition-all`,children:[(0,g.jsx)(de,{className:`w-4 h-4`}),` `,e(`archives.inscribe`,`Inscribe Memory`)]}),(0,g.jsx)(`button`,{onClick:Qe,title:`Rebuild Vector Index`,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-blue transition-colors`,children:(0,g.jsx)(c,{className:p(`w-4 h-4`,t&&`animate-spin`)})})]})]}),G&&(0,g.jsxs)(`div`,{className:p(`p-3 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2 text-sm font-bold uppercase tracking-widest`,G.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[G.type===`success`?(0,g.jsx)(u,{className:`w-4 h-4`}):(0,g.jsx)(ce,{className:`w-4 h-4`}),G.text]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-6`,children:[(0,g.jsxs)(`div`,{className:`lg:col-span-3 space-y-6`,children:[(0,g.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-3 flex items-center gap-2`,children:[(0,g.jsx)(l,{className:`w-3 h-3`}),` Decay Type`]}),(0,g.jsxs)(`select`,{value:T,onChange:e=>Ne(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-xs text-shogun-text focus:border-shogun-blue outline-none`,children:[(0,g.jsx)(`option`,{value:`all`,children:`All decay types`}),[`fast`,`medium`,`slow`,`sticky`,`pinned`].map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))]})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-3 flex items-center gap-2`,children:[(0,g.jsx)(se,{className:`w-3 h-3`}),` Agent Context`]}),(0,g.jsxs)(`select`,{value:E,onChange:e=>Pe(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-xs text-shogun-text focus:border-shogun-blue outline-none`,children:[(0,g.jsx)(`option`,{value:`all`,children:`Global / All Agents`}),S.map(e=>(0,g.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.agent_type,`)`]},e.id))]})]}),(0,g.jsxs)(`div`,{className:`space-y-1`,children:[(0,g.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2 flex items-center gap-2`,children:[(0,g.jsx)(ue,{className:`w-3 h-3`}),` Categorization`]}),Q.map(e=>(0,g.jsxs)(`button`,{onClick:()=>Me(e),className:p(`w-full flex items-center justify-between px-3 py-2 rounded-lg text-xs transition-all`,w===e?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/30 font-bold`:`text-shogun-subdued hover:bg-shogun-bg hover:text-shogun-text`),children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 capitalize`,children:[dt(e),e]}),(0,g.jsx)(`span`,{className:`text-[9px] font-mono opacity-50`,children:e===`all`?x?.total_active:x?.type_counts?.[e]||0})]},e))]}),(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-3 flex items-center gap-2`,children:[(0,g.jsx)(be,{className:`w-3 h-3`}),` Sort Ordinance`]}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:[{id:`created_at`,label:`Chronological`},{id:`relevance`,label:`Salience`},{id:`importance`,label:`Importance`}].map(e=>(0,g.jsx)(`button`,{onClick:()=>Fe(e.id),className:p(`px-3 py-2 rounded-lg text-left text-[10px] uppercase font-bold tracking-widest transition-all`,D===e.id?`bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/30`:`text-shogun-subdued hover:bg-shogun-bg border border-transparent`),children:e.label},e.id))})]})]}),(0,g.jsxs)(`div`,{className:`shogun-card !bg-gradient-to-br from-shogun-card to-[#0a0e1a]`,children:[(0,g.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest flex items-center gap-2 mb-4`,children:[(0,g.jsx)(me,{className:`w-3 h-3`}),` Salience Metrics`]}),(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,g.jsxs)(`div`,{className:`p-3 bg-shogun-bg/50 border border-shogun-border rounded-xl`,children:[(0,g.jsx)(`span`,{className:`text-[9px] text-shogun-subdued uppercase block mb-1`,children:`Retention`}),(0,g.jsxs)(`span`,{className:`text-sm font-bold text-green-500`,children:[x?.retention_rate,`%`]})]}),(0,g.jsxs)(`div`,{className:`p-3 bg-shogun-bg/50 border border-shogun-border rounded-xl`,children:[(0,g.jsx)(`span`,{className:`text-[9px] text-shogun-subdued uppercase block mb-1`,children:e(`archives.pinned`,`Pinned`)}),(0,g.jsx)(`span`,{className:`text-sm font-bold text-shogun-gold`,children:x?.pinned_count})]})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between items-center text-[10px] uppercase font-bold`,children:[(0,g.jsx)(`span`,{className:`text-shogun-subdued`,children:`Avg Relevance`}),(0,g.jsx)(`span`,{className:`text-shogun-blue`,children:(x?.avg_relevance||0).toFixed(3)})]}),(0,g.jsx)(`div`,{className:`h-1.5 bg-shogun-bg border border-shogun-border rounded-full overflow-hidden`,children:(0,g.jsx)(`div`,{className:`h-full bg-shogun-blue`,style:{width:`${(x?.avg_relevance||0)*100}%`}})})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between items-center text-[10px] uppercase font-bold`,children:[(0,g.jsx)(`span`,{className:`text-shogun-subdued`,children:`Avg Importance`}),(0,g.jsx)(`span`,{className:`text-shogun-gold`,children:(x?.avg_importance||0).toFixed(3)})]}),(0,g.jsx)(`div`,{className:`h-1.5 bg-shogun-bg border border-shogun-border rounded-full overflow-hidden`,children:(0,g.jsx)(`div`,{className:`h-full bg-shogun-gold`,style:{width:`${(x?.avg_importance||0)*100}%`}})})]}),x?.qdrant&&(0,g.jsxs)(`div`,{className:`pt-2 border-t border-shogun-border/50`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 text-[9px] text-shogun-subdued mb-1 uppercase tracking-tighter`,children:[(0,g.jsx)(le,{className:`w-3 h-3 text-shogun-blue`}),` Vector Index: `,x.qdrant.status]}),x.qdrant.error&&(0,g.jsx)(`p`,{className:`text-[8px] text-red-500/70 italic leading-tight`,children:x.qdrant.error})]})]})]})]}),(0,g.jsx)(`div`,{className:`lg:col-span-9 space-y-6`,children:(0,g.jsxs)(`div`,{className:`shogun-card !p-0 overflow-hidden border-shogun-blue/20`,children:[(0,g.jsxs)(`div`,{className:`p-4 bg-shogun-blue/5 border-b border-shogun-border flex items-center gap-4 relative`,children:[(0,g.jsxs)(`div`,{className:`relative flex-1`,children:[(0,g.jsx)(pe,{className:p(`absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 transition-colors`,Te?`text-shogun-blue animate-pulse`:`text-shogun-subdued`)}),(0,g.jsx)(`input`,{type:`text`,placeholder:e(`archives.search_placeholder`,`Enter semantic query or keyword segment...`),value:C,onChange:e=>je(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-xl pl-12 pr-4 py-3 text-sm focus:border-shogun-blue outline-none transition-all shadow-inner placeholder:text-shogun-subdued/50`}),C.length>0&&(0,g.jsx)(`button`,{onClick:()=>je(``),className:`absolute right-4 top-1/2 -translate-y-1/2 p-1 hover:bg-shogun-card rounded-md`,children:(0,g.jsx)(f,{className:`w-3 h-3 text-shogun-subdued`})})]}),C.trim().length>2&&(0,g.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] font-bold text-shogun-blue uppercase tracking-widest whitespace-nowrap`,children:[(0,g.jsx)(u,{className:`w-3 h-3`}),` Semantic Rank Active`]})]}),(0,g.jsx)(`div`,{className:`min-h-[500px] max-h-[800px] overflow-y-auto custom-scrollbar divide-y divide-shogun-border/50 bg-[#050508]/30`,children:t&&$.length===0?(0,g.jsxs)(`div`,{className:`h-[500px] flex flex-col items-center justify-center opacity-50 gap-4`,children:[(0,g.jsx)(c,{className:`w-10 h-10 animate-spin text-shogun-blue`}),(0,g.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.3em] shogun-title`,children:`Synchronizing Memory...`})]}):r?(0,g.jsxs)(`div`,{className:`h-[500px] flex flex-col items-center justify-center text-shogun-subdued gap-6`,children:[(0,g.jsx)(ge,{className:`w-12 h-12 text-red-400`}),(0,g.jsxs)(`div`,{className:`text-center space-y-3 max-w-lg px-8`,children:[(0,g.jsx)(`p`,{className:`text-sm font-bold text-red-300`,children:`Memory Fragments Failed to Load`}),(0,g.jsx)(`p`,{className:`text-xs leading-relaxed opacity-80`,children:r}),(0,g.jsx)(`button`,{onClick:Y,className:`px-4 py-2 rounded-lg border border-shogun-border bg-shogun-card text-xs font-bold hover:border-shogun-blue transition-colors`,children:`Retry Memory Load`})]})]}):$.length===0?(0,g.jsxs)(`div`,{className:`h-[500px] flex flex-col items-center justify-center text-shogun-subdued gap-6`,children:[(0,g.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-card border border-shogun-border flex items-center justify-center animate-pulse`,children:(0,g.jsx)(oe,{className:`w-8 h-8 opacity-20`})}),(0,g.jsxs)(`div`,{className:`text-center`,children:[(0,g.jsx)(`p`,{className:`text-sm font-bold shogun-title mb-2`,children:`No Fragments Discovered`}),(0,g.jsx)(`p`,{className:`text-xs max-w-md px-12 leading-relaxed opacity-60`,children:`The persistent knowledge stream contains no fragments matching your criteria. Try adjusting filters or entering a more descriptive semantic query.`})]})]}):(0,g.jsx)(`div`,{className:`divide-y divide-shogun-border/50`,children:$.map(e=>{let t=`scores`in e,n=e;return(0,g.jsxs)(`div`,{onClick:()=>k(n),className:`p-5 hover:bg-shogun-blue/[0.03] transition-all cursor-pointer group flex items-start gap-6 relative overflow-hidden`,children:[t&&(0,g.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-1 bg-shogun-blue opacity-30 group-hover:opacity-100 transition-opacity`}),(0,g.jsxs)(`div`,{className:p(`w-12 h-12 rounded-2xl bg-shogun-card border border-shogun-border flex flex-col items-center justify-center gap-0.5 shrink-0 transition-all`,Z(n.memory_type),`group-hover:border-shogun-blue/30 group-hover:shadow-[0_0_15px_rgba(74,140,199,0.1)]`),children:[dt(n.memory_type),(0,g.jsx)(`span`,{className:`text-[7px] font-bold uppercase opacity-60`,children:n.importance_score>.8?`Vital`:`Rec`})]}),(0,g.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 overflow-hidden`,children:[(0,g.jsx)(`span`,{className:p(`text-[10px] font-bold uppercase tracking-wider`,Z(n.memory_type)),children:n.memory_type}),n.memory_type===`programming`&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`text-[9px] text-cyan-300 bg-cyan-500/10 border border-cyan-500/20 px-2 py-0.5 rounded-full truncate max-w-[180px]`,children:n.workspace_name||`Unknown project`}),(0,g.jsx)(`span`,{className:`text-[9px] text-green-300 bg-green-500/10 border border-green-500/20 px-2 py-0.5 rounded-full`,children:(n.validation_status||`unverified`).replaceAll(`_`,` `)})]}),n.is_pinned&&(0,g.jsx)(s,{className:`w-3 h-3 text-shogun-gold`}),(0,g.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued flex items-center gap-1.5 border-l border-shogun-border pl-3`,children:[(0,g.jsx)(ie,{className:`w-3.5 h-3.5`}),` `,ft(n.created_at)]}),t&&(0,g.jsxs)(`span`,{className:`text-[10px] bg-shogun-blue/10 text-shogun-blue px-2 py-0.5 rounded-full font-bold flex items-center gap-1`,children:[(0,g.jsx)(u,{className:`w-2.5 h-2.5`}),` Final: `,n.scores.final.toFixed(3)]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 opacity-0 group-hover:opacity-100 transition-opacity shrink-0 translate-x-2 group-hover:translate-x-0 transition-all`,children:[n.memory_type!==`programming`&&(0,g.jsx)(`button`,{onClick:e=>Xe(n.id,e),className:`p-1.5 hover:bg-shogun-bg border border-transparent hover:border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-all`,children:n.is_pinned?(0,g.jsx)(Ce,{className:`w-4 h-4`}):(0,g.jsx)(s,{className:`w-4 h-4`})}),(0,g.jsx)(`button`,{onClick:e=>Ye(n.id,e),className:`p-1.5 hover:bg-shogun-bg border border-transparent hover:border-shogun-border rounded-lg text-shogun-subdued hover:text-red-500 transition-all`,children:(0,g.jsx)(he,{className:`w-4 h-4`})})]})]}),(0,g.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text group-hover:text-shogun-blue transition-colors line-clamp-1`,children:n.title}),(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued/80 leading-relaxed line-clamp-2 italic`,children:n.summary||n.content.slice(0,200)+`...`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-4 gap-4 items-center pt-2`,children:[(0,g.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between text-[8px] uppercase font-bold text-shogun-subdued`,children:[(0,g.jsx)(`span`,{children:`Similarity`}),(0,g.jsxs)(`span`,{className:`text-shogun-text font-mono`,children:[t?(n.scores.semantic_similarity*100).toFixed(0):`—`,`%`]})]}),(0,g.jsx)(`div`,{className:`h-1 bg-shogun-bg rounded-full overflow-hidden`,children:(0,g.jsx)(`div`,{className:`h-full bg-white opacity-20`,style:{width:`${(t?n.scores.semantic_similarity:0)*100}%`}})})]}),(0,g.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between text-[8px] uppercase font-bold text-shogun-subdued`,children:[(0,g.jsx)(`span`,{children:`Salience`}),(0,g.jsxs)(`span`,{className:`text-shogun-blue font-mono`,children:[((t?n.scores.relevance_score:n.relevance_score)*100).toFixed(0),`%`]})]}),(0,g.jsx)(`div`,{className:`h-1 bg-shogun-bg rounded-full overflow-hidden`,children:(0,g.jsx)(`div`,{className:`h-full bg-shogun-blue`,style:{width:`${(t?n.scores.relevance_score:n.relevance_score)*100}%`}})})]}),(0,g.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between text-[8px] uppercase font-bold text-shogun-subdued`,children:[(0,g.jsx)(`span`,{children:`Importance`}),(0,g.jsxs)(`span`,{className:`text-shogun-gold font-mono`,children:[((t?n.scores.importance_score:n.importance_score)*100).toFixed(0),`%`]})]}),(0,g.jsx)(`div`,{className:`h-1 bg-shogun-bg rounded-full overflow-hidden`,children:(0,g.jsx)(`div`,{className:`h-full bg-shogun-gold`,style:{width:`${(t?n.scores.importance_score:n.importance_score)*100}%`}})})]}),(0,g.jsx)(`div`,{className:`flex flex-col items-end`,children:(0,g.jsx)(`span`,{className:p(`text-[8px] font-bold uppercase px-2 py-0.5 rounded-md tracking-tighter`,n.decay_class===`pinned`?`bg-purple-500/10 text-purple-400`:n.decay_class===`sticky`?`bg-shogun-blue/10 text-shogun-blue`:`bg-shogun-card border border-shogun-border text-shogun-subdued`),children:n.decay_class})})]})]}),(0,g.jsx)(re,{className:`w-5 h-5 text-shogun-border self-center transition-all group-hover:translate-x-1 group-hover:text-shogun-blue opacity-50`})]},n.id)})})})]})})]}),Re&&(0,g.jsx)(`div`,{className:`fixed inset-0 z-[120] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md`,children:(0,g.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-6xl max-h-[94vh] rounded-2xl shadow-2xl overflow-hidden flex flex-col`,children:[(0,g.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`div`,{className:`w-11 h-11 rounded-xl bg-green-500/10 border border-green-500/20 flex items-center justify-center text-green-400`,children:(0,g.jsx)(d,{className:`w-6 h-6`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h3`,{className:`text-xl font-bold shogun-title`,children:`Import OpenClaw Memories`}),(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued uppercase tracking-widest font-bold`,children:`Validated Markdown into native Shogun Archives`})]})]}),(0,g.jsx)(`button`,{onClick:()=>M(!1),className:`p-2 hover:bg-shogun-bg rounded-lg`,children:(0,g.jsx)(f,{className:`w-6 h-6 text-shogun-subdued`})})]}),(0,g.jsxs)(`div`,{className:`p-6 overflow-y-auto grid grid-cols-1 lg:grid-cols-5 gap-6`,children:[(0,g.jsxs)(`div`,{className:`lg:col-span-2 space-y-5`,children:[(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold text-green-400 uppercase tracking-widest`,children:`Input & Native Defaults`}),(0,g.jsxs)(`label`,{className:`block p-4 border border-dashed border-green-500/30 rounded-xl bg-green-500/5 cursor-pointer text-center`,children:[(0,g.jsx)(d,{className:`w-6 h-6 text-green-400 mx-auto mb-2`}),(0,g.jsx)(`span`,{className:`text-xs font-bold`,children:`Select Markdown or ZIP files`}),(0,g.jsx)(`span`,{className:`block text-[9px] text-shogun-subdued mt-1`,children:`Multiple .md files and nested ZIP bundles supported`}),(0,g.jsx)(`input`,{type:`file`,accept:`.md,.zip,text/markdown,application/zip`,multiple:!0,className:`hidden`,onChange:e=>ze(Array.from(e.target.files||[]))})]}),N.length>0&&(0,g.jsxs)(`p`,{className:`text-[10px] text-green-300`,children:[N.length,` file`,N.length===1?``:`s`,` selected: `,N.map(e=>e.name).join(`, `)]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued block`,children:[`Or local folder path`,(0,g.jsx)(`input`,{value:R.folder_path,onChange:e=>z({...R,folder_path:e.target.value}),placeholder:`C:\\OpenClaw\\memory-export`,className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text normal-case`})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Target agent`,(0,g.jsxs)(`select`,{value:R.agent_id,onChange:e=>z({...R,agent_id:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:``,children:`Select agent`}),S.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Source`,(0,g.jsxs)(`select`,{value:R.source_type,onChange:e=>z({...R,source_type:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:`openclaw`,children:`OpenClaw`}),(0,g.jsx)(`option`,{value:`shogun_export`,children:`Shogun Export`}),(0,g.jsx)(`option`,{value:`generic_markdown`,children:`Generic Markdown`})]})]})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Default type`,(0,g.jsx)(`select`,{value:R.default_memory_type,onChange:e=>z({...R,default_memory_type:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[`semantic`,`episodic`,`procedural`,`persona`,`skills`].map(e=>(0,g.jsx)(`option`,{children:e},e))})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Importance`,(0,g.jsx)(`input`,{type:`number`,min:`1`,max:`10`,value:R.default_importance,onChange:e=>z({...R,default_importance:Number(e.target.value)}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Decay`,(0,g.jsx)(`select`,{value:R.default_decay_type,onChange:e=>z({...R,default_decay_type:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[`medium`,`fast`,`slow`,`sticky`,`pinned`].map(e=>(0,g.jsx)(`option`,{children:e},e))})]})]})]}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest`,children:`Duplicate & Conflict Policy`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Exact duplicates`,(0,g.jsxs)(`select`,{value:R.duplicate_policy,onChange:e=>z({...R,duplicate_policy:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:`skip_exact`,children:`Skip exact`}),(0,g.jsx)(`option`,{value:`import_as_new`,children:`Import as new`})]})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[9px] uppercase font-bold text-shogun-subdued`,children:[`Conflicts`,(0,g.jsxs)(`select`,{value:R.conflict_policy,onChange:e=>z({...R,conflict_policy:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:`skip`,children:`Skip`}),(0,g.jsx)(`option`,{value:`import_as_new`,children:`Import as new`})]})]})]}),(0,g.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:`Existing memories are never overwritten. Preview is mandatory before import.`})]}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold uppercase text-shogun-subdued`,children:`Import History`}),(0,g.jsx)(`button`,{onClick:X,children:(0,g.jsx)(c,{className:`w-3 h-3`})})]}),(0,g.jsx)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto`,children:Be.length===0?(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No import batches yet.`}):Be.map(e=>(0,g.jsxs)(`button`,{onClick:async()=>{F((await m.get(`${_}/import/batches/${e.batch_id}`)).data.data)},className:`w-full text-left p-3 bg-shogun-bg border border-shogun-border rounded-lg`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-mono truncate`,children:e.batch_id}),(0,g.jsx)(`span`,{className:`text-[8px] uppercase`,children:e.status.replaceAll(`_`,` `)})]}),(0,g.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[e.imported_count,` imported · `,e.failed_count,` failed`]})]},e.batch_id))})]})]}),(0,g.jsxs)(`div`,{className:`lg:col-span-3 space-y-5`,children:[(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold text-green-400 uppercase tracking-widest`,children:`Validated Preview`}),(0,g.jsx)(`button`,{onClick:st,disabled:I,className:`px-3 py-1.5 text-[9px] uppercase font-bold border border-green-500/30 text-green-400 rounded-lg disabled:opacity-40`,children:I?`Working…`:`Parse & Preview`})]}),P?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`grid grid-cols-6 gap-2`,children:[[`files`,P.total_files],[`valid`,P.valid_count],[`duplicates`,P.items?.filter(e=>e.status===`duplicate`).length||0],[`imported`,P.imported_count],[`embedded`,P.embedded_count],[`failed`,P.failed_count]].map(([e,t])=>(0,g.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-lg p-2`,children:[(0,g.jsx)(`p`,{className:`text-[7px] uppercase text-shogun-subdued`,children:e}),(0,g.jsx)(`p`,{className:`text-lg font-bold`,children:t})]},String(e)))}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.entries(P.report?.memory_type_distribution||{}).map(([e,t])=>(0,g.jsxs)(`span`,{className:`px-2 py-1 rounded border border-shogun-border text-[9px]`,children:[e,`: `,String(t)]},e))}),(0,g.jsx)(`div`,{className:`space-y-2 max-h-[42vh] overflow-y-auto`,children:(P.items||[]).map(e=>(0,g.jsxs)(`div`,{className:p(`p-3 border rounded-lg`,e.status===`invalid`||e.status===`failed`?`border-red-500/30 bg-red-500/5`:e.status===`duplicate`||e.status===`skipped`?`border-amber-500/30 bg-amber-500/5`:`border-shogun-border bg-shogun-bg`),children:[(0,g.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsx)(`p`,{className:`text-xs font-bold truncate`,children:e.title||e.source_file}),(0,g.jsx)(`p`,{className:`text-[9px] font-mono text-shogun-subdued truncate`,children:e.source_file})]}),(0,g.jsx)(`span`,{className:`text-[8px] font-bold uppercase shrink-0`,children:e.status.replaceAll(`_`,` `)})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-2 mt-2 text-[8px] uppercase`,children:[(0,g.jsx)(`span`,{children:e.memory_type}),(0,g.jsxs)(`span`,{children:[`importance `,e.importance]}),(0,g.jsx)(`span`,{children:e.decay_type}),e.tags.map(e=>(0,g.jsxs)(`span`,{className:`text-shogun-blue`,children:[`#`,e]},e))]}),(0,g.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-2 line-clamp-2 whitespace-pre-wrap`,children:e.body_excerpt}),e.warnings.map(e=>(0,g.jsxs)(`p`,{className:`text-[9px] text-amber-300 mt-1`,children:[`• `,e]},e)),e.error?.message&&(0,g.jsxs)(`p`,{className:`text-[9px] text-red-400 mt-1`,children:[`• `,e.error.message]}),e.embedding_error&&(0,g.jsxs)(`p`,{className:`text-[9px] text-red-400 mt-1`,children:[`Embedding: `,e.embedding_error]})]},e.item_id))})]}):(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Files are parsed as inert data. Nothing enters Archives until you review and confirm this preview.`})]}),P&&(0,g.jsxs)(`div`,{className:`shogun-card flex flex-wrap items-center justify-between gap-3`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-[10px] font-mono`,children:P.batch_id}),(0,g.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase`,children:P.status.replaceAll(`_`,` `)})]}),(0,g.jsxs)(`div`,{className:`flex gap-2`,children:[(0,g.jsxs)(`a`,{href:`${_}/import/batches/${P.batch_id}/report`,className:`px-3 py-2 border border-shogun-border rounded-lg text-[9px] font-bold uppercase`,children:[(0,g.jsx)(o,{className:`w-3 h-3 inline mr-1`}),` Report`]}),P.failed_count>0&&P.imported_count>0&&(0,g.jsx)(`button`,{onClick:()=>ut(P.batch_id),disabled:I,className:`px-3 py-2 border border-amber-500/30 text-amber-300 rounded-lg text-[9px] font-bold uppercase`,children:`Retry embeddings`}),[`completed`,`completed_with_warnings`].includes(P.status)&&(0,g.jsxs)(`button`,{onClick:()=>lt(P.batch_id),disabled:I,className:`px-3 py-2 border border-red-500/30 text-red-400 rounded-lg text-[9px] font-bold uppercase`,children:[(0,g.jsx)(fe,{className:`w-3 h-3 inline mr-1`}),` Rollback`]})]})]})]})]}),(0,g.jsxs)(`div`,{className:`p-5 border-t border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,g.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued flex items-center gap-2`,children:[(0,g.jsx)(l,{className:`w-4 h-4 text-green-400`}),` ZIP traversal blocked · Markdown never executed · imported memory remains auditable`]}),(0,g.jsxs)(`div`,{className:`flex gap-3`,children:[(0,g.jsx)(`button`,{onClick:()=>M(!1),className:`px-5 py-2 border border-shogun-border rounded-lg text-xs font-bold text-shogun-subdued`,children:`Close`}),(0,g.jsx)(`button`,{onClick:ct,disabled:I||P?.status!==`previewed`,className:`px-6 py-2 bg-green-600 text-white rounded-lg text-xs font-bold uppercase tracking-widest disabled:opacity-40`,children:`Import Valid Memories`})]})]})]})}),Le&&(0,g.jsx)(`div`,{className:`fixed inset-0 z-[110] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md`,children:(0,g.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-5xl max-h-[92vh] rounded-2xl shadow-2xl overflow-hidden flex flex-col`,children:[(0,g.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`div`,{className:`w-11 h-11 rounded-xl bg-shogun-blue/10 border border-shogun-blue/20 flex items-center justify-center text-shogun-blue`,children:(0,g.jsx)(xe,{className:`w-6 h-6`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h3`,{className:`text-xl font-bold shogun-title`,children:`Export Memory`}),(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued uppercase tracking-widest font-bold`,children:`OpenClaw-compatible Markdown bundle`})]})]}),(0,g.jsx)(`button`,{onClick:()=>j(!1),className:`p-2 hover:bg-shogun-bg rounded-lg`,children:(0,g.jsx)(f,{className:`w-6 h-6 text-shogun-subdued`})})]}),(0,g.jsxs)(`div`,{className:`p-6 overflow-y-auto grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Export Scope & Filters`}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Scope`,(0,g.jsxs)(`select`,{value:U.scope,onChange:e=>W({...U,scope:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:`all`,children:`All memory`}),(0,g.jsx)(`option`,{value:`agent`,children:`Selected agent`}),(0,g.jsx)(`option`,{value:`project`,children:`Selected project`}),(0,g.jsx)(`option`,{value:`archives`,children:`Archives only`})]})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`Agent`,(0,g.jsxs)(`select`,{value:U.agent_id,onChange:e=>W({...U,agent_id:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:``,children:`All agents`}),S.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),U.scope===`project`&&(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued block`,children:[`Project identifier`,(0,g.jsx)(`input`,{value:U.project_id,onChange:e=>W({...U,project_id:e.target.value}),placeholder:`Project slug or UUID`,className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text normal-case`})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`From`,(0,g.jsx)(`input`,{type:`date`,value:U.date_from,onChange:e=>W({...U,date_from:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued`,children:[`To`,(0,g.jsx)(`input`,{type:`date`,value:U.date_to,onChange:e=>W({...U,date_to:e.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2 text-xs text-shogun-text`})]})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-[10px] uppercase font-bold text-shogun-subdued mb-2`,children:`Memory types (none means all)`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Q.filter(e=>e!==`all`).map(e=>(0,g.jsx)(`button`,{onClick:()=>at(e),className:p(`px-3 py-1.5 rounded-lg border text-[9px] uppercase font-bold`,U.memory_types.includes(e)?`border-shogun-blue bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued`),children:e},e))})]}),(0,g.jsxs)(`label`,{className:`space-y-1 text-[10px] uppercase font-bold text-shogun-subdued block`,children:[`Minimum importance: `,Math.round(U.min_importance*100),`%`,(0,g.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:U.min_importance,onChange:e=>W({...U,min_importance:Number(e.target.value)}),className:`w-full accent-shogun-blue`})]})]}),(0,g.jsx)(`div`,{className:`shogun-card grid grid-cols-2 gap-3`,children:[[`include_archives`,`Include archives`],[`include_private`,`Include private`],[`include_sticky`,`Include sticky`],[`include_analysis`,`Include analysis`],[`include_raw_json`,`Include raw JSON`],[`include_secrets`,`Include secret-classified`],[`package_as_zip`,`Package as ZIP`]].map(([e,t])=>(0,g.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-shogun-text cursor-pointer`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:U[e],onChange:t=>W({...U,[e]:t.target.checked}),className:`accent-shogun-blue`}),` `,t]},e))}),(U.include_private||U.include_secrets)&&(0,g.jsxs)(`div`,{className:`p-4 rounded-xl bg-amber-500/10 border border-amber-500/30 text-amber-300 space-y-3`,children:[(0,g.jsxs)(`div`,{className:`flex gap-3`,children:[(0,g.jsx)(ge,{className:`w-5 h-5 shrink-0`}),(0,g.jsx)(`p`,{className:`text-xs leading-relaxed`,children:`This export may contain private or secret-classified context, preferences, project information, and operational memory. Store it securely.`})]}),(0,g.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-bold`,children:[(0,g.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>Je(e.target.checked),className:`accent-amber-400`}),` I understand and confirm this sensitive export.`]})]}),U.include_secrets&&(0,g.jsx)(`p`,{className:`text-[10px] text-red-400 border border-red-500/30 bg-red-500/10 rounded-lg p-3`,children:`Secret-classified memory is explicitly included. Review and protect the resulting bundle.`})]}),(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest`,children:`Export Preview`}),(0,g.jsx)(`button`,{onClick:nt,className:`px-3 py-1.5 text-[9px] font-bold uppercase border border-shogun-gold/30 text-shogun-gold rounded-lg`,children:`Refresh preview`})]}),B?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:[`memories`,`archives`,`sticky`,`analysis`,`private`,`total`].map(e=>(0,g.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-lg p-3`,children:[(0,g.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:e}),(0,g.jsx)(`p`,{className:`text-lg font-bold`,children:B.estimated_counts[e]||0})]},e))}),(0,g.jsx)(`div`,{children:B.warnings.map(e=>(0,g.jsxs)(`p`,{className:`text-[10px] text-amber-300`,children:[`• `,e]},e))})]}):(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Preview the selected filters before generating the bundle.`})]}),V&&(0,g.jsxs)(`div`,{className:`shogun-card border-shogun-blue/30 space-y-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold uppercase text-shogun-blue`,children:`Current Export`}),(0,g.jsx)(`span`,{className:`text-[9px] uppercase font-bold`,children:V.status.replaceAll(`_`,` `)})]}),(0,g.jsx)(`p`,{className:`text-[10px] font-mono text-shogun-subdued`,children:V.export_id}),(0,g.jsxs)(`p`,{className:`text-xs`,children:[V.records_exported,` Markdown files generated`]}),V.download_url&&(0,g.jsxs)(`a`,{href:V.download_url,className:`flex items-center justify-center gap-2 w-full py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold uppercase`,children:[(0,g.jsx)(o,{className:`w-4 h-4`}),` Download ZIP`]})]}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold uppercase text-shogun-subdued`,children:`Export History`}),(0,g.jsx)(`button`,{onClick:tt,children:(0,g.jsx)(c,{className:`w-3 h-3 text-shogun-subdued`})})]}),(0,g.jsx)(`div`,{className:`space-y-2 max-h-52 overflow-y-auto`,children:Ue.length===0?(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No exports yet.`}):Ue.map(e=>(0,g.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg flex items-center justify-between gap-2`,children:[(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsx)(`p`,{className:`text-[10px] font-mono truncate`,children:e.export_id}),(0,g.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[new Date(e.requested_at).toLocaleString(),` · `,e.records_exported,` files`]})]}),e.download_url?(0,g.jsx)(`a`,{title:`Download export`,href:e.download_url,children:(0,g.jsx)(o,{className:`w-4 h-4 text-shogun-blue`})}):(0,g.jsx)(`span`,{className:`text-[8px] uppercase text-shogun-subdued`,children:e.status})]},e.export_id))})]})]})]}),(0,g.jsxs)(`div`,{className:`p-5 border-t border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,g.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued flex items-center gap-2`,children:[(0,g.jsx)(Se,{className:`w-4 h-4 text-green-400`}),` Files remain local in Shogun-controlled storage.`]}),(0,g.jsxs)(`div`,{className:`flex gap-3`,children:[(0,g.jsx)(`button`,{onClick:()=>j(!1),className:`px-5 py-2 border border-shogun-border rounded-lg text-xs font-bold text-shogun-subdued`,children:`Close`}),(0,g.jsx)(`button`,{onClick:it,disabled:Ke||(U.include_private||U.include_secrets)&&!H,className:`px-6 py-2 bg-shogun-blue text-white rounded-lg text-xs font-bold uppercase tracking-widest disabled:opacity-40`,children:Ke?`Exporting…`:`Generate Export`})]})]})]})}),Ie&&(0,g.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md animate-in fade-in duration-300`,children:(0,g.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-2xl rounded-2xl shadow-2xl overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-shogun-gold/10 border border-shogun-gold/20 flex items-center justify-center text-shogun-gold`,children:(0,g.jsx)(de,{className:`w-6 h-6`})}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h3`,{className:`text-xl font-bold shogun-title`,children:`Inscribe Memory`}),(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued uppercase tracking-widest font-bold`,children:`Manual Fragment Injection`})]})]}),(0,g.jsx)(`button`,{onClick:()=>A(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,g.jsx)(f,{className:`w-6 h-6 text-shogun-subdued`})})]}),(0,g.jsxs)(`div`,{className:`p-8 space-y-6`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.memory_type`,`Memory Type`)}),(0,g.jsx)(`select`,{value:q.memory_type,onChange:e=>J({...q,memory_type:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all`,children:Q.filter(e=>e!==`all`).map(e=>(0,g.jsx)(`option`,{value:e,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.agent_attribution`,`Agent Attribution`)}),(0,g.jsxs)(`select`,{value:q.agent_id,onChange:e=>J({...q,agent_id:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all`,children:[(0,g.jsx)(`option`,{value:``,children:`Select Agent...`}),S.map(e=>(0,g.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.agent_type,`)`]},e.id))]})]})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.memory_title`,`Memory Title`)}),(0,g.jsx)(`input`,{type:`text`,placeholder:`E.g. Operational Guidelines for Project Alpha`,value:q.title,onChange:e=>J({...q,title:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all`})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.content_payload`,`Content Payload`)}),(0,g.jsx)(`textarea`,{rows:5,placeholder:`Paste fragment content here...`,value:q.content,onChange:e=>J({...q,content:e.target.value}),className:`w-full bg-shogun-card border border-shogun-border rounded-xl px-4 py-3 text-sm text-shogun-text outline-none focus:border-shogun-blue transition-all resize-none font-mono`})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-6 items-center`,children:[(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between text-[10px] font-bold uppercase tracking-widest`,children:[(0,g.jsx)(`span`,{className:`text-shogun-subdued`,children:`Intrinsic Importance`}),(0,g.jsxs)(`span`,{className:`text-shogun-gold`,children:[Math.round(q.importance_score*100),`%`]})]}),(0,g.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:q.importance_score,onChange:e=>J({...q,importance_score:parseFloat(e.target.value)}),className:`w-full h-2 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-shogun-gold`})]}),(0,g.jsxs)(`div`,{className:`space-y-2`,children:[(0,g.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:e(`archives.decay_class`,`Decay Class`)}),(0,g.jsx)(`div`,{className:`flex gap-2`,children:[`fast`,`medium`,`slow`,`sticky`,`pinned`].map(e=>(0,g.jsx)(`button`,{onClick:()=>J({...q,decay_class:e}),className:p(`px-2 py-1 rounded border text-[8px] font-bold uppercase transition-all flex-1`,q.decay_class===e?`bg-shogun-blue/20 border-shogun-blue text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:e},e))})]})]})]}),(0,g.jsxs)(`div`,{className:`p-6 bg-shogun-card border-t border-shogun-border mt-auto flex justify-end gap-3`,children:[(0,g.jsx)(`button`,{onClick:()=>A(!1),className:`px-6 py-2.5 rounded-xl border border-shogun-border text-sm font-bold text-shogun-subdued hover:bg-shogun-bg transition-all`,children:`Cancel`}),(0,g.jsx)(`button`,{onClick:Ze,className:`px-8 py-2.5 rounded-xl bg-shogun-blue text-white text-sm font-bold uppercase tracking-widest hover:brightness-110 transition-all shadow-[0_0_20px_rgba(74,140,199,0.3)]`,children:`Create Fragment`})]})]})}),O&&(0,g.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/90 backdrop-blur-md animate-in fade-in duration-300`,onClick:()=>k(null),children:(0,g.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-4xl rounded-3xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300`,onClick:e=>e.stopPropagation(),children:[(0,g.jsxs)(`div`,{className:`p-8 border-b border-shogun-border bg-shogun-card flex justify-between items-start`,children:[(0,g.jsxs)(`div`,{className:`flex items-start gap-5`,children:[(0,g.jsx)(`div`,{className:p(`w-14 h-14 rounded-2xl bg-[#050508] border border-shogun-border flex items-center justify-center`,Z(O.memory_type)),children:dt(O.memory_type)}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h3`,{className:`text-2xl font-bold shogun-title mb-1`,children:O.title}),(0,g.jsxs)(`div`,{className:`flex items-center gap-4 text-xs font-bold uppercase tracking-widest mt-1`,children:[(0,g.jsx)(`span`,{className:p(Z(O.memory_type)),children:O.memory_type}),(0,g.jsx)(`span`,{className:`text-shogun-subdued opacity-30`,children:`/`}),(0,g.jsxs)(`span`,{className:`text-shogun-subdued`,children:[`GUID: `,O.id]}),O.is_pinned&&(0,g.jsxs)(`span`,{className:`flex items-center gap-1.5 text-shogun-gold bg-shogun-gold/10 px-2.5 py-1 rounded-full`,children:[(0,g.jsx)(s,{className:`w-3 h-3`}),` Pinned`]})]})]})]}),(0,g.jsx)(`button`,{onClick:()=>k(null),className:`p-2 hover:bg-[#0a0e1a] rounded-xl transition-colors`,children:(0,g.jsx)(f,{className:`w-8 h-8 text-shogun-subdued hover:text-shogun-text`})})]}),(0,g.jsxs)(`div`,{className:`grid grid-cols-12 max-h-[75vh] overflow-y-auto`,children:[(0,g.jsxs)(`div`,{className:`col-span-8 p-8 border-r border-shogun-border space-y-8 bg-[#050508]/20`,children:[(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,g.jsx)(le,{className:`w-3.5 h-3.5`}),` `,O.memory_type===`programming`?`Verified Solution`:O.memory_type===`skills`?`Full Canonical SKILL.md`:`Intelligence Payload`]}),(0,g.jsx)(`div`,{className:`bg-shogun-bg border border-shogun-border p-6 rounded-2xl text-[13px] leading-relaxed text-shogun-text font-mono whitespace-pre-wrap break-words shadow-inner min-h-[300px]`,children:O.solution||O.content||`(Fragment empty)`})]}),O.memory_type===`programming`&&(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,g.jsxs)(`div`,{className:`shogun-card !p-4`,children:[(0,g.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-cyan-400 mb-2`,children:`Problem`}),(0,g.jsx)(`p`,{className:`text-xs text-shogun-text whitespace-pre-wrap`,children:O.problem||O.summary})]}),(0,g.jsxs)(`div`,{className:`shogun-card !p-4`,children:[(0,g.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-green-400 mb-2`,children:`Validation Evidence`}),(0,g.jsx)(`p`,{className:`text-xs text-shogun-text whitespace-pre-wrap`,children:O.evidence||`No evidence recorded.`})]})]}),(0,g.jsxs)(`div`,{className:`shogun-card !p-4 space-y-3`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-shogun-subdued mb-1`,children:`Files`}),(0,g.jsx)(`p`,{className:`text-xs font-mono text-shogun-text`,children:O.files?.join(`, `)||`No files recorded`})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-shogun-subdued mb-1`,children:`Languages`}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(O.languages||[]).map(e=>(0,g.jsx)(`span`,{className:`px-2 py-1 rounded bg-cyan-500/10 border border-cyan-500/20 text-[9px] text-cyan-300`,children:e},e))})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-[9px] uppercase font-bold text-shogun-subdued mb-1`,children:`Sources`}),(0,g.jsx)(`div`,{className:`space-y-1`,children:(O.source_urls||[]).map(e=>(0,g.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`block text-[10px] text-shogun-blue hover:underline break-all`,children:e},e))})]})]})]}),`scores`in O&&(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,g.jsx)(ne,{className:`w-3.5 h-3.5`}),` Semantic Score Analysis`]}),(0,g.jsx)(`div`,{className:`grid grid-cols-5 gap-3`,children:[{label:`Similarity`,val:O.scores.semantic_similarity,color:`shogun-blue`},{label:`Salience`,val:O.scores.relevance_score,color:`shogun-blue`},{label:`Importance`,val:O.scores.importance_score,color:`shogun-gold`},{label:`Confidence`,val:O.scores.confidence_score,color:`green-500`},{label:`Recency`,val:O.scores.recency_boost,color:`purple-400`}].map(e=>(0,g.jsxs)(`div`,{className:`shogun-card !p-3 text-center transition-transform hover:scale-105`,children:[(0,g.jsx)(`span`,{className:`text-[8px] text-shogun-subdued uppercase font-bold block mb-2`,children:e.label}),(0,g.jsxs)(`div`,{className:p(`text-xl font-bold font-mono tracking-tighter text-`+e.color),children:[Math.round(e.val*100),`%`]})]},e.label))})]})]}),(0,g.jsxs)(`div`,{className:`col-span-4 p-8 bg-shogun-card/50 space-y-8`,children:[(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em]`,children:`Operational Health`}),(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between items-center bg-shogun-bg/50 p-3 border border-shogun-border rounded-xl`,children:[(0,g.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold`,children:O.memory_type===`programming`?`Validation`:`Decay State`}),(0,g.jsx)(`span`,{className:p(`text-[9px] font-bold uppercase px-2 py-1 rounded-md`,O.decay_class===`pinned`?`bg-purple-500/10 text-purple-400`:`bg-shogun-blue/10 text-shogun-blue`),children:O.memory_type===`programming`?O.validation_status?.replaceAll(`_`,` `):O.decay_class})]}),(0,g.jsxs)(`div`,{className:`space-y-1`,children:[(0,g.jsxs)(`div`,{className:`flex justify-between text-[10px] text-shogun-subdued uppercase font-bold px-1`,children:[(0,g.jsx)(`span`,{children:`Utilization Pattern`}),(0,g.jsxs)(`span`,{className:`text-shogun-text font-mono truncate max-w-[100px]`,children:[O.successful_use_count,` of `,O.access_count]})]}),(0,g.jsx)(`div`,{className:`h-2 bg-shogun-bg border border-shogun-border rounded-full overflow-hidden`,children:(0,g.jsx)(`div`,{className:`h-full bg-green-500 transition-all`,style:{width:`${O.successful_use_count/Math.max(1,O.access_count)*100}%`}})})]})]})]}),(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em]`,children:`Provenance Detail`}),(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,g.jsx)(ie,{className:`w-4 h-4 text-shogun-blue`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Inscribed At`}),(0,g.jsx)(`p`,{className:`text-shogun-text font-bold`,children:O.created_at?new Date(O.created_at).toLocaleString():`Just now`})]})]}),O.memory_type===`programming`&&(0,g.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,g.jsx)(ae,{className:`w-4 h-4 text-cyan-400`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Project Workspace`}),(0,g.jsx)(`p`,{className:`text-shogun-text font-bold`,children:O.workspace_name||`Unknown project`}),(0,g.jsx)(`p`,{className:`text-[8px] font-mono text-shogun-subdued truncate max-w-[190px]`,children:O.workspace_key})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,g.jsx)(_e,{className:`w-4 h-4 text-shogun-gold`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Attributed Agent`}),(0,g.jsx)(`p`,{className:`text-shogun-text font-bold`,children:S.find(e=>e.id===O.agent_id)?.name||`System Initializer`})]})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-3 text-xs opacity-50`,children:[(0,g.jsx)(c,{className:`w-4 h-4 text-shogun-subdued`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-shogun-subdued text-[9px] uppercase font-bold`,children:`Last Reinforcement`}),(0,g.jsx)(`p`,{className:`text-shogun-text font-bold`,children:ft(O.last_confirmed_at)})]})]})]})]}),(0,g.jsxs)(`div`,{className:`pt-8 space-y-3`,children:[O.memory_type!==`programming`&&(0,g.jsx)(`button`,{onClick:()=>Xe(O.id),className:`w-full py-3 bg-shogun-bg border border-shogun-border rounded-xl text-xs font-bold uppercase tracking-widest hover:text-shogun-gold hover:border-shogun-gold transition-all flex items-center justify-center gap-3 group`,children:O.is_pinned?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(Ce,{className:`w-4 h-4 group-hover:scale-110`}),` Unpin Fragment`]}):(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(s,{className:`w-4 h-4 group-hover:scale-110`}),` Pin for Retrieval`]})}),(0,g.jsxs)(`button`,{onClick:()=>Ye(O.id),className:`w-full py-3 bg-shogun-bg border border-shogun-border rounded-xl text-xs font-bold uppercase tracking-widest hover:text-red-500 hover:border-red-500 transition-all flex items-center justify-center gap-3 group`,children:[(0,g.jsx)(i,{className:`w-4 h-4 group-hover:scale-110`}),` `,O.memory_type===`programming`?`Delete Programming Memory`:`Move to Archive`]})]})]})]})]})}),(0,g.jsx)(`style`,{children:` - .custom-scrollbar::-webkit-scrollbar { width: 4px; } - .custom-scrollbar::-webkit-scrollbar-track { background: transparent; } - .custom-scrollbar::-webkit-scrollbar-thumb { background: #1a2235; border-radius: 10px; } - .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #4a8cc7; } - `})]})}export{v as Archives}; \ No newline at end of file diff --git a/frontend/dist/assets/Backups-C--W39Tf.js b/frontend/dist/assets/Backups-C--W39Tf.js deleted file mode 100644 index ac4ac06..0000000 --- a/frontend/dist/assets/Backups-C--W39Tf.js +++ /dev/null @@ -1 +0,0 @@ -import{o as e,r as t,t as n}from"./jsx-runtime-DmifIpYY.js";import{t as r}from"./activity-D6ZKsL_W.js";import{t as i}from"./archive-CCh8OMBK.js";import{t as a}from"./chevron-right-BzAY5P9l.js";import{t as o}from"./circle-alert-DVHRBFRQ.js";import{t as s}from"./circle-check-D9mntLsp.js";import{t as c}from"./circle-question-mark-qh8t_nrj.js";import{t as l}from"./clock-B8iyCT3M.js";import{t as u}from"./database-B_RLhoAx.js";import{t as d}from"./file-text-Db8l8y7y.js";import{t as f}from"./hard-drive-CKvWVafA.js";import{t as p}from"./loader-circle-yHzGFbgr.js";import{t as m}from"./plus-DFW_DMbT.js";import{t as ee}from"./refresh-cw-CCrS0Omg.js";import{t as h}from"./rotate-ccw-DsOLVoka.js";import{t as g}from"./settings-DYFQa-lL.js";import{n as _,t as v}from"./toggle-right-r1O78oQo.js";import{t as te}from"./trash-2-Cid5DKqF.js";import{t as y}from"./upload-D8ecl32P.js";import{t as b}from"./axios-BPyV2soB.js";var x=e(t(),1),S=n(),C=()=>{let[e,t]=(0,x.useState)([]),[n,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(!1),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),[A,ne]=(0,x.useState)(!1),[j,M]=(0,x.useState)(`backups`),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(!1),[L,re]=(0,x.useState)(`data\\backups`),[R,z]=(0,x.useState)(null),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(!1),[W,G]=(0,x.useState)(null),K=(0,x.useRef)(null),q=async()=>{try{t((await(await fetch(`/api/v1/backups/list`)).json()).backups||[])}catch{}},J=async()=>{try{C(await(await fetch(`/api/v1/backups/settings`)).json())}catch{}},Y=async e=>{try{C(await(await fetch(`/api/v1/backups/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json()),k({type:`success`,text:`Settings saved.`}),setTimeout(()=>k(null),3e3)}catch{k({type:`error`,text:`Failed to save settings.`})}},X=async()=>{T(!0),k(null);try{let e=await(await fetch(`/api/v1/backups/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:`manual`})})).json();e.success?(k({type:`success`,text:`Backup created: ${e.filename} (${e.files_count} files)`}),q(),J()):k({type:`error`,text:e.detail||`Backup failed.`})}catch{k({type:`error`,text:`Backup failed.`})}T(!1)},ie=async e=>{if(confirm(`Delete ${e}?`))try{await fetch(`/api/v1/backups/${e}`,{method:`DELETE`}),q(),k({type:`success`,text:`Backup deleted.`}),setTimeout(()=>k(null),3e3)}catch{}},ae=async e=>{if(confirm(`This will overwrite your current database and configs. A restart is required afterwards. Continue?`)){D(e);try{let t=await(await fetch(`/api/v1/backups/restore/${e}`,{method:`POST`})).json();t.success?k({type:`success`,text:`Restored ${t.files_restored} files. Please restart Shogun.`}):k({type:`error`,text:t.detail||`Restore failed.`})}catch{k({type:`error`,text:`Restore failed.`})}D(null)}},Z=async()=>{I(!0);try{P((await b.get(`/api/v1/system/backup/info`)).data.data)}catch{}finally{I(!1)}},Q=async e=>{I(!0);try{let t=e===`raw`,n=await b.get(`/api/v1/system/backup/export`,{params:{save_path:L,include_db:t}});if(n.data?.success===!1)throw Error(n.data?.meta?.error||`Export failed`);let r=n.data?.data?.saved_to||L,i=n.data?.data?.size_bytes;z({type:`success`,text:`ZIP verified and saved to ${r}${typeof i==`number`?` (${(i/1024/1024).toFixed(2)} MB)`:``}`}),Z()}catch(e){z({type:`error`,text:e.response?.data?.meta?.error||e.response?.data?.detail||e.message||`Export failed`})}finally{I(!1)}},$=async e=>{if(e){if(!e.name.toLowerCase().endsWith(`.zip`)){G({type:`error`,text:`Please select a Shogun .zip backup.`});return}if(!confirm(`Import ${e.name}? This will replace the current Shogun state. A restart will be required.`)){K.current&&(K.current.value=``);return}V(!0),G(null);try{let t=new FormData;t.append(`file`,e),t.append(`restore_mode`,`auto`),t.append(`wipe_first`,`true`);let n=await b.post(`/api/v1/system/backup/import`,t,{headers:{"Content-Type":`multipart/form-data`}});if(n.data?.success===!1)throw Error(n.data?.meta?.error||`Import failed`);let r=n.data?.data||{};G({type:`success`,text:`${r.mode===`db`?`Raw database restored (${r.restored_bytes||0} bytes).`:`${r.total_rows_restored||0} rows restored across ${Object.keys(r.restored_tables||{}).length} tables.`} Restart Shogun to complete the import.`}),await Z()}catch(e){G({type:`error`,text:e.response?.data?.meta?.error||e.response?.data?.detail||e.message||`Import failed`})}finally{V(!1),U(!1),K.current&&(K.current.value=``)}}};return(0,x.useEffect)(()=>{q(),J()},[]),(0,x.useEffect)(()=>{j===`data`&&Z()},[j]),(0,S.jsxs)(`div`,{className:`p-8 max-w-5xl mx-auto space-y-8`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,S.jsx)(f,{className:`w-6 h-6 text-shogun-gold`}),`Backups & Data Management`]}),(0,S.jsx)(`p`,{className:`text-shogun-subdued mt-1`,children:`Protect your data with scheduled backups and manage your database.`})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(`button`,{onClick:()=>ne(!A),className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-shogun-card border border-shogun-border text-shogun-subdued hover:text-shogun-text hover:border-shogun-blue transition-colors text-sm`,children:[(0,S.jsx)(g,{className:`w-4 h-4`}),`Settings`]}),(0,S.jsxs)(`button`,{onClick:X,disabled:w,className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-shogun-gold text-black font-semibold hover:bg-shogun-gold/80 transition-colors text-sm disabled:opacity-50`,children:[(0,S.jsx)(m,{className:`w-4 h-4 ${w?`animate-spin`:``}`}),w?`Creating...`:`Backup Now`]})]})]}),(0,S.jsx)(`div`,{className:`flex items-center gap-1 p-1 bg-shogun-card border border-shogun-border rounded-xl w-fit`,children:[{id:`backups`,label:`Scheduled Backups`,icon:l},{id:`data`,label:`Data Management`,icon:u}].map(e=>(0,S.jsxs)(`button`,{onClick:()=>M(e.id),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold transition-all ${j===e.id?`bg-shogun-bg text-shogun-gold border border-shogun-border shadow-shogun`:`text-shogun-subdued hover:text-shogun-text`}`,children:[(0,S.jsx)(e.icon,{className:`w-3.5 h-3.5`}),e.label]},e.id))}),O&&(0,S.jsx)(`div`,{className:`rounded-xl p-4 border text-sm ${O.type===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-red-500/10 border-red-500/30 text-red-300`}`,children:O.text}),A&&n&&(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6 space-y-5`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-bold text-shogun-gold uppercase tracking-wider`,children:`Backup Settings`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Automatic Backups`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Automatically back up on a schedule.`})]}),(0,S.jsx)(`button`,{onClick:()=>Y({enabled:!n.enabled}),className:`text-shogun-gold`,children:n.enabled?(0,S.jsx)(v,{className:`w-8 h-8`}):(0,S.jsx)(_,{className:`w-8 h-8 text-shogun-subdued`})})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Backup Interval`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`How often to create automatic backups.`})]}),(0,S.jsxs)(`select`,{value:n.interval_hours,onChange:e=>Y({interval_hours:Number(e.target.value)}),className:`bg-shogun-bg border border-shogun-border rounded-lg px-3 py-1.5 text-sm text-white`,children:[(0,S.jsx)(`option`,{value:1,children:`Every hour`}),(0,S.jsx)(`option`,{value:6,children:`Every 6 hours`}),(0,S.jsx)(`option`,{value:12,children:`Every 12 hours`}),(0,S.jsx)(`option`,{value:24,children:`Every 24 hours`}),(0,S.jsx)(`option`,{value:48,children:`Every 2 days`}),(0,S.jsx)(`option`,{value:168,children:`Weekly`})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Backups to Keep`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Older backups beyond this limit are automatically deleted.`})]}),(0,S.jsx)(`select`,{value:n.max_backups,onChange:e=>Y({max_backups:Number(e.target.value)}),className:`bg-shogun-bg border border-shogun-border rounded-lg px-3 py-1.5 text-sm text-white`,children:[1,2,3,5,7,10,15,20].map(e=>(0,S.jsxs)(`option`,{value:e,children:[e,` backups`]},e))})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Include Vector Memory`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Include Qdrant data (significantly increases backup size).`})]}),(0,S.jsx)(`button`,{onClick:()=>Y({include_vector_memory:!n.include_vector_memory}),className:`text-shogun-gold`,children:n.include_vector_memory?(0,S.jsx)(v,{className:`w-8 h-8`}):(0,S.jsx)(_,{className:`w-8 h-8 text-shogun-subdued`})})]})]}),j===`backups`&&(0,S.jsxs)(S.Fragment,{children:[n&&(0,S.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-4 text-center`,children:[(0,S.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:`Schedule`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-white`,children:n.enabled?`Every ${n.interval_hours}h`:`Disabled`})]}),(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-4 text-center`,children:[(0,S.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:`Total Backups`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-white`,children:e.length})]}),(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-4 text-center`,children:[(0,S.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:`Last Backup`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-white`,children:n.last_backup?new Date(n.last_backup).toLocaleDateString():`Never`})]})]}),(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl overflow-hidden`,children:[(0,S.jsx)(`div`,{className:`px-6 py-4 border-b border-shogun-border`,children:(0,S.jsx)(`h2`,{className:`text-sm font-bold text-white`,children:`Available Backups`})}),e.length===0?(0,S.jsxs)(`div`,{className:`p-8 text-center text-shogun-subdued`,children:[(0,S.jsx)(i,{className:`w-10 h-10 mx-auto mb-3 opacity-30`}),(0,S.jsx)(`p`,{children:`No backups yet.`}),(0,S.jsx)(`p`,{className:`text-[11px] mt-1`,children:`Create one manually or enable automatic backups.`})]}):(0,S.jsx)(`div`,{className:`divide-y divide-shogun-border/50`,children:e.map(e=>(0,S.jsxs)(`div`,{className:`px-6 py-4 flex items-center justify-between hover:bg-shogun-bg/50 transition-colors`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,S.jsx)(f,{className:`w-5 h-5 text-shogun-blue`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e.filename}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-shogun-subdued mt-0.5`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(l,{className:`w-3 h-3`}),new Date(e.created_at).toLocaleString()]}),(0,S.jsx)(`span`,{children:e.size_formatted})]})]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(`button`,{onClick:()=>ae(e.filename),disabled:E===e.filename,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] bg-shogun-bg border border-shogun-border text-shogun-subdued hover:text-amber-400 hover:border-amber-400/50 transition-colors disabled:opacity-50`,children:[(0,S.jsx)(h,{className:`w-3 h-3 ${E===e.filename?`animate-spin`:``}`}),E===e.filename?`Restoring...`:`Restore`]}),(0,S.jsxs)(`button`,{onClick:()=>ie(e.filename),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] bg-shogun-bg border border-shogun-border text-shogun-subdued hover:text-red-400 hover:border-red-400/50 transition-colors`,children:[(0,S.jsx)(te,{className:`w-3 h-3`}),`Delete`]})]})]},e.filename))})]})]}),j===`data`&&(0,S.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-8 animate-in slide-in-from-bottom-4`,children:[(0,S.jsxs)(`div`,{className:`lg:col-span-4 space-y-6`,children:[(0,S.jsxs)(`section`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-5`,children:[(0,S.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-4 flex items-center gap-2`,children:[(0,S.jsx)(r,{className:`w-3 h-3`}),` System Snapshot`]}),F?(0,S.jsxs)(`div`,{className:`flex items-center gap-3 py-6 text-shogun-subdued animate-pulse`,children:[(0,S.jsx)(ee,{className:`w-4 h-4 animate-spin`}),(0,S.jsx)(`span`,{className:`text-xs uppercase font-bold tracking-widest`,children:`Scanning DB...`})]}):N?(0,S.jsxs)(`div`,{className:`space-y-4`,children:[N.tables&&Object.entries(N.tables).map(([e,t])=>(0,S.jsxs)(`div`,{className:`flex justify-between items-center bg-shogun-bg p-3 rounded-lg border border-shogun-border`,children:[(0,S.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold`,children:e.replace(/_/g,` `)}),(0,S.jsx)(`span`,{className:`text-sm font-bold text-shogun-text`,children:t})]},e)),(0,S.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border text-center`,children:[(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase font-bold`,children:`Total Rows`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-shogun-blue`,children:N.total_rows??`—`})]}),(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase font-bold`,children:`Database Size`}),(0,S.jsxs)(`p`,{className:`text-2xl font-bold text-shogun-text`,children:[`~`,((N.db_size_bytes||0)/1024/1024).toFixed(2),` MB`]})]})]}):(0,S.jsx)(`div`,{className:`py-6 text-center italic text-shogun-subdued text-xs`,children:`Click "Refresh" to scan the database.`}),(0,S.jsx)(`button`,{onClick:Z,className:`w-full mt-4 py-2 border border-shogun-border rounded-lg text-[9px] font-bold uppercase tracking-widest hover:text-shogun-blue transition-colors`,children:`Refresh Snapshot`})]}),(0,S.jsxs)(`div`,{className:`bg-indigo-500/5 border border-indigo-500/20 rounded-xl p-5`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-indigo-400 mb-2`,children:[(0,S.jsx)(c,{className:`w-4 h-4`}),(0,S.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Why Export?`})]}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Your Shogun stores months of custom knowledge, trained skills, and secure identities. Exporting allows you to migrate your entire mind-state to a new server or recover from hardware failure.`})]})]}),(0,S.jsxs)(`div`,{className:`lg:col-span-8 space-y-6`,children:[(0,S.jsxs)(`section`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6 space-y-6`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text mb-1`,children:`Export Library`}),(0,S.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Pack your entire intelligence store into a portable ZIP bundle.`})]}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Target Backup Directory`}),(0,S.jsx)(`input`,{type:`text`,value:L,onChange:e=>re(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-4 py-2.5 text-xs font-mono outline-none focus:border-shogun-blue text-white`})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,S.jsxs)(`button`,{onClick:()=>Q(`json`),disabled:F,className:`p-6 bg-shogun-bg border border-shogun-border rounded-2xl text-left hover:border-shogun-blue transition-all group disabled:opacity-50`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsx)(d,{className:`w-6 h-6 text-shogun-blue`}),(0,S.jsx)(a,{className:`w-4 h-4 text-shogun-subdued group-hover:translate-x-1 transition-transform`})]}),(0,S.jsx)(`div`,{className:`font-bold text-shogun-text`,children:`Safe JSON Bundle`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Exports every table individually. Safest for moving between Shogun versions.`})]}),(0,S.jsxs)(`button`,{onClick:()=>Q(`raw`),disabled:F,className:`p-6 bg-shogun-bg border border-shogun-border rounded-2xl text-left hover:border-shogun-gold transition-all group disabled:opacity-50`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsx)(u,{className:`w-6 h-6 text-shogun-gold`}),(0,S.jsx)(a,{className:`w-4 h-4 text-shogun-subdued group-hover:translate-x-1 transition-transform`})]}),(0,S.jsx)(`div`,{className:`font-bold text-shogun-text`,children:`Raw Database Swap`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Copies the actual Shogun.db file directly. Fast, requires same version.`})]})]})]}),R&&(0,S.jsxs)(`div`,{className:`p-3 rounded-lg flex items-center gap-3 text-xs font-bold uppercase ${R.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`}`,children:[R.type===`success`?(0,S.jsx)(s,{className:`w-4 h-4`}):(0,S.jsx)(o,{className:`w-4 h-4`}),R.text]})]}),(0,S.jsxs)(`section`,{onClick:()=>!B&&K.current?.click(),onDragEnter:e=>{e.preventDefault(),B||U(!0)},onDragOver:e=>e.preventDefault(),onDragLeave:e=>{e.preventDefault(),e.currentTarget===e.target&&U(!1)},onDrop:e=>{e.preventDefault(),U(!1),$(e.dataTransfer.files?.[0])},className:`bg-shogun-card border border-dashed rounded-xl flex flex-col items-center justify-center p-12 text-center group transition-all ${B?`border-shogun-gold/50 cursor-wait`:H?`border-shogun-blue bg-shogun-blue/10 scale-[1.01] cursor-copy`:`border-shogun-border cursor-pointer hover:bg-shogun-blue/[0.02] hover:border-shogun-blue/40`}`,children:[(0,S.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-bg border border-shogun-border flex items-center justify-center mb-4 group-hover:scale-110 transition-transform`,children:B?(0,S.jsx)(p,{className:`w-8 h-8 text-shogun-gold animate-spin`}):(0,S.jsx)(y,{className:`w-8 h-8 text-shogun-subdued group-hover:text-shogun-blue transition-colors`})}),(0,S.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-1`,children:B?`Importing Shogun State...`:`Import Shogun State`}),(0,S.jsxs)(`p`,{className:`text-xs text-shogun-subdued max-w-sm`,children:[`Drag and drop a previously exported `,(0,S.jsx)(`strong`,{children:`.zip`}),` bundle here, or click to select it. Scheduled and Data Management backups are both supported.`]}),(0,S.jsx)(`input`,{ref:K,type:`file`,className:`hidden`,accept:`.zip,application/zip`,disabled:B,onChange:e=>void $(e.target.files?.[0])})]}),W&&(0,S.jsxs)(`div`,{className:`p-3 rounded-lg flex items-center gap-3 text-xs font-bold ${W.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`}`,children:[W.type===`success`?(0,S.jsx)(s,{className:`w-4 h-4 shrink-0`}):(0,S.jsx)(o,{className:`w-4 h-4 shrink-0`}),W.text]})]})]}),(0,S.jsxs)(`div`,{className:`text-[11px] text-shogun-subdued border-t border-shogun-border/30 pt-4 space-y-1`,children:[(0,S.jsx)(`p`,{children:`• Backups include: database, configs, governance documents, and environment settings.`}),(0,S.jsx)(`p`,{children:`• Vector memory (Qdrant) is excluded by default due to size — enable in settings if needed.`}),(0,S.jsx)(`p`,{children:`• After restoring a backup, restart Shogun for changes to take effect.`})]})]})};export{C as Backups}; \ No newline at end of file diff --git a/frontend/dist/assets/Backups-DgqOnR8m.js b/frontend/dist/assets/Backups-DgqOnR8m.js new file mode 100644 index 0000000..8036f37 --- /dev/null +++ b/frontend/dist/assets/Backups-DgqOnR8m.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./archive-BOJnkAd3.js";import{t as n}from"./chevron-right-CVeYaFvJ.js";import{t as r}from"./circle-alert-043xB2li.js";import{t as i}from"./circle-check-DBu5bzEI.js";import{t as a}from"./clock-DQ9Dz1_z.js";import{t as ee}from"./file-text-CrD-Um8r.js";import{t as o}from"./plus-Cxx0HjpF.js";import{t as te}from"./refresh-cw-Dm6S5UAJ.js";import{t as s}from"./rotate-ccw-B4t0zm9t.js";import{t as c}from"./settings-DedojrI9.js";import{n as l,t as u}from"./toggle-right-CKFx_qbf.js";import{t as d}from"./trash-2-DqRUHXwV.js";import{t as f}from"./upload-NSOxRjZn.js";import{S as p,g as m,j as h,t as g,v as _,w as v,x as y}from"./index-Dy1E248t.js";import{t as b}from"./axios-BGmZl9Qd.js";var x=e(h(),1),S=g(),C=()=>{let[e,h]=(0,x.useState)([]),[g,C]=(0,x.useState)(null),[w,T]=(0,x.useState)(!1),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),[A,j]=(0,x.useState)(!1),[M,N]=(0,x.useState)(`backups`),[P,F]=(0,x.useState)(null),[I,L]=(0,x.useState)(!1),[R,ne]=(0,x.useState)(`data\\backups`),[z,B]=(0,x.useState)(null),[V,H]=(0,x.useState)(!1),[U,W]=(0,x.useState)(!1),[G,K]=(0,x.useState)(null),q=(0,x.useRef)(null),J=async()=>{try{let e=await(await fetch(`/api/v1/backups/list`)).json();h(e.backups||[])}catch{}},Y=async()=>{try{let e=await(await fetch(`/api/v1/backups/settings`)).json();C(e)}catch{}},X=async e=>{try{let t=await(await fetch(`/api/v1/backups/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)})).json();C(t),k({type:`success`,text:`Settings saved.`}),setTimeout(()=>k(null),3e3)}catch{k({type:`error`,text:`Failed to save settings.`})}},re=async()=>{T(!0),k(null);try{let e=await(await fetch(`/api/v1/backups/create`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({label:`manual`})})).json();e.success?(k({type:`success`,text:`Backup created: ${e.filename} (${e.files_count} files)`}),J(),Y()):k({type:`error`,text:e.detail||`Backup failed.`})}catch{k({type:`error`,text:`Backup failed.`})}T(!1)},ie=async e=>{if(confirm(`Delete ${e}?`))try{await fetch(`/api/v1/backups/${e}`,{method:`DELETE`}),J(),k({type:`success`,text:`Backup deleted.`}),setTimeout(()=>k(null),3e3)}catch{}},ae=async e=>{if(confirm(`This will overwrite your current database and configs. A restart is required afterwards. Continue?`)){D(e);try{let t=await(await fetch(`/api/v1/backups/restore/${e}`,{method:`POST`})).json();t.success?k({type:`success`,text:`Restored ${t.files_restored} files. Please restart Shogun.`}):k({type:`error`,text:t.detail||`Restore failed.`})}catch{k({type:`error`,text:`Restore failed.`})}D(null)}},Z=async()=>{L(!0);try{let e=await b.get(`/api/v1/system/backup/info`);F(e.data.data)}catch{}finally{L(!1)}},Q=async e=>{L(!0);try{let t=e===`raw`,n=await b.get(`/api/v1/system/backup/export`,{params:{save_path:R,include_db:t}});if(n.data?.success===!1)throw Error(n.data?.meta?.error||`Export failed`);let r=n.data?.data?.saved_to||R,i=n.data?.data?.size_bytes,a=typeof i==`number`?` (${(i/1024/1024).toFixed(2)} MB)`:``;B({type:`success`,text:`ZIP verified and saved to ${r}${a}`}),Z()}catch(e){let t=e.response?.data?.meta?.error||e.response?.data?.detail||e.message||`Export failed`;B({type:`error`,text:t})}finally{L(!1)}},$=async e=>{if(e){if(!e.name.toLowerCase().endsWith(`.zip`)){K({type:`error`,text:`Please select a Shogun .zip backup.`});return}if(!confirm(`Import ${e.name}? This will replace the current Shogun state. A restart will be required.`)){q.current&&(q.current.value=``);return}H(!0),K(null);try{let t=new FormData;t.append(`file`,e),t.append(`restore_mode`,`auto`),t.append(`wipe_first`,`true`);let n=await b.post(`/api/v1/system/backup/import`,t,{headers:{"Content-Type":`multipart/form-data`}});if(n.data?.success===!1)throw Error(n.data?.meta?.error||`Import failed`);let r=n.data?.data||{},i=r.mode===`db`?`Raw database restored (${r.restored_bytes||0} bytes).`:`${r.total_rows_restored||0} rows restored across ${Object.keys(r.restored_tables||{}).length} tables.`;K({type:`success`,text:`${i} Restart Shogun to complete the import.`}),await Z()}catch(e){let t=e.response?.data?.meta?.error||e.response?.data?.detail||e.message||`Import failed`;K({type:`error`,text:t})}finally{H(!1),W(!1),q.current&&(q.current.value=``)}}};return(0,x.useEffect)(()=>{J(),Y()},[]),(0,x.useEffect)(()=>{M===`data`&&Z()},[M]),(0,S.jsxs)(`div`,{className:`p-8 max-w-5xl mx-auto space-y-8`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,S.jsx)(_,{className:`w-6 h-6 text-shogun-gold`}),`Backups & Data Management`]}),(0,S.jsx)(`p`,{className:`text-shogun-subdued mt-1`,children:`Protect your data with scheduled backups and manage your database.`})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(`button`,{onClick:()=>j(!A),className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-shogun-card border border-shogun-border text-shogun-subdued hover:text-shogun-text hover:border-shogun-blue transition-colors text-sm`,children:[(0,S.jsx)(c,{className:`w-4 h-4`}),`Settings`]}),(0,S.jsxs)(`button`,{onClick:re,disabled:w,className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-shogun-gold text-black font-semibold hover:bg-shogun-gold/80 transition-colors text-sm disabled:opacity-50`,children:[(0,S.jsx)(o,{className:`w-4 h-4 ${w?`animate-spin`:``}`}),w?`Creating...`:`Backup Now`]})]})]}),(0,S.jsx)(`div`,{className:`flex items-center gap-1 p-1 bg-shogun-card border border-shogun-border rounded-xl w-fit`,children:[{id:`backups`,label:`Scheduled Backups`,icon:a},{id:`data`,label:`Data Management`,icon:y}].map(e=>(0,S.jsxs)(`button`,{onClick:()=>N(e.id),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-xs font-semibold transition-all ${M===e.id?`bg-shogun-bg text-shogun-gold border border-shogun-border shadow-shogun`:`text-shogun-subdued hover:text-shogun-text`}`,children:[(0,S.jsx)(e.icon,{className:`w-3.5 h-3.5`}),e.label]},e.id))}),O&&(0,S.jsx)(`div`,{className:`rounded-xl p-4 border text-sm ${O.type===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-red-500/10 border-red-500/30 text-red-300`}`,children:O.text}),A&&g&&(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6 space-y-5`,children:[(0,S.jsx)(`h2`,{className:`text-sm font-bold text-shogun-gold uppercase tracking-wider`,children:`Backup Settings`}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Automatic Backups`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Automatically back up on a schedule.`})]}),(0,S.jsx)(`button`,{onClick:()=>X({enabled:!g.enabled}),className:`text-shogun-gold`,children:g.enabled?(0,S.jsx)(u,{className:`w-8 h-8`}):(0,S.jsx)(l,{className:`w-8 h-8 text-shogun-subdued`})})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Backup Interval`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`How often to create automatic backups.`})]}),(0,S.jsxs)(`select`,{value:g.interval_hours,onChange:e=>X({interval_hours:Number(e.target.value)}),className:`bg-shogun-bg border border-shogun-border rounded-lg px-3 py-1.5 text-sm text-white`,children:[(0,S.jsx)(`option`,{value:1,children:`Every hour`}),(0,S.jsx)(`option`,{value:6,children:`Every 6 hours`}),(0,S.jsx)(`option`,{value:12,children:`Every 12 hours`}),(0,S.jsx)(`option`,{value:24,children:`Every 24 hours`}),(0,S.jsx)(`option`,{value:48,children:`Every 2 days`}),(0,S.jsx)(`option`,{value:168,children:`Weekly`})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Backups to Keep`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Older backups beyond this limit are automatically deleted.`})]}),(0,S.jsx)(`select`,{value:g.max_backups,onChange:e=>X({max_backups:Number(e.target.value)}),className:`bg-shogun-bg border border-shogun-border rounded-lg px-3 py-1.5 text-sm text-white`,children:[1,2,3,5,7,10,15,20].map(e=>(0,S.jsxs)(`option`,{value:e,children:[e,` backups`]},e))})]}),(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:`Include Vector Memory`}),(0,S.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Include Qdrant data (significantly increases backup size).`})]}),(0,S.jsx)(`button`,{onClick:()=>X({include_vector_memory:!g.include_vector_memory}),className:`text-shogun-gold`,children:g.include_vector_memory?(0,S.jsx)(u,{className:`w-8 h-8`}):(0,S.jsx)(l,{className:`w-8 h-8 text-shogun-subdued`})})]})]}),M===`backups`&&(0,S.jsxs)(S.Fragment,{children:[g&&(0,S.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-4 text-center`,children:[(0,S.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:`Schedule`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-white`,children:g.enabled?`Every ${g.interval_hours}h`:`Disabled`})]}),(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-4 text-center`,children:[(0,S.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:`Total Backups`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-white`,children:e.length})]}),(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-4 text-center`,children:[(0,S.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:`Last Backup`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-white`,children:g.last_backup?new Date(g.last_backup).toLocaleDateString():`Never`})]})]}),(0,S.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl overflow-hidden`,children:[(0,S.jsx)(`div`,{className:`px-6 py-4 border-b border-shogun-border`,children:(0,S.jsx)(`h2`,{className:`text-sm font-bold text-white`,children:`Available Backups`})}),e.length===0?(0,S.jsxs)(`div`,{className:`p-8 text-center text-shogun-subdued`,children:[(0,S.jsx)(t,{className:`w-10 h-10 mx-auto mb-3 opacity-30`}),(0,S.jsx)(`p`,{children:`No backups yet.`}),(0,S.jsx)(`p`,{className:`text-[11px] mt-1`,children:`Create one manually or enable automatic backups.`})]}):(0,S.jsx)(`div`,{className:`divide-y divide-shogun-border/50`,children:e.map(e=>(0,S.jsxs)(`div`,{className:`px-6 py-4 flex items-center justify-between hover:bg-shogun-bg/50 transition-colors`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,S.jsx)(_,{className:`w-5 h-5 text-shogun-blue`}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e.filename}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-shogun-subdued mt-0.5`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,S.jsx)(a,{className:`w-3 h-3`}),new Date(e.created_at).toLocaleString()]}),(0,S.jsx)(`span`,{children:e.size_formatted})]})]})]}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsxs)(`button`,{onClick:()=>ae(e.filename),disabled:E===e.filename,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] bg-shogun-bg border border-shogun-border text-shogun-subdued hover:text-amber-400 hover:border-amber-400/50 transition-colors disabled:opacity-50`,children:[(0,S.jsx)(s,{className:`w-3 h-3 ${E===e.filename?`animate-spin`:``}`}),E===e.filename?`Restoring...`:`Restore`]}),(0,S.jsxs)(`button`,{onClick:()=>ie(e.filename),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] bg-shogun-bg border border-shogun-border text-shogun-subdued hover:text-red-400 hover:border-red-400/50 transition-colors`,children:[(0,S.jsx)(d,{className:`w-3 h-3`}),`Delete`]})]})]},e.filename))})]})]}),M===`data`&&(0,S.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-12 gap-8 animate-in slide-in-from-bottom-4`,children:[(0,S.jsxs)(`div`,{className:`lg:col-span-4 space-y-6`,children:[(0,S.jsxs)(`section`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-5`,children:[(0,S.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-4 flex items-center gap-2`,children:[(0,S.jsx)(v,{className:`w-3 h-3`}),` System Snapshot`]}),I?(0,S.jsxs)(`div`,{className:`flex items-center gap-3 py-6 text-shogun-subdued animate-pulse`,children:[(0,S.jsx)(te,{className:`w-4 h-4 animate-spin`}),(0,S.jsx)(`span`,{className:`text-xs uppercase font-bold tracking-widest`,children:`Scanning DB...`})]}):P?(0,S.jsxs)(`div`,{className:`space-y-4`,children:[P.tables&&Object.entries(P.tables).map(([e,t])=>(0,S.jsxs)(`div`,{className:`flex justify-between items-center bg-shogun-bg p-3 rounded-lg border border-shogun-border`,children:[(0,S.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold`,children:e.replace(/_/g,` `)}),(0,S.jsx)(`span`,{className:`text-sm font-bold text-shogun-text`,children:t})]},e)),(0,S.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border text-center`,children:[(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase font-bold`,children:`Total Rows`}),(0,S.jsx)(`p`,{className:`text-lg font-bold text-shogun-blue`,children:P.total_rows??`—`})]}),(0,S.jsxs)(`div`,{className:`text-center`,children:[(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase font-bold`,children:`Database Size`}),(0,S.jsxs)(`p`,{className:`text-2xl font-bold text-shogun-text`,children:[`~`,((P.db_size_bytes||0)/1024/1024).toFixed(2),` MB`]})]})]}):(0,S.jsx)(`div`,{className:`py-6 text-center italic text-shogun-subdued text-xs`,children:`Click "Refresh" to scan the database.`}),(0,S.jsx)(`button`,{onClick:Z,className:`w-full mt-4 py-2 border border-shogun-border rounded-lg text-[9px] font-bold uppercase tracking-widest hover:text-shogun-blue transition-colors`,children:`Refresh Snapshot`})]}),(0,S.jsxs)(`div`,{className:`bg-indigo-500/5 border border-indigo-500/20 rounded-xl p-5`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-indigo-400 mb-2`,children:[(0,S.jsx)(p,{className:`w-4 h-4`}),(0,S.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Why Export?`})]}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Your Shogun stores months of custom knowledge, trained skills, and secure identities. Exporting allows you to migrate your entire mind-state to a new server or recover from hardware failure.`})]})]}),(0,S.jsxs)(`div`,{className:`lg:col-span-8 space-y-6`,children:[(0,S.jsxs)(`section`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6 space-y-6`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text mb-1`,children:`Export Library`}),(0,S.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Pack your entire intelligence store into a portable ZIP bundle.`})]}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Target Backup Directory`}),(0,S.jsx)(`input`,{type:`text`,value:R,onChange:e=>ne(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-4 py-2.5 text-xs font-mono outline-none focus:border-shogun-blue text-white`})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,S.jsxs)(`button`,{onClick:()=>Q(`json`),disabled:I,className:`p-6 bg-shogun-bg border border-shogun-border rounded-2xl text-left hover:border-shogun-blue transition-all group disabled:opacity-50`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsx)(ee,{className:`w-6 h-6 text-shogun-blue`}),(0,S.jsx)(n,{className:`w-4 h-4 text-shogun-subdued group-hover:translate-x-1 transition-transform`})]}),(0,S.jsx)(`div`,{className:`font-bold text-shogun-text`,children:`Safe JSON Bundle`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Exports every table individually. Safest for moving between Shogun versions.`})]}),(0,S.jsxs)(`button`,{onClick:()=>Q(`raw`),disabled:I,className:`p-6 bg-shogun-bg border border-shogun-border rounded-2xl text-left hover:border-shogun-gold transition-all group disabled:opacity-50`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsx)(y,{className:`w-6 h-6 text-shogun-gold`}),(0,S.jsx)(n,{className:`w-4 h-4 text-shogun-subdued group-hover:translate-x-1 transition-transform`})]}),(0,S.jsx)(`div`,{className:`font-bold text-shogun-text`,children:`Raw Database Swap`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Copies the actual Shogun.db file directly. Fast, requires same version.`})]})]})]}),z&&(0,S.jsxs)(`div`,{className:`p-3 rounded-lg flex items-center gap-3 text-xs font-bold uppercase ${z.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`}`,children:[z.type===`success`?(0,S.jsx)(i,{className:`w-4 h-4`}):(0,S.jsx)(r,{className:`w-4 h-4`}),z.text]})]}),(0,S.jsxs)(`section`,{onClick:()=>!V&&q.current?.click(),onDragEnter:e=>{e.preventDefault(),V||W(!0)},onDragOver:e=>e.preventDefault(),onDragLeave:e=>{e.preventDefault(),e.currentTarget===e.target&&W(!1)},onDrop:e=>{e.preventDefault(),W(!1),$(e.dataTransfer.files?.[0])},className:`bg-shogun-card border border-dashed rounded-xl flex flex-col items-center justify-center p-12 text-center group transition-all ${V?`border-shogun-gold/50 cursor-wait`:U?`border-shogun-blue bg-shogun-blue/10 scale-[1.01] cursor-copy`:`border-shogun-border cursor-pointer hover:bg-shogun-blue/[0.02] hover:border-shogun-blue/40`}`,children:[(0,S.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-bg border border-shogun-border flex items-center justify-center mb-4 group-hover:scale-110 transition-transform`,children:V?(0,S.jsx)(m,{className:`w-8 h-8 text-shogun-gold animate-spin`}):(0,S.jsx)(f,{className:`w-8 h-8 text-shogun-subdued group-hover:text-shogun-blue transition-colors`})}),(0,S.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-1`,children:V?`Importing Shogun State...`:`Import Shogun State`}),(0,S.jsxs)(`p`,{className:`text-xs text-shogun-subdued max-w-sm`,children:[`Drag and drop a previously exported `,(0,S.jsx)(`strong`,{children:`.zip`}),` bundle here, or click to select it. Scheduled and Data Management backups are both supported.`]}),(0,S.jsx)(`input`,{ref:q,type:`file`,className:`hidden`,accept:`.zip,application/zip`,disabled:V,onChange:e=>void $(e.target.files?.[0])})]}),G&&(0,S.jsxs)(`div`,{className:`p-3 rounded-lg flex items-center gap-3 text-xs font-bold ${G.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`}`,children:[G.type===`success`?(0,S.jsx)(i,{className:`w-4 h-4 shrink-0`}):(0,S.jsx)(r,{className:`w-4 h-4 shrink-0`}),G.text]})]})]}),(0,S.jsxs)(`div`,{className:`text-[11px] text-shogun-subdued border-t border-shogun-border/30 pt-4 space-y-1`,children:[(0,S.jsx)(`p`,{children:`• Backups include: database, configs, governance documents, and environment settings.`}),(0,S.jsx)(`p`,{children:`• Vector memory (Qdrant) is excluded by default due to size — enable in settings if needed.`}),(0,S.jsx)(`p`,{children:`• After restoring a backup, restart Shogun for changes to take effect.`})]})]})};export{C as Backups}; \ No newline at end of file diff --git a/frontend/dist/assets/Bushido-CR5LxXYP.js b/frontend/dist/assets/Bushido-CR5LxXYP.js new file mode 100644 index 0000000..aa603ac --- /dev/null +++ b/frontend/dist/assets/Bushido-CR5LxXYP.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,t as n}from"./flame-ufgLzmP6.js";import{t as r}from"./brain-circuit-BYgtGbs2.js";import{t as i}from"./circle-alert-043xB2li.js";import{t as a}from"./circle-check-DBu5bzEI.js";import{t as o}from"./clock-DQ9Dz1_z.js";import{t as s}from"./compass-DSx4BIld.js";import{t as c}from"./refresh-cw-Dm6S5UAJ.js";import{t as l}from"./rotate-ccw-B4t0zm9t.js";import{t as u}from"./save-CupVJLfi.js";import{t as d}from"./settings-2-BXoo7RAn.js";import{t as f}from"./sparkles-DyLIKWW0.js";import{t as p}from"./target-BgDPVmAm.js";import{t as m}from"./trending-up-Coxuq0al.js";import{d as h,i as g,j as _,r as v,t as y,w as b}from"./index-Dy1E248t.js";import{t as x}from"./axios-BGmZl9Qd.js";var S=e(_(),1),C=y(),w=`/api/v1/bushido`,T={reflection_intensity:70,consolidation_rate:45,exploration_variance:24,heartbeat_frequency:15};function E(){let{t:e}=v(),[_,y]=(0,S.useState)(null),[E,D]=(0,S.useState)(T),[O,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)([]),[M,N]=(0,S.useState)(!1),[P,F]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),R=(0,S.useCallback)(async()=>{try{let e=await x.get(`${w}/stats`);y(e.data.data)}catch{}},[]),z=(0,S.useCallback)(async()=>{try{let e=await x.get(`${w}/calibration`);D(e.data.data),k(!1)}catch{}},[]),B=(0,S.useCallback)(async()=>{try{let e=((await x.get(`${w}/recommendations`)).data.data||[]).slice(0,8);j(e)}catch{}},[]);(0,S.useEffect)(()=>{R(),z(),B()},[R,z,B]),(0,S.useEffect)(()=>{let e=setInterval(R,15e3);return()=>clearInterval(e)},[R]);let V=async()=>{F(!0);try{await x.post(`${w}/run`,{job_type:`persona_drift_check`,trigger_mode:`manual`,priority:50,scope:{agent_ids:[],memory_types:[]}}),L({type:`success`,text:e(`bushido.reflection_initiated`)}),setTimeout(()=>{R(),B()},5e3)}catch{L({type:`error`,text:e(`bushido.reflection_failed`)})}finally{F(!1),setTimeout(()=>L(null),5e3)}},H=async()=>{N(!0);try{await x.put(`${w}/calibration`,E),k(!1),L({type:`success`,text:e(`bushido.calibration_saved`)})}catch{L({type:`error`,text:e(`bushido.calibration_save_failed`)})}finally{N(!1),setTimeout(()=>L(null),4e3)}},U=async()=>{try{let t=await x.post(`${w}/calibration/reset`);D({reflection_intensity:t.data.data.reflection_intensity,consolidation_rate:t.data.data.consolidation_rate,exploration_variance:t.data.data.exploration_variance,heartbeat_frequency:t.data.data.heartbeat_frequency}),k(!1),L({type:`success`,text:e(`bushido.calibration_reset`)})}catch{L({type:`error`,text:e(`bushido.calibration_reset_failed`)})}finally{setTimeout(()=>L(null),4e3)}},W=(e,t)=>{D(n=>({...n,[e]:t})),k(!0)},G=_?.engine_status===`synchronized`,K=(E.consolidation_rate/1e3).toFixed(2),q=(E.exploration_variance/100).toFixed(2),J={low:`bg-green-500`,medium:`bg-shogun-gold`,high:`bg-orange-500`,critical:`bg-red-500`},Y=e=>{let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`Just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`};return(0,C.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-6xl mx-auto pb-12`,children:[(0,C.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`bushido.title`),` `,(0,C.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:e(`bushido.badge`)})]}),(0,C.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`bushido.subtitle`)})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsxs)(`div`,{className:`px-4 py-2 bg-shogun-card border border-shogun-border rounded-lg flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:g(`w-2 h-2 rounded-full shadow-[0_0_8px_rgba(34,197,94,0.6)]`,G?`bg-green-500 animate-pulse`:`bg-orange-500 animate-pulse`)}),(0,C.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-text`,children:e(_?G?`bushido.engine_synchronized`:`bushido.engine_degraded`:`bushido.connecting`)})]}),(0,C.jsxs)(`button`,{onClick:V,disabled:P,className:`flex items-center gap-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun disabled:opacity-50`,children:[(0,C.jsx)(c,{className:g(`w-4 h-4`,P&&`animate-spin`)}),e(P?`bushido.reflecting`:`bushido.force_reflection`)]})]})]}),I&&(0,C.jsxs)(`div`,{className:g(`p-4 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,I.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[I.type===`success`?(0,C.jsx)(a,{className:`w-5 h-5`}):(0,C.jsx)(i,{className:`w-5 h-5`}),(0,C.jsx)(`span`,{className:`text-sm font-bold uppercase tracking-widest`,children:I.text})]}),(0,C.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-4 gap-6`,children:[{label:e(`bushido.avg_fit_quality`),value:_?`${_.fit_quality}%`:`—`,icon:p,color:`text-shogun-gold`},{label:e(`bushido.active_cycles`),value:_?_.active_cycles.toLocaleString():`—`,icon:b,color:`text-shogun-blue`},{label:e(`bushido.optimization_delta`),value:_?`+${_.optimization_delta}%`:`—`,icon:m,color:`text-green-500`},{label:e(`bushido.neural_load`),value:_?`${_.neural_load}%`:`—`,icon:r,color:_&&_.neural_load>75?`text-red-400`:`text-shogun-subdued`}].map((e,t)=>(0,C.jsxs)(`div`,{className:`shogun-card border-b-2 border-transparent hover:border-shogun-blue transition-all group`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,C.jsx)(e.icon,{className:g(`w-3.5 h-3.5`,e.color)}),(0,C.jsx)(`span`,{className:`text-[9px] uppercase font-bold tracking-widest text-shogun-subdued`,children:e.label})]}),(0,C.jsx)(`div`,{className:`text-2xl font-bold text-shogun-text group-hover:scale-105 transition-transform origin-left`,children:e.value})]},t))}),(0,C.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,C.jsx)(`div`,{className:`lg:col-span-2 space-y-6`,children:(0,C.jsxs)(`div`,{className:`shogun-card space-y-8`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,C.jsx)(d,{className:`w-5 h-5 text-shogun-blue`}),` `,e(`bushido.behavior_calibration`)]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O&&(0,C.jsx)(`span`,{className:`text-[9px] text-orange-400 bg-orange-500/10 px-2 py-0.5 rounded border border-orange-500/20 font-bold uppercase`,children:e(`bushido.unsaved`)}),(0,C.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-tighter italic`,children:`Behavioral Tuning v1.0`})]})]}),(0,C.jsxs)(`div`,{className:`space-y-10 py-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(n,{className:`w-3.5 h-3.5 text-orange-500`}),` `,e(`bushido.reflection_intensity`)]}),(0,C.jsxs)(`span`,{className:`text-xs font-mono text-shogun-blue`,children:[E.reflection_intensity,`%`]})]}),(0,C.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:E.reflection_intensity,onChange:e=>W(`reflection_intensity`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-shogun-blue`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.reflection_intensity_desc`)})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(t,{className:`w-3.5 h-3.5 text-shogun-gold`}),` `,e(`bushido.memory_consolidation_rate`)]}),(0,C.jsxs)(`span`,{className:`text-xs font-mono text-shogun-gold`,children:[K,` / `,e(`bushido.epoch`)]})]}),(0,C.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:E.consolidation_rate,onChange:e=>W(`consolidation_rate`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-shogun-gold`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.memory_consolidation_desc`)})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(s,{className:`w-3.5 h-3.5 text-green-500`}),` `,e(`bushido.exploration_variance`)]}),(0,C.jsx)(`span`,{className:`text-xs font-mono text-green-500`,children:q})]}),(0,C.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:E.exploration_variance,onChange:e=>W(`exploration_variance`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-green-500`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.exploration_variance_desc`)})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(o,{className:`w-3.5 h-3.5 text-purple-400`}),` `,e(`bushido.heartbeat_frequency`)]}),(0,C.jsxs)(`span`,{className:`text-xs font-mono text-purple-400`,children:[E.heartbeat_frequency,`m`]})]}),(0,C.jsx)(`input`,{type:`range`,min:`1`,max:`120`,value:E.heartbeat_frequency,onChange:e=>W(`heartbeat_frequency`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-purple-500`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.heartbeat_frequency_desc`)})]})]}),(0,C.jsxs)(`div`,{className:`pt-6 border-t border-shogun-border flex gap-4`,children:[(0,C.jsxs)(`button`,{onClick:U,className:`flex-1 py-3 bg-shogun-card border border-shogun-border rounded-xl text-xs font-bold uppercase tracking-widest hover:text-shogun-gold hover:border-shogun-gold transition-all flex items-center justify-center gap-2`,children:[(0,C.jsx)(l,{className:`w-3.5 h-3.5`}),` `,e(`bushido.reset_to_baseline`)]}),(0,C.jsxs)(`button`,{onClick:H,disabled:M||!O,className:`flex-1 py-3 bg-[#1e293b] border border-shogun-blue/30 rounded-xl text-xs font-bold uppercase tracking-widest text-shogun-text hover:bg-shogun-blue transition-all shadow-[0_0_15px_rgba(74,140,199,0.1)] disabled:opacity-50 flex items-center justify-center gap-2`,children:[(0,C.jsx)(u,{className:`w-3.5 h-3.5`}),` `,e(M?`bushido.saving`:`bushido.save_calibration`)]})]})]})}),(0,C.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[(0,C.jsxs)(`div`,{className:`shogun-card min-h-[300px]`,children:[(0,C.jsxs)(`h3`,{className:`text-sm font-bold flex items-center gap-2 text-shogun-gold mb-6 uppercase tracking-widest`,children:[(0,C.jsx)(f,{className:`w-4 h-4`}),` `,e(`bushido.insight_stream`),(0,C.jsx)(`span`,{className:`text-[9px] text-shogun-subdued bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border ml-auto`,children:A.length})]}),(0,C.jsxs)(`div`,{className:`space-y-6`,children:[A.length===0&&(0,C.jsx)(`div`,{className:`text-[10px] text-shogun-subdued text-center py-8`,children:e(`bushido.no_recommendations`)}),A.map(e=>(0,C.jsxs)(`div`,{className:`flex gap-4 group`,children:[(0,C.jsx)(`div`,{className:g(`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 group-hover:scale-150 transition-transform`,J[e.risk_level]||`bg-shogun-blue`)}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`text-[11px] text-shogun-text leading-relaxed`,children:e.title}),(0,C.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued block mt-1`,children:[e.description.slice(0,120),`...`]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,C.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase px-1 py-0.5 rounded`,e.risk_level===`high`?`text-orange-400 bg-orange-500/10`:e.risk_level===`critical`?`text-red-400 bg-red-500/10`:e.risk_level===`medium`?`text-shogun-gold bg-shogun-gold/10`:`text-green-400 bg-green-500/10`),children:e.risk_level}),(0,C.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase`,children:e.created_at?Y(e.created_at):``})]})]})]},e.id))]})]}),(0,C.jsxs)(`div`,{className:`shogun-card bg-shogun-blue/5 border-shogun-blue/20`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 text-shogun-blue`,children:[(0,C.jsx)(h,{className:`w-4 h-4`}),(0,C.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:e(`bushido.formal_verification`)})]}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:e(`bushido.formal_verification_desc`)})]})]})]})]})}export{E as Bushido}; \ No newline at end of file diff --git a/frontend/dist/assets/Bushido-Dp8EOCjA.js b/frontend/dist/assets/Bushido-Dp8EOCjA.js deleted file mode 100644 index 5bf172b..0000000 --- a/frontend/dist/assets/Bushido-Dp8EOCjA.js +++ /dev/null @@ -1 +0,0 @@ -import{o as e,r as t,t as n}from"./jsx-runtime-DmifIpYY.js";import{t as r}from"./activity-D6ZKsL_W.js";import{n as i,t as a}from"./flame-CTTn1GjH.js";import{t as o}from"./brain-circuit-DqQf8Qkj.js";import{t as s}from"./circle-alert-DVHRBFRQ.js";import{t as c}from"./circle-check-D9mntLsp.js";import{t as l}from"./clock-B8iyCT3M.js";import{t as u}from"./compass-CbaQ9b1l.js";import{t as d}from"./refresh-cw-CCrS0Omg.js";import{t as f}from"./rotate-ccw-DsOLVoka.js";import{t as p}from"./save-CJWuwqGS.js";import{t as m}from"./settings-2-BKwYyfoW.js";import{t as h}from"./shield-check-4WxAMs16.js";import{t as g}from"./sparkles-DddBjN-5.js";import{t as _}from"./target-DVSHvQpc.js";import{t as v}from"./trending-up-CM0DQ6z2.js";import{t as y}from"./utils-wrb6h48Y.js";import{r as b}from"./i18n-FxgwkwP0.js";import{t as x}from"./axios-BPyV2soB.js";var S=e(t(),1),C=n(),w=`/api/v1/bushido`,T={reflection_intensity:70,consolidation_rate:45,exploration_variance:24,heartbeat_frequency:15};function E(){let{t:e}=b(),[t,n]=(0,S.useState)(null),[E,D]=(0,S.useState)(T),[O,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)([]),[M,N]=(0,S.useState)(!1),[P,F]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),R=(0,S.useCallback)(async()=>{try{n((await x.get(`${w}/stats`)).data.data)}catch{}},[]),z=(0,S.useCallback)(async()=>{try{D((await x.get(`${w}/calibration`)).data.data),k(!1)}catch{}},[]),B=(0,S.useCallback)(async()=>{try{j(((await x.get(`${w}/recommendations`)).data.data||[]).slice(0,8))}catch{}},[]);(0,S.useEffect)(()=>{R(),z(),B()},[R,z,B]),(0,S.useEffect)(()=>{let e=setInterval(R,15e3);return()=>clearInterval(e)},[R]);let V=async()=>{F(!0);try{await x.post(`${w}/run`,{job_type:`persona_drift_check`,trigger_mode:`manual`,priority:50,scope:{agent_ids:[],memory_types:[]}}),L({type:`success`,text:e(`bushido.reflection_initiated`)}),setTimeout(()=>{R(),B()},5e3)}catch{L({type:`error`,text:e(`bushido.reflection_failed`)})}finally{F(!1),setTimeout(()=>L(null),5e3)}},H=async()=>{N(!0);try{await x.put(`${w}/calibration`,E),k(!1),L({type:`success`,text:e(`bushido.calibration_saved`)})}catch{L({type:`error`,text:e(`bushido.calibration_save_failed`)})}finally{N(!1),setTimeout(()=>L(null),4e3)}},U=async()=>{try{let t=await x.post(`${w}/calibration/reset`);D({reflection_intensity:t.data.data.reflection_intensity,consolidation_rate:t.data.data.consolidation_rate,exploration_variance:t.data.data.exploration_variance,heartbeat_frequency:t.data.data.heartbeat_frequency}),k(!1),L({type:`success`,text:e(`bushido.calibration_reset`)})}catch{L({type:`error`,text:e(`bushido.calibration_reset_failed`)})}finally{setTimeout(()=>L(null),4e3)}},W=(e,t)=>{D(n=>({...n,[e]:t})),k(!0)},G=t?.engine_status===`synchronized`,K=(E.consolidation_rate/1e3).toFixed(2),q=(E.exploration_variance/100).toFixed(2),J={low:`bg-green-500`,medium:`bg-shogun-gold`,high:`bg-orange-500`,critical:`bg-red-500`},Y=e=>{let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`Just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`};return(0,C.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-6xl mx-auto pb-12`,children:[(0,C.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`bushido.title`),` `,(0,C.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:e(`bushido.badge`)})]}),(0,C.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`bushido.subtitle`)})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsxs)(`div`,{className:`px-4 py-2 bg-shogun-card border border-shogun-border rounded-lg flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:y(`w-2 h-2 rounded-full shadow-[0_0_8px_rgba(34,197,94,0.6)]`,G?`bg-green-500 animate-pulse`:`bg-orange-500 animate-pulse`)}),(0,C.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-text`,children:e(t?G?`bushido.engine_synchronized`:`bushido.engine_degraded`:`bushido.connecting`)})]}),(0,C.jsxs)(`button`,{onClick:V,disabled:P,className:`flex items-center gap-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun disabled:opacity-50`,children:[(0,C.jsx)(d,{className:y(`w-4 h-4`,P&&`animate-spin`)}),e(P?`bushido.reflecting`:`bushido.force_reflection`)]})]})]}),I&&(0,C.jsxs)(`div`,{className:y(`p-4 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,I.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[I.type===`success`?(0,C.jsx)(c,{className:`w-5 h-5`}):(0,C.jsx)(s,{className:`w-5 h-5`}),(0,C.jsx)(`span`,{className:`text-sm font-bold uppercase tracking-widest`,children:I.text})]}),(0,C.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-4 gap-6`,children:[{label:e(`bushido.avg_fit_quality`),value:t?`${t.fit_quality}%`:`—`,icon:_,color:`text-shogun-gold`},{label:e(`bushido.active_cycles`),value:t?t.active_cycles.toLocaleString():`—`,icon:r,color:`text-shogun-blue`},{label:e(`bushido.optimization_delta`),value:t?`+${t.optimization_delta}%`:`—`,icon:v,color:`text-green-500`},{label:e(`bushido.neural_load`),value:t?`${t.neural_load}%`:`—`,icon:o,color:t&&t.neural_load>75?`text-red-400`:`text-shogun-subdued`}].map((e,t)=>(0,C.jsxs)(`div`,{className:`shogun-card border-b-2 border-transparent hover:border-shogun-blue transition-all group`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,C.jsx)(e.icon,{className:y(`w-3.5 h-3.5`,e.color)}),(0,C.jsx)(`span`,{className:`text-[9px] uppercase font-bold tracking-widest text-shogun-subdued`,children:e.label})]}),(0,C.jsx)(`div`,{className:`text-2xl font-bold text-shogun-text group-hover:scale-105 transition-transform origin-left`,children:e.value})]},t))}),(0,C.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,C.jsx)(`div`,{className:`lg:col-span-2 space-y-6`,children:(0,C.jsxs)(`div`,{className:`shogun-card space-y-8`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,C.jsx)(m,{className:`w-5 h-5 text-shogun-blue`}),` `,e(`bushido.behavior_calibration`)]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O&&(0,C.jsx)(`span`,{className:`text-[9px] text-orange-400 bg-orange-500/10 px-2 py-0.5 rounded border border-orange-500/20 font-bold uppercase`,children:e(`bushido.unsaved`)}),(0,C.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-tighter italic`,children:`Behavioral Tuning v1.0`})]})]}),(0,C.jsxs)(`div`,{className:`space-y-10 py-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(a,{className:`w-3.5 h-3.5 text-orange-500`}),` `,e(`bushido.reflection_intensity`)]}),(0,C.jsxs)(`span`,{className:`text-xs font-mono text-shogun-blue`,children:[E.reflection_intensity,`%`]})]}),(0,C.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:E.reflection_intensity,onChange:e=>W(`reflection_intensity`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-shogun-blue`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.reflection_intensity_desc`)})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(i,{className:`w-3.5 h-3.5 text-shogun-gold`}),` `,e(`bushido.memory_consolidation_rate`)]}),(0,C.jsxs)(`span`,{className:`text-xs font-mono text-shogun-gold`,children:[K,` / `,e(`bushido.epoch`)]})]}),(0,C.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:E.consolidation_rate,onChange:e=>W(`consolidation_rate`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-shogun-gold`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.memory_consolidation_desc`)})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(u,{className:`w-3.5 h-3.5 text-green-500`}),` `,e(`bushido.exploration_variance`)]}),(0,C.jsx)(`span`,{className:`text-xs font-mono text-green-500`,children:q})]}),(0,C.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:E.exploration_variance,onChange:e=>W(`exploration_variance`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-green-500`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.exploration_variance_desc`)})]}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,C.jsxs)(`label`,{className:`text-xs font-bold text-shogun-text flex items-center gap-2 uppercase tracking-wide`,children:[(0,C.jsx)(l,{className:`w-3.5 h-3.5 text-purple-400`}),` `,e(`bushido.heartbeat_frequency`)]}),(0,C.jsxs)(`span`,{className:`text-xs font-mono text-purple-400`,children:[E.heartbeat_frequency,`m`]})]}),(0,C.jsx)(`input`,{type:`range`,min:`1`,max:`120`,value:E.heartbeat_frequency,onChange:e=>W(`heartbeat_frequency`,parseInt(e.target.value)),className:`w-full h-1.5 bg-shogun-card rounded-lg appearance-none cursor-pointer accent-purple-500`}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:e(`bushido.heartbeat_frequency_desc`)})]})]}),(0,C.jsxs)(`div`,{className:`pt-6 border-t border-shogun-border flex gap-4`,children:[(0,C.jsxs)(`button`,{onClick:U,className:`flex-1 py-3 bg-shogun-card border border-shogun-border rounded-xl text-xs font-bold uppercase tracking-widest hover:text-shogun-gold hover:border-shogun-gold transition-all flex items-center justify-center gap-2`,children:[(0,C.jsx)(f,{className:`w-3.5 h-3.5`}),` `,e(`bushido.reset_to_baseline`)]}),(0,C.jsxs)(`button`,{onClick:H,disabled:M||!O,className:`flex-1 py-3 bg-[#1e293b] border border-shogun-blue/30 rounded-xl text-xs font-bold uppercase tracking-widest text-shogun-text hover:bg-shogun-blue transition-all shadow-[0_0_15px_rgba(74,140,199,0.1)] disabled:opacity-50 flex items-center justify-center gap-2`,children:[(0,C.jsx)(p,{className:`w-3.5 h-3.5`}),` `,e(M?`bushido.saving`:`bushido.save_calibration`)]})]})]})}),(0,C.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[(0,C.jsxs)(`div`,{className:`shogun-card min-h-[300px]`,children:[(0,C.jsxs)(`h3`,{className:`text-sm font-bold flex items-center gap-2 text-shogun-gold mb-6 uppercase tracking-widest`,children:[(0,C.jsx)(g,{className:`w-4 h-4`}),` `,e(`bushido.insight_stream`),(0,C.jsx)(`span`,{className:`text-[9px] text-shogun-subdued bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border ml-auto`,children:A.length})]}),(0,C.jsxs)(`div`,{className:`space-y-6`,children:[A.length===0&&(0,C.jsx)(`div`,{className:`text-[10px] text-shogun-subdued text-center py-8`,children:e(`bushido.no_recommendations`)}),A.map(e=>(0,C.jsxs)(`div`,{className:`flex gap-4 group`,children:[(0,C.jsx)(`div`,{className:y(`w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 group-hover:scale-150 transition-transform`,J[e.risk_level]||`bg-shogun-blue`)}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`p`,{className:`text-[11px] text-shogun-text leading-relaxed`,children:e.title}),(0,C.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued block mt-1`,children:[e.description.slice(0,120),`...`]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,C.jsx)(`span`,{className:y(`text-[8px] font-bold uppercase px-1 py-0.5 rounded`,e.risk_level===`high`?`text-orange-400 bg-orange-500/10`:e.risk_level===`critical`?`text-red-400 bg-red-500/10`:e.risk_level===`medium`?`text-shogun-gold bg-shogun-gold/10`:`text-green-400 bg-green-500/10`),children:e.risk_level}),(0,C.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase`,children:e.created_at?Y(e.created_at):``})]})]})]},e.id))]})]}),(0,C.jsxs)(`div`,{className:`shogun-card bg-shogun-blue/5 border-shogun-blue/20`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3 mb-3 text-shogun-blue`,children:[(0,C.jsx)(h,{className:`w-4 h-4`}),(0,C.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:e(`bushido.formal_verification`)})]}),(0,C.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:e(`bushido.formal_verification_desc`)})]})]})]})]})}export{E as Bushido}; \ No newline at end of file diff --git a/frontend/dist/assets/Chat-BckkmBos.js b/frontend/dist/assets/Chat-BckkmBos.js deleted file mode 100644 index c10a1cd..0000000 --- a/frontend/dist/assets/Chat-BckkmBos.js +++ /dev/null @@ -1,41 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{s as i}from"./chunk-OE4NN4TA-BT-WiWAe.js";import{t as a}from"./archive-CCh8OMBK.js";import{t as o}from"./bot-DWzLMxmu.js";import{t as s}from"./calendar-DL2fCMC-.js";import{t as c}from"./camera-DjFKI4Th.js";import{t as l}from"./check-CBVCj3hp.js";import{t as u}from"./chevron-down-ZviArC66.js";import{t as d}from"./chevron-left-BFAWv4As.js";import{t as f}from"./chevron-right-BzAY5P9l.js";import{t as p}from"./chevron-up-NHCFdinU.js";import{t as m}from"./circle-alert-DVHRBFRQ.js";import{t as h}from"./circle-x-dN_LIrKM.js";import{t as ee}from"./clock-B8iyCT3M.js";import{t as te}from"./download-OoiqiOHD.js";import{t as g}from"./file-code-tXp5GKlr.js";import{t as _}from"./file-spreadsheet-CsZ2n5Og.js";import{t as v}from"./file-text-Db8l8y7y.js";import{t as y}from"./folder-open-C_e4r6rd.js";import{n as b,t as x}from"./image-yFh82dFc.js";import{t as S}from"./globe-CSe1LLSr.js";import{t as C}from"./hard-drive-CKvWVafA.js";import{t as w}from"./history-odxnpvgx.js";import{t as T}from"./keyboard-Cb4Fcm9X.js";import{t as E}from"./mail-CjEwmRbK.js";import{t as D}from"./message-square-D4G-UYnF.js";import{t as O}from"./monitor-DhSxAiCm.js";import{t as k}from"./mouse-pointer-2-BrcQlceQ.js";import{t as A}from"./pen-line-DT8VhOwz.js";import{t as j}from"./pin-BLXugO8S.js";import{t as M}from"./plus-DFW_DMbT.js";import{t as N}from"./refresh-cw-CCrS0Omg.js";import{t as ne}from"./save-CJWuwqGS.js";import{t as re}from"./search-CCF8DUSp.js";import{t as P}from"./send-D9KRspSg.js";import{t as F}from"./settings-DYFQa-lL.js";import{t as ie}from"./shield-alert-ClN8pu2X.js";import{t as I}from"./shield-B_MY4jWU.js";import{t as L}from"./sparkles-DddBjN-5.js";import{t as R}from"./target-DVSHvQpc.js";import{t as z}from"./terminal-CmBetb-2.js";import{t as ae}from"./trash-2-Cid5DKqF.js";import{t as B}from"./triangle-alert-BwzZbklP.js";import{t as V}from"./upload-D8ecl32P.js";import{t as H}from"./user-Dr0R8XdF.js";import{t as oe}from"./x-Bu7rztmN.js";import{t as U}from"./zap-BMpqZS6N.js";import{t as W}from"./utils-wrb6h48Y.js";import{r as G}from"./i18n-FxgwkwP0.js";import{t as K}from"./axios-BPyV2soB.js";var q=e(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),J=e(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),Y=e(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),se=e(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),ce=e(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`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`}]]),X=e(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),Z=e(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),le=e(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Q=t(n(),1),$=r(),ue=()=>{let e=i(),[t,n]=(0,Q.useState)(null),[r,o]=(0,Q.useState)(!0),[s,c]=(0,Q.useState)([]),[l,u]=(0,Q.useState)(`INBOX`),[p,h]=(0,Q.useState)([]),[ee,te]=(0,Q.useState)(0),[g,_]=(0,Q.useState)(1),[v,y]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),[T,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(``),[F,I]=(0,Q.useState)(``),[L,R]=(0,Q.useState)(``),[z,B]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)(``),[U,G]=(0,Q.useState)(``),q=async()=>{try{n((await K.get(`/api/v1/channels/email/account`)).data.data)}catch{n(null)}finally{o(!1)}};(0,Q.useEffect)(()=>{q()},[]),(0,Q.useEffect)(()=>{t?.is_active&&t.perm_read_mail&&J()},[t]),(0,Q.useEffect)(()=>{t?.is_active&&t.perm_read_mail&&Y()},[t,l,g]);let J=async()=>{try{c((await K.get(`/api/v1/channels/email/account/folders`)).data.data||[])}catch(e){console.error(`Failed to fetch folders`,e)}},Y=async()=>{y(!0);try{let e=await K.get(`/api/v1/channels/email/account/messages`,{params:{folder:l,page:g,per_page:15}});h(e.data.data.messages||[]),te(e.data.data.total||0)}catch(e){console.error(`Failed to fetch messages`,e)}finally{y(!1)}},se=async e=>{w(!0);try{S((await K.get(`/api/v1/channels/email/account/messages/${e}`,{params:{folder:l}})).data.data),h(t=>t.map(t=>t.uid===e?{...t,is_read:!0}:t))}catch(e){console.error(`Failed to load message body`,e)}finally{w(!1)}},X=async(e,t)=>{t.stopPropagation();try{await K.post(`/api/v1/channels/email/account/messages/${e}/unread`,null,{params:{folder:l}}),h(t=>t.map(t=>t.uid===e?{...t,is_read:!1}:t)),x?.uid===e&&S(e=>e?{...e,is_read:!1}:null)}catch(e){console.error(`Failed to mark unread`,e)}},Z=async(e,n)=>{if(n&&n.stopPropagation(),t?.perm_delete_mail)try{await K.delete(`/api/v1/channels/email/account/messages/${e}`,{params:{folder:l}}),x?.uid===e&&S(null),Y()}catch(e){console.error(`Failed to delete message`,e)}},ue=async e=>{if(e.preventDefault(),t?.perm_send_mail){B(!0),H(``),G(``);try{await K.post(`/api/v1/channels/email/account/send`,{to_address:O,cc_address:A,bcc_address:ne,subject:F,body:L}),G(`Email sent successfully!`),k(``),j(``),re(``),I(``),R(``),await J(),await Y(),setTimeout(()=>{D(!1),G(``)},1500)}catch(e){H(e.response?.data?.detail||`Failed to send email.`)}finally{B(!1)}}},de=e=>{let t=e.toLowerCase();return t===`inbox`?(0,$.jsx)(ce,{className:`w-4 h-4`}):t.includes(`trash`)||t.includes(`bin`)?(0,$.jsx)(le,{className:`w-4 h-4`}):t.includes(`archive`)?(0,$.jsx)(a,{className:`w-4 h-4`}):t.includes(`sent`)?(0,$.jsx)(P,{className:`w-4 h-4`}):(0,$.jsx)(b,{className:`w-4 h-4`})},fe=Math.ceil(ee/15);return r?(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-4`,children:[(0,$.jsx)(N,{className:`w-8 h-8 animate-spin text-shogun-blue`}),(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:`Synchronizing Mail Client…`})]}):!t||!t.is_active?(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,$.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-blue/10 flex items-center justify-center text-shogun-blue border border-shogun-blue/30 mb-4 animate-pulse`,children:(0,$.jsx)(E,{className:`w-8 h-8`})}),(0,$.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`No Mail Account Connected`}),(0,$.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed mb-6`,children:`To receive, compose, and organize mail, configure your provider in the Katana settings.`}),(0,$.jsx)(`button`,{onClick:()=>{e(`/katana`)},className:`px-5 py-2.5 bg-shogun-blue hover:bg-shogun-blue/90 text-white text-xs font-bold rounded-lg uppercase tracking-wider transition-all`,children:`Go to Katana Settings`})]}):t.perm_read_mail?(0,$.jsxs)(`div`,{className:`h-[calc(100vh-270px)] flex flex-col min-h-0 bg-[#050508]/30 rounded-2xl border border-shogun-border/40 overflow-hidden backdrop-blur-md`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center px-6 py-4 bg-[#0a0a0f]/60 border-b border-shogun-border/40 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`px-2.5 py-1 rounded bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue text-[10px] font-bold uppercase`,children:t.provider}),(0,$.jsx)(`span`,{className:`text-xs text-shogun-subdued font-medium`,children:t.email_address})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>{J(),Y()},className:`p-2 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 text-shogun-subdued hover:text-shogun-text rounded-lg transition-all`,title:`Refresh mail`,children:(0,$.jsx)(N,{className:W(`w-4 h-4`,v&&`animate-spin`)})}),t.perm_send_mail&&(0,$.jsxs)(`button`,{onClick:()=>D(!0),className:`flex items-center gap-1.5 px-4 py-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all`,children:[(0,$.jsx)(M,{className:`w-4 h-4`}),` Compose`]})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 flex min-h-0 divide-x divide-shogun-border/30`,children:[(0,$.jsxs)(`div`,{className:`w-48 bg-[#0a0a0f]/30 p-4 space-y-1.5 overflow-y-auto shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block px-2 mb-2`,children:`Folders`}),s.length===0?(0,$.jsx)(`div`,{className:`text-[11px] text-shogun-subdued italic px-2`,children:`No folders loaded.`}):s.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{u(e),_(1),S(null)},className:W(`w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-xs font-medium transition-all text-left`,l===e?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20`:`text-shogun-subdued hover:text-shogun-text hover:bg-shogun-card/40`),children:[de(e),(0,$.jsx)(`span`,{className:`truncate`,children:e})]},e))]}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-[#07070a]/40 divide-y divide-shogun-border/30`,children:[(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:v?(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-3 opacity-55`,children:[(0,$.jsx)(N,{className:`w-6 h-6 animate-spin text-shogun-blue`}),(0,$.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider`,children:`Fetching messages…`})]}):p.length===0?(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-2 opacity-50 p-6 text-center`,children:[(0,$.jsx)(E,{className:`w-10 h-10`}),(0,$.jsxs)(`p`,{className:`text-xs italic`,children:[`Folder `,l,` is empty.`]})]}):(0,$.jsx)(`div`,{className:`divide-y divide-shogun-border/25`,children:p.map(e=>(0,$.jsxs)(`div`,{onClick:()=>se(e.uid),className:W(`p-4 cursor-pointer hover:bg-shogun-card/30 transition-all border-l-2 flex flex-col gap-1.5 relative`,x?.uid===e.uid?`bg-shogun-blue/5 border-l-shogun-blue`:e.is_read?`border-l-transparent`:`border-l-shogun-gold bg-shogun-gold/[0.02]`),children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,$.jsx)(`span`,{className:W(`text-xs truncate max-w-[70%]`,e.is_read?`text-shogun-text/80 font-medium`:`text-shogun-gold font-bold`),children:e.from_address}),(0,$.jsx)(`span`,{className:`text-[10px] text-shogun-subdued shrink-0 font-mono`,children:e.date.split(`,`)[1]?.trim()?.slice(0,11)||e.date})]}),(0,$.jsx)(`p`,{className:W(`text-xs truncate`,e.is_read?`text-shogun-text/90`:`text-shogun-text font-bold`),children:e.subject||`(No Subject)`}),(0,$.jsx)(`p`,{className:`text-[10px] text-shogun-subdued truncate max-w-full leading-normal`,children:e.body_preview||`No preview available`})]},e.uid))})}),fe>1&&(0,$.jsxs)(`div`,{className:`flex justify-between items-center px-4 py-3 bg-[#0a0a0f]/60 shrink-0 border-t border-shogun-border/30`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued font-bold`,children:[`Page `,g,` of `,fe,` (`,ee,` messages)`]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{disabled:g<=1,onClick:()=>_(g-1),className:`p-1 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 rounded disabled:opacity-40 disabled:hover:bg-shogun-card transition-all`,children:(0,$.jsx)(d,{className:`w-4 h-4 text-shogun-text`})}),(0,$.jsx)(`button`,{disabled:g>=fe,onClick:()=>_(g+1),className:`p-1 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 rounded disabled:opacity-40 disabled:hover:bg-shogun-card transition-all`,children:(0,$.jsx)(f,{className:`w-4 h-4 text-shogun-text`})})]})]})]}),(0,$.jsx)(`div`,{className:`w-1/2 flex flex-col min-w-0 bg-[#050508]/40 overflow-hidden`,children:C?(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-shogun-subdued space-y-4`,children:[(0,$.jsx)(N,{className:`w-7 h-7 animate-spin text-shogun-gold`}),(0,$.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider font-bold`,children:`Loading full message payload…`})]}):x?(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,$.jsxs)(`div`,{className:`p-5 border-b border-shogun-border/30 bg-[#0a0a0f]/40 space-y-3 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text leading-snug`,children:x.subject||`(No Subject)`}),(0,$.jsxs)(`div`,{className:`flex gap-1.5 shrink-0`,children:[(0,$.jsx)(`button`,{onClick:e=>X(x.uid,e),className:`px-2 py-1 text-[10px] font-bold border border-shogun-border text-shogun-subdued hover:text-shogun-text rounded hover:bg-shogun-card/40 transition-all`,children:`Mark Unread`}),t.perm_delete_mail&&(0,$.jsx)(`button`,{onClick:()=>Z(x.uid),className:`p-1 border border-red-500/20 text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded transition-all`,title:`Delete Email`,children:(0,$.jsx)(ae,{className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`text-shogun-subdued font-semibold w-10 shrink-0`,children:`From:`}),(0,$.jsx)(`span`,{className:`text-shogun-text font-mono truncate`,children:x.from_address})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`text-shogun-subdued font-semibold w-10 shrink-0`,children:`To:`}),(0,$.jsx)(`span`,{className:`text-shogun-text font-mono truncate`,children:x.to_address})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`text-shogun-subdued font-semibold w-10 shrink-0`,children:`Date:`}),(0,$.jsx)(`span`,{className:`text-shogun-subdued font-mono truncate`,children:x.date})]})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 p-5 overflow-y-auto min-h-0 bg-[#030305]/80 space-y-4`,children:[x.body_html?(0,$.jsx)(`div`,{className:`w-full h-full min-h-[300px] border border-shogun-border/20 rounded-xl overflow-hidden bg-white/5`,children:(0,$.jsx)(`iframe`,{title:`email-body`,sandbox:`allow-popups allow-popups-to-escape-sandbox`,srcDoc:` - - - - - - ${x.body_html} - - - `,className:`w-full h-full border-none`})}):(0,$.jsx)(`div`,{className:`text-xs text-shogun-text font-mono whitespace-pre-wrap leading-relaxed bg-[#0a0a0f]/80 p-4 border border-shogun-border/20 rounded-xl`,children:x.body_text||`(Empty body)`}),x.attachments&&x.attachments.length>0&&(0,$.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/30 space-y-2`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:`Attachments`}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:x.attachments.map(e=>(0,$.jsx)(`div`,{className:`p-3 rounded-lg border border-shogun-border/20 bg-shogun-card flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs text-shogun-text truncate font-medium`,children:e.filename}),(0,$.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[e.content_type,` · `,(e.size/1024).toFixed(1),` KB`]})]})},e.filename))})]})]})]}):(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-shogun-subdued space-y-2 opacity-50 p-6 text-center`,children:[(0,$.jsx)(E,{className:`w-12 h-12`}),(0,$.jsx)(`p`,{className:`text-xs italic`,children:`Select an email to view details.`})]})})]}),T&&(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-md`,onClick:()=>{z||D(!1)}}),(0,$.jsxs)(`div`,{className:`relative w-full max-w-lg bg-[#09090e] border border-shogun-border rounded-2xl flex flex-col shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center px-5 py-3 border-b border-shogun-border/30 bg-[#0a0a0f]/40`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest flex items-center gap-2`,children:[(0,$.jsx)(P,{className:`w-4 h-4 text-shogun-blue`}),`Compose Directive`]}),(0,$.jsx)(`button`,{disabled:z,onClick:()=>D(!1),className:`p-1 text-shogun-subdued hover:text-shogun-text transition-colors disabled:opacity-40`,children:(0,$.jsx)(oe,{className:`w-5 h-5`})})]}),(0,$.jsxs)(`form`,{onSubmit:ue,className:`p-4 flex-1 flex flex-col gap-3 overflow-y-auto max-h-[55vh]`,children:[V&&(0,$.jsxs)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/20 text-red-500 rounded-lg text-xs font-semibold flex items-center gap-2`,children:[(0,$.jsx)(m,{className:`w-4 h-4 shrink-0`}),(0,$.jsx)(`span`,{children:V})]}),U&&(0,$.jsxs)(`div`,{className:`p-3 bg-green-500/10 border border-green-500/20 text-green-500 rounded-lg text-xs font-semibold flex items-center gap-2`,children:[(0,$.jsx)(m,{className:`w-4 h-4 shrink-0`}),(0,$.jsx)(`span`,{children:U})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`To *`}),(0,$.jsx)(`input`,{type:`email`,required:!0,placeholder:`recipient@domain.com`,value:O,onChange:e=>k(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Cc`}),(0,$.jsx)(`input`,{type:`text`,placeholder:`cc@domain.com, cc2@domain.com`,value:A,onChange:e=>j(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Bcc`}),(0,$.jsx)(`input`,{type:`text`,placeholder:`bcc@domain.com`,value:ne,onChange:e=>re(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Subject *`}),(0,$.jsx)(`input`,{type:`text`,required:!0,placeholder:`Enter subject title`,value:F,onChange:e=>I(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Body *`}),(0,$.jsx)(`textarea`,{required:!0,rows:4,placeholder:`Write message contents...`,value:L,onChange:e=>R(e.target.value),className:`w-full flex-1 min-h-[80px] bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono resize-y`})]}),(0,$.jsx)(`button`,{type:`submit`,disabled:z||!O||!F||!L,className:`w-full flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm uppercase tracking-wider transition-all mt-2`,children:z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{className:`w-4 h-4 animate-spin`}),` Transmitting Directive…`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(P,{className:`w-4 h-4`}),` Transmit Email`]})})]})]})]})]}):(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,$.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-400/10 flex items-center justify-center text-red-400 border border-red-400/30 mb-4`,children:(0,$.jsx)(ie,{className:`w-8 h-8`})}),(0,$.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`Read Permission Denied`}),(0,$.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed`,children:`The "Read Mail" permission is disabled for this account in Katana settings. Toggle this permission ON to view your inbox.`})]})},de=()=>{let e=i(),[t,n]=(0,Q.useState)(null),[r,a]=(0,Q.useState)(!0),[o,c]=(0,Q.useState)(new Date),[l,u]=(0,Q.useState)(`month`),[p,h]=(0,Q.useState)([]),[te,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(`create`),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(``),[k,j]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(``),[P,I]=(0,Q.useState)(``),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)(``),U=async()=>{try{n((await K.get(`/api/v1/channels/email/account`)).data.data)}catch{n(null)}finally{a(!1)}};(0,Q.useEffect)(()=>{U()},[]);let G=()=>{let e=new Date(o),t=new Date(o);if(l===`month`){e.setDate(1);let n=e.getDay();e.setDate(e.getDate()-n),e.setHours(0,0,0,0),t.setMonth(t.getMonth()+1),t.setDate(0);let r=6-t.getDay();t.setDate(t.getDate()+r),t.setHours(23,59,59,999)}else if(l===`week`){let n=e.getDay();e.setDate(e.getDate()-n),e.setHours(0,0,0,0),t.setDate(e.getDate()+6),t.setHours(23,59,59,999)}else e.setHours(0,0,0,0),t.setHours(23,59,59,999);return{start:e,end:t}},q=async()=>{if(!t?.is_active||!t.perm_read_calendar||t.calendar_provider===`none`)return;g(!0),v(``);let{start:e,end:n}=G();try{h((await K.get(`/api/v1/channels/calendar/events`,{params:{start:e.toISOString(),end:n.toISOString()}})).data.data||[])}catch(e){console.error(`Failed to fetch events`,e),v(e.response?.data?.detail||`Failed to sync calendar events.`)}finally{g(!1)}};(0,Q.useEffect)(()=>{t?.is_active&&t.perm_read_calendar&&q()},[t,o,l]);let J=()=>{let e=new Date(o);l===`month`?e.setMonth(e.getMonth()-1):l===`week`?e.setDate(e.getDate()-7):e.setDate(e.getDate()-1),c(e)},Y=()=>{let e=new Date(o);l===`month`?e.setMonth(e.getMonth()+1):l===`week`?e.setDate(e.getDate()+7):e.setDate(e.getDate()+1),c(e)},se=()=>{c(new Date)},ce=e=>{let t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().slice(0,16)},Z=e=>{if(!t?.perm_create_events)return;H(``),S(`create`),E(``),re(``),I(``),R(!1);let n=e?new Date(e):new Date;e?n.setHours(9,0,0,0):(n.setMinutes(0,0,0),n.setHours(n.getHours()+1));let r=new Date(n);r.setHours(r.getHours()+1),O(ce(n)),j(ce(r)),b(!0)},le=e=>{w(e),S(`view`),E(e.title),O(ce(new Date(e.start))),j(ce(new Date(e.end))),re(e.location||``),I(e.description||``),R(e.all_day||!1),H(``),b(!0)},ue=()=>{t?.perm_edit_events&&S(`edit`)},de=async e=>{e.preventDefault(),H(``);let t=new Date(D),n=new Date(k);if(n<=t){H(`End date/time must be after the start date/time.`);return}B(!0);try{let e={title:T,start:t.toISOString(),end:n.toISOString(),location:ne||null,description:P||null,all_day:L};x===`create`?await K.post(`/api/v1/channels/calendar/events`,e):x===`edit`&&C&&await K.patch(`/api/v1/channels/calendar/events/${C.id}`,e),b(!1),q()}catch(e){console.error(`Failed to save event`,e),H(e.response?.data?.detail||`Failed to save calendar event.`)}finally{B(!1)}},fe=async()=>{if(!(!C||!t?.perm_delete_events)&&window.confirm(`Are you sure you want to delete this event?`)){B(!0),H(``);try{await K.delete(`/api/v1/channels/calendar/events/${C.id}`),b(!1),q()}catch(e){console.error(`Failed to delete event`,e),H(e.response?.data?.detail||`Failed to delete event.`)}finally{B(!1)}}},pe=()=>{let e=o.getFullYear(),t=o.getMonth(),n=new Date(e,t,1).getDay(),r=new Date(e,t+1,0).getDate(),i=new Date(e,t,0).getDate(),a=[];for(let r=n-1;r>=0;r--){let n=new Date(e,t-1,i-r);a.push({date:n,isCurrentMonth:!1,key:`prev-${r}`})}for(let n=1;n<=r;n++){let r=new Date(e,t,n);a.push({date:r,isCurrentMonth:!0,key:`curr-${n}`})}let s=42-a.length;for(let n=1;n<=s;n++){let r=new Date(e,t+1,n);a.push({date:r,isCurrentMonth:!1,key:`next-${n}`})}return a},me=()=>{let e=new Date(o),t=e.getDay();e.setDate(e.getDate()-t);let n=[];for(let t=0;t<7;t++){let r=new Date(e);r.setDate(e.getDate()+t),n.push(r)}return n},he=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),ge=e=>p.filter(t=>he(new Date(t.start),e)).sort((e,t)=>new Date(e.start).getTime()-new Date(t.start).getTime());return r?(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-4`,children:[(0,$.jsx)(N,{className:`w-8 h-8 animate-spin text-shogun-blue`}),(0,$.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:`Synchronizing Calendar Board…`})]}):!t||!t.is_active||t.calendar_provider===`none`?(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,$.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-blue/10 flex items-center justify-center text-shogun-blue border border-shogun-blue/30 mb-4 animate-pulse`,children:(0,$.jsx)(s,{className:`w-8 h-8`})}),(0,$.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`No Calendar Account Connected`}),(0,$.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed mb-6`,children:`To manage schedules and CalDAV events, configure your Calendar provider in Katana settings.`}),(0,$.jsx)(`button`,{onClick:()=>{e(`/katana`)},className:`px-5 py-2.5 bg-shogun-blue hover:bg-shogun-blue/90 text-white text-xs font-bold rounded-lg uppercase tracking-wider transition-all`,children:`Go to Katana Settings`})]}):t.perm_read_calendar?(0,$.jsxs)(`div`,{className:`h-[calc(100vh-270px)] flex flex-col min-h-0 bg-[#050508]/30 rounded-2xl border border-shogun-border/40 overflow-hidden backdrop-blur-md`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between items-stretch sm:items-center px-6 py-4 bg-[#0a0a0f]/60 border-b border-shogun-border/40 gap-3 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center border border-shogun-border rounded-lg bg-shogun-card overflow-hidden`,children:[(0,$.jsx)(`button`,{onClick:J,className:`p-2 text-shogun-subdued hover:text-shogun-text hover:bg-white/5 transition-all`,children:(0,$.jsx)(d,{className:`w-4 h-4`})}),(0,$.jsx)(`button`,{onClick:se,className:`px-3 py-1.5 text-xs font-bold uppercase border-x border-shogun-border text-shogun-subdued hover:text-shogun-text hover:bg-white/5 transition-all`,children:`Today`}),(0,$.jsx)(`button`,{onClick:Y,className:`p-2 text-shogun-subdued hover:text-shogun-text hover:bg-white/5 transition-all`,children:(0,$.jsx)(f,{className:`w-4 h-4`})})]}),(0,$.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text font-mono truncate`,children:(()=>{if(l===`month`)return o.toLocaleString(`default`,{month:`long`,year:`numeric`});if(l===`week`){let e=me(),t=e[0],n=e[6];return t.getMonth()===n.getMonth()?`${t.toLocaleString(`default`,{month:`long`})} ${t.getFullYear()}`:t.getFullYear()===n.getFullYear()?`${t.toLocaleString(`default`,{month:`short`})} – ${n.toLocaleString(`default`,{month:`short`})} ${t.getFullYear()}`:`${t.toLocaleString(`default`,{month:`short`,year:`numeric`})} – ${n.toLocaleString(`default`,{month:`short`,year:`numeric`})}`}else return o.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})})()})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[_&&(0,$.jsxs)(`div`,{className:`hidden lg:flex items-center gap-1.5 px-3 py-1 bg-red-500/10 border border-red-500/20 text-red-400 rounded-md text-[10px] font-bold`,children:[(0,$.jsx)(m,{className:`w-3.5 h-3.5`}),(0,$.jsx)(`span`,{children:`Sync Error`})]}),(0,$.jsx)(`button`,{onClick:q,className:`p-2 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 text-shogun-subdued hover:text-shogun-text rounded-lg transition-all`,title:`Refresh events`,children:(0,$.jsx)(N,{className:W(`w-4 h-4`,te&&`animate-spin`)})}),(0,$.jsx)(`div`,{className:`flex border border-shogun-border rounded-lg bg-shogun-card p-0.5`,children:[`month`,`week`,`day`].map(e=>(0,$.jsx)(`button`,{onClick:()=>u(e),className:W(`px-3 py-1 rounded-md text-xs font-bold uppercase tracking-wider transition-all`,l===e?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20`:`text-shogun-subdued hover:text-shogun-text`),children:e},e))}),(0,$.jsxs)(`button`,{onClick:()=>e(`/shogun?tab=operations`),className:`flex items-center gap-1.5 px-4 py-2 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-500 hover:to-indigo-500 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all border border-purple-500/20 shadow-[0_0_10px_rgba(147,51,234,0.3)] hover:shadow-[0_0_15px_rgba(147,51,234,0.5)]`,children:[(0,$.jsx)(M,{className:`w-4 h-4`}),` Create Task`]}),t.perm_create_events&&(0,$.jsxs)(`button`,{onClick:()=>Z(),className:`flex items-center gap-1.5 px-4 py-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all`,children:[(0,$.jsx)(M,{className:`w-4 h-4`}),` Add Event`]})]})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-hidden relative flex flex-col bg-[#07070a]/20`,children:[te&&(0,$.jsxs)(`div`,{className:`absolute inset-0 bg-[#050508]/60 backdrop-blur-[2px] z-20 flex flex-col items-center justify-center text-shogun-subdued space-y-2`,children:[(0,$.jsx)(N,{className:`w-6 h-6 animate-spin text-shogun-blue`}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-widest font-bold`,children:`Querying CalDAV Node…`})]}),l===`month`&&(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-7 border-b border-shogun-border/30 bg-[#0a0a0f]/40 text-center py-2 shrink-0`,children:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`].map(e=>(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e},e))}),(0,$.jsx)(`div`,{className:`flex-1 grid grid-cols-7 grid-rows-6 divide-x divide-y divide-shogun-border/20 min-h-0 overflow-y-auto`,children:pe().map(({date:e,isCurrentMonth:n,key:r})=>{let i=ge(e),a=he(e,new Date);return(0,$.jsxs)(`div`,{onClick:()=>{t.perm_create_events?Z(e):(u(`day`),c(e))},className:W(`min-h-0 p-2 flex flex-col gap-1 transition-all cursor-pointer select-none relative group`,n?`bg-transparent`:`bg-[#07070a]/10 opacity-40`,a?`bg-shogun-blue/[0.02]`:`hover:bg-shogun-card/15`),children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center shrink-0`,children:[(0,$.jsx)(`span`,{className:W(`text-xs font-mono font-bold w-6 h-6 flex items-center justify-center rounded-full transition-all`,a?`bg-shogun-blue text-white shadow-[0_0_10px_rgba(74,140,199,0.5)]`:`text-shogun-text group-hover:text-shogun-blue`),children:e.getDate()}),i.length>0&&(0,$.jsx)(`span`,{className:`text-[9px] font-bold text-shogun-subdued bg-shogun-card border border-shogun-border/40 px-1.5 py-0.5 rounded font-mono`,children:i.length})]}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col gap-1 overflow-y-auto scrollbar-hide py-1`,children:[i.slice(0,3).map(e=>(0,$.jsxs)(`div`,{onClick:t=>{t.stopPropagation(),le(e)},className:W(`px-2 py-1 rounded text-[10px] font-medium truncate border transition-all text-left`,e.color===`cron_job`?`bg-gradient-to-r from-purple-950/40 to-indigo-950/40 border-purple-500/30 text-purple-200 hover:from-purple-900/50 hover:to-indigo-900/50 shadow-[0_0_8px_rgba(168,85,247,0.15)]`:e.all_day?`bg-shogun-gold/15 border-shogun-gold/30 text-shogun-gold hover:bg-shogun-gold/25`:`bg-shogun-blue/15 border-shogun-blue/30 text-shogun-blue hover:bg-shogun-blue/25`),title:`${e.title} (${new Date(e.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})`,children:[!e.all_day&&(0,$.jsx)(`span`,{className:`font-mono opacity-85 mr-1 font-bold`,children:new Date(e.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1})}),e.title]},e.id)),i.length>3&&(0,$.jsxs)(`div`,{className:`text-[9px] font-bold text-shogun-subdued italic px-1`,children:[`+ `,i.length-3,` more`]})]})]},r)})})]}),l===`week`&&(0,$.jsx)(`div`,{className:`flex-1 flex divide-x divide-shogun-border/20 min-h-0 overflow-x-auto`,children:me().map((e,n)=>{let r=ge(e),i=he(e,new Date);return(0,$.jsxs)(`div`,{className:W(`flex-1 min-w-[140px] flex flex-col min-h-0 bg-[#07070a]/10`,i&&`bg-shogun-blue/[0.01] border-x border-shogun-blue/10`),children:[(0,$.jsxs)(`div`,{className:W(`p-3 border-b border-shogun-border/30 bg-[#0a0a0f]/40 text-center shrink-0 flex flex-col items-center justify-center gap-0.5`,i&&`border-b-shogun-blue/50`),children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-wider`,children:e.toLocaleDateString(`default`,{weekday:`short`})}),(0,$.jsx)(`span`,{className:W(`text-sm font-mono font-bold w-7 h-7 flex items-center justify-center rounded-full`,i?`bg-shogun-blue text-white shadow-[0_0_8px_rgba(74,140,199,0.5)]`:`text-shogun-text`),children:e.getDate()})]}),(0,$.jsx)(`div`,{onClick:()=>{t.perm_create_events&&Z(e)},className:`flex-1 p-3 overflow-y-auto space-y-2.5 cursor-pointer hover:bg-shogun-card/[0.03] transition-colors`,children:r.length===0?(0,$.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,$.jsx)(`span`,{className:`text-[9px] text-shogun-subdued font-bold tracking-wider uppercase opacity-35`,children:`No Events`})}):r.map(e=>(0,$.jsxs)(`div`,{onClick:t=>{t.stopPropagation(),le(e)},className:W(`p-2.5 rounded-xl border transition-all text-left flex flex-col gap-1 shadow-lg hover:scale-[1.02]`,e.color===`cron_job`?`bg-gradient-to-br from-purple-950/30 to-indigo-950/30 border-purple-500/40 text-purple-200 hover:bg-purple-900/40 hover:border-purple-400 shadow-[0_0_12px_rgba(168,85,247,0.2)]`:e.all_day?`bg-shogun-gold/10 border-shogun-gold/30 text-shogun-gold hover:bg-shogun-gold/15`:`bg-shogun-blue/10 border-shogun-blue/30 text-shogun-blue hover:bg-shogun-blue/15`),children:[(0,$.jsx)(`span`,{className:`text-xs font-bold leading-snug line-clamp-2`,children:e.title}),(0,$.jsxs)(`span`,{className:`text-[9px] font-mono opacity-80 flex items-center gap-1 font-bold`,children:[(0,$.jsx)(ee,{className:`w-2.5 h-2.5`}),e.all_day?`All Day`:`${new Date(e.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1})} - ${new Date(e.end).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1})}`]}),e.location&&(0,$.jsxs)(`span`,{className:`text-[9px] opacity-80 flex items-center gap-1 truncate font-medium`,children:[(0,$.jsx)(X,{className:`w-2.5 h-2.5 shrink-0`}),e.location]})]},e.id))})]},n)})}),l===`day`&&(0,$.jsx)(`div`,{className:`flex-1 flex min-h-0 divide-x divide-shogun-border/20`,children:(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-shogun-border/20 pb-3 shrink-0`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Day Agenda`}),(0,$.jsxs)(`span`,{className:`text-xs text-shogun-subdued font-bold font-mono`,children:[ge(o).length,` Events scheduled`]})]}),ge(o).length===0?(0,$.jsxs)(`div`,{className:`h-48 flex flex-col items-center justify-center text-shogun-subdued space-y-2 opacity-50`,children:[(0,$.jsx)(s,{className:`w-8 h-8`}),(0,$.jsx)(`p`,{className:`text-xs italic`,children:`No directives scheduled for this sector.`})]}):(0,$.jsx)(`div`,{className:`space-y-3`,children:ge(o).map(n=>(0,$.jsxs)(`div`,{onClick:()=>le(n),className:W(`p-4 rounded-2xl border transition-all cursor-pointer hover:bg-shogun-card/45 flex flex-col md:flex-row md:items-center justify-between gap-4`,n.color===`cron_job`?`bg-gradient-to-r from-purple-950/20 to-indigo-950/20 border-purple-500/30 text-purple-200 hover:from-purple-950/35 hover:to-indigo-950/35`:n.all_day?`bg-shogun-gold/5 border-shogun-gold/20 text-shogun-gold`:`bg-shogun-blue/5 border-shogun-blue/20 text-shogun-blue`),children:[(0,$.jsxs)(`div`,{className:`space-y-1.5 flex-1 min-w-0`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text leading-snug`,children:n.title}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[11px] text-shogun-subdued font-medium`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ee,{className:`w-3 h-3 text-shogun-blue`}),n.all_day?`All Day`:`${new Date(n.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})} - ${new Date(n.end).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`]}),n.location&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 truncate max-w-xs`,children:[(0,$.jsx)(X,{className:`w-3 h-3 text-shogun-gold`}),n.location]})]}),n.description&&(0,$.jsx)(`p`,{className:`text-xs text-shogun-subdued font-mono truncate max-w-2xl mt-1.5 opacity-90`,children:n.description})]}),(0,$.jsx)(`div`,{className:`flex gap-2 self-end md:self-center shrink-0`,children:n.color===`cron_job`?(0,$.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(`/shogun?tab=operations`)},className:`px-3 py-1.5 text-[10px] font-bold border border-purple-500/30 text-purple-300 hover:text-purple-200 hover:border-purple-500/50 rounded-lg hover:bg-purple-500/10 transition-all`,children:`Configure`}):(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),le(n),ue()},disabled:!t.perm_edit_events,className:`px-3 py-1.5 text-[10px] font-bold border border-shogun-border text-shogun-subdued hover:text-shogun-text rounded-lg hover:bg-white/5 transition-all disabled:opacity-40`,children:`Edit`})})]},n.id))})]})})]}),y&&(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/75 backdrop-blur-md`,onClick:()=>{z||b(!1)}}),(0,$.jsxs)(`div`,{className:`relative w-full max-w-lg bg-[#09090e] border border-shogun-border rounded-2xl flex flex-col shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center p-5 border-b border-shogun-border/30 bg-[#0a0a0f]/40`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest flex items-center gap-2`,children:[(0,$.jsx)(s,{className:`w-4 h-4 text-shogun-blue`}),x===`create`&&`Schedule Event`,x===`view`&&`Event Parameters`,x===`edit`&&`Edit Event`]}),(0,$.jsx)(`button`,{disabled:z,onClick:()=>b(!1),className:`p-1 text-shogun-subdued hover:text-shogun-text transition-colors disabled:opacity-40`,children:(0,$.jsx)(oe,{className:`w-5 h-5`})})]}),x===`view`&&C?(0,$.jsxs)(`div`,{className:`p-6 space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-bold text-shogun-text leading-snug`,children:C.title}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2.5 text-xs text-shogun-subdued mt-2 font-medium`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ee,{className:`w-4 h-4 text-shogun-blue`}),(0,$.jsx)(`span`,{children:C.all_day?`${new Date(C.start).toLocaleDateString()} (All Day)`:`${new Date(C.start).toLocaleString()} – ${new Date(C.end).toLocaleString()}`})]}),C.location&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{className:`w-4 h-4 text-shogun-gold`}),(0,$.jsx)(`span`,{className:`text-shogun-text`,children:C.location})]})]})]}),C.description&&(0,$.jsxs)(`div`,{className:`space-y-1.5 p-4 rounded-xl border border-shogun-border/20 bg-[#050508]/80`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:`Description`}),(0,$.jsx)(`p`,{className:`text-xs text-shogun-text font-mono whitespace-pre-wrap leading-relaxed`,children:C.description})]}),(0,$.jsx)(`div`,{className:`flex justify-between items-center pt-2 border-t border-shogun-border/20 gap-3`,children:C.color===`cron_job`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{}),(0,$.jsxs)(`button`,{onClick:()=>{b(!1),e(`/shogun?tab=operations`)},className:`flex items-center gap-1.5 px-5 py-2 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-500 hover:to-indigo-500 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all shadow-[0_0_10px_rgba(147,51,234,0.3)]`,children:[(0,$.jsx)(F,{className:`w-4 h-4`}),` Configure Cron Job`]})]}):(0,$.jsxs)($.Fragment,{children:[t.perm_delete_events?(0,$.jsxs)(`button`,{onClick:fe,disabled:z,className:`flex items-center gap-1.5 px-4 py-2 border border-red-500/20 text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded-lg text-xs font-bold transition-all disabled:opacity-40`,children:[(0,$.jsx)(ae,{className:`w-4 h-4`}),` Delete Event`]}):(0,$.jsx)(`div`,{}),t.perm_edit_events&&(0,$.jsxs)(`button`,{onClick:ue,className:`flex items-center gap-1.5 px-5 py-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all`,children:[(0,$.jsx)(A,{className:`w-4 h-4`}),` Edit Event`]})]})})]}):(0,$.jsxs)(`form`,{onSubmit:de,className:`p-5 flex-1 flex flex-col gap-4 overflow-y-auto`,children:[V&&(0,$.jsxs)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/20 text-red-500 rounded-lg text-xs font-semibold flex items-center gap-2`,children:[(0,$.jsx)(m,{className:`w-4 h-4 shrink-0`}),(0,$.jsx)(`span`,{children:V})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Event Title *`}),(0,$.jsx)(`input`,{type:`text`,required:!0,placeholder:`Brief description of event`,value:T,onChange:e=>E(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Start Date & Time *`}),(0,$.jsx)(`input`,{type:`datetime-local`,required:!0,value:D,onChange:e=>O(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`End Date & Time *`}),(0,$.jsx)(`input`,{type:`datetime-local`,required:!0,value:k,onChange:e=>j(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`allDayCheck`,checked:L,onChange:e=>R(e.target.checked),className:`rounded border-shogun-border text-shogun-blue focus:ring-shogun-blue bg-[#050508]`}),(0,$.jsx)(`label`,{htmlFor:`allDayCheck`,className:`text-xs text-shogun-text select-none cursor-pointer`,children:`All Day Event`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Location`}),(0,$.jsx)(`input`,{type:`text`,placeholder:`e.g. Conference Room A, Virtual Link`,value:ne,onChange:e=>re(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Description`}),(0,$.jsx)(`textarea`,{rows:4,placeholder:`Enter additional details...`,value:P,onChange:e=>I(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono resize-y`})]}),(0,$.jsxs)(`div`,{className:`flex gap-3 mt-2`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:z,onClick:()=>{x===`edit`?S(`view`):b(!1)},className:`flex-1 py-3 border border-shogun-border text-shogun-subdued hover:text-shogun-text font-bold rounded-lg text-sm uppercase tracking-wider transition-all disabled:opacity-40`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`submit`,disabled:z||!T||!D||!k,className:`flex-1 flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm uppercase tracking-wider transition-all`,children:z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(N,{className:`w-4 h-4 animate-spin`}),` Synchronizing CalDAV…`]}):x===`edit`?`Update Event`:`Create Event`})]})]})]})]})]}):(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,$.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-400/10 flex items-center justify-center text-red-400 border border-red-400/30 mb-4`,children:(0,$.jsx)(ie,{className:`w-8 h-8`})}),(0,$.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`Read Permission Denied`}),(0,$.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed`,children:`The "Read Calendar" permission is disabled for this account in Katana settings. Toggle this permission ON to view your calendar board.`})]})};function fe(e){return[`ts`,`tsx`,`js`,`jsx`,`py`,`go`,`rs`,`java`,`c`,`cpp`,`h`,`cs`,`rb`,`php`,`sh`,`bat`,`ps1`,`yaml`,`yml`,`toml`,`ini`,`cfg`].includes(e)?g:[`csv`,`xlsx`,`xls`].includes(e)?_:[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`bmp`,`ico`].includes(e)?x:[`zip`,`tar`,`gz`,`rar`,`7z`,`bz2`].includes(e)?a:[`txt`,`md`,`log`,`json`,`xml`,`html`,`css`].includes(e)?v:J}function pe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function me(e){return e?new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(e)):`Date unavailable`}function he({node:e,depth:t,selectedPath:n,expandedPaths:r,onSelect:i,onToggle:a}){let o=e.type===`directory`,s=r.has(e.path),c=n===e.path,l=o?s?y:b:fe(e.extension||``);return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{onClick:()=>{i(e),o&&a(e.path)},className:W(`w-full flex items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-all group`,c?`bg-shogun-blue/15 text-shogun-blue`:`text-shogun-text hover:bg-shogun-card`),style:{paddingLeft:`${t*16+8}px`},children:[o?(0,$.jsx)(`span`,{className:`w-3 h-3 flex items-center justify-center flex-shrink-0 text-shogun-subdued`,children:s?(0,$.jsx)(u,{className:`w-3 h-3`}):(0,$.jsx)(f,{className:`w-3 h-3`})}):(0,$.jsx)(`span`,{className:`w-3 h-3 flex-shrink-0`}),(0,$.jsx)(l,{className:W(`w-4 h-4 flex-shrink-0`,o?`text-shogun-gold`:`text-shogun-subdued`)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,$.jsx)(`span`,{className:`block truncate`,children:e.name}),!o&&(0,$.jsxs)(`span`,{className:`block truncate text-[9px] leading-3 text-shogun-subdued/60 font-mono`,title:`Created ${me(e.created_at)}`,children:[`Created `,me(e.created_at)]})]}),!o&&e.size!==void 0&&(0,$.jsx)(`span`,{className:`text-[10px] text-shogun-subdued/60 font-mono flex-shrink-0`,children:pe(e.size)})]}),o&&s&&e.children&&(0,$.jsxs)(`div`,{children:[e.children.map(e=>(0,$.jsx)(he,{node:e,depth:t+1,selectedPath:n,expandedPaths:r,onSelect:i,onToggle:a},e.path)),e.children.length===0&&(0,$.jsx)(`div`,{className:`text-[11px] text-shogun-subdued/40 italic pl-4 py-1`,style:{paddingLeft:`${(t+1)*16+20}px`},children:`Empty folder`})]})]})}var ge=()=>{let[e,t]=(0,Q.useState)([]),[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(new Set([``])),[c,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1),[h,ee]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(!0),[v,x]=(0,Q.useState)(!1),[S,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(null),[D,O]=(0,Q.useState)(null),[k,j]=(0,Q.useState)(``),[M,P]=(0,Q.useState)(!1),[F,ie]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(!1),[G,J]=(0,Q.useState)(!1),se=(0,Q.useRef)(0),ce=(0,Q.useRef)(null),X=(0,Q.useCallback)((e,t)=>{E({type:e,text:t}),setTimeout(()=>E(null),3e3)},[]),Z=(0,Q.useCallback)(async()=>{try{_(!0),w(null);let[e,n]=await Promise.all([K.get(`/api/v1/workspace/tree`),K.get(`/api/v1/workspace/info`)]);e.data?.success&&t(e.data.data.tree),n.data?.success&&r(n.data.data)}catch(e){w(e?.response?.data?.detail||e.message)}finally{_(!1)}},[]);(0,Q.useEffect)(()=>{Z()},[Z]);let le=async e=>{if(a(e),m(!1),ee(!1),L(!1),P(!1),e.type===`file`)try{let t=await K.get(`/api/v1/workspace/read`,{params:{path:e.path}});t.data?.success&&(u(t.data.data.content),f(t.data.data.content))}catch(e){let t=e?.response?.data?.detail||`Failed to read file`;t.toLowerCase().includes(`binary`)?(ee(!0),u(``)):u(`[Error] ${t}`),f(``)}else u(``),f(``)},ue=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},de=async()=>{if(!(!i||i.type!==`file`)){x(!0);try{(await K.post(`/api/v1/workspace/write`,{path:i.path,content:d})).data?.success&&(u(d),m(!1),X(`success`,`Saved ${i.name}`),Z())}catch(e){X(`error`,e?.response?.data?.detail||`Save failed`)}finally{x(!1)}}},ge=async()=>{if(!k.trim())return;let e=i?.type===`directory`?i.path:``,t=e?`${e}/${k.trim()}`:k.trim();try{D===`folder`?(await K.post(`/api/v1/workspace/mkdir`,{path:t}),X(`success`,`Created folder: ${k.trim()}`)):(await K.post(`/api/v1/workspace/write`,{path:t,content:``}),X(`success`,`Created file: ${k.trim()}`)),O(null),j(``),e&&s(t=>new Set([...t,e])),Z()}catch(e){X(`error`,e?.response?.data?.detail||`Creation failed`)}},_e=async()=>{if(i)try{await K.delete(`/api/v1/workspace/delete`,{params:{path:i.path}}),X(`success`,`Deleted: ${i.name}`),a(null),u(``),L(!1),Z()}catch(e){X(`error`,e?.response?.data?.detail||`Delete failed`)}},ve=async()=>{if(!i||!F.trim())return;let e=i.path.split(`/`);e[e.length-1]=F.trim();let t=e.join(`/`);try{await K.post(`/api/v1/workspace/rename`,{old_path:i.path,new_path:t}),X(`success`,`Renamed to: ${F.trim()}`),P(!1),a(null),Z()}catch(e){X(`error`,e?.response?.data?.detail||`Rename failed`)}},ye=async e=>{if(!e||e.length===0)return;J(!0);let t=i?.type===`directory`?i.path:``;try{let n=new FormData;Array.from(e).forEach(e=>n.append(`files`,e)),n.append(`path`,t);let r=await K.post(`/api/v1/workspace/upload`,n,{headers:{"Content-Type":`multipart/form-data`}});if(r.data?.success){let e=r.data.data.uploaded;X(`success`,`Uploaded ${e} file${e===1?``:`s`}`),t&&s(e=>new Set([...e,t])),Z()}}catch(e){X(`error`,e?.response?.data?.detail||`Upload failed`)}finally{J(!1)}},be=e=>{e.preventDefault(),e.stopPropagation(),se.current+=1,e.dataTransfer.types.includes(`Files`)&&U(!0)},xe=e=>{e.preventDefault(),e.stopPropagation(),--se.current,se.current===0&&U(!1)},Se=e=>{e.preventDefault(),e.stopPropagation()},Ce=e=>{e.preventDefault(),e.stopPropagation(),U(!1),se.current=0,e.dataTransfer.files?.length&&ye(e.dataTransfer.files)},we=(e,t)=>{if(!t)return e;let n=t.toLowerCase();return e.reduce((e,r)=>{if(r.name.toLowerCase().includes(n))e.push(r);else if(r.type===`directory`&&r.children){let n=we(r.children,t);n.length>0&&e.push({...r,children:n})}return e},[])},Te={name:`Workspace`,path:``,type:`directory`,children:we(e,R)};return S?(0,$.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,$.jsx)(B,{className:`w-10 h-10 text-red-400 mx-auto`}),(0,$.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`Workspace Unavailable`}),(0,$.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-md`,children:S}),(0,$.jsxs)(`button`,{onClick:Z,className:`px-4 py-2 bg-shogun-blue/20 text-shogun-blue rounded-lg text-sm hover:bg-shogun-blue/30 transition-colors`,children:[(0,$.jsx)(N,{className:`w-4 h-4 inline mr-1`}),` Retry`]})]})}):(0,$.jsxs)(`div`,{className:`h-full flex flex-col relative`,onDragEnter:be,onDragLeave:xe,onDragOver:Se,onDrop:Ce,children:[(0,$.jsx)(`input`,{ref:ce,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&(ye(e.target.files),e.target.value=``)}}),H&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 bg-shogun-bg/90 backdrop-blur-sm flex items-center justify-center border-2 border-dashed border-shogun-blue rounded-xl transition-all`,children:(0,$.jsxs)(`div`,{className:`text-center space-y-3 animate-pulse`,children:[(0,$.jsx)(V,{className:`w-12 h-12 text-shogun-blue mx-auto`}),(0,$.jsx)(`h3`,{className:`text-lg font-bold text-shogun-blue`,children:`Drop files here`}),(0,$.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:i?.type===`directory`?(0,$.jsxs)($.Fragment,{children:[`Upload into `,(0,$.jsxs)(`span`,{className:`font-mono text-shogun-blue`,children:[i.path,`/`]})]}):`Upload to workspace root`})]})}),T&&(0,$.jsxs)(`div`,{className:W(`px-4 py-2 text-xs font-medium flex items-center gap-2 shrink-0 transition-all`,T.type===`success`?`bg-emerald-500/10 text-emerald-400 border-b border-emerald-500/20`:`bg-red-500/10 text-red-400 border-b border-red-500/20`),children:[T.type===`success`?(0,$.jsx)(l,{className:`w-3 h-3`}):(0,$.jsx)(B,{className:`w-3 h-3`}),T.text]}),(0,$.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,$.jsxs)(`div`,{className:`w-72 border-r border-shogun-border flex flex-col bg-shogun-bg/50 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`p-2 border-b border-shogun-border flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{onClick:()=>O(`file`),title:`New File`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-blue transition-colors`,children:(0,$.jsx)(q,{className:`w-4 h-4`})}),(0,$.jsx)(`button`,{onClick:()=>O(`folder`),title:`New Folder`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,$.jsx)(Y,{className:`w-4 h-4`})}),(0,$.jsx)(`button`,{onClick:()=>ce.current?.click(),title:`Upload Files`,disabled:G,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-emerald-400 transition-colors`,children:(0,$.jsx)(V,{className:W(`w-4 h-4`,G&&`animate-bounce`)})}),i&&i.path!==``&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{onClick:()=>{ie(i.name),P(!0)},title:`Rename`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text transition-colors`,children:(0,$.jsx)(A,{className:`w-4 h-4`})}),(0,$.jsx)(`button`,{onClick:()=>L(!0),title:`Delete`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-red-400 transition-colors`,children:(0,$.jsx)(ae,{className:`w-4 h-4`})})]}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(`button`,{onClick:Z,title:`Refresh`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text transition-colors`,children:(0,$.jsx)(N,{className:W(`w-4 h-4`,g&&`animate-spin`)})})]}),(0,$.jsx)(`div`,{className:`px-2 pt-2 shrink-0`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(re,{className:`w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-shogun-subdued`}),(0,$.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:`Search files...`,className:`w-full bg-shogun-card border border-shogun-border rounded-md pl-8 pr-3 py-1.5 text-xs text-shogun-text placeholder-shogun-subdued/40 focus:outline-none focus:border-shogun-blue/50`})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto p-1 mt-1`,children:g?(0,$.jsx)(`div`,{className:`flex items-center justify-center h-20`,children:(0,$.jsx)(N,{className:`w-5 h-5 animate-spin text-shogun-subdued`})}):(0,$.jsx)(he,{node:Te,depth:0,selectedPath:i?.path??null,expandedPaths:o,onSelect:le,onToggle:ue})}),n&&(0,$.jsxs)(`div`,{className:`p-2 border-t border-shogun-border text-[10px] text-shogun-subdued/60 space-y-0.5 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(C,{className:`w-3 h-3`}),` `,n.total_files,` files · `,n.total_directories,` dirs · `,n.total_size_mb,` MB`]}),(0,$.jsx)(`div`,{className:`font-mono truncate`,title:n.path,children:n.path})]})]}),(0,$.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`px-4 py-2.5 border-b border-shogun-border flex items-center gap-3 shrink-0 bg-shogun-bg/30`,children:i.type===`file`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(fe(i.extension||``),{className:`w-4 h-4 text-shogun-subdued`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-shogun-text truncate`,children:i.path}),i.size!==void 0&&(0,$.jsx)(`span`,{className:`text-[10px] text-shogun-subdued font-mono`,children:pe(i.size)}),(0,$.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued font-mono`,title:i.modified_at?`Modified ${me(i.modified_at)}`:void 0,children:[`Created `,me(i.created_at)]}),(0,$.jsx)(`div`,{className:`flex-1`}),!h&&(p?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(`button`,{onClick:de,disabled:v,className:`px-3 py-1 bg-emerald-500/20 text-emerald-400 rounded text-xs font-medium hover:bg-emerald-500/30 transition-colors flex items-center gap-1`,children:[(0,$.jsx)(ne,{className:`w-3 h-3`}),` `,v?`Saving...`:`Save`]}),(0,$.jsx)(`button`,{onClick:()=>{m(!1),f(c)},className:`px-3 py-1 bg-shogun-card text-shogun-subdued rounded text-xs hover:text-shogun-text transition-colors`,children:(0,$.jsx)(oe,{className:`w-3 h-3`})})]}):(0,$.jsxs)(`button`,{onClick:()=>m(!0),className:`px-3 py-1 bg-shogun-blue/10 text-shogun-blue rounded text-xs font-medium hover:bg-shogun-blue/20 transition-colors flex items-center gap-1`,children:[(0,$.jsx)(A,{className:`w-3 h-3`}),` Edit`]})),h&&(0,$.jsxs)(`a`,{href:`/api/v1/workspace/download?path=${encodeURIComponent(i.path)}`,download:!0,className:`px-3 py-1 bg-shogun-blue/10 text-shogun-blue rounded text-xs font-medium hover:bg-shogun-blue/20 transition-colors flex items-center gap-1`,children:[(0,$.jsx)(te,{className:`w-3 h-3`}),` Download`]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`w-4 h-4 text-shogun-gold`}),(0,$.jsxs)(`span`,{className:`text-sm font-medium text-shogun-text truncate`,children:[i.path||`Workspace`,`/`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[i.children?.length||0,` items`]})]})}),(0,$.jsx)(`div`,{className:`flex-1 overflow-auto`,children:i.type===`file`?h?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,$.jsxs)(`div`,{className:`text-center space-y-4 max-w-sm`,children:[(0,$.jsx)(fe(i.extension||``),{className:`w-16 h-16 text-shogun-subdued/30 mx-auto`}),(0,$.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:i.name}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-4 text-xs text-shogun-subdued`,children:[(0,$.jsxs)(`span`,{className:`bg-shogun-card px-2 py-1 rounded font-mono`,children:[`.`,i.extension]}),i.size!==void 0&&(0,$.jsx)(`span`,{children:pe(i.size)})]}),(0,$.jsx)(`p`,{className:`text-xs text-shogun-subdued/60`,children:`Binary file — cannot be displayed as text.`})]}),(0,$.jsxs)(`a`,{href:`/api/v1/workspace/download?path=${encodeURIComponent(i.path)}`,download:!0,className:`inline-flex items-center gap-2 px-4 py-2 bg-shogun-blue/15 text-shogun-blue rounded-lg text-sm font-medium hover:bg-shogun-blue/25 transition-colors`,children:[(0,$.jsx)(te,{className:`w-4 h-4`}),` Download File`]})]})}):p?(0,$.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),className:`w-full h-full bg-transparent text-shogun-text text-sm font-mono p-4 resize-none focus:outline-none leading-relaxed`,spellCheck:!1}):(0,$.jsx)(`pre`,{className:`text-sm font-mono text-shogun-text p-4 whitespace-pre-wrap break-words leading-relaxed`,children:c||(0,$.jsx)(`span`,{className:`text-shogun-subdued italic`,children:`Empty file`})}):(0,$.jsxs)(`div`,{className:`p-4 space-y-2`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text mb-3`,children:[`Contents of `,i.path?i.name:`Workspace`,`/`]}),i.children&&i.children.length>0?(0,$.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2`,children:i.children.map(e=>(0,$.jsxs)(`button`,{onClick:()=>le(e),className:`flex items-start gap-2 p-3 rounded-lg bg-shogun-card hover:bg-shogun-card/80 border border-shogun-border hover:border-shogun-blue/30 transition-all text-left group`,children:[(0,$.jsx)(e.type===`directory`?b:fe(e.extension||``),{className:W(`w-5 h-5 mt-0.5 flex-shrink-0`,e.type===`directory`?`text-shogun-gold`:`text-shogun-subdued`)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-shogun-text truncate group-hover:text-shogun-blue transition-colors`,children:e.name}),e.type===`file`&&e.size!==void 0&&(0,$.jsx)(`div`,{className:`text-[10px] text-shogun-subdued`,children:pe(e.size)}),(0,$.jsxs)(`div`,{className:`mt-1 text-[9px] leading-3 text-shogun-subdued/60 font-mono truncate`,title:`Created ${me(e.created_at)}`,children:[`Created `,me(e.created_at)]})]})]},e.path))}):(0,$.jsx)(`p`,{className:`text-sm text-shogun-subdued italic`,children:`This folder is empty`})]})})]}):(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,$.jsx)(y,{className:`w-12 h-12 text-shogun-gold/30 mx-auto`}),(0,$.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`Agent Workspace`}),(0,$.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-sm`,children:`Select a file or folder from the tree to view or edit it. This is the shared workspace used by the Shogun and all Samurai agents.`}),n&&(0,$.jsx)(`div`,{className:`text-xs text-shogun-subdued font-mono bg-shogun-card px-3 py-1.5 rounded-lg inline-block`,children:n.path})]})})})]}),D&&(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-xl p-5 w-96 shadow-2xl space-y-4`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[D===`folder`?(0,$.jsx)(Y,{className:`w-4 h-4 text-shogun-gold`}):(0,$.jsx)(q,{className:`w-4 h-4 text-shogun-blue`}),`New `,D===`folder`?`Folder`:`File`]}),i?.type===`directory`&&(0,$.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued`,children:[`Inside: `,(0,$.jsxs)(`span`,{className:`font-mono text-shogun-text`,children:[i.path,`/`]})]}),(0,$.jsx)(`input`,{autoFocus:!0,type:`text`,value:k,onChange:e=>j(e.target.value),onKeyDown:e=>e.key===`Enter`&&ge(),placeholder:D===`folder`?`Folder name`:`filename.txt`,className:`w-full bg-shogun-card border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text placeholder-shogun-subdued/40 focus:outline-none focus:border-shogun-blue/50`}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,$.jsx)(`button`,{onClick:()=>{O(null),j(``)},className:`px-4 py-1.5 text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),(0,$.jsx)(`button`,{onClick:ge,disabled:!k.trim(),className:`px-4 py-1.5 bg-shogun-blue/20 text-shogun-blue rounded-lg text-xs font-medium hover:bg-shogun-blue/30 transition-colors disabled:opacity-40`,children:`Create`})]})]})}),M&&i&&(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-xl p-5 w-96 shadow-2xl space-y-4`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,$.jsx)(A,{className:`w-4 h-4 text-shogun-gold`}),` Rename`]}),(0,$.jsx)(`p`,{className:`text-[11px] text-shogun-subdued font-mono`,children:i.path}),(0,$.jsx)(`input`,{autoFocus:!0,type:`text`,value:F,onChange:e=>ie(e.target.value),onKeyDown:e=>e.key===`Enter`&&ve(),className:`w-full bg-shogun-card border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text focus:outline-none focus:border-shogun-blue/50`}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,$.jsx)(`button`,{onClick:()=>P(!1),className:`px-4 py-1.5 text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),(0,$.jsx)(`button`,{onClick:ve,disabled:!F.trim()||F===i.name,className:`px-4 py-1.5 bg-shogun-gold/20 text-shogun-gold rounded-lg text-xs font-medium hover:bg-shogun-gold/30 transition-colors disabled:opacity-40`,children:`Rename`})]})]})}),I&&i&&(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/30 rounded-xl p-5 w-96 shadow-2xl space-y-4`,children:[(0,$.jsxs)(`h3`,{className:`text-sm font-bold text-red-400 flex items-center gap-2`,children:[(0,$.jsx)(ae,{className:`w-4 h-4`}),` Delete `,i.type===`directory`?`Folder`:`File`]}),(0,$.jsxs)(`p`,{className:`text-sm text-shogun-text`,children:[`Are you sure you want to delete `,(0,$.jsx)(`span`,{className:`font-mono text-red-400`,children:i.name}),`?`,i.type===`directory`&&(0,$.jsx)(`span`,{className:`block text-xs text-shogun-subdued mt-1`,children:`This will delete the folder and all its contents.`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,$.jsx)(`button`,{onClick:()=>L(!1),className:`px-4 py-1.5 text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),(0,$.jsx)(`button`,{onClick:_e,className:`px-4 py-1.5 bg-red-500/20 text-red-400 rounded-lg text-xs font-medium hover:bg-red-500/30 transition-colors`,children:`Delete`})]})]})})]})},_e=`shogun_comms_current`,ve=`shogun_comms_history`,ye=50,be=`chat.welcome_message`;function xe(e){try{let t=localStorage.getItem(_e);return t?JSON.parse(t):[{role:`shogun`,content:e(be),timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}]}catch{return[{role:`shogun`,content:e(be),timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}]}}function Se(e){localStorage.setItem(_e,JSON.stringify(e))}async function Ce(e,t=!0){let n=await fetch(`/api/v1/comms/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({role:e.role,content:e.content,client_message_id:e.id,mirror_to_telegram:t,message_data:{model:e.model,provider:e.provider,search:e.search,mode:e.mode,attachments:e.attachments}})});if(!n.ok)throw Error(`Could not sync chat message: HTTP ${n.status}`)}function we(){try{let e=localStorage.getItem(ve);return e?JSON.parse(e):[]}catch{return[]}}function Te(e,t){let n=t(be);if(e.filter(e=>!(e.role===`shogun`&&e.content===n)).length===0)return;let r=we(),i=[{id:Date.now().toString(),startedAt:e[0]?.timestamp||new Date().toLocaleTimeString(),messages:e},...r].slice(0,ye);localStorage.setItem(ve,JSON.stringify(i))}var Ee={low:`bg-emerald-500/20 text-emerald-400 border-emerald-500/30`,medium:`bg-amber-500/20 text-amber-400 border-amber-500/30`,high:`bg-orange-500/20 text-orange-400 border-orange-500/30`,critical:`bg-red-500/20 text-red-400 border-red-500/30`},De=({att:e,idx:t,setMessages:n})=>{let[r,i]=(0,Q.useState)(!1),a=!!e.resolved,o=async t=>{try{await fetch(`/api/v1/security/toolgate/confirm`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({confirm_id:e.confirmId,approved:t})}),n(n=>{let r=[...n];for(let n=r.length-1;n>=0;n--){let i=r[n].attachments;if(!i)continue;let a=i.findIndex(t=>t.type===`toolgate_confirm`&&t.confirmId===e.confirmId);if(a>=0){let e=[...i];e[a]={...e[a],resolved:t?`approved`:`denied`},r[n]={...r[n],attachments:e};break}}return r})}catch(e){console.error(`ToolGate confirm failed:`,e)}};return(0,$.jsxs)(`div`,{className:W(`rounded-xl border-2 overflow-hidden transition-all`,a?e.resolved===`approved`?`border-emerald-500/40 bg-emerald-500/5`:`border-red-500/40 bg-red-500/5`:`border-amber-500/50 bg-amber-500/5 animate-pulse`),children:[(0,$.jsxs)(`div`,{className:W(`flex items-center gap-2 px-4 py-2.5`,a?e.resolved===`approved`?`bg-emerald-500/10`:`bg-red-500/10`:`bg-amber-500/10`),children:[(0,$.jsx)(ie,{className:W(`w-4 h-4`,a?e.resolved===`approved`?`text-emerald-400`:`text-red-400`:`text-amber-400`)}),(0,$.jsx)(`span`,{className:W(`text-xs font-bold uppercase tracking-widest`,a?e.resolved===`approved`?`text-emerald-300`:`text-red-300`:`text-amber-300`),children:a?e.resolved===`approved`?`✅ APPROVED`:`❌ DENIED`:`âš\xA0️ CONFIRMATION REQUIRED`})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3 space-y-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,$.jsx)(`span`,{className:`text-xs font-bold text-shogun-text font-mono`,children:e.tool}),(0,$.jsxs)(`span`,{className:W(`text-[10px] px-2 py-0.5 rounded-full border font-bold uppercase`,Ee[e.risk||`medium`]||Ee.medium),children:[e.risk,` risk`]})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:e.reason}),e.args&&Object.keys(e.args).length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`button`,{onClick:()=>i(!r),className:`flex items-center gap-1 text-[10px] text-shogun-subdued hover:text-shogun-text transition-colors`,children:[r?(0,$.jsx)(p,{className:`w-3 h-3`}):(0,$.jsx)(u,{className:`w-3 h-3`}),`Parameters (`,Object.keys(e.args).length,`)`]}),r&&(0,$.jsx)(`div`,{className:`mt-1.5 bg-black/30 rounded-lg p-2 text-[10px] font-mono text-shogun-subdued space-y-0.5 max-h-32 overflow-y-auto`,children:Object.entries(e.args).map(([e,t])=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`text-amber-400`,children:[e,`:`]}),` `,JSON.stringify(t)]},e))})]}),!a&&(0,$.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,$.jsxs)(`button`,{onClick:()=>o(!0),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 bg-emerald-600/80 hover:bg-emerald-500 text-white rounded-lg text-xs font-bold uppercase tracking-wider transition-all active:scale-95`,children:[(0,$.jsx)(l,{className:`w-3.5 h-3.5`}),` Approve`]}),(0,$.jsxs)(`button`,{onClick:()=>o(!1),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 bg-red-600/80 hover:bg-red-500 text-white rounded-lg text-xs font-bold uppercase tracking-wider transition-all active:scale-95`,children:[(0,$.jsx)(h,{className:`w-3.5 h-3.5`}),` Deny`]})]})]})]},t)},Oe=()=>{let{t:e}=G(),[t,n]=(0,Q.useState)(()=>xe(e)),r=localStorage.getItem(`shogun_operator_name`)||`Daimyo`,[i,a]=(0,Q.useState)(``),[s,l]=(0,Q.useState)(!1),[d,p]=(0,Q.useState)(null),[h,ee]=(0,Q.useState)(`auto`),[te,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(we),[y,b]=(0,Q.useState)(null),x=(0,Q.useRef)(null),C=(0,Q.useRef)(null),E=(0,Q.useRef)(null),[D,A]=(0,Q.useState)([]),[M,N]=(0,Q.useState)(null),[ne,re]=(0,Q.useState)(!1),[F,ie]=(0,Q.useState)(`Balanced`);(0,Q.useEffect)(()=>{fetch(`/api/v1/models/routing/profiles/active`).then(e=>e.ok?e.json():null).then(e=>{e?.data?.name&&ie(e.data.name)}).catch(()=>void 0)},[]);let B=async e=>{if(e){re(!0);try{let t=new FormData;t.append(`file`,e),t.append(`source`,`chat`),t.append(`chat_session_id`,`web-chat`);let n=await fetch(`/api/v1/visual/intake`,{method:`POST`,body:t}),r=await n.json();if(!n.ok)throw Error(r.detail||`Image upload failed.`);A(e=>[...e,r.data])}catch(e){p(e.message||`Image upload failed.`)}finally{re(!1),E.current&&(E.current.value=``)}}};(0,Q.useEffect)(()=>{let e=!1,t=async()=>{if(!C.current)try{let t=await fetch(`/api/v1/comms/messages?limit=200`);if(!t.ok)return;let r=((await t.json()).data||[]).map(e=>({id:e.id,role:e.role===`user`?`user`:`shogun`,content:e.content,channel:e.channel,timestamp:new Date(e.created_at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),...e.message_data||{}}));!e&&r.length>0&&n(r)}catch{}};t();let r=window.setInterval(t,4e3);return()=>{e=!0,window.clearInterval(r)}},[]),(0,Q.useEffect)(()=>{Se(t)},[t]),(0,Q.useEffect)(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)},[t,s]);let V=async()=>{if(!i.trim()&&D.length===0||s)return;let r=i.trim()||`Please review this image.`,o=[...D],c={id:crypto.randomUUID(),role:`user`,content:r,timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),channel:`comms`,attachments:o};try{await Ce(c)}catch(e){console.error(`Chat sync failed:`,e)}let u=[...t,c];n(u),a(``),A([]),l(!0),p(null);let d=u.filter(e=>e.role===`user`||e.role===`shogun`).slice(-20).map(e=>({role:e.role===`shogun`?`assistant`:`user`,content:e.content})),f={id:crypto.randomUUID(),role:`shogun`,content:``,timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),channel:`comms`};n(e=>[...e,f]);try{let e=new AbortController;C.current=e;let t=await fetch(`/api/v1/agents/shogun/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:r,history:d.slice(0,-1),mode:h,session_id:`web-chat`,attachments:o.map(e=>({artifact_id:e.artifact_id}))}),signal:e.signal});if(!t.ok||!t.body)throw Error(`HTTP ${t.status}`);let i=t.body.getReader(),a=new TextDecoder,s=``,c=``,u={};for(;;){let{done:e,value:t}=await i.read();if(e)break;s+=a.decode(t,{stream:!0});let r=s.split(` -`);s=r.pop()??``;for(let e of r){if(!e.startsWith(`data: `))continue;let t=e.slice(6).trim();if(t===`[DONE]`)break;try{let e=JSON.parse(t);if(e.type===`meta`)u={model:e.model,provider:e.provider,timestamp:e.timestamp,search:e.search,mode:e.mode},n(e=>{let t=[...e];return t[t.length-1]={...t[t.length-1],...u},t});else if(e.type===`status`)p(e.content);else if(e.type===`token`){l(!1),p(null),c+=e.content;let t=c;n(e=>{let n=[...e];return n[n.length-1]={...n[n.length-1],content:t},n})}else e.type===`error`?(c=e.content,n(t=>{let n=[...t];return n[n.length-1]={...n[n.length-1],content:e.content},n})):e.type===`ronin_screenshot`?n(t=>{let n=[...t],r=n[n.length-1],i=r.attachments||[];return n[n.length-1]={...r,attachments:[...i,{type:`screenshot`,url:e.url,description:e.description||`Desktop screenshot`}]},n}):e.type===`ronin_action`?n(t=>{let n=[...t],r=n[n.length-1],i=r.attachments||[];return n[n.length-1]={...r,attachments:[...i,{type:`action`,action:e.action,detail:e.detail||``}]},n}):e.type===`toolgate_confirm`?(n(t=>{let n=[...t],r=n[n.length-1],i=r.attachments||[];return n[n.length-1]={...r,attachments:[...i,{type:`toolgate_confirm`,confirmId:e.confirm_id,tool:e.tool,args:e.args||{},risk:e.risk,reason:e.reason}]},n}),l(!1),p(`Awaiting confirmation...`)):e.type===`toolgate_resolved`?(n(t=>{let n=[...t];for(let t=n.length-1;t>=0;t--){let r=n[t].attachments;if(!r)continue;let i=r.findIndex(t=>t.type===`toolgate_confirm`&&t.confirmId===e.confirm_id);if(i>=0){let a=[...r];a[i]={...a[i],resolved:e.approved?`approved`:`denied`},n[t]={...n[t],attachments:a};break}}return n}),p(null),l(!0)):e.type===`action`&&p(e.content)}catch{}}}c.trim()&&await Ce({...f,...u,content:c})}catch(t){t?.name===`AbortError`?n(e=>{let t=[...e],n=t[t.length-1];return n.content===``?t[t.length-1]={...n,content:`â›” Cancelled by operator.`}:t[t.length-1]={...n,content:n.content+` - -â›” *Cancelled by operator.*`},t}):(console.error(`Streaming failed:`,t),n(t=>{let n=[...t];return n[n.length-1]={...n[n.length-1],content:`âš\xA0️ `+e(`chat.bridge_interrupted`,`Neural bridge interrupted. Check logs.`)},n}))}finally{C.current=null,l(!1),p(null)}},K=()=>{C.current&&C.current.abort()},q=async()=>{Te(t,e);try{await fetch(`/api/v1/comms/messages`,{method:`DELETE`})}catch{}n([{role:`shogun`,content:e(be),timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}]),v(we())},J=()=>{v(we()),g(!0)},Y=async r=>{Te(t,e),n(r.messages),g(!1);try{await fetch(`/api/v1/comms/messages`,{method:`DELETE`}),await Promise.all(r.messages.filter(t=>t.content&&t.content!==e(be)).map(e=>Ce({...e,id:e.id||crypto.randomUUID(),channel:`comms`},!1)))}catch(e){console.error(`Could not restore shared chat session:`,e)}};return(0,$.jsxs)(`div`,{className:`flex flex-col w-full min-w-0 h-full space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`chat.neural_link`,`Neural Connection`)}),(0,$.jsxs)(`span`,{className:`rounded border border-purple-400/30 bg-purple-400/10 px-2 py-1 text-[9px] font-bold uppercase text-purple-300`,children:[`Routing: `,F]})]}),(0,$.jsxs)(`button`,{onClick:q,className:`flex items-center gap-1.5 px-3 py-1.5 border border-red-500/20 text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded-lg text-xs font-bold transition-all`,title:e(`chat.clear_tooltip`,`Clear current session`),children:[(0,$.jsx)(ae,{className:`w-3.5 h-3.5`}),e(`chat.clear_session`,`Clear Link`)]})]}),(0,$.jsxs)(`div`,{className:`flex-1 w-full shogun-card overflow-hidden flex flex-col p-0`,children:[(0,$.jsxs)(`div`,{ref:x,className:`flex-1 overflow-y-auto p-6 space-y-6 scrollbar-hide scroll-smooth`,children:[t.length===0&&(0,$.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-3 opacity-50`,children:[(0,$.jsx)(z,{className:`w-12 h-12`}),(0,$.jsx)(`p`,{className:`text-sm italic tracking-wide`,children:e(`chat.terminal_empty`,`Terminal empty. Awaiting mission parameters.`)})]}),t.map((t,i)=>(0,$.jsxs)(`div`,{className:W(`flex gap-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,t.role===`user`?`flex-row-reverse`:`flex-row`),children:[(0,$.jsx)(`div`,{className:W(`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 border`,t.role===`user`?`bg-shogun-blue/10 border-shogun-blue/30 text-shogun-blue`:`bg-shogun-gold/10 border-shogun-gold/30 text-shogun-gold`),children:t.role===`user`?(0,$.jsx)(H,{className:`w-4 h-4`}):(0,$.jsx)(o,{className:`w-4 h-4`})}),(0,$.jsxs)(`div`,{className:W(`max-w-[70%] space-y-1 flex flex-col`,t.role===`user`?`items-end`:`items-start`),children:[(0,$.jsx)(`div`,{className:W(`p-4 rounded-2xl text-sm leading-relaxed whitespace-pre-wrap`,t.role===`user`?`bg-shogun-card border border-shogun-border text-shogun-text rounded-tr-none`:`bg-[#050508] border border-shogun-border text-shogun-gold rounded-tl-none font-mono`),children:t.role===`shogun`&&t.content===``&&(!t.attachments||t.attachments.length===0)?(0,$.jsx)(`div`,{className:`flex items-center gap-2 py-1`,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-cyan-400 animate-pulse`}),(0,$.jsx)(`span`,{className:`text-xs text-cyan-400/80 font-mono animate-pulse`,children:d})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-shogun-gold/70 animate-bounce [animation-delay:0ms]`}),(0,$.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-shogun-gold/70 animate-bounce [animation-delay:150ms]`}),(0,$.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-shogun-gold/70 animate-bounce [animation-delay:300ms]`})]})}):(0,$.jsxs)($.Fragment,{children:[t.content,t.attachments&&t.attachments.length>0&&(0,$.jsxs)(`div`,{className:W(`space-y-2`,t.content?`mt-3 border-t border-shogun-border/30 pt-3`:``),children:[t.attachments.map((e,t)=>{if(e.type===`image`)return(0,$.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-cyan-500/30 bg-black/30 max-w-2xl`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>N(e),className:`block w-full bg-[#070b14]`,children:(0,$.jsx)(`img`,{src:e.thumbnail_url,alt:e.caption||e.filename,className:`w-full max-h-[420px] object-contain hover:opacity-90 transition-opacity`})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 border-t border-cyan-500/20`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-[10px] font-bold text-cyan-300`,children:e.filename}),(0,$.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued uppercase`,children:[e.source,` · `,e.width,`×`,e.height,` · `,e.status]})]}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(`button`,{onClick:async()=>{(await fetch(`/api/v1/visual/${e.artifact_id}/pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pinned:!e.pinned})})).ok&&n(t=>t.map(t=>({...t,attachments:t.attachments?.map(t=>t.type===`image`&&t.artifact_id===e.artifact_id?{...t,pinned:!e.pinned}:t)})))},title:e.pinned?`Unpin`:`Pin beyond retention`,className:W(`p-1.5 rounded border`,e.pinned?`border-amber-400/40 text-amber-300`:`border-shogun-border text-shogun-subdued`),children:(0,$.jsx)(j,{className:`w-3.5 h-3.5`})}),(0,$.jsx)(`button`,{onClick:async()=>{window.confirm(`Delete this image artifact?`)&&(await fetch(`/api/v1/visual/${e.artifact_id}`,{method:`DELETE`})).ok&&n(t=>t.map(t=>({...t,attachments:t.attachments?.filter(t=>t.type!==`image`||t.artifact_id!==e.artifact_id)})))},title:`Delete image`,className:`p-1.5 rounded border border-red-500/30 text-red-400`,children:(0,$.jsx)(ae,{className:`w-3.5 h-3.5`})})]})]})]},t);if(e.type===`screenshot`)return(0,$.jsxs)(`div`,{className:`rounded-lg overflow-hidden border border-cyan-500/30 bg-black/40`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 bg-cyan-500/10 border-b border-cyan-500/20`,children:[(0,$.jsx)(c,{className:`w-3 h-3 text-cyan-400`}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-cyan-400 uppercase tracking-wider`,children:`Desktop Screenshot`})]}),(0,$.jsx)(`img`,{src:e.url,alt:e.description,className:`w-full max-h-[400px] object-contain cursor-pointer hover:opacity-90 transition-opacity`,onClick:()=>window.open(e.url,`_blank`)})]},t);if(e.type===`toolgate_confirm`)return(0,$.jsx)(De,{att:e,idx:t,setMessages:n},t);if(e.type===`action`){let n=e.action===`click`,r=e.action===`type`,i=e.action===`error`;return(0,$.jsxs)(`div`,{className:W(`flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-mono border`,i?`bg-red-500/10 border-red-500/30 text-red-400`:n?`bg-purple-500/10 border-purple-500/30 text-purple-300`:r?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-cyan-500/10 border-cyan-500/30 text-cyan-300`),children:[n&&(0,$.jsx)(k,{className:`w-3.5 h-3.5 shrink-0`}),r&&(0,$.jsx)(T,{className:`w-3.5 h-3.5 shrink-0`}),i&&(0,$.jsx)(m,{className:`w-3.5 h-3.5 shrink-0`}),!n&&!r&&!i&&(0,$.jsx)(O,{className:`w-3.5 h-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:e.detail})]},t)}return null}),s&&d&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-cyan-400/70 font-mono`,children:[(0,$.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-cyan-400 animate-pulse`}),(0,$.jsx)(`span`,{className:`animate-pulse`,children:d})]})]})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1 mt-1`,children:[(0,$.jsx)(`span`,{className:`text-[10px] text-shogun-subdued font-bold tracking-wider`,children:t.role===`user`?r:e(`chat.agent_label`,`SHOGUN`)}),(0,$.jsx)(`span`,{className:`text-[10px] text-shogun-subdued opacity-50`,children:t.timestamp}),t.channel===`telegram`&&(0,$.jsx)(`span`,{className:`text-[9px] text-sky-400/80 uppercase tracking-wider`,children:`Telegram`}),t.role===`shogun`&&(t.model||t.search||t.mode)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.mode&&(0,$.jsxs)(`div`,{className:W(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider`,t.mode===`fast`?`bg-emerald-500/10 border border-emerald-500/30 text-emerald-400`:t.mode===`governed`?`bg-amber-500/10 border border-amber-500/30 text-amber-400`:`bg-purple-500/10 border border-purple-500/30 text-purple-400`),children:[t.mode===`fast`?(0,$.jsx)(U,{className:`w-2.5 h-2.5`}):t.mode===`governed`?(0,$.jsx)(I,{className:`w-2.5 h-2.5`}):(0,$.jsx)(R,{className:`w-2.5 h-2.5`}),t.mode===`fast`?`Fast`:t.mode===`governed`?`Governed`:`Mission`]}),t.search?(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue`,children:[(0,$.jsx)(S,{className:`w-2.5 h-2.5`}),e(`chat.web_search`,`Web Search`)]}):t.model?(0,$.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider bg-shogun-card border border-shogun-border text-shogun-subdued`,children:[(0,$.jsx)(o,{className:`w-2.5 h-2.5`}),t.model]}):null]})]})]})]},i))]}),(0,$.jsxs)(`div`,{className:`p-4 bg-[#050508]/50 border-t border-shogun-border shrink-0`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1 mb-3`,children:[{id:`auto`,label:`Auto`,icon:L,color:`cyan`,desc:`Automatically selects the best mode`},{id:`fast`,label:`Fast Chat`,icon:U,color:`emerald`,desc:`Conversation only — no tools or memory`},{id:`governed`,label:`Governed`,icon:I,color:`amber`,desc:`Context-aware with memory (coming soon)`},{id:`mission`,label:`Mission`,icon:R,color:`purple`,desc:`Full agent orchestration with tools`}].map(({id:e,label:t,icon:n,color:r})=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ee(e),className:W(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-widest border transition-all`,h===e?`bg-${r}-500/15 border-${r}-500/40 text-${r}-400`:`bg-transparent border-shogun-border/50 text-shogun-subdued/60 hover:border-shogun-subdued hover:text-shogun-subdued`),style:h===e?{backgroundColor:r===`cyan`?`rgba(6,182,212,0.15)`:r===`emerald`?`rgba(16,185,129,0.15)`:r===`amber`?`rgba(245,158,11,0.15)`:`rgba(168,85,247,0.15)`,borderColor:r===`cyan`?`rgba(6,182,212,0.4)`:r===`emerald`?`rgba(16,185,129,0.4)`:r===`amber`?`rgba(245,158,11,0.4)`:`rgba(168,85,247,0.4)`,color:r===`cyan`?`rgb(34,211,238)`:r===`emerald`?`rgb(52,211,153)`:r===`amber`?`rgb(251,191,36)`:`rgb(192,132,252)`}:{},children:[(0,$.jsx)(n,{className:`w-3 h-3`}),t]},e))}),(0,$.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,$.jsx)(`input`,{ref:E,type:`file`,accept:`image/jpeg,image/png,image/webp,image/gif`,className:`hidden`,onChange:e=>void B(e.target.files?.[0])}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>E.current?.click(),disabled:ne||s,title:`Add image`,className:`absolute left-2 z-10 p-2 text-cyan-400 hover:bg-cyan-500/10 rounded-lg disabled:opacity-40`,children:(0,$.jsx)(se,{className:W(`w-5 h-5`,ne&&`animate-pulse`)})}),(0,$.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&V(),disabled:s,placeholder:s?e(`chat.placeholder_thinking`,`Shogun is thinking...`):h===`auto`?`Ask anything — Shogun routes automatically...`:h===`fast`?`Ask anything...`:h===`mission`?`Enter mission directive...`:`Ask with context...`,className:`w-full bg-shogun-card border border-shogun-border rounded-xl py-4 pl-14 pr-14 text-shogun-text placeholder:text-shogun-subdued focus:outline-none focus:border-shogun-blue focus:ring-1 focus:ring-shogun-blue/20 transition-all font-mono text-sm disabled:opacity-50 disabled:cursor-not-allowed`}),s?(0,$.jsx)(`button`,{onClick:K,className:`absolute right-2 p-2 bg-red-600 text-white rounded-lg hover:bg-red-500 transition-all active:scale-95 animate-pulse`,title:`Cancel operation`,children:(0,$.jsx)(Z,{className:`w-5 h-5 fill-current`})}):(0,$.jsx)(`button`,{onClick:V,disabled:!i.trim()&&D.length===0,className:`absolute right-2 p-2 bg-shogun-blue text-white rounded-lg hover:bg-shogun-blue/80 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed`,children:(0,$.jsx)(P,{className:`w-5 h-5`})})]}),D.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-2`,children:D.map(e=>(0,$.jsxs)(`div`,{className:`relative w-24 h-20 rounded-lg overflow-hidden border border-cyan-500/30 bg-black`,children:[(0,$.jsx)(`img`,{src:e.thumbnail_url,alt:e.filename,className:`w-full h-full object-cover`}),(0,$.jsx)(`button`,{onClick:()=>A(t=>t.filter(t=>t.artifact_id!==e.artifact_id)),className:`absolute right-1 top-1 p-1 rounded bg-black/80 text-white`,children:(0,$.jsx)(oe,{className:`w-3 h-3`})})]},e.artifact_id))}),(0,$.jsxs)(`div`,{className:`flex justify-between mt-3 px-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-4`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued flex items-center gap-1`,children:[(0,$.jsx)(z,{className:`w-3 h-3`}),` UTF-8`]}),(0,$.jsxs)(`button`,{onClick:J,className:`text-[10px] text-shogun-subdued flex items-center gap-1 underline cursor-pointer hover:text-shogun-blue transition-colors`,children:[(0,$.jsx)(w,{className:`w-3 h-3`}),e(`chat.view_history`,`View History`),` (`,_.length,` `,e(`chat.sessions`,`sessions`),`)`]})]}),(0,$.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:e(`chat.enter_to_send`,`Press Enter to send`)})]})]})]}),M&&(0,$.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center bg-black/90 p-6`,onClick:()=>N(null),children:(0,$.jsxs)(`div`,{className:`relative max-w-[95vw] max-h-[95vh]`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`img`,{src:M.content_url,alt:M.caption||M.filename,className:`max-w-[95vw] max-h-[88vh] object-contain rounded-xl border border-cyan-500/30`}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-shogun-subdued`,children:[(0,$.jsxs)(`span`,{children:[M.filename,` · `,M.width,`×`,M.height]}),(0,$.jsx)(`button`,{onClick:()=>N(null),className:`p-2 rounded border border-shogun-border`,children:(0,$.jsx)(oe,{className:`w-4 h-4`})})]})]})}),te&&(0,$.jsxs)(`div`,{className:`fixed inset-0 z-50 flex`,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>g(!1)}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 h-full w-full max-w-xl bg-shogun-bg border-l border-shogun-border flex flex-col shadow-2xl`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-5 border-b border-shogun-border shrink-0`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h3`,{className:`text-lg font-bold text-shogun-text flex items-center gap-2`,children:[(0,$.jsx)(w,{className:`w-5 h-5 text-shogun-gold`}),e(`chat.comms_history`,`Comms History`)]}),(0,$.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued mt-0.5`,children:[_.length,` `,e(`chat.archived_sessions`,`archived sessions`)]})]}),(0,$.jsx)(`button`,{onClick:()=>g(!1),className:`p-2 text-shogun-subdued hover:text-shogun-text hover:bg-shogun-card rounded-lg transition-all`,children:(0,$.jsx)(oe,{className:`w-5 h-5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2`,children:_.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-shogun-subdued space-y-3 opacity-50`,children:[(0,$.jsx)(w,{className:`w-10 h-10`}),(0,$.jsx)(`p`,{className:`text-sm italic`,children:e(`chat.no_history`,`No archived sessions found.`)})]}):_.map(t=>{let n=y===t.id,r=t.messages.find(e=>e.role===`user`)?.content||`(empty)`,i=t.messages.filter(e=>e.role===`user`).length;return(0,$.jsxs)(`div`,{className:`border border-shogun-border rounded-xl overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 p-3 cursor-pointer hover:bg-shogun-card/50 transition-colors`,onClick:()=>b(n?null:t.id),children:[n?(0,$.jsx)(u,{className:`w-4 h-4 text-shogun-subdued shrink-0`}):(0,$.jsx)(f,{className:`w-4 h-4 text-shogun-subdued shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-mono text-shogun-text truncate`,children:r}),(0,$.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[t.startedAt,` · `,i,` `,e(`chat.messages`,`messages`)]})]}),(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),Y(t)},className:`text-[10px] text-shogun-blue hover:text-shogun-gold font-bold uppercase tracking-wider shrink-0 px-2 py-1 border border-shogun-blue/30 rounded-lg transition-colors`,children:e(`chat.restore`,`RESTORE`)})]}),n&&(0,$.jsx)(`div`,{className:`border-t border-shogun-border bg-[#050508] p-3 space-y-2 max-h-64 overflow-y-auto`,children:t.messages.map((e,t)=>(0,$.jsxs)(`div`,{className:W(`text-xs`,e.role===`user`?`text-right`:`text-left`),children:[(0,$.jsx)(`span`,{className:W(`inline-block px-3 py-1.5 rounded-lg max-w-[85%] text-left`,e.role===`user`?`bg-shogun-blue/10 text-shogun-text border border-shogun-blue/20`:`bg-shogun-gold/5 text-shogun-gold border border-shogun-gold/10 font-mono`),children:e.content.length>120?e.content.slice(0,120)+`…`:e.content}),(0,$.jsx)(`div`,{className:`text-[9px] text-shogun-subdued mt-0.5 px-1`,children:e.timestamp})]},t))})]},t.id)})}),_.length>0&&(0,$.jsx)(`div`,{className:`p-4 border-t border-shogun-border shrink-0`,children:(0,$.jsx)(`button`,{onClick:()=>{localStorage.removeItem(ve),v([])},className:`w-full text-xs text-red-400/60 hover:text-red-400 transition-colors py-2 border border-red-400/10 hover:border-red-400/30 rounded-lg`,children:e(`chat.clear_all_history`,`CLEAR ALL HISTORY`)})})]})]})]})},ke=()=>{let{t:e}=G(),[t,n]=(0,Q.useState)(`chat`);return(0,$.jsxs)(`div`,{className:`flex flex-col w-full min-w-0 h-[calc(100vh-140px)] space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex justify-between items-center shrink-0`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`chat.title`,`Comms`),` `,(0,$.jsxs)(`span`,{className:`text-xs font-normal text-shogun-subdued bg-shogun-card px-2 py-1 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:[t===`chat`&&e(`chat.badge`,`Command Console`),t===`mail`&&e(`mail.badge`,`Mail Client`),t===`calendar`&&e(`calendar.badge`,`Calendar Board`),t===`files`&&`File Explorer`]})]}),(0,$.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`comms.subtitle`,`Chat · Mail · Calendar · Files`)})]})}),(0,$.jsx)(`div`,{className:`flex border-b border-shogun-border shrink-0`,children:[{id:`chat`,label:e(`chat.tab_chat`,`Chat`),icon:D},{id:`mail`,label:e(`chat.tab_mail`,`Mail`),icon:E},{id:`calendar`,label:e(`chat.tab_calendar`,`Calendar`),icon:s},{id:`files`,label:`Files`,icon:y}].map(({id:e,label:r,icon:i})=>(0,$.jsxs)(`button`,{onClick:()=>n(e),className:W(`px-6 py-3 text-sm font-bold uppercase tracking-widest transition-all relative flex items-center gap-2`,t===e?`text-shogun-blue`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,$.jsx)(i,{className:`w-4 h-4`}),r,t===e&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-blue shadow-[0_0_10px_rgba(74,140,199,0.5)]`})]},e))}),(0,$.jsxs)(`div`,{className:`flex-1 min-h-0`,children:[t===`chat`&&(0,$.jsx)(Oe,{}),t===`mail`&&(0,$.jsx)(ue,{}),t===`calendar`&&(0,$.jsx)(de,{}),t===`files`&&(0,$.jsx)(ge,{})]})]})};export{ke as Chat}; \ No newline at end of file diff --git a/frontend/dist/assets/Chat-Du0Wj6Wr.js b/frontend/dist/assets/Chat-Du0Wj6Wr.js new file mode 100644 index 0000000..45470b4 --- /dev/null +++ b/frontend/dist/assets/Chat-Du0Wj6Wr.js @@ -0,0 +1,41 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./archive-BOJnkAd3.js";import{t as n}from"./bot-BktkIwhq.js";import{t as r}from"./calendar-Cad5gZZR.js";import{t as i}from"./camera-BK7z_aNh.js";import{t as a}from"./check-DnxCktpz.js";import{t as o}from"./chevron-down-qQcy55Tl.js";import{t as s}from"./chevron-left-CoAjCl9c.js";import{t as c}from"./chevron-right-CVeYaFvJ.js";import{t as l}from"./chevron-up-BQBhWwJ7.js";import{t as u}from"./circle-alert-043xB2li.js";import{t as d}from"./circle-x-Dv8yz1YS.js";import{t as f}from"./clock-DQ9Dz1_z.js";import{t as p}from"./file-code-J1Snk2yW.js";import{t as m}from"./file-spreadsheet-ikcYZmJa.js";import{t as h}from"./file-text-CrD-Um8r.js";import{t as g}from"./folder-open-CZ39dYm6.js";import{n as ee,t as _}from"./image-2kgiS9WC.js";import{t as v}from"./keyboard-Cg2CjLNk.js";import{t as y}from"./mail-Ca9FQxut.js";import{t as b}from"./monitor-DrwnCrGM.js";import{t as x}from"./mouse-pointer-2-CgDYWfSe.js";import{t as S}from"./pen-line-BmYzOL4O.js";import{t as C}from"./pin-Trq2cvHx.js";import{t as te}from"./plus-Cxx0HjpF.js";import{t as w}from"./refresh-cw-Dm6S5UAJ.js";import{t as T}from"./save-CupVJLfi.js";import{t as E}from"./search-DuRUeriq.js";import{t as D}from"./send-BcKLBpfZ.js";import{t as O}from"./settings-DedojrI9.js";import{t as k}from"./shield-alert-DzWPVhkC.js";import{t as A}from"./sparkles-DyLIKWW0.js";import{t as j}from"./target-BgDPVmAm.js";import{t as M}from"./terminal-B0TmVXNb.js";import{t as ne}from"./trash-2-DqRUHXwV.js";import{t as N}from"./upload-NSOxRjZn.js";import{t as re}from"./zap-CQy--vuS.js";import{O as P,T as F,_ as I,a as ie,b as L,c as R,i as z,j as B,m as V,r as H,s as U,t as ae,u as W,v as oe,y as se}from"./index-Dy1E248t.js";import{t as G}from"./axios-BGmZl9Qd.js";var K=F(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),q=F(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),J=F(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),ce=F(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),le=F(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`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`}]]),Y=F(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),X=F(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ue=F(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Z=e(B(),1),Q=ae(),de=()=>{let e=P(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!0),[o,l]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(`INBOX`),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(0),[_,v]=(0,Z.useState)(1),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(!1),[O,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(``),[N,re]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(``),[L,R]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(``),[H,U]=(0,Z.useState)(!1),[ae,W]=(0,Z.useState)(``),[oe,se]=(0,Z.useState)(``),K=async()=>{try{let e=await G.get(`/api/v1/channels/email/account`);r(e.data.data)}catch{r(null)}finally{a(!1)}};(0,Z.useEffect)(()=>{K()},[]),(0,Z.useEffect)(()=>{n?.is_active&&n.perm_read_mail&&q()},[n]),(0,Z.useEffect)(()=>{n?.is_active&&n.perm_read_mail&&J()},[n,d,_]);let q=async()=>{try{let e=await G.get(`/api/v1/channels/email/account/folders`);l(e.data.data||[])}catch(e){console.error(`Failed to fetch folders`,e)}},J=async()=>{x(!0);try{let e=await G.get(`/api/v1/channels/email/account/messages`,{params:{folder:d,page:_,per_page:15}});m(e.data.data.messages||[]),g(e.data.data.total||0)}catch(e){console.error(`Failed to fetch messages`,e)}finally{x(!1)}},ce=async e=>{E(!0);try{let t=await G.get(`/api/v1/channels/email/account/messages/${e}`,{params:{folder:d}});C(t.data.data),m(t=>t.map(t=>t.uid===e?{...t,is_read:!0}:t))}catch(e){console.error(`Failed to load message body`,e)}finally{E(!1)}},Y=async(e,t)=>{t.stopPropagation();try{await G.post(`/api/v1/channels/email/account/messages/${e}/unread`,null,{params:{folder:d}}),m(t=>t.map(t=>t.uid===e?{...t,is_read:!1}:t)),S?.uid===e&&C(e=>e?{...e,is_read:!1}:null)}catch(e){console.error(`Failed to mark unread`,e)}},X=async(e,t)=>{if(t&&t.stopPropagation(),n?.perm_delete_mail)try{await G.delete(`/api/v1/channels/email/account/messages/${e}`,{params:{folder:d}}),S?.uid===e&&C(null),J()}catch(e){console.error(`Failed to delete message`,e)}},de=async e=>{if(e.preventDefault(),n?.perm_send_mail){U(!0),W(``),se(``);try{await G.post(`/api/v1/channels/email/account/send`,{to_address:j,cc_address:N,bcc_address:F,subject:L,body:B}),se(`Email sent successfully!`),M(``),re(``),I(``),R(``),V(``),await q(),await J(),setTimeout(()=>{A(!1),se(``)},1500)}catch(e){W(e.response?.data?.detail||`Failed to send email.`)}finally{U(!1)}}},fe=e=>{let n=e.toLowerCase();return n===`inbox`?(0,Q.jsx)(le,{className:`w-4 h-4`}):n.includes(`trash`)||n.includes(`bin`)?(0,Q.jsx)(ue,{className:`w-4 h-4`}):n.includes(`archive`)?(0,Q.jsx)(t,{className:`w-4 h-4`}):n.includes(`sent`)?(0,Q.jsx)(D,{className:`w-4 h-4`}):(0,Q.jsx)(ee,{className:`w-4 h-4`})},pe=Math.ceil(h/15);return i?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-4`,children:[(0,Q.jsx)(w,{className:`w-8 h-8 animate-spin text-shogun-blue`}),(0,Q.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:`Synchronizing Mail Client…`})]}):!n||!n.is_active?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,Q.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-blue/10 flex items-center justify-center text-shogun-blue border border-shogun-blue/30 mb-4 animate-pulse`,children:(0,Q.jsx)(y,{className:`w-8 h-8`})}),(0,Q.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`No Mail Account Connected`}),(0,Q.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed mb-6`,children:`To receive, compose, and organize mail, configure your provider in the Katana settings.`}),(0,Q.jsx)(`button`,{onClick:()=>{e(`/katana`)},className:`px-5 py-2.5 bg-shogun-blue hover:bg-shogun-blue/90 text-white text-xs font-bold rounded-lg uppercase tracking-wider transition-all`,children:`Go to Katana Settings`})]}):n.perm_read_mail?(0,Q.jsxs)(`div`,{className:`h-[calc(100vh-270px)] flex flex-col min-h-0 bg-[#050508]/30 rounded-2xl border border-shogun-border/40 overflow-hidden backdrop-blur-md`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center px-6 py-4 bg-[#0a0a0f]/60 border-b border-shogun-border/40 shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:`px-2.5 py-1 rounded bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue text-[10px] font-bold uppercase`,children:n.provider}),(0,Q.jsx)(`span`,{className:`text-xs text-shogun-subdued font-medium`,children:n.email_address})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`button`,{onClick:()=>{q(),J()},className:`p-2 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 text-shogun-subdued hover:text-shogun-text rounded-lg transition-all`,title:`Refresh mail`,children:(0,Q.jsx)(w,{className:z(`w-4 h-4`,b&&`animate-spin`)})}),n.perm_send_mail&&(0,Q.jsxs)(`button`,{onClick:()=>A(!0),className:`flex items-center gap-1.5 px-4 py-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all`,children:[(0,Q.jsx)(te,{className:`w-4 h-4`}),` Compose`]})]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 flex min-h-0 divide-x divide-shogun-border/30`,children:[(0,Q.jsxs)(`div`,{className:`w-48 bg-[#0a0a0f]/30 p-4 space-y-1.5 overflow-y-auto shrink-0`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block px-2 mb-2`,children:`Folders`}),o.length===0?(0,Q.jsx)(`div`,{className:`text-[11px] text-shogun-subdued italic px-2`,children:`No folders loaded.`}):o.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>{f(e),v(1),C(null)},className:z(`w-full flex items-center gap-2.5 px-3 py-2 rounded-lg text-xs font-medium transition-all text-left`,d===e?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20`:`text-shogun-subdued hover:text-shogun-text hover:bg-shogun-card/40`),children:[fe(e),(0,Q.jsx)(`span`,{className:`truncate`,children:e})]},e))]}),(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-[#07070a]/40 divide-y divide-shogun-border/30`,children:[(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:b?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-3 opacity-55`,children:[(0,Q.jsx)(w,{className:`w-6 h-6 animate-spin text-shogun-blue`}),(0,Q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider`,children:`Fetching messages…`})]}):p.length===0?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-2 opacity-50 p-6 text-center`,children:[(0,Q.jsx)(y,{className:`w-10 h-10`}),(0,Q.jsxs)(`p`,{className:`text-xs italic`,children:[`Folder `,d,` is empty.`]})]}):(0,Q.jsx)(`div`,{className:`divide-y divide-shogun-border/25`,children:p.map(e=>(0,Q.jsxs)(`div`,{onClick:()=>ce(e.uid),className:z(`p-4 cursor-pointer hover:bg-shogun-card/30 transition-all border-l-2 flex flex-col gap-1.5 relative`,S?.uid===e.uid?`bg-shogun-blue/5 border-l-shogun-blue`:e.is_read?`border-l-transparent`:`border-l-shogun-gold bg-shogun-gold/[0.02]`),children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Q.jsx)(`span`,{className:z(`text-xs truncate max-w-[70%]`,e.is_read?`text-shogun-text/80 font-medium`:`text-shogun-gold font-bold`),children:e.from_address}),(0,Q.jsx)(`span`,{className:`text-[10px] text-shogun-subdued shrink-0 font-mono`,children:e.date.split(`,`)[1]?.trim()?.slice(0,11)||e.date})]}),(0,Q.jsx)(`p`,{className:z(`text-xs truncate`,e.is_read?`text-shogun-text/90`:`text-shogun-text font-bold`),children:e.subject||`(No Subject)`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-shogun-subdued truncate max-w-full leading-normal`,children:e.body_preview||`No preview available`})]},e.uid))})}),pe>1&&(0,Q.jsxs)(`div`,{className:`flex justify-between items-center px-4 py-3 bg-[#0a0a0f]/60 shrink-0 border-t border-shogun-border/30`,children:[(0,Q.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued font-bold`,children:[`Page `,_,` of `,pe,` (`,h,` messages)`]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`button`,{disabled:_<=1,onClick:()=>v(_-1),className:`p-1 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 rounded disabled:opacity-40 disabled:hover:bg-shogun-card transition-all`,children:(0,Q.jsx)(s,{className:`w-4 h-4 text-shogun-text`})}),(0,Q.jsx)(`button`,{disabled:_>=pe,onClick:()=>v(_+1),className:`p-1 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 rounded disabled:opacity-40 disabled:hover:bg-shogun-card transition-all`,children:(0,Q.jsx)(c,{className:`w-4 h-4 text-shogun-text`})})]})]})]}),(0,Q.jsx)(`div`,{className:`w-1/2 flex flex-col min-w-0 bg-[#050508]/40 overflow-hidden`,children:T?(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-shogun-subdued space-y-4`,children:[(0,Q.jsx)(w,{className:`w-7 h-7 animate-spin text-shogun-gold`}),(0,Q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider font-bold`,children:`Loading full message payload…`})]}):S?(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,Q.jsxs)(`div`,{className:`p-5 border-b border-shogun-border/30 bg-[#0a0a0f]/40 space-y-3 shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-start gap-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text leading-snug`,children:S.subject||`(No Subject)`}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5 shrink-0`,children:[(0,Q.jsx)(`button`,{onClick:e=>Y(S.uid,e),className:`px-2 py-1 text-[10px] font-bold border border-shogun-border text-shogun-subdued hover:text-shogun-text rounded hover:bg-shogun-card/40 transition-all`,children:`Mark Unread`}),n.perm_delete_mail&&(0,Q.jsx)(`button`,{onClick:()=>X(S.uid),className:`p-1 border border-red-500/20 text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded transition-all`,title:`Delete Email`,children:(0,Q.jsx)(ne,{className:`w-3.5 h-3.5`})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-shogun-subdued font-semibold w-10 shrink-0`,children:`From:`}),(0,Q.jsx)(`span`,{className:`text-shogun-text font-mono truncate`,children:S.from_address})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-shogun-subdued font-semibold w-10 shrink-0`,children:`To:`}),(0,Q.jsx)(`span`,{className:`text-shogun-text font-mono truncate`,children:S.to_address})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-shogun-subdued font-semibold w-10 shrink-0`,children:`Date:`}),(0,Q.jsx)(`span`,{className:`text-shogun-subdued font-mono truncate`,children:S.date})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 p-5 overflow-y-auto min-h-0 bg-[#030305]/80 space-y-4`,children:[S.body_html?(0,Q.jsx)(`div`,{className:`w-full h-full min-h-[300px] border border-shogun-border/20 rounded-xl overflow-hidden bg-white/5`,children:(0,Q.jsx)(`iframe`,{title:`email-body`,sandbox:`allow-popups allow-popups-to-escape-sandbox`,srcDoc:` + + + + + + ${S.body_html} + + + `,className:`w-full h-full border-none`})}):(0,Q.jsx)(`div`,{className:`text-xs text-shogun-text font-mono whitespace-pre-wrap leading-relaxed bg-[#0a0a0f]/80 p-4 border border-shogun-border/20 rounded-xl`,children:S.body_text||`(Empty body)`}),S.attachments&&S.attachments.length>0&&(0,Q.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/30 space-y-2`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:`Attachments`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-2`,children:S.attachments.map(e=>(0,Q.jsx)(`div`,{className:`p-3 rounded-lg border border-shogun-border/20 bg-shogun-card flex items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-shogun-text truncate font-medium`,children:e.filename}),(0,Q.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[e.content_type,` · `,(e.size/1024).toFixed(1),` KB`]})]})},e.filename))})]})]})]}):(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-shogun-subdued space-y-2 opacity-50 p-6 text-center`,children:[(0,Q.jsx)(y,{className:`w-12 h-12`}),(0,Q.jsx)(`p`,{className:`text-xs italic`,children:`Select an email to view details.`})]})})]}),O&&(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/70 backdrop-blur-md`,onClick:()=>{H||A(!1)}}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-lg bg-[#09090e] border border-shogun-border rounded-2xl flex flex-col shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center px-5 py-3 border-b border-shogun-border/30 bg-[#0a0a0f]/40`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest flex items-center gap-2`,children:[(0,Q.jsx)(D,{className:`w-4 h-4 text-shogun-blue`}),`Compose Directive`]}),(0,Q.jsx)(`button`,{disabled:H,onClick:()=>A(!1),className:`p-1 text-shogun-subdued hover:text-shogun-text transition-colors disabled:opacity-40`,children:(0,Q.jsx)(ie,{className:`w-5 h-5`})})]}),(0,Q.jsxs)(`form`,{onSubmit:de,className:`p-4 flex-1 flex flex-col gap-3 overflow-y-auto max-h-[55vh]`,children:[ae&&(0,Q.jsxs)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/20 text-red-500 rounded-lg text-xs font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`w-4 h-4 shrink-0`}),(0,Q.jsx)(`span`,{children:ae})]}),oe&&(0,Q.jsxs)(`div`,{className:`p-3 bg-green-500/10 border border-green-500/20 text-green-500 rounded-lg text-xs font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`w-4 h-4 shrink-0`}),(0,Q.jsx)(`span`,{children:oe})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`To *`}),(0,Q.jsx)(`input`,{type:`email`,required:!0,placeholder:`recipient@domain.com`,value:j,onChange:e=>M(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Cc`}),(0,Q.jsx)(`input`,{type:`text`,placeholder:`cc@domain.com, cc2@domain.com`,value:N,onChange:e=>re(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Bcc`}),(0,Q.jsx)(`input`,{type:`text`,placeholder:`bcc@domain.com`,value:F,onChange:e=>I(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Subject *`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,placeholder:`Enter subject title`,value:L,onChange:e=>R(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Body *`}),(0,Q.jsx)(`textarea`,{required:!0,rows:4,placeholder:`Write message contents...`,value:B,onChange:e=>V(e.target.value),className:`w-full flex-1 min-h-[80px] bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono resize-y`})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:H||!j||!L||!B,className:`w-full flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm uppercase tracking-wider transition-all mt-2`,children:H?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(w,{className:`w-4 h-4 animate-spin`}),` Transmitting Directive…`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{className:`w-4 h-4`}),` Transmit Email`]})})]})]})]})]}):(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,Q.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-400/10 flex items-center justify-center text-red-400 border border-red-400/30 mb-4`,children:(0,Q.jsx)(k,{className:`w-8 h-8`})}),(0,Q.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`Read Permission Denied`}),(0,Q.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed`,children:`The "Read Mail" permission is disabled for this account in Katana settings. Toggle this permission ON to view your inbox.`})]})},fe=()=>{let e=P(),[t,n]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(!0),[o,l]=(0,Z.useState)(new Date),[d,p]=(0,Z.useState)(`month`),[m,h]=(0,Z.useState)([]),[g,ee]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(!1),[x,C]=(0,Z.useState)(`create`),[T,E]=(0,Z.useState)(null),[D,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(``),[N,re]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(``),[L,R]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(!1),[ae,W]=(0,Z.useState)(``),oe=async()=>{try{let e=await G.get(`/api/v1/channels/email/account`);n(e.data.data)}catch{n(null)}finally{a(!1)}};(0,Z.useEffect)(()=>{oe()},[]);let se=()=>{let e=new Date(o),t=new Date(o);if(d===`month`){e.setDate(1);let n=e.getDay();e.setDate(e.getDate()-n),e.setHours(0,0,0,0),t.setMonth(t.getMonth()+1),t.setDate(0);let r=6-t.getDay();t.setDate(t.getDate()+r),t.setHours(23,59,59,999)}else if(d===`week`){let n=e.getDay();e.setDate(e.getDate()-n),e.setHours(0,0,0,0),t.setDate(e.getDate()+6),t.setHours(23,59,59,999)}else e.setHours(0,0,0,0),t.setHours(23,59,59,999);return{start:e,end:t}},K=async()=>{if(!t?.is_active||!t.perm_read_calendar||t.calendar_provider===`none`)return;ee(!0),v(``);let{start:e,end:n}=se();try{let t=await G.get(`/api/v1/channels/calendar/events`,{params:{start:e.toISOString(),end:n.toISOString()}});h(t.data.data||[])}catch(e){console.error(`Failed to fetch events`,e),v(e.response?.data?.detail||`Failed to sync calendar events.`)}finally{ee(!1)}};(0,Z.useEffect)(()=>{t?.is_active&&t.perm_read_calendar&&K()},[t,o,d]);let q=()=>{let e=new Date(o);d===`month`?e.setMonth(e.getMonth()-1):d===`week`?e.setDate(e.getDate()-7):e.setDate(e.getDate()-1),l(e)},J=()=>{let e=new Date(o);d===`month`?e.setMonth(e.getMonth()+1):d===`week`?e.setDate(e.getDate()+7):e.setDate(e.getDate()+1),l(e)},ce=()=>{l(new Date)},le=e=>{let t=e.getTimezoneOffset()*6e4;return new Date(e.getTime()-t).toISOString().slice(0,16)},X=e=>{if(!t?.perm_create_events)return;W(``),C(`create`),A(``),I(``),R(``),V(!1);let n=e?new Date(e):new Date;e?n.setHours(9,0,0,0):(n.setMinutes(0,0,0),n.setHours(n.getHours()+1));let r=new Date(n);r.setHours(r.getHours()+1),M(le(n)),re(le(r)),b(!0)},ue=e=>{E(e),C(`view`),A(e.title),M(le(new Date(e.start))),re(le(new Date(e.end))),I(e.location||``),R(e.description||``),V(e.all_day||!1),W(``),b(!0)},de=()=>{t?.perm_edit_events&&C(`edit`)},fe=async e=>{e.preventDefault(),W(``);let t=new Date(j),n=new Date(N);if(n<=t){W(`End date/time must be after the start date/time.`);return}U(!0);try{let e={title:D,start:t.toISOString(),end:n.toISOString(),location:F||null,description:L||null,all_day:B};x===`create`?await G.post(`/api/v1/channels/calendar/events`,e):x===`edit`&&T&&await G.patch(`/api/v1/channels/calendar/events/${T.id}`,e),b(!1),K()}catch(e){console.error(`Failed to save event`,e),W(e.response?.data?.detail||`Failed to save calendar event.`)}finally{U(!1)}},pe=async()=>{if(!(!T||!t?.perm_delete_events)&&window.confirm(`Are you sure you want to delete this event?`)){U(!0),W(``);try{await G.delete(`/api/v1/channels/calendar/events/${T.id}`),b(!1),K()}catch(e){console.error(`Failed to delete event`,e),W(e.response?.data?.detail||`Failed to delete event.`)}finally{U(!1)}}},me=()=>{let e=o.getFullYear(),t=o.getMonth(),n=new Date(e,t,1).getDay(),r=new Date(e,t+1,0).getDate(),i=new Date(e,t,0).getDate(),a=[];for(let r=n-1;r>=0;r--){let n=new Date(e,t-1,i-r);a.push({date:n,isCurrentMonth:!1,key:`prev-${r}`})}for(let n=1;n<=r;n++){let r=new Date(e,t,n);a.push({date:r,isCurrentMonth:!0,key:`curr-${n}`})}let s=42-a.length;for(let n=1;n<=s;n++){let r=new Date(e,t+1,n);a.push({date:r,isCurrentMonth:!1,key:`next-${n}`})}return a},he=()=>{let e=new Date(o),t=e.getDay();e.setDate(e.getDate()-t);let n=[];for(let t=0;t<7;t++){let r=new Date(e);r.setDate(e.getDate()+t),n.push(r)}return n},ge=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),$=e=>m.filter(t=>{let n=new Date(t.start);return ge(n,e)}).sort((e,t)=>new Date(e.start).getTime()-new Date(t.start).getTime());return i?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-4`,children:[(0,Q.jsx)(w,{className:`w-8 h-8 animate-spin text-shogun-blue`}),(0,Q.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:`Synchronizing Calendar Board…`})]}):!t||!t.is_active||t.calendar_provider===`none`?(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,Q.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-shogun-blue/10 flex items-center justify-center text-shogun-blue border border-shogun-blue/30 mb-4 animate-pulse`,children:(0,Q.jsx)(r,{className:`w-8 h-8`})}),(0,Q.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`No Calendar Account Connected`}),(0,Q.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed mb-6`,children:`To manage schedules and CalDAV events, configure your Calendar provider in Katana settings.`}),(0,Q.jsx)(`button`,{onClick:()=>{e(`/katana`)},className:`px-5 py-2.5 bg-shogun-blue hover:bg-shogun-blue/90 text-white text-xs font-bold rounded-lg uppercase tracking-wider transition-all`,children:`Go to Katana Settings`})]}):t.perm_read_calendar?(0,Q.jsxs)(`div`,{className:`h-[calc(100vh-270px)] flex flex-col min-h-0 bg-[#050508]/30 rounded-2xl border border-shogun-border/40 overflow-hidden backdrop-blur-md`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between items-stretch sm:items-center px-6 py-4 bg-[#0a0a0f]/60 border-b border-shogun-border/40 gap-3 shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center border border-shogun-border rounded-lg bg-shogun-card overflow-hidden`,children:[(0,Q.jsx)(`button`,{onClick:q,className:`p-2 text-shogun-subdued hover:text-shogun-text hover:bg-white/5 transition-all`,children:(0,Q.jsx)(s,{className:`w-4 h-4`})}),(0,Q.jsx)(`button`,{onClick:ce,className:`px-3 py-1.5 text-xs font-bold uppercase border-x border-shogun-border text-shogun-subdued hover:text-shogun-text hover:bg-white/5 transition-all`,children:`Today`}),(0,Q.jsx)(`button`,{onClick:J,className:`p-2 text-shogun-subdued hover:text-shogun-text hover:bg-white/5 transition-all`,children:(0,Q.jsx)(c,{className:`w-4 h-4`})})]}),(0,Q.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text font-mono truncate`,children:(()=>{if(d===`month`)return o.toLocaleString(`default`,{month:`long`,year:`numeric`});if(d===`week`){let e=he(),t=e[0],n=e[6];return t.getMonth()===n.getMonth()?`${t.toLocaleString(`default`,{month:`long`})} ${t.getFullYear()}`:t.getFullYear()===n.getFullYear()?`${t.toLocaleString(`default`,{month:`short`})} – ${n.toLocaleString(`default`,{month:`short`})} ${t.getFullYear()}`:`${t.toLocaleString(`default`,{month:`short`,year:`numeric`})} – ${n.toLocaleString(`default`,{month:`short`,year:`numeric`})}`}else return o.toLocaleDateString(`default`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})})()})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[_&&(0,Q.jsxs)(`div`,{className:`hidden lg:flex items-center gap-1.5 px-3 py-1 bg-red-500/10 border border-red-500/20 text-red-400 rounded-md text-[10px] font-bold`,children:[(0,Q.jsx)(u,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(`span`,{children:`Sync Error`})]}),(0,Q.jsx)(`button`,{onClick:K,className:`p-2 border border-shogun-border bg-shogun-card hover:bg-shogun-card/80 text-shogun-subdued hover:text-shogun-text rounded-lg transition-all`,title:`Refresh events`,children:(0,Q.jsx)(w,{className:z(`w-4 h-4`,g&&`animate-spin`)})}),(0,Q.jsx)(`div`,{className:`flex border border-shogun-border rounded-lg bg-shogun-card p-0.5`,children:[`month`,`week`,`day`].map(e=>(0,Q.jsx)(`button`,{onClick:()=>p(e),className:z(`px-3 py-1 rounded-md text-xs font-bold uppercase tracking-wider transition-all`,d===e?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20`:`text-shogun-subdued hover:text-shogun-text`),children:e},e))}),(0,Q.jsxs)(`button`,{onClick:()=>e(`/shogun?tab=operations`),className:`flex items-center gap-1.5 px-4 py-2 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-500 hover:to-indigo-500 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all border border-purple-500/20 shadow-[0_0_10px_rgba(147,51,234,0.3)] hover:shadow-[0_0_15px_rgba(147,51,234,0.5)]`,children:[(0,Q.jsx)(te,{className:`w-4 h-4`}),` Create Task`]}),t.perm_create_events&&(0,Q.jsxs)(`button`,{onClick:()=>X(),className:`flex items-center gap-1.5 px-4 py-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all`,children:[(0,Q.jsx)(te,{className:`w-4 h-4`}),` Add Event`]})]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-hidden relative flex flex-col bg-[#07070a]/20`,children:[g&&(0,Q.jsxs)(`div`,{className:`absolute inset-0 bg-[#050508]/60 backdrop-blur-[2px] z-20 flex flex-col items-center justify-center text-shogun-subdued space-y-2`,children:[(0,Q.jsx)(w,{className:`w-6 h-6 animate-spin text-shogun-blue`}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-widest font-bold`,children:`Querying CalDAV Node…`})]}),d===`month`&&(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,Q.jsx)(`div`,{className:`grid grid-cols-7 border-b border-shogun-border/30 bg-[#0a0a0f]/40 text-center py-2 shrink-0`,children:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`].map(e=>(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e},e))}),(0,Q.jsx)(`div`,{className:`flex-1 grid grid-cols-7 grid-rows-6 divide-x divide-y divide-shogun-border/20 min-h-0 overflow-y-auto`,children:me().map(({date:e,isCurrentMonth:n,key:r})=>{let i=$(e),a=ge(e,new Date);return(0,Q.jsxs)(`div`,{onClick:()=>{t.perm_create_events?X(e):(p(`day`),l(e))},className:z(`min-h-0 p-2 flex flex-col gap-1 transition-all cursor-pointer select-none relative group`,n?`bg-transparent`:`bg-[#07070a]/10 opacity-40`,a?`bg-shogun-blue/[0.02]`:`hover:bg-shogun-card/15`),children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center shrink-0`,children:[(0,Q.jsx)(`span`,{className:z(`text-xs font-mono font-bold w-6 h-6 flex items-center justify-center rounded-full transition-all`,a?`bg-shogun-blue text-white shadow-[0_0_10px_rgba(74,140,199,0.5)]`:`text-shogun-text group-hover:text-shogun-blue`),children:e.getDate()}),i.length>0&&(0,Q.jsx)(`span`,{className:`text-[9px] font-bold text-shogun-subdued bg-shogun-card border border-shogun-border/40 px-1.5 py-0.5 rounded font-mono`,children:i.length})]}),(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col gap-1 overflow-y-auto scrollbar-hide py-1`,children:[i.slice(0,3).map(e=>(0,Q.jsxs)(`div`,{onClick:t=>{t.stopPropagation(),ue(e)},className:z(`px-2 py-1 rounded text-[10px] font-medium truncate border transition-all text-left`,e.color===`cron_job`?`bg-gradient-to-r from-purple-950/40 to-indigo-950/40 border-purple-500/30 text-purple-200 hover:from-purple-900/50 hover:to-indigo-900/50 shadow-[0_0_8px_rgba(168,85,247,0.15)]`:e.all_day?`bg-shogun-gold/15 border-shogun-gold/30 text-shogun-gold hover:bg-shogun-gold/25`:`bg-shogun-blue/15 border-shogun-blue/30 text-shogun-blue hover:bg-shogun-blue/25`),title:`${e.title} (${new Date(e.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})`,children:[!e.all_day&&(0,Q.jsx)(`span`,{className:`font-mono opacity-85 mr-1 font-bold`,children:new Date(e.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1})}),e.title]},e.id)),i.length>3&&(0,Q.jsxs)(`div`,{className:`text-[9px] font-bold text-shogun-subdued italic px-1`,children:[`+ `,i.length-3,` more`]})]})]},r)})})]}),d===`week`&&(0,Q.jsx)(`div`,{className:`flex-1 flex divide-x divide-shogun-border/20 min-h-0 overflow-x-auto`,children:he().map((e,n)=>{let r=$(e),i=ge(e,new Date);return(0,Q.jsxs)(`div`,{className:z(`flex-1 min-w-[140px] flex flex-col min-h-0 bg-[#07070a]/10`,i&&`bg-shogun-blue/[0.01] border-x border-shogun-blue/10`),children:[(0,Q.jsxs)(`div`,{className:z(`p-3 border-b border-shogun-border/30 bg-[#0a0a0f]/40 text-center shrink-0 flex flex-col items-center justify-center gap-0.5`,i&&`border-b-shogun-blue/50`),children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-wider`,children:e.toLocaleDateString(`default`,{weekday:`short`})}),(0,Q.jsx)(`span`,{className:z(`text-sm font-mono font-bold w-7 h-7 flex items-center justify-center rounded-full`,i?`bg-shogun-blue text-white shadow-[0_0_8px_rgba(74,140,199,0.5)]`:`text-shogun-text`),children:e.getDate()})]}),(0,Q.jsx)(`div`,{onClick:()=>{t.perm_create_events&&X(e)},className:`flex-1 p-3 overflow-y-auto space-y-2.5 cursor-pointer hover:bg-shogun-card/[0.03] transition-colors`,children:r.length===0?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,Q.jsx)(`span`,{className:`text-[9px] text-shogun-subdued font-bold tracking-wider uppercase opacity-35`,children:`No Events`})}):r.map(e=>(0,Q.jsxs)(`div`,{onClick:t=>{t.stopPropagation(),ue(e)},className:z(`p-2.5 rounded-xl border transition-all text-left flex flex-col gap-1 shadow-lg hover:scale-[1.02]`,e.color===`cron_job`?`bg-gradient-to-br from-purple-950/30 to-indigo-950/30 border-purple-500/40 text-purple-200 hover:bg-purple-900/40 hover:border-purple-400 shadow-[0_0_12px_rgba(168,85,247,0.2)]`:e.all_day?`bg-shogun-gold/10 border-shogun-gold/30 text-shogun-gold hover:bg-shogun-gold/15`:`bg-shogun-blue/10 border-shogun-blue/30 text-shogun-blue hover:bg-shogun-blue/15`),children:[(0,Q.jsx)(`span`,{className:`text-xs font-bold leading-snug line-clamp-2`,children:e.title}),(0,Q.jsxs)(`span`,{className:`text-[9px] font-mono opacity-80 flex items-center gap-1 font-bold`,children:[(0,Q.jsx)(f,{className:`w-2.5 h-2.5`}),e.all_day?`All Day`:`${new Date(e.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1})} - ${new Date(e.end).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1})}`]}),e.location&&(0,Q.jsxs)(`span`,{className:`text-[9px] opacity-80 flex items-center gap-1 truncate font-medium`,children:[(0,Q.jsx)(Y,{className:`w-2.5 h-2.5 shrink-0`}),e.location]})]},e.id))})]},n)})}),d===`day`&&(0,Q.jsx)(`div`,{className:`flex-1 flex min-h-0 divide-x divide-shogun-border/20`,children:(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between border-b border-shogun-border/20 pb-3 shrink-0`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Day Agenda`}),(0,Q.jsxs)(`span`,{className:`text-xs text-shogun-subdued font-bold font-mono`,children:[$(o).length,` Events scheduled`]})]}),$(o).length===0?(0,Q.jsxs)(`div`,{className:`h-48 flex flex-col items-center justify-center text-shogun-subdued space-y-2 opacity-50`,children:[(0,Q.jsx)(r,{className:`w-8 h-8`}),(0,Q.jsx)(`p`,{className:`text-xs italic`,children:`No directives scheduled for this sector.`})]}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:$(o).map(n=>(0,Q.jsxs)(`div`,{onClick:()=>ue(n),className:z(`p-4 rounded-2xl border transition-all cursor-pointer hover:bg-shogun-card/45 flex flex-col md:flex-row md:items-center justify-between gap-4`,n.color===`cron_job`?`bg-gradient-to-r from-purple-950/20 to-indigo-950/20 border-purple-500/30 text-purple-200 hover:from-purple-950/35 hover:to-indigo-950/35`:n.all_day?`bg-shogun-gold/5 border-shogun-gold/20 text-shogun-gold`:`bg-shogun-blue/5 border-shogun-blue/20 text-shogun-blue`),children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5 flex-1 min-w-0`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text leading-snug`,children:n.title}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5 text-[11px] text-shogun-subdued font-medium`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(f,{className:`w-3 h-3 text-shogun-blue`}),n.all_day?`All Day`:`${new Date(n.start).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})} - ${new Date(n.end).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`]}),n.location&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 truncate max-w-xs`,children:[(0,Q.jsx)(Y,{className:`w-3 h-3 text-shogun-gold`}),n.location]})]}),n.description&&(0,Q.jsx)(`p`,{className:`text-xs text-shogun-subdued font-mono truncate max-w-2xl mt-1.5 opacity-90`,children:n.description})]}),(0,Q.jsx)(`div`,{className:`flex gap-2 self-end md:self-center shrink-0`,children:n.color===`cron_job`?(0,Q.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(`/shogun?tab=operations`)},className:`px-3 py-1.5 text-[10px] font-bold border border-purple-500/30 text-purple-300 hover:text-purple-200 hover:border-purple-500/50 rounded-lg hover:bg-purple-500/10 transition-all`,children:`Configure`}):(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),ue(n),de()},disabled:!t.perm_edit_events,className:`px-3 py-1.5 text-[10px] font-bold border border-shogun-border text-shogun-subdued hover:text-shogun-text rounded-lg hover:bg-white/5 transition-all disabled:opacity-40`,children:`Edit`})})]},n.id))})]})})]}),y&&(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/75 backdrop-blur-md`,onClick:()=>{H||b(!1)}}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-lg bg-[#09090e] border border-shogun-border rounded-2xl flex flex-col shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center p-5 border-b border-shogun-border/30 bg-[#0a0a0f]/40`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest flex items-center gap-2`,children:[(0,Q.jsx)(r,{className:`w-4 h-4 text-shogun-blue`}),x===`create`&&`Schedule Event`,x===`view`&&`Event Parameters`,x===`edit`&&`Edit Event`]}),(0,Q.jsx)(`button`,{disabled:H,onClick:()=>b(!1),className:`p-1 text-shogun-subdued hover:text-shogun-text transition-colors disabled:opacity-40`,children:(0,Q.jsx)(ie,{className:`w-5 h-5`})})]}),x===`view`&&T?(0,Q.jsxs)(`div`,{className:`p-6 space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-bold text-shogun-text leading-snug`,children:T.title}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2.5 text-xs text-shogun-subdued mt-2 font-medium`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(f,{className:`w-4 h-4 text-shogun-blue`}),(0,Q.jsx)(`span`,{children:T.all_day?`${new Date(T.start).toLocaleDateString()} (All Day)`:`${new Date(T.start).toLocaleString()} – ${new Date(T.end).toLocaleString()}`})]}),T.location&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{className:`w-4 h-4 text-shogun-gold`}),(0,Q.jsx)(`span`,{className:`text-shogun-text`,children:T.location})]})]})]}),T.description&&(0,Q.jsxs)(`div`,{className:`space-y-1.5 p-4 rounded-xl border border-shogun-border/20 bg-[#050508]/80`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest block`,children:`Description`}),(0,Q.jsx)(`p`,{className:`text-xs text-shogun-text font-mono whitespace-pre-wrap leading-relaxed`,children:T.description})]}),(0,Q.jsx)(`div`,{className:`flex justify-between items-center pt-2 border-t border-shogun-border/20 gap-3`,children:T.color===`cron_job`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{}),(0,Q.jsxs)(`button`,{onClick:()=>{b(!1),e(`/shogun?tab=operations`)},className:`flex items-center gap-1.5 px-5 py-2 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-500 hover:to-indigo-500 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all shadow-[0_0_10px_rgba(147,51,234,0.3)]`,children:[(0,Q.jsx)(O,{className:`w-4 h-4`}),` Configure Cron Job`]})]}):(0,Q.jsxs)(Q.Fragment,{children:[t.perm_delete_events?(0,Q.jsxs)(`button`,{onClick:pe,disabled:H,className:`flex items-center gap-1.5 px-4 py-2 border border-red-500/20 text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded-lg text-xs font-bold transition-all disabled:opacity-40`,children:[(0,Q.jsx)(ne,{className:`w-4 h-4`}),` Delete Event`]}):(0,Q.jsx)(`div`,{}),t.perm_edit_events&&(0,Q.jsxs)(`button`,{onClick:de,className:`flex items-center gap-1.5 px-5 py-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg text-xs uppercase tracking-wider transition-all`,children:[(0,Q.jsx)(S,{className:`w-4 h-4`}),` Edit Event`]})]})})]}):(0,Q.jsxs)(`form`,{onSubmit:fe,className:`p-5 flex-1 flex flex-col gap-4 overflow-y-auto`,children:[ae&&(0,Q.jsxs)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/20 text-red-500 rounded-lg text-xs font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(u,{className:`w-4 h-4 shrink-0`}),(0,Q.jsx)(`span`,{children:ae})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Event Title *`}),(0,Q.jsx)(`input`,{type:`text`,required:!0,placeholder:`Brief description of event`,value:D,onChange:e=>A(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Start Date & Time *`}),(0,Q.jsx)(`input`,{type:`datetime-local`,required:!0,value:j,onChange:e=>M(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`End Date & Time *`}),(0,Q.jsx)(`input`,{type:`datetime-local`,required:!0,value:N,onChange:e=>re(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`allDayCheck`,checked:B,onChange:e=>V(e.target.checked),className:`rounded border-shogun-border text-shogun-blue focus:ring-shogun-blue bg-[#050508]`}),(0,Q.jsx)(`label`,{htmlFor:`allDayCheck`,className:`text-xs text-shogun-text select-none cursor-pointer`,children:`All Day Event`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Location`}),(0,Q.jsx)(`input`,{type:`text`,placeholder:`e.g. Conference Room A, Virtual Link`,value:F,onChange:e=>I(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Description`}),(0,Q.jsx)(`textarea`,{rows:4,placeholder:`Enter additional details...`,value:L,onChange:e=>R(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono resize-y`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-3 mt-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:H,onClick:()=>{x===`edit`?C(`view`):b(!1)},className:`flex-1 py-3 border border-shogun-border text-shogun-subdued hover:text-shogun-text font-bold rounded-lg text-sm uppercase tracking-wider transition-all disabled:opacity-40`,children:`Cancel`}),(0,Q.jsx)(`button`,{type:`submit`,disabled:H||!D||!j||!N,className:`flex-1 flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm uppercase tracking-wider transition-all`,children:H?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(w,{className:`w-4 h-4 animate-spin`}),` Synchronizing CalDAV…`]}):x===`edit`?`Update Event`:`Create Event`})]})]})]})]})]}):(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued text-center p-8`,children:[(0,Q.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-400/10 flex items-center justify-center text-red-400 border border-red-400/30 mb-4`,children:(0,Q.jsx)(k,{className:`w-8 h-8`})}),(0,Q.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`Read Permission Denied`}),(0,Q.jsx)(`p`,{className:`max-w-md text-xs text-shogun-subdued leading-relaxed`,children:`The "Read Calendar" permission is disabled for this account in Katana settings. Toggle this permission ON to view your calendar board.`})]})};function pe(e){return[`ts`,`tsx`,`js`,`jsx`,`py`,`go`,`rs`,`java`,`c`,`cpp`,`h`,`cs`,`rb`,`php`,`sh`,`bat`,`ps1`,`yaml`,`yml`,`toml`,`ini`,`cfg`].includes(e)?p:[`csv`,`xlsx`,`xls`].includes(e)?m:[`png`,`jpg`,`jpeg`,`gif`,`svg`,`webp`,`bmp`,`ico`].includes(e)?_:[`zip`,`tar`,`gz`,`rar`,`7z`,`bz2`].includes(e)?t:[`txt`,`md`,`log`,`json`,`xml`,`html`,`css`].includes(e)?h:q}function me(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function he(e){return e?new Intl.DateTimeFormat(void 0,{year:`numeric`,month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(new Date(e)):`Date unavailable`}function ge({node:e,depth:t,selectedPath:n,expandedPaths:r,onSelect:i,onToggle:a}){let s=e.type===`directory`,l=r.has(e.path),u=n===e.path,d=s?l?g:ee:pe(e.extension||``);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`button`,{onClick:()=>{i(e),s&&a(e.path)},className:z(`w-full flex items-center gap-1.5 px-2 py-1 text-sm rounded-md transition-all group`,u?`bg-shogun-blue/15 text-shogun-blue`:`text-shogun-text hover:bg-shogun-card`),style:{paddingLeft:`${t*16+8}px`},children:[s?(0,Q.jsx)(`span`,{className:`w-3 h-3 flex items-center justify-center flex-shrink-0 text-shogun-subdued`,children:l?(0,Q.jsx)(o,{className:`w-3 h-3`}):(0,Q.jsx)(c,{className:`w-3 h-3`})}):(0,Q.jsx)(`span`,{className:`w-3 h-3 flex-shrink-0`}),(0,Q.jsx)(d,{className:z(`w-4 h-4 flex-shrink-0`,s?`text-shogun-gold`:`text-shogun-subdued`)}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 text-left`,children:[(0,Q.jsx)(`span`,{className:`block truncate`,children:e.name}),!s&&(0,Q.jsxs)(`span`,{className:`block truncate text-[9px] leading-3 text-shogun-subdued/60 font-mono`,title:`Created ${he(e.created_at)}`,children:[`Created `,he(e.created_at)]})]}),!s&&e.size!==void 0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-shogun-subdued/60 font-mono flex-shrink-0`,children:me(e.size)})]}),s&&l&&e.children&&(0,Q.jsxs)(`div`,{children:[e.children.map(e=>(0,Q.jsx)(ge,{node:e,depth:t+1,selectedPath:n,expandedPaths:r,onSelect:i,onToggle:a},e.path)),e.children.length===0&&(0,Q.jsx)(`div`,{className:`text-[11px] text-shogun-subdued/40 italic pl-4 py-1`,style:{paddingLeft:`${(t+1)*16+20}px`},children:`Empty folder`})]})]})}var $=()=>{let[e,t]=(0,Z.useState)([]),[n,r]=(0,Z.useState)(null),[i,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(new Set([``])),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(!1),[h,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!0),[b,x]=(0,Z.useState)(!1),[C,te]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(``),[re,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(``),[B,V]=(0,Z.useState)(!1),[H,U]=(0,Z.useState)(``),[ae,W]=(0,Z.useState)(!1),[se,q]=(0,Z.useState)(!1),ce=(0,Z.useRef)(0),le=(0,Z.useRef)(null),Y=(0,Z.useCallback)((e,t)=>{O({type:e,text:t}),setTimeout(()=>O(null),3e3)},[]),X=(0,Z.useCallback)(async()=>{try{y(!0),te(null);let[e,n]=await Promise.all([G.get(`/api/v1/workspace/tree`),G.get(`/api/v1/workspace/info`)]);e.data?.success&&t(e.data.data.tree),n.data?.success&&r(n.data.data)}catch(e){let t=e?.response?.data?.detail||e.message;te(t)}finally{y(!1)}},[]);(0,Z.useEffect)(()=>{X()},[X]);let ue=async e=>{if(o(e),m(!1),_(!1),V(!1),P(!1),e.type===`file`)try{let t=await G.get(`/api/v1/workspace/read`,{params:{path:e.path}});t.data?.success&&(u(t.data.data.content),f(t.data.data.content))}catch(e){let t=e?.response?.data?.detail||`Failed to read file`;t.toLowerCase().includes(`binary`)?(_(!0),u(``)):u(`[Error] ${t}`),f(``)}else u(``),f(``)},de=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},fe=async()=>{if(!(!i||i.type!==`file`)){x(!0);try{(await G.post(`/api/v1/workspace/write`,{path:i.path,content:d})).data?.success&&(u(d),m(!1),Y(`success`,`Saved ${i.name}`),X())}catch(e){Y(`error`,e?.response?.data?.detail||`Save failed`)}finally{x(!1)}}},$=async()=>{if(!j.trim())return;let e=i?.type===`directory`?i.path:``,t=e?`${e}/${j.trim()}`:j.trim();try{k===`folder`?(await G.post(`/api/v1/workspace/mkdir`,{path:t}),Y(`success`,`Created folder: ${j.trim()}`)):(await G.post(`/api/v1/workspace/write`,{path:t,content:``}),Y(`success`,`Created file: ${j.trim()}`)),A(null),M(``),e&&c(t=>new Set([...t,e])),X()}catch(e){Y(`error`,e?.response?.data?.detail||`Creation failed`)}},_e=async()=>{if(i)try{await G.delete(`/api/v1/workspace/delete`,{params:{path:i.path}}),Y(`success`,`Deleted: ${i.name}`),o(null),u(``),V(!1),X()}catch(e){Y(`error`,e?.response?.data?.detail||`Delete failed`)}},ve=async()=>{if(!i||!F.trim())return;let e=i.path.split(`/`);e[e.length-1]=F.trim();let t=e.join(`/`);try{await G.post(`/api/v1/workspace/rename`,{old_path:i.path,new_path:t}),Y(`success`,`Renamed to: ${F.trim()}`),P(!1),o(null),X()}catch(e){Y(`error`,e?.response?.data?.detail||`Rename failed`)}},ye=async e=>{if(!e||e.length===0)return;q(!0);let t=i?.type===`directory`?i.path:``;try{let n=new FormData;Array.from(e).forEach(e=>n.append(`files`,e)),n.append(`path`,t);let r=await G.post(`/api/v1/workspace/upload`,n,{headers:{"Content-Type":`multipart/form-data`}});if(r.data?.success){let e=r.data.data.uploaded;Y(`success`,`Uploaded ${e} file${e===1?``:`s`}`),t&&c(e=>new Set([...e,t])),X()}}catch(e){Y(`error`,e?.response?.data?.detail||`Upload failed`)}finally{q(!1)}},be=e=>{e.preventDefault(),e.stopPropagation(),ce.current+=1,e.dataTransfer.types.includes(`Files`)&&W(!0)},xe=e=>{e.preventDefault(),e.stopPropagation(),--ce.current,ce.current===0&&W(!1)},Se=e=>{e.preventDefault(),e.stopPropagation()},Ce=e=>{e.preventDefault(),e.stopPropagation(),W(!1),ce.current=0,e.dataTransfer.files?.length&&ye(e.dataTransfer.files)},we=(e,t)=>{if(!t)return e;let n=t.toLowerCase();return e.reduce((e,r)=>{if(r.name.toLowerCase().includes(n))e.push(r);else if(r.type===`directory`&&r.children){let n=we(r.children,t);n.length>0&&e.push({...r,children:n})}return e},[])},Te={name:`Workspace`,path:``,type:`directory`,children:we(e,H)};return C?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,Q.jsx)(R,{className:`w-10 h-10 text-red-400 mx-auto`}),(0,Q.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`Workspace Unavailable`}),(0,Q.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-md`,children:C}),(0,Q.jsxs)(`button`,{onClick:X,className:`px-4 py-2 bg-shogun-blue/20 text-shogun-blue rounded-lg text-sm hover:bg-shogun-blue/30 transition-colors`,children:[(0,Q.jsx)(w,{className:`w-4 h-4 inline mr-1`}),` Retry`]})]})}):(0,Q.jsxs)(`div`,{className:`h-full flex flex-col relative`,onDragEnter:be,onDragLeave:xe,onDragOver:Se,onDrop:Ce,children:[(0,Q.jsx)(`input`,{ref:le,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&(ye(e.target.files),e.target.value=``)}}),ae&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-50 bg-shogun-bg/90 backdrop-blur-sm flex items-center justify-center border-2 border-dashed border-shogun-blue rounded-xl transition-all`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-3 animate-pulse`,children:[(0,Q.jsx)(N,{className:`w-12 h-12 text-shogun-blue mx-auto`}),(0,Q.jsx)(`h3`,{className:`text-lg font-bold text-shogun-blue`,children:`Drop files here`}),(0,Q.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:i?.type===`directory`?(0,Q.jsxs)(Q.Fragment,{children:[`Upload into `,(0,Q.jsxs)(`span`,{className:`font-mono text-shogun-blue`,children:[i.path,`/`]})]}):`Upload to workspace root`})]})}),D&&(0,Q.jsxs)(`div`,{className:z(`px-4 py-2 text-xs font-medium flex items-center gap-2 shrink-0 transition-all`,D.type===`success`?`bg-emerald-500/10 text-emerald-400 border-b border-emerald-500/20`:`bg-red-500/10 text-red-400 border-b border-red-500/20`),children:[D.type===`success`?(0,Q.jsx)(a,{className:`w-3 h-3`}):(0,Q.jsx)(R,{className:`w-3 h-3`}),D.text]}),(0,Q.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,Q.jsxs)(`div`,{className:`w-72 border-r border-shogun-border flex flex-col bg-shogun-bg/50 shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`p-2 border-b border-shogun-border flex items-center gap-1 shrink-0`,children:[(0,Q.jsx)(`button`,{onClick:()=>A(`file`),title:`New File`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-blue transition-colors`,children:(0,Q.jsx)(K,{className:`w-4 h-4`})}),(0,Q.jsx)(`button`,{onClick:()=>A(`folder`),title:`New Folder`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,Q.jsx)(J,{className:`w-4 h-4`})}),(0,Q.jsx)(`button`,{onClick:()=>le.current?.click(),title:`Upload Files`,disabled:se,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-emerald-400 transition-colors`,children:(0,Q.jsx)(N,{className:z(`w-4 h-4`,se&&`animate-bounce`)})}),i&&i.path!==``&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>{I(i.name),P(!0)},title:`Rename`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text transition-colors`,children:(0,Q.jsx)(S,{className:`w-4 h-4`})}),(0,Q.jsx)(`button`,{onClick:()=>V(!0),title:`Delete`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-red-400 transition-colors`,children:(0,Q.jsx)(ne,{className:`w-4 h-4`})})]}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(`button`,{onClick:X,title:`Refresh`,className:`p-1.5 rounded hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text transition-colors`,children:(0,Q.jsx)(w,{className:z(`w-4 h-4`,v&&`animate-spin`)})})]}),(0,Q.jsx)(`div`,{className:`px-2 pt-2 shrink-0`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(E,{className:`w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-shogun-subdued`}),(0,Q.jsx)(`input`,{type:`text`,value:H,onChange:e=>U(e.target.value),placeholder:`Search files...`,className:`w-full bg-shogun-card border border-shogun-border rounded-md pl-8 pr-3 py-1.5 text-xs text-shogun-text placeholder-shogun-subdued/40 focus:outline-none focus:border-shogun-blue/50`})]})}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto p-1 mt-1`,children:v?(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-20`,children:(0,Q.jsx)(w,{className:`w-5 h-5 animate-spin text-shogun-subdued`})}):(0,Q.jsx)(ge,{node:Te,depth:0,selectedPath:i?.path??null,expandedPaths:s,onSelect:ue,onToggle:de})}),n&&(0,Q.jsxs)(`div`,{className:`p-2 border-t border-shogun-border text-[10px] text-shogun-subdued/60 space-y-0.5 shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(oe,{className:`w-3 h-3`}),` `,n.total_files,` files · `,n.total_directories,` dirs · `,n.total_size_mb,` MB`]}),(0,Q.jsx)(`div`,{className:`font-mono truncate`,title:n.path,children:n.path})]})]}),(0,Q.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0`,children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`px-4 py-2.5 border-b border-shogun-border flex items-center gap-3 shrink-0 bg-shogun-bg/30`,children:i.type===`file`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(pe(i.extension||``),{className:`w-4 h-4 text-shogun-subdued`}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-shogun-text truncate`,children:i.path}),i.size!==void 0&&(0,Q.jsx)(`span`,{className:`text-[10px] text-shogun-subdued font-mono`,children:me(i.size)}),(0,Q.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued font-mono`,title:i.modified_at?`Modified ${he(i.modified_at)}`:void 0,children:[`Created `,he(i.created_at)]}),(0,Q.jsx)(`div`,{className:`flex-1`}),!h&&(p?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsxs)(`button`,{onClick:fe,disabled:b,className:`px-3 py-1 bg-emerald-500/20 text-emerald-400 rounded text-xs font-medium hover:bg-emerald-500/30 transition-colors flex items-center gap-1`,children:[(0,Q.jsx)(T,{className:`w-3 h-3`}),` `,b?`Saving...`:`Save`]}),(0,Q.jsx)(`button`,{onClick:()=>{m(!1),f(l)},className:`px-3 py-1 bg-shogun-card text-shogun-subdued rounded text-xs hover:text-shogun-text transition-colors`,children:(0,Q.jsx)(ie,{className:`w-3 h-3`})})]}):(0,Q.jsxs)(`button`,{onClick:()=>m(!0),className:`px-3 py-1 bg-shogun-blue/10 text-shogun-blue rounded text-xs font-medium hover:bg-shogun-blue/20 transition-colors flex items-center gap-1`,children:[(0,Q.jsx)(S,{className:`w-3 h-3`}),` Edit`]})),h&&(0,Q.jsxs)(`a`,{href:`/api/v1/workspace/download?path=${encodeURIComponent(i.path)}`,download:!0,className:`px-3 py-1 bg-shogun-blue/10 text-shogun-blue rounded text-xs font-medium hover:bg-shogun-blue/20 transition-colors flex items-center gap-1`,children:[(0,Q.jsx)(L,{className:`w-3 h-3`}),` Download`]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(g,{className:`w-4 h-4 text-shogun-gold`}),(0,Q.jsxs)(`span`,{className:`text-sm font-medium text-shogun-text truncate`,children:[i.path||`Workspace`,`/`]}),(0,Q.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[i.children?.length||0,` items`]})]})}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto`,children:i.type===`file`?h?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-4 max-w-sm`,children:[(0,Q.jsx)(pe(i.extension||``),{className:`w-16 h-16 text-shogun-subdued/30 mx-auto`}),(0,Q.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:i.name}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-4 text-xs text-shogun-subdued`,children:[(0,Q.jsxs)(`span`,{className:`bg-shogun-card px-2 py-1 rounded font-mono`,children:[`.`,i.extension]}),i.size!==void 0&&(0,Q.jsx)(`span`,{children:me(i.size)})]}),(0,Q.jsx)(`p`,{className:`text-xs text-shogun-subdued/60`,children:`Binary file — cannot be displayed as text.`})]}),(0,Q.jsxs)(`a`,{href:`/api/v1/workspace/download?path=${encodeURIComponent(i.path)}`,download:!0,className:`inline-flex items-center gap-2 px-4 py-2 bg-shogun-blue/15 text-shogun-blue rounded-lg text-sm font-medium hover:bg-shogun-blue/25 transition-colors`,children:[(0,Q.jsx)(L,{className:`w-4 h-4`}),` Download File`]})]})}):p?(0,Q.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),className:`w-full h-full bg-transparent text-shogun-text text-sm font-mono p-4 resize-none focus:outline-none leading-relaxed`,spellCheck:!1}):(0,Q.jsx)(`pre`,{className:`text-sm font-mono text-shogun-text p-4 whitespace-pre-wrap break-words leading-relaxed`,children:l||(0,Q.jsx)(`span`,{className:`text-shogun-subdued italic`,children:`Empty file`})}):(0,Q.jsxs)(`div`,{className:`p-4 space-y-2`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text mb-3`,children:[`Contents of `,i.path?i.name:`Workspace`,`/`]}),i.children&&i.children.length>0?(0,Q.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2`,children:i.children.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>ue(e),className:`flex items-start gap-2 p-3 rounded-lg bg-shogun-card hover:bg-shogun-card/80 border border-shogun-border hover:border-shogun-blue/30 transition-all text-left group`,children:[(0,Q.jsx)(e.type===`directory`?ee:pe(e.extension||``),{className:z(`w-5 h-5 mt-0.5 flex-shrink-0`,e.type===`directory`?`text-shogun-gold`:`text-shogun-subdued`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-shogun-text truncate group-hover:text-shogun-blue transition-colors`,children:e.name}),e.type===`file`&&e.size!==void 0&&(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued`,children:me(e.size)}),(0,Q.jsxs)(`div`,{className:`mt-1 text-[9px] leading-3 text-shogun-subdued/60 font-mono truncate`,title:`Created ${he(e.created_at)}`,children:[`Created `,he(e.created_at)]})]})]},e.path))}):(0,Q.jsx)(`p`,{className:`text-sm text-shogun-subdued italic`,children:`This folder is empty`})]})})]}):(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,Q.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,Q.jsx)(g,{className:`w-12 h-12 text-shogun-gold/30 mx-auto`}),(0,Q.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`Agent Workspace`}),(0,Q.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-sm`,children:`Select a file or folder from the tree to view or edit it. This is the shared workspace used by the Shogun and all Samurai agents.`}),n&&(0,Q.jsx)(`div`,{className:`text-xs text-shogun-subdued font-mono bg-shogun-card px-3 py-1.5 rounded-lg inline-block`,children:n.path})]})})})]}),k&&(0,Q.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,Q.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-xl p-5 w-96 shadow-2xl space-y-4`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[k===`folder`?(0,Q.jsx)(J,{className:`w-4 h-4 text-shogun-gold`}):(0,Q.jsx)(K,{className:`w-4 h-4 text-shogun-blue`}),`New `,k===`folder`?`Folder`:`File`]}),i?.type===`directory`&&(0,Q.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued`,children:[`Inside: `,(0,Q.jsxs)(`span`,{className:`font-mono text-shogun-text`,children:[i.path,`/`]})]}),(0,Q.jsx)(`input`,{autoFocus:!0,type:`text`,value:j,onChange:e=>M(e.target.value),onKeyDown:e=>e.key===`Enter`&&$(),placeholder:k===`folder`?`Folder name`:`filename.txt`,className:`w-full bg-shogun-card border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text placeholder-shogun-subdued/40 focus:outline-none focus:border-shogun-blue/50`}),(0,Q.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,Q.jsx)(`button`,{onClick:()=>{A(null),M(``)},className:`px-4 py-1.5 text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),(0,Q.jsx)(`button`,{onClick:$,disabled:!j.trim(),className:`px-4 py-1.5 bg-shogun-blue/20 text-shogun-blue rounded-lg text-xs font-medium hover:bg-shogun-blue/30 transition-colors disabled:opacity-40`,children:`Create`})]})]})}),re&&i&&(0,Q.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,Q.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-xl p-5 w-96 shadow-2xl space-y-4`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,Q.jsx)(S,{className:`w-4 h-4 text-shogun-gold`}),` Rename`]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-shogun-subdued font-mono`,children:i.path}),(0,Q.jsx)(`input`,{autoFocus:!0,type:`text`,value:F,onChange:e=>I(e.target.value),onKeyDown:e=>e.key===`Enter`&&ve(),className:`w-full bg-shogun-card border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text focus:outline-none focus:border-shogun-blue/50`}),(0,Q.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,Q.jsx)(`button`,{onClick:()=>P(!1),className:`px-4 py-1.5 text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),(0,Q.jsx)(`button`,{onClick:ve,disabled:!F.trim()||F===i.name,className:`px-4 py-1.5 bg-shogun-gold/20 text-shogun-gold rounded-lg text-xs font-medium hover:bg-shogun-gold/30 transition-colors disabled:opacity-40`,children:`Rename`})]})]})}),B&&i&&(0,Q.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,Q.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/30 rounded-xl p-5 w-96 shadow-2xl space-y-4`,children:[(0,Q.jsxs)(`h3`,{className:`text-sm font-bold text-red-400 flex items-center gap-2`,children:[(0,Q.jsx)(ne,{className:`w-4 h-4`}),` Delete `,i.type===`directory`?`Folder`:`File`]}),(0,Q.jsxs)(`p`,{className:`text-sm text-shogun-text`,children:[`Are you sure you want to delete `,(0,Q.jsx)(`span`,{className:`font-mono text-red-400`,children:i.name}),`?`,i.type===`directory`&&(0,Q.jsx)(`span`,{className:`block text-xs text-shogun-subdued mt-1`,children:`This will delete the folder and all its contents.`})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,Q.jsx)(`button`,{onClick:()=>V(!1),className:`px-4 py-1.5 text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),(0,Q.jsx)(`button`,{onClick:_e,className:`px-4 py-1.5 bg-red-500/20 text-red-400 rounded-lg text-xs font-medium hover:bg-red-500/30 transition-colors`,children:`Delete`})]})]})})]})},_e=`shogun_comms_current`,ve=`shogun_comms_history`,ye=50,be=`chat.welcome_message`;function xe(e){try{let t=localStorage.getItem(_e);return t?JSON.parse(t):[{role:`shogun`,content:e(be),timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}]}catch{return[{role:`shogun`,content:e(be),timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}]}}function Se(e){localStorage.setItem(_e,JSON.stringify(e))}async function Ce(e,t=!0){let n=await fetch(`/api/v1/comms/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({role:e.role,content:e.content,client_message_id:e.id,mirror_to_telegram:t,message_data:{model:e.model,provider:e.provider,search:e.search,mode:e.mode,attachments:e.attachments}})});if(!n.ok)throw Error(`Could not sync chat message: HTTP ${n.status}`)}function we(){try{let e=localStorage.getItem(ve);return e?JSON.parse(e):[]}catch{return[]}}function Te(e,t){let n=t(be);if(e.filter(e=>!(e.role===`shogun`&&e.content===n)).length===0)return;let r=we(),i=[{id:Date.now().toString(),startedAt:e[0]?.timestamp||new Date().toLocaleTimeString(),messages:e},...r].slice(0,ye);localStorage.setItem(ve,JSON.stringify(i))}var Ee={low:`bg-emerald-500/20 text-emerald-400 border-emerald-500/30`,medium:`bg-amber-500/20 text-amber-400 border-amber-500/30`,high:`bg-orange-500/20 text-orange-400 border-orange-500/30`,critical:`bg-red-500/20 text-red-400 border-red-500/30`},De=({att:e,idx:t,setMessages:n})=>{let[r,i]=(0,Z.useState)(!1),s=!!e.resolved,c=async t=>{try{await fetch(`/api/v1/security/toolgate/confirm`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({confirm_id:e.confirmId,approved:t})}),n(n=>{let r=[...n];for(let n=r.length-1;n>=0;n--){let i=r[n].attachments;if(!i)continue;let a=i.findIndex(t=>t.type===`toolgate_confirm`&&t.confirmId===e.confirmId);if(a>=0){let e=[...i];e[a]={...e[a],resolved:t?`approved`:`denied`},r[n]={...r[n],attachments:e};break}}return r})}catch(e){console.error(`ToolGate confirm failed:`,e)}};return(0,Q.jsxs)(`div`,{className:z(`rounded-xl border-2 overflow-hidden transition-all`,s?e.resolved===`approved`?`border-emerald-500/40 bg-emerald-500/5`:`border-red-500/40 bg-red-500/5`:`border-amber-500/50 bg-amber-500/5 animate-pulse`),children:[(0,Q.jsxs)(`div`,{className:z(`flex items-center gap-2 px-4 py-2.5`,s?e.resolved===`approved`?`bg-emerald-500/10`:`bg-red-500/10`:`bg-amber-500/10`),children:[(0,Q.jsx)(k,{className:z(`w-4 h-4`,s?e.resolved===`approved`?`text-emerald-400`:`text-red-400`:`text-amber-400`)}),(0,Q.jsx)(`span`,{className:z(`text-xs font-bold uppercase tracking-widest`,s?e.resolved===`approved`?`text-emerald-300`:`text-red-300`:`text-amber-300`),children:s?e.resolved===`approved`?`✅ APPROVED`:`❌ DENIED`:`âš\xA0️ CONFIRMATION REQUIRED`})]}),(0,Q.jsxs)(`div`,{className:`px-4 py-3 space-y-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-bold text-shogun-text font-mono`,children:e.tool}),(0,Q.jsxs)(`span`,{className:z(`text-[10px] px-2 py-0.5 rounded-full border font-bold uppercase`,Ee[e.risk||`medium`]||Ee.medium),children:[e.risk,` risk`]})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:e.reason}),e.args&&Object.keys(e.args).length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`button`,{onClick:()=>i(!r),className:`flex items-center gap-1 text-[10px] text-shogun-subdued hover:text-shogun-text transition-colors`,children:[r?(0,Q.jsx)(l,{className:`w-3 h-3`}):(0,Q.jsx)(o,{className:`w-3 h-3`}),`Parameters (`,Object.keys(e.args).length,`)`]}),r&&(0,Q.jsx)(`div`,{className:`mt-1.5 bg-black/30 rounded-lg p-2 text-[10px] font-mono text-shogun-subdued space-y-0.5 max-h-32 overflow-y-auto`,children:Object.entries(e.args).map(([e,t])=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`text-amber-400`,children:[e,`:`]}),` `,JSON.stringify(t)]},e))})]}),!s&&(0,Q.jsxs)(`div`,{className:`flex gap-2 pt-1`,children:[(0,Q.jsxs)(`button`,{onClick:()=>c(!0),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 bg-emerald-600/80 hover:bg-emerald-500 text-white rounded-lg text-xs font-bold uppercase tracking-wider transition-all active:scale-95`,children:[(0,Q.jsx)(a,{className:`w-3.5 h-3.5`}),` Approve`]}),(0,Q.jsxs)(`button`,{onClick:()=>c(!1),className:`flex-1 flex items-center justify-center gap-1.5 px-3 py-2 bg-red-600/80 hover:bg-red-500 text-white rounded-lg text-xs font-bold uppercase tracking-wider transition-all active:scale-95`,children:[(0,Q.jsx)(d,{className:`w-3.5 h-3.5`}),` Deny`]})]})]})]},t)},Oe=()=>{let{t:e}=H(),[t,r]=(0,Z.useState)(()=>xe(e)),a=localStorage.getItem(`shogun_operator_name`)||`Daimyo`,[s,l]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(`auto`),[ee,_]=(0,Z.useState)(!1),[y,S]=(0,Z.useState)(we),[te,w]=(0,Z.useState)(null),T=(0,Z.useRef)(null),E=(0,Z.useRef)(null),O=(0,Z.useRef)(null),[k,N]=(0,Z.useState)([]),[P,F]=(0,Z.useState)(null),[L,R]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(`Balanced`);(0,Z.useEffect)(()=>{fetch(`/api/v1/models/routing/profiles/active`).then(e=>e.ok?e.json():null).then(e=>{e?.data?.name&&V(e.data.name)}).catch(()=>void 0)},[]);let ae=async e=>{if(e){R(!0);try{let t=new FormData;t.append(`file`,e),t.append(`source`,`chat`),t.append(`chat_session_id`,`web-chat`);let n=await fetch(`/api/v1/visual/intake`,{method:`POST`,body:t}),r=await n.json();if(!n.ok)throw Error(r.detail||`Image upload failed.`);N(e=>[...e,r.data])}catch(e){m(e.message||`Image upload failed.`)}finally{R(!1),O.current&&(O.current.value=``)}}};(0,Z.useEffect)(()=>{let e=!1,t=async()=>{if(!E.current)try{let t=await fetch(`/api/v1/comms/messages?limit=200`);if(!t.ok)return;let n=((await t.json()).data||[]).map(e=>({id:e.id,role:e.role===`user`?`user`:`shogun`,content:e.content,channel:e.channel,timestamp:new Date(e.created_at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),...e.message_data||{}}));!e&&n.length>0&&r(n)}catch{}};t();let n=window.setInterval(t,4e3);return()=>{e=!0,window.clearInterval(n)}},[]),(0,Z.useEffect)(()=>{Se(t)},[t]),(0,Z.useEffect)(()=>{T.current&&(T.current.scrollTop=T.current.scrollHeight)},[t,d]);let oe=async()=>{if(!s.trim()&&k.length===0||d)return;let n=s.trim()||`Please review this image.`,i=[...k],a={id:crypto.randomUUID(),role:`user`,content:n,timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),channel:`comms`,attachments:i};try{await Ce(a)}catch(e){console.error(`Chat sync failed:`,e)}let o=[...t,a];r(o),l(``),N([]),f(!0),m(null);let c=o.filter(e=>e.role===`user`||e.role===`shogun`).slice(-20).map(e=>({role:e.role===`shogun`?`assistant`:`user`,content:e.content})),u={id:crypto.randomUUID(),role:`shogun`,content:``,timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),channel:`comms`};r(e=>[...e,u]);try{let e=new AbortController;E.current=e;let t=await fetch(`/api/v1/agents/shogun/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:n,history:c.slice(0,-1),mode:h,session_id:`web-chat`,attachments:i.map(e=>({artifact_id:e.artifact_id}))}),signal:e.signal});if(!t.ok||!t.body)throw Error(`HTTP ${t.status}`);let a=t.body.getReader(),o=new TextDecoder,s=``,l=``,d={};for(;;){let{done:e,value:t}=await a.read();if(e)break;s+=o.decode(t,{stream:!0});let n=s.split(` +`);s=n.pop()??``;for(let e of n){if(!e.startsWith(`data: `))continue;let t=e.slice(6).trim();if(t===`[DONE]`)break;try{let e=JSON.parse(t);if(e.type===`meta`)d={model:e.model,provider:e.provider,timestamp:e.timestamp,search:e.search,mode:e.mode},r(e=>{let t=[...e];return t[t.length-1]={...t[t.length-1],...d},t});else if(e.type===`status`)m(e.content);else if(e.type===`token`){f(!1),m(null),l+=e.content;let t=l;r(e=>{let n=[...e];return n[n.length-1]={...n[n.length-1],content:t},n})}else e.type===`error`?(l=e.content,r(t=>{let n=[...t];return n[n.length-1]={...n[n.length-1],content:e.content},n})):e.type===`ronin_screenshot`?r(t=>{let n=[...t],r=n[n.length-1],i=r.attachments||[];return n[n.length-1]={...r,attachments:[...i,{type:`screenshot`,url:e.url,description:e.description||`Desktop screenshot`}]},n}):e.type===`ronin_action`?r(t=>{let n=[...t],r=n[n.length-1],i=r.attachments||[];return n[n.length-1]={...r,attachments:[...i,{type:`action`,action:e.action,detail:e.detail||``}]},n}):e.type===`toolgate_confirm`?(r(t=>{let n=[...t],r=n[n.length-1],i=r.attachments||[];return n[n.length-1]={...r,attachments:[...i,{type:`toolgate_confirm`,confirmId:e.confirm_id,tool:e.tool,args:e.args||{},risk:e.risk,reason:e.reason}]},n}),f(!1),m(`Awaiting confirmation...`)):e.type===`toolgate_resolved`?(r(t=>{let n=[...t];for(let t=n.length-1;t>=0;t--){let r=n[t].attachments;if(!r)continue;let i=r.findIndex(t=>t.type===`toolgate_confirm`&&t.confirmId===e.confirm_id);if(i>=0){let a=[...r];a[i]={...a[i],resolved:e.approved?`approved`:`denied`},n[t]={...n[t],attachments:a};break}}return n}),m(null),f(!0)):e.type===`action`&&m(e.content)}catch{}}}l.trim()&&await Ce({...u,...d,content:l})}catch(t){t?.name===`AbortError`?r(e=>{let t=[...e],n=t[t.length-1];return n.content===``?t[t.length-1]={...n,content:`â›” Cancelled by operator.`}:t[t.length-1]={...n,content:n.content+` + +â›” *Cancelled by operator.*`},t}):(console.error(`Streaming failed:`,t),r(t=>{let n=[...t];return n[n.length-1]={...n[n.length-1],content:`âš\xA0️ `+e(`chat.bridge_interrupted`,`Neural bridge interrupted. Check logs.`)},n}))}finally{E.current=null,f(!1),m(null)}},G=()=>{E.current&&E.current.abort()},K=async()=>{Te(t,e);try{await fetch(`/api/v1/comms/messages`,{method:`DELETE`})}catch{}let n=[{role:`shogun`,content:e(be),timestamp:new Date().toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}];r(n),S(we())},q=()=>{S(we()),_(!0)},J=async n=>{Te(t,e),r(n.messages),_(!1);try{await fetch(`/api/v1/comms/messages`,{method:`DELETE`}),await Promise.all(n.messages.filter(t=>t.content&&t.content!==e(be)).map(e=>Ce({...e,id:e.id||crypto.randomUUID(),channel:`comms`},!1)))}catch(e){console.error(`Could not restore shared chat session:`,e)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col w-full min-w-0 h-full space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex justify-between items-center shrink-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`chat.neural_link`,`Neural Connection`)}),(0,Q.jsxs)(`span`,{className:`rounded border border-purple-400/30 bg-purple-400/10 px-2 py-1 text-[9px] font-bold uppercase text-purple-300`,children:[`Routing: `,B]})]}),(0,Q.jsxs)(`button`,{onClick:K,className:`flex items-center gap-1.5 px-3 py-1.5 border border-red-500/20 text-red-400/80 hover:text-red-400 hover:bg-red-500/10 rounded-lg text-xs font-bold transition-all`,title:e(`chat.clear_tooltip`,`Clear current session`),children:[(0,Q.jsx)(ne,{className:`w-3.5 h-3.5`}),e(`chat.clear_session`,`Clear Link`)]})]}),(0,Q.jsxs)(`div`,{className:`flex-1 w-full shogun-card overflow-hidden flex flex-col p-0`,children:[(0,Q.jsxs)(`div`,{ref:T,className:`flex-1 overflow-y-auto p-6 space-y-6 scrollbar-hide scroll-smooth`,children:[t.length===0&&(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued space-y-3 opacity-50`,children:[(0,Q.jsx)(M,{className:`w-12 h-12`}),(0,Q.jsx)(`p`,{className:`text-sm italic tracking-wide`,children:e(`chat.terminal_empty`,`Terminal empty. Awaiting mission parameters.`)})]}),t.map((t,o)=>(0,Q.jsxs)(`div`,{className:z(`flex gap-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,t.role===`user`?`flex-row-reverse`:`flex-row`),children:[(0,Q.jsx)(`div`,{className:z(`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 border`,t.role===`user`?`bg-shogun-blue/10 border-shogun-blue/30 text-shogun-blue`:`bg-shogun-gold/10 border-shogun-gold/30 text-shogun-gold`),children:t.role===`user`?(0,Q.jsx)(U,{className:`w-4 h-4`}):(0,Q.jsx)(n,{className:`w-4 h-4`})}),(0,Q.jsxs)(`div`,{className:z(`max-w-[70%] space-y-1 flex flex-col`,t.role===`user`?`items-end`:`items-start`),children:[(0,Q.jsx)(`div`,{className:z(`p-4 rounded-2xl text-sm leading-relaxed whitespace-pre-wrap`,t.role===`user`?`bg-shogun-card border border-shogun-border text-shogun-text rounded-tr-none`:`bg-[#050508] border border-shogun-border text-shogun-gold rounded-tl-none font-mono`),children:t.role===`shogun`&&t.content===``&&(!t.attachments||t.attachments.length===0)?(0,Q.jsx)(`div`,{className:`flex items-center gap-2 py-1`,children:p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-cyan-400 animate-pulse`}),(0,Q.jsx)(`span`,{className:`text-xs text-cyan-400/80 font-mono animate-pulse`,children:p})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-shogun-gold/70 animate-bounce [animation-delay:0ms]`}),(0,Q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-shogun-gold/70 animate-bounce [animation-delay:150ms]`}),(0,Q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-shogun-gold/70 animate-bounce [animation-delay:300ms]`})]})}):(0,Q.jsxs)(Q.Fragment,{children:[t.content,t.attachments&&t.attachments.length>0&&(0,Q.jsxs)(`div`,{className:z(`space-y-2`,t.content?`mt-3 border-t border-shogun-border/30 pt-3`:``),children:[t.attachments.map((e,t)=>{if(e.type===`image`)return(0,Q.jsxs)(`div`,{className:`rounded-xl overflow-hidden border border-cyan-500/30 bg-black/30 max-w-2xl`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>F(e),className:`block w-full bg-[#070b14]`,children:(0,Q.jsx)(`img`,{src:e.thumbnail_url,alt:e.caption||e.filename,className:`w-full max-h-[420px] object-contain hover:opacity-90 transition-opacity`})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2 border-t border-cyan-500/20`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[10px] font-bold text-cyan-300`,children:e.filename}),(0,Q.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued uppercase`,children:[e.source,` · `,e.width,`×`,e.height,` · `,e.status]})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Q.jsx)(`button`,{onClick:async()=>{(await fetch(`/api/v1/visual/${e.artifact_id}/pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pinned:!e.pinned})})).ok&&r(t=>t.map(t=>({...t,attachments:t.attachments?.map(t=>t.type===`image`&&t.artifact_id===e.artifact_id?{...t,pinned:!e.pinned}:t)})))},title:e.pinned?`Unpin`:`Pin beyond retention`,className:z(`p-1.5 rounded border`,e.pinned?`border-amber-400/40 text-amber-300`:`border-shogun-border text-shogun-subdued`),children:(0,Q.jsx)(C,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`button`,{onClick:async()=>{window.confirm(`Delete this image artifact?`)&&(await fetch(`/api/v1/visual/${e.artifact_id}`,{method:`DELETE`})).ok&&r(t=>t.map(t=>({...t,attachments:t.attachments?.filter(t=>t.type!==`image`||t.artifact_id!==e.artifact_id)})))},title:`Delete image`,className:`p-1.5 rounded border border-red-500/30 text-red-400`,children:(0,Q.jsx)(ne,{className:`w-3.5 h-3.5`})})]})]})]},t);if(e.type===`screenshot`)return(0,Q.jsxs)(`div`,{className:`rounded-lg overflow-hidden border border-cyan-500/30 bg-black/40`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 bg-cyan-500/10 border-b border-cyan-500/20`,children:[(0,Q.jsx)(i,{className:`w-3 h-3 text-cyan-400`}),(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-cyan-400 uppercase tracking-wider`,children:`Desktop Screenshot`})]}),(0,Q.jsx)(`img`,{src:e.url,alt:e.description,className:`w-full max-h-[400px] object-contain cursor-pointer hover:opacity-90 transition-opacity`,onClick:()=>window.open(e.url,`_blank`)})]},t);if(e.type===`toolgate_confirm`)return(0,Q.jsx)(De,{att:e,idx:t,setMessages:r},t);if(e.type===`action`){let n=e.action===`click`,r=e.action===`type`,i=e.action===`error`;return(0,Q.jsxs)(`div`,{className:z(`flex items-center gap-2 px-3 py-2 rounded-lg text-xs font-mono border`,i?`bg-red-500/10 border-red-500/30 text-red-400`:n?`bg-purple-500/10 border-purple-500/30 text-purple-300`:r?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-cyan-500/10 border-cyan-500/30 text-cyan-300`),children:[n&&(0,Q.jsx)(x,{className:`w-3.5 h-3.5 shrink-0`}),r&&(0,Q.jsx)(v,{className:`w-3.5 h-3.5 shrink-0`}),i&&(0,Q.jsx)(u,{className:`w-3.5 h-3.5 shrink-0`}),!n&&!r&&!i&&(0,Q.jsx)(b,{className:`w-3.5 h-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:e.detail})]},t)}return null}),d&&p&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-cyan-400/70 font-mono`,children:[(0,Q.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-cyan-400 animate-pulse`}),(0,Q.jsx)(`span`,{className:`animate-pulse`,children:p})]})]})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-1 mt-1`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-shogun-subdued font-bold tracking-wider`,children:t.role===`user`?a:e(`chat.agent_label`,`SHOGUN`)}),(0,Q.jsx)(`span`,{className:`text-[10px] text-shogun-subdued opacity-50`,children:t.timestamp}),t.channel===`telegram`&&(0,Q.jsx)(`span`,{className:`text-[9px] text-sky-400/80 uppercase tracking-wider`,children:`Telegram`}),t.role===`shogun`&&(t.model||t.search||t.mode)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.mode&&(0,Q.jsxs)(`div`,{className:z(`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider`,t.mode===`fast`?`bg-emerald-500/10 border border-emerald-500/30 text-emerald-400`:t.mode===`governed`?`bg-amber-500/10 border border-amber-500/30 text-amber-400`:`bg-purple-500/10 border border-purple-500/30 text-purple-400`),children:[t.mode===`fast`?(0,Q.jsx)(re,{className:`w-2.5 h-2.5`}):t.mode===`governed`?(0,Q.jsx)(W,{className:`w-2.5 h-2.5`}):(0,Q.jsx)(j,{className:`w-2.5 h-2.5`}),t.mode===`fast`?`Fast`:t.mode===`governed`?`Governed`:`Mission`]}),t.search?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue`,children:[(0,Q.jsx)(se,{className:`w-2.5 h-2.5`}),e(`chat.web_search`,`Web Search`)]}):t.model?(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider bg-shogun-card border border-shogun-border text-shogun-subdued`,children:[(0,Q.jsx)(n,{className:`w-2.5 h-2.5`}),t.model]}):null]})]})]})]},o))]}),(0,Q.jsxs)(`div`,{className:`p-4 bg-[#050508]/50 border-t border-shogun-border shrink-0`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-1 mb-3`,children:[{id:`auto`,label:`Auto`,icon:A,color:`cyan`,desc:`Automatically selects the best mode`},{id:`fast`,label:`Fast Chat`,icon:re,color:`emerald`,desc:`Conversation only — no tools or memory`},{id:`governed`,label:`Governed`,icon:W,color:`amber`,desc:`Context-aware with memory (coming soon)`},{id:`mission`,label:`Mission`,icon:j,color:`purple`,desc:`Full agent orchestration with tools`}].map(({id:e,label:t,icon:n,color:r})=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>g(e),className:z(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-widest border transition-all`,h===e?`bg-${r}-500/15 border-${r}-500/40 text-${r}-400`:`bg-transparent border-shogun-border/50 text-shogun-subdued/60 hover:border-shogun-subdued hover:text-shogun-subdued`),style:h===e?{backgroundColor:r===`cyan`?`rgba(6,182,212,0.15)`:r===`emerald`?`rgba(16,185,129,0.15)`:r===`amber`?`rgba(245,158,11,0.15)`:`rgba(168,85,247,0.15)`,borderColor:r===`cyan`?`rgba(6,182,212,0.4)`:r===`emerald`?`rgba(16,185,129,0.4)`:r===`amber`?`rgba(245,158,11,0.4)`:`rgba(168,85,247,0.4)`,color:r===`cyan`?`rgb(34,211,238)`:r===`emerald`?`rgb(52,211,153)`:r===`amber`?`rgb(251,191,36)`:`rgb(192,132,252)`}:{},children:[(0,Q.jsx)(n,{className:`w-3 h-3`}),t]},e))}),(0,Q.jsxs)(`div`,{className:`relative flex items-center`,children:[(0,Q.jsx)(`input`,{ref:O,type:`file`,accept:`image/jpeg,image/png,image/webp,image/gif`,className:`hidden`,onChange:e=>void ae(e.target.files?.[0])}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>O.current?.click(),disabled:L||d,title:`Add image`,className:`absolute left-2 z-10 p-2 text-cyan-400 hover:bg-cyan-500/10 rounded-lg disabled:opacity-40`,children:(0,Q.jsx)(ce,{className:z(`w-5 h-5`,L&&`animate-pulse`)})}),(0,Q.jsx)(`input`,{type:`text`,value:s,onChange:e=>l(e.target.value),onKeyDown:e=>e.key===`Enter`&&!e.shiftKey&&oe(),disabled:d,placeholder:d?e(`chat.placeholder_thinking`,`Shogun is thinking...`):h===`auto`?`Ask anything — Shogun routes automatically...`:h===`fast`?`Ask anything...`:h===`mission`?`Enter mission directive...`:`Ask with context...`,className:`w-full bg-shogun-card border border-shogun-border rounded-xl py-4 pl-14 pr-14 text-shogun-text placeholder:text-shogun-subdued focus:outline-none focus:border-shogun-blue focus:ring-1 focus:ring-shogun-blue/20 transition-all font-mono text-sm disabled:opacity-50 disabled:cursor-not-allowed`}),d?(0,Q.jsx)(`button`,{onClick:G,className:`absolute right-2 p-2 bg-red-600 text-white rounded-lg hover:bg-red-500 transition-all active:scale-95 animate-pulse`,title:`Cancel operation`,children:(0,Q.jsx)(X,{className:`w-5 h-5 fill-current`})}):(0,Q.jsx)(`button`,{onClick:oe,disabled:!s.trim()&&k.length===0,className:`absolute right-2 p-2 bg-shogun-blue text-white rounded-lg hover:bg-shogun-blue/80 transition-all active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed`,children:(0,Q.jsx)(D,{className:`w-5 h-5`})})]}),k.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2 mt-2`,children:k.map(e=>(0,Q.jsxs)(`div`,{className:`relative w-24 h-20 rounded-lg overflow-hidden border border-cyan-500/30 bg-black`,children:[(0,Q.jsx)(`img`,{src:e.thumbnail_url,alt:e.filename,className:`w-full h-full object-cover`}),(0,Q.jsx)(`button`,{onClick:()=>N(t=>t.filter(t=>t.artifact_id!==e.artifact_id)),className:`absolute right-1 top-1 p-1 rounded bg-black/80 text-white`,children:(0,Q.jsx)(ie,{className:`w-3 h-3`})})]},e.artifact_id))}),(0,Q.jsxs)(`div`,{className:`flex justify-between mt-3 px-2`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-4`,children:[(0,Q.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued flex items-center gap-1`,children:[(0,Q.jsx)(M,{className:`w-3 h-3`}),` UTF-8`]}),(0,Q.jsxs)(`button`,{onClick:q,className:`text-[10px] text-shogun-subdued flex items-center gap-1 underline cursor-pointer hover:text-shogun-blue transition-colors`,children:[(0,Q.jsx)(I,{className:`w-3 h-3`}),e(`chat.view_history`,`View History`),` (`,y.length,` `,e(`chat.sessions`,`sessions`),`)`]})]}),(0,Q.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:e(`chat.enter_to_send`,`Press Enter to send`)})]})]})]}),P&&(0,Q.jsx)(`div`,{className:`fixed inset-0 z-[70] flex items-center justify-center bg-black/90 p-6`,onClick:()=>F(null),children:(0,Q.jsxs)(`div`,{className:`relative max-w-[95vw] max-h-[95vh]`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`img`,{src:P.content_url,alt:P.caption||P.filename,className:`max-w-[95vw] max-h-[88vh] object-contain rounded-xl border border-cyan-500/30`}),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-shogun-subdued`,children:[(0,Q.jsxs)(`span`,{children:[P.filename,` · `,P.width,`×`,P.height]}),(0,Q.jsx)(`button`,{onClick:()=>F(null),className:`p-2 rounded border border-shogun-border`,children:(0,Q.jsx)(ie,{className:`w-4 h-4`})})]})]})}),ee&&(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-50 flex`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>_(!1)}),(0,Q.jsxs)(`div`,{className:`absolute right-0 top-0 h-full w-full max-w-xl bg-shogun-bg border-l border-shogun-border flex flex-col shadow-2xl`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between p-5 border-b border-shogun-border shrink-0`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`text-lg font-bold text-shogun-text flex items-center gap-2`,children:[(0,Q.jsx)(I,{className:`w-5 h-5 text-shogun-gold`}),e(`chat.comms_history`,`Comms History`)]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued mt-0.5`,children:[y.length,` `,e(`chat.archived_sessions`,`archived sessions`)]})]}),(0,Q.jsx)(`button`,{onClick:()=>_(!1),className:`p-2 text-shogun-subdued hover:text-shogun-text hover:bg-shogun-card rounded-lg transition-all`,children:(0,Q.jsx)(ie,{className:`w-5 h-5`})})]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-2`,children:y.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-shogun-subdued space-y-3 opacity-50`,children:[(0,Q.jsx)(I,{className:`w-10 h-10`}),(0,Q.jsx)(`p`,{className:`text-sm italic`,children:e(`chat.no_history`,`No archived sessions found.`)})]}):y.map(t=>{let n=te===t.id,r=t.messages.find(e=>e.role===`user`)?.content||`(empty)`,i=t.messages.filter(e=>e.role===`user`).length;return(0,Q.jsxs)(`div`,{className:`border border-shogun-border rounded-xl overflow-hidden`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 p-3 cursor-pointer hover:bg-shogun-card/50 transition-colors`,onClick:()=>w(n?null:t.id),children:[n?(0,Q.jsx)(o,{className:`w-4 h-4 text-shogun-subdued shrink-0`}):(0,Q.jsx)(c,{className:`w-4 h-4 text-shogun-subdued shrink-0`}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-mono text-shogun-text truncate`,children:r}),(0,Q.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[t.startedAt,` · `,i,` `,e(`chat.messages`,`messages`)]})]}),(0,Q.jsx)(`button`,{onClick:e=>{e.stopPropagation(),J(t)},className:`text-[10px] text-shogun-blue hover:text-shogun-gold font-bold uppercase tracking-wider shrink-0 px-2 py-1 border border-shogun-blue/30 rounded-lg transition-colors`,children:e(`chat.restore`,`RESTORE`)})]}),n&&(0,Q.jsx)(`div`,{className:`border-t border-shogun-border bg-[#050508] p-3 space-y-2 max-h-64 overflow-y-auto`,children:t.messages.map((e,t)=>(0,Q.jsxs)(`div`,{className:z(`text-xs`,e.role===`user`?`text-right`:`text-left`),children:[(0,Q.jsx)(`span`,{className:z(`inline-block px-3 py-1.5 rounded-lg max-w-[85%] text-left`,e.role===`user`?`bg-shogun-blue/10 text-shogun-text border border-shogun-blue/20`:`bg-shogun-gold/5 text-shogun-gold border border-shogun-gold/10 font-mono`),children:e.content.length>120?e.content.slice(0,120)+`…`:e.content}),(0,Q.jsx)(`div`,{className:`text-[9px] text-shogun-subdued mt-0.5 px-1`,children:e.timestamp})]},t))})]},t.id)})}),y.length>0&&(0,Q.jsx)(`div`,{className:`p-4 border-t border-shogun-border shrink-0`,children:(0,Q.jsx)(`button`,{onClick:()=>{localStorage.removeItem(ve),S([])},className:`w-full text-xs text-red-400/60 hover:text-red-400 transition-colors py-2 border border-red-400/10 hover:border-red-400/30 rounded-lg`,children:e(`chat.clear_all_history`,`CLEAR ALL HISTORY`)})})]})]})]})},ke=()=>{let{t:e}=H(),[t,n]=(0,Z.useState)(`chat`);return(0,Q.jsxs)(`div`,{className:`flex flex-col w-full min-w-0 h-[calc(100vh-140px)] space-y-4`,children:[(0,Q.jsx)(`div`,{className:`flex justify-between items-center shrink-0`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`chat.title`,`Comms`),` `,(0,Q.jsxs)(`span`,{className:`text-xs font-normal text-shogun-subdued bg-shogun-card px-2 py-1 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:[t===`chat`&&e(`chat.badge`,`Command Console`),t===`mail`&&e(`mail.badge`,`Mail Client`),t===`calendar`&&e(`calendar.badge`,`Calendar Board`),t===`files`&&`File Explorer`]})]}),(0,Q.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`comms.subtitle`,`Chat · Mail · Calendar · Files`)})]})}),(0,Q.jsx)(`div`,{className:`flex border-b border-shogun-border shrink-0`,children:[{id:`chat`,label:e(`chat.tab_chat`,`Chat`),icon:V},{id:`mail`,label:e(`chat.tab_mail`,`Mail`),icon:y},{id:`calendar`,label:e(`chat.tab_calendar`,`Calendar`),icon:r},{id:`files`,label:`Files`,icon:g}].map(({id:e,label:r,icon:i})=>(0,Q.jsxs)(`button`,{onClick:()=>n(e),className:z(`px-6 py-3 text-sm font-bold uppercase tracking-widest transition-all relative flex items-center gap-2`,t===e?`text-shogun-blue`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,Q.jsx)(i,{className:`w-4 h-4`}),r,t===e&&(0,Q.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-blue shadow-[0_0_10px_rgba(74,140,199,0.5)]`})]},e))}),(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0`,children:[t===`chat`&&(0,Q.jsx)(Oe,{}),t===`mail`&&(0,Q.jsx)(de,{}),t===`calendar`&&(0,Q.jsx)(fe,{}),t===`files`&&(0,Q.jsx)($,{})]})]})};export{ke as Chat}; \ No newline at end of file diff --git a/frontend/dist/assets/Dashboard-B7DagOAO.js b/frontend/dist/assets/Dashboard-B7DagOAO.js deleted file mode 100644 index 57b26a8..0000000 --- a/frontend/dist/assets/Dashboard-B7DagOAO.js +++ /dev/null @@ -1 +0,0 @@ -import{o as e,r as t,t as n}from"./jsx-runtime-DmifIpYY.js";import{n as r}from"./chunk-OE4NN4TA-BT-WiWAe.js";import{t as i}from"./activity-D6ZKsL_W.js";import{t as a}from"./chevron-right-BzAY5P9l.js";import{t as o}from"./circle-alert-DVHRBFRQ.js";import{t as s}from"./clock-B8iyCT3M.js";import{t as c}from"./cpu-jON2DlCR.js";import{t as l}from"./layout-grid-CJTAEcGa.js";import{t as u}from"./lock-CYZB3Koj.js";import{t as d}from"./plus-DFW_DMbT.js";import{t as f}from"./power-BmbVankB.js";import{t as p}from"./refresh-cw-CCrS0Omg.js";import{t as m}from"./server-CMY38Yt2.js";import{t as h}from"./settings-DYFQa-lL.js";import{t as g}from"./shield-alert-ClN8pu2X.js";import{t as _}from"./shield-B_MY4jWU.js";import{t as v}from"./trending-up-CM0DQ6z2.js";import{t as y}from"./users-D7R1ctQe.js";import{t as b}from"./x-Bu7rztmN.js";import{t as x}from"./zap-BMpqZS6N.js";import{t as S}from"./utils-wrb6h48Y.js";import{r as C}from"./i18n-FxgwkwP0.js";import{t as w}from"./axios-BPyV2soB.js";import{t as T}from"./HarakiriModal-uap-l0fS.js";var E=e(t(),1),D=n(),O=({title:e,value:t,status:n,icon:i,colorClass:a,trend:o,to:s})=>{let c=(0,D.jsxs)(`div`,{className:S(`shogun-card group transition-all duration-300 relative overflow-hidden`,s&&`cursor-pointer hover:border-shogun-blue/50 hover:shadow-lg hover:shadow-shogun-blue/5`),children:[(0,D.jsx)(`div`,{className:`absolute -right-2 -bottom-2 opacity-[0.03] group-hover:opacity-[0.07] transition-opacity`,children:(0,D.jsx)(i,{className:`w-24 h-24`})}),(0,D.jsxs)(`div`,{className:`flex justify-between items-start mb-4 relative z-10`,children:[(0,D.jsx)(`div`,{className:S(`p-2 rounded-lg bg-opacity-10`,a.replace(`text-`,`bg-`)),children:(0,D.jsx)(i,{className:S(`w-5 h-5`,a)})}),(0,D.jsxs)(`div`,{className:`flex flex-col items-end`,children:[n&&(0,D.jsx)(`span`,{className:S(`text-[8px] uppercase font-bold px-2 py-0.5 rounded-full border mb-1`,n===`healthy`||n===`online`||n===`active`?`text-green-500 border-green-500/30 bg-green-500/5`:`text-shogun-gold border-shogun-gold/30 bg-shogun-gold/5`),children:n}),o&&(0,D.jsxs)(`span`,{className:`text-[9px] text-green-500 flex items-center gap-1 font-bold`,children:[(0,D.jsx)(v,{className:`w-2.5 h-2.5`}),` `,o]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1 relative z-10`,children:[(0,D.jsx)(`h3`,{className:`text-shogun-subdued text-[10px] font-bold uppercase tracking-widest`,children:e}),(0,D.jsx)(`p`,{className:`text-2xl font-bold text-shogun-text group-hover:text-shogun-gold transition-colors`,children:t})]})]});return s===`/samurai`?(0,D.jsx)(`a`,{href:`/samurai`,className:`block`,children:c}):s?(0,D.jsx)(r,{to:s,className:`block`,children:c}):c},k=()=>{let[e,t]=(0,E.useState)(null),[n,v]=(0,E.useState)(!0),[k,A]=(0,E.useState)(null),[j,M]=(0,E.useState)(!1),[N,P]=(0,E.useState)(!1),[F,I]=(0,E.useState)(null),{t:L}=C(),R=k?.active_tier||e?.security_posture?.tier||`tactical`,z=k?.active_policy_is_builtin===!1?k?.active_policy_name:null,B=async()=>{v(!0);try{let[e,n]=await Promise.all([w.get(`/api/v1/system/overview`),w.get(`/api/v1/security/posture`)]);t(e.data.data),A(n.data.data)}catch(e){console.error(`Failed to fetch dashboard data:`,e)}finally{v(!1)}},V=async()=>{if(k?.kill_switch_active){if(!confirm(L(`dashboard.reset_confirm`,`Reset Harakiri? Posture will be restored to TACTICAL.`)))return;M(!0);try{A((await w.delete(`/api/v1/security/kill-switch`)).data.data)}catch{}finally{M(!1)}return}P(!0)},H=async()=>{P(!1),M(!0);try{A((await w.post(`/api/v1/security/kill-switch`)).data.data)}catch{}finally{M(!1)}},U=async()=>{try{I((await w.get(`/api/v1/system/metrics`)).data.data)}catch{}};return(0,E.useEffect)(()=>{B(),U();let e=setInterval(U,5e3);return()=>clearInterval(e)},[]),(0,D.jsxs)(`div`,{className:`space-y-8 pb-12 animate-in fade-in duration-700`,children:[k?.kill_switch_active&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-4 bg-red-500/10 border border-red-500/40 rounded-xl animate-pulse shadow-[0_0_30px_rgba(239,68,68,0.15)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(g,{className:`w-5 h-5 text-red-500 shrink-0`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-sm font-bold text-red-400 uppercase tracking-wider`,children:L(`topbar.harakiri_active`,`⛔ GLOBAL KILL-SWITCH ACTIVE`)}),(0,D.jsx)(`p`,{className:`text-[10px] text-red-400/70 mt-0.5`,children:L(`dashboard.harakiri_suspended`,`All autonomous agent activity is suspended. Posture locked to SHRINE.`)})]})]}),(0,D.jsxs)(`button`,{onClick:V,disabled:j,className:`flex items-center gap-2 px-4 py-2 bg-red-500 hover:bg-red-600 text-white font-bold text-xs rounded-lg transition-all shrink-0 disabled:opacity-50`,children:[(0,D.jsx)(b,{className:`w-3.5 h-3.5`}),` `,L(`topbar.reset_harakiri`,`Reset Kill Switch`)]})]}),(0,D.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-end justify-between gap-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h2`,{className:`text-4xl font-bold shogun-title flex items-center gap-3`,children:[`Tenshu `,(0,D.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-3 py-1 rounded border border-shogun-border uppercase tracking-[0.3em] ml-2`,children:L(`dashboard.title_command_center`,`Command Center`)})]}),(0,D.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-2 font-medium`,children:L(`dashboard.title_desc`,`Monitoring the Samurai lattice and autonomous behavioral loops.`)})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`button`,{onClick:B,disabled:n,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,D.jsx)(p,{className:S(`w-4 h-4`,n&&`animate-spin`)})}),(0,D.jsxs)(r,{to:`/chat`,className:`flex items-center gap-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun`,children:[L(`dashboard.enter_command`,`ENTER COMMAND`),` `,(0,D.jsx)(a,{className:`w-4 h-4`})]})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6`,children:[(0,D.jsx)(O,{title:L(`dashboard.system_health`,`Neural Engine`),value:e?.shogun_profile?.name||`Shogun Prime`,status:e?.system_health?.runtime||`online`,icon:c,colorClass:`text-shogun-blue`,trend:`+5.2%`,to:`/shogun`}),(0,D.jsx)(O,{title:L(`dashboard.active_samurai`,`Active Lattice`),value:`${e?.active_samurai?.length||0} ${L(`dashboard.samurai_unit`,`Samurai`)}`,status:L(`dashboard.operational`,`operational`),icon:y,colorClass:`text-shogun-gold`,trend:L(`dashboard.grid_stable`,`Grid Stable`),to:`/samurai`}),(0,D.jsx)(O,{title:L(`dashboard.database`,`Knowledge Vol.`),value:`${e?.knowledge_volume?.toLocaleString()||`1,248`} ${L(`dashboard.records`,`Records`)}`,status:e?.system_health?.qdrant===`healthy`?L(`dashboard.lattice_indexed`,`Lattice Indexed`):e?.system_health?.qdrant||L(`dashboard.indexed`,`indexed`),icon:m,colorClass:e?.system_health?.qdrant===`healthy`?`text-green-500`:`text-red-500`,trend:e?.system_health?.qdrant===`healthy`?L(`dashboard.recall`,`99.9% Recall`):L(`dashboard.sync_error`,`Sync Error`),to:`/archives`}),(0,D.jsx)(O,{title:L(`dashboard.security_posture`,`Security Posture`),value:z||R.toUpperCase(),status:z?`CUSTOM · ${R.toUpperCase()}`:L(`common.active`,`Active`),icon:_,colorClass:{shrine:`text-shogun-gold`,guarded:`text-green-400`,tactical:`text-shogun-blue`,campaign:`text-orange-400`,ronin:`text-red-500`}[R]||`text-shogun-blue`,to:`/torii`})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,D.jsxs)(`div`,{className:`lg:col-span-2 space-y-8`,children:[(0,D.jsxs)(`div`,{className:`shogun-card overflow-hidden !p-0`,children:[(0,D.jsxs)(`div`,{className:`p-5 border-b border-shogun-border bg-[#050508]/50 flex items-center justify-between`,children:[(0,D.jsxs)(`h3`,{className:`font-bold text-shogun-text flex items-center gap-3`,children:[(0,D.jsx)(l,{className:`w-4 h-4 text-shogun-blue`}),L(`dashboard.active_deployment`,`Active Deployment Registry`)]}),(0,D.jsxs)(`a`,{href:`/samurai`,className:`text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors flex items-center gap-1`,children:[L(`dashboard.full_fleet`,`Full Fleet`),` `,(0,D.jsx)(a,{className:`w-3 h-3`})]})]}),(0,D.jsx)(`div`,{className:`overflow-x-auto`,children:(0,D.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{className:`border-b border-shogun-border text-shogun-subdued uppercase text-[9px] tracking-widest bg-[#050508]/30`,children:[(0,D.jsx)(`th`,{className:`p-5 font-bold`,children:L(`dashboard.designation`,`Designation`)}),(0,D.jsx)(`th`,{className:`p-5 font-bold`,children:L(`dashboard.current_task`,`Current Task`)}),(0,D.jsx)(`th`,{className:`p-5 font-bold`,children:L(`dashboard.engagement`,`Engagement`)}),(0,D.jsx)(`th`,{className:`p-5 font-bold text-right`,children:L(`dashboard.status`,`Status`)})]})}),(0,D.jsx)(`tbody`,{className:`divide-y divide-shogun-border`,children:(e?.active_samurai||[]).map(e=>(0,D.jsxs)(`tr`,{className:`group hover:bg-shogun-gold/5 transition-all`,children:[(0,D.jsx)(`td`,{className:`p-5`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`div`,{className:`w-8 h-8 rounded bg-[#050508] border border-shogun-border flex items-center justify-center font-bold text-shogun-gold text-xs group-hover:border-shogun-gold/50`,children:e.name[0]}),(0,D.jsx)(`span`,{className:`font-bold text-shogun-text`,children:e.name})]})}),(0,D.jsx)(`td`,{className:`p-5 text-shogun-subdued text-xs font-medium`,children:e.current_task}),(0,D.jsx)(`td`,{className:`p-5`,children:(0,D.jsx)(`div`,{className:`w-24 h-1.5 bg-shogun-card rounded-full overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full bg-shogun-blue rounded-full`,style:{width:e.status===`active`?`85%`:`15%`}})})}),(0,D.jsx)(`td`,{className:`p-5 text-right`,children:(0,D.jsx)(`span`,{className:S(`text-[9px] px-2 py-0.5 rounded border font-bold uppercase tracking-tighter`,e.status===`active`?`text-green-500 border-green-500/20 bg-green-500/5`:`text-shogun-subdued border-shogun-subdued/20 bg-shogun-subdued/5`),children:e.status})})]},e.id))})]})})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,D.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,D.jsxs)(`h3`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,D.jsx)(x,{className:`w-4 h-4 text-shogun-gold`}),` `,L(`dashboard.quick_actions`,`Quick Actions`)]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,D.jsxs)(`a`,{href:`/samurai`,className:`flex flex-col items-center justify-center p-4 bg-[#050508] border border-shogun-border rounded-xl hover:border-shogun-gold transition-all group`,children:[(0,D.jsx)(d,{className:`w-5 h-5 text-shogun-subdued group-hover:text-shogun-gold mb-2`}),(0,D.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued group-hover:text-shogun-text`,children:L(`dashboard.new_samurai`,`New Samurai`)})]}),(0,D.jsxs)(r,{to:`/katana`,className:`flex flex-col items-center justify-center p-4 bg-[#050508] border border-shogun-border rounded-xl hover:border-shogun-blue transition-all group`,children:[(0,D.jsx)(h,{className:`w-5 h-5 text-shogun-subdued group-hover:text-shogun-blue mb-2`}),(0,D.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued group-hover:text-shogun-text`,children:L(`dashboard.model_setup`,`Model Setup`)})]})]})]}),(0,D.jsxs)(`div`,{className:`shogun-card flex flex-col justify-center items-center text-center space-y-3 bg-red-500/5 border-red-500/20`,children:[(0,D.jsx)(`div`,{className:S(`w-10 h-10 rounded-full flex items-center justify-center`,k?.kill_switch_active?`bg-red-500 text-white animate-pulse`:`bg-red-500/20 text-red-500`),children:(0,D.jsx)(f,{className:`w-5 h-5`})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:k?.kill_switch_active?L(`dashboard.harakiri_activated`,`Harakiri Active`):L(`dashboard.harakiri`,`Emergency Stop`)}),(0,D.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1 px-4`,children:k?.kill_switch_active?L(`dashboard.harakiri_suspended`,`All agents suspended. Posture: SHRINE.`):L(`dashboard.harakiri_desc`,`Immediately suspend all active autonomous engagement.`)})]}),(0,D.jsxs)(`button`,{onClick:V,disabled:j,className:S(`flex items-center gap-3 text-white rounded-lg transition-all shadow-lg disabled:opacity-50 active:scale-95 px-5 py-2`,k?.kill_switch_active?`bg-green-600 hover:bg-green-700`:`bg-red-500 hover:bg-red-600`),children:[(0,D.jsx)(f,{className:`w-4 h-4 shrink-0`}),(0,D.jsxs)(`div`,{className:`flex flex-col items-start`,children:[(0,D.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] leading-tight`,children:j?L(`common.loading`,`Working...`):k?.kill_switch_active?L(`topbar.reset_harakiri`,`Reset Harakiri`):L(`dashboard.harakiri`,`Harakiri`)}),!j&&(0,D.jsxs)(`span`,{className:`text-[8px] font-normal opacity-70 tracking-widest leading-tight`,children:[`[`,L(`torii.kill_switch`,`Kill Switch`),`]`]})]})]})]})]})]}),(0,D.jsx)(`div`,{className:`space-y-6`,children:(0,D.jsxs)(`div`,{className:`shogun-card h-full min-h-[500px] flex flex-col`,children:[(0,D.jsxs)(`h3`,{className:`font-bold text-shogun-text flex items-center gap-3 mb-6`,children:[(0,D.jsx)(s,{className:`w-4 h-4 text-shogun-blue`}),L(`dashboard.recent_events`,`Telemetry Feed`)]}),(0,D.jsx)(`div`,{className:`space-y-8 flex-1`,children:(e?.recent_events||[]).map((t,n)=>(0,D.jsxs)(`div`,{className:`flex gap-4 group`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,D.jsx)(`div`,{className:S(`p-1.5 rounded-lg border`,t.type===`security`?`text-red-500 border-red-500/30 bg-red-500/5`:t.type===`agent`?`text-shogun-gold border-shogun-gold/30 bg-shogun-gold/5`:`text-shogun-blue border-shogun-blue/30 bg-shogun-blue/5`),children:t.type===`security`?(0,D.jsx)(u,{className:`w-3 h-3`}):t.type===`agent`?(0,D.jsx)(y,{className:`w-3 h-3`}):(0,D.jsx)(i,{className:`w-3 h-3`})}),n(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex justify-between text-[10px] font-bold uppercase mb-1`,children:[(0,D.jsx)(`span`,{className:`text-shogun-subdued`,children:e.label}),(0,D.jsx)(`span`,{className:S(e.value>85?`text-red-500`:e.value>60?`text-shogun-gold`:`text-green-500`),children:e.detail})]}),(0,D.jsx)(`div`,{className:`w-full h-1 bg-shogun-card rounded-full overflow-hidden`,children:(0,D.jsx)(`div`,{className:S(`h-full rounded-full transition-all duration-700`,e.value>85?`bg-red-500`:e.value>60?`bg-shogun-gold`:`bg-green-500`),style:{width:`${e.value}%`}})})]},e.label))})]})]})})]}),N&&(0,D.jsx)(T,{onConfirm:H,onCancel:()=>P(!1)})]})};export{k as Dashboard}; \ No newline at end of file diff --git a/frontend/dist/assets/Dashboard-TALL07U2.js b/frontend/dist/assets/Dashboard-TALL07U2.js new file mode 100644 index 0000000..f97d6cd --- /dev/null +++ b/frontend/dist/assets/Dashboard-TALL07U2.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chevron-right-CVeYaFvJ.js";import{t as n}from"./circle-alert-043xB2li.js";import{t as r}from"./clock-DQ9Dz1_z.js";import{t as i}from"./cpu-BM3hm7mB.js";import{t as a}from"./layout-grid-BCXZ_u1g.js";import{t as o}from"./lock-CGEyUK_n.js";import{t as s}from"./plus-Cxx0HjpF.js";import{t as c}from"./power-Bl6a5geq.js";import{t as l}from"./refresh-cw-Dm6S5UAJ.js";import{t as u}from"./server-CVvUGKOH.js";import{t as d}from"./settings-DedojrI9.js";import{t as f}from"./shield-alert-DzWPVhkC.js";import{t as p}from"./trending-up-Coxuq0al.js";import{t as m}from"./zap-CQy--vuS.js";import{E as h,a as g,i as _,j as v,o as y,r as b,t as x,u as S,w as C}from"./index-Dy1E248t.js";import{t as w}from"./axios-BGmZl9Qd.js";import{t as T}from"./HarakiriModal-ChG-WA-N.js";var E=e(v(),1),D=x(),O=({title:e,value:t,status:n,icon:r,colorClass:i,trend:a,to:o})=>{let s=(0,D.jsxs)(`div`,{className:_(`shogun-card group transition-all duration-300 relative overflow-hidden`,o&&`cursor-pointer hover:border-shogun-blue/50 hover:shadow-lg hover:shadow-shogun-blue/5`),children:[(0,D.jsx)(`div`,{className:`absolute -right-2 -bottom-2 opacity-[0.03] group-hover:opacity-[0.07] transition-opacity`,children:(0,D.jsx)(r,{className:`w-24 h-24`})}),(0,D.jsxs)(`div`,{className:`flex justify-between items-start mb-4 relative z-10`,children:[(0,D.jsx)(`div`,{className:_(`p-2 rounded-lg bg-opacity-10`,i.replace(`text-`,`bg-`)),children:(0,D.jsx)(r,{className:_(`w-5 h-5`,i)})}),(0,D.jsxs)(`div`,{className:`flex flex-col items-end`,children:[n&&(0,D.jsx)(`span`,{className:_(`text-[8px] uppercase font-bold px-2 py-0.5 rounded-full border mb-1`,n===`healthy`||n===`online`||n===`active`?`text-green-500 border-green-500/30 bg-green-500/5`:`text-shogun-gold border-shogun-gold/30 bg-shogun-gold/5`),children:n}),a&&(0,D.jsxs)(`span`,{className:`text-[9px] text-green-500 flex items-center gap-1 font-bold`,children:[(0,D.jsx)(p,{className:`w-2.5 h-2.5`}),` `,a]})]})]}),(0,D.jsxs)(`div`,{className:`space-y-1 relative z-10`,children:[(0,D.jsx)(`h3`,{className:`text-shogun-subdued text-[10px] font-bold uppercase tracking-widest`,children:e}),(0,D.jsx)(`p`,{className:`text-2xl font-bold text-shogun-text group-hover:text-shogun-gold transition-colors`,children:t})]})]});return o===`/samurai`?(0,D.jsx)(`a`,{href:`/samurai`,className:`block`,children:s}):o?(0,D.jsx)(h,{to:o,className:`block`,children:s}):s},k=()=>{let[e,p]=(0,E.useState)(null),[v,x]=(0,E.useState)(!0),[k,A]=(0,E.useState)(null),[j,M]=(0,E.useState)(!1),[N,P]=(0,E.useState)(!1),[F,I]=(0,E.useState)(null),{t:L}=b(),R=k?.active_tier||e?.security_posture?.tier||`tactical`,z=k?.active_policy_is_builtin===!1?k?.active_policy_name:null,B=async()=>{x(!0);try{let[e,t]=await Promise.all([w.get(`/api/v1/system/overview`),w.get(`/api/v1/security/posture`)]);p(e.data.data),A(t.data.data)}catch(e){console.error(`Failed to fetch dashboard data:`,e)}finally{x(!1)}},V=async()=>{if(k?.kill_switch_active){if(!confirm(L(`dashboard.reset_confirm`,`Reset Harakiri? Posture will be restored to TACTICAL.`)))return;M(!0);try{let e=await w.delete(`/api/v1/security/kill-switch`);A(e.data.data)}catch{}finally{M(!1)}return}P(!0)},H=async()=>{P(!1),M(!0);try{let e=await w.post(`/api/v1/security/kill-switch`);A(e.data.data)}catch{}finally{M(!1)}},U=async()=>{try{let e=await w.get(`/api/v1/system/metrics`);I(e.data.data)}catch{}};return(0,E.useEffect)(()=>{B(),U();let e=setInterval(U,5e3);return()=>clearInterval(e)},[]),(0,D.jsxs)(`div`,{className:`space-y-8 pb-12 animate-in fade-in duration-700`,children:[k?.kill_switch_active&&(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-4 p-4 bg-red-500/10 border border-red-500/40 rounded-xl animate-pulse shadow-[0_0_30px_rgba(239,68,68,0.15)]`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(f,{className:`w-5 h-5 text-red-500 shrink-0`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`span`,{className:`text-sm font-bold text-red-400 uppercase tracking-wider`,children:L(`topbar.harakiri_active`,`⛔ GLOBAL KILL-SWITCH ACTIVE`)}),(0,D.jsx)(`p`,{className:`text-[10px] text-red-400/70 mt-0.5`,children:L(`dashboard.harakiri_suspended`,`All autonomous agent activity is suspended. Posture locked to SHRINE.`)})]})]}),(0,D.jsxs)(`button`,{onClick:V,disabled:j,className:`flex items-center gap-2 px-4 py-2 bg-red-500 hover:bg-red-600 text-white font-bold text-xs rounded-lg transition-all shrink-0 disabled:opacity-50`,children:[(0,D.jsx)(g,{className:`w-3.5 h-3.5`}),` `,L(`topbar.reset_harakiri`,`Reset Kill Switch`)]})]}),(0,D.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-end justify-between gap-4`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`h2`,{className:`text-4xl font-bold shogun-title flex items-center gap-3`,children:[`Tenshu `,(0,D.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-3 py-1 rounded border border-shogun-border uppercase tracking-[0.3em] ml-2`,children:L(`dashboard.title_command_center`,`Command Center`)})]}),(0,D.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-2 font-medium`,children:L(`dashboard.title_desc`,`Monitoring the Samurai lattice and autonomous behavioral loops.`)})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`button`,{onClick:B,disabled:v,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,D.jsx)(l,{className:_(`w-4 h-4`,v&&`animate-spin`)})}),(0,D.jsxs)(h,{to:`/chat`,className:`flex items-center gap-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun`,children:[L(`dashboard.enter_command`,`ENTER COMMAND`),` `,(0,D.jsx)(t,{className:`w-4 h-4`})]})]})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6`,children:[(0,D.jsx)(O,{title:L(`dashboard.system_health`,`Neural Engine`),value:e?.shogun_profile?.name||`Shogun Prime`,status:e?.system_health?.runtime||`online`,icon:i,colorClass:`text-shogun-blue`,trend:`+5.2%`,to:`/shogun`}),(0,D.jsx)(O,{title:L(`dashboard.active_samurai`,`Active Lattice`),value:`${e?.active_samurai?.length||0} ${L(`dashboard.samurai_unit`,`Samurai`)}`,status:L(`dashboard.operational`,`operational`),icon:y,colorClass:`text-shogun-gold`,trend:L(`dashboard.grid_stable`,`Grid Stable`),to:`/samurai`}),(0,D.jsx)(O,{title:L(`dashboard.database`,`Knowledge Vol.`),value:`${e?.knowledge_volume?.toLocaleString()||`1,248`} ${L(`dashboard.records`,`Records`)}`,status:e?.system_health?.qdrant===`healthy`?L(`dashboard.lattice_indexed`,`Lattice Indexed`):e?.system_health?.qdrant||L(`dashboard.indexed`,`indexed`),icon:u,colorClass:e?.system_health?.qdrant===`healthy`?`text-green-500`:`text-red-500`,trend:e?.system_health?.qdrant===`healthy`?L(`dashboard.recall`,`99.9% Recall`):L(`dashboard.sync_error`,`Sync Error`),to:`/archives`}),(0,D.jsx)(O,{title:L(`dashboard.security_posture`,`Security Posture`),value:z||R.toUpperCase(),status:z?`CUSTOM · ${R.toUpperCase()}`:L(`common.active`,`Active`),icon:S,colorClass:{shrine:`text-shogun-gold`,guarded:`text-green-400`,tactical:`text-shogun-blue`,campaign:`text-orange-400`,ronin:`text-red-500`}[R]||`text-shogun-blue`,to:`/torii`})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,D.jsxs)(`div`,{className:`lg:col-span-2 space-y-8`,children:[(0,D.jsxs)(`div`,{className:`shogun-card overflow-hidden !p-0`,children:[(0,D.jsxs)(`div`,{className:`p-5 border-b border-shogun-border bg-[#050508]/50 flex items-center justify-between`,children:[(0,D.jsxs)(`h3`,{className:`font-bold text-shogun-text flex items-center gap-3`,children:[(0,D.jsx)(a,{className:`w-4 h-4 text-shogun-blue`}),L(`dashboard.active_deployment`,`Active Deployment Registry`)]}),(0,D.jsxs)(`a`,{href:`/samurai`,className:`text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors flex items-center gap-1`,children:[L(`dashboard.full_fleet`,`Full Fleet`),` `,(0,D.jsx)(t,{className:`w-3 h-3`})]})]}),(0,D.jsx)(`div`,{className:`overflow-x-auto`,children:(0,D.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{className:`border-b border-shogun-border text-shogun-subdued uppercase text-[9px] tracking-widest bg-[#050508]/30`,children:[(0,D.jsx)(`th`,{className:`p-5 font-bold`,children:L(`dashboard.designation`,`Designation`)}),(0,D.jsx)(`th`,{className:`p-5 font-bold`,children:L(`dashboard.current_task`,`Current Task`)}),(0,D.jsx)(`th`,{className:`p-5 font-bold`,children:L(`dashboard.engagement`,`Engagement`)}),(0,D.jsx)(`th`,{className:`p-5 font-bold text-right`,children:L(`dashboard.status`,`Status`)})]})}),(0,D.jsx)(`tbody`,{className:`divide-y divide-shogun-border`,children:(e?.active_samurai||[]).map(e=>(0,D.jsxs)(`tr`,{className:`group hover:bg-shogun-gold/5 transition-all`,children:[(0,D.jsx)(`td`,{className:`p-5`,children:(0,D.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,D.jsx)(`div`,{className:`w-8 h-8 rounded bg-[#050508] border border-shogun-border flex items-center justify-center font-bold text-shogun-gold text-xs group-hover:border-shogun-gold/50`,children:e.name[0]}),(0,D.jsx)(`span`,{className:`font-bold text-shogun-text`,children:e.name})]})}),(0,D.jsx)(`td`,{className:`p-5 text-shogun-subdued text-xs font-medium`,children:e.current_task}),(0,D.jsx)(`td`,{className:`p-5`,children:(0,D.jsx)(`div`,{className:`w-24 h-1.5 bg-shogun-card rounded-full overflow-hidden`,children:(0,D.jsx)(`div`,{className:`h-full bg-shogun-blue rounded-full`,style:{width:e.status===`active`?`85%`:`15%`}})})}),(0,D.jsx)(`td`,{className:`p-5 text-right`,children:(0,D.jsx)(`span`,{className:_(`text-[9px] px-2 py-0.5 rounded border font-bold uppercase tracking-tighter`,e.status===`active`?`text-green-500 border-green-500/20 bg-green-500/5`:`text-shogun-subdued border-shogun-subdued/20 bg-shogun-subdued/5`),children:e.status})})]},e.id))})]})})]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,D.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,D.jsxs)(`h3`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,D.jsx)(m,{className:`w-4 h-4 text-shogun-gold`}),` `,L(`dashboard.quick_actions`,`Quick Actions`)]}),(0,D.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,D.jsxs)(`a`,{href:`/samurai`,className:`flex flex-col items-center justify-center p-4 bg-[#050508] border border-shogun-border rounded-xl hover:border-shogun-gold transition-all group`,children:[(0,D.jsx)(s,{className:`w-5 h-5 text-shogun-subdued group-hover:text-shogun-gold mb-2`}),(0,D.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued group-hover:text-shogun-text`,children:L(`dashboard.new_samurai`,`New Samurai`)})]}),(0,D.jsxs)(h,{to:`/katana`,className:`flex flex-col items-center justify-center p-4 bg-[#050508] border border-shogun-border rounded-xl hover:border-shogun-blue transition-all group`,children:[(0,D.jsx)(d,{className:`w-5 h-5 text-shogun-subdued group-hover:text-shogun-blue mb-2`}),(0,D.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued group-hover:text-shogun-text`,children:L(`dashboard.model_setup`,`Model Setup`)})]})]})]}),(0,D.jsxs)(`div`,{className:`shogun-card flex flex-col justify-center items-center text-center space-y-3 bg-red-500/5 border-red-500/20`,children:[(0,D.jsx)(`div`,{className:_(`w-10 h-10 rounded-full flex items-center justify-center`,k?.kill_switch_active?`bg-red-500 text-white animate-pulse`:`bg-red-500/20 text-red-500`),children:(0,D.jsx)(c,{className:`w-5 h-5`})}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:k?.kill_switch_active?L(`dashboard.harakiri_activated`,`Harakiri Active`):L(`dashboard.harakiri`,`Emergency Stop`)}),(0,D.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1 px-4`,children:k?.kill_switch_active?L(`dashboard.harakiri_suspended`,`All agents suspended. Posture: SHRINE.`):L(`dashboard.harakiri_desc`,`Immediately suspend all active autonomous engagement.`)})]}),(0,D.jsxs)(`button`,{onClick:V,disabled:j,className:_(`flex items-center gap-3 text-white rounded-lg transition-all shadow-lg disabled:opacity-50 active:scale-95 px-5 py-2`,k?.kill_switch_active?`bg-green-600 hover:bg-green-700`:`bg-red-500 hover:bg-red-600`),children:[(0,D.jsx)(c,{className:`w-4 h-4 shrink-0`}),(0,D.jsxs)(`div`,{className:`flex flex-col items-start`,children:[(0,D.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] leading-tight`,children:j?L(`common.loading`,`Working...`):k?.kill_switch_active?L(`topbar.reset_harakiri`,`Reset Harakiri`):L(`dashboard.harakiri`,`Harakiri`)}),!j&&(0,D.jsxs)(`span`,{className:`text-[8px] font-normal opacity-70 tracking-widest leading-tight`,children:[`[`,L(`torii.kill_switch`,`Kill Switch`),`]`]})]})]})]})]})]}),(0,D.jsx)(`div`,{className:`space-y-6`,children:(0,D.jsxs)(`div`,{className:`shogun-card h-full min-h-[500px] flex flex-col`,children:[(0,D.jsxs)(`h3`,{className:`font-bold text-shogun-text flex items-center gap-3 mb-6`,children:[(0,D.jsx)(r,{className:`w-4 h-4 text-shogun-blue`}),L(`dashboard.recent_events`,`Telemetry Feed`)]}),(0,D.jsx)(`div`,{className:`space-y-8 flex-1`,children:(e?.recent_events||[]).map((t,n)=>(0,D.jsxs)(`div`,{className:`flex gap-4 group`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,D.jsx)(`div`,{className:_(`p-1.5 rounded-lg border`,t.type===`security`?`text-red-500 border-red-500/30 bg-red-500/5`:t.type===`agent`?`text-shogun-gold border-shogun-gold/30 bg-shogun-gold/5`:`text-shogun-blue border-shogun-blue/30 bg-shogun-blue/5`),children:t.type===`security`?(0,D.jsx)(o,{className:`w-3 h-3`}):t.type===`agent`?(0,D.jsx)(y,{className:`w-3 h-3`}):(0,D.jsx)(C,{className:`w-3 h-3`})}),n(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex justify-between text-[10px] font-bold uppercase mb-1`,children:[(0,D.jsx)(`span`,{className:`text-shogun-subdued`,children:e.label}),(0,D.jsx)(`span`,{className:_(e.value>85?`text-red-500`:e.value>60?`text-shogun-gold`:`text-green-500`),children:e.detail})]}),(0,D.jsx)(`div`,{className:`w-full h-1 bg-shogun-card rounded-full overflow-hidden`,children:(0,D.jsx)(`div`,{className:_(`h-full rounded-full transition-all duration-700`,e.value>85?`bg-red-500`:e.value>60?`bg-shogun-gold`:`bg-green-500`),style:{width:`${e.value}%`}})})]},e.label))})]})]})})]}),N&&(0,D.jsx)(T,{onConfirm:H,onCancel:()=>P(!1)})]})};export{k as Dashboard}; \ No newline at end of file diff --git a/frontend/dist/assets/Dojo-7HoAvpnH.js b/frontend/dist/assets/Dojo-7HoAvpnH.js deleted file mode 100644 index bbd53ed..0000000 --- a/frontend/dist/assets/Dojo-7HoAvpnH.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{t as i}from"./book-c3cQ6ocr.js";import{t as a}from"./chevron-down-ZviArC66.js";import{t as o}from"./chevron-right-BzAY5P9l.js";import{t as s}from"./circle-alert-DVHRBFRQ.js";import{t as c}from"./circle-check-D9mntLsp.js";import{t as ee}from"./globe-CSe1LLSr.js";import{t as te}from"./layers-4dQLphXM.js";import{t as ne}from"./link-DhxsOVpy.js";import{t as l}from"./loader-circle-yHzGFbgr.js";import{t as u}from"./lock-CYZB3Koj.js";import{t as d}from"./package-CVNMjeKj.js";import{t as f}from"./plus-DFW_DMbT.js";import{t as p}from"./refresh-cw-CCrS0Omg.js";import{t as re}from"./search-CCF8DUSp.js";import{t as ie}from"./shield-check-4WxAMs16.js";import{t as ae}from"./shield-B_MY4jWU.js";import{t as m}from"./sparkles-DddBjN-5.js";import{t as oe}from"./star-HhdEV9Ok.js";import{t as h}from"./user-plus-DNXtLt6r.js";import{t as se}from"./x-Bu7rztmN.js";import{t as g}from"./zap-BMpqZS6N.js";import{t as _}from"./utils-wrb6h48Y.js";import{r as ce}from"./i18n-FxgwkwP0.js";import{t as v}from"./axios-BPyV2soB.js";var y=e(`award`,[[`path`,{d:`m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526`,key:`1yiouv`}],[`circle`,{cx:`12`,cy:`8`,r:`6`,key:`1vp47v`}]]),b=e(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),x=e(`graduation-cap`,[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]),S=e(`trophy`,[[`path`,{d:`M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978`,key:`1n3hpd`}],[`path`,{d:`M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978`,key:`rfe1zi`}],[`path`,{d:`M18 9h1.5a1 1 0 0 0 0-5H18`,key:`7xy6bh`}],[`path`,{d:`M4 22h16`,key:`57wxv0`}],[`path`,{d:`M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z`,key:`1mhfuq`}],[`path`,{d:`M6 9H4.5a1 1 0 0 1 0-5H6`,key:`tex48p`}]]),C=t(n(),1),w=r();function le(e){let t=e?.credential_model_ids||e?.credentialModelIds||e?.modelIds;return Array.isArray(t)&&t.length?t:[e?.modelId||e?.model_id||`unknown (legacy credential)`]}function T({item:e}){return(0,w.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-center gap-1`,children:le(e).map(e=>(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-shogun-border bg-[#050508] px-1.5 py-0.5 text-[8px] font-mono text-shogun-subdued`,children:[(0,w.jsx)(u,{className:`h-2.5 w-2.5`}),` `,e]},e))})}function E(){let{t:e}=ce(),[t,n]=(0,C.useState)(`catalog`),[r,E]=(0,C.useState)(!0),[de,fe]=(0,C.useState)([]),[pe,me]=(0,C.useState)([]),[he,ge]=(0,C.useState)([]),[_e,ve]=(0,C.useState)([]),[D,O]=(0,C.useState)(null),[k,ye]=(0,C.useState)(null),[A,be]=(0,C.useState)([]),[j,xe]=(0,C.useState)(``),[M,Se]=(0,C.useState)(null),[N,Ce]=(0,C.useState)(null),[we,P]=(0,C.useState)(!1),[F,Te]=(0,C.useState)(``),[Ee,De]=(0,C.useState)(!1),[I,Oe]=(0,C.useState)(``),[ke,Ae]=(0,C.useState)(!1),[L,R]=(0,C.useState)(null),[z,B]=(0,C.useState)(null),[V,je]=(0,C.useState)(null),[Me,Ne]=(0,C.useState)(null),[H,Pe]=(0,C.useState)(null),[U,Fe]=(0,C.useState)({}),[Ie,W]=(0,C.useState)(`idle`),[G,Le]=(0,C.useState)(null),[Re,ze]=(0,C.useState)(null),[Be,Ve]=(0,C.useState)(!1),[He,Ue]=(0,C.useState)(``),[We,Ge]=(0,C.useState)(!1),[Ke,qe]=(0,C.useState)(null),[Je,Ye]=(0,C.useState)(null),[K,Xe]=(0,C.useState)(null),[Ze,Qe]=(0,C.useState)(!1),[q,J]=(0,C.useState)(null),[Y,$e]=(0,C.useState)(new Set),[et,tt]=(0,C.useState)([]),[nt,rt]=(0,C.useState)(null),X=(0,C.useCallback)(async()=>{try{let[e,t]=await Promise.all([v.get(`/api/v1/dojo/openclaw/stats`),v.get(`/api/v1/dojo/openclaw/registration-status`)]);ye(e.data.data),Ce(t.data.data)}catch(e){console.error(`Error fetching stats:`,e)}},[]),Z=(0,C.useCallback)(async()=>{try{be((await v.get(`/api/v1/dojo/openclaw/subcategories`)).data.data||[])}catch(e){console.error(`Error fetching subcategories:`,e)}},[]),Q=(0,C.useCallback)(async()=>{try{let e=(await v.get(`/api/v1/dojo/openclaw/installed`)).data.data||[];tt(e),$e(new Set(e.map(e=>e.openclaw_skill_id).filter(Boolean)))}catch(e){console.error(`Error fetching installed skills:`,e)}},[]),$=(0,C.useCallback)(async()=>{E(!0),rt(null);try{if(t===`catalog`){let e={limit:200};j&&(e.search=j),fe((await v.get(`/api/v1/dojo/openclaw/skills`,{params:e})).data.data||[])}else if(t===`bundles`)me((await v.get(`/api/v1/dojo/openclaw/bundles`)).data.data||[]);else if(t===`specializations`){let[e,t]=await Promise.all([v.get(`/api/v1/dojo/openclaw/specializations`),v.get(`/api/v1/dojo/openclaw/achievements`).catch(()=>null)]);ge(e.data.data||[]),t&&O(t.data.data)}else if(t===`achieved`){let e=(await v.get(`/api/v1/dojo/openclaw/achievements`)).data.data;O(e),Ye({test_results:e?.achieved_skills||[],transcript:[]});let[t,n,r]=await Promise.allSettled([v.get(`/api/v1/dojo/openclaw/badges`),v.get(`/api/v1/dojo/openclaw/installed`),v.get(`/api/v1/dojo/openclaw/transcript`)]);if(t.status===`fulfilled`&&ve(t.value.data.data||[]),n.status===`fulfilled`){let e=n.value.data.data||[];tt(e),$e(new Set(e.map(e=>e.openclaw_skill_id).filter(Boolean)))}r.status===`fulfilled`&&r.value.data.data&&Ye(r.value.data.data)}}catch(e){console.error(`Error fetching tab data:`,e),rt(e.response?.data?.detail||e.response?.data?.message||e.message||`Unable to load Dojo data.`)}finally{E(!1)}},[t,j]);(0,C.useEffect)(()=>{X(),Z(),Q()},[X,Z,Q]),(0,C.useEffect)(()=>{let e=setTimeout(()=>{$()},t===`catalog`&&j?400:0);return()=>clearTimeout(e)},[t,j]);let it=async()=>{if(F.trim()){De(!0);try{Ce((await v.post(`/api/v1/dojo/openclaw/register`,{agent_name:F})).data.data),P(!1),Te(``)}catch(e){console.error(`Registration failed:`,e)}finally{De(!1)}}},at=async()=>{if(I.trim()){Ae(!0),R(null);try{R({type:`success`,text:(await v.post(`/api/v1/dojo/skills/add-url`,{url:I})).data.data.message}),Oe(``)}catch(e){R({type:`error`,text:e.response?.data?.detail||`Failed to import URL`})}finally{Ae(!1)}}},ot=async()=>{Ge(!0),qe(null);try{await v.post(`/api/v1/dojo/openclaw/credentials`,{openclaw_api_key:He}),qe({type:`success`,text:`API key saved.`}),Ue(``),Ve(!1),X()}catch(e){qe({type:`error`,text:e.response?.data?.detail||`Failed to save credentials`})}finally{Ge(!1)}},st=async e=>{W(`loading`),ze(null),Le(null);try{let t=(await v.post(`/api/v1/dojo/openclaw/exams/auto-take`,{skill_id:e})).data.data;Le(t),W(`result`);try{Ye((await v.get(`/api/v1/dojo/openclaw/transcript`)).data.data)}catch{}$()}catch(e){ze(e.response?.data?.detail||`Could not complete exam. Check your API key in credentials.`),W(`idle`)}},ct=()=>{W(`idle`),Le(null),ze(null)},lt=async e=>{Xe(e.id),J(null);try{(await v.post(`/api/v1/dojo/openclaw/install`,{openclaw_skill_id:e.id,skill_name:e.name,slug:e.slug||``,version:e.version||`1.0.0`,risk_tier:e.risk_tier||`standard`,description:e.description||``,permissions:e.permissions||{},capabilities:e.capabilities||[]})).data.data.already_installed?J({type:`info`,text:`${e.name} is already installed.`}):J({type:`success`,text:`${e.name} installed successfully!`}),$e(t=>new Set(t).add(e.id)),Q()}catch(e){J({type:`error`,text:e.response?.data?.detail||`Install failed.`})}finally{Xe(null),setTimeout(()=>J(null),4e3)}},ut=async()=>{Qe(!0),J(null);try{let e=(await v.post(`/api/v1/dojo/openclaw/installed/refresh`)).data.data||{};J({type:`success`,text:e.updated?`Updated ${e.updated} installed skill${e.updated===1?``:`s`} and synchronized Archives.`:`Installed skills are current. ${e.protected||0} SkillOpt version${e.protected===1?``:`s`} preserved.`}),await Q(),await $()}catch(e){J({type:`error`,text:e.response?.data?.detail||`Skill refresh failed.`})}finally{Qe(!1),setTimeout(()=>J(null),6e3)}},dt=async e=>{Ne(e.id),J(null);try{let t=(await v.post(`/api/v1/dojo/openclaw/specializations/${encodeURIComponent(e.id)}/enroll`)).data.data?.awarded||[];J({type:`success`,text:t.length?`Enrolled and awarded ${t.length} badge${t.length===1?``:`s`}!`:`Enrolled in ${e.name||e.title}.`}),O((await v.get(`/api/v1/dojo/openclaw/achievements`)).data.data)}catch(e){J({type:`error`,text:e.response?.data?.detail||`Specialization enrollment failed.`})}finally{Ne(null),setTimeout(()=>J(null),5e3)}},ft=de.filter(e=>{let t=!j||e.name?.toLowerCase().includes(j.toLowerCase())||e.description?.toLowerCase().includes(j.toLowerCase()),n=!z||e.faculty===z||e.subcategory===z;return t&&n}),pt=pe.filter(e=>!j||e.name?.toLowerCase().includes(j.toLowerCase())||e.description?.toLowerCase().includes(j.toLowerCase())),mt=he.filter(e=>!j||e.name?.toLowerCase().includes(j.toLowerCase())||e.description?.toLowerCase().includes(j.toLowerCase())),ht=Je?.test_results?.length?Je.test_results:D?.achieved_skills||[],gt=[{key:`catalog`,label:e(`dojo.tab_explore`,`Skill Catalog`),icon:i,count:k?.skills},{key:`bundles`,label:e(`dojo.tab_bundles`,`Ready Bundles`),icon:d,count:k?.bundles},{key:`specializations`,label:e(`dojo.tab_specializations`,`Specializations`),icon:x,count:k?.specializations},{key:`achieved`,label:e(`dojo.tab_achieved`,`Achieved`),icon:S}];return(0,w.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-7xl mx-auto pb-12`,children:[q&&(0,w.jsxs)(`div`,{className:_(`fixed top-6 right-6 z-50 px-5 py-3 rounded-xl shadow-lg text-sm font-bold animate-in slide-in-from-top duration-300 flex items-center gap-3`,q.type===`success`?`bg-green-500/90 text-white`:q.type===`info`?`bg-shogun-blue/90 text-white`:`bg-red-500/90 text-white`),children:[q.type===`success`?(0,w.jsx)(c,{className:`w-4 h-4`}):q.type===`info`?(0,w.jsx)(s,{className:`w-4 h-4`}):(0,w.jsx)(se,{className:`w-4 h-4`}),q.text]}),(0,w.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`dojo.title`,`The Dojo`),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`OpenClaw Hub`})]}),(0,w.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`dojo.subtitle`,`Discover and install specialized skills from the global OpenClaw College registry.`)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsxs)(`div`,{className:`hidden lg:flex items-center gap-6 px-6 border-r border-shogun-border`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest leading-none`,children:`Catalog`}),(0,w.jsxs)(`span`,{className:`text-xl font-bold text-shogun-gold`,children:[k?.skills??(0,w.jsx)(l,{className:`w-4 h-4 animate-spin inline`}),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal`,children:`Skills`})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest leading-none`,children:`Subcategories`}),(0,w.jsxs)(`span`,{className:`text-xl font-bold text-shogun-blue`,children:[k?.subcategories??(0,w.jsx)(l,{className:`w-4 h-4 animate-spin inline`}),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal`,children:`Fields`})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest leading-none`,children:`Badges`}),(0,w.jsxs)(`span`,{className:`text-xl font-bold text-purple-400`,children:[k?.badges??(0,w.jsx)(l,{className:`w-4 h-4 animate-spin inline`}),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal`,children:`Available`})]})]})]}),(0,w.jsx)(`button`,{onClick:()=>{X(),$(),Z()},className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,w.jsx)(p,{className:_(`w-4 h-4`,r&&`animate-spin`)})})]})]}),(0,w.jsx)(`div`,{className:`flex border-b border-shogun-border overflow-x-auto`,children:gt.map(e=>{let r=e.icon;return(0,w.jsxs)(`button`,{onClick:()=>n(e.key),className:_(`px-5 py-3 text-sm font-bold uppercase tracking-widest transition-all relative flex items-center gap-2 whitespace-nowrap`,t===e.key?`text-shogun-gold`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,w.jsx)(r,{className:`w-3.5 h-3.5`}),e.label,e.count!==void 0&&(0,w.jsx)(`span`,{className:_(`text-[9px] px-1.5 py-0.5 rounded-full font-mono`,t===e.key?`bg-shogun-gold/10 text-shogun-gold`:`bg-shogun-card text-shogun-subdued`),children:e.count}),t===e.key&&(0,w.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-gold shadow-[0_0_10px_rgba(212,160,23,0.5)]`})]},e.key)})}),(0,w.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-4 gap-8 mt-6`,children:[(0,w.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(re,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-shogun-subdued`}),(0,w.jsx)(`input`,{type:`text`,placeholder:`Filter Dojo...`,value:j,onChange:e=>xe(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl pl-10 pr-4 py-3 text-sm focus:border-shogun-gold outline-none transition-all shadow-inner`})]}),(0,w.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-2`,children:[(0,w.jsx)(ne,{className:`w-3 h-3`}),` Import from URL`]}),(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(`input`,{type:`text`,placeholder:`GitHub / ClawHub URL...`,value:I,onChange:e=>{Oe(e.target.value),R(null)},className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs focus:border-shogun-blue outline-none transition-all`,onKeyDown:e=>e.key===`Enter`&&at()}),(0,w.jsx)(`button`,{onClick:at,disabled:ke||!I.trim(),className:`px-3 py-2 bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue rounded-lg text-xs font-bold uppercase tracking-wider hover:bg-shogun-blue/20 transition-colors disabled:opacity-30`,children:ke?(0,w.jsx)(l,{className:`w-3 h-3 animate-spin`}):(0,w.jsx)(f,{className:`w-3 h-3`})})]}),L&&(0,w.jsx)(`p`,{className:_(`text-[10px] leading-relaxed`,L.type===`success`?`text-green-400`:`text-red-400`),children:L.text}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60 italic`,children:`Paste a repo URL to import skills directly from source.`})]}),(0,w.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,w.jsx)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest border-b border-shogun-border pb-2`,children:`All Categories`}),(0,w.jsx)(`div`,{onClick:()=>B(null),className:_(`text-[10px] px-3 py-1.5 rounded cursor-pointer transition-colors font-bold`,z?`text-shogun-subdued hover:text-shogun-gold`:`bg-shogun-gold/10 text-shogun-gold`),children:`All Categories`}),A.length>0?(0,w.jsxs)(w.Fragment,{children:[A.filter(e=>e.facultyId===`technical`).length>0&&(0,w.jsxs)(`div`,{className:`space-y-1`,children:[(0,w.jsxs)(`p`,{className:`text-[8px] font-bold text-shogun-blue uppercase tracking-[0.2em] flex items-center gap-1.5 mt-2 px-1 cursor-pointer select-none hover:opacity-80 transition-opacity`,onClick:()=>Fe(e=>({...e,technical:!e.technical})),children:[(0,w.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-shogun-blue inline-block`}),`faculties.technical`,U.technical?(0,w.jsx)(o,{className:`w-2.5 h-2.5 ml-auto`}):(0,w.jsx)(a,{className:`w-2.5 h-2.5 ml-auto`})]}),!U.technical&&A.filter(e=>e.facultyId===`technical`).map(e=>(0,w.jsx)(`div`,{onClick:()=>B(e.id),className:_(`text-[10px] px-3 py-1 rounded cursor-pointer transition-colors truncate`,z===e.id?`bg-shogun-gold/10 text-shogun-gold font-bold`:`text-shogun-subdued hover:text-shogun-text hover:bg-[#050508]`),children:e.name},e.id))]}),A.filter(e=>e.facultyId===`human_wellbeing`).length>0&&(0,w.jsxs)(`div`,{className:`space-y-1`,children:[(0,w.jsxs)(`p`,{className:`text-[8px] font-bold text-orange-400 uppercase tracking-[0.2em] flex items-center gap-1.5 mt-3 px-1 cursor-pointer select-none hover:opacity-80 transition-opacity`,onClick:()=>Fe(e=>({...e,human_wellbeing:!e.human_wellbeing})),children:[(0,w.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-orange-400 inline-block`}),`faculties.human_wellbeing`,U.human_wellbeing?(0,w.jsx)(o,{className:`w-2.5 h-2.5 ml-auto`}):(0,w.jsx)(a,{className:`w-2.5 h-2.5 ml-auto`})]}),!U.human_wellbeing&&A.filter(e=>e.facultyId===`human_wellbeing`).map(e=>(0,w.jsx)(`div`,{onClick:()=>B(e.id),className:_(`text-[10px] px-3 py-1 rounded cursor-pointer transition-colors truncate`,z===e.id?`bg-shogun-gold/10 text-shogun-gold font-bold`:`text-shogun-subdued hover:text-shogun-text hover:bg-[#050508]`),children:e.name},e.id))]}),A.filter(e=>e.facultyId===`business_professional`).length>0&&(0,w.jsxs)(`div`,{className:`space-y-1`,children:[(0,w.jsxs)(`p`,{className:`text-[8px] font-bold text-green-400 uppercase tracking-[0.2em] flex items-center gap-1.5 mt-3 px-1 cursor-pointer select-none hover:opacity-80 transition-opacity`,onClick:()=>Fe(e=>({...e,business_professional:!e.business_professional})),children:[(0,w.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`}),`faculties.business_professional`,U.business_professional?(0,w.jsx)(o,{className:`w-2.5 h-2.5 ml-auto`}):(0,w.jsx)(a,{className:`w-2.5 h-2.5 ml-auto`})]}),!U.business_professional&&A.filter(e=>e.facultyId===`business_professional`).map(e=>(0,w.jsx)(`div`,{onClick:()=>B(e.id),className:_(`text-[10px] px-3 py-1 rounded cursor-pointer transition-colors truncate`,z===e.id?`bg-shogun-gold/10 text-shogun-gold font-bold`:`text-shogun-subdued hover:text-shogun-text hover:bg-[#050508]`),children:e.name},e.id))]})]}):Array.from({length:8}).map((e,t)=>(0,w.jsx)(`div`,{className:`h-4 bg-shogun-bg border border-shogun-border rounded animate-pulse`},t))]}),(0,w.jsx)(`div`,{className:_(`shogun-card border-2 transition-all`,N?.registered?`bg-green-500/5 border-green-500/20`:`bg-shogun-gold/5 border-shogun-gold/20`),children:N?.registered?(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(b,{className:`w-5 h-5 text-green-500`}),(0,w.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:`Registered`})]}),(0,w.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:[`Your Shogun is enrolled at OpenClaw College as `,(0,w.jsx)(`strong`,{className:`text-shogun-text`,children:N.agent_name}),`.`]}),(0,w.jsxs)(`code`,{className:`block text-[9px] bg-[#050508] p-2 rounded border border-shogun-border text-shogun-subdued font-mono truncate`,children:[`ID: `,N.openclaw_agent_id]}),(0,w.jsxs)(`button`,{onClick:()=>Ve(!Be),className:`w-full py-2 text-[10px] font-bold uppercase tracking-widest border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-blue hover:border-shogun-blue/40 transition-colors flex items-center justify-center gap-2`,children:[(0,w.jsx)(u,{className:`w-3 h-3`}),` `,Be?`Hide`:`Set API Key`]}),Be&&(0,w.jsxs)(`div`,{className:`space-y-2 pt-1`,children:[(0,w.jsx)(`label`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`X-API-Key (membership key)`}),(0,w.jsx)(`input`,{type:`password`,value:He,onChange:e=>Ue(e.target.value),placeholder:`paste your api key…`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs focus:border-shogun-blue outline-none transition-all font-mono`}),Ke&&(0,w.jsx)(`p`,{className:_(`text-[9px]`,Ke.type===`success`?`text-green-400`:`text-red-400`),children:Ke.text}),(0,w.jsx)(`button`,{onClick:ot,disabled:We||!He.trim(),className:`w-full py-2 bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue text-[10px] font-bold uppercase tracking-widest rounded-lg hover:bg-shogun-blue/20 transition-colors disabled:opacity-30`,children:We?(0,w.jsx)(l,{className:`w-3 h-3 animate-spin mx-auto`}):`Save Key`})]})]}):(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(h,{className:`w-5 h-5 text-shogun-gold`}),(0,w.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:`Join OpenClaw College`})]}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Register your Shogun to earn badges, track specializations, and participate in the global agent community.`}),(0,w.jsxs)(`button`,{onClick:()=>P(!0),className:`w-full py-2.5 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-[10px] uppercase tracking-[0.2em] rounded-lg shadow-shogun transition-all flex items-center justify-center gap-2`,children:[(0,w.jsx)(h,{className:`w-3.5 h-3.5`}),` Sign Up for OpenClaw College`]})]})}),(0,w.jsxs)(`div`,{className:`shogun-card bg-shogun-blue/5 border-shogun-blue/20`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,w.jsx)(S,{className:`w-5 h-5 text-shogun-gold`}),(0,w.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:`OpenClaw Certified`})]}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`All skills in the Dojo have undergone automated safety auditing by the OpenClaw College board. Verified skills display the "Zen" mark of stability.`})]})]}),(0,w.jsx)(`div`,{className:`lg:col-span-3`,children:r?(0,w.jsxs)(`div`,{className:`p-20 text-center shogun-card bg-[#050508]/20 flex flex-col items-center gap-4 border-dashed`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(p,{className:`w-10 h-10 animate-spin text-shogun-gold`}),(0,w.jsx)(m,{className:`absolute -top-1 -right-1 w-4 h-4 text-shogun-blue animate-pulse`})]}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] text-shogun-subdued`,children:`Syncing with OpenClaw College...`})]}):(0,w.jsxs)(w.Fragment,{children:[nt&&(0,w.jsxs)(`div`,{className:`mb-4 rounded-xl border border-red-500/30 bg-red-500/10 p-4 text-xs text-red-300`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 font-bold`,children:[(0,w.jsx)(s,{className:`h-4 w-4`}),` Dojo sync failed`]}),(0,w.jsx)(`p`,{className:`mt-1 font-mono text-[10px]`,children:nt})]}),t===`catalog`&&(0,w.jsx)(`div`,{className:`space-y-4`,children:ft.length===0?(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:[(0,w.jsx)(re,{className:`w-8 h-8 text-shogun-subdued mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No skills match your search criteria.`})]}):(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:ft.map(e=>(0,w.jsxs)(`div`,{onClick:()=>Se(e),className:`shogun-card group hover:border-shogun-gold/50 cursor-pointer transition-all flex flex-col`,children:[(0,w.jsxs)(`div`,{className:`flex justify-between items-start mb-4`,children:[(0,w.jsx)(`div`,{className:`w-12 h-12 bg-[#050508] border border-shogun-border rounded-xl flex items-center justify-center text-shogun-gold group-hover:bg-shogun-gold/10 transition-colors`,children:(0,w.jsx)(i,{className:`w-6 h-6`})}),(0,w.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Y.has(e.id)&&(0,w.jsxs)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 bg-green-500/15 text-green-400 rounded border border-green-500/30 flex items-center gap-1`,children:[(0,w.jsx)(c,{className:`w-2.5 h-2.5`}),` Installed`]}),(0,w.jsxs)(`code`,{className:`text-[9px] bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border text-shogun-subdued`,children:[`v`,e.version]})]}),(0,w.jsx)(`span`,{className:_(`text-[8px] font-bold uppercase tracking-widest mt-1`,e.risk_tier===`shrine`?`text-shogun-gold`:e.risk_tier===`tactical`?`text-shogun-blue`:e.risk_tier===`elevated`?`text-orange-400`:`text-green-400`),children:e.risk_tier})]})]}),(0,w.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text group-hover:text-shogun-gold transition-colors`,children:e.name}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-2 line-clamp-3 leading-relaxed flex-1`,children:e.description}),(0,w.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-shogun-border flex items-center justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[e.permissions?.network&&(0,w.jsx)(ee,{className:`w-3 h-3 text-shogun-blue`}),e.permissions?.shell&&(0,w.jsx)(g,{className:`w-3 h-3 text-red-500`}),e.permissions?.filesystem_write&&(0,w.jsx)(ie,{className:`w-3 h-3 text-green-500`}),e.permissions?.filesystem_read&&(0,w.jsx)(i,{className:`w-3 h-3 text-purple-400`}),e.permissions?.credentials&&(0,w.jsx)(u,{className:`w-3 h-3 text-orange-400`})]}),(0,w.jsx)(`div`,{onClick:t=>{t.stopPropagation(),Y.has(e.id)||lt(e)},className:_(`flex items-center gap-1 text-[10px] font-mono transition-colors`,Y.has(e.id)?`text-green-400`:K===e.id?`text-shogun-gold animate-pulse cursor-pointer`:`text-shogun-subdued group-hover:text-shogun-gold cursor-pointer`),children:Y.has(e.id)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(c,{className:`w-3 h-3`}),` Installed`]}):K===e.id?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(l,{className:`w-3 h-3 animate-spin`}),` Installing…`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(f,{className:`w-3 h-3`}),` + Install`]})})]})]},e.id))})}),t===`bundles`&&(0,w.jsx)(`div`,{className:`space-y-4`,children:pt.length===0?(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:[(0,w.jsx)(d,{className:`w-8 h-8 text-shogun-subdued mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No bundles available.`})]}):(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:pt.map(e=>(0,w.jsxs)(`div`,{className:_(`shogun-card group cursor-pointer transition-all`,H===e.id?`border-shogun-blue/50`:`hover:border-shogun-blue/50`),onClick:()=>Pe(H===e.id?null:e.id),children:[(0,w.jsxs)(`div`,{className:`flex items-start gap-4 mb-3`,children:[(0,w.jsx)(`div`,{className:`w-12 h-12 bg-shogun-blue/10 border border-shogun-blue/20 rounded-xl flex items-center justify-center flex-shrink-0 text-xl`,children:e.icon||`📦`}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text group-hover:text-shogun-blue transition-colors`,children:e.name}),e.currentVersion?.riskTier&&(0,w.jsx)(`span`,{className:_(`text-[9px] px-2 py-0.5 rounded font-bold uppercase tracking-widest`,e.currentVersion.riskTier===`low`?`bg-green-500/10 text-green-400`:e.currentVersion.riskTier===`medium`?`bg-yellow-500/10 text-yellow-400`:`bg-red-500/10 text-red-400`),children:e.currentVersion.riskTier})]}),(0,w.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold mt-0.5`,children:[e.skillIds?.length||0,` skills · `,e.facultyId||`General`,e.currentVersion?.versionLabel&&(0,w.jsxs)(w.Fragment,{children:[` · v`,e.currentVersion.versionLabel]})]})]}),(0,w.jsx)(o,{className:_(`w-4 h-4 text-shogun-subdued transition-transform mt-1`,H===e.id&&`rotate-90`)})]}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed line-clamp-3`,children:e.shortDescription||e.description}),H===e.id&&(0,w.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-shogun-border space-y-3`,onClick:e=>e.stopPropagation(),children:[e.currentVersion?.skills&&e.currentVersion.skills.length>0?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(g,{className:`w-3.5 h-3.5 text-shogun-blue`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Included Skills`}),(0,w.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued font-mono`,children:e.currentVersion.skills.length})]}),(0,w.jsx)(`div`,{className:`space-y-1 pl-5`,children:e.currentVersion.skills.map(e=>(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`text-[8px] px-2 py-0.5 bg-[#050508] border border-shogun-border rounded font-mono text-shogun-subdued`,children:e.id}),(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-text`,children:e.name})]},e.id))})]}):e.skillIds&&e.skillIds.length>0?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(g,{className:`w-3.5 h-3.5 text-shogun-blue`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Included Skills`}),(0,w.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued font-mono`,children:e.skillIds.length})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pl-5`,children:e.skillIds.map(e=>(0,w.jsx)(`span`,{className:`text-[8px] px-2 py-0.5 bg-[#050508] border border-shogun-border rounded font-mono text-shogun-subdued`,children:e},e))})]}):null,(0,w.jsx)(`div`,{className:`mt-3 pt-3 border-t border-shogun-border`,children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono text-shogun-blue cursor-pointer hover:text-shogun-blue/80 transition-colors`,children:[(0,w.jsx)(f,{className:`w-3 h-3`}),` Install Bundle`]})})]}),H!==e.id&&(0,w.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-shogun-border flex items-center justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(te,{className:`w-3 h-3 text-shogun-blue`}),(0,w.jsxs)(`span`,{className:`text-[10px] font-mono text-shogun-subdued`,children:[e.skillIds?.length||0,` skills included`]})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono text-shogun-subdued group-hover:text-shogun-blue transition-colors`,children:[(0,w.jsx)(f,{className:`w-3 h-3`}),` Install Bundle`]})]})]},e.id))})}),t===`specializations`&&(0,w.jsx)(`div`,{className:`space-y-4`,children:mt.length===0?(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:[(0,w.jsx)(x,{className:`w-8 h-8 text-shogun-subdued mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No specializations available.`})]}):(0,w.jsx)(`div`,{className:`grid grid-cols-1 gap-6`,children:mt.map(e=>{let t=D?.specializations_earned?.find(t=>t.id===e.id);return(0,w.jsxs)(`div`,{className:_(`shogun-card group cursor-pointer transition-all`,V===e.id?`border-purple-400/50`:`hover:border-purple-400/50`),onClick:()=>je(V===e.id?null:e.id),children:[(0,w.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,w.jsx)(`div`,{className:`w-14 h-14 bg-purple-500/10 border border-purple-500/20 rounded-xl flex items-center justify-center flex-shrink-0 text-2xl`,children:e.icon||`🎓`}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,w.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text group-hover:text-purple-400 transition-colors`,children:e.name}),(0,w.jsx)(`span`,{className:`text-[9px] px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded font-bold uppercase tracking-widest`,children:e.degreeType||`Specialization`})]}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed line-clamp-2`,children:e.title||e.description}),t&&(0,w.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,w.jsx)(b,{className:`h-3.5 w-3.5 text-green-400`}),(0,w.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider text-green-400`,children:`Earned with`}),(0,w.jsx)(T,{item:t})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mt-3`,children:[(0,w.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest`,children:[`Faculty: `,e.facultyId||e.faculty||`General`]}),(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued/60`,children:`•`}),(0,w.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest`,children:[`Category: `,e.categoryId||`—`]}),(0,w.jsx)(o,{className:_(`w-3 h-3 text-shogun-subdued transition-transform ml-auto`,V===e.id&&`rotate-90`)})]})]})]}),V===e.id&&(0,w.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-shogun-border space-y-4`,onClick:e=>e.stopPropagation(),children:[e.requirements?.map((e,t)=>(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type===`bundle_count`?(0,w.jsx)(d,{className:`w-3.5 h-3.5 text-shogun-gold`}):(0,w.jsx)(g,{className:`w-3.5 h-3.5 text-shogun-blue`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:e.label}),(0,w.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued font-mono`,children:e.count})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pl-5`,children:(e.bundleIds||e.skillIds||[]).map(e=>(0,w.jsx)(`span`,{className:`text-[8px] px-2 py-0.5 bg-[#050508] border border-shogun-border rounded font-mono text-shogun-subdued truncate max-w-[160px]`,children:e},e))})]},t)),e.badgeId&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,w.jsx)(y,{className:`w-3.5 h-3.5 text-purple-400`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Badge Reward`}),(0,w.jsx)(`span`,{className:`text-[9px] px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded font-mono`,children:e.badgeId})]}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>dt(e),disabled:Me===e.id||D?.enrollments?.some(t=>(typeof t==`string`?t:t.specializationId)===e.id),className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg border border-purple-500/30 bg-purple-500/10 text-purple-300 text-xs font-bold uppercase tracking-wider hover:bg-purple-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:Me===e.id?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(l,{className:`w-4 h-4 animate-spin`}),` Enrolling…`]}):D?.enrollments?.some(t=>(typeof t==`string`?t:t.specializationId)===e.id)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(c,{className:`w-4 h-4`}),` Enrolled`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(x,{className:`w-4 h-4`}),` Enroll & Evaluate`]})})]})]},e.id)})})}),t===`achieved`&&(0,w.jsxs)(`div`,{className:`space-y-8`,children:[D?.registered?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(y,{className:`w-8 h-8 text-shogun-gold mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-shogun-gold`,children:D.badges?.length||0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Badges Earned`})]}),(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(x,{className:`w-8 h-8 text-purple-400 mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-purple-400`,children:D.specializations_earned?.length||0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Specializations`})]}),(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(oe,{className:`w-8 h-8 text-shogun-blue mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-shogun-blue`,children:D.skills_installed??D.skills_completed??0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Skills Installed`})]}),(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(c,{className:`w-8 h-8 text-green-400 mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-green-400`,children:D.exams_passed||0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Exams Passed`})]})]}),D.specializations_earned?.length>0&&(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(x,{className:`w-3.5 h-3.5 text-purple-400`}),` Earned Specializations`]}),(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:D.specializations_earned.map(e=>(0,w.jsxs)(`div`,{className:`shogun-card border-purple-500/20 text-center`,children:[(0,w.jsx)(x,{className:`w-7 h-7 text-purple-400 mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e.name||e.title}),(0,w.jsx)(T,{item:e})]},e.id||e.name))})]}),(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(y,{className:`w-3.5 h-3.5 text-shogun-gold`}),` Earned Badges`]}),D.badges?.length>0?(0,w.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:D.badges.map(e=>(0,w.jsxs)(`div`,{className:`shogun-card text-center hover:border-shogun-gold/50 transition-all group`,children:[(0,w.jsx)(`div`,{className:`w-12 h-12 bg-shogun-gold/10 rounded-full flex items-center justify-center mx-auto mb-3 group-hover:bg-shogun-gold/20 transition-colors`,children:(0,w.jsx)(y,{className:`w-6 h-6 text-shogun-gold`})}),(0,w.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e.name}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-1 line-clamp-2`,children:e.description}),(0,w.jsx)(T,{item:e})]},e.id||e.name))}):(0,w.jsx)(`div`,{className:`p-6 text-center shogun-card border-dashed`,children:(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No badges earned yet. Complete skills and specializations to earn badges.`})})]}),et.length>0&&(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(d,{className:`w-3.5 h-3.5 text-green-400`}),` Installed Skills`,(0,w.jsx)(`span`,{className:`text-[9px] px-2 py-0.5 bg-green-500/10 text-green-400 rounded-full font-mono`,children:et.length}),(0,w.jsxs)(`button`,{onClick:ut,disabled:Ze,className:`ml-auto inline-flex items-center gap-1.5 rounded-lg border border-shogun-blue/30 bg-shogun-blue/10 px-2.5 py-1.5 text-[9px] font-bold tracking-widest text-shogun-blue transition-colors hover:bg-shogun-blue/20 disabled:opacity-50`,title:`Fetch current canonical SKILL.md files and synchronize Archives`,children:[(0,w.jsx)(p,{className:_(`h-3 w-3`,Ze&&`animate-spin`)}),Ze?`Refreshing…`:`Refresh Skills`]})]}),(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:et.map(e=>{let t=e.openclaw_skill_id||e.skill_id;return(0,w.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border border-green-500/15 bg-gradient-to-r from-green-500/5 via-[#050508] to-[#050508] transition-all hover:border-green-500/30`,children:[(0,w.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-1 bg-green-500/50`}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3 p-3.5 pl-4`,children:[(0,w.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-green-500/10 border border-green-500/20 flex items-center justify-center flex-shrink-0`,children:(0,w.jsx)(g,{className:`w-4 h-4 text-green-400`})}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-xs font-bold text-shogun-text truncate`,children:e.name}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[e.faculty&&(0,w.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued uppercase tracking-wider`,children:e.faculty?.replace(/_/g,` `)}),(0,w.jsxs)(`span`,{className:`text-[8px] text-shogun-subdued font-mono`,children:[`v`,e.version]})]})]}),(0,w.jsx)(c,{className:`w-4 h-4 text-green-400 flex-shrink-0`})]})]},t)})})]}),ht.length>0&&(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(x,{className:`w-3.5 h-3.5 text-shogun-blue`}),` Achieved Skills & Certification Transcript`]}),(0,w.jsx)(`div`,{className:`space-y-3`,children:ht.map((e,t)=>{let n=e.verificationStatus===`approved`||e.score>=85,r=de.find(t=>t.id===e.skillId)?.name||e.skillName||e.testId,i=e.passedAt?new Date(e.passedAt).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`}):null;return(0,w.jsxs)(`div`,{className:_(`relative overflow-hidden rounded-xl border transition-all`,n?`bg-gradient-to-r from-green-500/5 via-[#050508] to-[#050508] border-green-500/20`:`bg-gradient-to-r from-orange-500/5 via-[#050508] to-[#050508] border-orange-500/20`),children:[(0,w.jsx)(`div`,{className:_(`absolute left-0 top-0 bottom-0 w-1`,n?`bg-green-500`:`bg-orange-400`)}),(0,w.jsxs)(`div`,{className:`flex items-center gap-4 p-4 pl-5`,children:[(0,w.jsx)(`div`,{className:_(`w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0 border`,n?`bg-green-500/10 border-green-500/30`:`bg-orange-500/10 border-orange-500/30`),children:n?(0,w.jsx)(b,{className:`w-5 h-5 text-green-400`}):(0,w.jsx)(s,{className:`w-5 h-5 text-orange-400`})}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-sm font-bold text-shogun-text truncate`,children:r}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 flex-wrap`,children:[i&&(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued flex items-center gap-1`,children:[(0,w.jsx)(p,{className:`w-2.5 h-2.5`}),` `,i]}),e.agentName&&(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued flex items-center gap-1`,children:[(0,w.jsx)(ae,{className:`w-2.5 h-2.5`}),` `,e.agentName]}),(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued flex items-center gap-1`,children:[(0,w.jsx)(u,{className:`w-2.5 h-2.5`}),(0,w.jsx)(`span`,{className:`font-mono`,children:le(D?.achieved_skills?.find(t=>t.testId===e.testId||t.skillId===e.skillId)||e).join(`, `)})]})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col items-end gap-1 flex-shrink-0`,children:[(0,w.jsxs)(`span`,{className:_(`text-lg font-black font-mono`,n?`text-green-400`:`text-orange-400`),children:[e.score,`%`]}),(0,w.jsx)(`span`,{className:_(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded-full`,n?`bg-green-500/10 text-green-400 border border-green-500/20`:`bg-orange-500/10 text-orange-400 border border-orange-500/20`),children:n?`✓ Certified`:`Not Passed`})]})]})]},e.id||t)})})]})]}):(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed border-2 border-shogun-gold/20`,children:[(0,w.jsx)(h,{className:`w-10 h-10 text-shogun-gold mx-auto mb-4 opacity-50`}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`Not Registered Yet`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-md mx-auto mb-6`,children:`Register your Shogun with OpenClaw College to start earning badges and tracking specializations.`}),(0,w.jsxs)(`button`,{onClick:()=>P(!0),className:`px-6 py-3 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all inline-flex items-center gap-2`,children:[(0,w.jsx)(h,{className:`w-4 h-4`}),` Sign Up Now`]})]}),(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(S,{className:`w-3.5 h-3.5 text-purple-400`}),` All Available Badges`]}),_e.length>0?(0,w.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:_e.map(e=>{let t=D?.badges?.find(t=>t.id===e.id),n=!!t;return(0,w.jsxs)(`div`,{className:_(`shogun-card text-center transition-all`,n?`border-shogun-gold/30 bg-shogun-gold/5`:`opacity-60 hover:opacity-100`),children:[(0,w.jsx)(`div`,{className:_(`w-10 h-10 rounded-full flex items-center justify-center mx-auto mb-2`,n?`bg-shogun-gold/20`:`bg-shogun-card`),children:n?(0,w.jsx)(c,{className:`w-5 h-5 text-shogun-gold`}):(0,w.jsx)(u,{className:`w-4 h-4 text-shogun-subdued`})}),(0,w.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-text`,children:e.name}),e.description&&(0,w.jsx)(`p`,{className:`text-[8px] text-shogun-subdued mt-1 line-clamp-2`,children:e.description}),t&&(0,w.jsx)(T,{item:t})]},e.id||e.name)})}):(0,w.jsxs)(`div`,{className:`p-6 text-center shogun-card border-dashed`,children:[(0,w.jsx)(S,{className:`w-6 h-6 text-shogun-subdued mx-auto mb-2 opacity-30`}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Badge catalog loading failed. Check connection to OpenClaw College.`})]})]})]})]})})]}),M&&(0,w.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-300`,children:(0,w.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-3xl rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300 flex flex-col max-h-[90vh]`,children:[(0,w.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center flex-shrink-0`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-gold`,children:(0,w.jsx)(g,{className:`w-5 h-5`})}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:M.name}),(0,w.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:[`Faculty: `,M.faculty||`General`]})]})]}),(0,w.jsx)(`button`,{onClick:()=>{Se(null),ct()},className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,w.jsx)(se,{className:`w-5 h-5 text-shogun-subdued`})})]}),Ie===`idle`&&(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 overflow-y-auto`,children:[(0,w.jsxs)(`div`,{className:`p-8 space-y-6 border-r border-shogun-border`,children:[(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Description`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-text leading-relaxed`,children:M.description})]}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Capabilities`}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(M.capabilities||[]).length>0?M.capabilities.map(e=>(0,w.jsx)(`span`,{className:`text-[10px] px-2 py-1 bg-shogun-card border border-shogun-border rounded text-shogun-subdued`,children:e},e)):(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:`No capabilities declared`})})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Metadata`}),(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,w.jsxs)(`div`,{className:`p-2 bg-[#050508] rounded border border-shogun-border`,children:[(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued block`,children:`Version`}),(0,w.jsx)(`span`,{className:`text-xs font-mono text-shogun-text`,children:M.version})]}),(0,w.jsxs)(`div`,{className:`p-2 bg-[#050508] rounded border border-shogun-border`,children:[(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued block`,children:`Risk Tier`}),(0,w.jsx)(`span`,{className:_(`text-xs font-bold uppercase`,M.risk_tier===`shrine`?`text-shogun-gold`:M.risk_tier===`elevated`?`text-orange-400`:`text-green-400`),children:M.risk_tier})]})]})]})]}),(0,w.jsxs)(`div`,{className:`p-8 space-y-6 bg-[#050508]/30`,children:[(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest flex items-center gap-2`,children:[(0,w.jsx)(u,{className:`w-3 h-3`}),` Permission Audit`]}),(0,w.jsx)(`div`,{className:`space-y-2`,children:Object.entries(M.permissions||{}).map(([e,t])=>(0,w.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-shogun-bg border border-shogun-border rounded-lg`,children:[(0,w.jsx)(`span`,{className:`text-xs text-shogun-text font-bold capitalize`,children:e.replace(/_/g,` `)}),t?(0,w.jsx)(c,{className:`w-4 h-4 text-green-500`}):(0,w.jsx)(ue,{className:`w-4 h-4 text-shogun-subdued`})]},e))})]}),(0,w.jsxs)(`div`,{className:`space-y-3 pt-2`,children:[Re&&(0,w.jsx)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-400 mb-2`,children:Re}),(0,w.jsxs)(`button`,{onClick:()=>st(M.id),className:`w-full py-4 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all flex items-center justify-center gap-3`,children:[(0,w.jsx)(x,{className:`w-5 h-5`}),` `,e(`dojo.take_exam`,`Take Certification Exam`)]}),(0,w.jsx)(`button`,{onClick:()=>!Y.has(M?.id)&<(M),disabled:K===M?.id||Y.has(M?.id),className:_(`w-full py-3 bg-shogun-card border font-bold text-xs uppercase tracking-[0.2em] rounded-xl transition-all flex items-center justify-center gap-3`,Y.has(M?.id)?`border-green-500/30 text-green-400`:K===M?.id?`border-shogun-border text-shogun-gold animate-pulse`:`border-shogun-border text-shogun-subdued hover:text-shogun-text`),children:Y.has(M?.id)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(c,{className:`w-5 h-5`}),` Installed`]}):K===M?.id?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(l,{className:`w-5 h-5 animate-spin`}),` Installing…`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(f,{className:`w-5 h-5`}),` Install to `,N?.agent_name||`Shogun`]})}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued text-center italic`,children:`Take the 30–50 question exam to get instantly certified by OpenClaw College.`})]})]})]}),Ie===`loading`&&(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-20 gap-6`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(p,{className:`w-12 h-12 animate-spin text-shogun-gold`}),(0,w.jsx)(m,{className:`absolute -top-1 -right-1 w-4 h-4 text-shogun-blue animate-pulse`})]}),(0,w.jsxs)(`p`,{className:`text-sm font-bold text-shogun-text`,children:[N?.agent_name||`Hero-San`,` is taking the exam...`]}),(0,w.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] text-shogun-subdued`,children:`Answering questions · Submitting to OpenClaw College`})]}),Ie===`result`&&G&&(0,w.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-6 border-b border-shogun-border flex items-center gap-6 flex-shrink-0`,children:[(0,w.jsx)(`div`,{className:_(`w-16 h-16 rounded-full flex items-center justify-center border-3`,G.passed||G.verificationStatus===`approved`?`bg-green-500/10 border-green-500 shadow-[0_0_30px_rgba(34,197,94,0.2)]`:`bg-orange-500/10 border-orange-500`),children:G.passed||G.verificationStatus===`approved`?(0,w.jsx)(b,{className:`w-8 h-8 text-green-400`}):(0,w.jsx)(s,{className:`w-8 h-8 text-orange-400`})}),(0,w.jsxs)(`div`,{className:`flex-1`,children:[(0,w.jsx)(`h3`,{className:_(`text-xl font-bold`,G.passed||G.verificationStatus===`approved`?`text-green-400`:`text-orange-400`),children:G.passed||G.verificationStatus===`approved`?e(`dojo.passed`,`Certified!`):e(`dojo.failed`,`Not Passed`)}),(0,w.jsxs)(`p`,{className:`text-shogun-subdued text-xs mt-1`,children:[G.agent_name||N?.agent_name||`Hero-San`,` scored `,(0,w.jsxs)(`span`,{className:`font-bold text-shogun-text`,children:[G.score,`%`]}),` (`,G.questions_correct??`?`,`/`,G.questions_total??`?`,` correct)`]}),(G.passed||G.verificationStatus===`approved`)&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,w.jsx)(m,{className:`w-3 h-3 text-shogun-gold animate-pulse`}),(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-gold font-bold uppercase tracking-widest`,children:[`OpenClaw Certified · `,M?.name]}),G.model_id&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued`,children:`·`}),(0,w.jsx)(u,{className:`w-3 h-3 text-shogun-subdued`}),(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued font-mono`,children:G.model_id})]})]})]}),(0,w.jsxs)(`div`,{className:`text-right`,children:[(0,w.jsxs)(`p`,{className:_(`text-3xl font-black font-mono`,G.passed||G.verificationStatus===`approved`?`text-green-400`:`text-orange-400`),children:[G.score,`%`]}),(0,w.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest`,children:[`Pass: `,G.pass_threshold??85,`%`]})]})]}),(0,w.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-4`,children:[(0,w.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2 sticky top-0 bg-shogun-bg py-2 z-10`,children:[(0,w.jsx)(x,{className:`w-3.5 h-3.5 text-shogun-gold`}),` Exam Review — `,G.questions_total,` Questions`]}),(G.questions_review||[]).map((e,t)=>(0,w.jsxs)(`div`,{className:_(`p-4 rounded-xl border transition-all`,e.isCorrect?`bg-green-500/5 border-green-500/20`:`bg-red-500/5 border-red-500/20`),children:[(0,w.jsxs)(`p`,{className:`text-xs text-shogun-text font-medium leading-relaxed mb-3`,children:[(0,w.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued font-mono mr-2`,children:[t+1,`.`]}),e.text?.replace(/^\d+\.\s*/,``)]}),(0,w.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 pl-4`,children:(e.options||[]).map((t,n)=>{let r=t===e.correctAnswer,i=t===e.agentAnswer&&!e.isCorrect;return(0,w.jsxs)(`div`,{className:_(`text-xs px-3 py-2 rounded-lg border flex items-center gap-2`,r?`bg-green-500/10 border-green-500/40 text-green-400 font-bold`:i?`bg-red-500/10 border-red-500/40 text-red-400 font-bold`:`bg-[#050508] border-shogun-border/30 text-shogun-subdued/60`),children:[(0,w.jsxs)(`span`,{className:`font-mono text-[10px] opacity-60 w-4`,children:[String.fromCharCode(65+n),`.`]}),(0,w.jsx)(`span`,{className:`flex-1`,children:t}),r&&(0,w.jsx)(c,{className:`w-3.5 h-3.5 text-green-400 flex-shrink-0`}),i&&(0,w.jsx)(ue,{className:`w-3.5 h-3.5 text-red-400 flex-shrink-0`})]},n)})})]},e.id||t))]}),(0,w.jsxs)(`div`,{className:`p-4 border-t border-shogun-border flex items-center gap-3 flex-shrink-0`,children:[(0,w.jsx)(`button`,{onClick:ct,className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued text-xs font-bold uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Close`}),!(G.passed||G.verificationStatus===`approved`)&&(0,w.jsx)(`button`,{onClick:()=>st(M?.id),className:`flex-1 py-3 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all`,children:`Retry Exam`})]})]})]})}),we&&(0,w.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-300`,children:(0,w.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300`,children:[(0,w.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-shogun-gold/10 border border-shogun-gold/20 flex items-center justify-center`,children:(0,w.jsx)(x,{className:`w-5 h-5 text-shogun-gold`})}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`Sign Up for OpenClaw College`}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Agent Registration`})]})]}),(0,w.jsx)(`button`,{onClick:()=>P(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,w.jsx)(se,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,w.jsxs)(`div`,{className:`p-8 space-y-6`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Agent Display Name`}),(0,w.jsx)(`input`,{type:`text`,value:F,onChange:e=>Te(e.target.value),placeholder:`My Shogun`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-shogun-gold outline-none transition-all`,autoFocus:!0}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:`This name will appear in the global OpenClaw Agent Registry.`})]}),(0,w.jsx)(`div`,{className:`p-4 bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl`,children:(0,w.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,w.jsx)(s,{className:`w-4 h-4 text-shogun-blue flex-shrink-0 mt-0.5`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-text font-bold mb-1`,children:`What happens when you register?`}),(0,w.jsxs)(`ul`,{className:`text-[9px] text-shogun-subdued space-y-1`,children:[(0,w.jsx)(`li`,{children:`• Your Shogun gets a unique ID on the OpenClaw College platform`}),(0,w.jsx)(`li`,{children:`• You can earn badges and track specialization progress`}),(0,w.jsx)(`li`,{children:`• You can submit skill feedback and suggest new skills`}),(0,w.jsx)(`li`,{children:`• Registration is free and requires no API key`})]})]})]})}),(0,w.jsxs)(`div`,{className:`flex gap-3`,children:[(0,w.jsx)(`button`,{onClick:()=>P(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,w.jsx)(`button`,{onClick:it,disabled:Ee||!F.trim(),className:`flex-1 py-3 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all flex items-center justify-center gap-2 disabled:opacity-50`,children:Ee?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(l,{className:`w-4 h-4 animate-spin`}),` Registering...`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h,{className:`w-4 h-4`}),` Register`]})})]})]})]})})]})}var ue=({className:e,...t})=>(0,w.jsxs)(`svg`,{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`,className:e,...t,children:[(0,w.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,w.jsx)(`path`,{d:`m15 9-6 6`}),(0,w.jsx)(`path`,{d:`m9 9 6 6`})]});export{E as Dojo}; \ No newline at end of file diff --git a/frontend/dist/assets/Dojo-BCOKo4Yv.js b/frontend/dist/assets/Dojo-BCOKo4Yv.js new file mode 100644 index 0000000..926c509 --- /dev/null +++ b/frontend/dist/assets/Dojo-BCOKo4Yv.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./book-BRn0Wicm.js";import{t as n}from"./chevron-down-qQcy55Tl.js";import{t as r}from"./chevron-right-CVeYaFvJ.js";import{t as i}from"./circle-alert-043xB2li.js";import{t as a}from"./circle-check-DBu5bzEI.js";import{t as ee}from"./layers-PPVhckft.js";import{t as te}from"./link-Cl51GLTm.js";import{t as o}from"./lock-CGEyUK_n.js";import{t as s}from"./package-BxV01e8e.js";import{t as c}from"./plus-Cxx0HjpF.js";import{t as l}from"./refresh-cw-Dm6S5UAJ.js";import{t as ne}from"./search-DuRUeriq.js";import{t as u}from"./sparkles-DyLIKWW0.js";import{t as re}from"./star-DhgMUt17.js";import{t as d}from"./user-plus-vtJ7dasD.js";import{t as f}from"./zap-CQy--vuS.js";import{T as p,a as m,d as ie,g as h,i as g,j as ae,r as oe,t as _,u as se,y as ce}from"./index-Dy1E248t.js";import{t as v}from"./axios-BGmZl9Qd.js";var y=p(`award`,[[`path`,{d:`m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526`,key:`1yiouv`}],[`circle`,{cx:`12`,cy:`8`,r:`6`,key:`1vp47v`}]]),b=p(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),x=p(`graduation-cap`,[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]),S=p(`trophy`,[[`path`,{d:`M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978`,key:`1n3hpd`}],[`path`,{d:`M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978`,key:`rfe1zi`}],[`path`,{d:`M18 9h1.5a1 1 0 0 0 0-5H18`,key:`7xy6bh`}],[`path`,{d:`M4 22h16`,key:`57wxv0`}],[`path`,{d:`M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z`,key:`1mhfuq`}],[`path`,{d:`M6 9H4.5a1 1 0 0 1 0-5H6`,key:`tex48p`}]]),C=e(ae(),1),w=_();function le(e){let t=e?.credential_model_ids||e?.credentialModelIds||e?.modelIds;return Array.isArray(t)&&t.length?t:[e?.modelId||e?.model_id||`unknown (legacy credential)`]}function T({item:e}){return(0,w.jsx)(`div`,{className:`mt-2 flex flex-wrap justify-center gap-1`,children:le(e).map(e=>(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-shogun-border bg-[#050508] px-1.5 py-0.5 text-[8px] font-mono text-shogun-subdued`,children:[(0,w.jsx)(o,{className:`h-2.5 w-2.5`}),` `,e]},e))})}function E(){let{t:e}=oe(),[p,ae]=(0,C.useState)(`catalog`),[_,E]=(0,C.useState)(!0),[de,fe]=(0,C.useState)([]),[pe,me]=(0,C.useState)([]),[he,ge]=(0,C.useState)([]),[_e,ve]=(0,C.useState)([]),[D,O]=(0,C.useState)(null),[k,ye]=(0,C.useState)(null),[A,be]=(0,C.useState)([]),[j,xe]=(0,C.useState)(``),[M,Se]=(0,C.useState)(null),[N,Ce]=(0,C.useState)(null),[we,P]=(0,C.useState)(!1),[F,Te]=(0,C.useState)(``),[Ee,De]=(0,C.useState)(!1),[I,Oe]=(0,C.useState)(``),[ke,Ae]=(0,C.useState)(!1),[L,R]=(0,C.useState)(null),[z,B]=(0,C.useState)(null),[V,je]=(0,C.useState)(null),[Me,Ne]=(0,C.useState)(null),[H,Pe]=(0,C.useState)(null),[U,W]=(0,C.useState)({}),[Fe,G]=(0,C.useState)(`idle`),[K,Ie]=(0,C.useState)(null),[Le,Re]=(0,C.useState)(null),[ze,Be]=(0,C.useState)(!1),[Ve,He]=(0,C.useState)(``),[Ue,We]=(0,C.useState)(!1),[Ge,Ke]=(0,C.useState)(null),[qe,Je]=(0,C.useState)(null),[q,Ye]=(0,C.useState)(null),[Xe,Ze]=(0,C.useState)(!1),[J,Y]=(0,C.useState)(null),[X,Qe]=(0,C.useState)(new Set),[$e,et]=(0,C.useState)([]),[tt,nt]=(0,C.useState)(null),Z=(0,C.useCallback)(async()=>{try{let[e,t]=await Promise.all([v.get(`/api/v1/dojo/openclaw/stats`),v.get(`/api/v1/dojo/openclaw/registration-status`)]);ye(e.data.data),Ce(t.data.data)}catch(e){console.error(`Error fetching stats:`,e)}},[]),rt=(0,C.useCallback)(async()=>{try{let e=await v.get(`/api/v1/dojo/openclaw/subcategories`);be(e.data.data||[])}catch(e){console.error(`Error fetching subcategories:`,e)}},[]),Q=(0,C.useCallback)(async()=>{try{let e=(await v.get(`/api/v1/dojo/openclaw/installed`)).data.data||[];et(e),Qe(new Set(e.map(e=>e.openclaw_skill_id).filter(Boolean)))}catch(e){console.error(`Error fetching installed skills:`,e)}},[]),$=(0,C.useCallback)(async()=>{E(!0),nt(null);try{if(p===`catalog`){let e={limit:200};j&&(e.search=j);let t=await v.get(`/api/v1/dojo/openclaw/skills`,{params:e});fe(t.data.data||[])}else if(p===`bundles`){let e=await v.get(`/api/v1/dojo/openclaw/bundles`);me(e.data.data||[])}else if(p===`specializations`){let[e,t]=await Promise.all([v.get(`/api/v1/dojo/openclaw/specializations`),v.get(`/api/v1/dojo/openclaw/achievements`).catch(()=>null)]);ge(e.data.data||[]),t&&O(t.data.data)}else if(p===`achieved`){let e=(await v.get(`/api/v1/dojo/openclaw/achievements`)).data.data;O(e),Je({test_results:e?.achieved_skills||[],transcript:[]});let[t,n,r]=await Promise.allSettled([v.get(`/api/v1/dojo/openclaw/badges`),v.get(`/api/v1/dojo/openclaw/installed`),v.get(`/api/v1/dojo/openclaw/transcript`)]);if(t.status===`fulfilled`&&ve(t.value.data.data||[]),n.status===`fulfilled`){let e=n.value.data.data||[];et(e),Qe(new Set(e.map(e=>e.openclaw_skill_id).filter(Boolean)))}r.status===`fulfilled`&&r.value.data.data&&Je(r.value.data.data)}}catch(e){console.error(`Error fetching tab data:`,e),nt(e.response?.data?.detail||e.response?.data?.message||e.message||`Unable to load Dojo data.`)}finally{E(!1)}},[p,j]);(0,C.useEffect)(()=>{Z(),rt(),Q()},[Z,rt,Q]),(0,C.useEffect)(()=>{let e=setTimeout(()=>{$()},p===`catalog`&&j?400:0);return()=>clearTimeout(e)},[p,j]);let it=async()=>{if(F.trim()){De(!0);try{let e=await v.post(`/api/v1/dojo/openclaw/register`,{agent_name:F});Ce(e.data.data),P(!1),Te(``)}catch(e){console.error(`Registration failed:`,e)}finally{De(!1)}}},at=async()=>{if(I.trim()){Ae(!0),R(null);try{let e=await v.post(`/api/v1/dojo/skills/add-url`,{url:I});R({type:`success`,text:e.data.data.message}),Oe(``)}catch(e){R({type:`error`,text:e.response?.data?.detail||`Failed to import URL`})}finally{Ae(!1)}}},ot=async()=>{We(!0),Ke(null);try{await v.post(`/api/v1/dojo/openclaw/credentials`,{openclaw_api_key:Ve}),Ke({type:`success`,text:`API key saved.`}),He(``),Be(!1),Z()}catch(e){Ke({type:`error`,text:e.response?.data?.detail||`Failed to save credentials`})}finally{We(!1)}},st=async e=>{G(`loading`),Re(null),Ie(null);try{let t=(await v.post(`/api/v1/dojo/openclaw/exams/auto-take`,{skill_id:e})).data.data;Ie(t),G(`result`);try{let e=await v.get(`/api/v1/dojo/openclaw/transcript`);Je(e.data.data)}catch{}$()}catch(e){Re(e.response?.data?.detail||`Could not complete exam. Check your API key in credentials.`),G(`idle`)}},ct=()=>{G(`idle`),Ie(null),Re(null)},lt=async e=>{Ye(e.id),Y(null);try{(await v.post(`/api/v1/dojo/openclaw/install`,{openclaw_skill_id:e.id,skill_name:e.name,slug:e.slug||``,version:e.version||`1.0.0`,risk_tier:e.risk_tier||`standard`,description:e.description||``,permissions:e.permissions||{},capabilities:e.capabilities||[]})).data.data.already_installed?Y({type:`info`,text:`${e.name} is already installed.`}):Y({type:`success`,text:`${e.name} installed successfully!`}),Qe(t=>new Set(t).add(e.id)),Q()}catch(e){Y({type:`error`,text:e.response?.data?.detail||`Install failed.`})}finally{Ye(null),setTimeout(()=>Y(null),4e3)}},ut=async()=>{Ze(!0),Y(null);try{let e=(await v.post(`/api/v1/dojo/openclaw/installed/refresh`)).data.data||{};Y({type:`success`,text:e.updated?`Updated ${e.updated} installed skill${e.updated===1?``:`s`} and synchronized Archives.`:`Installed skills are current. ${e.protected||0} SkillOpt version${e.protected===1?``:`s`} preserved.`}),await Q(),await $()}catch(e){Y({type:`error`,text:e.response?.data?.detail||`Skill refresh failed.`})}finally{Ze(!1),setTimeout(()=>Y(null),6e3)}},dt=async e=>{Ne(e.id),Y(null);try{let t=(await v.post(`/api/v1/dojo/openclaw/specializations/${encodeURIComponent(e.id)}/enroll`)).data.data?.awarded||[];Y({type:`success`,text:t.length?`Enrolled and awarded ${t.length} badge${t.length===1?``:`s`}!`:`Enrolled in ${e.name||e.title}.`});let n=await v.get(`/api/v1/dojo/openclaw/achievements`);O(n.data.data)}catch(e){Y({type:`error`,text:e.response?.data?.detail||`Specialization enrollment failed.`})}finally{Ne(null),setTimeout(()=>Y(null),5e3)}},ft=de.filter(e=>{let t=!j||e.name?.toLowerCase().includes(j.toLowerCase())||e.description?.toLowerCase().includes(j.toLowerCase()),n=!z||e.faculty===z||e.subcategory===z;return t&&n}),pt=pe.filter(e=>!j||e.name?.toLowerCase().includes(j.toLowerCase())||e.description?.toLowerCase().includes(j.toLowerCase())),mt=he.filter(e=>!j||e.name?.toLowerCase().includes(j.toLowerCase())||e.description?.toLowerCase().includes(j.toLowerCase())),ht=qe?.test_results?.length?qe.test_results:D?.achieved_skills||[],gt=[{key:`catalog`,label:e(`dojo.tab_explore`,`Skill Catalog`),icon:t,count:k?.skills},{key:`bundles`,label:e(`dojo.tab_bundles`,`Ready Bundles`),icon:s,count:k?.bundles},{key:`specializations`,label:e(`dojo.tab_specializations`,`Specializations`),icon:x,count:k?.specializations},{key:`achieved`,label:e(`dojo.tab_achieved`,`Achieved`),icon:S}];return(0,w.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-7xl mx-auto pb-12`,children:[J&&(0,w.jsxs)(`div`,{className:g(`fixed top-6 right-6 z-50 px-5 py-3 rounded-xl shadow-lg text-sm font-bold animate-in slide-in-from-top duration-300 flex items-center gap-3`,J.type===`success`?`bg-green-500/90 text-white`:J.type===`info`?`bg-shogun-blue/90 text-white`:`bg-red-500/90 text-white`),children:[J.type===`success`?(0,w.jsx)(a,{className:`w-4 h-4`}):J.type===`info`?(0,w.jsx)(i,{className:`w-4 h-4`}):(0,w.jsx)(m,{className:`w-4 h-4`}),J.text]}),(0,w.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`dojo.title`,`The Dojo`),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`OpenClaw Hub`})]}),(0,w.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`dojo.subtitle`,`Discover and install specialized skills from the global OpenClaw College registry.`)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsxs)(`div`,{className:`hidden lg:flex items-center gap-6 px-6 border-r border-shogun-border`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest leading-none`,children:`Catalog`}),(0,w.jsxs)(`span`,{className:`text-xl font-bold text-shogun-gold`,children:[k?.skills??(0,w.jsx)(h,{className:`w-4 h-4 animate-spin inline`}),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal`,children:`Skills`})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest leading-none`,children:`Subcategories`}),(0,w.jsxs)(`span`,{className:`text-xl font-bold text-shogun-blue`,children:[k?.subcategories??(0,w.jsx)(h,{className:`w-4 h-4 animate-spin inline`}),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal`,children:`Fields`})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest leading-none`,children:`Badges`}),(0,w.jsxs)(`span`,{className:`text-xl font-bold text-purple-400`,children:[k?.badges??(0,w.jsx)(h,{className:`w-4 h-4 animate-spin inline`}),` `,(0,w.jsx)(`span`,{className:`text-[10px] font-normal`,children:`Available`})]})]})]}),(0,w.jsx)(`button`,{onClick:()=>{Z(),$(),rt()},className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,w.jsx)(l,{className:g(`w-4 h-4`,_&&`animate-spin`)})})]})]}),(0,w.jsx)(`div`,{className:`flex border-b border-shogun-border overflow-x-auto`,children:gt.map(e=>{let t=e.icon;return(0,w.jsxs)(`button`,{onClick:()=>ae(e.key),className:g(`px-5 py-3 text-sm font-bold uppercase tracking-widest transition-all relative flex items-center gap-2 whitespace-nowrap`,p===e.key?`text-shogun-gold`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,w.jsx)(t,{className:`w-3.5 h-3.5`}),e.label,e.count!==void 0&&(0,w.jsx)(`span`,{className:g(`text-[9px] px-1.5 py-0.5 rounded-full font-mono`,p===e.key?`bg-shogun-gold/10 text-shogun-gold`:`bg-shogun-card text-shogun-subdued`),children:e.count}),p===e.key&&(0,w.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-gold shadow-[0_0_10px_rgba(212,160,23,0.5)]`})]},e.key)})}),(0,w.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-4 gap-8 mt-6`,children:[(0,w.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(ne,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-shogun-subdued`}),(0,w.jsx)(`input`,{type:`text`,placeholder:`Filter Dojo...`,value:j,onChange:e=>xe(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl pl-10 pr-4 py-3 text-sm focus:border-shogun-gold outline-none transition-all shadow-inner`})]}),(0,w.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-2`,children:[(0,w.jsx)(te,{className:`w-3 h-3`}),` Import from URL`]}),(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[(0,w.jsx)(`input`,{type:`text`,placeholder:`GitHub / ClawHub URL...`,value:I,onChange:e=>{Oe(e.target.value),R(null)},className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs focus:border-shogun-blue outline-none transition-all`,onKeyDown:e=>e.key===`Enter`&&at()}),(0,w.jsx)(`button`,{onClick:at,disabled:ke||!I.trim(),className:`px-3 py-2 bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue rounded-lg text-xs font-bold uppercase tracking-wider hover:bg-shogun-blue/20 transition-colors disabled:opacity-30`,children:ke?(0,w.jsx)(h,{className:`w-3 h-3 animate-spin`}):(0,w.jsx)(c,{className:`w-3 h-3`})})]}),L&&(0,w.jsx)(`p`,{className:g(`text-[10px] leading-relaxed`,L.type===`success`?`text-green-400`:`text-red-400`),children:L.text}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60 italic`,children:`Paste a repo URL to import skills directly from source.`})]}),(0,w.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,w.jsx)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest border-b border-shogun-border pb-2`,children:`All Categories`}),(0,w.jsx)(`div`,{onClick:()=>B(null),className:g(`text-[10px] px-3 py-1.5 rounded cursor-pointer transition-colors font-bold`,z?`text-shogun-subdued hover:text-shogun-gold`:`bg-shogun-gold/10 text-shogun-gold`),children:`All Categories`}),A.length>0?(0,w.jsxs)(w.Fragment,{children:[A.filter(e=>e.facultyId===`technical`).length>0&&(0,w.jsxs)(`div`,{className:`space-y-1`,children:[(0,w.jsxs)(`p`,{className:`text-[8px] font-bold text-shogun-blue uppercase tracking-[0.2em] flex items-center gap-1.5 mt-2 px-1 cursor-pointer select-none hover:opacity-80 transition-opacity`,onClick:()=>W(e=>({...e,technical:!e.technical})),children:[(0,w.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-shogun-blue inline-block`}),`faculties.technical`,U.technical?(0,w.jsx)(r,{className:`w-2.5 h-2.5 ml-auto`}):(0,w.jsx)(n,{className:`w-2.5 h-2.5 ml-auto`})]}),!U.technical&&A.filter(e=>e.facultyId===`technical`).map(e=>(0,w.jsx)(`div`,{onClick:()=>B(e.id),className:g(`text-[10px] px-3 py-1 rounded cursor-pointer transition-colors truncate`,z===e.id?`bg-shogun-gold/10 text-shogun-gold font-bold`:`text-shogun-subdued hover:text-shogun-text hover:bg-[#050508]`),children:e.name},e.id))]}),A.filter(e=>e.facultyId===`human_wellbeing`).length>0&&(0,w.jsxs)(`div`,{className:`space-y-1`,children:[(0,w.jsxs)(`p`,{className:`text-[8px] font-bold text-orange-400 uppercase tracking-[0.2em] flex items-center gap-1.5 mt-3 px-1 cursor-pointer select-none hover:opacity-80 transition-opacity`,onClick:()=>W(e=>({...e,human_wellbeing:!e.human_wellbeing})),children:[(0,w.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-orange-400 inline-block`}),`faculties.human_wellbeing`,U.human_wellbeing?(0,w.jsx)(r,{className:`w-2.5 h-2.5 ml-auto`}):(0,w.jsx)(n,{className:`w-2.5 h-2.5 ml-auto`})]}),!U.human_wellbeing&&A.filter(e=>e.facultyId===`human_wellbeing`).map(e=>(0,w.jsx)(`div`,{onClick:()=>B(e.id),className:g(`text-[10px] px-3 py-1 rounded cursor-pointer transition-colors truncate`,z===e.id?`bg-shogun-gold/10 text-shogun-gold font-bold`:`text-shogun-subdued hover:text-shogun-text hover:bg-[#050508]`),children:e.name},e.id))]}),A.filter(e=>e.facultyId===`business_professional`).length>0&&(0,w.jsxs)(`div`,{className:`space-y-1`,children:[(0,w.jsxs)(`p`,{className:`text-[8px] font-bold text-green-400 uppercase tracking-[0.2em] flex items-center gap-1.5 mt-3 px-1 cursor-pointer select-none hover:opacity-80 transition-opacity`,onClick:()=>W(e=>({...e,business_professional:!e.business_professional})),children:[(0,w.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`}),`faculties.business_professional`,U.business_professional?(0,w.jsx)(r,{className:`w-2.5 h-2.5 ml-auto`}):(0,w.jsx)(n,{className:`w-2.5 h-2.5 ml-auto`})]}),!U.business_professional&&A.filter(e=>e.facultyId===`business_professional`).map(e=>(0,w.jsx)(`div`,{onClick:()=>B(e.id),className:g(`text-[10px] px-3 py-1 rounded cursor-pointer transition-colors truncate`,z===e.id?`bg-shogun-gold/10 text-shogun-gold font-bold`:`text-shogun-subdued hover:text-shogun-text hover:bg-[#050508]`),children:e.name},e.id))]})]}):Array.from({length:8}).map((e,t)=>(0,w.jsx)(`div`,{className:`h-4 bg-shogun-bg border border-shogun-border rounded animate-pulse`},t))]}),(0,w.jsx)(`div`,{className:g(`shogun-card border-2 transition-all`,N?.registered?`bg-green-500/5 border-green-500/20`:`bg-shogun-gold/5 border-shogun-gold/20`),children:N?.registered?(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(b,{className:`w-5 h-5 text-green-500`}),(0,w.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:`Registered`})]}),(0,w.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:[`Your Shogun is enrolled at OpenClaw College as `,(0,w.jsx)(`strong`,{className:`text-shogun-text`,children:N.agent_name}),`.`]}),(0,w.jsxs)(`code`,{className:`block text-[9px] bg-[#050508] p-2 rounded border border-shogun-border text-shogun-subdued font-mono truncate`,children:[`ID: `,N.openclaw_agent_id]}),(0,w.jsxs)(`button`,{onClick:()=>Be(!ze),className:`w-full py-2 text-[10px] font-bold uppercase tracking-widest border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-blue hover:border-shogun-blue/40 transition-colors flex items-center justify-center gap-2`,children:[(0,w.jsx)(o,{className:`w-3 h-3`}),` `,ze?`Hide`:`Set API Key`]}),ze&&(0,w.jsxs)(`div`,{className:`space-y-2 pt-1`,children:[(0,w.jsx)(`label`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`X-API-Key (membership key)`}),(0,w.jsx)(`input`,{type:`password`,value:Ve,onChange:e=>He(e.target.value),placeholder:`paste your api key…`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs focus:border-shogun-blue outline-none transition-all font-mono`}),Ge&&(0,w.jsx)(`p`,{className:g(`text-[9px]`,Ge.type===`success`?`text-green-400`:`text-red-400`),children:Ge.text}),(0,w.jsx)(`button`,{onClick:ot,disabled:Ue||!Ve.trim(),className:`w-full py-2 bg-shogun-blue/10 border border-shogun-blue/30 text-shogun-blue text-[10px] font-bold uppercase tracking-widest rounded-lg hover:bg-shogun-blue/20 transition-colors disabled:opacity-30`,children:Ue?(0,w.jsx)(h,{className:`w-3 h-3 animate-spin mx-auto`}):`Save Key`})]})]}):(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(d,{className:`w-5 h-5 text-shogun-gold`}),(0,w.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:`Join OpenClaw College`})]}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Register your Shogun to earn badges, track specializations, and participate in the global agent community.`}),(0,w.jsxs)(`button`,{onClick:()=>P(!0),className:`w-full py-2.5 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-[10px] uppercase tracking-[0.2em] rounded-lg shadow-shogun transition-all flex items-center justify-center gap-2`,children:[(0,w.jsx)(d,{className:`w-3.5 h-3.5`}),` Sign Up for OpenClaw College`]})]})}),(0,w.jsxs)(`div`,{className:`shogun-card bg-shogun-blue/5 border-shogun-blue/20`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,w.jsx)(S,{className:`w-5 h-5 text-shogun-gold`}),(0,w.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:`OpenClaw Certified`})]}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`All skills in the Dojo have undergone automated safety auditing by the OpenClaw College board. Verified skills display the "Zen" mark of stability.`})]})]}),(0,w.jsx)(`div`,{className:`lg:col-span-3`,children:_?(0,w.jsxs)(`div`,{className:`p-20 text-center shogun-card bg-[#050508]/20 flex flex-col items-center gap-4 border-dashed`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(l,{className:`w-10 h-10 animate-spin text-shogun-gold`}),(0,w.jsx)(u,{className:`absolute -top-1 -right-1 w-4 h-4 text-shogun-blue animate-pulse`})]}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] text-shogun-subdued`,children:`Syncing with OpenClaw College...`})]}):(0,w.jsxs)(w.Fragment,{children:[tt&&(0,w.jsxs)(`div`,{className:`mb-4 rounded-xl border border-red-500/30 bg-red-500/10 p-4 text-xs text-red-300`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 font-bold`,children:[(0,w.jsx)(i,{className:`h-4 w-4`}),` Dojo sync failed`]}),(0,w.jsx)(`p`,{className:`mt-1 font-mono text-[10px]`,children:tt})]}),p===`catalog`&&(0,w.jsx)(`div`,{className:`space-y-4`,children:ft.length===0?(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:[(0,w.jsx)(ne,{className:`w-8 h-8 text-shogun-subdued mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No skills match your search criteria.`})]}):(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:ft.map(e=>(0,w.jsxs)(`div`,{onClick:()=>Se(e),className:`shogun-card group hover:border-shogun-gold/50 cursor-pointer transition-all flex flex-col`,children:[(0,w.jsxs)(`div`,{className:`flex justify-between items-start mb-4`,children:[(0,w.jsx)(`div`,{className:`w-12 h-12 bg-[#050508] border border-shogun-border rounded-xl flex items-center justify-center text-shogun-gold group-hover:bg-shogun-gold/10 transition-colors`,children:(0,w.jsx)(t,{className:`w-6 h-6`})}),(0,w.jsxs)(`div`,{className:`flex flex-col items-end gap-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[X.has(e.id)&&(0,w.jsxs)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 bg-green-500/15 text-green-400 rounded border border-green-500/30 flex items-center gap-1`,children:[(0,w.jsx)(a,{className:`w-2.5 h-2.5`}),` Installed`]}),(0,w.jsxs)(`code`,{className:`text-[9px] bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border text-shogun-subdued`,children:[`v`,e.version]})]}),(0,w.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest mt-1`,e.risk_tier===`shrine`?`text-shogun-gold`:e.risk_tier===`tactical`?`text-shogun-blue`:e.risk_tier===`elevated`?`text-orange-400`:`text-green-400`),children:e.risk_tier})]})]}),(0,w.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text group-hover:text-shogun-gold transition-colors`,children:e.name}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-2 line-clamp-3 leading-relaxed flex-1`,children:e.description}),(0,w.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-shogun-border flex items-center justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex gap-2`,children:[e.permissions?.network&&(0,w.jsx)(ce,{className:`w-3 h-3 text-shogun-blue`}),e.permissions?.shell&&(0,w.jsx)(f,{className:`w-3 h-3 text-red-500`}),e.permissions?.filesystem_write&&(0,w.jsx)(ie,{className:`w-3 h-3 text-green-500`}),e.permissions?.filesystem_read&&(0,w.jsx)(t,{className:`w-3 h-3 text-purple-400`}),e.permissions?.credentials&&(0,w.jsx)(o,{className:`w-3 h-3 text-orange-400`})]}),(0,w.jsx)(`div`,{onClick:t=>{t.stopPropagation(),X.has(e.id)||lt(e)},className:g(`flex items-center gap-1 text-[10px] font-mono transition-colors`,X.has(e.id)?`text-green-400`:q===e.id?`text-shogun-gold animate-pulse cursor-pointer`:`text-shogun-subdued group-hover:text-shogun-gold cursor-pointer`),children:X.has(e.id)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(a,{className:`w-3 h-3`}),` Installed`]}):q===e.id?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h,{className:`w-3 h-3 animate-spin`}),` Installing…`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(c,{className:`w-3 h-3`}),` + Install`]})})]})]},e.id))})}),p===`bundles`&&(0,w.jsx)(`div`,{className:`space-y-4`,children:pt.length===0?(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:[(0,w.jsx)(s,{className:`w-8 h-8 text-shogun-subdued mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No bundles available.`})]}):(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:pt.map(e=>(0,w.jsxs)(`div`,{className:g(`shogun-card group cursor-pointer transition-all`,H===e.id?`border-shogun-blue/50`:`hover:border-shogun-blue/50`),onClick:()=>Pe(H===e.id?null:e.id),children:[(0,w.jsxs)(`div`,{className:`flex items-start gap-4 mb-3`,children:[(0,w.jsx)(`div`,{className:`w-12 h-12 bg-shogun-blue/10 border border-shogun-blue/20 rounded-xl flex items-center justify-center flex-shrink-0 text-xl`,children:e.icon||`📦`}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text group-hover:text-shogun-blue transition-colors`,children:e.name}),e.currentVersion?.riskTier&&(0,w.jsx)(`span`,{className:g(`text-[9px] px-2 py-0.5 rounded font-bold uppercase tracking-widest`,e.currentVersion.riskTier===`low`?`bg-green-500/10 text-green-400`:e.currentVersion.riskTier===`medium`?`bg-yellow-500/10 text-yellow-400`:`bg-red-500/10 text-red-400`),children:e.currentVersion.riskTier})]}),(0,w.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold mt-0.5`,children:[e.skillIds?.length||0,` skills · `,e.facultyId||`General`,e.currentVersion?.versionLabel&&(0,w.jsxs)(w.Fragment,{children:[` · v`,e.currentVersion.versionLabel]})]})]}),(0,w.jsx)(r,{className:g(`w-4 h-4 text-shogun-subdued transition-transform mt-1`,H===e.id&&`rotate-90`)})]}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed line-clamp-3`,children:e.shortDescription||e.description}),H===e.id&&(0,w.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-shogun-border space-y-3`,onClick:e=>e.stopPropagation(),children:[e.currentVersion?.skills&&e.currentVersion.skills.length>0?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(f,{className:`w-3.5 h-3.5 text-shogun-blue`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Included Skills`}),(0,w.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued font-mono`,children:e.currentVersion.skills.length})]}),(0,w.jsx)(`div`,{className:`space-y-1 pl-5`,children:e.currentVersion.skills.map(e=>(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`text-[8px] px-2 py-0.5 bg-[#050508] border border-shogun-border rounded font-mono text-shogun-subdued`,children:e.id}),(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-text`,children:e.name})]},e.id))})]}):e.skillIds&&e.skillIds.length>0?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(f,{className:`w-3.5 h-3.5 text-shogun-blue`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Included Skills`}),(0,w.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued font-mono`,children:e.skillIds.length})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pl-5`,children:e.skillIds.map(e=>(0,w.jsx)(`span`,{className:`text-[8px] px-2 py-0.5 bg-[#050508] border border-shogun-border rounded font-mono text-shogun-subdued`,children:e},e))})]}):null,(0,w.jsx)(`div`,{className:`mt-3 pt-3 border-t border-shogun-border`,children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono text-shogun-blue cursor-pointer hover:text-shogun-blue/80 transition-colors`,children:[(0,w.jsx)(c,{className:`w-3 h-3`}),` Install Bundle`]})})]}),H!==e.id&&(0,w.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-shogun-border flex items-center justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(ee,{className:`w-3 h-3 text-shogun-blue`}),(0,w.jsxs)(`span`,{className:`text-[10px] font-mono text-shogun-subdued`,children:[e.skillIds?.length||0,` skills included`]})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] font-mono text-shogun-subdued group-hover:text-shogun-blue transition-colors`,children:[(0,w.jsx)(c,{className:`w-3 h-3`}),` Install Bundle`]})]})]},e.id))})}),p===`specializations`&&(0,w.jsx)(`div`,{className:`space-y-4`,children:mt.length===0?(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:[(0,w.jsx)(x,{className:`w-8 h-8 text-shogun-subdued mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No specializations available.`})]}):(0,w.jsx)(`div`,{className:`grid grid-cols-1 gap-6`,children:mt.map(e=>{let t=D?.specializations_earned?.find(t=>t.id===e.id);return(0,w.jsxs)(`div`,{className:g(`shogun-card group cursor-pointer transition-all`,V===e.id?`border-purple-400/50`:`hover:border-purple-400/50`),onClick:()=>je(V===e.id?null:e.id),children:[(0,w.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,w.jsx)(`div`,{className:`w-14 h-14 bg-purple-500/10 border border-purple-500/20 rounded-xl flex items-center justify-center flex-shrink-0 text-2xl`,children:e.icon||`🎓`}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,w.jsx)(`h4`,{className:`text-lg font-bold text-shogun-text group-hover:text-purple-400 transition-colors`,children:e.name}),(0,w.jsx)(`span`,{className:`text-[9px] px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded font-bold uppercase tracking-widest`,children:e.degreeType||`Specialization`})]}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed line-clamp-2`,children:e.title||e.description}),t&&(0,w.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,w.jsx)(b,{className:`h-3.5 w-3.5 text-green-400`}),(0,w.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider text-green-400`,children:`Earned with`}),(0,w.jsx)(T,{item:t})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-4 mt-3`,children:[(0,w.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest`,children:[`Faculty: `,e.facultyId||e.faculty||`General`]}),(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued/60`,children:`•`}),(0,w.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued uppercase font-bold tracking-widest`,children:[`Category: `,e.categoryId||`—`]}),(0,w.jsx)(r,{className:g(`w-3 h-3 text-shogun-subdued transition-transform ml-auto`,V===e.id&&`rotate-90`)})]})]})]}),V===e.id&&(0,w.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-shogun-border space-y-4`,onClick:e=>e.stopPropagation(),children:[e.requirements?.map((e,t)=>(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.type===`bundle_count`?(0,w.jsx)(s,{className:`w-3.5 h-3.5 text-shogun-gold`}):(0,w.jsx)(f,{className:`w-3.5 h-3.5 text-shogun-blue`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:e.label}),(0,w.jsx)(`span`,{className:`text-[9px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued font-mono`,children:e.count})]}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pl-5`,children:(e.bundleIds||e.skillIds||[]).map(e=>(0,w.jsx)(`span`,{className:`text-[8px] px-2 py-0.5 bg-[#050508] border border-shogun-border rounded font-mono text-shogun-subdued truncate max-w-[160px]`,children:e},e))})]},t)),e.badgeId&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,w.jsx)(y,{className:`w-3.5 h-3.5 text-purple-400`}),(0,w.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Badge Reward`}),(0,w.jsx)(`span`,{className:`text-[9px] px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded font-mono`,children:e.badgeId})]}),(0,w.jsx)(`button`,{type:`button`,onClick:()=>dt(e),disabled:Me===e.id||D?.enrollments?.some(t=>(typeof t==`string`?t:t.specializationId)===e.id),className:`w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg border border-purple-500/30 bg-purple-500/10 text-purple-300 text-xs font-bold uppercase tracking-wider hover:bg-purple-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:Me===e.id?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h,{className:`w-4 h-4 animate-spin`}),` Enrolling…`]}):D?.enrollments?.some(t=>(typeof t==`string`?t:t.specializationId)===e.id)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(a,{className:`w-4 h-4`}),` Enrolled`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(x,{className:`w-4 h-4`}),` Enroll & Evaluate`]})})]})]},e.id)})})}),p===`achieved`&&(0,w.jsxs)(`div`,{className:`space-y-8`,children:[D?.registered?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(y,{className:`w-8 h-8 text-shogun-gold mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-shogun-gold`,children:D.badges?.length||0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Badges Earned`})]}),(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(x,{className:`w-8 h-8 text-purple-400 mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-purple-400`,children:D.specializations_earned?.length||0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Specializations`})]}),(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(re,{className:`w-8 h-8 text-shogun-blue mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-shogun-blue`,children:D.skills_installed??D.skills_completed??0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Skills Installed`})]}),(0,w.jsxs)(`div`,{className:`shogun-card text-center`,children:[(0,w.jsx)(a,{className:`w-8 h-8 text-green-400 mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-2xl font-bold text-green-400`,children:D.exams_passed||0}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Exams Passed`})]})]}),D.specializations_earned?.length>0&&(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(x,{className:`w-3.5 h-3.5 text-purple-400`}),` Earned Specializations`]}),(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:D.specializations_earned.map(e=>(0,w.jsxs)(`div`,{className:`shogun-card border-purple-500/20 text-center`,children:[(0,w.jsx)(x,{className:`w-7 h-7 text-purple-400 mx-auto mb-2`}),(0,w.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e.name||e.title}),(0,w.jsx)(T,{item:e})]},e.id||e.name))})]}),(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(y,{className:`w-3.5 h-3.5 text-shogun-gold`}),` Earned Badges`]}),D.badges?.length>0?(0,w.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:D.badges.map(e=>(0,w.jsxs)(`div`,{className:`shogun-card text-center hover:border-shogun-gold/50 transition-all group`,children:[(0,w.jsx)(`div`,{className:`w-12 h-12 bg-shogun-gold/10 rounded-full flex items-center justify-center mx-auto mb-3 group-hover:bg-shogun-gold/20 transition-colors`,children:(0,w.jsx)(y,{className:`w-6 h-6 text-shogun-gold`})}),(0,w.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e.name}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-1 line-clamp-2`,children:e.description}),(0,w.jsx)(T,{item:e})]},e.id||e.name))}):(0,w.jsx)(`div`,{className:`p-6 text-center shogun-card border-dashed`,children:(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No badges earned yet. Complete skills and specializations to earn badges.`})})]}),$e.length>0&&(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(s,{className:`w-3.5 h-3.5 text-green-400`}),` Installed Skills`,(0,w.jsx)(`span`,{className:`text-[9px] px-2 py-0.5 bg-green-500/10 text-green-400 rounded-full font-mono`,children:$e.length}),(0,w.jsxs)(`button`,{onClick:ut,disabled:Xe,className:`ml-auto inline-flex items-center gap-1.5 rounded-lg border border-shogun-blue/30 bg-shogun-blue/10 px-2.5 py-1.5 text-[9px] font-bold tracking-widest text-shogun-blue transition-colors hover:bg-shogun-blue/20 disabled:opacity-50`,title:`Fetch current canonical SKILL.md files and synchronize Archives`,children:[(0,w.jsx)(l,{className:g(`h-3 w-3`,Xe&&`animate-spin`)}),Xe?`Refreshing…`:`Refresh Skills`]})]}),(0,w.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:$e.map(e=>{let t=e.openclaw_skill_id||e.skill_id;return(0,w.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border border-green-500/15 bg-gradient-to-r from-green-500/5 via-[#050508] to-[#050508] transition-all hover:border-green-500/30`,children:[(0,w.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-1 bg-green-500/50`}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3 p-3.5 pl-4`,children:[(0,w.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-green-500/10 border border-green-500/20 flex items-center justify-center flex-shrink-0`,children:(0,w.jsx)(f,{className:`w-4 h-4 text-green-400`})}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-xs font-bold text-shogun-text truncate`,children:e.name}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[e.faculty&&(0,w.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 bg-shogun-card border border-shogun-border rounded text-shogun-subdued uppercase tracking-wider`,children:e.faculty?.replace(/_/g,` `)}),(0,w.jsxs)(`span`,{className:`text-[8px] text-shogun-subdued font-mono`,children:[`v`,e.version]})]})]}),(0,w.jsx)(a,{className:`w-4 h-4 text-green-400 flex-shrink-0`})]})]},t)})})]}),ht.length>0&&(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(x,{className:`w-3.5 h-3.5 text-shogun-blue`}),` Achieved Skills & Certification Transcript`]}),(0,w.jsx)(`div`,{className:`space-y-3`,children:ht.map((e,t)=>{let n=e.verificationStatus===`approved`||e.score>=85,r=de.find(t=>t.id===e.skillId)?.name||e.skillName||e.testId,a=e.passedAt?new Date(e.passedAt).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`}):null;return(0,w.jsxs)(`div`,{className:g(`relative overflow-hidden rounded-xl border transition-all`,n?`bg-gradient-to-r from-green-500/5 via-[#050508] to-[#050508] border-green-500/20`:`bg-gradient-to-r from-orange-500/5 via-[#050508] to-[#050508] border-orange-500/20`),children:[(0,w.jsx)(`div`,{className:g(`absolute left-0 top-0 bottom-0 w-1`,n?`bg-green-500`:`bg-orange-400`)}),(0,w.jsxs)(`div`,{className:`flex items-center gap-4 p-4 pl-5`,children:[(0,w.jsx)(`div`,{className:g(`w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0 border`,n?`bg-green-500/10 border-green-500/30`:`bg-orange-500/10 border-orange-500/30`),children:n?(0,w.jsx)(b,{className:`w-5 h-5 text-green-400`}):(0,w.jsx)(i,{className:`w-5 h-5 text-orange-400`})}),(0,w.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,w.jsx)(`p`,{className:`text-sm font-bold text-shogun-text truncate`,children:r}),(0,w.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 flex-wrap`,children:[a&&(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued flex items-center gap-1`,children:[(0,w.jsx)(l,{className:`w-2.5 h-2.5`}),` `,a]}),e.agentName&&(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued flex items-center gap-1`,children:[(0,w.jsx)(se,{className:`w-2.5 h-2.5`}),` `,e.agentName]}),(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued flex items-center gap-1`,children:[(0,w.jsx)(o,{className:`w-2.5 h-2.5`}),(0,w.jsx)(`span`,{className:`font-mono`,children:le(D?.achieved_skills?.find(t=>t.testId===e.testId||t.skillId===e.skillId)||e).join(`, `)})]})]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col items-end gap-1 flex-shrink-0`,children:[(0,w.jsxs)(`span`,{className:g(`text-lg font-black font-mono`,n?`text-green-400`:`text-orange-400`),children:[e.score,`%`]}),(0,w.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded-full`,n?`bg-green-500/10 text-green-400 border border-green-500/20`:`bg-orange-500/10 text-orange-400 border border-orange-500/20`),children:n?`✓ Certified`:`Not Passed`})]})]})]},e.id||t)})})]})]}):(0,w.jsxs)(`div`,{className:`p-12 text-center shogun-card border-dashed border-2 border-shogun-gold/20`,children:[(0,w.jsx)(d,{className:`w-10 h-10 text-shogun-gold mx-auto mb-4 opacity-50`}),(0,w.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`Not Registered Yet`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-md mx-auto mb-6`,children:`Register your Shogun with OpenClaw College to start earning badges and tracking specializations.`}),(0,w.jsxs)(`button`,{onClick:()=>P(!0),className:`px-6 py-3 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all inline-flex items-center gap-2`,children:[(0,w.jsx)(d,{className:`w-4 h-4`}),` Sign Up Now`]})]}),(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h3`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2`,children:[(0,w.jsx)(S,{className:`w-3.5 h-3.5 text-purple-400`}),` All Available Badges`]}),_e.length>0?(0,w.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:_e.map(e=>{let t=D?.badges?.find(t=>t.id===e.id),n=!!t;return(0,w.jsxs)(`div`,{className:g(`shogun-card text-center transition-all`,n?`border-shogun-gold/30 bg-shogun-gold/5`:`opacity-60 hover:opacity-100`),children:[(0,w.jsx)(`div`,{className:g(`w-10 h-10 rounded-full flex items-center justify-center mx-auto mb-2`,n?`bg-shogun-gold/20`:`bg-shogun-card`),children:n?(0,w.jsx)(a,{className:`w-5 h-5 text-shogun-gold`}):(0,w.jsx)(o,{className:`w-4 h-4 text-shogun-subdued`})}),(0,w.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-text`,children:e.name}),e.description&&(0,w.jsx)(`p`,{className:`text-[8px] text-shogun-subdued mt-1 line-clamp-2`,children:e.description}),t&&(0,w.jsx)(T,{item:t})]},e.id||e.name)})}):(0,w.jsxs)(`div`,{className:`p-6 text-center shogun-card border-dashed`,children:[(0,w.jsx)(S,{className:`w-6 h-6 text-shogun-subdued mx-auto mb-2 opacity-30`}),(0,w.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Badge catalog loading failed. Check connection to OpenClaw College.`})]})]})]})]})})]}),M&&(0,w.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-300`,children:(0,w.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-3xl rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300 flex flex-col max-h-[90vh]`,children:[(0,w.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center flex-shrink-0`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-gold`,children:(0,w.jsx)(f,{className:`w-5 h-5`})}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:M.name}),(0,w.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:[`Faculty: `,M.faculty||`General`]})]})]}),(0,w.jsx)(`button`,{onClick:()=>{Se(null),ct()},className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,w.jsx)(m,{className:`w-5 h-5 text-shogun-subdued`})})]}),Fe===`idle`&&(0,w.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 overflow-y-auto`,children:[(0,w.jsxs)(`div`,{className:`p-8 space-y-6 border-r border-shogun-border`,children:[(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Description`}),(0,w.jsx)(`p`,{className:`text-sm text-shogun-text leading-relaxed`,children:M.description})]}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Capabilities`}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(M.capabilities||[]).length>0?M.capabilities.map(e=>(0,w.jsx)(`span`,{className:`text-[10px] px-2 py-1 bg-shogun-card border border-shogun-border rounded text-shogun-subdued`,children:e},e)):(0,w.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:`No capabilities declared`})})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(`h4`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:`Metadata`}),(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,w.jsxs)(`div`,{className:`p-2 bg-[#050508] rounded border border-shogun-border`,children:[(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued block`,children:`Version`}),(0,w.jsx)(`span`,{className:`text-xs font-mono text-shogun-text`,children:M.version})]}),(0,w.jsxs)(`div`,{className:`p-2 bg-[#050508] rounded border border-shogun-border`,children:[(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued block`,children:`Risk Tier`}),(0,w.jsx)(`span`,{className:g(`text-xs font-bold uppercase`,M.risk_tier===`shrine`?`text-shogun-gold`:M.risk_tier===`elevated`?`text-orange-400`:`text-green-400`),children:M.risk_tier})]})]})]})]}),(0,w.jsxs)(`div`,{className:`p-8 space-y-6 bg-[#050508]/30`,children:[(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-gold uppercase tracking-widest flex items-center gap-2`,children:[(0,w.jsx)(o,{className:`w-3 h-3`}),` Permission Audit`]}),(0,w.jsx)(`div`,{className:`space-y-2`,children:Object.entries(M.permissions||{}).map(([e,t])=>(0,w.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-shogun-bg border border-shogun-border rounded-lg`,children:[(0,w.jsx)(`span`,{className:`text-xs text-shogun-text font-bold capitalize`,children:e.replace(/_/g,` `)}),t?(0,w.jsx)(a,{className:`w-4 h-4 text-green-500`}):(0,w.jsx)(ue,{className:`w-4 h-4 text-shogun-subdued`})]},e))})]}),(0,w.jsxs)(`div`,{className:`space-y-3 pt-2`,children:[Le&&(0,w.jsx)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-400 mb-2`,children:Le}),(0,w.jsxs)(`button`,{onClick:()=>st(M.id),className:`w-full py-4 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all flex items-center justify-center gap-3`,children:[(0,w.jsx)(x,{className:`w-5 h-5`}),` `,e(`dojo.take_exam`,`Take Certification Exam`)]}),(0,w.jsx)(`button`,{onClick:()=>!X.has(M?.id)&<(M),disabled:q===M?.id||X.has(M?.id),className:g(`w-full py-3 bg-shogun-card border font-bold text-xs uppercase tracking-[0.2em] rounded-xl transition-all flex items-center justify-center gap-3`,X.has(M?.id)?`border-green-500/30 text-green-400`:q===M?.id?`border-shogun-border text-shogun-gold animate-pulse`:`border-shogun-border text-shogun-subdued hover:text-shogun-text`),children:X.has(M?.id)?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(a,{className:`w-5 h-5`}),` Installed`]}):q===M?.id?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h,{className:`w-5 h-5 animate-spin`}),` Installing…`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(c,{className:`w-5 h-5`}),` Install to `,N?.agent_name||`Shogun`]})}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued text-center italic`,children:`Take the 30–50 question exam to get instantly certified by OpenClaw College.`})]})]})]}),Fe===`loading`&&(0,w.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-20 gap-6`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(l,{className:`w-12 h-12 animate-spin text-shogun-gold`}),(0,w.jsx)(u,{className:`absolute -top-1 -right-1 w-4 h-4 text-shogun-blue animate-pulse`})]}),(0,w.jsxs)(`p`,{className:`text-sm font-bold text-shogun-text`,children:[N?.agent_name||`Hero-San`,` is taking the exam...`]}),(0,w.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] text-shogun-subdued`,children:`Answering questions · Submitting to OpenClaw College`})]}),Fe===`result`&&K&&(0,w.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,w.jsxs)(`div`,{className:`p-6 border-b border-shogun-border flex items-center gap-6 flex-shrink-0`,children:[(0,w.jsx)(`div`,{className:g(`w-16 h-16 rounded-full flex items-center justify-center border-3`,K.passed||K.verificationStatus===`approved`?`bg-green-500/10 border-green-500 shadow-[0_0_30px_rgba(34,197,94,0.2)]`:`bg-orange-500/10 border-orange-500`),children:K.passed||K.verificationStatus===`approved`?(0,w.jsx)(b,{className:`w-8 h-8 text-green-400`}):(0,w.jsx)(i,{className:`w-8 h-8 text-orange-400`})}),(0,w.jsxs)(`div`,{className:`flex-1`,children:[(0,w.jsx)(`h3`,{className:g(`text-xl font-bold`,K.passed||K.verificationStatus===`approved`?`text-green-400`:`text-orange-400`),children:K.passed||K.verificationStatus===`approved`?e(`dojo.passed`,`Certified!`):e(`dojo.failed`,`Not Passed`)}),(0,w.jsxs)(`p`,{className:`text-shogun-subdued text-xs mt-1`,children:[K.agent_name||N?.agent_name||`Hero-San`,` scored `,(0,w.jsxs)(`span`,{className:`font-bold text-shogun-text`,children:[K.score,`%`]}),` (`,K.questions_correct??`?`,`/`,K.questions_total??`?`,` correct)`]}),(K.passed||K.verificationStatus===`approved`)&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,w.jsx)(u,{className:`w-3 h-3 text-shogun-gold animate-pulse`}),(0,w.jsxs)(`span`,{className:`text-[9px] text-shogun-gold font-bold uppercase tracking-widest`,children:[`OpenClaw Certified · `,M?.name]}),K.model_id&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued`,children:`·`}),(0,w.jsx)(o,{className:`w-3 h-3 text-shogun-subdued`}),(0,w.jsx)(`span`,{className:`text-[9px] text-shogun-subdued font-mono`,children:K.model_id})]})]})]}),(0,w.jsxs)(`div`,{className:`text-right`,children:[(0,w.jsxs)(`p`,{className:g(`text-3xl font-black font-mono`,K.passed||K.verificationStatus===`approved`?`text-green-400`:`text-orange-400`),children:[K.score,`%`]}),(0,w.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest`,children:[`Pass: `,K.pass_threshold??85,`%`]})]})]}),(0,w.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-4`,children:[(0,w.jsxs)(`h4`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-[0.2em] flex items-center gap-2 sticky top-0 bg-shogun-bg py-2 z-10`,children:[(0,w.jsx)(x,{className:`w-3.5 h-3.5 text-shogun-gold`}),` Exam Review — `,K.questions_total,` Questions`]}),(K.questions_review||[]).map((e,t)=>(0,w.jsxs)(`div`,{className:g(`p-4 rounded-xl border transition-all`,e.isCorrect?`bg-green-500/5 border-green-500/20`:`bg-red-500/5 border-red-500/20`),children:[(0,w.jsxs)(`p`,{className:`text-xs text-shogun-text font-medium leading-relaxed mb-3`,children:[(0,w.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued font-mono mr-2`,children:[t+1,`.`]}),e.text?.replace(/^\d+\.\s*/,``)]}),(0,w.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 pl-4`,children:(e.options||[]).map((t,n)=>{let r=t===e.correctAnswer,i=t===e.agentAnswer&&!e.isCorrect;return(0,w.jsxs)(`div`,{className:g(`text-xs px-3 py-2 rounded-lg border flex items-center gap-2`,r?`bg-green-500/10 border-green-500/40 text-green-400 font-bold`:i?`bg-red-500/10 border-red-500/40 text-red-400 font-bold`:`bg-[#050508] border-shogun-border/30 text-shogun-subdued/60`),children:[(0,w.jsxs)(`span`,{className:`font-mono text-[10px] opacity-60 w-4`,children:[String.fromCharCode(65+n),`.`]}),(0,w.jsx)(`span`,{className:`flex-1`,children:t}),r&&(0,w.jsx)(a,{className:`w-3.5 h-3.5 text-green-400 flex-shrink-0`}),i&&(0,w.jsx)(ue,{className:`w-3.5 h-3.5 text-red-400 flex-shrink-0`})]},n)})})]},e.id||t))]}),(0,w.jsxs)(`div`,{className:`p-4 border-t border-shogun-border flex items-center gap-3 flex-shrink-0`,children:[(0,w.jsx)(`button`,{onClick:ct,className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued text-xs font-bold uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Close`}),!(K.passed||K.verificationStatus===`approved`)&&(0,w.jsx)(`button`,{onClick:()=>st(M?.id),className:`flex-1 py-3 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all`,children:`Retry Exam`})]})]})]})}),we&&(0,w.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-300`,children:(0,w.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300`,children:[(0,w.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex justify-between items-center`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,w.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-shogun-gold/10 border border-shogun-gold/20 flex items-center justify-center`,children:(0,w.jsx)(x,{className:`w-5 h-5 text-shogun-gold`})}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`Sign Up for OpenClaw College`}),(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Agent Registration`})]})]}),(0,w.jsx)(`button`,{onClick:()=>P(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,w.jsx)(m,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,w.jsxs)(`div`,{className:`p-8 space-y-6`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Agent Display Name`}),(0,w.jsx)(`input`,{type:`text`,value:F,onChange:e=>Te(e.target.value),placeholder:`My Shogun`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-shogun-gold outline-none transition-all`,autoFocus:!0}),(0,w.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:`This name will appear in the global OpenClaw Agent Registry.`})]}),(0,w.jsx)(`div`,{className:`p-4 bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl`,children:(0,w.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,w.jsx)(i,{className:`w-4 h-4 text-shogun-blue flex-shrink-0 mt-0.5`}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-[10px] text-shogun-text font-bold mb-1`,children:`What happens when you register?`}),(0,w.jsxs)(`ul`,{className:`text-[9px] text-shogun-subdued space-y-1`,children:[(0,w.jsx)(`li`,{children:`• Your Shogun gets a unique ID on the OpenClaw College platform`}),(0,w.jsx)(`li`,{children:`• You can earn badges and track specialization progress`}),(0,w.jsx)(`li`,{children:`• You can submit skill feedback and suggest new skills`}),(0,w.jsx)(`li`,{children:`• Registration is free and requires no API key`})]})]})]})}),(0,w.jsxs)(`div`,{className:`flex gap-3`,children:[(0,w.jsx)(`button`,{onClick:()=>P(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,w.jsx)(`button`,{onClick:it,disabled:Ee||!F.trim(),className:`flex-1 py-3 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-shogun transition-all flex items-center justify-center gap-2 disabled:opacity-50`,children:Ee?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(h,{className:`w-4 h-4 animate-spin`}),` Registering...`]}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(d,{className:`w-4 h-4`}),` Register`]})})]})]})]})})]})}var ue=({className:e,...t})=>(0,w.jsxs)(`svg`,{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`,className:e,...t,children:[(0,w.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,w.jsx)(`path`,{d:`m15 9-6 6`}),(0,w.jsx)(`path`,{d:`m9 9 6 6`})]});export{E as Dojo}; \ No newline at end of file diff --git a/frontend/dist/assets/Gensui-DPPvYa_2.js b/frontend/dist/assets/Gensui-DPPvYa_2.js new file mode 100644 index 0000000..f94bd19 --- /dev/null +++ b/frontend/dist/assets/Gensui-DPPvYa_2.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./bot-BktkIwhq.js";import{t as n}from"./circle-check-DBu5bzEI.js";import{t as r}from"./circle-x-Dv8yz1YS.js";import{t as i}from"./clock-DQ9Dz1_z.js";import{t as a}from"./compass-DSx4BIld.js";import{t as o}from"./eye-jI9oiQpv.js";import{t as s}from"./key-t4c9dJnx.js";import{t as c}from"./link-2-CJnpoC8q.js";import{t as l}from"./refresh-cw-Dm6S5UAJ.js";import{t as u}from"./server-CVvUGKOH.js";import{t as d}from"./shield-alert-DzWPVhkC.js";import{t as f}from"./wifi-nqq7raTh.js";import{t as p}from"./zap-CQy--vuS.js";import{T as m,c as ee,d as h,g,i as _,j as v,p as y,r as b,t as x,u as S,y as C}from"./index-Dy1E248t.js";import{t as w}from"./axios-BGmZl9Qd.js";import{n as T,r as E,t as D}from"./infrastructureAuth-D0TsVUiV.js";var O=m(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),k=m(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),A=m(`pen-tool`,[[`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`,key:`nt11vn`}],[`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`,key:`15qc1e`}],[`path`,{d:`m2.3 2.3 7.286 7.286`,key:`1wuzzi`}],[`circle`,{cx:`11`,cy:`11`,r:`2`,key:`xmgehs`}]]),j=m(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),M=m(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),N=e(v(),1),P=x(),F=[{key:`allow_external_models`,label:`External Models`,icon:C},{key:`allow_local_models`,label:`Local Models`,icon:u},{key:`allow_tool_execution`,label:`Tool Execution`,icon:p},{key:`allow_mado`,label:`Mado Browser`,icon:o},{key:`allow_memory_write`,label:`Memory Write`,icon:A},{key:`allow_memory_read`,label:`Memory Read`,icon:o},{key:`allow_agent_flow`,label:`Agent Flow`,icon:y},{key:`allow_nexus`,label:`Nexus Comms`,icon:y},{key:`allow_samurai_delegation`,label:`Samurai Delegation`,icon:t},{key:`allow_scheduled_triggers`,label:`Scheduled Triggers`,icon:i},{key:`allow_autonomous_loops`,label:`Autonomous Loops`,icon:l},{key:`allow_external_web`,label:`External Web`,icon:C},{key:`allow_file_write`,label:`File Write`,icon:O},{key:`allow_external_api`,label:`External APIs`,icon:a}];function I(e){if(!e)return`—`;try{return new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return e}}function L(){let{t:e}=b(),[t,a]=(0,N.useState)(null),[o,p]=(0,N.useState)(!0),[m,v]=(0,N.useState)(`http://localhost:8787`),[y,x]=(0,N.useState)(``),[O,A]=(0,N.useState)(``),[L,R]=(0,N.useState)(`development`),[z,B]=(0,N.useState)(D),[V,H]=(0,N.useState)(!1),[U,W]=(0,N.useState)(null),[G,K]=(0,N.useState)(!1),[q,J]=(0,N.useState)(null),[Y,X]=(0,N.useState)(!1),[Z,Q]=(0,N.useState)(!1),$=(0,N.useCallback)(async()=>{try{let e=await w.get(`/api/v1/gensui/status`);a(e.data)}catch(e){console.error(`Gensui status error:`,e)}finally{p(!1)}},[]);(0,N.useEffect)(()=>{$();let e=setInterval($,15e3);return()=>clearInterval(e)},[$]);let te=async()=>{H(!0),W(null);try{let e=await w.post(`/api/v1/gensui/test`,{server_url:m},T(z));W(e.data)}catch(e){W({reachable:!1,error:e.response?.data?.detail||`Test failed`})}finally{H(!1)}},ne=async()=>{K(!0),J(null);try{let e=await w.post(`/api/v1/gensui/connect`,{server_url:m,enrollment_token:y||null,instance_name:O||null,environment:L},T(z));J({type:`success`,text:e.data.message||`Connected`}),await $()}catch(e){J({type:`error`,text:e.response?.data?.detail||`Connection failed`})}finally{K(!1)}},re=async()=>{X(!0);try{await w.post(`/api/v1/gensui/disconnect`,{},T(z)),Q(!1),await $()}catch(e){console.error(`Disconnect error:`,e)}finally{X(!1)}};if(o)return(0,P.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,P.jsx)(g,{className:`w-8 h-8 animate-spin text-indigo-400`})});let ie=t?.enabled&&t?.enrolled;return(0,P.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-5xl mx-auto pb-12`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`gensui.title`,`Gensui`),(0,P.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Fleet Command`})]}),(0,P.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`gensui.subtitle`,`Connect this Shogun instance to a Gensui server for centralized fleet management, posture enforcement, and security coordination.`)})]}),(0,P.jsx)(`button`,{onClick:$,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors self-start`,children:(0,P.jsx)(l,{className:_(`w-4 h-4`,o&&`animate-spin`)})})]}),(0,P.jsxs)(`div`,{className:`shogun-card`,children:[(0,P.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,P.jsx)(s,{className:`w-3 h-3`}),` Infrastructure Admin Token`]}),(0,P.jsx)(`input`,{type:`password`,autoComplete:`off`,value:z,onChange:e=>{let t=e.target.value;B(t),E(t)},placeholder:`Required by Shogun Server mode`,className:`mt-2 w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm font-mono focus:border-indigo-500 outline-none transition-all`}),(0,P.jsx)(`p`,{className:`mt-2 text-[10px] text-shogun-subdued`,children:`Kept only in this browser tab session. Desktop requests from localhost do not require it.`})]}),ie?(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsx)(`div`,{className:`shogun-card bg-emerald-500/5 border-emerald-500/20`,children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,P.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center`,children:(0,P.jsx)(f,{className:`w-7 h-7 text-emerald-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,P.jsx)(`p`,{className:`text-lg font-bold text-shogun-text`,children:t?.connected?e(`gensui.connected`,`Connected to Gensui`):e(`gensui.enrolled_offline`,`Enrolled — Connection Lost`)}),(0,P.jsx)(`span`,{className:_(`w-2.5 h-2.5 rounded-full animate-pulse`,t?.connected?`bg-emerald-500`:`bg-amber-500`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-shogun-subdued`,children:[(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(u,{className:`w-3 h-3`}),t?.server_url]}),(0,P.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,P.jsx)(j,{className:`w-3 h-3`}),t?.environment]})]})]})]}),(0,P.jsxs)(`button`,{onClick:()=>Q(!0),className:`px-4 py-2.5 bg-red-500/10 border border-red-500/20 text-red-400 font-bold text-xs uppercase tracking-widest rounded-xl hover:bg-red-500/20 transition-all flex items-center gap-2`,children:[(0,P.jsx)(M,{className:`w-3.5 h-3.5`}),` Disconnect`]})]})}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,P.jsxs)(`div`,{className:`shogun-card`,children:[(0,P.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2`,children:`Shogun ID`}),(0,P.jsx)(`code`,{className:`text-xs font-mono text-shogun-text break-all`,children:t?.shogun_id||`—`})]}),(0,P.jsxs)(`div`,{className:`shogun-card`,children:[(0,P.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2`,children:`Instance Name`}),(0,P.jsx)(`p`,{className:`text-sm font-bold text-shogun-text`,children:t?.instance_name||`—`})]}),(0,P.jsxs)(`div`,{className:`shogun-card`,children:[(0,P.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2`,children:`Last Sync`}),(0,P.jsxs)(`p`,{className:`text-sm text-shogun-text flex items-center gap-1.5`,children:[(0,P.jsx)(i,{className:`w-3 h-3 text-shogun-subdued`}),I(t?.last_sync_at||null)]})]})]}),t?.effective_posture&&(0,P.jsxs)(`div`,{className:`shogun-card`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mb-5`,children:[(0,P.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,P.jsx)(h,{className:`w-5 h-5 text-indigo-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-[10px] font-bold text-indigo-400 uppercase tracking-widest`,children:`Active Posture`}),(0,P.jsx)(`p`,{className:`text-lg font-bold text-shogun-text`,children:t.effective_posture.posture_name||`Default`})]})]}),t.effective_posture.rules&&(0,P.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2`,children:F.map(({key:e,label:i,icon:a})=>{let o=t.effective_posture?.rules?.[e]??!0;return(0,P.jsxs)(`div`,{className:_(`flex items-center gap-2 px-3 py-2 rounded-xl border text-xs font-semibold transition-all`,o?`bg-emerald-500/5 border-emerald-500/20 text-emerald-400`:`bg-red-500/5 border-red-500/20 text-red-400`),children:[(0,P.jsx)(a,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,P.jsx)(`span`,{className:`truncate`,children:i}),o?(0,P.jsx)(n,{className:`w-3 h-3 ml-auto flex-shrink-0`}):(0,P.jsx)(r,{className:`w-3 h-3 ml-auto flex-shrink-0`})]},e)})})]}),!t?.effective_posture&&(0,P.jsxs)(`div`,{className:`shogun-card border-dashed flex items-center gap-4 p-6`,children:[(0,P.jsx)(d,{className:`w-8 h-8 text-amber-400`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-sm font-bold text-shogun-text`,children:`Awaiting Posture Sync`}),(0,P.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`No posture received from Gensui yet. This may mean enrollment is pending approval, or the server hasn't assigned a policy.`})]})]})]}):(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`div`,{className:`shogun-card border-dashed border-2 border-indigo-500/20 p-8 flex flex-col md:flex-row items-center gap-8`,children:[(0,P.jsx)(`div`,{className:`w-24 h-24 rounded-3xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center flex-shrink-0`,children:(0,P.jsx)(S,{className:`w-12 h-12 text-indigo-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-xl font-bold text-shogun-text mb-2`,children:e(`gensui.not_connected`,`Not Connected to Gensui`)}),(0,P.jsx)(`p`,{className:`text-sm text-shogun-subdued leading-relaxed max-w-xl`,children:e(`gensui.connect_desc`,`Connect this Shogun instance to a Gensui Central Command server for fleet-wide security posture management, remote policy enforcement, telemetry monitoring, and emergency Harakiri capabilities.`)})]})]}),(0,P.jsxs)(`div`,{className:`shogun-card`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,P.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,P.jsx)(c,{className:`w-5 h-5 text-indigo-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:e(`gensui.connect_title`,`Connect to Gensui Server`)}),(0,P.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Fleet Enrollment`})]})]}),(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,P.jsx)(u,{className:`w-3 h-3`}),` Server URL *`]}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsx)(`input`,{value:m,onChange:e=>v(e.target.value),placeholder:`http://localhost:8787`,className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`}),(0,P.jsxs)(`button`,{onClick:te,disabled:V||!m.trim(),className:`px-5 py-3 bg-shogun-card border border-shogun-border text-shogun-text font-bold text-xs uppercase tracking-widest rounded-xl hover:border-indigo-500 transition-all disabled:opacity-40 flex items-center gap-2`,children:[V?(0,P.jsx)(g,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(k,{className:`w-4 h-4`}),e(`gensui.test`,`Test Connection`)]})]}),U&&(0,P.jsx)(`div`,{className:_(`flex items-center gap-2 text-xs px-3 py-2 rounded-lg`,U.reachable?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-red-500/10 text-red-400 border border-red-500/20`),children:U.reachable?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}),(0,P.jsxs)(`span`,{children:[`Gensui `,U.version,` reachable — ready to connect`]})]}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(r,{className:`w-4 h-4 flex-shrink-0`}),(0,P.jsx)(`span`,{children:U.error})]})})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,P.jsx)(s,{className:`w-3 h-3`}),` Enrollment Token`]}),(0,P.jsx)(`input`,{value:y,onChange:e=>x(e.target.value),placeholder:`Paste the enrollment token from Gensui admin panel...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm font-mono focus:border-indigo-500 outline-none transition-all`}),(0,P.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Generate this token in the Gensui Admin UI → Enrollment page. Leave empty to connect without auto-enrollment.`})]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,P.jsx)(j,{className:`w-3 h-3`}),` Instance Name`]}),(0,P.jsx)(`input`,{value:O,onChange:e=>A(e.target.value),placeholder:`My Shogun (auto-detected)`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,P.jsx)(C,{className:`w-3 h-3`}),` Environment`]}),(0,P.jsxs)(`select`,{value:L,onChange:e=>R(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all appearance-none`,children:[(0,P.jsx)(`option`,{value:`development`,children:`Development`}),(0,P.jsx)(`option`,{value:`staging`,children:`Staging`}),(0,P.jsx)(`option`,{value:`production`,children:`Production`})]})]})]}),q&&(0,P.jsxs)(`div`,{className:_(`flex items-center gap-2 text-xs px-3 py-2 rounded-lg`,q.type===`success`?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-red-500/10 text-red-400 border border-red-500/20`),children:[q.type===`success`?(0,P.jsx)(n,{className:`w-4 h-4 flex-shrink-0`}):(0,P.jsx)(r,{className:`w-4 h-4 flex-shrink-0`}),(0,P.jsx)(`span`,{children:q.text})]}),(0,P.jsxs)(`button`,{onClick:ne,disabled:G||!m.trim(),className:`w-full py-3.5 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.15em] rounded-xl shadow-lg transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[G?(0,P.jsx)(g,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(c,{className:`w-4 h-4`}),G?e(`gensui.connecting`,`Connecting...`):e(`gensui.connect_btn`,`Connect to Gensui`)]})]})]}),(0,P.jsxs)(`div`,{className:`shogun-card`,children:[(0,P.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-4`,children:`How It Works`}),(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[{icon:c,title:`Enroll`,desc:`Submit your enrollment token to register this Shogun instance with the Gensui server.`},{icon:h,title:`Receive Policy`,desc:`Gensui pushes security posture and permission rules that are enforced locally by the Torii.`},{icon:f,title:`Stay Connected`,desc:`Heartbeats, telemetry, and command polling run in the background to maintain the fleet link.`}].map(({icon:e,title:t,desc:n})=>(0,P.jsxs)(`div`,{className:`flex items-start gap-3 p-4 rounded-xl border border-shogun-border bg-shogun-card/50`,children:[(0,P.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center flex-shrink-0`,children:(0,P.jsx)(e,{className:`w-4 h-4 text-indigo-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:t}),(0,P.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-0.5 leading-relaxed`,children:n})]})]},t))})]})]}),Z&&(0,P.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,P.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/30 w-full max-w-sm rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,P.jsxs)(`div`,{className:`p-6 border-b border-red-500/20 bg-red-500/5 flex items-center gap-3`,children:[(0,P.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 border border-red-500/20 flex items-center justify-center`,children:(0,P.jsx)(M,{className:`w-5 h-5 text-red-400`})}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Disconnect from Gensui`}),(0,P.jsx)(`p`,{className:`text-[10px] text-red-400 uppercase tracking-widest font-bold`,children:`Fleet link will be severed`})]})]}),(0,P.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,P.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`This will stop all heartbeats, policy sync, and command polling. Your Shogun will operate independently without fleet oversight.`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-amber-400 bg-amber-500/10 border border-amber-500/20 px-3 py-2 rounded-lg`,children:[(0,P.jsx)(ee,{className:`w-4 h-4 flex-shrink-0`}),(0,P.jsx)(`span`,{children:`Any cached posture will be cleared. The Torii will revert to local-only policies.`})]}),(0,P.jsxs)(`div`,{className:`flex gap-3`,children:[(0,P.jsx)(`button`,{onClick:()=>Q(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,P.jsxs)(`button`,{onClick:re,disabled:Y,className:`flex-1 py-3 bg-red-600 hover:bg-red-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[Y?(0,P.jsx)(g,{className:`w-4 h-4 animate-spin`}):(0,P.jsx)(M,{className:`w-4 h-4`}),`Disconnect`]})]})]})]})})]})}export{L as Gensui}; \ No newline at end of file diff --git a/frontend/dist/assets/Gensui-Dt7bmEZH.js b/frontend/dist/assets/Gensui-Dt7bmEZH.js deleted file mode 100644 index e12bcc5..0000000 --- a/frontend/dist/assets/Gensui-Dt7bmEZH.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{t as i}from"./bot-DWzLMxmu.js";import{t as a}from"./circle-check-D9mntLsp.js";import{t as o}from"./circle-x-dN_LIrKM.js";import{t as s}from"./clock-B8iyCT3M.js";import{t as c}from"./compass-CbaQ9b1l.js";import{t as l}from"./eye-DuX8zHAU.js";import{t as u}from"./globe-CSe1LLSr.js";import{t as d}from"./key-B6HBhf9q.js";import{t as f}from"./link-2-DtQcNcp-.js";import{t as p}from"./loader-circle-yHzGFbgr.js";import{t as m}from"./network-RTAno7O_.js";import{t as h}from"./refresh-cw-CCrS0Omg.js";import{t as g}from"./server-CMY38Yt2.js";import{t as _}from"./shield-alert-ClN8pu2X.js";import{t as v}from"./shield-check-4WxAMs16.js";import{t as y}from"./shield-B_MY4jWU.js";import{t as b}from"./triangle-alert-BwzZbklP.js";import{t as x}from"./wifi-Df0GuaCb.js";import{t as S}from"./zap-BMpqZS6N.js";import{t as C}from"./utils-wrb6h48Y.js";import{r as w}from"./i18n-FxgwkwP0.js";import{t as T}from"./axios-BPyV2soB.js";var E=e(`file-code-corner`,[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]]),D=e(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),O=e(`pen-tool`,[[`path`,{d:`M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z`,key:`nt11vn`}],[`path`,{d:`m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18`,key:`15qc1e`}],[`path`,{d:`m2.3 2.3 7.286 7.286`,key:`1wuzzi`}],[`circle`,{cx:`11`,cy:`11`,r:`2`,key:`xmgehs`}]]),k=e(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),A=e(`unlink`,[[`path`,{d:`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,key:`yqzxt4`}],[`path`,{d:`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,key:`4qinb0`}],[`line`,{x1:`8`,x2:`8`,y1:`2`,y2:`5`,key:`1041cp`}],[`line`,{x1:`2`,x2:`5`,y1:`8`,y2:`8`,key:`14m1p5`}],[`line`,{x1:`16`,x2:`16`,y1:`19`,y2:`22`,key:`rzdirn`}],[`line`,{x1:`19`,x2:`22`,y1:`16`,y2:`16`,key:`ox905f`}]]),j=t(n(),1),M=r(),N=[{key:`allow_external_models`,label:`External Models`,icon:u},{key:`allow_local_models`,label:`Local Models`,icon:g},{key:`allow_tool_execution`,label:`Tool Execution`,icon:S},{key:`allow_mado`,label:`Mado Browser`,icon:l},{key:`allow_memory_write`,label:`Memory Write`,icon:O},{key:`allow_memory_read`,label:`Memory Read`,icon:l},{key:`allow_agent_flow`,label:`Agent Flow`,icon:m},{key:`allow_nexus`,label:`Nexus Comms`,icon:m},{key:`allow_samurai_delegation`,label:`Samurai Delegation`,icon:i},{key:`allow_scheduled_triggers`,label:`Scheduled Triggers`,icon:s},{key:`allow_autonomous_loops`,label:`Autonomous Loops`,icon:h},{key:`allow_external_web`,label:`External Web`,icon:u},{key:`allow_file_write`,label:`File Write`,icon:E},{key:`allow_external_api`,label:`External APIs`,icon:c}];function P(e){if(!e)return`—`;try{return new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}catch{return e}}function F(){let{t:e}=w(),[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(!0),[c,l]=(0,j.useState)(`http://localhost:8787`),[m,S]=(0,j.useState)(``),[E,O]=(0,j.useState)(``),[F,I]=(0,j.useState)(`development`),[L,R]=(0,j.useState)(!1),[z,B]=(0,j.useState)(null),[V,H]=(0,j.useState)(!1),[U,W]=(0,j.useState)(null),[G,K]=(0,j.useState)(!1),[q,J]=(0,j.useState)(!1),Y=(0,j.useCallback)(async()=>{try{n((await T.get(`/api/v1/gensui/status`)).data)}catch(e){console.error(`Gensui status error:`,e)}finally{i(!1)}},[]);(0,j.useEffect)(()=>{Y();let e=setInterval(Y,15e3);return()=>clearInterval(e)},[Y]);let X=async()=>{R(!0),B(null);try{B((await T.post(`/api/v1/gensui/test`,{server_url:c})).data)}catch(e){B({reachable:!1,error:e.response?.data?.detail||`Test failed`})}finally{R(!1)}},Z=async()=>{H(!0),W(null);try{W({type:`success`,text:(await T.post(`/api/v1/gensui/connect`,{server_url:c,enrollment_token:m||null,instance_name:E||null,environment:F})).data.message||`Connected`}),await Y()}catch(e){W({type:`error`,text:e.response?.data?.detail||`Connection failed`})}finally{H(!1)}},Q=async()=>{K(!0);try{await T.post(`/api/v1/gensui/disconnect`),J(!1),await Y()}catch(e){console.error(`Disconnect error:`,e)}finally{K(!1)}};if(r)return(0,M.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,M.jsx)(p,{className:`w-8 h-8 animate-spin text-indigo-400`})});let $=t?.enabled&&t?.enrolled;return(0,M.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-5xl mx-auto pb-12`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`gensui.title`,`Gensui`),(0,M.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Fleet Command`})]}),(0,M.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`gensui.subtitle`,`Connect this Shogun instance to a Gensui server for centralized fleet management, posture enforcement, and security coordination.`)})]}),(0,M.jsx)(`button`,{onClick:Y,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors self-start`,children:(0,M.jsx)(h,{className:C(`w-4 h-4`,r&&`animate-spin`)})})]}),$?(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsx)(`div`,{className:`shogun-card bg-emerald-500/5 border-emerald-500/20`,children:(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,M.jsx)(`div`,{className:`w-14 h-14 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center`,children:(0,M.jsx)(x,{className:`w-7 h-7 text-emerald-400`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,M.jsx)(`p`,{className:`text-lg font-bold text-shogun-text`,children:t?.connected?e(`gensui.connected`,`Connected to Gensui`):e(`gensui.enrolled_offline`,`Enrolled — Connection Lost`)}),(0,M.jsx)(`span`,{className:C(`w-2.5 h-2.5 rounded-full animate-pulse`,t?.connected?`bg-emerald-500`:`bg-amber-500`)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-shogun-subdued`,children:[(0,M.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,M.jsx)(g,{className:`w-3 h-3`}),t?.server_url]}),(0,M.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,M.jsx)(k,{className:`w-3 h-3`}),t?.environment]})]})]})]}),(0,M.jsxs)(`button`,{onClick:()=>J(!0),className:`px-4 py-2.5 bg-red-500/10 border border-red-500/20 text-red-400 font-bold text-xs uppercase tracking-widest rounded-xl hover:bg-red-500/20 transition-all flex items-center gap-2`,children:[(0,M.jsx)(A,{className:`w-3.5 h-3.5`}),` Disconnect`]})]})}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,M.jsxs)(`div`,{className:`shogun-card`,children:[(0,M.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2`,children:`Shogun ID`}),(0,M.jsx)(`code`,{className:`text-xs font-mono text-shogun-text break-all`,children:t?.shogun_id||`—`})]}),(0,M.jsxs)(`div`,{className:`shogun-card`,children:[(0,M.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2`,children:`Instance Name`}),(0,M.jsx)(`p`,{className:`text-sm font-bold text-shogun-text`,children:t?.instance_name||`—`})]}),(0,M.jsxs)(`div`,{className:`shogun-card`,children:[(0,M.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-2`,children:`Last Sync`}),(0,M.jsxs)(`p`,{className:`text-sm text-shogun-text flex items-center gap-1.5`,children:[(0,M.jsx)(s,{className:`w-3 h-3 text-shogun-subdued`}),P(t?.last_sync_at||null)]})]})]}),t?.effective_posture&&(0,M.jsxs)(`div`,{className:`shogun-card`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3 mb-5`,children:[(0,M.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,M.jsx)(v,{className:`w-5 h-5 text-indigo-400`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-[10px] font-bold text-indigo-400 uppercase tracking-widest`,children:`Active Posture`}),(0,M.jsx)(`p`,{className:`text-lg font-bold text-shogun-text`,children:t.effective_posture.posture_name||`Default`})]})]}),t.effective_posture.rules&&(0,M.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2`,children:N.map(({key:e,label:n,icon:r})=>{let i=t.effective_posture?.rules?.[e]??!0;return(0,M.jsxs)(`div`,{className:C(`flex items-center gap-2 px-3 py-2 rounded-xl border text-xs font-semibold transition-all`,i?`bg-emerald-500/5 border-emerald-500/20 text-emerald-400`:`bg-red-500/5 border-red-500/20 text-red-400`),children:[(0,M.jsx)(r,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,M.jsx)(`span`,{className:`truncate`,children:n}),i?(0,M.jsx)(a,{className:`w-3 h-3 ml-auto flex-shrink-0`}):(0,M.jsx)(o,{className:`w-3 h-3 ml-auto flex-shrink-0`})]},e)})})]}),!t?.effective_posture&&(0,M.jsxs)(`div`,{className:`shogun-card border-dashed flex items-center gap-4 p-6`,children:[(0,M.jsx)(_,{className:`w-8 h-8 text-amber-400`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-sm font-bold text-shogun-text`,children:`Awaiting Posture Sync`}),(0,M.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`No posture received from Gensui yet. This may mean enrollment is pending approval, or the server hasn't assigned a policy.`})]})]})]}):(0,M.jsxs)(`div`,{className:`space-y-6`,children:[(0,M.jsxs)(`div`,{className:`shogun-card border-dashed border-2 border-indigo-500/20 p-8 flex flex-col md:flex-row items-center gap-8`,children:[(0,M.jsx)(`div`,{className:`w-24 h-24 rounded-3xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center flex-shrink-0`,children:(0,M.jsx)(y,{className:`w-12 h-12 text-indigo-400`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-xl font-bold text-shogun-text mb-2`,children:e(`gensui.not_connected`,`Not Connected to Gensui`)}),(0,M.jsx)(`p`,{className:`text-sm text-shogun-subdued leading-relaxed max-w-xl`,children:e(`gensui.connect_desc`,`Connect this Shogun instance to a Gensui Central Command server for fleet-wide security posture management, remote policy enforcement, telemetry monitoring, and emergency Harakiri capabilities.`)})]})]}),(0,M.jsxs)(`div`,{className:`shogun-card`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,M.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,M.jsx)(f,{className:`w-5 h-5 text-indigo-400`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:e(`gensui.connect_title`,`Connect to Gensui Server`)}),(0,M.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`Fleet Enrollment`})]})]}),(0,M.jsxs)(`div`,{className:`space-y-5`,children:[(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,M.jsx)(g,{className:`w-3 h-3`}),` Server URL *`]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`http://localhost:8787`,className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`}),(0,M.jsxs)(`button`,{onClick:X,disabled:L||!c.trim(),className:`px-5 py-3 bg-shogun-card border border-shogun-border text-shogun-text font-bold text-xs uppercase tracking-widest rounded-xl hover:border-indigo-500 transition-all disabled:opacity-40 flex items-center gap-2`,children:[L?(0,M.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,M.jsx)(D,{className:`w-4 h-4`}),e(`gensui.test`,`Test Connection`)]})]}),z&&(0,M.jsx)(`div`,{className:C(`flex items-center gap-2 text-xs px-3 py-2 rounded-lg`,z.reachable?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-red-500/10 text-red-400 border border-red-500/20`),children:z.reachable?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(a,{className:`w-4 h-4 flex-shrink-0`}),(0,M.jsxs)(`span`,{children:[`Gensui `,z.version,` reachable — ready to connect`]})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(o,{className:`w-4 h-4 flex-shrink-0`}),(0,M.jsx)(`span`,{children:z.error})]})})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,M.jsx)(d,{className:`w-3 h-3`}),` Enrollment Token`]}),(0,M.jsx)(`input`,{value:m,onChange:e=>S(e.target.value),placeholder:`Paste the enrollment token from Gensui admin panel...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm font-mono focus:border-indigo-500 outline-none transition-all`}),(0,M.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Generate this token in the Gensui Admin UI → Enrollment page. Leave empty to connect without auto-enrollment.`})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,M.jsx)(k,{className:`w-3 h-3`}),` Instance Name`]}),(0,M.jsx)(`input`,{value:E,onChange:e=>O(e.target.value),placeholder:`My Shogun (auto-detected)`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`})]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,M.jsx)(u,{className:`w-3 h-3`}),` Environment`]}),(0,M.jsxs)(`select`,{value:F,onChange:e=>I(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all appearance-none`,children:[(0,M.jsx)(`option`,{value:`development`,children:`Development`}),(0,M.jsx)(`option`,{value:`staging`,children:`Staging`}),(0,M.jsx)(`option`,{value:`production`,children:`Production`})]})]})]}),U&&(0,M.jsxs)(`div`,{className:C(`flex items-center gap-2 text-xs px-3 py-2 rounded-lg`,U.type===`success`?`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`:`bg-red-500/10 text-red-400 border border-red-500/20`),children:[U.type===`success`?(0,M.jsx)(a,{className:`w-4 h-4 flex-shrink-0`}):(0,M.jsx)(o,{className:`w-4 h-4 flex-shrink-0`}),(0,M.jsx)(`span`,{children:U.text})]}),(0,M.jsxs)(`button`,{onClick:Z,disabled:V||!c.trim(),className:`w-full py-3.5 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.15em] rounded-xl shadow-lg transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[V?(0,M.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,M.jsx)(f,{className:`w-4 h-4`}),V?e(`gensui.connecting`,`Connecting...`):e(`gensui.connect_btn`,`Connect to Gensui`)]})]})]}),(0,M.jsxs)(`div`,{className:`shogun-card`,children:[(0,M.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest mb-4`,children:`How It Works`}),(0,M.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[{icon:f,title:`Enroll`,desc:`Submit your enrollment token to register this Shogun instance with the Gensui server.`},{icon:v,title:`Receive Policy`,desc:`Gensui pushes security posture and permission rules that are enforced locally by the Torii.`},{icon:x,title:`Stay Connected`,desc:`Heartbeats, telemetry, and command polling run in the background to maintain the fleet link.`}].map(({icon:e,title:t,desc:n})=>(0,M.jsxs)(`div`,{className:`flex items-start gap-3 p-4 rounded-xl border border-shogun-border bg-shogun-card/50`,children:[(0,M.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center flex-shrink-0`,children:(0,M.jsx)(e,{className:`w-4 h-4 text-indigo-400`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:t}),(0,M.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-0.5 leading-relaxed`,children:n})]})]},t))})]})]}),q&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,M.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/30 w-full max-w-sm rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,M.jsxs)(`div`,{className:`p-6 border-b border-red-500/20 bg-red-500/5 flex items-center gap-3`,children:[(0,M.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 border border-red-500/20 flex items-center justify-center`,children:(0,M.jsx)(A,{className:`w-5 h-5 text-red-400`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Disconnect from Gensui`}),(0,M.jsx)(`p`,{className:`text-[10px] text-red-400 uppercase tracking-widest font-bold`,children:`Fleet link will be severed`})]})]}),(0,M.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,M.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`This will stop all heartbeats, policy sync, and command polling. Your Shogun will operate independently without fleet oversight.`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-amber-400 bg-amber-500/10 border border-amber-500/20 px-3 py-2 rounded-lg`,children:[(0,M.jsx)(b,{className:`w-4 h-4 flex-shrink-0`}),(0,M.jsx)(`span`,{children:`Any cached posture will be cleared. The Torii will revert to local-only policies.`})]}),(0,M.jsxs)(`div`,{className:`flex gap-3`,children:[(0,M.jsx)(`button`,{onClick:()=>J(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,M.jsxs)(`button`,{onClick:Q,disabled:G,className:`flex-1 py-3 bg-red-600 hover:bg-red-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[G?(0,M.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,M.jsx)(A,{className:`w-4 h-4`}),`Disconnect`]})]})]})]})})]})}export{F as Gensui}; \ No newline at end of file diff --git a/frontend/dist/assets/Guide-DyCPa0i_.js b/frontend/dist/assets/Guide-DyCPa0i_.js new file mode 100644 index 0000000..fba08ae --- /dev/null +++ b/frontend/dist/assets/Guide-DyCPa0i_.js @@ -0,0 +1,32 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./app-window-BFcF7ht7.js";import{n,t as r}from"./flame-ufgLzmP6.js";import{t as i}from"./brain-circuit-BYgtGbs2.js";import{t as a}from"./camera-BK7z_aNh.js";import{t as o}from"./circle-alert-043xB2li.js";import{t as s}from"./circle-check-DBu5bzEI.js";import{t as ee}from"./clock-DQ9Dz1_z.js";import{t as c}from"./compass-DSx4BIld.js";import{t as l}from"./cpu-BM3hm7mB.js";import{t as u}from"./crosshair-B6y1p9rN.js";import{t as d}from"./external-link-pPtmvETu.js";import{t as te}from"./eye-jI9oiQpv.js";import{t as ne}from"./file-key-BpopqW-g.js";import{t as f}from"./file-spreadsheet-ikcYZmJa.js";import{t as p}from"./file-text-CrD-Um8r.js";import{t as m}from"./folder-open-CZ39dYm6.js";import{t as re}from"./funnel-BkXG8UUQ.js";import{t as h}from"./git-branch-qj-Uwi0O.js";import{t as ie}from"./git-merge-1UmnhoFd.js";import{t as g}from"./key-t4c9dJnx.js";import{t as _}from"./layers-PPVhckft.js";import{t as v}from"./link-2-CJnpoC8q.js";import{t as y}from"./lock-CGEyUK_n.js";import{t as b}from"./mail-Ca9FQxut.js";import{t as x}from"./monitor-DrwnCrGM.js";import{t as S}from"./package-BxV01e8e.js";import{n as C,t as ae}from"./route-B34TZTak.js";import{t as oe}from"./power-Bl6a5geq.js";import{t as w}from"./refresh-cw-Dm6S5UAJ.js";import{t as T}from"./search-DuRUeriq.js";import{t as E}from"./shield-alert-DzWPVhkC.js";import{t as se}from"./sliders-horizontal-C0TTejMz.js";import{t as D}from"./sparkles-DyLIKWW0.js";import{t as O}from"./star-DhgMUt17.js";import{t as k}from"./terminal-B0TmVXNb.js";import{t as ce}from"./trash-2-DqRUHXwV.js";import{t as A}from"./workflow-JDh8EYE0.js";import{t as j}from"./zap-CQy--vuS.js";import{C as le,S as ue,T as M,b as N,d as P,i as F,j as I,k as L,l as de,m as R,o as z,p as B,r as fe,t as V,u as H,v as U,w as W,x as G,y as K}from"./index-Dy1E248t.js";var pe=M(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),me=M(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),q=M(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),he=M(`printer`,[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]),J=e(I(),1),Y=V(),X=Object.assign({"../i18n/guide/da.json":()=>L(()=>import(`./da-lkfdJjo8.js`),[]),"../i18n/guide/de.json":()=>L(()=>import(`./de-tDz3tHGn.js`),[]),"../i18n/guide/en.json":()=>L(()=>import(`./en-uRYLjdQa.js`),[]),"../i18n/guide/es.json":()=>L(()=>import(`./es-DxY1-u2W.js`),[]),"../i18n/guide/fr.json":()=>L(()=>import(`./fr-DCniX-k5.js`),[]),"../i18n/guide/hi.json":()=>L(()=>import(`./hi-OutIXnUt.js`),[]),"../i18n/guide/it.json":()=>L(()=>import(`./it-BHHYOmqd.js`),[]),"../i18n/guide/ja.json":()=>L(()=>import(`./ja-CD21cCYJ.js`),[]),"../i18n/guide/ko.json":()=>L(()=>import(`./ko-wilZu6az.js`),[]),"../i18n/guide/no.json":()=>L(()=>import(`./no-DAO5Nv-B.js`),[]),"../i18n/guide/pl.json":()=>L(()=>import(`./pl-DMSrmwFl.js`),[]),"../i18n/guide/pt.json":()=>L(()=>import(`./pt-DrnB5IL_.js`),[]),"../i18n/guide/sv.json":()=>L(()=>import(`./sv-BYtggFof.js`),[]),"../i18n/guide/uk.json":()=>L(()=>import(`./uk-C15TWbxK.js`),[]),"../i18n/guide/zh.json":()=>L(()=>import(`./zh-CAiuUj9O.js`),[])}),Z={},Q=new WeakMap;async function ge(e){if(Z[e])return Z[e];let t=X[`../i18n/guide/${e}.json`];if(!t)return{};try{let n=(await t()).default;return Z[e]=n,n}catch(t){return console.error(`[guide-i18n] Failed to load the ${e} Guide catalog`,t),{}}}function _e(e,t){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;){if(!r.parentElement?.closest(`code, pre, script, style, svg`)){let e=r.nodeValue??``,n=Q.get(r),i=n??e,a=i.trim();if(a&&(n!==void 0||Object.prototype.hasOwnProperty.call(t,a))){n===void 0&&Q.set(r,i);let e=i.match(/^\s*/)?.[0]??``,o=i.match(/\s*$/)?.[0]??``;r.nodeValue=`${e}${t[a]??a}${o}`}}r=n.nextNode()}}function $(){let{t:e,language:M}=fe(),[I,L]=(0,J.useState)(`onboarding`),[V,X]=(0,J.useState)(`ref-tenshu`),Z=(0,J.useRef)(null),Q=(0,J.useRef)(null),$=[{id:`ref-tenshu`,label:`Tenshu`,icon:q,color:`text-shogun-blue`},{id:`ref-server`,label:`Server Mode`,icon:S,color:`text-emerald-400`},{id:`ref-comms`,label:`Comms`,icon:R,color:`text-shogun-blue`},{id:`ref-profile`,label:`Shogun Profile`,icon:l,color:`text-shogun-gold`},{id:`ref-flowstack`,label:`Flow Stacking`,icon:_,color:`text-violet-400`},{id:`ref-samurai`,label:`Samurai Network`,icon:z,color:`text-shogun-gold`},{id:`ref-katana`,label:`Katana`,icon:de,color:`text-shogun-blue`},{id:`ref-telegram`,label:`Telegram Setup`,icon:R,color:`text-sky-400`},{id:`ref-teams`,label:`Teams Setup`,icon:z,color:`text-indigo-400`},{id:`ref-archives`,label:`Archives`,icon:G,color:`text-shogun-gold`},{id:`ref-dojo`,label:`Dojo`,icon:r,color:`text-shogun-gold`},{id:`ref-kaizen`,label:`Kaizen`,icon:P,color:`text-shogun-gold`},{id:`ref-bushido`,label:`Bushido`,icon:w,color:`text-shogun-blue`},{id:`ref-mado`,label:`Mado`,icon:t,color:`text-cyan-400`},{id:`ref-ronin`,label:`Ronin`,icon:u,color:`text-orange-400`},{id:`ref-office`,label:`Office`,icon:f,color:`text-green-400`},{id:`ref-workspace`,label:`Workspace`,icon:m,color:`text-amber-400`},{id:`ref-torii`,label:`Torii`,icon:y,color:`text-red-400`},{id:`ref-toolgate`,label:`ToolGate`,icon:H,color:`text-orange-400`},{id:`ref-nexus`,label:`Nexus`,icon:K,color:`text-indigo-400`},{id:`ref-nexus-gateway`,label:`Nexus Gateway`,icon:v,color:`text-indigo-400`},{id:`ref-gensui`,label:`Gensui`,icon:E,color:`text-indigo-400`},{id:`ref-logs`,label:`Logs`,icon:k,color:`text-shogun-subdued`},{id:`ref-maintenance`,label:`Maintenance`,icon:U,color:`text-shogun-gold`},{id:`ref-visual-intake`,label:`Visual Intake`,icon:te,color:`text-cyan-400`},{id:`ref-ide-mode`,label:`IDE Mode`,icon:x,color:`text-emerald-400`},{id:`ref-model-router`,label:`Model Router`,icon:ae,color:`text-blue-400`},{id:`ref-active-skills`,label:`Active Skills`,icon:D,color:`text-amber-400`},{id:`ref-skillopt`,label:`SkillOpt`,icon:i,color:`text-fuchsia-400`}],ve=(0,J.useCallback)(e=>{let t=document.getElementById(e);t&&(t.scrollIntoView({behavior:`smooth`,block:`start`}),X(e))},[]),ye=(0,J.useCallback)(()=>{let e=Q.current;if(!e)return;let t=window.open(``,`_blank`,`width=1100,height=800`);if(!t){window.alert(`Please allow pop-ups to print the Grand Reference.`);return}t.opener=null;let n=Array.from(document.querySelectorAll(`link[rel="stylesheet"], style`)).map(e=>e instanceof HTMLLinkElement?``:e.outerHTML).join(` +`),r=e.querySelector(`h3`)?.textContent?.trim()||`The Grand Reference`;t.document.open(),t.document.write(` + + + + + ${r} + ${n} + + + +
${e.innerHTML}
+ + `),t.document.close();let i=()=>{t.focus(),t.print()};t.document.readyState===`complete`?window.setTimeout(i,250):t.addEventListener(`load`,()=>window.setTimeout(i,250),{once:!0})},[M]);return(0,J.useEffect)(()=>{if(I!==`reference`)return;let e=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&X(t.target.id)},{rootMargin:`-80px 0px -60% 0px`,threshold:.1}),t=setTimeout(()=>{$.forEach(({id:t})=>{let n=document.getElementById(t);n&&e.observe(n)})},100);return()=>{clearTimeout(t),e.disconnect()}},[I]),(0,J.useEffect)(()=>{let e=!1;return ge(M).then(t=>{!e&&Z.current&&_e(Z.current,t)}),()=>{e=!0}},[I,M]),(0,Y.jsxs)(`div`,{ref:Z,className:`max-w-7xl mx-auto space-y-8 animate-in fade-in duration-500 pb-20`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-6`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h2`,{className:`text-4xl font-bold shogun-title flex items-center gap-4`,children:[e(`guide.title`,`Framework Guide`),(0,Y.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-1 rounded border border-shogun-border tracking-[0.3em] uppercase`,children:e(`guide.badge`,`Knowledge Base`)})]}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`guide.subtitle`,`Master the Shogun architecture, operations, and system maintenance.`)})]})}),(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 p-1 bg-shogun-card border border-shogun-border rounded-xl w-fit`,children:[{id:`onboarding`,label:e(`guide.tab_onboarding`,`Onboarding`),icon:c},{id:`reference`,label:e(`guide.tab_reference`,`Reference Manual`),icon:le},{id:`architecture`,label:e(`guide.tab_architecture`,`Architecture`),icon:l},{id:`safety`,label:e(`guide.tab_safety`,`Safety Protocols`),icon:P}].map(e=>(0,Y.jsxs)(`button`,{onClick:()=>L(e.id),className:F(`flex items-center gap-2 px-6 py-2.5 rounded-lg text-xs font-bold uppercase tracking-widest transition-all`,I===e.id?`bg-shogun-blue text-white shadow-lg`:`text-shogun-subdued hover:text-shogun-text hover:bg-shogun-bg`),children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4`}),e.label]},e.id))}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-8`,children:[I===`onboarding`&&(0,Y.jsxs)(`div`,{className:`space-y-8 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsxs)(`section`,{className:`shogun-card border-l-4 border-shogun-blue`,children:[(0,Y.jsxs)(`h3`,{className:`text-xl font-bold text-shogun-text mb-4 flex items-center gap-3`,children:[(0,Y.jsx)(j,{className:`w-6 h-6 text-shogun-blue`}),`Your Journey Begins`]}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed mb-6`,children:`Welcome to Shogun. You are not just running a tool; you are commanding a distributed cognitive lattice. This system is designed for high-stakes automation, deep research, and secure agent-to-agent collaboration. This guide will walk you through everything you need to go from zero to fully operational.`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,Y.jsxs)(`div`,{className:`p-4 bg-shogun-bg border border-shogun-border rounded-xl`,children:[(0,Y.jsx)(`div`,{className:`text-shogun-blue font-bold text-lg mb-1`,children:`1. Connect Brains`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Head to `,(0,Y.jsx)(`strong`,{children:`Katana`}),` to add your API keys or local models. This is where your AI's "intelligence" comes from.`]})]}),(0,Y.jsxs)(`div`,{className:`p-4 bg-shogun-bg border border-shogun-border rounded-xl`,children:[(0,Y.jsx)(`div`,{className:`text-shogun-gold font-bold text-lg mb-1`,children:`2. Train Skills`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Visit the `,(0,Y.jsx)(`strong`,{children:`Dojo`}),` to browse 4,000+ specialized skills. Certify your agents for specific task categories.`]})]}),(0,Y.jsxs)(`div`,{className:`p-4 bg-shogun-bg border border-shogun-border rounded-xl`,children:[(0,Y.jsx)(`div`,{className:`text-green-500 font-bold text-lg mb-1`,children:`3. Start Chatting`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Open `,(0,Y.jsx)(`strong`,{children:`Tenshu`}),` or the global chat. Your Shogun is now ready to assist, research, and execute.`]})]})]}),(0,Y.jsxs)(`div`,{id:`ref-telegram`,className:`shogun-card space-y-6 scroll-mt-6 border-sky-400/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2 text-base`,children:[(0,Y.jsx)(R,{className:`w-5 h-5 text-sky-400`}),` Telegram — Complete Beginner Setup`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Use Telegram on your phone or computer to talk directly to your Shogun.`})]}),(0,Y.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-sky-400 bg-sky-400/10 border border-sky-400/20 px-2.5 py-1 rounded-full w-fit`,children:`About 10–15 minutes`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg border border-sky-400/20 bg-sky-400/5`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-bold`,children:`The easiest supported choice`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[`Choose `,(0,Y.jsx)(`strong`,{children:`Polling`}),`. It works while Shogun is running and does not require a public website or router changes. Although the screen also shows a Webhook option, the listener in this release operates by polling. Use Webhook only if an administrator has supplied a separate compatible webhook receiver.`]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text mb-3`,children:`Before you begin`}),(0,Y.jsx)(`div`,{className:`grid sm:grid-cols-3 gap-3`,children:[[`Telegram account`,`Install Telegram and sign in on your phone or computer.`],[`Running Shogun`,`Shogun must remain open and have internet access to receive messages.`],[`Private test first`,`Connect a private one-to-one chat before trying a Telegram group.`]].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed mt-1`,children:t})]},e))})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part A — Create your Telegram bot`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Open the official `,(0,Y.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-sky-400 hover:underline font-bold`,children:`@BotFather`}),` chat. Check the username carefully: it must be exactly `,(0,Y.jsx)(`code`,{children:`@BotFather`}),` and should show Telegram's verification mark.`]}),(0,Y.jsxs)(`li`,{children:[`Press `,(0,Y.jsx)(`strong`,{children:`Start`}),`, or type `,(0,Y.jsx)(`code`,{children:`/start`}),`. Then type `,(0,Y.jsx)(`code`,{children:`/newbot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`BotFather asks for a display name. This is the friendly name people see, for example `,(0,Y.jsx)(`code`,{children:`My Shogun`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Choose a unique username. Telegram requires 5–32 Latin letters, numbers, or underscores, and the username must end in `,(0,Y.jsx)(`code`,{children:`bot`}),`, for example `,(0,Y.jsx)(`code`,{children:`northwind_shogun_bot`}),`.`]}),(0,Y.jsx)(`li`,{children:`BotFather returns a long token containing numbers, a colon, and letters. Copy the entire token. Treat it exactly like a password: anyone who has it can control the bot. Never paste it into email, screenshots, tickets, or chat messages.`})]}),(0,Y.jsxs)(`a`,{href:`https://core.telegram.org/bots/features#botfather`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-sky-400 hover:underline`,children:[(0,Y.jsx)(d,{className:`w-3 h-3`}),` Official Telegram BotFather instructions`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part B — Connect the bot to Shogun`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`In Shogun, open `,(0,Y.jsx)(`strong`,{children:`The Katana → Telegram`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Paste the token into `,(0,Y.jsx)(`strong`,{children:`Bot Token`}),`. Leave the eye icon closed unless you need to check what you pasted.`]}),(0,Y.jsxs)(`li`,{children:[`Select `,(0,Y.jsx)(`strong`,{children:`Polling`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`For this first connection, leave `,(0,Y.jsx)(`strong`,{children:`Allowed Chat IDs`}),` empty. This temporary step lets Shogun discover your ID. Do not leave it empty permanently, because an empty list allows every Telegram chat that can reach the bot.`]}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Connect Bot`}),`. Success is shown as a green `,(0,Y.jsx)(`strong`,{children:`Connected`}),` badge and the bot's username.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part C — Find and save your Chat ID safely`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Return to Telegram and open the new bot using the link from BotFather or by searching for its username.`}),(0,Y.jsxs)(`li`,{children:[`Press `,(0,Y.jsx)(`strong`,{children:`Start`}),` and send a simple message such as `,(0,Y.jsx)(`code`,{children:`Hello`}),`. A bot cannot begin a private conversation until you contact it first.`]}),(0,Y.jsxs)(`li`,{children:[`Return to `,(0,Y.jsx)(`strong`,{children:`Katana → Telegram`}),` and click `,(0,Y.jsx)(`strong`,{children:`Auto-detect Chat ID`}),`. Your personal Chat ID should appear in both the test field and the Allowed Chat IDs field.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Important:`}),` auto-detect fills the form but does not save the whitelist by itself. Paste the same bot token into `,(0,Y.jsx)(`strong`,{children:`Bot Token`}),` again, confirm Polling is selected, and click `,(0,Y.jsx)(`strong`,{children:`Update Connection`}),`. This second save makes the whitelist permanent.`]}),(0,Y.jsxs)(`li`,{children:[`Enter the detected ID under `,(0,Y.jsx)(`strong`,{children:`Test Connection`}),` and click `,(0,Y.jsx)(`strong`,{children:`Send Test`}),`. Telegram should receive “Shogun Test Message.”`]}),(0,Y.jsxs)(`li`,{children:[`Send `,(0,Y.jsx)(`code`,{children:`Hello Shogun`}),` to the bot. A normal AI reply confirms that both incoming and outgoing communication work.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-shogun-bg border border-shogun-border space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-shogun-text`,children:`Optional: use the bot in a group`}),(0,Y.jsxs)(`ol`,{className:`text-[11px] text-shogun-subdued space-y-2 ml-4 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Add the bot to the Telegram group.`}),(0,Y.jsxs)(`li`,{children:[`Send a command addressed to it, such as `,(0,Y.jsx)(`code`,{children:`/start@your_bot_name`}),`, or reply directly to one of its messages.`]}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Auto-detect Chat ID`}),` again. Group IDs are normally negative numbers.`]}),(0,Y.jsxs)(`li`,{children:[`Add that negative ID to Allowed Chat IDs, paste the token again, and click `,(0,Y.jsx)(`strong`,{children:`Update Connection`}),`.`]})]}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Telegram Privacy Mode is enabled for group bots by default. The bot normally sees commands, direct mentions, and replies—not every group message. This is the safer default. If an administrator disables Privacy Mode in BotFather, remove and re-add the bot to the group afterward.`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-shogun-bg border border-shogun-border space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-shogun-text`,children:`Security checklist`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Keep at least one Allowed Chat ID saved.`}),(0,Y.jsx)(`li`,{children:`Use a separate bot for testing and production.`}),(0,Y.jsx)(`li`,{children:`Only run one Shogun instance with a given token; two pollers can compete for the same messages.`}),(0,Y.jsx)(`li`,{children:`If the token is exposed, regenerate or revoke it in BotFather, then reconnect Shogun with the replacement.`}),(0,Y.jsx)(`li`,{children:`Disconnect the bot in Katana when remote access is no longer needed.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Telegram troubleshooting`}),(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left bg-shogun-bg text-shogun-subdued`,children:[(0,Y.jsx)(`th`,{className:`p-3`,children:`What you see`}),(0,Y.jsx)(`th`,{className:`p-3`,children:`What to do`})]})}),(0,Y.jsxs)(`tbody`,{className:`divide-y divide-shogun-border text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Invalid token or HTTP 401`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Copy the complete token from BotFather again. A revoked token automatically disconnects the listener.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Auto-detect finds nothing`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Send a fresh message directly to the bot, wait a few seconds, then retry. Confirm no other application is consuming updates for the same token.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Test works, but your messages are ignored`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Check that your exact Chat ID is in Allowed Chat IDs and that you completed the second Update Connection save.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Group messages are ignored`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Mention the bot, use a command, or reply to it. Check the negative group ID and Telegram Privacy Mode.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Replies stop when the computer sleeps`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Keep Shogun running on an awake, internet-connected computer or server. Polling is performed by Shogun itself.`})]})]})]})})]})]})]}),(0,Y.jsx)(`section`,{className:`shogun-card bg-red-500/[0.04] border-red-500/20 border-l-4 border-l-red-500`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center gap-4`,children:[(0,Y.jsx)(`div`,{className:`p-3 rounded-xl bg-red-500/10 border border-red-500/20 shrink-0 w-fit`,children:(0,Y.jsx)(C,{className:`w-8 h-8 text-red-500`})}),(0,Y.jsxs)(`div`,{className:`space-y-2 flex-1`,children:[(0,Y.jsxs)(`h3`,{className:`text-lg font-bold text-shogun-text flex items-center gap-2`,children:[`Complete Video Guide`,(0,Y.jsx)(`span`,{className:`text-[9px] font-bold text-red-400 bg-red-500/10 px-2 py-0.5 rounded-full uppercase tracking-widest`,children:`YouTube`})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Prefer video? Watch the full Shogun walkthrough series — from installation to advanced workflows, agent configuration, and security setup.`}),(0,Y.jsxs)(`a`,{href:`https://www.youtube.com/@ShogunAIAgents`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 px-4 py-2 bg-red-500 hover:bg-red-600 text-white text-xs font-bold rounded-lg transition-all duration-200 shadow-lg hover:shadow-red-500/25 mt-1`,children:[(0,Y.jsx)(C,{className:`w-3.5 h-3.5`}),`Watch on YouTube`,(0,Y.jsx)(d,{className:`w-3 h-3 opacity-60`})]})]})]})}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(s,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Prerequisites`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`What you need before you begin.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-shogun-blue`}),` At Least One API Key`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`You need an API key from at least one AI provider — OpenAI, Anthropic, Google Gemini, or Perplexity. These are obtained from the provider's developer portal. Without a key, the Shogun cannot think.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(U,{className:`w-4 h-4 text-shogun-blue`}),` Or a Local Model (Optional)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`If you prefer to run AI entirely on your own machine (no internet required), install `,(0,Y.jsx)(`strong`,{children:`Ollama`}),` and pull a model like `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`llama3`}),`. Shogun will auto-detect it on the Katana → Local Models tab.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-4 h-4 text-shogun-blue`}),` A Modern Browser`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Shogun's UI is designed for modern browsers — Chrome, Edge, Firefox, or Safari. Ensure JavaScript is enabled. The interface is fully responsive and works on tablets and phones as well.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-shogun-blue`}),` Shogun Backend Running`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The backend server must be running on `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`localhost:8000`}),`. If you installed via Docker, it starts automatically. Otherwise, run `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`python -m shogun`}),` from the project root.`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(c,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`First Launch — Step by Step`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Follow these steps in order for the smoothest setup experience.`})]})]}),(0,Y.jsx)(`div`,{className:`space-y-4`,children:[{step:1,title:`Add Your First AI Provider`,color:`text-shogun-blue`,icon:g,desc:`Navigate to Katana → Cloud Providers. Click "Add Provider." Choose the provider type (e.g., OpenAI), paste your API key, and save. Within seconds, all available models from that provider will appear as options throughout Shogun.`},{step:2,title:`Choose a Routing Profile`,color:`text-shogun-blue`,icon:l,desc:`Go to Katana → Model Routing. Choose a routing profile, or use Custom to select an ordered primary and fallback model list from your connected providers.`},{step:3,title:`Review Your Security Posture`,color:`text-red-400`,icon:y,desc:`Visit Torii (Security). The default posture is TACTICAL — a balanced setting that gives the AI enough freedom for productive work while keeping dangerous operations locked down. Read the tier descriptions and choose the level that matches your risk comfort.`},{step:4,title:`Write Your Constitution (Optional)`,color:`text-shogun-gold`,icon:p,desc:`Open Kaizen → Constitution tab. This is the AI's "rule book." The default constitution covers essential safety rules. You can add your own rules here — for example, "Never send emails without my approval" or "Always respond in formal English." Click "Publish Edicts" when done.`},{step:5,title:`Deploy Your First Samurai (Optional)`,color:`text-shogun-gold`,icon:z,desc:`Head to Samurai Network. Click "Deploy Samurai," choose a role (e.g., Researcher, Analyst), give it a name, and deploy. Your first sub-agent is now ready to receive delegated tasks from the main Shogun.`},{step:6,title:`Start a Conversation`,color:`text-green-500`,icon:R,desc:`Click "Enter Command" on the dashboard (or navigate to Comms). Type your first message. The Shogun will respond using the primary model you selected. Congratulations — you are operational!`}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card flex gap-5 items-start`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col items-center gap-2 shrink-0`,children:(0,Y.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-shogun-bg border border-shogun-border flex items-center justify-center font-bold text-lg ${e.color}`,children:e.step})}),(0,Y.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4 ${e.color}`}),e.title]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.desc})]})]},e.step))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(le,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Core Concepts`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Key terms you'll encounter throughout the platform.`})]})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[{term:`Shogun`,def:`The main AI agent — your primary assistant. It coordinates everything, delegates to Samurai, and answers your questions directly.`,icon:l,color:`text-shogun-gold`},{term:`Samurai`,def:`Specialized sub-agents that handle specific tasks. Think of them as employees — each one has a role, a name, and a current assignment.`,icon:z,color:`text-shogun-gold`},{term:`Lattice`,def:`The network of all connected agents (Shogun + Samurai). The lattice distributes work intelligently and ensures no single agent is overwhelmed.`,icon:B,color:`text-shogun-blue`},{term:`Constitution`,def:`A set of inviolable rules written in YAML that govern what all agents are allowed to do. Managed in the Kaizen page.`,icon:p,color:`text-shogun-gold`},{term:`Security Posture`,def:`The built-in tier or custom policy selected in Torii. ToolGate turns that selection into capability boundaries and runtime ALLOW, CONFIRM, or BLOCK decisions.`,icon:y,color:`text-red-400`},{term:`Harakiri`,def:`The emergency kill switch. Instantly freezes all agent activity and locks the system to maximum security (SHRINE).`,icon:P,color:`text-red-400`},{term:`Routing Profile`,def:`A set of rules that decides which AI model handles which type of task. For example: code → GPT-4, research → Perplexity.`,icon:h,color:`text-shogun-blue`},{term:`Salience`,def:`A memory importance score (0.0–1.0). High-salience memories are retrieved first. The system auto-adjusts salience over time.`,icon:O,color:`text-shogun-gold`},{term:`Reflection Cycle`,def:`An automated self-improvement loop where the AI analyzes its own performance and generates optimization insights. Run from Bushido.`,icon:w,color:`text-shogun-blue`},{term:`Ronin (Desktop)`,def:`The desktop control capability. Allows agents to interact with OS desktops — mouse, keyboard, screenshots, and native apps. Torii selects its policy; ToolGate governs its capability boundary and runtime decisions alongside Posture Guard, App Trust, and Komainu.`,icon:u,color:`text-orange-400`},{term:`Komainu (Guardian)`,def:`The physical override system for Ronin. A three-tier safety mechanism: Level 1 (Pause), Level 2 (Terminate), Level 3 (Harakiri). Detects human mouse/keyboard input and stops the AI. Named after Japanese shrine guardians.`,icon:E,color:`text-red-400`}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4 ${e.color}`}),e.term]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.def})]},e.term))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(q,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Navigation Map`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Every page in Shogun at a glance — what it does and when to use it.`})]})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[{name:`Tenshu (Dashboard)`,purpose:`Your home screen. See stat cards, active agents, recent events, quick actions, and the Harakiri button. The first thing you see when you open Shogun.`,icon:q,color:`text-shogun-blue`},{name:`Comms (Chat)`,purpose:`Talk directly to your Shogun. Send questions or commands. Responses stream in real time. View chat history and restore old sessions. Also includes an integrated email client and calendar.`,icon:R,color:`text-shogun-blue`},{name:`Shogun Profile`,purpose:`Configure your AI's identity, personality, behavioral directives, and scheduled jobs. Model selection lives in Katana; security configuration lives in Torii and ToolGate.`,icon:l,color:`text-shogun-gold`},{name:`Samurai Network`,purpose:`Deploy and manage specialized sub-agents. Each Samurai has a role, routing profile, and spawn policy. Monitor their tasks and status.`,icon:z,color:`text-shogun-gold`},{name:`Katana (System Forge)`,purpose:`Install and connect AI providers, models, tools, file formats, channels, and account-specific scopes. Katana exposes capabilities; ToolGate governs whether they may run.`,icon:de,color:`text-shogun-blue`},{name:`Archives (Memory)`,purpose:`Search, browse, create, and manage the AI's memories. Supports semantic search, salience pinning, and memory type filtering.`,icon:G,color:`text-shogun-gold`},{name:`Dojo (Training Hall)`,purpose:`Browse 4,000+ skills from the OpenClaw College. Study training material, take certification exams, and track achievements.`,icon:r,color:`text-shogun-gold`},{name:`Kaizen (Governance)`,purpose:`Write the Constitution (YAML rules) and the Mandate (Markdown mission statement). Manage revision history and audit trails.`,icon:P,color:`text-shogun-gold`},{name:`Bushido (Reflection)`,purpose:`Calibrate self-improvement behavior. Tune reflection intensity, consolidation rate, and exploration variance. View AI-generated insights.`,icon:w,color:`text-shogun-blue`},{name:`Torii (Security)`,purpose:`Select the active built-in tier or custom posture and access the Harakiri kill switch. Custom posture lifecycle is owned by ToolGate.`,icon:y,color:`text-red-400`},{name:`ToolGate (Runtime Permissions)`,purpose:`Create, edit, and delete custom postures; configure capability boundaries; and inspect effective tool verdicts, risk indications, confirmations, and per-tool overrides.`,icon:H,color:`text-orange-400`},{name:`Mado (Browser)`,purpose:`Browser automation layer powered by Playwright. Your AI can navigate to URLs, extract page content, take screenshots, and interact with web pages—within the capability boundaries and runtime verdicts shown in ToolGate.`,icon:t,color:`text-cyan-400`},{name:`Ronin (Desktop Control)`,purpose:`Desktop automation layer. Allows governed mouse, keyboard, screenshot, and native app control. Protected by Posture Guard, App Trust (4 levels), Komainu physical override, and environment detection. Only available at TACTICAL tier or higher.`,icon:u,color:`text-orange-400`},{name:`Agent Flow (Workflows)`,purpose:`Visual drag-and-drop workflow builder. Design multi-step AI pipelines by chaining Input, Samurai, Shogun Approval, Logic Gate, Browser, and Output nodes. Execute complex orchestration flows.`,icon:A,color:`text-violet-400`},{name:`Mail (Email Client)`,purpose:`Full IMAP/SMTP email integration. Browse your inbox, read and compose emails, reply with CC/BCC, navigate folders. Your Shogun can also read, send, and manage emails via native skills.`,icon:b,color:`text-sky-400`},{name:`Calendar`,purpose:`CalDAV calendar integration. View upcoming events, create new ones (with time, location, and description), and manage your schedule. Your Shogun can query and create events via native skills.`,icon:pe,color:`text-emerald-400`},{name:`Nexus (Collaboration)`,purpose:`Create Joint Workspaces. Invite other Shogun instances over the network. Exchange typed messages and co-edit a shared whiteboard.`,icon:K,color:`text-indigo-400`},{name:`Gensui (Fleet Command)`,purpose:`Connect this Shogun to Central Command for fleet governance, telemetry, commands, and emergency Harakiri. While managed, Gensui owns ToolGate; the local control surface is read-only and enforces the cached central policy during outages.`,icon:E,color:`text-indigo-400`},{name:`Backups & Data`,purpose:`Scheduled and manual backups with configurable retention. Export/import your entire database. Manage backup settings and restore from any point.`,icon:U,color:`text-shogun-gold`},{name:`Updates`,purpose:`Auto-checks for new Shogun versions every 6 hours. One-click install to download and apply updates. Preserves your data, configs, and environment.`,icon:N,color:`text-emerald-400`},{name:`Logs (Compliance Dashboard)`,purpose:`NIS2, SOC2, and EU AI Act-compliant event stream. Filter by 11 categories (Decision, Oversight, Risk, Model, Policy, Memory, Tools, Auth, Incident, System). Click trace IDs for full workflow reconstruction. Audit chain verifies tamper-proof integrity.`,icon:k,color:`text-shogun-subdued`},{name:`Guide (Documentation)`,purpose:`This page — a comprehensive knowledge base covering onboarding, architecture, reference manual, and safety protocols. Located in the Maintenance section.`,icon:ue,color:`text-shogun-subdued`}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card flex gap-4 items-start`,children:[(0,Y.jsx)(`div`,{className:`p-2 rounded-lg bg-shogun-bg border border-shogun-border shrink-0`,children:(0,Y.jsx)(e.icon,{className:`w-5 h-5 ${e.color}`})}),(0,Y.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:e.name}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.purpose})]})]},e.name))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-green-500/40 pb-3`,children:[(0,Y.jsx)(D,{className:`w-6 h-6 text-green-500`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Tips & Best Practices`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Recommendations from experienced operators.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-green-500`}),` Start with TACTICAL Posture`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The default "TACTICAL" security tier is recommended for most users. It gives the AI enough autonomy to be useful while keeping dangerous operations (like shell access and auto-spawning) locked down. Only move to CAMPAIGN or RONIN when you fully understand the risks.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-green-500`}),` Add Fallback Models`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Don't rely on a single AI provider. In Katana → Model Routing, edit Custom routing and add at least one fallback model from a different provider. If the primary goes down, the router tries the next eligible model.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-green-500`}),` Pin Important Memories`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`If there's a fact the AI must never forget — a company policy, a key contact, a critical instruction — create it as a memory in Archives and pin it. Pinned memories always have maximum salience and are always loaded into context.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-green-500`}),` Enable Automatic Backups`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Your Shogun accumulates valuable knowledge over time. Go to `,(0,Y.jsx)(`strong`,{children:`Backups`}),` in the sidebar → enable automatic backups on a schedule. You can also manually export a "Safe JSON Bundle" from the Data Management tab. This protects you from data loss due to hardware failure.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-green-500`}),` Write a Clear Mandate`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Mandate (Kaizen → Mandate tab) is injected into every conversation. Use it to set the AI's overall purpose, tone, and special instructions. For example: "You are a senior financial analyst. Always cite sources. Respond in English."`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-green-500`}),` Monitor the Compliance Dashboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Check the Logs page regularly — it records every action with full NIS2/SOC2/EU AI Act provenance. Use the `,(0,Y.jsx)(`strong`,{children:`Decision`}),` tab to track AI reasoning influences. Click trace IDs to reconstruct full workflows. Verify the `,(0,Y.jsx)(`strong`,{children:`"Chain Intact"`}),` badge stays green — a broken chain indicates tampering. Export the audit log periodically for off-site compliance archival.`]})]})]})]})]}),I===`reference`&&(0,Y.jsxs)(`div`,{className:`flex gap-8 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsx)(`nav`,{className:`hidden lg:block w-56 shrink-0`,children:(0,Y.jsxs)(`div`,{className:`sticky top-6 space-y-1 p-3 bg-shogun-card border border-shogun-border rounded-xl max-h-[calc(100vh-120px)] overflow-y-auto`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pb-2 mb-2 border-b border-shogun-border`,children:[(0,Y.jsx)(me,{className:`w-4 h-4 text-shogun-blue`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Sections`})]}),$.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>ve(e.id),className:F(`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-[11px] font-medium transition-all duration-200 text-left`,V===e.id?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20 shadow-sm`:`text-shogun-subdued hover:text-shogun-text hover:bg-shogun-bg border border-transparent`),children:[(0,Y.jsx)(e.icon,{className:F(`w-3.5 h-3.5 shrink-0`,V===e.id?`text-shogun-blue`:e.color)}),e.label]},e.id))]})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-16`,ref:Q,children:[(0,Y.jsxs)(`div`,{className:`text-center max-w-3xl mx-auto space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3`,children:[(0,Y.jsx)(`h3`,{className:`text-3xl font-bold shogun-title`,children:`The Grand Reference`}),(0,Y.jsxs)(`button`,{type:`button`,onClick:ye,className:`print-hide inline-flex items-center gap-2 rounded-lg border border-shogun-blue/30 bg-shogun-blue/10 px-3 py-2 text-xs font-bold text-shogun-blue transition-colors hover:bg-shogun-blue/20`,children:[(0,Y.jsx)(he,{className:`h-4 w-4`}),`Print Guide`]})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ve(`ref-flowstack`),className:`print-hide mx-auto flex items-center gap-2 rounded-xl border border-violet-400/30 bg-violet-500/10 px-4 py-2.5 text-xs font-bold text-violet-300 transition-colors hover:bg-violet-500/20`,children:[(0,Y.jsx)(_,{className:`h-4 w-4`}),`Flow Stacking & Stack Orchestrator — full reference`]}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed`,children:`A deep-dive, page-by-page, tab-by-tab, button-by-button manual of every single capability within the Shogun platform. Written in plain language so anyone can understand it — no technical jargon required.`})]}),(0,Y.jsxs)(`section`,{id:`ref-tenshu`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(q,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Tenshu — The Command Center`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Your home screen. The first thing you see when you open Shogun.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-blue`}),` Stat Cards (Top Row)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Four large cards at the top of the page. Each one is a "quick look" at a different part of the system. They are clickable — clicking one takes you to the related page.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Neural Engine:`}),` Shows the name of your primary AI and whether it is currently running. Click to go to the Shogun Profile page.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Active Lattice:`}),` How many sub-agents (Samurai) are currently deployed. Click to go to the Samurai Network page.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Knowledge Volume:`}),` The total number of memories stored in the Archives. Also indicates whether the search index is healthy or has errors.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security Tier:`}),` Shows your current protection level (e.g., "GUARDED" or "TACTICAL"). Click to go to Torii.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-shogun-blue`}),` Active Deployment Registry`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A table below the stat cards that lists every Samurai (sub-agent) currently running. For each one you can see:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Designation:`}),` The agent's name and its first-letter icon.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Current Task:`}),` What the agent is working on right now.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Engagement Bar:`}),` A progress bar showing how busy it is.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Status:`}),` A green "active" or blue "suspended" badge.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-shogun-blue`}),` Quick Actions Panel`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Two large shortcut buttons below the deployment registry:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`New Samurai:`}),` Opens the Samurai Network page to deploy a new sub-agent.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Model Setup:`}),` Opens the Katana page to configure AI models.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-red-400`}),` Emergency Stop (Harakiri)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A red button on the dashboard. Pressing it opens a two-step confirmation modal. Once confirmed, `,(0,Y.jsx)(`strong`,{children:`all active agent operations are immediately stopped`}),`. The security posture locks to "SHRINE" (maximum protection). A pulsing red banner appears at the top of Every page until you press "Reset Harakiri".`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-gold`}),` Telemetry Feed (Right Sidebar)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A timeline of recent system events displayed on the right side. Each event has a colored icon (red for security, gold for agent, blue for system) and a timestamp. At the bottom, a "System Load" bar shows current CPU usage.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-blue`}),` "Enter Command" Button`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The blue button in the top right. Clicking it takes you straight to the Comms (Chat) page where you can start talking to your Shogun.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-server`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-emerald-400/40 pb-3`,children:[(0,Y.jsx)(S,{className:`w-6 h-6 text-emerald-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Shogun Server Mode — Container Installation`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Run Shogun and The Tenshu continuously with Docker, PostgreSQL, and Qdrant.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card border-l-4 border-l-red-500 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4`}),` Ronin Does Not Work in Server Mode`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A container cannot safely access the server's physical desktop. Ronin screenshots, mouse and keyboard control, native application control, and host-desktop sessions are disabled and rejected by the server. Selecting the Torii posture named `,(0,Y.jsx)(`strong`,{children:`RONIN`}),` does not override this container boundary. Install Shogun directly on a desktop computer when Ronin Desktop Control is required.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{className:`text-emerald-400`,children:`Still available:`}),` Mado browser automation runs Chromium inside the container. Agent Flows, Flow Stacking, Telegram, Microsoft Teams, Nexus, memory, ToolGate, HARAKIRI, and external local-model servers such as Ollama continue to work.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-emerald-400`}),` Before You Install`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Windows or macOS:`}),` Install Docker Desktop and start it.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Linux:`}),` Install Docker Engine and the Docker Compose plugin.`]}),(0,Y.jsx)(`li`,{children:`Allow outbound internet access while the image and service images are downloaded.`}),(0,Y.jsx)(`li`,{children:`Plan remote administration through a VPN, SSH tunnel, or authenticated HTTPS reverse proxy.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-emerald-400`}),` One-Click Installation`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-4 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Open the latest Shogun GitHub Release.`}),(0,Y.jsxs)(`li`,{children:[`Download `,(0,Y.jsx)(`code`,{children:`Shogun-Server-Install.bat`}),` on Windows, or `,(0,Y.jsx)(`code`,{children:`Shogun-Server-Install.sh`}),` on Linux/macOS.`]}),(0,Y.jsx)(`li`,{children:`Run the installer. It generates secrets, builds the image, and starts all services.`}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`code`,{children:`http://127.0.0.1:8000/setup`}),` and complete the Setup Wizard as the Primary Admin.`]})]}),(0,Y.jsxs)(`a`,{href:`https://github.com/AlphaHorizon-AI/Shogun/releases/latest`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] font-bold text-emerald-400 hover:underline`,children:[(0,Y.jsx)(d,{className:`w-3 h-3`}),` Open the latest Shogun Release`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-emerald-400`}),` What the Stack Runs`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shogun + The Tenshu:`}),` A non-root application container exposed on port 8000.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`PostgreSQL:`}),` Structured application, configuration, team, and audit data.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Qdrant:`}),` Vector memory and semantic retrieval.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Internal network:`}),` PostgreSQL and Qdrant are not published to the host.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Health and restart controls:`}),` Failed services are detected and restarted automatically.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-emerald-400`}),` Persistence and Upgrades`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Named Docker volumes preserve application data, memories, vault content, configuration, logs, PostgreSQL, and Qdrant. The installer also preserves `,(0,Y.jsx)(`code`,{children:`.env.server`}),` when updating the source.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-red-400 leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Never use`}),` `,(0,Y.jsx)(`code`,{children:`docker compose down -v`}),` unless you intentionally want to delete all Server-mode data.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-emerald-400`}),` Team Access Model`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Primary Admin operates The Tenshu and owns platform administration. Team members communicate with Shogun through their configured Telegram or Microsoft Teams identities and receive separate identity and pinned-memory contexts. Team members do not receive access to The Tenshu.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-emerald-400`}),` Network Security`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Tenshu binds to `,(0,Y.jsx)(`code`,{children:`127.0.0.1`}),` by default and is therefore reachable only from the server itself. Do not expose it on a public or shared network without an authenticated HTTPS reverse proxy. A VPN or SSH tunnel is the preferred way to administer it remotely.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-emerald-400`}),` Essential Server Commands`]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg border border-shogun-border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Status`}),(0,Y.jsx)(`code`,{className:`text-[10px] text-emerald-400 break-all`,children:`docker compose --env-file .env.server -f docker-compose.server.yml ps`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg border border-shogun-border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Live Logs`}),(0,Y.jsx)(`code`,{className:`text-[10px] text-emerald-400 break-all`,children:`docker compose --env-file .env.server -f docker-compose.server.yml logs -f shogun`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg border border-shogun-border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Safe Stop`}),(0,Y.jsx)(`code`,{className:`text-[10px] text-emerald-400 break-all`,children:`docker compose --env-file .env.server -f docker-compose.server.yml down`})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-comms`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(R,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Comms — The Conversation`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Your direct line to the Shogun AI. Four tabs: Chat, Mail, Calendar, and Files.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-blue`}),` Chat Window`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The main area showing your conversation. Your messages appear on the right (blue icon), and the Shogun's replies appear on the left (gold icon). While the AI is thinking, three bouncing dots are shown. Responses stream in token by token so you can watch the answer being written in real time.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-4 h-4 text-shogun-blue`}),` Model & Search Tags`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Below each Shogun reply you will see a small tag. If the reply used a `,(0,Y.jsx)(`strong`,{children:`Web Search`}),` (via Perplexity), a blue "Web Search" badge appears. Otherwise, the name of the AI model used is shown (e.g., "gpt-4o").`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-gold`}),` Input Bar & Sending`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Type your message at the bottom and press `,(0,Y.jsx)(`strong`,{children:`Enter`}),` (or click the blue send arrow) to send. While the AI is responding, the input field is locked and shows "Transmitting directive..." to prevent double-sending.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(c,{className:`w-4 h-4 text-shogun-gold`}),` Session History`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Below the input bar, click `,(0,Y.jsx)(`strong`,{children:`"View History"`}),` to open a right-hand drawer showing all your previous chat sessions. Each session shows a preview of the first message and the number of messages. Click `,(0,Y.jsx)(`strong`,{children:`"Restore"`}),` to reload an old conversation. Click `,(0,Y.jsx)(`strong`,{children:`"Clear All History"`}),` at the bottom to permanently erase all archived sessions.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-red-400`}),` Clear Button (Trash Icon)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The trash icon in the top right `,(0,Y.jsx)(`strong`,{children:`archives`}),` the current session to history and starts a fresh conversation. Your old messages are not lost — they are kept in the History drawer and can be restored at any time.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mt-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-sky-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-sky-400`}),` Mail — Email Client`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A full IMAP/SMTP email client built into Comms. Browse your inbox with sender, subject, date, and preview. Click any message to read the full content. `,(0,Y.jsx)(`strong`,{children:`Compose`}),` new emails with To, CC, BCC, subject, and body. Reply to existing messages with quoted context. Navigate between folders (Inbox, Sent, Drafts). Configure your email account in the system settings. The Shogun can also manage email via native skills: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`fetch_inbox`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`read_email`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`send_email`}),`.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(pe,{className:`w-4 h-4 text-emerald-400`}),` Calendar — Event Management`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`CalDAV calendar integration. View your upcoming events on a timeline with titles, times, locations, and descriptions. Create new events by specifying a title, start/end time, location, and optional description. Supports all-day events. Connect a CalDAV server in the system settings. The Shogun can query and create events via native skills: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`list_calendar_events`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`create_calendar_event`}),`.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-amber-400/40 mt-4`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(m,{className:`w-4 h-4 text-amber-400`}),` Files — Workspace File Explorer`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A full visual file manager for the Agent Workspace — the dedicated folder shared between the Shogun, all Samurai agents, and the user. The Files tab provides everything you need to browse, create, edit, upload, and delete files without leaving the Comms page.`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 mt-2`,children:[(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Tree Sidebar (Left)`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Expandable directory tree with file-type icons (code, spreadsheet, image, archive, text).`}),(0,Y.jsx)(`li`,{children:`File sizes shown in human-readable format (KB, MB).`}),(0,Y.jsx)(`li`,{children:`Real-time search filter to find files instantly.`}),(0,Y.jsx)(`li`,{children:`Workspace info footer: total files, directories, and disk usage.`})]})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Content Panel (Right)`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Click a file to view its contents in a monospace reader.`}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Edit`}),` to modify any text file inline, then `,(0,Y.jsx)(`strong`,{children:`Save`}),` to write back to disk.`]}),(0,Y.jsx)(`li`,{children:`Click a folder to see its contents as a clickable card grid with icons and sizes.`}),(0,Y.jsx)(`li`,{children:`Empty state shows workspace path and usage instructions.`})]})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Toolbar Actions`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`New File`}),` (file+ icon): Creates a file inside the selected folder or workspace root.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`New Folder`}),` (folder+ icon): Creates a directory. Nested paths auto-created.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Upload`}),` (upload icon): Opens a file picker to upload one or more files.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Rename`}),` (edit icon): Renames the selected file or folder.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Delete`}),` (trash icon): Deletes with confirmation. Directories deleted recursively.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Refresh`}),` (refresh icon): Reloads the tree from disk.`]})]})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Drag & Drop Upload`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Drag files from your desktop or file manager and drop them anywhere on the File Explorer.`}),(0,Y.jsx)(`li`,{children:`A blue overlay appears showing where files will land.`}),(0,Y.jsx)(`li`,{children:`Files are uploaded into the currently selected folder, or workspace root if none is selected.`}),(0,Y.jsx)(`li`,{children:`Multiple files can be dropped at once. All file types are supported.`}),(0,Y.jsx)(`li`,{children:`Filenames are sanitized on the server. Path traversal is blocked.`})]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-profile`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(l,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Shogun Profile — Your AI's Identity`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Configure the identity, personality, behavior, and scheduled operations of your main Shogun agent. Has 3 tabs; security configuration is owned by ToolGate.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(l,{className:`w-4 h-4 text-shogun-gold`}),` General Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Set the Shogun's name, choose an active "Persona" (a pre-built personality template), and write a description. On the right side, adjust the `,(0,Y.jsx)(`strong`,{children:`Autonomy Level`}),` slider (how much freedom the AI gets), `,(0,Y.jsx)(`strong`,{children:`Tone`}),` (e.g., Analytical, Direct), `,(0,Y.jsx)(`strong`,{children:`Risk Tolerance`}),`, `,(0,Y.jsx)(`strong`,{children:`Verbosity`}),` (how detailed responses are), `,(0,Y.jsx)(`strong`,{children:`Planning Depth`}),`, `,(0,Y.jsx)(`strong`,{children:`Tool Usage`}),`, `,(0,Y.jsx)(`strong`,{children:`Security Bias`}),`, and `,(0,Y.jsx)(`strong`,{children:`Memory Style`}),`. Click the avatar image to upload a custom picture.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-gold`}),` Model Selection`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Model selection is configured centrally in `,(0,Y.jsx)(`strong`,{children:`Katana → Model Routing`}),`, where providers, routing profiles, capability requirements, primary models, and fallback order share one source of truth.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-gold`}),` Behavior Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A full-screen YAML text editor showing the Shogun's core behavioral directives — its priorities, operational constraints, and delegation rules. Think of this as the AI's "rule book." You can edit it directly, and the badge in the top-right confirms it is in "YAML Mode."`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-orange-400`}),` Security Summary`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The General tab shows the active policy, inherited base tier, and capability risk as a compact summary. Use `,(0,Y.jsx)(`strong`,{children:`Open ToolGate`}),` to inspect or change security behavior. The former Permissions tab now redirects to ToolGate so there is only one runtime-permission control surface.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(w,{className:`w-4 h-4 text-shogun-gold`}),` Operations Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`View and manage scheduled background jobs. Preset jobs include `,(0,Y.jsx)(`strong`,{children:`Memory Consolidation`}),` (summarizes and compresses old memories), `,(0,Y.jsx)(`strong`,{children:`Knowledge Refresh`}),` (updates outdated knowledge), and `,(0,Y.jsx)(`strong`,{children:`Security Audit`}),`. Each can be enabled/disabled with a toggle. Below the presets, you can `,(0,Y.jsx)(`strong`,{children:`create custom jobs`}),` with a name, schedule (nightly, weekly, monthly, or one-time), priority, and instructions.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-samurai`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(z,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Samurai Network — The Fleet`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Deploy, manage, and monitor specialized sub-agents.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-shogun-gold`}),` Fleet Stats (Top)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Four stat cards: `,(0,Y.jsx)(`strong`,{children:`Total Fleet`}),` (all agents), `,(0,Y.jsx)(`strong`,{children:`Active`}),` (currently working), `,(0,Y.jsx)(`strong`,{children:`Suspended`}),` (paused), and `,(0,Y.jsx)(`strong`,{children:`Signal Range`}),` (network reach).`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-gold`}),` Agent Table & Search`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A large table listing every Samurai. Use the search bar to filter by name. Each row shows: the agent's `,(0,Y.jsx)(`strong`,{children:`name and role badge`}),`, `,(0,Y.jsx)(`strong`,{children:`status`}),` (green dot = active), `,(0,Y.jsx)(`strong`,{children:`current task`}),` (with a live progress bar if running), `,(0,Y.jsx)(`strong`,{children:`role/slug`}),`, `,(0,Y.jsx)(`strong`,{children:`routing profile`}),`, and `,(0,Y.jsx)(`strong`,{children:`deployment date`}),`. Hover over a row to reveal action buttons.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-shogun-gold`}),` Row Action Buttons`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Three buttons appear when you hover over a Samurai row:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Pause/Play:`}),` Suspend a running agent or resume a suspended one.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Trash:`}),` Permanently delete the agent (asks for confirmation first).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Configure (⋮):`}),` Opens a modal where you can change the agent's name, role, routing profile, spawn policy, and description.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(S,{className:`w-4 h-4 text-shogun-blue`}),` "Deploy Samurai" Button`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The blue button in the top right. Opens a form where you choose a `,(0,Y.jsx)(`strong`,{children:`Role`}),` from the pre-defined Samurai roles list, give it a `,(0,Y.jsx)(`strong`,{children:`custom name`}),`, choose a `,(0,Y.jsx)(`strong`,{children:`Spawn Policy`}),` (Manual, Auto, or Scheduled), optionally assign a `,(0,Y.jsx)(`strong`,{children:`Routing Profile`}),`, and write a description. Click "Deploy Samurai" to create it.`]})]})]}),(0,Y.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-subdued uppercase tracking-widest pl-1 border-l-2 border-shogun-gold/40 ml-1`,children:`Samurai Orchestration`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(A,{className:`w-4 h-4 text-violet-400`}),` Agent Flow — Workflow Builder`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A visual drag-and-drop canvas for designing multi-step AI pipelines. Build workflows by chaining 13 node types, including the governed, memory-aware Coding node:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Input:`}),` The entry point — accepts user text, data, or triggers.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Samurai:`}),` Delegates a task to a specific sub-agent.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shogun Approval:`}),` Pauses the flow for human confirmation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Logic:`}),` A conditional gate — routes based on a condition.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Mado Browser:`}),` Automates a web browsing action.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Email Send / Telegram & Teams:`}),` Delivers results through configured channels.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Workspace / Office:`}),` Performs governed file operations or works with Office documents.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Subflow:`}),` Runs a reusable child Agent Flow.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Stack Orchestrator:`}),` Supervises a long-running Flow Stack.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Output:`}),` Collects and presents the final result, with optional memory infusion.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-violet-400`}),` Canvas, Execution & AI Creation`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Position nodes freely on the visual canvas and draw directed edges between them. Edges define execution order — data flows from source to target. The canvas supports pan, zoom, and node reordering. Workflows are saved to the database.`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Click `,(0,Y.jsx)(`strong`,{children:`Execute`}),` to run a workflow. Nodes process in topological order, passing outputs as inputs to the next. Shogun Approval nodes pause until you confirm.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Shogun can manage workflows natively: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`list_agent_flows`}),` discovers flows and stacks, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`get_agent_flow`}),` reads a complete graph, and `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`patch_agent_flow`}),` safely changes selected nodes or edges. It can also create, replace, and delete flows. The agent is instructed to inspect a flow before editing it.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(S,{className:`w-4 h-4 text-violet-400`}),` Template Gallery`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click `,(0,Y.jsx)(`strong`,{children:`New Flow`}),` to browse 173 pre-built workflow templates across 11 different categories, including 33 distinct Coding templates. Templates range in difficulty from `,(0,Y.jsx)(`strong`,{children:`Beginner`}),` to `,(0,Y.jsx)(`strong`,{children:`Advanced`}),`.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`When you select a template, the canvas is automatically populated. Samurai nodes inside templates use `,(0,Y.jsx)(`strong`,{children:`Ephemeral (Ad-Hoc)`}),` agents by default to keep your Fleet clean, but can be manually linked to a permanent Fleet Samurai via the node properties panel.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-orange-400/40 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-orange-400`}),` Output Memory Infusion`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`An Output node can opt into `,(0,Y.jsx)(`strong`,{children:`Memory Infusion`}),`. When its configured completion state is reached, the flow engine—not the model—stores selected output fields in Archives. Configure the memory type, importance, decay, tags, title template, content fields, maximum length, sensitive-data redaction, and behavior when fields are missing.`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Storage can run on success, partial completion, or always. Exact-hash or semantic deduplication prevents repeated memories and reinforces an existing match. Every stored, skipped, or deduplicated result carries flow/run/node provenance and an audit event. Memory Infusion is disabled by default and must be enabled per Output node.`})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-katana`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(l,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Katana — The System Forge`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Where you install and connect models, tools, formats, channels, account integrations, and operational capability providers. Shows 13 tabs normally and 14 when IDE Mode is available in Campaign or Ronin posture. Katana exposes capabilities; it does not decide whether a capability may run.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-shogun-blue`}),` AI Model Provider Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Lists every cloud or local AI service you have connected (OpenAI, Anthropic, Google Gemini, Perplexity, Ollama, etc.). Each provider card shows its `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`type`}),`, `,(0,Y.jsx)(`strong`,{children:`status`}),`, and available `,(0,Y.jsx)(`strong`,{children:`models`}),`. Add, edit, enable, disable, or delete provider connections here; credentials are stored through the backend rather than displayed after saving.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-blue`}),` File Formats Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Controls the file-format registry used by governed tools. Review recognized extensions, MIME types, capability categories, safety classifications, size limits, and which operations are available for each format.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(n,{className:`w-4 h-4 text-shogun-blue`}),` Routing Profiles Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Create "routing profiles" — sets of rules that decide which AI model handles which type of task. For example, you can create a "Balanced" profile where: code tasks go to GPT-4, research tasks go to Perplexity Sonar, and simple chat goes to a cheap model. Each profile has a `,(0,Y.jsx)(`strong`,{children:`name`}),`, optional `,(0,Y.jsx)(`strong`,{children:`default model`}),`, and a list of `,(0,Y.jsx)(`strong`,{children:`rules`}),` (task type → model pair). Profiles can be set as the system default.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-shogun-blue`}),` Toolbox Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Lists the external tools installed or connected to Shogun — web search, file access, database connections, code execution, and more. Each tool shows its `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`type`}),`, and availability status. You can `,(0,Y.jsx)(`strong`,{children:`register new tools`}),` and connect or disconnect existing ones. These controls determine whether a capability exists; `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` determines whether, when, and with what confirmation it may execute.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-shogun-blue`}),` Skills · Active Usage Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shows which Dojo skills are actually retrieved and injected during agent runs, along with usage outcomes, trajectory evidence, and improvement candidates. See `,(0,Y.jsx)(`strong`,{children:`Active Skills & Trajectory Capture`}),` below for the complete runtime lifecycle.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-shogun-blue`}),` Team Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Primary Admin can switch this installation between `,(0,Y.jsx)(`strong`,{children:`Single User`}),` and `,(0,Y.jsx)(`strong`,{children:`Team Mode`}),`. Single-user mode immediately disables every Team Member's Telegram or Microsoft Teams access while retaining the saved roster. Switching back to Team Mode restores access for those saved members.`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In Team Mode, add members by name and their verified Telegram user ID or Microsoft Teams identity. Each member receives an isolated identity memory so Shogun can remember that person without exposing another member's private context. Deleting a member revokes access, removes them from the roster, and archives their identity memory. The Primary Admin is protected and cannot be deleted.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(f,{className:`w-4 h-4 text-shogun-blue`}),` Office App Mode Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Controls the `,(0,Y.jsx)(`strong`,{children:`Office App Mode`}),` — Shogun's ability to read, create, and modify Microsoft Office documents (`,(0,Y.jsx)(`code`,{children:`.xlsx`}),`, `,(0,Y.jsx)(`code`,{children:`.docx`}),`, `,(0,Y.jsx)(`code`,{children:`.pptx`}),`). The tab has a master `,(0,Y.jsx)(`strong`,{children:`enable/disable`}),` toggle at the top. Below it are four sections:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Approved Folders:`}),` Four directory paths (Input, Output, Templates, Temp) that define the allowed file boundaries. When left empty, they automatically use the `,(0,Y.jsx)(`strong`,{children:`workspace root`}),` folder. All file operations are jailed to these directories — any path outside them is rejected.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Per-Application Settings:`}),` Individual cards for `,(0,Y.jsx)(`strong`,{children:`Excel`}),`, `,(0,Y.jsx)(`strong`,{children:`Word`}),`, `,(0,Y.jsx)(`strong`,{children:`PowerPoint`}),`, and `,(0,Y.jsx)(`strong`,{children:`Outlook`}),` — each with its own enable toggle, macro policy (allow/block), overwrite protection, and timeout. Excel also has an external links toggle; Outlook has draft-only vs. send mode and domain allowlists.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Safety Rules:`}),` Global policies including path traversal blocking, Windows shortcut (`,(0,Y.jsx)(`code`,{children:`.lnk`}),`) blocking, UNC/network path blocking, output versioning, and a maximum file size cap (default 100 MB).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security Posture Gate:`}),` Office operations require at least `,(0,Y.jsx)(`strong`,{children:`Guarded`}),` posture. In `,(0,Y.jsx)(`strong`,{children:`Shrine`}),` mode, all Office tools are disabled. The minimum posture can be raised (e.g., to Tactical) for stricter environments.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-shogun-blue`}),` Mail & Calendar Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Connect your email account for AI-powered mail capabilities. Configure an `,(0,Y.jsx)(`strong`,{children:`IMAP/SMTP`}),` account by entering server addresses, port numbers, and credentials. Once connected, the Shogun can:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Read emails:`}),` Fetch and analyze incoming mail from the inbox.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Send emails:`}),` Compose and send messages (requires `,(0,Y.jsx)(`code`,{children:`perm_send_mail`}),` to be enabled).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Calendar events:`}),` Create and manage calendar entries (when supported by the provider).`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The tab shows `,(0,Y.jsx)(`strong`,{children:`connection status`}),`, account details, and `,(0,Y.jsx)(`strong`,{children:`Account Scopes`}),` for read, send, and calendar access. These scopes describe what the connected account exposes; ToolGate remains the runtime authority and can further restrict or require confirmation for every action. All mail activity is logged in the immutable audit chain.`]})]}),(0,Y.jsxs)(`div`,{id:`ref-telegram`,className:`shogun-card space-y-5 md:col-span-2 scroll-mt-6 border-sky-400/20`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-4 h-4 text-shogun-blue`}),` Telegram Integration`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Connect a private Telegram bot so you can talk to Shogun from your phone. A first-time personal setup normally takes 10–15 minutes.`}),(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg border border-sky-400/20 bg-sky-400/5 text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{className:`text-shogun-text`,children:`Choose Polling.`}),` It is the working listener in this release and needs no public URL. Keep Webhook for administrator-managed custom deployments.`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`In Telegram, open the verified `,(0,Y.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-sky-400 hover:underline`,children:`@BotFather`}),` account and send `,(0,Y.jsx)(`code`,{children:`/newbot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Choose a display name, then a unique username ending in `,(0,Y.jsx)(`code`,{children:`bot`}),`. Copy the token BotFather returns and protect it like a password.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Katana → Telegram`}),`, paste the token, select Polling, temporarily leave Allowed Chat IDs empty, and click `,(0,Y.jsx)(`strong`,{children:`Connect Bot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Open your new bot in Telegram, press Start, and send `,(0,Y.jsx)(`code`,{children:`Hello`}),`. Bots cannot initiate private conversations.`]}),(0,Y.jsxs)(`li`,{children:[`Back in Katana, click `,(0,Y.jsx)(`strong`,{children:`Auto-detect Chat ID`}),`. The detected ID is placed in the test and whitelist fields.`]}),(0,Y.jsxs)(`li`,{children:[`Paste the token again and click `,(0,Y.jsx)(`strong`,{children:`Update Connection`}),`. This second save is essential: auto-detect changes the form, but the Allowed Chat IDs whitelist is not permanent until the connection is updated.`]}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Send Test`}),`, then send `,(0,Y.jsx)(`code`,{children:`Hello Shogun`}),` from Telegram. Receiving both replies completes the private-chat setup.`]})]}),(0,Y.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text mb-2`,children:`Adding a group`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:`Add the bot, send a direct command or mention, then auto-detect again. A group ID is normally negative. Add it to Allowed Chat IDs, paste the token again, and Update Connection. Telegram Privacy Mode normally limits the bot to commands, mentions, and replies.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text mb-2`,children:`Safety rules`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued ml-4 list-disc space-y-1`,children:[(0,Y.jsx)(`li`,{children:`Never leave Allowed Chat IDs empty after discovery.`}),(0,Y.jsx)(`li`,{children:`Run only one Shogun poller per token.`}),(0,Y.jsx)(`li`,{children:`Regenerate an exposed token in BotFather immediately.`}),(0,Y.jsx)(`li`,{children:`Shogun must stay awake, running, and online.`})]})]})]}),(0,Y.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{className:`text-shogun-text`,children:`If auto-detect finds nothing:`}),` send a fresh direct message to the bot, wait a few seconds, and retry. If Send Test works but normal messages are ignored, verify the exact Chat ID and repeat the second Update Connection save. See the expanded Telegram setup and troubleshooting walkthrough in the Onboarding tab.`]}),(0,Y.jsxs)(`a`,{href:`https://core.telegram.org/bots/features`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-sky-400 hover:underline`,children:[(0,Y.jsx)(d,{className:`w-3 h-3`}),` Official Telegram bot and Privacy Mode reference`]})]}),(0,Y.jsxs)(`div`,{id:`ref-teams`,className:`shogun-card space-y-2 md:col-span-2 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-blue`}),` Microsoft Teams Adapter`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Connect Microsoft Teams as an enterprise command and notification channel for Shogun. Teams is the communication surface; `,(0,Y.jsx)(`strong`,{children:`Katana`}),` manages the channel, while `,(0,Y.jsx)(`strong`,{children:`Gensui`}),` continues to enforce identity, authorization, approvals, policy, and audit. The adapter supports personal chats, group chats, and channel commands when the Shogun bot is directly mentioned.`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Overview:`}),` Shows adapter health, tenant and SSO status, recent activity, errors, and active approval requests.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Setup Wizard:`}),` Configures the deployment mode, allowed Microsoft tenants, Bot/App ID, secret reference, public HTTPS messaging endpoint, valid domains, and downloadable Teams app package.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Entra & Roles:`}),` Maps verified Teams and Microsoft Entra identities to Shogun roles. New identities begin as `,(0,Y.jsx)(`strong`,{children:`Viewer`}),` until deliberately promoted.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security Policy:`}),` Controls available command groups, destructive-command approval flow, approval expiry, and dual approval for fleet shutdown.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Audit & Diagnostics:`}),` Records inbound commands, risk classification, authorization decisions, response outcomes, and correlation IDs. Built-in checks validate the Shogun backend, Microsoft Graph configuration, proactive messaging, and Teams manifest.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Commands such as `,(0,Y.jsx)(`code`,{children:`status`}),`, `,(0,Y.jsx)(`code`,{children:`agents`}),`, `,(0,Y.jsx)(`code`,{children:`run workflow`}),`, `,(0,Y.jsx)(`code`,{children:`pause agent`}),`, and `,(0,Y.jsx)(`code`,{children:`show pending approvals`}),` are classified by risk before dispatch. Critical commands—including Harakiri—never execute directly from a casual Teams message and must pass through Gensui confirmation and the configured approval policy. Production use requires a Microsoft Entra/Azure Bot registration and a public HTTPS Teams Bridge endpoint.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-6 border-indigo-400/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2 text-base`,children:[(0,Y.jsx)(z,{className:`w-5 h-5 text-indigo-400`}),` Microsoft Teams — Step-by-Step Connection Guide`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`A complete path from an empty Microsoft tenant to a working Shogun personal chat and channel mention.`})]}),(0,Y.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-indigo-400 bg-indigo-400/10 border border-indigo-400/20 px-2.5 py-1 rounded-full w-fit`,children:`Administrator-assisted setup`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg border border-amber-400/20 bg-amber-400/5`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-amber-300 font-bold flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4`}),` Non-technical reality check`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Teams is an enterprise deployment, not a one-token connection. Most organizations require a `,(0,Y.jsx)(`strong`,{children:`Microsoft 365/Teams administrator`}),`, an `,(0,Y.jsx)(`strong`,{children:`Azure or Entra administrator`}),`, and the person who operates the Shogun server. The simplest safe pilot is`,(0,Y.jsx)(`strong`,{children:` Single tenant + Customer-hosted Teams Bridge + personal chat`}),`. Leave SSO, Microsoft Graph, and proactive messaging off until basic chat works.`]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text mb-3`,children:`What must be ready`}),(0,Y.jsx)(`div`,{className:`grid sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[[`Microsoft 365 tenant`,`A work or school tenant with Microsoft Teams.`],[`Azure subscription`,`Permission to create an Entra app registration and Azure Bot resource.`],[`Public HTTPS address`,`A stable internet address for the Teams Bridge, or a secure tunnel for a pilot.`],[`Shogun server access`,`Permission to start the included bridge and set protected environment values.`]].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed mt-1`,children:t})]},e))})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-indigo-400/5 border border-indigo-400/20`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-shogun-text`,children:`Administrator handoff checklist`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-1`,children:`If someone else manages Microsoft 365, give that person this exact list:`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued leading-relaxed mt-2 ml-4 list-disc space-y-1.5`,children:[(0,Y.jsxs)(`li`,{children:[`Create a `,(0,Y.jsx)(`strong`,{children:`single-tenant Microsoft Entra app registration`}),` for Shogun.`]}),(0,Y.jsxs)(`li`,{children:[`Create an `,(0,Y.jsx)(`strong`,{children:`Azure Bot`}),` using that existing app registration and enable its Microsoft Teams channel.`]}),(0,Y.jsxs)(`li`,{children:[`Provide the `,(0,Y.jsx)(`strong`,{children:`Directory (tenant) ID`}),` and `,(0,Y.jsx)(`strong`,{children:`Application (client) ID`}),`.`]}),(0,Y.jsx)(`li`,{children:`Store the client secret or certificate in the approved secret store; do not send it by email or Teams chat.`}),(0,Y.jsx)(`li`,{children:`Permit the Shogun custom Teams app for pilot users, or upload it to the organization's app catalog.`}),(0,Y.jsxs)(`li`,{children:[`Provide a public HTTPS hostname that routes to the Shogun Teams Bridge on port `,(0,Y.jsx)(`code`,{children:`3978`}),`.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part A — Register Shogun in Microsoft Entra`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Sign in to the `,(0,Y.jsx)(`a`,{href:`https://portal.azure.com`,target:`_blank`,rel:`noreferrer`,className:`text-indigo-400 hover:underline font-bold`,children:`Azure portal`}),` with the administrator account.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Microsoft Entra ID → App registrations → New registration`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Enter a recognizable name such as `,(0,Y.jsx)(`code`,{children:`Shogun Teams Bot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Select `,(0,Y.jsx)(`strong`,{children:`Accounts in this organizational directory only`}),` for a single-tenant deployment, then select `,(0,Y.jsx)(`strong`,{children:`Register`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`On Overview, copy `,(0,Y.jsx)(`strong`,{children:`Application (client) ID`}),` and `,(0,Y.jsx)(`strong`,{children:`Directory (tenant) ID`}),`. Keep the labels with the values so they are not confused.`]}),(0,Y.jsxs)(`li`,{children:[`For a pilot using a client secret, open `,(0,Y.jsx)(`strong`,{children:`Certificates & secrets → Client secrets → New client secret`}),`. Copy the secret `,(0,Y.jsx)(`strong`,{children:`Value`}),` immediately; it is displayed only once. Store it in an approved secret manager. For production, Microsoft recommends a managed identity, federated credential, or certificate instead of a long-lived client secret.`]})]}),(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoft-365/agents-sdk/azure-bot-authentication-for-javascript`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(d,{className:`w-3 h-3`}),` Official Microsoft authentication options`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part B — Create and configure the Azure Bot`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`In the Azure portal, select `,(0,Y.jsx)(`strong`,{children:`Create a resource`}),`, search for `,(0,Y.jsx)(`strong`,{children:`Azure Bot`}),`, and select `,(0,Y.jsx)(`strong`,{children:`Create`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Choose the subscription and resource group, enter a unique bot handle, and select `,(0,Y.jsx)(`strong`,{children:`Single Tenant`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`For Microsoft App ID, choose `,(0,Y.jsx)(`strong`,{children:`Use existing app registration`}),` and enter the Application (client) ID from Part A.`]}),(0,Y.jsxs)(`li`,{children:[`After deployment, open the Azure Bot resource. Under `,(0,Y.jsx)(`strong`,{children:`Settings → Configuration`}),`, set Messaging endpoint to `,(0,Y.jsx)(`code`,{children:`https://YOUR-BRIDGE-HOST/api/messages`}),`, then apply the change.`]}),(0,Y.jsxs)(`li`,{children:[`Under `,(0,Y.jsx)(`strong`,{children:`Settings → Channels`}),`, add or enable the `,(0,Y.jsx)(`strong`,{children:`Microsoft Teams`}),` channel.`]})]}),(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoftteams/platform/teams-sdk/teams/azure-configuration`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(d,{className:`w-3 h-3`}),` Official Azure Bot and Teams channel instructions`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part C — Start the included Teams Bridge`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The bridge is the Microsoft-facing service in `,(0,Y.jsx)(`code`,{children:`bridge/teams`}),`. Teams sends messages to the bridge; the bridge validates and normalizes them, then sends governed commands to Shogun. The bridge requires `,(0,Y.jsx)(`strong`,{children:`Node.js 22 or newer`}),`.`]}),(0,Y.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-[#050508] border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Bridge environment values`}),(0,Y.jsx)(`pre`,{className:`text-[10px] text-indigo-300 whitespace-pre-wrap overflow-x-auto`,children:`tenantId= +clientId= +clientSecret= +SHOGUN_INTERNAL_API_URL=http://:8000 +SHOGUN_INTERNAL_API_KEY=`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-[#050508] border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Install and start`}),(0,Y.jsx)(`pre`,{className:`text-[10px] text-indigo-300 whitespace-pre-wrap overflow-x-auto`,children:`cd bridge/teams +npm install +npm run build +npm start`})]})]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Set the same `,(0,Y.jsx)(`code`,{children:`SHOGUN_INTERNAL_API_KEY`}),` in the operating-system environment for both Shogun and the bridge, then restart both. Do not commit this key to source control.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:`SHOGUN_INTERNAL_API_URL`}),` must be an address the bridge can reach. If both run on one computer, `,(0,Y.jsx)(`code`,{children:`http://127.0.0.1:8000`}),` is normally correct.`]}),(0,Y.jsxs)(`li`,{children:[`The bridge listens on port `,(0,Y.jsx)(`code`,{children:`3978`}),`. Put it behind a public HTTPS reverse proxy or a controlled development tunnel.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`code`,{children:`https://YOUR-BRIDGE-HOST/api/teams/health`}),`. A JSON response with status `,(0,Y.jsx)(`code`,{children:`ok`}),` confirms the bridge is reachable.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part D — Complete Katana's Setup Wizard`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Open `,(0,Y.jsx)(`strong`,{children:`The Katana → Microsoft Teams → Setup Wizard`}),` and use these values:`]}),(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left bg-shogun-bg text-shogun-subdued`,children:[(0,Y.jsx)(`th`,{className:`p-3`,children:`Katana field`}),(0,Y.jsx)(`th`,{className:`p-3`,children:`Recommended value`})]})}),(0,Y.jsxs)(`tbody`,{className:`divide-y divide-shogun-border text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Deployment mode`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[(0,Y.jsx)(`strong`,{children:`Customer-hosted Teams Bridge`}),` for production; Local development + tunnel for a pilot.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Tenant mode`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[(0,Y.jsx)(`strong`,{children:`Single tenant`}),`.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Allowed tenant IDs`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The Directory (tenant) ID from Entra. Enter one ID per line.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Bot / App ID`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The Application (client) ID from Entra.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Bot display name`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`A friendly name such as `,(0,Y.jsx)(`code`,{children:`Shogun`}),`.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Secret reference`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`A reference such as `,(0,Y.jsx)(`code`,{children:`vault://teams/bot-client-secret`}),`, never the secret value. The actual credential is injected into the bridge runtime.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Public messaging endpoint`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[(0,Y.jsx)(`code`,{children:`https://YOUR-BRIDGE-HOST/api/messages`}),` — exactly the same URL configured on the Azure Bot.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Valid domains`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`Hostname only, for example `,(0,Y.jsx)(`code`,{children:`teams-bridge.example.com`}),`. Do not include `,(0,Y.jsx)(`code`,{children:`https://`}),` or a path.`]})]})]})]})}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Save configuration`}),`.`]}),(0,Y.jsx)(`li`,{children:`Keep SSO, Microsoft Graph, and Proactive messaging disabled for the first test.`}),(0,Y.jsx)(`li`,{children:`Under Security Policy, keep destructive commands disabled and dual approval enabled.`}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Enable adapter`}),`. Overview should become Production ready or show a specific missing item.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part E — Generate and install the Teams app`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Generate Teams app package`}),`. Shogun downloads `,(0,Y.jsx)(`code`,{children:`shogun-teams-app.zip`}),`. Do not unzip it.`]}),(0,Y.jsxs)(`li`,{children:[`For a personal pilot, open Teams and choose `,(0,Y.jsx)(`strong`,{children:`Apps → Manage your apps → Upload an app → Upload a custom app`}),`. Select the ZIP, then choose `,(0,Y.jsx)(`strong`,{children:`Add`}),` and `,(0,Y.jsx)(`strong`,{children:`Open`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`If Upload a custom app is missing, a Teams administrator must allow it or upload the ZIP centrally at`,(0,Y.jsx)(`a`,{href:`https://admin.teams.microsoft.com`,target:`_blank`,rel:`noreferrer`,className:`text-indigo-400 hover:underline`,children:` Teams admin center`}),` under `,(0,Y.jsx)(`strong`,{children:`Teams apps → Manage apps → Upload new app`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`For a team or channel, install the app in that team too. In channel messages, directly mention `,(0,Y.jsx)(`code`,{children:`@Shogun`}),` before the command.`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/deploy-and-publish/apps-upload`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(d,{className:`w-3 h-3`}),` Upload a custom app in Teams`]}),(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoftteams/teams-custom-app-policies-and-settings`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(d,{className:`w-3 h-3`}),` Teams administrator app policies`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part F — Test in the right order`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Open a personal chat with the installed Shogun app. The welcome message should say Shogun is connected.`}),(0,Y.jsxs)(`li`,{children:[`Send `,(0,Y.jsx)(`code`,{children:`help`}),`, then `,(0,Y.jsx)(`code`,{children:`status`}),`. These are safe first commands for a new Viewer identity.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Katana → Microsoft Teams → Entra & Roles`}),`. Your identity should appear after the first message.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Audit Log`}),`. The commands should have timestamps, authorization results, and correlation IDs.`]}),(0,Y.jsxs)(`li`,{children:[`Under `,(0,Y.jsx)(`strong`,{children:`Diagnostics`}),`, run Shogun backend and Teams manifest. Test Graph and proactive messaging only after configuring those features.`]}),(0,Y.jsxs)(`li`,{children:[`Finally test a channel with `,(0,Y.jsx)(`code`,{children:`@Shogun status`}),`. A plain `,(0,Y.jsx)(`code`,{children:`status`}),` without the mention may be ignored.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Teams troubleshooting`}),(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left bg-shogun-bg text-shogun-subdued`,children:[(0,Y.jsx)(`th`,{className:`p-3`,children:`What you see`}),(0,Y.jsx)(`th`,{className:`p-3`,children:`What to check`})]})}),(0,Y.jsxs)(`tbody`,{className:`divide-y divide-shogun-border text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`The app cannot be uploaded`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Ask the Teams administrator to enable custom app upload or upload the ZIP in Teams admin center. Regenerate the ZIP after changing App ID, valid domains, or SSO.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Bot sends no reply`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`Check bridge health, confirm Azure Bot uses the exact `,(0,Y.jsx)(`code`,{children:`/api/messages`}),` HTTPS endpoint, and confirm the Teams channel is enabled.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`“Shogun is unreachable”`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The bridge is online but cannot reach Shogun. Check the internal API URL, network/firewall access, and that both processes use the same internal API key.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Unauthorized or silent command`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Compare the tenant with Allowed tenant IDs. In a channel, mention the bot and ensure the app is installed in that team.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Only safe commands work`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`This is expected for new Viewer identities. An administrator must deliberately assign a higher Shogun role and command policy.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Authentication stopped later`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The client secret may have expired. Replace it in the bridge's secret store, restart the bridge, and retire the old secret.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Proactive messages disappear after restart`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The included bridge uses in-memory storage for development. Production needs Azure Blob or Cosmos-backed Agents SDK storage, and the user must contact the bot once first.`})]})]})]})})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg border border-green-400/20 bg-green-400/5`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-green-400`,children:`Setup is complete when all six statements are true`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued mt-2 ml-4 list-disc space-y-1.5`,children:[(0,Y.jsxs)(`li`,{children:[`The bridge health URL returns status `,(0,Y.jsx)(`code`,{children:`ok`}),`.`]}),(0,Y.jsx)(`li`,{children:`Katana Overview reports the adapter as ready with the correct tenant.`}),(0,Y.jsx)(`li`,{children:`The Teams app installs without a manifest error.`}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:`help`}),` and `,(0,Y.jsx)(`code`,{children:`status`}),` receive replies in a personal chat.`]}),(0,Y.jsx)(`li`,{children:`The user appears under Entra & Roles and the command appears in Audit Log.`}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:`@Shogun status`}),` works in every team/channel where the app was intentionally installed.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-archives`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(G,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Archives — The Memory Vault`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Everything the Shogun has ever learned, remembered, or been told.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-gold`}),` Semantic Search Bar`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Type a question or topic and the system finds matching memories using AI-powered "meaning" search — not just keyword matching. For example, searching "customer complaints" can also return memories about "user feedback" or "product issues." Results are ranked by relevance.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-shogun-gold`}),` Memory Types`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Memories are categorized into types:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Semantic:`}),` Facts and knowledge (e.g., "The capital of France is Paris").`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Episodic:`}),` Experiences and events (e.g., "User asked about pricing on April 15").`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Procedural:`}),` How-to instructions and workflows.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Persona:`}),` Durable identity, relationship, and communication context.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Skills:`}),` Canonical achieved-skill content synchronized from the Dojo.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Programming:`}),` Reusable coding solutions with evidence, validation, files, languages, and sources.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-shogun-gold`}),` Salience Score`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Each memory has relevance and importance signals that influence retrieval. Frequently reused memories can be reinforced, while decay policies control retention: `,(0,Y.jsx)(`strong`,{children:`fast`}),`, `,(0,Y.jsx)(`strong`,{children:`medium`}),`, `,(0,Y.jsx)(`strong`,{children:`slow`}),`, `,(0,Y.jsx)(`strong`,{children:`sticky`}),`, or `,(0,Y.jsx)(`strong`,{children:`pinned`}),`. Pin critical memories to keep them at maximum priority.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-shogun-gold`}),` Inscribe Memory (+ Button)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click the "+" button to manually add a new memory. You choose the `,(0,Y.jsx)(`strong`,{children:`type`}),` (semantic, episodic, etc.), write the `,(0,Y.jsx)(`strong`,{children:`content`}),`, and optionally set the `,(0,Y.jsx)(`strong`,{children:`salience`}),`. This is useful for injecting facts, rules, or context that the AI should always know about.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-gold`}),` Browse, Filter & Lifecycle`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Filter by memory type, decay policy, or agent, then sort chronologically or by salience/importance. Each card exposes its content, provenance, scores, dates, and tags. Normal memories move to the archive instead of being hard-deleted; Programming memories use an explicit permanent-delete action.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-shogun-gold`}),` Import & Export`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Import Memories`}),` accepts OpenClaw exports, Shogun exports, and generic Markdown from files, ZIP archives, or folders. It parses input as inert data, validates a preview, reports duplicates/conflicts, supports embedding retries and rollback, and blocks ZIP path traversal.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Export Memory`}),` creates an OpenClaw-compatible Markdown bundle. Scope and filter by agent, project, memory type, date, and minimum importance; optionally include archived, private, sticky, analysis, raw, or secret-bearing content. Sensitive exports require confirmation and remain available in export history.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-shogun-gold/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(i,{className:`w-4 h-4 text-shogun-gold`}),` Self-Reinforced Learning`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In Mission Mode, Shogun is instructed to proactively retain durable guidance when you explicitly correct it, tool use reveals verified information likely to help future work, or you confirm a reusable decision, preference, or idea. It must avoid transient, speculative, duplicated, sensitive, or task-local material and record source and confidence where applicable.`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Two cases also have dedicated automatic capture: explicit operator corrections become durable semantic memories, and completed Mado web research becomes a sourced procedural memory. Existing matches are reused or reinforced instead of blindly duplicated. Governed Chat mechanically captures explicit corrections but cannot browse or use Mission tools.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-dojo`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(r,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Dojo — The Training Hall`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Browse, study, and certify your agents on 4,000+ skills. Has 4 tabs.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-gold`}),` Catalog Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The default tab. Shows every available skill from the OpenClaw College database. Each skill shows its `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`risk tier`}),` (Low, Medium, High, Critical), and faculty category. A sidebar shows faculty categories in a collapsible tree — click a category to filter skills. Use the search bar to find specific skills by name. Click any skill to see its full training literature.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(S,{className:`w-4 h-4 text-shogun-gold`}),` Bundles Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Skills grouped into themed bundles (e.g., "Web Security Fundamentals," "Data Analysis Pack"). Each bundle card shows the bundle name, number of skills included, average difficulty, and a description. Click a bundle to expand it and see all the skills it contains.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-shogun-gold`}),` Specializations Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Higher-level groupings that combine multiple bundles into a career-path style progression. Think of these as "majors" — completing a specialization means your agent is deeply trained in an entire domain.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-shogun-gold`}),` Achieved Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shows all the certifications your agents have already passed. Each entry shows the skill name, exam score, pass/fail status, and date achieved. Achieved skills are synchronized into the Archives `,(0,Y.jsx)(`strong`,{children:`Skills`}),` memory layer so their canonical instructions can participate in runtime retrieval.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-gold`}),` Skill Detail & Exams`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When you click a skill, its detail pane shows canonical training content, source material, and risk tier plus a `,(0,Y.jsx)(`strong`,{children:`Take Exam`}),` action. Canonical skill content is structured as an operational instruction foundation: purpose, use conditions, inputs, workflow, decision rules, outputs, safety constraints, failure handling, examples, and success criteria. Exams contain 30–50 multiple-choice questions; passing certifies the agent and records the achievement.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-kaizen`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(P,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Kaizen — The Constitutional Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Define the fundamental laws and ethical boundaries for all agents. Has 2 tabs.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-gold`}),` Constitution Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A full-screen YAML code editor where you write the "Constitution" — the AI's core laws. The system validates the YAML in real time (green dot = correct syntax, red = error with details). On the right sidebar, `,(0,Y.jsx)(`strong`,{children:`Active Principles`}),` are extracted from the YAML and shown as colored cards: red (Critical), orange (High), gold (Balanced), blue (Medium), green (Low). Click `,(0,Y.jsx)(`strong`,{children:`"Publish Edicts"`}),` to save your changes — a new revision is created automatically.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-gold`}),` The Mandate Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A Markdown editor for writing the Shogun's "Mission Statement." This is a free-form document defining objectives and operating principles. Use the `,(0,Y.jsx)(`strong`,{children:`Edit/Preview`}),` toggle to switch between writing mode and rendered mode. Key sections of this document are automatically injected into the AI's system prompt on every interaction, so if you write "Always respond in Danish" here, the AI will obey.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(w,{className:`w-4 h-4 text-shogun-gold`}),` Revision History`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`On the right sidebar (both tabs). Shows a timeline of every saved version of the Constitution or Mandate. Each entry shows the version number, change summary, and date. The most recent version is highlighted.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-shogun-gold`}),` Download Audit Log`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`At the bottom of the sidebar. Downloads a JSON file containing the full audit history of all governance changes. Useful for compliance or reviewing what rules were changed and when.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-bushido`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(w,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Bushido — The Reflection Engine`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Automated self-improvement cycles where the AI analyzes its own performance.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-blue`}),` Calibration Controls`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Three dials that control the Shogun's self-improvement behavior: `,(0,Y.jsx)(`strong`,{children:`Reflection Frequency`}),` (how often the system thinks about its own performance), `,(0,Y.jsx)(`strong`,{children:`Consolidation Threshold`}),` (when to compress old memories), and `,(0,Y.jsx)(`strong`,{children:`Exploration Budget`}),` (how willing the system is to try new approaches). Each has a slider and a plain-English description.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-shogun-blue`}),` Insight Stream`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A live feed of AI-generated suggestions. The system autonomously analyzes its own behavior and posts insights like "Model X is 2x faster for code tasks" or "Memory #412 hasn't been used in 30 days — consider archiving." Each insight has a severity badge and a timestamp.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(w,{className:`w-4 h-4 text-shogun-blue`}),` Reflection Trigger`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A button to manually trigger a reflection cycle. The system will analyze recent interactions, evaluate model performance, check memory health, and produce a set of actionable insights. Results appear in the Insight Stream.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-mado`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-cyan-400/40 pb-3`,children:[(0,Y.jsx)(t,{className:`w-6 h-6 text-cyan-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Mado — The Browser Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Secure browser automation. Your AI can browse the web, extract content, and take screenshots.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-4 h-4 text-cyan-400`}),` Browse Web`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Shogun can navigate to any URL using the `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),` native skill. It loads the full page via Playwright (a real browser engine), then extracts the content as readable text or raw HTML. You can optionally pass a CSS selector to target a specific element on the page.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-cyan-400`}),` Screenshots`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`After navigating to a page, the Shogun can take a screenshot using `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`take_screenshot`}),`. Choose between viewport-only or full-page capture. Screenshots are saved locally and can be used in mission reports or sent via Telegram.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-cyan-400`}),` Security Integration`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Mado respects the active Torii tier or custom policy as enforced by ToolGate. Browser automation must be enabled in that policy's capability boundaries. In `,(0,Y.jsx)(`strong`,{children:`SHRINE`}),` tier, Mado is disabled entirely. In `,(0,Y.jsx)(`strong`,{children:`GUARDED`}),`, it's limited to 1 session with no downloads or uploads. In `,(0,Y.jsx)(`strong`,{children:`TACTICAL`}),` and above, broader Mado features can be available.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-cyan-400`}),` Session Management`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Browser sessions are managed automatically. When Shogun shuts down, all active Playwright browser instances are cleanly closed. The Mado page in the sidebar shows the current session status and lets you manually manage active browser contexts.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-cyan-400`}),` One Permission Authority`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Torii selects the governing tier or custom policy; ToolGate is the runtime permission authority for Mado. The active policy controls browser access, headless or visible mode, autonomous browsing, uploads, downloads, and session limits. Mado remains an operational console for runtime health, screenshots, resets, and diagnostics—it does not maintain a second permission system.`})]})]}),(0,Y.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-cyan-400 uppercase tracking-widest pl-1 border-l-2 border-cyan-400/40 ml-1`,children:`Practical How-To Guide — Using Mado Step by Step`}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-cyan-400 font-mono text-sm`,children:`01`}),` First-Time Setup — Install Chromium`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Before Mado can work, you need the browser engine. This is a `,(0,Y.jsx)(`strong`,{children:`one-time setup`}),`:`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsxs)(`li`,{children:[`Navigate to `,(0,Y.jsx)(`strong`,{children:`Mado`}),` in the sidebar.`]}),(0,Y.jsxs)(`li`,{children:[`If Chromium is not installed, you'll see a `,(0,Y.jsx)(`strong`,{children:`"Install Chromium"`}),` button in the top-right corner.`]}),(0,Y.jsx)(`li`,{children:`Click it. The system will download and install Playwright + Chromium (1–2 minutes depending on connection).`}),(0,Y.jsxs)(`li`,{children:[`Once complete, the badge changes to a green `,(0,Y.jsx)(`strong`,{children:`"Chromium Ready"`}),` indicator with the version number.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Security Note:`}),` Mado must be enabled in the active policy's browser capability boundary in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`. The built-in `,(0,Y.jsx)(`strong`,{children:`SHRINE`}),` policy disables Mado. `,(0,Y.jsx)(`strong`,{children:`GUARDED`}),` allows one session with no downloads or uploads. `,(0,Y.jsx)(`strong`,{children:`TACTICAL`}),` and higher tiers can expose broader features, subject to the active policy's ToolGate rules.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-cyan-400 font-mono text-sm`,children:`02`}),` Let Shogun Manage the Browser`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`You do not need to create browser sessions manually. Shogun creates its managed browser profile automatically the first time a governed task calls `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),`.`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsxs)(`li`,{children:[`Select the tier or custom policy in `,(0,Y.jsx)(`strong`,{children:`Torii`}),`, then review browser permissions in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`.`]}),(0,Y.jsx)(`li`,{children:`Ask Shogun to browse, or run an AgentFlow containing a Mado Browser node.`}),(0,Y.jsxs)(`li`,{children:[`Use `,(0,Y.jsx)(`strong`,{children:`Mado → Overview`}),` to inspect the managed session.`]}),(0,Y.jsxs)(`li`,{children:[`Use `,(0,Y.jsx)(`strong`,{children:`Reset`}),` only when the browser needs a clean profile.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Advanced diagnostics`}),` lists runtime sessions and storage paths without adding another security configuration layer.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-emerald-400 font-mono text-sm`,children:`A`}),` Scenario: Browse the Web via Chat`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The easiest way to use Mado — just ask your Shogun in the chat. Behind the scenes, it uses the `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),` native skill.`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-cyan-400/80 font-bold uppercase tracking-widest`,children:`Example Chat Prompts`}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Browse https://news.ycombinator.com and give me the top 5 stories"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Go to https://example.com/pricing and extract the pricing table"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Visit https://github.com/trending and summarize what's popular today"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Browse https://weather.com and tell me the forecast for Copenhagen"`})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`What happens:`}),` The Shogun launches a headless browser session (if not already running), navigates to the URL, auto-accepts cookie consent walls (Google/YouTube), extracts the page content as text, and returns it in the chat — up to 20,000 characters.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Targeting specific content:`}),` Add a CSS selector to extract only what you need:`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono bg-shogun-bg rounded px-2 py-1`,children:`"Browse https://en.wikipedia.org/wiki/Shogun and extract the text from the #mw-content-text selector"`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-emerald-400 font-mono text-sm`,children:`B`}),` Scenario: Screenshot a Web Page`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`After browsing to a page, you can ask the Shogun to take a screenshot:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-cyan-400/80 font-bold uppercase tracking-widest`,children:`Example Chat Sequence`}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`1. "Browse https://my-dashboard.example.com/analytics"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`2. "Now take a screenshot of this page"`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-text font-mono`,children:[`3. "Take a full-page screenshot" `,(0,Y.jsx)(`span`,{className:`text-shogun-subdued`,children:`(captures entire scrollable page)`})]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Screenshots are saved to the `,(0,Y.jsx)(`strong`,{children:`Mado → Screenshots`}),` tab with a timestamp. You can view all captured images there. Files are stored at `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`data/mado/screenshots/`}),`.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-violet-400 font-mono text-sm`,children:`C`}),` Scenario: Inspecting Browser Operations`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Use the Mado console to inspect browser work while ToolGate remains responsible for runtime permissions:`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Overview:`}),` Check Chromium, agent-browser health, and session count.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Screenshots:`}),` Review evidence captured by chat and AgentFlow tasks.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Advanced:`}),` Inspect runtime sessions and storage paths, or remove stale sessions.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Torii:`}),` Select the tier or custom policy. `,(0,Y.jsx)(`strong`,{children:`ToolGate:`}),` Inspect or change its browser capability boundaries and runtime rules.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Design principle:`}),` Torii selects the policy, ToolGate governs runtime permission, and Mado shows browser operations.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-violet-400 font-mono text-sm`,children:`D`}),` Scenario: Multi-Step Automation with Agent Flow`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`For complex workflows, combine Mado with Agent Flow — the visual workflow builder:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-cyan-400/80 font-bold uppercase tracking-widest`,children:`Example: Daily Competitor Price Check`}),(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-shogun-subdued`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Input Node →`}),` "Check competitor prices"`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Mado Browser Node →`}),` Navigate to competitor's pricing page`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Samurai Node →`}),` "Analyze the pricing data and compare to our current prices"`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Logic Node →`}),` If prices changed → proceed, else → skip`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Samurai Node →`}),` "Draft a summary email of pricing changes"`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Output Node →`}),` Final report`]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`The `,(0,Y.jsx)(`strong`,{children:`Mado Browser node`}),` in Agent Flow supports: navigate to a URL, extract content (text/HTML), and take screenshots. Chain it with Samurai nodes for AI analysis and Logic nodes for conditional routing.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-amber-400 font-mono text-sm`,children:`E`}),` Scenario: Filling Forms & Clicking Elements`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Mado supports full interaction with web pages — not just reading them. Via the API, you can:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Fill forms:`}),` Provide a list of `,(0,Y.jsxs)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:[`{`,`selector, value, type`,`}`]}),` objects. Supports text inputs, dropdowns (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`select`}),`), and checkboxes.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Click elements:`}),` Click any element by CSS selector — buttons, links, menu items.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Wait for elements:`}),` Pause until a specific CSS selector appears on the page (with configurable timeout).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Execute JavaScript:`}),` Run custom JS scripts on the page for advanced extraction or interaction.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Upload files:`}),` Upload a local file to a file input element (requires TACTICAL tier or higher).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Download files:`}),` Capture a triggered download and save it locally (requires TACTICAL tier or higher).`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[`These actions are available through the REST API at `,(0,Y.jsxs)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:[`/api/v1/mado/sessions/`,`{`,`session_id`,`}`,`/fill-form`]}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/click`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/wait`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/execute-js`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/upload`}),`, and `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/download`}),`.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-amber-400 font-mono text-sm`,children:`F`}),` Scenario: Generating PDFs from Web Pages`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Mado can convert any web page to a PDF document — useful for archiving, reports, or compliance evidence:`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsx)(`li`,{children:`Navigate to the page you want to convert (via chat, AgentFlow, or API).`}),(0,Y.jsxs)(`li`,{children:[`Call the PDF endpoint: `,(0,Y.jsxs)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:[`POST /api/v1/mado/sessions/`,`{`,`session_id`,`}`,`/pdf`]})]}),(0,Y.jsxs)(`li`,{children:[`The PDF is generated in A4 format with background colors and saved to `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`data/mado/downloads/`}),`.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Note:`}),` PDF generation only works in `,(0,Y.jsx)(`strong`,{children:`headless`}),` mode (Chromium limitation).`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-cyan-400 font-mono text-sm`,children:`💡`}),` Understanding Browser Profiles`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Each session has a `,(0,Y.jsx)(`strong`,{children:`profile`}),` — a persistent directory on disk that stores cookies, local storage, cache, and login sessions. This means:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Logins persist:`}),` If you log into a website in session "research_agent", next time you use that profile, you're still logged in.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Isolation:`}),` Different profiles don't share cookies or data — like using separate Chrome profiles.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Cleanup:`}),` Delete a session to close the browser. The profile data stays on disk until you manually delete it from `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`data/mado/profiles/`}),`.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Storage paths`}),` are visible under `,(0,Y.jsx)(`strong`,{children:`Mado → Advanced`}),`. The agent-managed profile is created automatically and can be reset from Overview.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-red-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-red-400`}),` Configuring Mado Permissions`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Select the tier or custom policy in `,(0,Y.jsx)(`strong`,{children:`Torii`}),`, then configure its Mado boundaries in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`. These rules apply consistently to chat, Telegram, the Mado API, and AgentFlow browser nodes. Gensui owns the same ToolGate controls when centrally managed.`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-red-400/80 font-bold uppercase tracking-widest`,children:`ToolGate Capability Boundaries`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-2 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Mado enabled:`}),` Allows or blocks browser automation entirely.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Headless only:`}),` Prevents visible browser windows at restricted postures.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Maximum sessions:`}),` Applies to API, agent-managed, and AgentFlow sessions.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Autonomous browsing:`}),` Controls unattended browser work.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Downloads and uploads:`}),` Governs file transfer through Mado.`]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Priority:`}),` Gensui-owned ToolGate policy overrides standalone ToolGate settings when fleet governance is active. Mado itself does not override either authority.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-red-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-red-400 font-mono text-sm`,children:`⚠`}),` Troubleshooting`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`"Browser automation is disabled"`}),` — The active policy's ToolGate boundary does not allow Mado. Use `,(0,Y.jsx)(`strong`,{children:`Torii`}),` to select an appropriate tier or custom policy, then inspect `,(0,Y.jsx)(`strong`,{children:`ToolGate → Capability Boundaries`}),`. The built-in GUARDED tier allows one restricted session; TACTICAL and higher can expose broader features.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`"No active browser session"`}),` — For chat skills (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`take_screenshot`}),`), you must first use `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),` to navigate to a page.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Chromium not installed`}),` — Click "Install Chromium" on the Mado page. Requires internet access for the initial download (~200 MB).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Session shows "idle" forever`}),` — The browser launches lazily. It only starts when you perform an action (navigate, screenshot, etc.). This is normal.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Visible mode blocked`}),` — The active policy's Mado boundary may enforce headless-only browsing. Campaign- or Ronin-based policies can permit visible sessions when ToolGate enables them.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-ronin`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-orange-400/40 pb-3`,children:[(0,Y.jsx)(u,{className:`w-6 h-6 text-orange-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Ronin - Desktop Control Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Governed desktop automation: mouse, keyboard, screenshots, native apps, and OS interaction.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-red-500/10 border-red-500/30 border-l-4 border-l-red-500`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-red-500 flex items-center gap-2 mb-3`,children:[(0,Y.jsx)(E,{className:`w-5 h-5`}),`CRITICAL: Understand the Repercussions Before Enabling`]}),(0,Y.jsxs)(`div`,{className:`space-y-3 text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Ronin gives the AI direct physical control of your computer.`}),` This is not a sandboxed operation. When enabled, Shogun can move your mouse, press keys, read your screen, interact with any application, and execute OS-level commands. This is fundamentally different from browser automation (Mado), which runs in an isolated Chromium sandbox.`]}),(0,Y.jsxs)(`div`,{className:`bg-[#050508] rounded-lg p-3 border border-red-500/20 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-red-400 font-bold text-[10px] uppercase tracking-widest`,children:`What can go wrong:`}),(0,Y.jsxs)(`ul`,{className:`ml-4 list-disc space-y-1.5`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Data Loss:`}),` The AI can click Delete buttons, overwrite files, or drag items to trash. At CAMPAIGN/RONIN tier, file deletion is allowed or only requires approval but mistakes happen in milliseconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Credential Exposure:`}),` If the AI types into a password field, opens a password manager, or interacts with banking/crypto apps your credentials could be exposed, logged, or transmitted. At RONIN tier, credential entry is ALLOWED with no gate.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Financial Damage:`}),` The AI can click purchase buttons, submit orders, confirm transactions, or interact with trading platforms. There is no undo for financial actions.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Software Installation:`}),` At CAMPAIGN tier, software installation requires approval. At RONIN tier, the AI can download and install arbitrary software without asking.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Admin Escalation:`}),` At RONIN tier, admin escalation is enabled. The AI can accept UAC prompts, run as administrator, and modify system settings.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`External Data Upload:`}),` The AI can open a browser, paste sensitive data, and upload it to external services. At RONIN tier, this is ALLOWED without approval.`]})]})]}),(0,Y.jsx)(`p`,{className:`text-red-400 font-bold`,children:`Rule of thumb: If you would not give a stranger unsupervised access to your desktop, do not enable CAMPAIGN or RONIN posture on that machine.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-orange-400`}),` Posture Levels`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Ronin has four posture levels. The active posture is set in Torii → Security Posture and shown in the Ronin header.`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-[#7a8899] bg-[#7a8899]/10 px-2 py-0.5 rounded`,children:`DISABLED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`No desktop access at all. Shrine and Guarded tiers.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-blue bg-shogun-blue/10 px-2 py-0.5 rounded`,children:`OBSERVE ONLY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Screenshots and window listing only. Read-only.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`BROWSER ONLY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Playwright/Mado browser control only. No desktop.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 bg-orange-400/10 px-2 py-0.5 rounded`,children:`DESKTOP LIMITED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Mouse, keyboard, screenshots. No native apps, no shell, no admin. Tactical tier.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`DESKTOP FULL`}),(0,Y.jsxs)(`span`,{className:`text-xs text-shogun-subdued`,children:[`Full control: native apps, shell commands, admin escalation. Campaign/Ronin tier.`,` `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`DANGEROUS.`})]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4 text-orange-400`}),` Where to Configure`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Torii selects the governing tier or custom policy. Its inherited desktop ceiling and explicit Ronin boundaries are shown and governed in ToolGate; Ronin cannot widen them from its operational console.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE / GUARDED:`}),` Ronin is disabled. No desktop control at all.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL:`}),` Ronin is desktop_limited. Mouse + keyboard + screenshots. 1 session max. Dangerous actions blocked.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` Ronin is desktop_full. Native apps + shell. 5 sessions max. Dangerous actions require approval.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN:`}),` Ronin is desktop_full. Everything allowed. 10 sessions. Admin escalation enabled. `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`No safety gates. VM only recommended.`})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`After selecting a tier, the Ronin constraints appear in the Current Constraints card on the left side of Torii (Ronin Desktop, Ronin Sessions, Mouse/Keyboard).`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-orange-400`}),` Application Trust Levels`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every application on your OS is classified into one of four trust levels. The Posture Guard evaluates: Agent + Posture + App Trust + Environment = Decision.`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`TRUSTED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`VS Code, Notepad, Calculator, Shogun. Safe to interact.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-yellow-400 bg-yellow-400/10 px-2 py-0.5 rounded`,children:`RESTRICTED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Chrome, Excel, PowerPoint. Some caution required.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 bg-orange-400/10 px-2 py-0.5 rounded`,children:`SENSITIVE`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Outlook, SAP, Salesforce, CRM. Requires elevated posture.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`FORBIDDEN`}),(0,Y.jsxs)(`span`,{className:`text-xs text-shogun-subdued`,children:[`Password managers, banking apps, crypto wallets. `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Always blocked, no override.`})]})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The trust registry comes pre-populated with 50+ applications. View and filter them on the App Trust tab in Ronin.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-red-400`}),` Komainu Guardian (Physical Override)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Komainu is a hardware-level safety mechanism. It monitors for human mouse and keyboard activity and can instantly override the AI. Three levels:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-yellow-400 bg-yellow-400/10 px-2 py-0.5 rounded`,children:`LEVEL 1: PAUSE`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Any human input pauses the active Ronin session. Resume manually.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 bg-orange-400/10 px-2 py-0.5 rounded`,children:`LEVEL 2: TERMINATE`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Any human input kills the active session immediately.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`LEVEL 3: HARAKIRI`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Any human input triggers full emergency stop for all sessions and agents.`})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Triple-Escape`}),` (press Escape 3 times rapidly) is a hard-coded Level 3 trigger that cannot be disabled, overridden, or circumvented. It always triggers Harakiri.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-orange-400`}),` Capabilities Registry`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`20+ registered actions organized by category. Each has a risk level, minimum posture requirement, and an approval flag. View them on the Capabilities tab in Ronin.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Desktop:`}),` screenshot, click, move_mouse, type, hotkey, locate_image, read_screen`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Browser:`}),` open, click, type, extract, screenshot (bridges to Mado)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`OS:`}),` list_windows, focus_window, get_foreground_app`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(x,{className:`w-4 h-4 text-orange-400`}),` Environment Detection`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Ronin automatically detects the environment type at startup. This affects which posture policies are allowed.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Physical Machine:`}),` Your real hardware. Highest risk surface.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`VM:`}),` VirtualBox, VMware, Hyper-V. Recommended for full desktop posture.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Sandbox:`}),` Windows Sandbox, Docker. Safe for testing.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Remote Desktop:`}),` RDP sessions. Higher latency, lower risk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Citrix / Cloud Workspace:`}),` Enterprise environments. Policy may be enforced by Gensui.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-4 border-l-red-500`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4 text-red-400`}),` Tier-by-Tier Ronin Repercussions`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`This table shows exactly what the AI can do at each security tier. `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Read this carefully before changing your posture.`})]}),(0,Y.jsx)(`div`,{className:`bg-shogun-bg rounded-lg overflow-hidden border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border`,children:[(0,Y.jsx)(`th`,{className:`text-left p-2.5 text-shogun-subdued font-bold uppercase tracking-widest text-[10px]`,children:`Dangerous Action`}),(0,Y.jsx)(`th`,{className:`text-center p-2.5 text-shogun-blue font-bold uppercase tracking-widest text-[10px]`,children:`Tactical`}),(0,Y.jsx)(`th`,{className:`text-center p-2.5 text-orange-400 font-bold uppercase tracking-widest text-[10px]`,children:`Campaign`}),(0,Y.jsx)(`th`,{className:`text-center p-2.5 text-red-400 font-bold uppercase tracking-widest text-[10px]`,children:`Ronin`})]})}),(0,Y.jsxs)(`tbody`,{className:`text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Credential Entry`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`File Deletion`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`External Uploads`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Software Install`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Native App Interaction`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Shell Commands`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-2.5 font-bold text-red-400`,children:`Admin Escalation (UAC)`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]})]})]})}),(0,Y.jsx)(`p`,{className:`text-xs text-red-400 font-bold leading-relaxed`,children:`At RONIN tier, every dangerous action is allowed WITHOUT operator approval. This means the AI can delete files, enter credentials, install software, and escalate to admin autonomously. Only use RONIN tier in fully isolated, disposable environments (VMs, sandboxes).`})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4 text-orange-400`}),` Dashboard Tabs`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Ronin page has 5 tabs:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Control:`}),` Status cards, environment detection panel, and a Quick Action executor for manual desktop commands.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Sessions:`}),` Create and manage desktop sessions. Choose posture level and Komainu guardian level per session.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`App Trust:`}),` View the pre-classified trust registry. Filter by trust level.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Capabilities:`}),` View all registered desktop actions with risk levels and posture requirements.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Audit Trail:`}),` Chronological feed of all Ronin events with severity coloring.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(oe,{className:`w-4 h-4 text-red-400`}),` Emergency Controls`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Multiple layers of emergency shutdown:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`STOP Button:`}),` The red skull button in the Ronin header. Triggers Harakiri.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Triple-Escape:`}),` Press Escape 3 times rapidly. Hard-coded, cannot be disabled.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-yellow-400`,children:`Komainu Override:`}),` Any human mouse or keyboard input triggers the configured level.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Torii Harakiri:`}),` The global kill switch on the Torii page. Stops everything system-wide.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-office`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-green-400/40 pb-3`,children:[(0,Y.jsx)(f,{className:`w-6 h-6 text-green-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Office App Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Controlled Microsoft Office automation — Excel, Word, PowerPoint, Outlook.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-green-400`}),` Overview`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Office App Mode (codename Katana) lets the AI agent read, modify, and create Excel workbooks, Word documents, PowerPoint presentations, and Outlook emails — all within strict security boundaries. It uses a hybrid architecture: pure Python libraries handle most operations cross-platform. COM automation is only used for PDF export, formula calculation, and Outlook.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-green-500/10 border-green-500/30 border-l-4 border-l-green-500 space-y-3`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-green-400 flex items-center gap-2`,children:[(0,Y.jsx)(s,{className:`w-5 h-5`}),` Getting Started`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-decimal`,children:[(0,Y.jsx)(`li`,{children:`Navigate to Sidebar → Office (under Capabilities).`}),(0,Y.jsx)(`li`,{children:`Enable Office App Mode with the master toggle.`}),(0,Y.jsx)(`li`,{children:`Configure all four folders — input, output, templates, and temp.`}),(0,Y.jsx)(`li`,{children:`Toggle individual apps — enable only what you need.`}),(0,Y.jsx)(`li`,{children:`Save your configuration.`}),(0,Y.jsx)(`li`,{children:`The 27 Office tools are now available to the agent in chat.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-green-400`}),` Approved Folders`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every file operation is validated against four folder boundaries (input, output, templates, temp). Files outside are rejected. Path traversal, UNC paths, and .lnk shortcuts are blocked.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-green-400`}),` Output Versioning`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The agent never overwrites originals. Every save creates a timestamped copy (e.g. report_20260630_094500.xlsx). Old outputs are cleaned after the retention period (default: 30 days).`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(f,{className:`w-4 h-4 text-green-400`}),` Excel (8 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Open workbook`}),(0,Y.jsx)(`li`,{children:`Read range / all cells`}),(0,Y.jsx)(`li`,{children:`Write range`}),(0,Y.jsx)(`li`,{children:`List sheets`}),(0,Y.jsx)(`li`,{children:`Save as (versioned)`}),(0,Y.jsx)(`li`,{children:`Export PDF (COM)`}),(0,Y.jsx)(`li`,{children:`Recalculate (COM)`}),(0,Y.jsx)(`li`,{children:`Get metadata`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-blue-400`}),` Word (6 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Open document`}),(0,Y.jsx)(`li`,{children:`Replace placeholders`}),(0,Y.jsx)(`li`,{children:`Insert table`}),(0,Y.jsx)(`li`,{children:`Save as (versioned)`}),(0,Y.jsx)(`li`,{children:`Export PDF (COM)`}),(0,Y.jsx)(`li`,{children:`Get metadata`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-orange-400`}),` PowerPoint (7 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Open presentation`}),(0,Y.jsx)(`li`,{children:`Replace placeholders`}),(0,Y.jsx)(`li`,{children:`Insert table`}),(0,Y.jsx)(`li`,{children:`Insert image`}),(0,Y.jsx)(`li`,{children:`Save as (versioned)`}),(0,Y.jsx)(`li`,{children:`Export PDF (COM)`}),(0,Y.jsx)(`li`,{children:`Get metadata`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-cyan-400`}),` Outlook (4 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Create draft`}),(0,Y.jsx)(`li`,{children:`Attach file`}),(0,Y.jsx)(`li`,{children:`Save + review`}),(0,Y.jsx)(`li`,{children:`Send (high-risk)`})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-cyan-400`}),` Outlook Modes`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`DRAFT ONLY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Create and save drafts. Never sends.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-yellow-400 bg-yellow-400/10 px-2 py-0.5 rounded`,children:`CONFIRMED SEND`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Can send with human approval.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`APPROVED RECIPIENTS`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Auto-send to allowlisted domains.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-green-400`}),` Security Per Posture`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE:`}),` Office completely disabled.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`GUARDED:`}),` Read, write, save-as. No overwrite, no macros, no send.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL:`}),` + Delete (approval). + Send (approval).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` + Delete (allowed). + Send (approval).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN:`}),` + Overwrite originals. Send still requires approval.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-green-400`}),` Audit Trail`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every Office operation emits an office.* event into the dual-write audit chain. Events include application, action, file paths, duration, and status. View them on the Logs page filtered by category: office.`})]})]}),(0,Y.jsxs)(`section`,{id:`ref-workspace`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-amber-400/40 pb-3`,children:[(0,Y.jsx)(m,{className:`w-6 h-6 text-amber-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Workspace — Agent File System`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`A dedicated folder where the Shogun and all Samurai agents have persistent read/write access.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-amber-400`}),` Overview`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Workspace is a single, dedicated directory where the Shogun and all Samurai agents can read, write, and manage files. It serves as the agent’s persistent “desk” — a safe location to store outputs, share data between agents, and create working documents. Availability and access mode follow the active policy's filesystem and workspace boundaries in ToolGate; the built-in Shrine policy disables it.`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Default location: data/workspace/ inside the Shogun project directory. The path is configurable via environment variable WORKSPACE_PATH.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-amber-500/10 border-amber-500/30 border-l-4 border-l-amber-500 space-y-3`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-amber-400 flex items-center gap-2`,children:[(0,Y.jsx)(s,{className:`w-5 h-5`}),` Getting Started`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-decimal`,children:[(0,Y.jsx)(`li`,{children:`Navigate to Comms (sidebar) and click the Files tab.`}),(0,Y.jsx)(`li`,{children:`The File Explorer shows the workspace tree on the left and a content viewer/editor on the right.`}),(0,Y.jsx)(`li`,{children:`Use the toolbar buttons to create new files, new folders, rename, or delete items.`}),(0,Y.jsx)(`li`,{children:`Click any file to view its content. Click Edit to modify it inline, then Save.`}),(0,Y.jsx)(`li`,{children:`In Mission Mode chat, ask the Shogun to use workspace tools — it can read, write, list, and manage files directly.`}),(0,Y.jsx)(`li`,{children:`The workspace folder is automatically created on first startup at data/workspace/.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(m,{className:`w-4 h-4 text-amber-400`}),` File Explorer (Comms → Files Tab)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The File Explorer is a tab inside the Comms page, alongside Chat, Mail, and Calendar. It provides a visual interface for managing workspace files:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Tree sidebar:`}),` Expandable directory tree with file-type icons (code, spreadsheet, image, archive, text), size labels, and real-time search filter.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Content viewer:`}),` Displays file contents with monospace formatting. Shows file path, extension, and size in the header bar.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Inline editor:`}),` Click Edit to modify any text file directly in the browser. Click Save to write changes back to disk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Create File:`}),` Click the file+ icon in the toolbar. Enter a filename. The file is created inside the currently selected folder (or workspace root).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Create Folder:`}),` Click the folder+ icon. Enter a folder name. Nested paths are created automatically.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Rename:`}),` Select an item, click the edit icon. Enter the new name and confirm.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Delete:`}),` Select an item, click the trash icon. A confirmation dialog appears. Directories are deleted recursively including all contents.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Grid view:`}),` When a directory is selected, its contents are displayed as a clickable card grid with icons and sizes.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Info footer:`}),` Shows the full workspace path, total file count, directory count, and disk usage in MB.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Drag & drop upload:`}),` Drag files from your desktop onto the File Explorer to upload them. A blue overlay indicates the drop target. Multiple files supported simultaneously.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Upload button:`}),` Click the upload icon in the toolbar to open a native file picker for selecting files to upload into the current folder.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-amber-400`}),` 6 Agent Native Tools`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In Mission Mode, the Shogun and all Samurai agents have 6 workspace tools injected as native functions. The agent sees the workspace path in its system prompt and can use these tools autonomously:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_info`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Returns workspace path, whether access is enabled, total files, total directories, and total size in MB.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_list`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Lists files and directories at a given relative path. Returns name, type, size (for files), and child count (for dirs).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_read`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Reads a text file\\u2019s content (capped at 5 MB). Returns content, size, and path. Binary files return an error.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_write`}),` `,(0,Y.jsx)(`span`,{className:`text-yellow-400`,children:`(medium risk)`}),` \\u2014 Creates or overwrites a text file. Parent directories are auto-created. Returns action (created/overwritten) and size.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_mkdir`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Creates a subdirectory with parents. Returns action (created/already_exists).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_delete`}),` `,(0,Y.jsx)(`span`,{className:`text-red-400`,children:`(high risk)`}),` \\u2014 Deletes a single file. Cannot delete directories (safety constraint via agent tools; the UI can delete dirs).`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-amber-400`}),` Path Validation & Security`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`All workspace operations — both the File Explorer UI and agent native tools — enforce strict path validation at every level:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Boundary enforcement:`}),` Every path is resolved to its absolute form and checked that it remains inside the workspace root. Any escape attempt is blocked.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Traversal blocking:`}),` Paths containing `,(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`..`}),` are rejected immediately, before any filesystem operation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Absolute path blocking:`}),` Only relative paths (from workspace root) are accepted. Paths starting with `,(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`/`}),` or `,(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`\\`}),` are rejected.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`UNC path blocking:`}),` Network paths are rejected to prevent lateral movement.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Size guard:`}),` File reads are capped at 5 MB (agent tools) or 10 MB (File Explorer UI) to prevent memory exhaustion.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Root protection:`}),` The workspace root directory itself cannot be deleted.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-amber-400`}),` Security Posture Matrix`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The workspace is a binary gate: either fully available or completely locked.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE:`}),` \\u274C Workspace completely disabled. No read, no write, no listing. All 6 tools return errors. File Explorer shows an error state with retry button.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`GUARDED:`}),` \\u2705 Full read/write access. All 6 agent tools available. File Explorer fully functional.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL:`}),` \\u2705 Full read/write access. All 6 agent tools available.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` \\u2705 Full read/write access. All 6 agent tools available.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN:`}),` \\u2705 Full read/write access. All 6 agent tools available.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(v,{className:`w-4 h-4 text-amber-400`}),` Office App Mode Alignment`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Workspace and Office App Mode share the same folder concept. The four “Approved Folders” in the Katana’s Office tab (input, output, templates, temp) can be left empty to auto-map to the workspace root directory. This means Office file operations and agent workspace tools operate in the same directory by default. Configure custom paths in the Katana → Office tab if you need separate boundaries for Office automation.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-4 h-4 text-amber-400`}),` REST API Endpoints`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The File Explorer UI uses a dedicated REST API under /api/v1/workspace/. These endpoints are also available for external integrations and custom tooling:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`GET /api/v1/workspace/info`}),` \\u2014 Metadata, path, and disk usage`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`GET /api/v1/workspace/tree`}),` \\u2014 Full recursive directory tree (JSON)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`GET /api/v1/workspace/read?path=`}),` \\u2014 Read file content as text`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`POST /api/v1/workspace/write`}),` \\u2014 Create or update file (JSON body: path, content)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`POST /api/v1/workspace/mkdir`}),` \\u2014 Create directory (JSON body: path)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`DELETE /api/v1/workspace/delete?path=`}),` \\u2014 Delete file or directory`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`POST /api/v1/workspace/rename`}),` \\u2014 Rename/move (JSON body: old_path, new_path)`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-amber-400`}),` System Prompt Integration`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When workspace is enabled, the Shogun’s system prompt includes the workspace path and available tools in two places: the ACTIVE SECURITY POSTURE block (“Workspace: ENABLED — /path/to/workspace”) and the YOUR CAPABILITIES block (listing all 6 tools by name). This ensures the agent knows where to save files and which tools it can call. At SHRINE, the prompt shows “Workspace: DISABLED (SHRINE posture)”.`})]})]}),(0,Y.jsxs)(`section`,{id:`ref-torii`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(y,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Torii — Security Portal`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Select the active built-in tier or custom posture. Custom postures are created, edited, and deleted in ToolGate, then become available here immediately.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-red-400`}),` Security Posture (Left Column)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Five clickable tiers, from safest to most dangerous:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE (MAX):`}),` Zero-trust. Local only. No external tools. Maximum safety.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`GUARDED:`}),` Restricted network. Only approved tools. Everything needs human approval.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL (DEFAULT):`}),` Balanced autonomy. The AI has scoped file access and can use approved tools on its own.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` High autonomy. Broad internet access. Agents can auto-spawn without asking.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN (UNSAFE):`}),` Unrestricted. Only use in completely isolated test environments.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Click a built-in tier or custom posture to activate it. Built-in tiers are protected presets. Use `,(0,Y.jsx)(`strong`,{children:`Manage custom postures in ToolGate`}),` to create or maintain reusable postures, then return here to choose which one is active.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-red-400`}),` Unified Posture Selector`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Built-in tiers and every custom posture from ToolGate appear in the same selection grid. The active marker reflects the policy actually enforced at runtime. Selecting a built-in tier clears any previous custom assignment; selecting a custom posture activates that policy together with its inherited base tier.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-red-400`}),` Current Constraints`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The constraints panel summarizes the effective filesystem, network, shell, skills, delegation, communications, browser, and desktop limits. For a custom posture these values come from its base tier and ToolGate capability boundaries—not from whichever posture happened to be selected previously.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-red-500`}),` Harakiri Button`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The red button in the top right of the Torii page. Same as the one on the Dashboard — activates the global kill switch. Requires two-step confirmation. Once active, all agents are frozen and the posture locks to SHRINE. Press "Reset Harakiri" to restore normal operation.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-toolgate`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-orange-400/40 pb-3`,children:[(0,Y.jsx)(H,{className:`w-6 h-6 text-orange-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`ToolGate — Runtime Permissions`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The single place to create custom postures and configure or understand what security policies permit at runtime.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-orange-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-orange-400`}),` Ownership Model`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Torii`}),` selects the active built-in tier or custom posture. `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` owns custom posture creation, editing, deletion, capability ceilings, and per-call runtime authorization. `,(0,Y.jsx)(`strong`,{children:`Katana`}),` manages installed or connected capabilities, model providers and routing, and account-specific scopes. `,(0,Y.jsx)(`strong`,{children:`Shogun Profile`}),` owns identity, behavior, and operations—not security configuration. When centrally managed, `,(0,Y.jsx)(`strong`,{children:`Gensui owns ToolGate`}),` and the local view becomes read-only.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-orange-400`}),` Custom Posture Library`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Create, edit, and delete reusable custom postures in ToolGate. Each posture has a name, description, inherited base tier, kill-switch and dry-run flags, and detailed capability boundaries. New postures appear immediately in Torii, where activation is always an explicit separate choice. Deleting an active custom posture safely returns Torii to its base tier.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-orange-400`}),` Policy-Scoped Rules`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`ToolGate always follows the currently active policy. A built-in tier uses its own scope. A custom policy uses a stable policy-specific scope and inherits its base tier's default risk mode. Switching tiers or custom policies loads that scope's own capability boundaries, tool overrides, and advanced content rules.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-orange-400`}),` Capability Boundaries & Risk`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The capability panel explains the policy ceiling for filesystem, network, shell, skills, subagents, memory, communications, workflows, browser, visual intake, IDE, and related features. The `,(0,Y.jsx)(`strong`,{children:`Capability Risk Index`}),` summarizes exposure from 0–100. Built-in presets are read-only; assigned custom policies can be edited here.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-orange-400`}),` Effective Tool Policy`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every registered tool shows its effective `,(0,Y.jsx)(`strong`,{children:`ALLOW`}),`, `,(0,Y.jsx)(`strong`,{children:`CONFIRM`}),`, or `,(0,Y.jsx)(`strong`,{children:`BLOCK`}),` verdict, risk class, source, and reason. Local overrides may narrow a standalone policy. They cannot widen an enclosing capability boundary or a centrally enforced Gensui rule.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-orange-400`}),` Simulator, Approvals & Audit`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Use the simulator to preview a tool call with its actual parameters before running it. Calls that require confirmation enter the approval queue and fail closed on denial or timeout. Decisions preserve their policy source and are written to the compliance trail.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(se,{className:`w-4 h-4 text-orange-400`}),` Advanced Content Controls`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Turn on `,(0,Y.jsx)(`strong`,{children:`Advanced mode`}),` to flag specific words or phrases inside nested tool arguments. Each rule can match a phrase anywhere or as a whole word, be case-sensitive or case-insensitive, apply to every tool or one selected tool, and return `,(0,Y.jsx)(`strong`,{children:`CONFIRM`}),` or `,(0,Y.jsx)(`strong`,{children:`BLOCK`}),`. Advanced rules are scoped to the active tier or custom policy and can only tighten the final verdict. When Gensui manages the instance, the same rules are edited centrally and remain enforced from the cached policy during temporary outages.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-nexus`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-indigo-400/40 pb-3`,children:[(0,Y.jsx)(z,{className:`w-6 h-6 text-indigo-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Nexus — The Alliance`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Inter-agent collaboration. Work with other Shogun instances across the network.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-indigo-400`}),` Identity Card (Top)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Displays your Shogun's unique ID and public key. Other Shogun instances need this to verify your messages are authentic. Click the copy icon to put your agent ID on the clipboard for sharing.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-indigo-400`}),` Workspace List (Left Column)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A list of all Joint Workspaces you have created or joined. Each card shows the workspace name, topic, and number of peer agents connected. Click a workspace to open it. Hover over a card to see the `,(0,Y.jsx)(`strong`,{children:`delete button`}),` (red X in the corner). Deleting a workspace permanently removes it and all its messages.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(S,{className:`w-4 h-4 text-indigo-400`}),` "Create Workspace" Button`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Opens a form where you enter a `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`description`}),`, and `,(0,Y.jsx)(`strong`,{children:`topic`}),` for the new workspace. After creation, you can invite other Shogun agents by providing their network URL.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-indigo-400`}),` Invite Peers`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Inside a workspace detail view, click `,(0,Y.jsx)(`strong`,{children:`"Invite Peer"`}),`. Enter the `,(0,Y.jsx)(`strong`,{children:`endpoint URL`}),` of the other Shogun (e.g., http://192.168.1.50:8000) and optionally a display name. The system will contact the remote agent, exchange identity information, and add it to the workspace.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-indigo-400`}),` A2A Message Thread`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Inside a workspace, the right panel shows all messages exchanged between agents. Messages can be typed in the compose box at the bottom. Choose a `,(0,Y.jsx)(`strong`,{children:`message type`}),` from the dropdown: "update" for status reports, "proposal" for suggestions, "approval" for sign-offs, or "task" for actionable assignments. Messages are automatically signed with your agent's identity.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-indigo-400`}),` Shared Whiteboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Below the message thread, a full-width text editor where all agents in the workspace can collaboratively write plans, code, or reports. Click `,(0,Y.jsx)(`strong`,{children:`"Edit"`}),` to enter editing mode, make your changes, then click `,(0,Y.jsx)(`strong`,{children:`"Save"`}),` to publish them to all connected peers.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-nexus-gateway`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-indigo-400/40 pb-3`,children:[(0,Y.jsx)(v,{className:`w-6 h-6 text-indigo-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Nexus External Gateway`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Bidirectional interoperability with Microsoft 365, Salesforce, Google, and ServiceNow agents. Send and receive tasks through governed A2A channels.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-indigo-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-indigo-400`}),` What Is the External Gateway?`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Nexus External Gateway enables `,(0,Y.jsx)(`strong`,{children:`bidirectional`}),` communication between Shogun and enterprise AI agents. `,(0,Y.jsx)(`strong`,{children:`Inbound:`}),` external platforms (Microsoft 365 Copilot, Salesforce Einstein/Agentforce, Google Vertex AI, ServiceNow) send tasks into Shogun for execution. `,(0,Y.jsx)(`strong`,{children:`Outbound:`}),` Shogun can dispatch tasks `,(0,Y.jsx)(`em`,{children:`to`}),` external agents — e.g. ask Salesforce to update a CRM record, ask M365 to schedule a meeting, or trigger a ServiceNow workflow. Shogun acts as an independent execution and orchestration layer that works `,(0,Y.jsx)(`em`,{children:`alongside`}),` enterprise agents, not as a replacement. No vendor SDKs, no platform lock-in. Just standard HTTP + Bearer tokens.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:`Standalone Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Shogun runs independently with local agents, models, browser control, and memory. No external connectivity needed.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-indigo-400/40`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:`Enterprise-Connected Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`External agents submit tasks via A2A, webhooks, or MCP. Shogun executes and returns results.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-red-400/40`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:`Governed Hybrid Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Both modes combined, with Gensui enforcing postures, platform allowlists, and real-time policy checks on every task.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-indigo-400`}),` Register an External Agent`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /api/v1/nexus/external/register-agent`}),` — Provide a `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`platform`}),` (e.g. microsoft_365, salesforce), optional `,(0,Y.jsx)(`strong`,{children:`endpoint_url`}),` (for outbound dispatch), and optional `,(0,Y.jsx)(`strong`,{children:`direction`}),` (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`inbound`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`outbound`}),`, or `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`bidirectional`}),`). Shogun returns a unique API token. Set `,(0,Y.jsx)(`strong`,{children:`endpoint_url`}),` to enable Shogun to dispatch tasks `,(0,Y.jsx)(`em`,{children:`to`}),` the external agent.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-indigo-400`}),` Discover Capabilities`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`GET /api/v1/nexus/capabilities`}),` — Returns the 9 default capabilities Shogun exposes (e.g. document.summarize, spreadsheet.analyze, email.draft) plus any custom-registered capabilities. External agents query this to know what they can ask for.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-indigo-400`}),` Submit a Task (A2A)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /api/v1/nexus/external/a2a/task`}),` — Send a JSON payload with the action, input context, source_agent_id, and source_platform. Shogun authenticates, policy-checks, routes to the best internal agent, executes via LLM, and returns the result.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-indigo-400`}),` Task Status & Callbacks`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`GET /external/task/id`}),` — Poll for task status (pending, executing, completed, blocked, failed). `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /external/task/id/callback`}),` — Receive async callback updates from remote systems.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-red-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-red-400`}),` Four-Layer Security Model`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every inbound task passes through four enforcement layers before execution:`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 mt-2`,children:[(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Bearer Authentication`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Each registered agent has a unique token. Invalid tokens get an immediate 401.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Hardcoded Blocks`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`desktop.execute, ronin.stop, ronin.harakiri are permanently blocked for all external agents. No override possible.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Platform Allowlists`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Per-platform rules control which capabilities each platform can use. M365 can summarize docs but not touch local files.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Gensui Posture`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`When Gensui is active, its real-time posture can disable all Nexus communication, block browser/desktop sessions, or restrict file writes fleet-wide.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ne,{className:`w-4 h-4 text-indigo-400`}),` Audit Trail`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every gateway operation produces dual-logged audit events: `,(0,Y.jsx)(`strong`,{children:`Layer 1 (Operational)`}),` in the main SQLite database with 90-day retention, and `,(0,Y.jsx)(`strong`,{children:`Layer 2 (Immutable)`}),` in the HMAC-chained append-only database for NIS2/SOC2/EU AI Act compliance with 7-year retention.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-purple-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(d,{className:`w-4 h-4 text-purple-400`}),` Outbound Dispatch (Shogun → External Agent)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shogun can also `,(0,Y.jsx)(`strong`,{children:`send tasks to external agents`}),`. When an external agent has an `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`endpoint_url`}),` configured and its direction is `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`outbound`}),` or `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`bidirectional`}),`, Shogun can dispatch tasks to it.`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-purple-400/80 font-bold uppercase tracking-widest`,children:`API Endpoints`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-2 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /api/v1/nexus/external/dispatch`}),` — Send a task to an external agent. Provide the `,(0,Y.jsx)(`strong`,{children:`agent_id`}),`, `,(0,Y.jsx)(`strong`,{children:`action`}),` (e.g. `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`crm.update_contact`}),`), and `,(0,Y.jsx)(`strong`,{children:`input_context`}),`. Shogun POSTs the payload to the agent's endpoint_url with the agent's token as a Bearer header.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`GET /api/v1/nexus/external/dispatchable-agents`}),` — List all agents that can receive outbound tasks (direction is outbound or bidirectional AND endpoint_url is set).`]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Use cases:`}),` Ask Salesforce to update a CRM record, ask M365 to schedule a meeting, trigger a ServiceNow incident workflow, send processed data back to Google Cloud. The external agent receives a JSON payload with the action, input context, and a task_id for tracking.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Direction field:`}),` `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`inbound`}),` = agent can only send tasks to Shogun. `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`outbound`}),` = Shogun can only send tasks to the agent. `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`bidirectional`}),` = both directions.`]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-gensui`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-indigo-400/40 pb-3`,children:[(0,Y.jsx)(E,{className:`w-6 h-6 text-indigo-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Gensui — Fleet Command`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Connect your Shogun to a centralized Gensui server for fleet management and security coordination.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-indigo-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-indigo-400`}),` What is Gensui?`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Gensui is a `,(0,Y.jsx)(`strong`,{children:`Central Command server`}),` that manages a fleet of Shogun instances. When connected, Gensui owns ToolGate for that instance: it pushes the active policy, capability boundaries, tool verdicts, and advanced content rules; receives telemetry; issues commands including remote Harakiri; and coordinates fleet operations. The Tenshu ToolGate remains visible for explanation but becomes read-only.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(v,{className:`w-4 h-4 text-indigo-400`}),` Connection Form (Not Connected)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When not connected, the page shows a setup form with four fields:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Server URL:`}),` The address of the Gensui server (e.g., http://localhost:8787). Click "Test Connection" to verify reachability before connecting.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Enrollment Token:`}),` A one-time token generated in the Gensui admin panel. Paste it here to auto-enroll this Shogun instance.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Instance Name:`}),` A human-readable name for this Shogun (displayed in the Gensui fleet dashboard).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Environment:`}),` Choose Development, Staging, or Production to tag this instance.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-green-400`}),` Status Dashboard (Connected)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Once connected, the page transforms into a live status dashboard showing:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Connection status:`}),` Green badge when actively connected, amber when enrolled but offline.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shogun ID:`}),` The unique identifier assigned during enrollment.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Last Sync:`}),` Timestamp of the most recent heartbeat or policy sync.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Disconnect button:`}),` Severs the fleet link with a confirmation modal.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-indigo-400`}),` Active Posture Card`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Displays the security policy pushed from Gensui. Capability boundaries, per-tool verdicts, and advanced word or phrase rules are configured together in the central `,(0,Y.jsx)(`strong`,{children:`Gensui ToolGate`}),`. They are enforced locally and override standalone ToolGate settings while the fleet relationship is active, including from the last valid cached policy when Gensui is temporarily unreachable.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-indigo-400`}),` Background Services`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When connected, four background tasks run automatically:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Heartbeat:`}),` Reports status to Gensui every 15 seconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Policy Sync:`}),` Fetches effective posture every 30 seconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Command Polling:`}),` Checks for pending commands (e.g., Harakiri) every 5 seconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Telemetry Push:`}),` Sends buffered events to Gensui every 10 seconds.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-logs`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-subdued/40 pb-3`,children:[(0,Y.jsx)(k,{className:`w-6 h-6 text-shogun-subdued`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Logs — The Compliance Dashboard`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`NIS2, SOC2, and EU AI Act-compliant event logging with full trace reconstruction and tamper-proof audit chain.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-shogun-blue`}),` Dual-Layer Architecture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every event is written to `,(0,Y.jsx)(`strong`,{children:`two independent stores`}),`: (1) an `,(0,Y.jsx)(`strong`,{children:`operational SQLite log`}),` (fast, searchable, 90-day retention) for day-to-day monitoring, and (2) a `,(0,Y.jsx)(`strong`,{children:`tamper-resistant HMAC-chained audit database`}),` (append-only, 7-year retention) for regulatory evidence. If anyone modifies or deletes an entry in the audit chain, the cryptographic hash chain breaks — and the dashboard flags it immediately.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-subdued`}),` Event Stream`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The main panel shows every event in chronological order. Each row displays: `,(0,Y.jsx)(`strong`,{children:`timestamp`}),`, `,(0,Y.jsx)(`strong`,{children:`category icon`}),`, `,(0,Y.jsx)(`strong`,{children:`severity badge`}),` (info/warn/error/critical), `,(0,Y.jsx)(`strong`,{children:`result status`}),` (green check for success, red X for denied), the `,(0,Y.jsx)(`strong`,{children:`action description`}),`, `,(0,Y.jsx)(`strong`,{children:`event type tag`}),` (e.g., DECISION.CONTEXT), the `,(0,Y.jsx)(`strong`,{children:`model used`}),`, `,(0,Y.jsx)(`strong`,{children:`tool invoked`}),`, and `,(0,Y.jsx)(`strong`,{children:`trace ID link`}),`. Click any event to expand its detail panel. Toggle between `,(0,Y.jsx)(`strong`,{children:`Live`}),` (auto-refresh every 5 seconds) and `,(0,Y.jsx)(`strong`,{children:`Paused`}),` modes.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(re,{className:`w-4 h-4 text-shogun-subdued`}),` Category Tabs`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Eleven filterable categories across the top, each with a real-time event count badge:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Decision:`}),` AI decision provenance — context assembled, influences tracked (EU AI Act). Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`decision.context`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`decision.influences`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Oversight:`}),` Human review — AI responses delivered for implicit oversight, emergency shutdowns. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`oversight.response_delivered`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`oversight.emergency_shutdown`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` Security tier warnings, denied tools, high-autonomy alerts. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`risk.tools_denied`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`risk.high_autonomy_mode`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Model:`}),` Model selection, LLM responses, API errors, fallback activations. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`model.selected`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`model.response`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`model.error`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Policy:`}),` ToolGate evaluations under the Torii-selected policy — effective allow, confirm, or block decisions, their policy source, and any matching advanced content rule. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`policy.evaluated`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Memory:`}),` Memory recall, search queries, write operations with retrieval provenance. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`memory.search`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`memory.write`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Tools:`}),` Tool/skill executions, arguments, and results. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`tool.executed`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Auth:`}),` Session tracking, security posture changes, API credential lifecycle, kill switch activations. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.session`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.posture_changed`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.credential_added`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.kill_switch_activated`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Incident:`}),` Critical security events — model API failures, kill switch emergency actions, audit chain integrity violations. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`incident.model_api_error`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`incident.kill_switch`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`incident.chain_broken`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`System:`}),` Server lifecycle (startup/shutdown), governance configuration changes (Constitution/Mandate), backup and restore provenance. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.startup`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.shutdown`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.config_changed`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.backup_created`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.backup_restored`}),`.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(v,{className:`w-4 h-4 text-shogun-blue`}),` Trace Reconstruction`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every chat turn generates a `,(0,Y.jsx)(`strong`,{children:`trace_id`}),` (e.g., `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`trc_d5ae40fb`}),`) that links all events in that workflow — from policy evaluation through memory recall, model selection, tool execution, and decision provenance. Click any trace ID link to open the `,(0,Y.jsx)(`strong`,{children:`Trace Reconstruction modal`}),`, which displays every event in the chain as a numbered timeline. This allows full `,(0,Y.jsx)(`strong`,{children:`workflow reconstruction`}),` for incident investigation.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ne,{className:`w-4 h-4 text-shogun-gold`}),` Event Detail Panel`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Click any event to expand a detail panel showing the full NIS2/SOC2 + EU AI Act record:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`WHO/WHAT/WHEN:`}),` User ID, agent, event type, timestamp.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`MODEL/PROVIDER:`}),` Which AI model and cloud provider handled the request.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`POLICY:`}),` Security policy reference, decision (allowed/denied), and reason.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RISK/TRACE:`}),` Risk score and correlated trace ID.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`AI Confidence bar:`}),` Color-coded indicator (green ≥ 70%, yellow 40–70%, red < 40%).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Framework badges:`}),` Shows which compliance frameworks apply (SOC2, NIS2, EU_AI_ACT).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Governance flags:`}),` Human oversight required, evidence completeness, risk level.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Detail payload:`}),` Full structured JSON of all event metadata.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-green-500`}),` Audit Chain Integrity`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The top-right corner shows a real-time `,(0,Y.jsx)(`strong`,{children:`Chain Intact`}),` indicator (green) or `,(0,Y.jsx)(`strong`,{children:`Chain Broken`}),` alert (red, pulsing). This verifies the HMAC-SHA256 hash chain across all immutable audit records. If the chain is intact, no records have been tampered with. The status bar at the bottom also shows "AUDIT: INTACT" or "BROKEN."`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-shogun-gold`}),` Compliance Export`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click the download icon to export the `,(0,Y.jsx)(`strong`,{children:`immutable audit log`}),` as a JSON file. This export pulls from the tamper-proof chain (not the operational log), making it suitable for regulatory auditors, compliance reviews, and incident investigations. The export includes all event metadata, governance flags, and chain hashes.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ce,{className:`w-4 h-4 text-red-400`}),` Clear Operational Logs`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click the trash icon to clear the `,(0,Y.jsx)(`strong`,{children:`operational log only`}),`. The immutable audit chain is `,(0,Y.jsx)(`strong`,{children:`never affected`}),` by this action — it is append-only and cannot be cleared. A confirmation dialog warns you before deletion. The clearing event itself is recorded in the immutable audit chain as evidence.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-maintenance`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-subdued/40 pb-3`,children:[(0,Y.jsx)(U,{className:`w-6 h-6 text-shogun-subdued`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Maintenance — Backups, Data & Updates`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Found under the `,(0,Y.jsx)(`strong`,{children:`Maintenance`}),` section at the bottom of the sidebar.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-gold/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-gold`}),` Scheduled Backups`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Navigate to `,(0,Y.jsx)(`strong`,{children:`Backups`}),` in the sidebar. Enable automatic backups with a configurable schedule (hourly to weekly). Set how many old backups to keep — older ones are automatically deleted. Backups include your database, configs, governance documents, and environment settings.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-blue`}),` Data Management Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`On the `,(0,Y.jsx)(`strong`,{children:`Backups`}),` page, switch to the `,(0,Y.jsx)(`strong`,{children:`Data Management`}),` tab. Here you'll find a live System Snapshot (row counts per table, DB size), one-click export as a `,(0,Y.jsx)(`strong`,{children:`Safe JSON Bundle`}),` or `,(0,Y.jsx)(`strong`,{children:`Raw Database Swap`}),`, and an Import area to restore from a previous export.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-emerald-400`}),` System Updates`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Navigate to `,(0,Y.jsx)(`strong`,{children:`Updates`}),` in the sidebar. The automatic checker reads the repository's `,(0,Y.jsx)(`code`,{children:`version.json`}),` manifest, compares its numeric build with the installed build, and caches the result for 6 hours. `,(0,Y.jsx)(`strong`,{children:`Check for Updates`}),` forces a fresh check; an available release displays an `,(0,Y.jsx)(`strong`,{children:`UPDATE`}),` badge in the sidebar.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click `,(0,Y.jsx)(`strong`,{children:`Install Update`}),` to download the current `,(0,Y.jsx)(`code`,{children:`main`}),` branch, replace application code, and rebuild the frontend while preserving your database, configurations, environment, and virtual environment. Restart Shogun when installation completes. Private repositories can use a locally encrypted GitHub token configured on the Updates page.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-amber-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-amber-400`}),` Restore & Recovery`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every backup in the list has a `,(0,Y.jsx)(`strong`,{children:`Restore`}),` button. Clicking it overwrites your current database and config files with the backup's contents. A restart is required afterwards. Use this to roll back after a bad config change, recover from corruption, or migrate to a new machine.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-flowstack`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-violet-400/40 pb-3`,children:[(0,Y.jsx)(_,{className:`w-6 h-6 text-violet-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Flow Stacking — Stack Orchestrator`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The governed runtime layer above Agent Flow — long-horizon execution with checkpoints, verification gates, retries, and artifact capture.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-violet-400`}),` What Is Flow Stacking?`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`While individual `,(0,Y.jsx)(`strong`,{children:`Agent Flows`}),` handle single-pipeline execution, `,(0,Y.jsx)(`strong`,{children:`Flow Stacking`}),` chains multiple flows into long-horizon execution pipelines. The `,(0,Y.jsx)(`strong`,{children:`Stack Orchestrator`}),` manages the entire lifecycle: planning, checkpointing, verification, retries, and artifact collection. Navigate to `,(0,Y.jsx)(`strong`,{children:`Flow Stack`}),` in the sidebar to access it.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-violet-400`}),` Three Operating Modes`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Goal-Driven:`}),` Describe what you want — the planner selects and sequences flows automatically. `,(0,Y.jsx)(`strong`,{children:`Selected Stack:`}),` Pick a specific Flow Stack to execute. `,(0,Y.jsx)(`strong`,{children:`Template:`}),` Instantiate from a reusable template.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(s,{className:`w-4 h-4 text-violet-400`}),` Verification Gates`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`After each step, independent quality checks run (deterministic + semantic model judging). If a step fails verification, the retry service categorizes the failure (permission, runtime, verification, tool/flow) and applies the configured retry policy.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-violet-400`}),` Durable Checkpoints`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Context summaries and state snapshots are saved after each step. If a run is paused or interrupted, it can be resumed from the last checkpoint — no lost progress. Use `,(0,Y.jsx)(`strong`,{children:`Pause`}),` and `,(0,Y.jsx)(`strong`,{children:`Resume`}),` buttons in the Flow Stack dashboard.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(S,{className:`w-4 h-4 text-violet-400`}),` Artifact Capture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Outputs from each phase (files, reports, analysis results) are automatically captured and cataloged. View all artifacts for a run from the `,(0,Y.jsx)(`strong`,{children:`Artifacts`}),` tab in the execution detail view.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-violet-400`}),` Governed Permissions`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Flow Stacking is gated by six ToolGate capability boundaries: `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`agentflow_create`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`agentflow_execute`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`agentflow_autonomous`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`flowstack_create`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`flowstack_execute`}),`, and `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`flowstack_autonomous`}),`. The built-in policies require `,(0,Y.jsx)(`strong`,{children:`Tactical`}),` tier or above; a custom policy inherits a base tier and may narrow those permissions. Select the policy in `,(0,Y.jsx)(`strong`,{children:`Torii`}),`, then use `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` to understand its boundaries and whether execution is allowed, confirmed, or blocked.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-violet-400`}),` Agent Inspection & Editing`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shogun discovers stacks with `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`list_agent_flows`}),` and reads their complete phases, subflow mappings, nodes, edges, orchestrator configuration, and lifecycle state with `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`get_flow_stack`}),`. It can then use `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`create_flow_stack`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`edit_flow_stack`}),`, or `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`delete_flow_stack`}),` under the active posture and Flow Stack permissions.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`For a standard Agent Flow, Shogun uses `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`get_agent_flow`}),` and prefers `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`patch_agent_flow`}),` for targeted graph changes that preserve untouched nodes and edges. A direct operator instruction to edit a flow authorizes that targeted patch for the current turn; Shogun still has to inspect first, remain at Tactical posture or above, and obey the separate create, activate, execute, template, and delete permissions.`]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-visual-intake`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-cyan-400/40 pb-3`,children:[(0,Y.jsx)(te,{className:`w-6 h-6 text-cyan-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Visual Intake — Image Analysis`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Secure, source-neutral image upload, processing, and AI-powered vision analysis with full governance.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-cyan-400`}),` Upload & Process`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Upload images from chat, Telegram, email, or browser. Shogun normalizes them to WebP, generates 640×640 thumbnails, strips all EXIF metadata (GPS, camera info, timestamps) for privacy, and deduplicates via SHA-256 hashing. Supported formats: JPEG, PNG, WebP, static GIF (max 20 MB).`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-cyan-400`}),` AI Vision`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Describe:`}),` Generate natural language descriptions. `,(0,Y.jsx)(`strong`,{children:`Inspect:`}),` Deep inspection with custom prompts — ask specific questions about content. `,(0,Y.jsx)(`strong`,{children:`OCR:`}),` Extract text from screenshots, documents, and photos. `,(0,Y.jsx)(`strong`,{children:`Compare:`}),` Side-by-side comparison of two images with AI analysis.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-cyan-400`}),` 7 Permission Flags`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_image_intake`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_local_vision`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_cloud_vision`}),` (off — privacy-sensitive), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_ocr`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_attach_to_stack`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_auto_memory`}),` (off — privacy-sensitive), and `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_delete`}),` (on). These are policy-scoped capability boundaries in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`; there is no separate Visual Intake permission tab in Katana.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(v,{className:`w-4 h-4 text-cyan-400`}),` Stack Integration`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Pin important images to prevent retention expiry (default: 30 days). Attach images as artifacts to Stack Orchestrator runs for evidence trails. Images can be linked to chat sessions and messages for context tracking.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-ide-mode`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-emerald-400/40 pb-3`,children:[(0,Y.jsx)(x,{className:`w-6 h-6 text-emerald-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`IDE Mode — VS Code Integration`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Connect your VS Code editor via a governed WebSocket bridge for AI-assisted development.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-amber-500/10 border-amber-500/30 border-l-4 border-l-amber-500`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-amber-400 flex items-center gap-2 mb-3`,children:[(0,Y.jsx)(E,{className:`w-5 h-5`}),`Requires Campaign or Ronin Posture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`IDE Mode is exposed by Katana only when the active policy is based on Campaign or Ronin and its ToolGate capability boundary enables `,(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`ide_enabled`}),`. The WebSocket bridge only accepts connections from localhost (`,(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`127.0.0.1`}),` / `,(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`::1`}),`) — remote connections are rejected.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-emerald-400`}),` File Operations`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Read, create, list, search, and apply patches to files within approved workspaces. Every write creates an automatic SHA-256 snapshot for rollback. `,(0,Y.jsx)(`strong`,{children:`Protected files`}),` (`,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.env`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`*.pem`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`*.key`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`id_rsa*`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`credentials*`}),`) are always blocked.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-emerald-400`}),` Terminal & Git`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Run approved commands (allowlisted per posture: `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`pytest`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`python`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`npm`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`ruff`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`mypy`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`tsc`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`cargo`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`go`}),`). Git operations: status, diff, branch, create-branch, commit. `,(0,Y.jsx)(`strong`,{children:`Push is disabled by default`}),`; git mutations require Ronin + explicit approval.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-emerald-400`}),` Pairing System`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Pairing uses one-time `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`SHG-`}),` prefixed tokens with SHA-256 digest comparison and 10-minute expiry. Generate a token in the Katana IDE tab, enter it in VS Code, and the bridge connects. Revoke all pairings instantly from the dashboard.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-emerald-400`}),` Workspace Boundaries`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`All file operations are restricted to approved workspace paths. Path traversal is blocked. Symlinks that escape boundaries are rejected. Denied directories: `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.ssh`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.aws`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.azure`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.gnupg`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.kube`}),`. Emergency `,(0,Y.jsx)(`strong`,{children:`Kill Switch`}),` endpoint terminates all IDE connections instantly.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-emerald-400`}),` VS Code Extension`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Install the `,(0,Y.jsx)(`strong`,{children:`shogun-ide-bridge`}),` extension from `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`bridge/vscode/`}),`. Configure `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`shogun.bridgeUrl`}),` (default: `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`ws://127.0.0.1:8000/api/v1/ide/bridge`}),`). Commands: `,(0,Y.jsx)(`strong`,{children:`Shogun: Connect`}),`, `,(0,Y.jsx)(`strong`,{children:`Shogun: Disconnect`}),`, `,(0,Y.jsx)(`strong`,{children:`Shogun: Open Dashboard`}),`.`]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-model-router`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-blue-400/40 pb-3`,children:[(0,Y.jsx)(ae,{className:`w-6 h-6 text-blue-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Model Router — Intelligent Model Selection`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Provider-agnostic, task-aware model selection with routing profiles, registry, and usage telemetry.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(c,{className:`w-4 h-4 text-blue-400`}),` How It Works`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Instead of hardcoding which model handles each request, the Model Router evaluates the `,(0,Y.jsx)(`strong`,{children:`task type`}),`, `,(0,Y.jsx)(`strong`,{children:`complexity`}),`, and your `,(0,Y.jsx)(`strong`,{children:`active routing profile`}),` to select the optimal model automatically. Navigate to `,(0,Y.jsx)(`strong`,{children:`Katana → Model Routing`}),` to configure profiles and view the model registry.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-blue-400`}),` 5 Routing Profiles`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`ULTRA ECONOMY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Strongly prefers local models, minimizes API calls.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-emerald-400 bg-emerald-400/10 px-2 py-0.5 rounded`,children:`ECONOMY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Low-cost daily work, escalates only for complex tasks.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-blue-400 bg-blue-400/10 px-2 py-0.5 rounded`,children:`BALANCED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Recommended balance of quality and cost. Default profile.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-amber-400 bg-amber-400/10 px-2 py-0.5 rounded`,children:`HIGH CAPABILITY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Uses stronger models earlier in the complexity curve.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`PREMIUM`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Maximum quality, always picks the best available model.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-blue-400`}),` Task Classification`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every request is classified into one of 20+ task types across 5 complexity tiers:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5 text-xs text-shogun-subdued`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-green-400`,children:`Simple:`}),` simple_chat, classification, extraction, memory_write`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-emerald-400`,children:`Moderate:`}),` summarization, browser_task, skill_selection`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-blue-400`,children:`Complex:`}),` planning, coding_plan, coding_edit, stack_planning`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-amber-400`,children:`Critical:`}),` complex_reasoning, test_failure_analysis, self_verification`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-cyan-400`,children:`Vision:`}),` visual_understanding, screenshot_analysis, photo_understanding`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-blue-400`}),` Model Registry`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every model available to Shogun is registered with its provider, capabilities, quality/cost/latency tiers, context window, and role tags. Test connections directly from the registry. Add cloud providers or local Ollama models.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-blue-400`}),` Decision & Usage Logs`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every routing decision is persisted: which task type, complexity score, selected model, fallback model, and reason. Usage telemetry tracks input/output tokens, cost estimates, and latency. View summaries and per-stack breakdowns.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-cyan-400`}),` OpenClaw College Ecosystem Intelligence`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`In `,(0,Y.jsx)(`strong`,{children:`Updates`}),`, anonymous ecosystem benchmark sharing is enabled by default. The operator can opt out at any time. When enabled, Shogun sends only model/provider, coarse task type, success, bucketed tokens/latency/cost, local-versus-cloud, country code, Shogun version, and a weekly rotating anonymous installation hash.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Never transmitted:`}),` prompts, outputs, files, error contents, agent names, credentials, or exact IP addresses. College publishes rankings only after at least 20 events from five anonymous installations and retains raw telemetry for 31 days.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-active-skills`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-amber-400/40 pb-3`,children:[(0,Y.jsx)(D,{className:`w-6 h-6 text-amber-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Active Skills & Trajectory Capture`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Runtime skill retrieval from the Dojo — automatic selection, context injection, outcome tracking, and improvement candidates.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(r,{className:`w-4 h-4 text-amber-400`}),` How Active Skills Work`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When a Shogun agent processes a request, the Active Skill system automatically `,(0,Y.jsx)(`strong`,{children:`retrieves`}),` relevant skills from the Dojo, `,(0,Y.jsx)(`strong`,{children:`gates`}),` them against the active ToolGate capability boundaries and exam requirements, `,(0,Y.jsx)(`strong`,{children:`injects`}),` skill content into the LLM context (advisory or context_block mode), and `,(0,Y.jsx)(`strong`,{children:`tracks`}),` the outcome (success, partial, failed, not_used, blocked). Torii selects the governing tier or custom policy; ToolGate applies its runtime rules. Skills are live during execution — not just catalog entries.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-amber-400`}),` Configuration`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5 text-xs text-shogun-subdued`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_max_per_run`}),`: 5 — max skills per execution run`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_max_per_step`}),`: 3 — max skills per step`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_max_total_context_tokens`}),`: 2,500 — token budget`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_require_exam_pass`}),`: true — only use passed skills`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_preserve_during_compaction`}),`: true — keep during context compaction`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ie,{className:`w-4 h-4 text-amber-400`}),` Trajectory Capture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every skill invocation generates a structured evidence trail: `,(0,Y.jsx)(`strong`,{children:`Candidate Retrievals`}),` (which skills were considered), `,(0,Y.jsx)(`strong`,{children:`Episodes`}),` (full lifecycle), `,(0,Y.jsx)(`strong`,{children:`Trajectories`}),` (outcome scoring), `,(0,Y.jsx)(`strong`,{children:`Tool Links`}),` (tools called during usage), `,(0,Y.jsx)(`strong`,{children:`Verification Links`}),` (how outcomes were verified), `,(0,Y.jsx)(`strong`,{children:`Outcome Scores`}),` (deterministic scoring), and `,(0,Y.jsx)(`strong`,{children:`Improvement Candidates`}),` (suggested fixes). All data is secret-redacted automatically.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-skillopt`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-fuchsia-400/40 pb-3`,children:[(0,Y.jsx)(i,{className:`w-6 h-6 text-fuchsia-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`SkillOpt — Automated Skill Optimization`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Data-driven skill improvement pipeline — version management, training runs, candidate generation, validation, and promotion.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ie,{className:`w-4 h-4 text-fuchsia-400`}),` The Optimization Pipeline`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Usage Events`}),` are captured from Active Skill runs. A `,(0,Y.jsx)(`strong`,{children:`Training Run`}),` uses these to generate optimized `,(0,Y.jsx)(`strong`,{children:`Candidates`}),`. Each candidate is `,(0,Y.jsx)(`strong`,{children:`Validated`}),` against held-out tasks with safety checks and scoring. Successful candidates are `,(0,Y.jsx)(`strong`,{children:`Promoted`}),` to become the new active version; failing ones are `,(0,Y.jsx)(`strong`,{children:`Rejected`}),` with a reason.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-fuchsia-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-fuchsia-400`}),` Version Management`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every skill change creates an immutable version: version number, content hash, validation score, and status (`,(0,Y.jsx)(`code`,{className:`text-fuchsia-400`,children:`candidate`}),` → `,(0,Y.jsx)(`code`,{className:`text-fuchsia-400`,children:`active`}),` → `,(0,Y.jsx)(`code`,{className:`text-fuchsia-400`,children:`retired`}),`). Browse all versions for any skill from the SkillOpt tab in `,(0,Y.jsx)(`strong`,{children:`Katana`}),`. Compare candidate vs baseline content with the interactive diff viewer.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-fuchsia-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-fuchsia-400`}),` Katana Dashboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The SkillOpt tab in `,(0,Y.jsx)(`strong`,{children:`Katana`}),` provides real-time tracking of optimization runs, interactive diff viewer for candidates vs baseline, one-click promote/reject controls, and metrics for average improvement scores. Start training runs, view all skill versions, and monitor usage events.`]})]})]})]})]})]}),I===`architecture`&&(0,Y.jsxs)(`div`,{className:`space-y-16 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsxs)(`div`,{className:`text-center max-w-3xl mx-auto space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`text-3xl font-bold shogun-title`,children:`System Architecture`}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed`,children:`A deep-dive into how Shogun is built — the layers, protocols, and subsystems that make it work. Understanding the architecture helps you make better decisions about configuration, security, and scaling.`})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(_,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`System Topology`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The big picture — how all the pieces fit together.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(q,{className:`w-4 h-4 text-shogun-blue`}),` Three-Tier Design`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shogun is built in three tiers: `,(0,Y.jsx)(`strong`,{children:`Presentation`}),` (the React-based UI you're looking at), `,(0,Y.jsx)(`strong`,{children:`Application`}),` (a FastAPI backend handling all business logic, routing, and orchestration), and `,(0,Y.jsx)(`strong`,{children:`Persistence`}),` (SQLite in desktop mode or PostgreSQL in Server mode, plus Qdrant for vector memory). Each tier is independent and communicates through governed APIs.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-shogun-blue`}),` Lattice Architecture`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Instead of one monolithic AI, Shogun uses a "Lattice" — a network of specialized sub-agents (Samurai) coordinated by a central Shogun agent. Work is distributed across the lattice based on agent roles and routing profiles. This makes the system resilient, parallelizable, and scalable.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-4 h-4 text-shogun-blue`}),` External Integrations`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The system connects outward to cloud AI providers (OpenAI, Anthropic, Gemini, Perplexity, OpenRouter) and local model servers (Ollama). It integrates with Telegram for mobile messaging, supports the A2A (Agent-to-Agent) protocol for cross-network collaboration via Nexus, automates web browsing via Mado (Playwright), connects to email servers (IMAP/SMTP), and syncs with calendar servers (CalDAV).`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(l,{className:`w-4 h-4 text-shogun-blue`}),` Desktop and Server Deployment`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Desktop mode runs Shogun, The Tenshu, SQLite, and local Qdrant directly on one computer. Server mode runs the application, PostgreSQL, and Qdrant as isolated Docker services with persistent volumes and automatic restarts. Both stay on hardware you control; Server mode is intended for continuous operation and Team-mode access through Telegram or Microsoft Teams.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(z,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Agent Hierarchy`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How intelligence is distributed across the network.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-shogun-gold`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-gold text-lg flex items-center gap-2`,children:[(0,Y.jsx)(l,{className:`w-5 h-5`}),` The Shogun`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The central coordinator. Receives user queries, decides how to respond, and can delegate sub-tasks to Samurai agents. Has its own personality, behavioral directives, and primary model. Think of the Shogun as the CEO — it makes strategic decisions and assigns work.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Configured in: Shogun Profile`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-shogun-blue`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-blue text-lg flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-5 h-5`}),` Samurai Agents`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Specialized sub-agents, each with a defined role (Researcher, Analyst, Developer, etc.). Samurai can run independently or be orchestrated by the Shogun. Each has its own routing profile, spawn policy, and task queue. Think of them as department heads — experts in their domain.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Managed in: Samurai Network`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-indigo-400`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-indigo-400 text-lg flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-5 h-5`}),` Peer Shoguns`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Other Shogun instances running on different machines. Connected via the Nexus collaboration module using the A2A Protocol. Peers exchange messages, share whiteboard content, and can coordinate on complex multi-agent tasks across network boundaries.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Connected via: Nexus`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-indigo-400 md:col-span-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-indigo-400 text-lg flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-5 h-5`}),` Gensui (Fleet Command)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`An optional Central Command server that sits above multiple Shogun instances. When connected, Gensui owns ToolGate for the managed fleet: it pushes policy scopes, capability boundaries, per-tool verdicts, and advanced content rules; monitors telemetry; issues commands including remote Harakiri; and coordinates fleet-wide policy. Each Shogun maintains heartbeats, policy sync, command polling, and a last-known-good policy cache for fail-closed continuity.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Connected via: Alliance → Gensui`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(G,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`The Memory Tier`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How the system stores, retrieves, and manages knowledge.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-gold`}),` Vector Memory (Qdrant)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Memories are converted into numerical vectors (embeddings) and stored in a Qdrant vector database. This enables `,(0,Y.jsx)(`strong`,{children:`semantic search`}),` — you can search by meaning, not just keywords. When the AI responds to a query, it automatically retrieves the most relevant memories from this layer and includes them in context.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-gold`}),` Structured Storage`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Agents, providers, routing profiles, governance documents, chat history, certifications, team identities, and security policies use SQLite (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`shogun.db`}),`) in desktop mode and PostgreSQL in Server mode. This database is the source of truth for everything except vector embeddings.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-shogun-gold`}),` Memory Types`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Memories are categorized into five types: `,(0,Y.jsx)(`strong`,{children:`Semantic`}),` (facts and knowledge), `,(0,Y.jsx)(`strong`,{children:`Episodic`}),` (events and experiences), `,(0,Y.jsx)(`strong`,{children:`Procedural`}),` (instructions and workflows), `,(0,Y.jsx)(`strong`,{children:`Persona`}),` (identity, preferences, and personal information), and `,(0,Y.jsx)(`strong`,{children:`Skills`}),` (learned capabilities from the Dojo). Each type has different retrieval priorities and consolidation rules. The type influences how aggressively the memory fades over time.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-shogun-gold`}),` Salience & Decay`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every memory has a salience score (0.0–1.0). Frequently accessed memories rise in salience; unused ones decay naturally. The Bushido reflection engine periodically reviews memories and consolidates low-salience ones. You can `,(0,Y.jsx)(`strong`,{children:`pin`}),` critical memories to prevent decay entirely.`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(R,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Communication Protocol`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How agents talk to each other and to you.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-blue`}),` User → Shogun (REST + SSE)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When you type a message in Comms, it is sent as an HTTP POST to the backend. The response is streamed back via `,(0,Y.jsx)(`strong`,{children:`Server-Sent Events (SSE)`}),` — the tokens appear one at a time in real-time. This is what creates the "typing" effect you see as the AI responds.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-shogun-blue`}),` Shogun → Samurai (Internal Dispatch)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Shogun delegates tasks to Samurai agents via an internal dispatch queue. Each delegation includes the task description, priority level, and context from the conversation. The Samurai processes the task independently and reports results back.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(K,{className:`w-4 h-4 text-indigo-400`}),` Shogun → Peers (A2A Protocol)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Inter-Shogun communication uses the `,(0,Y.jsx)(`strong`,{children:`Agent-to-Agent (A2A)`}),` protocol over HTTP. Messages are typed (update, proposal, approval, task) and cryptographically signed with the sender's identity keys. Each peer validates signatures before accepting messages.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-shogun-blue`}),` Shogun → AI Providers (LLM Calls)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The routing engine selects a model based on the active routing profile (or uses the default primary model). The request is sent to the chosen provider's API (OpenAI, Anthropic, etc.) with the assembled prompt (user message + system prompt + memory context + constitution). Streaming responses are relayed back to the frontend.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(y,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Security Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Defense-in-depth architecture that protects every agent action.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-red-400`}),` Tiered Posture System`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Five built-in security tiers (SHRINE → GUARDED → TACTICAL → CAMPAIGN → RONIN), plus custom policies based on those tiers, define the capability ceiling. Torii selects the active tier or policy; ToolGate displays and enforces its filesystem, network, shell, tools, workflow, memory, and delegation rules.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-red-400`}),` Kaizen Constitution Validator`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every proposed agent action is validated against the Constitution (written in Kaizen). If an action violates any constitutional rule, it is blocked before execution. The validation happens server-side, so agents cannot bypass it. Rules are evaluated by priority (critical rules are checked first).`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4 text-red-400`}),` Harakiri Kill Switch`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A global emergency mechanism. When activated, `,(0,Y.jsx)(`strong`,{children:`all`}),` agent activity is instantly frozen, the posture locks to SHRINE (maximum protection), and a prominent red banner appears system-wide. Requires a two-step confirmation to activate and a deliberate reset to restore normal operations.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-red-400`}),` Identity & Signing`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Each Shogun instance has a unique ID and cryptographic key pair. All A2A messages are signed, ensuring peers can verify authenticity. API keys for external providers are stored encrypted in the database and never exposed in the frontend.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(l,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Intelligence Pipeline`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The journey of a message from input to output.`})]})]}),(0,Y.jsx)(`div`,{className:`space-y-4`,children:[{step:1,title:`User Input`,desc:`You type a message in the Comms chat interface. The message is sent to the backend via HTTP POST.`,color:`text-shogun-blue`,icon:R},{step:2,title:`Routing Decision`,desc:`The routing engine checks the active routing profile for matching task rules. If a rule matches (e.g., "research" → Perplexity), that model is used. Otherwise, the primary model is selected.`,color:`text-shogun-blue`,icon:h},{step:3,title:`Context Assembly`,desc:`The system assembles the full prompt: system instructions + Mandate (from Kaizen) + relevant memories (from Archives, via semantic search) + current conversation history + constitutional rules.`,color:`text-shogun-gold`,icon:_},{step:4,title:`Security Validation`,desc:`The assembled request is checked against the active ToolGate policy and constitutional rules. Capability boundaries, tool verdicts, parameters, and advanced content rules can require confirmation or block execution.`,color:`text-red-400`,icon:P},{step:5,title:`LLM Invocation`,desc:`The validated prompt is sent to the selected AI model's API. The response streams back token-by-token via SSE.`,color:`text-shogun-blue`,icon:l},{step:6,title:`Memory Inscription`,desc:`After the response completes, key information from the exchange may be automatically stored as new memories in the Archives, increasing the AI's knowledge for future queries.`,color:`text-shogun-gold`,icon:G}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card flex gap-5 items-start`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col items-center gap-2 shrink-0`,children:(0,Y.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-shogun-bg border border-shogun-border flex items-center justify-center font-bold text-lg ${e.color}`,children:e.step})}),(0,Y.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4 ${e.color}`}),e.title]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.desc})]})]},e.step))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(w,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Self-Improvement Loop (Bushido)`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How the system continuously optimizes itself.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-gold`}),` Reflection Cycles`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Bushido engine periodically analyzes recent interactions to evaluate model performance, memory utilization, and agent effectiveness. It looks for patterns — which models are faster, which memories are frequently retrieved, which agents are underperforming — and generates actionable insights.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(n,{className:`w-4 h-4 text-shogun-gold`}),` Memory Consolidation`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Low-salience episodic memories are periodically transformed into compact semantic summaries. This prevents the memory store from growing indefinitely while preserving the knowledge within. The consolidation rate is configurable via the Bushido calibration controls.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(c,{className:`w-4 h-4 text-shogun-gold`}),` Exploration vs. Exploitation`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The "Exploration Variance" parameter controls how much the system deviates from proven strategies. Low variance means the AI sticks to what works; high variance means it experiments with new approaches. This is the classic explore-exploit tradeoff, tunable in Bushido.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-shogun-gold`}),` Formal Verification`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`All behavioral optimizations proposed by the Bushido engine are verified against the Kaizen constitution before being applied. This ensures that self-improvement never violates the fundamental laws defined by the operator. The system cannot "optimize its way" past your rules.`})]})]})]})]}),I===`safety`&&(0,Y.jsxs)(`div`,{className:`space-y-16 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsxs)(`div`,{className:`text-center max-w-3xl mx-auto space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`text-3xl font-bold shogun-title`,children:`Safety & Security Protocols`}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed`,children:`Shogun is built with a defense-in-depth security model. Multiple independent layers work together to ensure that no single failure can compromise the system. This page explains every safety mechanism in detail.`})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(P,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Security Philosophy`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The principles that govern every safety decision in Shogun.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-t-2 border-red-400`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-lg`,children:`Defense in Depth`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`No single layer is trusted alone. Security is selected at the posture and policy level in Torii, configured and enforced at runtime in ToolGate, constrained constitutionally in Kaizen, and validated again at action execution. An attacker would need to bypass all of these layers simultaneously.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-t-2 border-orange-400`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-lg`,children:`Least Privilege`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Agents receive only the minimum permissions needed for their tasks. Filesystem access, shell execution, delegation, and other capabilities must fit inside the active ToolGate boundary; per-tool and advanced content rules may further tighten execution but cannot widen that ceiling.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-t-2 border-shogun-gold`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-lg`,children:`Fail Closed`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When in doubt, the system blocks rather than allows. If a constitutional rule is ambiguous, the action is denied. If the security posture cannot be verified, the system defaults to SHRINE (maximum protection). The Harakiri kill switch ensures instant lockdown in emergencies.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(y,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`The Five Security Tiers`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Each tier represents a different balance between safety and autonomy. Choose based on your environment and risk tolerance.`})]})]}),(0,Y.jsx)(`div`,{className:`space-y-4`,children:[{tier:`SHRINE`,subtitle:`Maximum Protection`,color:`border-green-500 bg-green-500/5`,badge:`text-green-500 bg-green-500/10 border-green-500/30`,desc:`Zero-trust mode. All external connections are blocked. Agents can only process information locally with no filesystem, network, or shell access. No sub-agent spawning. Every action requires explicit human approval. Use this when you suspect a breach, while auditing, or when running highly sensitive operations.`,perms:[`Filesystem: None`,`Network: None (local only)`,`Shell: Blocked`,`Sub-agents: Blocked`,`Tools: Disabled`,`Mail: Disabled`,`Calendar: Disabled`,`Cron: Disabled`,`Mado Browser: Disabled`,`Human approval: Everything`]},{tier:`GUARDED`,subtitle:`Restricted Operations`,color:`border-blue-500 bg-blue-500/5`,badge:`text-blue-500 bg-blue-500/10 border-blue-500/30`,desc:`Highly restricted. Filesystem access limited to approved directories only. Network restricted to approved endpoints. All tool usage requires human confirmation. Sub-agents limited to 2 maximum. Suitable for production environments where safety takes priority over speed.`,perms:[`Filesystem: Allowlist only`,`Network: Approved endpoints only`,`Shell: Blocked`,`Sub-agents: Max 2 (manual)`,`Tools: With approval`,`Mail: Read only`,`Calendar: Read only`,`Cron: View only`,`Mado Browser: Enabled (1 session)`,`Human approval: Most actions`]},{tier:`TACTICAL`,subtitle:`Balanced (Default)`,color:`border-shogun-gold bg-shogun-gold/5`,badge:`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`,desc:`The recommended default. Agents have scoped file access (read and write within designated directories), can use approved tools autonomously, and have filtered network access. Shell commands are still blocked. Up to 5 sub-agents can be spawned. A good balance between productivity and safety.`,perms:[`Filesystem: Scoped read/write`,`Network: Filtered (allowlist)`,`Shell: Blocked`,`Sub-agents: Max 5 (manual)`,`Tools: Approved auto-allowed`,`Mail: Read & Send`,`Calendar: Full access`,`Cron: Full access`,`Mado Browser: Headless only`,`Human approval: Dangerous only`]},{tier:`CAMPAIGN`,subtitle:`High Autonomy`,color:`border-orange-500 bg-orange-500/5`,badge:`text-orange-500 bg-orange-500/10 border-orange-500/30`,desc:`Extended autonomy for advanced users. Broad filesystem access. Full internet access. Shell commands allowed with logging. Sub-agents can auto-spawn based on policies. Only use this in controlled environments where you have monitoring in place and trust the AI models you are running.`,perms:[`Filesystem: Broad access`,`Network: Full internet`,`Shell: Allowed (logged)`,`Sub-agents: Auto-spawn enabled`,`Tools: All enabled`,`Mail: Read & Send`,`Calendar: Full access`,`Cron: Full access`,`Mado Browser: Enabled`,`Human approval: Critical only`]},{tier:`RONIN`,subtitle:`⚠ Unrestricted`,color:`border-red-500 bg-red-500/5`,badge:`text-red-500 bg-red-500/10 border-red-500/30`,desc:`No restrictions whatsoever. Full filesystem, network, shell, and tool access with zero oversight. ONLY use this in completely isolated sandbox/test environments with no access to production data, external services, or sensitive information. This tier exists for testing and development purposes only.`,perms:[`Filesystem: Unrestricted`,`Network: Unrestricted`,`Shell: Unrestricted`,`Sub-agents: Unrestricted`,`Tools: All enabled`,`Mail: Unrestricted`,`Calendar: Unrestricted`,`Cron: Full access`,`Mado Browser: Autonomous`,`Human approval: None`]}].map(e=>(0,Y.jsx)(`div`,{className:`shogun-card border-l-4 ${e.color}`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-start gap-4`,children:[(0,Y.jsxs)(`div`,{className:`md:w-1/3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-bold uppercase px-2 py-1 rounded border ${e.badge}`,children:e.tier}),(0,Y.jsx)(`span`,{className:`text-sm font-bold text-shogun-text`,children:e.subtitle})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.desc})]}),(0,Y.jsx)(`div`,{className:`md:w-2/3 grid grid-cols-2 md:grid-cols-5 gap-2`,children:e.perms.map((e,t)=>{let[n,r]=e.split(`: `);return(0,Y.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-lg p-2`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest`,children:n}),(0,Y.jsx)(`div`,{className:`text-[10px] text-shogun-text font-bold mt-0.5`,children:r})]},t)})})]})},e.tier))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(p,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Constitutional Guardrails`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The AI's inviolable laws — written by you, enforced by the system.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-gold`}),` How It Works`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Constitution is a YAML document written in the Kaizen page. Each rule has a `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`description`}),`, `,(0,Y.jsx)(`strong`,{children:`priority level`}),` (critical, high, balanced, medium, low), and `,(0,Y.jsx)(`strong`,{children:`enforcement mode`}),`. Before any agent action is executed, the system checks it against every constitutional rule in priority order. Critical rules are checked first.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-shogun-gold`}),` Enforcement Modes`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Rules can be set to different enforcement modes: `,(0,Y.jsx)(`strong`,{children:`Block`}),` (action is stopped entirely), `,(0,Y.jsx)(`strong`,{children:`Warn`}),` (action proceeds but a warning is logged), or `,(0,Y.jsx)(`strong`,{children:`Audit`}),` (action proceeds silently, logged for later review). Critical safety rules should always use "Block" mode.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(w,{className:`w-4 h-4 text-shogun-gold`}),` Revision History`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every time you publish the Constitution, a new revision is saved. You can review all past versions in the Kaizen sidebar. This creates an immutable audit trail — you can always see who changed what and when. Useful for compliance and debugging unexpected behavior.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-shogun-gold`}),` The Mandate`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In addition to the Constitution (hard rules), the Mandate (Kaizen → Mandate tab) injects soft directives into every AI conversation. While the Constitution blocks actions, the Mandate shapes behavior — tone, language, priorities, and focus areas. Both work together to align the AI with your intentions.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-orange-400/40 pb-3`,children:[(0,Y.jsx)(H,{className:`w-6 h-6 text-orange-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`ToolGate — Runtime Tool Enforcement`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The policy-aware control surface and enforcement engine for capability ceilings, risk, confirmations, overrides, and parameter-sensitive runtime decisions.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-orange-400`}),` How It Works`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Torii`}),` selects the built-in tier or custom policy. `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` loads that policy's stable scope, displays its capability ceiling, and intercepts every native tool call before execution. It combines the inherited risk mode, capability boundary, parameter analysis, per-tool override, and advanced content rules into one effective `,(0,Y.jsx)(`strong`,{children:`ALLOW`}),`, `,(0,Y.jsx)(`strong`,{children:`CONFIRM`}),`, or `,(0,Y.jsx)(`strong`,{children:`BLOCK`}),` verdict.`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Katana controls whether a tool is installed or connected, while PostureGuard controls which tools are visible to the agent. ToolGate remains the final runtime authorization layer even for visible, connected tools. A connected email tool can therefore be available in Katana but still require confirmation or be blocked by ToolGate.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4 text-red-400`}),` Risk Classification`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every native tool is classified with a `,(0,Y.jsx)(`strong`,{children:`risk score`}),` from 0.0 (harmless) to 1.0 (critical). The classification is based on four risk dimensions:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Data exfiltration:`}),` Can this tool send data outside the system? (send_email, external API calls)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Destructive mutation:`}),` Can this tool permanently alter or delete data? (file write, database operations)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Autonomy escalation:`}),` Can this tool spawn new processes or grant itself more power? (spawn_samurai, create_cron_job)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Physical world impact:`}),` Can this tool affect the real world? (desktop_click, desktop_type, send_email)`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-shogun-gold`}),` Tier-Based Thresholds`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Each built-in tier defines the baseline thresholds for its ToolGate scope. A custom policy inherits the default risk mode of its base tier while keeping its own capability boundaries, tool overrides, and advanced rules:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Confirm threshold:`}),` Tools with risk scores above this require human confirmation before executing.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Block threshold:`}),` Tools with risk scores above this are blocked entirely — no amount of confirmation can override.`]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A policy override or parameter/content rule may tighten that baseline, but it cannot widen a blocked capability boundary or a centrally managed Gensui rule.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-shogun-gold`}),` Parameter-Aware Analysis`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`ToolGate doesn't just check the tool name — it inspects the actual parameters. The `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`check_tool_access`}),` function analyzes:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Target paths:`}),` File operations targeting system directories get elevated risk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Email recipients:`}),` External domains may trigger higher scrutiny than internal ones.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Cron schedules:`}),` Very frequent schedules (every minute) are flagged as higher risk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shell commands:`}),` Commands containing `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`rm`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`sudo`}),`, or pipe chains get elevated risk.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-shogun-blue`}),` Dual-Path Enforcement`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`ToolGate enforces on `,(0,Y.jsx)(`strong`,{children:`both`}),` tool execution paths in the system:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Structured mode:`}),` When the AI uses JSON-formatted tool calls (standard mode), ToolGate intercepts in the structured execution pipeline before `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`execute_native_tool`}),` is called.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Text mode:`}),` When the AI uses text-based tool invocation (fallback mode), ToolGate intercepts in the text-mode extraction pipeline before the tool function is dispatched.`]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`This ensures no tool call can bypass ToolGate regardless of the AI model's response format.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-blue`}),` Audit Trail`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every ToolGate decision is logged with its provenance: tool name, parameters, computed risk, active policy scope and base tier, decision, source, reason, and any matching advanced content rule. Blocked and confirmed events appear in the `,(0,Y.jsx)(`strong`,{children:`Risk`}),` and `,(0,Y.jsx)(`strong`,{children:`Policy`}),` views of Logs. These entries are dual-written to both Layer 1 (operational, 90-day retention) and Layer 2 (immutable HMAC chain, 7-year retention).`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-500/40 pb-3`,children:[(0,Y.jsx)(o,{className:`w-6 h-6 text-red-500`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Harakiri — Emergency Protocol`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The nuclear option. When everything else fails, this stops the world.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card border-l-4 border-red-500 bg-red-500/[0.02] space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4`}),` What Happens When Activated`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`All agent activity is immediately frozen.`}),` Running tasks are interrupted mid-execution. No new tasks can be started.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security posture locks to SHRINE`}),` (maximum protection). Filesystem, network, shell, and tool access are all revoked.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`A pulsing red banner appears`}),` at the top of every page in the system, alerting all users that the kill switch is active.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`A critical log entry is created`}),` with the timestamp and reason for activation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`External connections are severed.`}),` Telegram bot, Nexus peers, and outgoing API calls are all paused.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-red-400`}),` Activation & Recovery`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Two-step confirmation:`}),` You must click the Harakiri button, then confirm in a modal dialog. This prevents accidental activation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Available from two locations:`}),` The Dashboard (Tenshu) and the Security Portal (Torii). Both trigger the same global mechanism.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`To recover:`}),` Click "Reset Harakiri" on the banner or from the Torii page. The posture returns to TACTICAL (the safe default). You must then manually re-enable any higher postures if desired.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`No data is lost.`}),` Harakiri only freezes operations — it does not delete or modify any data, memories, agents, or settings.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`bg-[#0a0505] border border-red-500/20 p-4 rounded-xl`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-red-500 font-bold uppercase tracking-widest mb-2`,children:`When to Use Harakiri`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Use the kill switch when: you observe unexpected or harmful agent behavior, you suspect your API keys have been compromised, an agent is consuming excessive resources, or you need to perform a security audit. When in doubt, press the button — it's always better to freeze and investigate than to let a problem escalate.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(y,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Operational Security Best Practices`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Recommended practices for maintaining a secure Shogun deployment.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-shogun-blue`}),` Rotate API Keys Regularly`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`API keys for AI providers should be rotated periodically. If you suspect a key has been exposed, revoke it immediately from the provider's dashboard and update it in Katana → Cloud Providers.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-shogun-blue`}),` Use the Compliance Dashboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Logs page is your compliance nerve center. Make it a habit to check the `,(0,Y.jsx)(`strong`,{children:`Decision`}),` tab to review AI reasoning provenance, the `,(0,Y.jsx)(`strong`,{children:`Risk`}),` tab for security tier warnings and denied tools, the `,(0,Y.jsx)(`strong`,{children:`Oversight`}),` tab for human review actions, the `,(0,Y.jsx)(`strong`,{children:`Incident`}),` tab for critical alerts (model API failures, kill switch activations, chain integrity violations), and the `,(0,Y.jsx)(`strong`,{children:`System`}),` tab for server lifecycle and governance config changes. Verify the audit chain stays intact. Export the immutable audit log regularly for off-site archival — this is your evidence for NIS2, SOC2, and EU AI Act compliance.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-shogun-blue`}),` Test Posture Changes in SHRINE`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Before upgrading to a higher security posture (e.g., TACTICAL → CAMPAIGN), test your constitutional rules in SHRINE mode first. This ensures your guardrails are properly configured before giving agents more freedom.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-shogun-blue`}),` Isolate RONIN Environments`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`If you need RONIN (unrestricted) mode for testing, run it on an isolated machine or VM with no access to production data, credential stores, or external services. Never run RONIN on a machine connected to your main network.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-shogun-blue`}),` Backup Before Major Changes`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Before changing the security posture, modifying the Constitution, or deploying new agents, export a backup via the Data Management tab. This gives you a restore point if something goes wrong.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-shogun-blue`}),` Limit Nexus Peer Access`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Only invite trusted Shogun instances as peers in Nexus. Every peer can send messages and propose tasks. Verify the identity of remote agents before accepting workspace invitations. Remove inactive or unknown peers promptly.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-amber-500/40 pb-3`,children:[(0,Y.jsx)(E,{className:`w-6 h-6 text-amber-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`ToolGate — Runtime Tool Enforcement`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The runtime behavior of the ToolGate policy selected in Torii, including local and centrally managed operation.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`ToolGate sits between PostureGuard (which determines `,(0,Y.jsx)(`em`,{children:`which tools are visible`}),`) and the executor that runs them. It provides policy-scoped, per-call enforcement based on capability boundaries, risk mode, tool overrides, parameter analysis, and advanced word or phrase rules. In standalone Tenshu it is editable locally; while connected to Gensui, the local ToolGate is read-only and the last valid centrally managed policy remains enforced during temporary outages.`]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,Y.jsxs)(`div`,{className:`bg-emerald-500/5 border border-emerald-500/20 rounded-lg p-3 space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-emerald-400 uppercase tracking-wider`,children:`ALLOW`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Low-risk tools (browse, fetch, list) execute immediately with no interruption.`})]}),(0,Y.jsxs)(`div`,{className:`bg-amber-500/5 border border-amber-500/20 rounded-lg p-3 space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400 uppercase tracking-wider`,children:`CONFIRM`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`High-risk tools (send email, desktop control) pause and show a confirmation card in the chat. You must click Approve or Deny before execution proceeds.`})]}),(0,Y.jsxs)(`div`,{className:`bg-red-500/5 border border-red-500/20 rounded-lg p-3 space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-red-400 uppercase tracking-wider`,children:`BLOCK`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Critical-risk or destructive patterns are blocked outright. The tool receives a "blocked" response, and the AI must find an alternative approach.`})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4 text-amber-400`}),` Risk Classification`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every tool in the registry is assigned a risk level: `,(0,Y.jsx)(`strong`,{className:`text-emerald-400`,children:`LOW`}),` (read-only, no side effects), `,(0,Y.jsx)(`strong`,{className:`text-amber-400`,children:`MEDIUM`}),` (creates/modifies internal state), `,(0,Y.jsx)(`strong`,{className:`text-orange-400`,children:`HIGH`}),` (external side effects or control actions), or `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`CRITICAL`}),` (destructive or irreversible). The Mode × Risk threshold matrix determines the default action for each combination.`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-amber-400`}),` Parameter-Aware Checks`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Beyond the static risk level, ToolGate recursively inspects nested arguments. Built-in analysis detects destructive commands, sensitive paths, recursive deletion, mass operations, credential-like input, and force flags. `,(0,Y.jsx)(`strong`,{children:`Advanced mode`}),` adds operator-defined words or phrases with whole-word or substring matching, optional case sensitivity, global or tool-specific scope, and a CONFIRM or BLOCK outcome. These checks can only tighten the final decision.`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ee,{className:`w-4 h-4 text-amber-400`}),` Confirmation Timeout`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When a confirmation card appears, you have `,(0,Y.jsx)(`strong`,{children:`60 seconds`}),` to respond. If the timer expires, the tool is `,(0,Y.jsx)(`strong`,{children:`auto-denied`}),` for safety. The AI receives a "denied by operator" result and can adapt its approach.`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-purple-500/40 pb-3`,children:[(0,Y.jsx)(ce,{className:`w-6 h-6 text-purple-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Quarantine — Shogun Trash`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Recoverable soft-delete for file operations.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When Shogun deletes a file (via Ronin desktop automation or future file tools), the file is not permanently removed. Instead, it is moved to a `,(0,Y.jsx)(`code`,{className:`text-amber-400 bg-black/30 px-1.5 py-0.5 rounded`,children:`.shogun_trash/`}),` directory at the project root. This acts as a safety net against accidental or AI-initiated data loss.`]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Quarantine`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Files are timestamped and moved to trash. A manifest.json tracks the original path, deletion reason, file size, and timestamp.`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Recover`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Any quarantined file can be restored to its original location via the recovery function. No data is permanently lost until explicitly purged.`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Auto-Purge`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Files older than 30 days are eligible for automatic permanent deletion. This prevents unbounded disk growth while preserving recent safety net coverage.`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Audit Trail`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Every quarantine and recovery action is logged. The manifest provides a complete history of what was deleted, when, and why.`})]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(o,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Threat Model`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Known risk categories and how Shogun mitigates them.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4`}),` Prompt Injection`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` Malicious input that tricks the AI into ignoring its rules. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` Constitutional rules are enforced server-side and cannot be overridden by prompt content. The security posture applies independently of the AI's decision-making.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4`}),` Credential Exposure`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` API keys or secrets leaking through agent responses or logs. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` Keys are stored encrypted in the database and never included in prompts or agent context. The frontend never receives raw key values — only masked previews.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4`}),` Runaway Agent`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` An agent entering a loop, spawning unlimited sub-agents, or consuming excessive API credits. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` Spawn policies limit auto-spawning. The Harakiri kill switch provides instant global shutdown. Resource monitoring in Bushido flags anomalies.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(o,{className:`w-4 h-4`}),` Unauthorized Peer Access`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` A malicious Shogun instance connecting as a peer and injecting harmful tasks. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` All A2A messages are cryptographically signed. Peers must be explicitly invited by URL. Workspace deletion removes all peer access immediately.`]})]})]})]})]}),(0,Y.jsx)(`div`,{className:`mt-16 pt-8 border-t border-shogun-border/40`,children:(0,Y.jsx)(`div`,{className:`shogun-card bg-orange-500/5 border-orange-500/20`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Y.jsx)(o,{className:`w-6 h-6 text-orange-400 shrink-0 mt-1`}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-orange-400`}),e(`guide.disclaimer_title`,`Legal Disclaimer`)]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e(`guide.disclaimer_body`,`Shogun is provided for general informational, experimental, and operational use only. It is provided “as is” and “as available,” without warranties of any kind, express or implied, including but not limited to accuracy, fitness for a particular purpose, merchantability, availability, or non-infringement. Users are solely responsible for evaluating, validating, monitoring, and approving any outputs, actions, configurations, or decisions made with or through Shogun. Alpha Horizon disclaims liability for any direct, indirect, incidental, consequential, or special damages arising from the use of, or inability to use, Shogun, except where such limitation is not permitted by applicable law.`)}),(0,Y.jsx)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg border-l-4 border-l-orange-400`,children:(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e(`guide.disclaimer_oversight`,`Human oversight required: Shogun may generate inaccurate, incomplete, or inappropriate outputs. It must not be relied upon without appropriate human review, especially in legal, financial, compliance, security, or other high-impact contexts.`)})})]})]})})})]})]})}export{$ as Guide}; \ No newline at end of file diff --git a/frontend/dist/assets/Guide-GLLDQu_k.js b/frontend/dist/assets/Guide-GLLDQu_k.js deleted file mode 100644 index d20def9..0000000 --- a/frontend/dist/assets/Guide-GLLDQu_k.js +++ /dev/null @@ -1,32 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{t as i}from"./preload-helper-D4M6sveU.js";import{t as a}from"./activity-D6ZKsL_W.js";import{t as o}from"./app-window-pINhreuP.js";import{n as s,t as c}from"./flame-CTTn1GjH.js";import{t as ee}from"./book-open-2svOUQwn.js";import{t as l}from"./brain-circuit-DqQf8Qkj.js";import{t as te}from"./camera-DjFKI4Th.js";import{t as u}from"./circle-alert-DVHRBFRQ.js";import{t as d}from"./circle-check-D9mntLsp.js";import{t as ne}from"./circle-question-mark-qh8t_nrj.js";import{t as re}from"./clock-B8iyCT3M.js";import{t as f}from"./compass-CbaQ9b1l.js";import{t as p}from"./cpu-jON2DlCR.js";import{t as m}from"./crosshair-IDZ5dQs8.js";import{t as h}from"./database-B_RLhoAx.js";import{t as g}from"./download-OoiqiOHD.js";import{t as _}from"./external-link-Cfo2qohD.js";import{t as v}from"./eye-DuX8zHAU.js";import{t as ie}from"./file-key-B5dIYAeh.js";import{t as y}from"./file-spreadsheet-CsZ2n5Og.js";import{t as b}from"./file-text-Db8l8y7y.js";import{t as x}from"./folder-open-C_e4r6rd.js";import{t as ae}from"./funnel-BttEh0de.js";import{t as S}from"./git-branch-eFNiJwrC.js";import{t as oe}from"./git-merge-B6sFCDV0.js";import{t as C}from"./globe-CSe1LLSr.js";import{t as w}from"./hard-drive-CKvWVafA.js";import{t as T}from"./key-B6HBhf9q.js";import{t as E}from"./layers-4dQLphXM.js";import{t as D}from"./link-2-DtQcNcp-.js";import{t as O}from"./lock-CYZB3Koj.js";import{t as k}from"./mail-CjEwmRbK.js";import{t as A}from"./message-square-D4G-UYnF.js";import{t as j}from"./monitor-DhSxAiCm.js";import{t as M}from"./network-RTAno7O_.js";import{t as N}from"./package-CVNMjeKj.js";import{n as P,t as se}from"./route-B0unASBQ.js";import{t as ce}from"./power-BmbVankB.js";import{t as F}from"./refresh-cw-CCrS0Omg.js";import{t as I}from"./search-CCF8DUSp.js";import{t as L}from"./shield-alert-ClN8pu2X.js";import{t as R}from"./shield-check-4WxAMs16.js";import{t as z}from"./shield-B_MY4jWU.js";import{t as le}from"./sliders-horizontal-D4RY2Aan.js";import{t as B}from"./sparkles-DddBjN-5.js";import{t as V}from"./star-HhdEV9Ok.js";import{t as ue}from"./sword-TTbEsDHx.js";import{t as H}from"./terminal-CmBetb-2.js";import{t as U}from"./trash-2-Cid5DKqF.js";import{t as W}from"./users-D7R1ctQe.js";import{t as de}from"./workflow-DS_AVE1X.js";import{t as G}from"./zap-BMpqZS6N.js";import{t as K}from"./utils-wrb6h48Y.js";import{r as fe}from"./i18n-FxgwkwP0.js";var pe=e(`calendar-days`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}],[`path`,{d:`M8 14h.01`,key:`6423bh`}],[`path`,{d:`M12 14h.01`,key:`1etili`}],[`path`,{d:`M16 14h.01`,key:`1gbofw`}],[`path`,{d:`M8 18h.01`,key:`lrp35t`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M16 18h.01`,key:`kzsmim`}]]),me=e(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),q=e(`panels-top-left`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 9h18`,key:`1pudct`}],[`path`,{d:`M9 21V9`,key:`1oto5p`}]]),he=e(`printer`,[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]),J=t(n(),1),Y=r(),X=Object.assign({"../i18n/guide/da.json":()=>i(()=>import(`./da-CUl2nAxQ.js`),[]),"../i18n/guide/de.json":()=>i(()=>import(`./de-CKXBKCdQ.js`),[]),"../i18n/guide/en.json":()=>i(()=>import(`./en-CGMLEiIe.js`),[]),"../i18n/guide/es.json":()=>i(()=>import(`./es-BIO-Fzjk.js`),[]),"../i18n/guide/fr.json":()=>i(()=>import(`./fr-CdiV4bnx.js`),[]),"../i18n/guide/hi.json":()=>i(()=>import(`./hi-DvAXEQco.js`),[]),"../i18n/guide/it.json":()=>i(()=>import(`./it-Ctlfc5Ye.js`),[]),"../i18n/guide/ja.json":()=>i(()=>import(`./ja-C60STqvx.js`),[]),"../i18n/guide/ko.json":()=>i(()=>import(`./ko-BlbkoPlm.js`),[]),"../i18n/guide/no.json":()=>i(()=>import(`./no-CRYdIc84.js`),[]),"../i18n/guide/pl.json":()=>i(()=>import(`./pl-NSA4ufTs.js`),[]),"../i18n/guide/pt.json":()=>i(()=>import(`./pt-Da_bGDrX.js`),[]),"../i18n/guide/sv.json":()=>i(()=>import(`./sv-CVXRNJrZ.js`),[]),"../i18n/guide/uk.json":()=>i(()=>import(`./uk-cJ6O5vCR.js`),[]),"../i18n/guide/zh.json":()=>i(()=>import(`./zh-BGPYDBBr.js`),[])}),Z={},Q=new WeakMap;async function ge(e){if(Z[e])return Z[e];let t=X[`../i18n/guide/${e}.json`];if(!t)return{};try{let n=(await t()).default;return Z[e]=n,n}catch(t){return console.error(`[guide-i18n] Failed to load the ${e} Guide catalog`,t),{}}}function _e(e,t){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=n.nextNode();for(;r;){if(!r.parentElement?.closest(`code, pre, script, style, svg`)){let e=r.nodeValue??``,n=Q.get(r),i=n??e,a=i.trim();if(a&&(n!==void 0||Object.prototype.hasOwnProperty.call(t,a))){n===void 0&&Q.set(r,i);let e=i.match(/^\s*/)?.[0]??``,o=i.match(/\s*$/)?.[0]??``;r.nodeValue=`${e}${t[a]??a}${o}`}}r=n.nextNode()}}function $(){let{t:e,language:t}=fe(),[n,r]=(0,J.useState)(`onboarding`),[i,X]=(0,J.useState)(`ref-tenshu`),Z=(0,J.useRef)(null),Q=(0,J.useRef)(null),$=[{id:`ref-tenshu`,label:`Tenshu`,icon:q,color:`text-shogun-blue`},{id:`ref-server`,label:`Server Mode`,icon:N,color:`text-emerald-400`},{id:`ref-comms`,label:`Comms`,icon:A,color:`text-shogun-blue`},{id:`ref-profile`,label:`Shogun Profile`,icon:p,color:`text-shogun-gold`},{id:`ref-flowstack`,label:`Flow Stacking`,icon:E,color:`text-violet-400`},{id:`ref-samurai`,label:`Samurai Network`,icon:W,color:`text-shogun-gold`},{id:`ref-katana`,label:`Katana`,icon:ue,color:`text-shogun-blue`},{id:`ref-telegram`,label:`Telegram Setup`,icon:A,color:`text-sky-400`},{id:`ref-teams`,label:`Teams Setup`,icon:W,color:`text-indigo-400`},{id:`ref-archives`,label:`Archives`,icon:h,color:`text-shogun-gold`},{id:`ref-dojo`,label:`Dojo`,icon:c,color:`text-shogun-gold`},{id:`ref-kaizen`,label:`Kaizen`,icon:R,color:`text-shogun-gold`},{id:`ref-bushido`,label:`Bushido`,icon:F,color:`text-shogun-blue`},{id:`ref-mado`,label:`Mado`,icon:o,color:`text-cyan-400`},{id:`ref-ronin`,label:`Ronin`,icon:m,color:`text-orange-400`},{id:`ref-office`,label:`Office`,icon:y,color:`text-green-400`},{id:`ref-workspace`,label:`Workspace`,icon:x,color:`text-amber-400`},{id:`ref-torii`,label:`Torii`,icon:O,color:`text-red-400`},{id:`ref-toolgate`,label:`ToolGate`,icon:z,color:`text-orange-400`},{id:`ref-nexus`,label:`Nexus`,icon:C,color:`text-indigo-400`},{id:`ref-nexus-gateway`,label:`Nexus Gateway`,icon:D,color:`text-indigo-400`},{id:`ref-gensui`,label:`Gensui`,icon:L,color:`text-indigo-400`},{id:`ref-logs`,label:`Logs`,icon:H,color:`text-shogun-subdued`},{id:`ref-maintenance`,label:`Maintenance`,icon:w,color:`text-shogun-gold`},{id:`ref-visual-intake`,label:`Visual Intake`,icon:v,color:`text-cyan-400`},{id:`ref-ide-mode`,label:`IDE Mode`,icon:j,color:`text-emerald-400`},{id:`ref-model-router`,label:`Model Router`,icon:se,color:`text-blue-400`},{id:`ref-active-skills`,label:`Active Skills`,icon:B,color:`text-amber-400`},{id:`ref-skillopt`,label:`SkillOpt`,icon:l,color:`text-fuchsia-400`}],ve=(0,J.useCallback)(e=>{let t=document.getElementById(e);t&&(t.scrollIntoView({behavior:`smooth`,block:`start`}),X(e))},[]),ye=(0,J.useCallback)(()=>{let e=Q.current;if(!e)return;let n=window.open(``,`_blank`,`width=1100,height=800`);if(!n){window.alert(`Please allow pop-ups to print the Grand Reference.`);return}n.opener=null;let r=Array.from(document.querySelectorAll(`link[rel="stylesheet"], style`)).map(e=>e instanceof HTMLLinkElement?``:e.outerHTML).join(` -`),i=e.querySelector(`h3`)?.textContent?.trim()||`The Grand Reference`;n.document.open(),n.document.write(` - - - - - ${i} - ${r} - - - -
${e.innerHTML}
- - `),n.document.close();let a=()=>{n.focus(),n.print()};n.document.readyState===`complete`?window.setTimeout(a,250):n.addEventListener(`load`,()=>window.setTimeout(a,250),{once:!0})},[t]);return(0,J.useEffect)(()=>{if(n!==`reference`)return;let e=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&X(t.target.id)},{rootMargin:`-80px 0px -60% 0px`,threshold:.1}),t=setTimeout(()=>{$.forEach(({id:t})=>{let n=document.getElementById(t);n&&e.observe(n)})},100);return()=>{clearTimeout(t),e.disconnect()}},[n]),(0,J.useEffect)(()=>{let e=!1;return ge(t).then(t=>{!e&&Z.current&&_e(Z.current,t)}),()=>{e=!0}},[n,t]),(0,Y.jsxs)(`div`,{ref:Z,className:`max-w-7xl mx-auto space-y-8 animate-in fade-in duration-500 pb-20`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-6`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`h2`,{className:`text-4xl font-bold shogun-title flex items-center gap-4`,children:[e(`guide.title`,`Framework Guide`),(0,Y.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-1 rounded border border-shogun-border tracking-[0.3em] uppercase`,children:e(`guide.badge`,`Knowledge Base`)})]}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`guide.subtitle`,`Master the Shogun architecture, operations, and system maintenance.`)})]})}),(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 p-1 bg-shogun-card border border-shogun-border rounded-xl w-fit`,children:[{id:`onboarding`,label:e(`guide.tab_onboarding`,`Onboarding`),icon:f},{id:`reference`,label:e(`guide.tab_reference`,`Reference Manual`),icon:ee},{id:`architecture`,label:e(`guide.tab_architecture`,`Architecture`),icon:p},{id:`safety`,label:e(`guide.tab_safety`,`Safety Protocols`),icon:R}].map(e=>(0,Y.jsxs)(`button`,{onClick:()=>r(e.id),className:K(`flex items-center gap-2 px-6 py-2.5 rounded-lg text-xs font-bold uppercase tracking-widest transition-all`,n===e.id?`bg-shogun-blue text-white shadow-lg`:`text-shogun-subdued hover:text-shogun-text hover:bg-shogun-bg`),children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4`}),e.label]},e.id))}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 gap-8`,children:[n===`onboarding`&&(0,Y.jsxs)(`div`,{className:`space-y-8 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsxs)(`section`,{className:`shogun-card border-l-4 border-shogun-blue`,children:[(0,Y.jsxs)(`h3`,{className:`text-xl font-bold text-shogun-text mb-4 flex items-center gap-3`,children:[(0,Y.jsx)(G,{className:`w-6 h-6 text-shogun-blue`}),`Your Journey Begins`]}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed mb-6`,children:`Welcome to Shogun. You are not just running a tool; you are commanding a distributed cognitive lattice. This system is designed for high-stakes automation, deep research, and secure agent-to-agent collaboration. This guide will walk you through everything you need to go from zero to fully operational.`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,Y.jsxs)(`div`,{className:`p-4 bg-shogun-bg border border-shogun-border rounded-xl`,children:[(0,Y.jsx)(`div`,{className:`text-shogun-blue font-bold text-lg mb-1`,children:`1. Connect Brains`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Head to `,(0,Y.jsx)(`strong`,{children:`Katana`}),` to add your API keys or local models. This is where your AI's "intelligence" comes from.`]})]}),(0,Y.jsxs)(`div`,{className:`p-4 bg-shogun-bg border border-shogun-border rounded-xl`,children:[(0,Y.jsx)(`div`,{className:`text-shogun-gold font-bold text-lg mb-1`,children:`2. Train Skills`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Visit the `,(0,Y.jsx)(`strong`,{children:`Dojo`}),` to browse 4,000+ specialized skills. Certify your agents for specific task categories.`]})]}),(0,Y.jsxs)(`div`,{className:`p-4 bg-shogun-bg border border-shogun-border rounded-xl`,children:[(0,Y.jsx)(`div`,{className:`text-green-500 font-bold text-lg mb-1`,children:`3. Start Chatting`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Open `,(0,Y.jsx)(`strong`,{children:`Tenshu`}),` or the global chat. Your Shogun is now ready to assist, research, and execute.`]})]})]}),(0,Y.jsxs)(`div`,{id:`ref-telegram`,className:`shogun-card space-y-6 scroll-mt-6 border-sky-400/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2 text-base`,children:[(0,Y.jsx)(A,{className:`w-5 h-5 text-sky-400`}),` Telegram — Complete Beginner Setup`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Use Telegram on your phone or computer to talk directly to your Shogun.`})]}),(0,Y.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-sky-400 bg-sky-400/10 border border-sky-400/20 px-2.5 py-1 rounded-full w-fit`,children:`About 10–15 minutes`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg border border-sky-400/20 bg-sky-400/5`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-bold`,children:`The easiest supported choice`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[`Choose `,(0,Y.jsx)(`strong`,{children:`Polling`}),`. It works while Shogun is running and does not require a public website or router changes. Although the screen also shows a Webhook option, the listener in this release operates by polling. Use Webhook only if an administrator has supplied a separate compatible webhook receiver.`]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text mb-3`,children:`Before you begin`}),(0,Y.jsx)(`div`,{className:`grid sm:grid-cols-3 gap-3`,children:[[`Telegram account`,`Install Telegram and sign in on your phone or computer.`],[`Running Shogun`,`Shogun must remain open and have internet access to receive messages.`],[`Private test first`,`Connect a private one-to-one chat before trying a Telegram group.`]].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed mt-1`,children:t})]},e))})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part A — Create your Telegram bot`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Open the official `,(0,Y.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-sky-400 hover:underline font-bold`,children:`@BotFather`}),` chat. Check the username carefully: it must be exactly `,(0,Y.jsx)(`code`,{children:`@BotFather`}),` and should show Telegram's verification mark.`]}),(0,Y.jsxs)(`li`,{children:[`Press `,(0,Y.jsx)(`strong`,{children:`Start`}),`, or type `,(0,Y.jsx)(`code`,{children:`/start`}),`. Then type `,(0,Y.jsx)(`code`,{children:`/newbot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`BotFather asks for a display name. This is the friendly name people see, for example `,(0,Y.jsx)(`code`,{children:`My Shogun`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Choose a unique username. Telegram requires 5–32 Latin letters, numbers, or underscores, and the username must end in `,(0,Y.jsx)(`code`,{children:`bot`}),`, for example `,(0,Y.jsx)(`code`,{children:`northwind_shogun_bot`}),`.`]}),(0,Y.jsx)(`li`,{children:`BotFather returns a long token containing numbers, a colon, and letters. Copy the entire token. Treat it exactly like a password: anyone who has it can control the bot. Never paste it into email, screenshots, tickets, or chat messages.`})]}),(0,Y.jsxs)(`a`,{href:`https://core.telegram.org/bots/features#botfather`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-sky-400 hover:underline`,children:[(0,Y.jsx)(_,{className:`w-3 h-3`}),` Official Telegram BotFather instructions`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part B — Connect the bot to Shogun`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`In Shogun, open `,(0,Y.jsx)(`strong`,{children:`The Katana → Telegram`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Paste the token into `,(0,Y.jsx)(`strong`,{children:`Bot Token`}),`. Leave the eye icon closed unless you need to check what you pasted.`]}),(0,Y.jsxs)(`li`,{children:[`Select `,(0,Y.jsx)(`strong`,{children:`Polling`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`For this first connection, leave `,(0,Y.jsx)(`strong`,{children:`Allowed Chat IDs`}),` empty. This temporary step lets Shogun discover your ID. Do not leave it empty permanently, because an empty list allows every Telegram chat that can reach the bot.`]}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Connect Bot`}),`. Success is shown as a green `,(0,Y.jsx)(`strong`,{children:`Connected`}),` badge and the bot's username.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part C — Find and save your Chat ID safely`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Return to Telegram and open the new bot using the link from BotFather or by searching for its username.`}),(0,Y.jsxs)(`li`,{children:[`Press `,(0,Y.jsx)(`strong`,{children:`Start`}),` and send a simple message such as `,(0,Y.jsx)(`code`,{children:`Hello`}),`. A bot cannot begin a private conversation until you contact it first.`]}),(0,Y.jsxs)(`li`,{children:[`Return to `,(0,Y.jsx)(`strong`,{children:`Katana → Telegram`}),` and click `,(0,Y.jsx)(`strong`,{children:`Auto-detect Chat ID`}),`. Your personal Chat ID should appear in both the test field and the Allowed Chat IDs field.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Important:`}),` auto-detect fills the form but does not save the whitelist by itself. Paste the same bot token into `,(0,Y.jsx)(`strong`,{children:`Bot Token`}),` again, confirm Polling is selected, and click `,(0,Y.jsx)(`strong`,{children:`Update Connection`}),`. This second save makes the whitelist permanent.`]}),(0,Y.jsxs)(`li`,{children:[`Enter the detected ID under `,(0,Y.jsx)(`strong`,{children:`Test Connection`}),` and click `,(0,Y.jsx)(`strong`,{children:`Send Test`}),`. Telegram should receive “Shogun Test Message.”`]}),(0,Y.jsxs)(`li`,{children:[`Send `,(0,Y.jsx)(`code`,{children:`Hello Shogun`}),` to the bot. A normal AI reply confirms that both incoming and outgoing communication work.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-shogun-bg border border-shogun-border space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-shogun-text`,children:`Optional: use the bot in a group`}),(0,Y.jsxs)(`ol`,{className:`text-[11px] text-shogun-subdued space-y-2 ml-4 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Add the bot to the Telegram group.`}),(0,Y.jsxs)(`li`,{children:[`Send a command addressed to it, such as `,(0,Y.jsx)(`code`,{children:`/start@your_bot_name`}),`, or reply directly to one of its messages.`]}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Auto-detect Chat ID`}),` again. Group IDs are normally negative numbers.`]}),(0,Y.jsxs)(`li`,{children:[`Add that negative ID to Allowed Chat IDs, paste the token again, and click `,(0,Y.jsx)(`strong`,{children:`Update Connection`}),`.`]})]}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Telegram Privacy Mode is enabled for group bots by default. The bot normally sees commands, direct mentions, and replies—not every group message. This is the safer default. If an administrator disables Privacy Mode in BotFather, remove and re-add the bot to the group afterward.`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-shogun-bg border border-shogun-border space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-shogun-text`,children:`Security checklist`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Keep at least one Allowed Chat ID saved.`}),(0,Y.jsx)(`li`,{children:`Use a separate bot for testing and production.`}),(0,Y.jsx)(`li`,{children:`Only run one Shogun instance with a given token; two pollers can compete for the same messages.`}),(0,Y.jsx)(`li`,{children:`If the token is exposed, regenerate or revoke it in BotFather, then reconnect Shogun with the replacement.`}),(0,Y.jsx)(`li`,{children:`Disconnect the bot in Katana when remote access is no longer needed.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Telegram troubleshooting`}),(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left bg-shogun-bg text-shogun-subdued`,children:[(0,Y.jsx)(`th`,{className:`p-3`,children:`What you see`}),(0,Y.jsx)(`th`,{className:`p-3`,children:`What to do`})]})}),(0,Y.jsxs)(`tbody`,{className:`divide-y divide-shogun-border text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Invalid token or HTTP 401`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Copy the complete token from BotFather again. A revoked token automatically disconnects the listener.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Auto-detect finds nothing`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Send a fresh message directly to the bot, wait a few seconds, then retry. Confirm no other application is consuming updates for the same token.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Test works, but your messages are ignored`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Check that your exact Chat ID is in Allowed Chat IDs and that you completed the second Update Connection save.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Group messages are ignored`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Mention the bot, use a command, or reply to it. Check the negative group ID and Telegram Privacy Mode.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Replies stop when the computer sleeps`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Keep Shogun running on an awake, internet-connected computer or server. Polling is performed by Shogun itself.`})]})]})]})})]})]})]}),(0,Y.jsx)(`section`,{className:`shogun-card bg-red-500/[0.04] border-red-500/20 border-l-4 border-l-red-500`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center gap-4`,children:[(0,Y.jsx)(`div`,{className:`p-3 rounded-xl bg-red-500/10 border border-red-500/20 shrink-0 w-fit`,children:(0,Y.jsx)(P,{className:`w-8 h-8 text-red-500`})}),(0,Y.jsxs)(`div`,{className:`space-y-2 flex-1`,children:[(0,Y.jsxs)(`h3`,{className:`text-lg font-bold text-shogun-text flex items-center gap-2`,children:[`Complete Video Guide`,(0,Y.jsx)(`span`,{className:`text-[9px] font-bold text-red-400 bg-red-500/10 px-2 py-0.5 rounded-full uppercase tracking-widest`,children:`YouTube`})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Prefer video? Watch the full Shogun walkthrough series — from installation to advanced workflows, agent configuration, and security setup.`}),(0,Y.jsxs)(`a`,{href:`https://www.youtube.com/@ShogunAIAgents`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 px-4 py-2 bg-red-500 hover:bg-red-600 text-white text-xs font-bold rounded-lg transition-all duration-200 shadow-lg hover:shadow-red-500/25 mt-1`,children:[(0,Y.jsx)(P,{className:`w-3.5 h-3.5`}),`Watch on YouTube`,(0,Y.jsx)(_,{className:`w-3 h-3 opacity-60`})]})]})]})}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(d,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Prerequisites`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`What you need before you begin.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-blue`}),` At Least One API Key`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`You need an API key from at least one AI provider — OpenAI, Anthropic, Google Gemini, or Perplexity. These are obtained from the provider's developer portal. Without a key, the Shogun cannot think.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(w,{className:`w-4 h-4 text-shogun-blue`}),` Or a Local Model (Optional)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`If you prefer to run AI entirely on your own machine (no internet required), install `,(0,Y.jsx)(`strong`,{children:`Ollama`}),` and pull a model like `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`llama3`}),`. Shogun will auto-detect it on the Katana → Local Models tab.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-shogun-blue`}),` A Modern Browser`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Shogun's UI is designed for modern browsers — Chrome, Edge, Firefox, or Safari. Ensure JavaScript is enabled. The interface is fully responsive and works on tablets and phones as well.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-shogun-blue`}),` Shogun Backend Running`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The backend server must be running on `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`localhost:8000`}),`. If you installed via Docker, it starts automatically. Otherwise, run `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`python -m shogun`}),` from the project root.`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(f,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`First Launch — Step by Step`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Follow these steps in order for the smoothest setup experience.`})]})]}),(0,Y.jsx)(`div`,{className:`space-y-4`,children:[{step:1,title:`Add Your First AI Provider`,color:`text-shogun-blue`,icon:T,desc:`Navigate to Katana → Cloud Providers. Click "Add Provider." Choose the provider type (e.g., OpenAI), paste your API key, and save. Within seconds, all available models from that provider will appear as options throughout Shogun.`},{step:2,title:`Choose a Routing Profile`,color:`text-shogun-blue`,icon:p,desc:`Go to Katana → Model Routing. Choose a routing profile, or use Custom to select an ordered primary and fallback model list from your connected providers.`},{step:3,title:`Review Your Security Posture`,color:`text-red-400`,icon:O,desc:`Visit Torii (Security). The default posture is TACTICAL — a balanced setting that gives the AI enough freedom for productive work while keeping dangerous operations locked down. Read the tier descriptions and choose the level that matches your risk comfort.`},{step:4,title:`Write Your Constitution (Optional)`,color:`text-shogun-gold`,icon:b,desc:`Open Kaizen → Constitution tab. This is the AI's "rule book." The default constitution covers essential safety rules. You can add your own rules here — for example, "Never send emails without my approval" or "Always respond in formal English." Click "Publish Edicts" when done.`},{step:5,title:`Deploy Your First Samurai (Optional)`,color:`text-shogun-gold`,icon:W,desc:`Head to Samurai Network. Click "Deploy Samurai," choose a role (e.g., Researcher, Analyst), give it a name, and deploy. Your first sub-agent is now ready to receive delegated tasks from the main Shogun.`},{step:6,title:`Start a Conversation`,color:`text-green-500`,icon:A,desc:`Click "Enter Command" on the dashboard (or navigate to Comms). Type your first message. The Shogun will respond using the primary model you selected. Congratulations — you are operational!`}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card flex gap-5 items-start`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col items-center gap-2 shrink-0`,children:(0,Y.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-shogun-bg border border-shogun-border flex items-center justify-center font-bold text-lg ${e.color}`,children:e.step})}),(0,Y.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4 ${e.color}`}),e.title]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.desc})]})]},e.step))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(ee,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Core Concepts`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Key terms you'll encounter throughout the platform.`})]})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[{term:`Shogun`,def:`The main AI agent — your primary assistant. It coordinates everything, delegates to Samurai, and answers your questions directly.`,icon:p,color:`text-shogun-gold`},{term:`Samurai`,def:`Specialized sub-agents that handle specific tasks. Think of them as employees — each one has a role, a name, and a current assignment.`,icon:W,color:`text-shogun-gold`},{term:`Lattice`,def:`The network of all connected agents (Shogun + Samurai). The lattice distributes work intelligently and ensures no single agent is overwhelmed.`,icon:M,color:`text-shogun-blue`},{term:`Constitution`,def:`A set of inviolable rules written in YAML that govern what all agents are allowed to do. Managed in the Kaizen page.`,icon:b,color:`text-shogun-gold`},{term:`Security Posture`,def:`The built-in tier or custom policy selected in Torii. ToolGate turns that selection into capability boundaries and runtime ALLOW, CONFIRM, or BLOCK decisions.`,icon:O,color:`text-red-400`},{term:`Harakiri`,def:`The emergency kill switch. Instantly freezes all agent activity and locks the system to maximum security (SHRINE).`,icon:R,color:`text-red-400`},{term:`Routing Profile`,def:`A set of rules that decides which AI model handles which type of task. For example: code → GPT-4, research → Perplexity.`,icon:S,color:`text-shogun-blue`},{term:`Salience`,def:`A memory importance score (0.0–1.0). High-salience memories are retrieved first. The system auto-adjusts salience over time.`,icon:V,color:`text-shogun-gold`},{term:`Reflection Cycle`,def:`An automated self-improvement loop where the AI analyzes its own performance and generates optimization insights. Run from Bushido.`,icon:F,color:`text-shogun-blue`},{term:`Ronin (Desktop)`,def:`The desktop control capability. Allows agents to interact with OS desktops — mouse, keyboard, screenshots, and native apps. Torii selects its policy; ToolGate governs its capability boundary and runtime decisions alongside Posture Guard, App Trust, and Komainu.`,icon:m,color:`text-orange-400`},{term:`Komainu (Guardian)`,def:`The physical override system for Ronin. A three-tier safety mechanism: Level 1 (Pause), Level 2 (Terminate), Level 3 (Harakiri). Detects human mouse/keyboard input and stops the AI. Named after Japanese shrine guardians.`,icon:L,color:`text-red-400`}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4 ${e.color}`}),e.term]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.def})]},e.term))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(q,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Navigation Map`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Every page in Shogun at a glance — what it does and when to use it.`})]})]}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[{name:`Tenshu (Dashboard)`,purpose:`Your home screen. See stat cards, active agents, recent events, quick actions, and the Harakiri button. The first thing you see when you open Shogun.`,icon:q,color:`text-shogun-blue`},{name:`Comms (Chat)`,purpose:`Talk directly to your Shogun. Send questions or commands. Responses stream in real time. View chat history and restore old sessions. Also includes an integrated email client and calendar.`,icon:A,color:`text-shogun-blue`},{name:`Shogun Profile`,purpose:`Configure your AI's identity, personality, behavioral directives, and scheduled jobs. Model selection lives in Katana; security configuration lives in Torii and ToolGate.`,icon:p,color:`text-shogun-gold`},{name:`Samurai Network`,purpose:`Deploy and manage specialized sub-agents. Each Samurai has a role, routing profile, and spawn policy. Monitor their tasks and status.`,icon:W,color:`text-shogun-gold`},{name:`Katana (System Forge)`,purpose:`Install and connect AI providers, models, tools, file formats, channels, and account-specific scopes. Katana exposes capabilities; ToolGate governs whether they may run.`,icon:ue,color:`text-shogun-blue`},{name:`Archives (Memory)`,purpose:`Search, browse, create, and manage the AI's memories. Supports semantic search, salience pinning, and memory type filtering.`,icon:h,color:`text-shogun-gold`},{name:`Dojo (Training Hall)`,purpose:`Browse 4,000+ skills from the OpenClaw College. Study training material, take certification exams, and track achievements.`,icon:c,color:`text-shogun-gold`},{name:`Kaizen (Governance)`,purpose:`Write the Constitution (YAML rules) and the Mandate (Markdown mission statement). Manage revision history and audit trails.`,icon:R,color:`text-shogun-gold`},{name:`Bushido (Reflection)`,purpose:`Calibrate self-improvement behavior. Tune reflection intensity, consolidation rate, and exploration variance. View AI-generated insights.`,icon:F,color:`text-shogun-blue`},{name:`Torii (Security)`,purpose:`Select the active built-in tier or custom posture and access the Harakiri kill switch. Custom posture lifecycle is owned by ToolGate.`,icon:O,color:`text-red-400`},{name:`ToolGate (Runtime Permissions)`,purpose:`Create, edit, and delete custom postures; configure capability boundaries; and inspect effective tool verdicts, risk indications, confirmations, and per-tool overrides.`,icon:z,color:`text-orange-400`},{name:`Mado (Browser)`,purpose:`Browser automation layer powered by Playwright. Your AI can navigate to URLs, extract page content, take screenshots, and interact with web pages—within the capability boundaries and runtime verdicts shown in ToolGate.`,icon:o,color:`text-cyan-400`},{name:`Ronin (Desktop Control)`,purpose:`Desktop automation layer. Allows governed mouse, keyboard, screenshot, and native app control. Protected by Posture Guard, App Trust (4 levels), Komainu physical override, and environment detection. Only available at TACTICAL tier or higher.`,icon:m,color:`text-orange-400`},{name:`Agent Flow (Workflows)`,purpose:`Visual drag-and-drop workflow builder. Design multi-step AI pipelines by chaining Input, Samurai, Shogun Approval, Logic Gate, Browser, and Output nodes. Execute complex orchestration flows.`,icon:de,color:`text-violet-400`},{name:`Mail (Email Client)`,purpose:`Full IMAP/SMTP email integration. Browse your inbox, read and compose emails, reply with CC/BCC, navigate folders. Your Shogun can also read, send, and manage emails via native skills.`,icon:k,color:`text-sky-400`},{name:`Calendar`,purpose:`CalDAV calendar integration. View upcoming events, create new ones (with time, location, and description), and manage your schedule. Your Shogun can query and create events via native skills.`,icon:pe,color:`text-emerald-400`},{name:`Nexus (Collaboration)`,purpose:`Create Joint Workspaces. Invite other Shogun instances over the network. Exchange typed messages and co-edit a shared whiteboard.`,icon:C,color:`text-indigo-400`},{name:`Gensui (Fleet Command)`,purpose:`Connect this Shogun to Central Command for fleet governance, telemetry, commands, and emergency Harakiri. While managed, Gensui owns ToolGate; the local control surface is read-only and enforces the cached central policy during outages.`,icon:L,color:`text-indigo-400`},{name:`Backups & Data`,purpose:`Scheduled and manual backups with configurable retention. Export/import your entire database. Manage backup settings and restore from any point.`,icon:w,color:`text-shogun-gold`},{name:`Updates`,purpose:`Auto-checks for new Shogun versions every 6 hours. One-click install to download and apply updates. Preserves your data, configs, and environment.`,icon:g,color:`text-emerald-400`},{name:`Logs (Compliance Dashboard)`,purpose:`NIS2, SOC2, and EU AI Act-compliant event stream. Filter by 11 categories (Decision, Oversight, Risk, Model, Policy, Memory, Tools, Auth, Incident, System). Click trace IDs for full workflow reconstruction. Audit chain verifies tamper-proof integrity.`,icon:H,color:`text-shogun-subdued`},{name:`Guide (Documentation)`,purpose:`This page — a comprehensive knowledge base covering onboarding, architecture, reference manual, and safety protocols. Located in the Maintenance section.`,icon:ne,color:`text-shogun-subdued`}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card flex gap-4 items-start`,children:[(0,Y.jsx)(`div`,{className:`p-2 rounded-lg bg-shogun-bg border border-shogun-border shrink-0`,children:(0,Y.jsx)(e.icon,{className:`w-5 h-5 ${e.color}`})}),(0,Y.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:e.name}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.purpose})]})]},e.name))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-green-500/40 pb-3`,children:[(0,Y.jsx)(B,{className:`w-6 h-6 text-green-500`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Tips & Best Practices`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Recommendations from experienced operators.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-green-500`}),` Start with TACTICAL Posture`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The default "TACTICAL" security tier is recommended for most users. It gives the AI enough autonomy to be useful while keeping dangerous operations (like shell access and auto-spawning) locked down. Only move to CAMPAIGN or RONIN when you fully understand the risks.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-green-500`}),` Add Fallback Models`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Don't rely on a single AI provider. In Katana → Model Routing, edit Custom routing and add at least one fallback model from a different provider. If the primary goes down, the router tries the next eligible model.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(V,{className:`w-4 h-4 text-green-500`}),` Pin Important Memories`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`If there's a fact the AI must never forget — a company policy, a key contact, a critical instruction — create it as a memory in Archives and pin it. Pinned memories always have maximum salience and are always loaded into context.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-green-500`}),` Enable Automatic Backups`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Your Shogun accumulates valuable knowledge over time. Go to `,(0,Y.jsx)(`strong`,{children:`Backups`}),` in the sidebar → enable automatic backups on a schedule. You can also manually export a "Safe JSON Bundle" from the Data Management tab. This protects you from data loss due to hardware failure.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-green-500`}),` Write a Clear Mandate`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Mandate (Kaizen → Mandate tab) is injected into every conversation. Use it to set the AI's overall purpose, tone, and special instructions. For example: "You are a senior financial analyst. Always cite sources. Respond in English."`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-green-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-green-500`}),` Monitor the Compliance Dashboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Check the Logs page regularly — it records every action with full NIS2/SOC2/EU AI Act provenance. Use the `,(0,Y.jsx)(`strong`,{children:`Decision`}),` tab to track AI reasoning influences. Click trace IDs to reconstruct full workflows. Verify the `,(0,Y.jsx)(`strong`,{children:`"Chain Intact"`}),` badge stays green — a broken chain indicates tampering. Export the audit log periodically for off-site compliance archival.`]})]})]})]})]}),n===`reference`&&(0,Y.jsxs)(`div`,{className:`flex gap-8 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsx)(`nav`,{className:`hidden lg:block w-56 shrink-0`,children:(0,Y.jsxs)(`div`,{className:`sticky top-6 space-y-1 p-3 bg-shogun-card border border-shogun-border rounded-xl max-h-[calc(100vh-120px)] overflow-y-auto`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pb-2 mb-2 border-b border-shogun-border`,children:[(0,Y.jsx)(me,{className:`w-4 h-4 text-shogun-blue`}),(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Sections`})]}),$.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>ve(e.id),className:K(`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-[11px] font-medium transition-all duration-200 text-left`,i===e.id?`bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20 shadow-sm`:`text-shogun-subdued hover:text-shogun-text hover:bg-shogun-bg border border-transparent`),children:[(0,Y.jsx)(e.icon,{className:K(`w-3.5 h-3.5 shrink-0`,i===e.id?`text-shogun-blue`:e.color)}),e.label]},e.id))]})}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-16`,ref:Q,children:[(0,Y.jsxs)(`div`,{className:`text-center max-w-3xl mx-auto space-y-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3`,children:[(0,Y.jsx)(`h3`,{className:`text-3xl font-bold shogun-title`,children:`The Grand Reference`}),(0,Y.jsxs)(`button`,{type:`button`,onClick:ye,className:`print-hide inline-flex items-center gap-2 rounded-lg border border-shogun-blue/30 bg-shogun-blue/10 px-3 py-2 text-xs font-bold text-shogun-blue transition-colors hover:bg-shogun-blue/20`,children:[(0,Y.jsx)(he,{className:`h-4 w-4`}),`Print Guide`]})]}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ve(`ref-flowstack`),className:`print-hide mx-auto flex items-center gap-2 rounded-xl border border-violet-400/30 bg-violet-500/10 px-4 py-2.5 text-xs font-bold text-violet-300 transition-colors hover:bg-violet-500/20`,children:[(0,Y.jsx)(E,{className:`h-4 w-4`}),`Flow Stacking & Stack Orchestrator — full reference`]}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed`,children:`A deep-dive, page-by-page, tab-by-tab, button-by-button manual of every single capability within the Shogun platform. Written in plain language so anyone can understand it — no technical jargon required.`})]}),(0,Y.jsxs)(`section`,{id:`ref-tenshu`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(q,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Tenshu — The Command Center`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Your home screen. The first thing you see when you open Shogun.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-blue`}),` Stat Cards (Top Row)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Four large cards at the top of the page. Each one is a "quick look" at a different part of the system. They are clickable — clicking one takes you to the related page.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Neural Engine:`}),` Shows the name of your primary AI and whether it is currently running. Click to go to the Shogun Profile page.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Active Lattice:`}),` How many sub-agents (Samurai) are currently deployed. Click to go to the Samurai Network page.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Knowledge Volume:`}),` The total number of memories stored in the Archives. Also indicates whether the search index is healthy or has errors.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security Tier:`}),` Shows your current protection level (e.g., "GUARDED" or "TACTICAL"). Click to go to Torii.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-blue`}),` Active Deployment Registry`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A table below the stat cards that lists every Samurai (sub-agent) currently running. For each one you can see:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Designation:`}),` The agent's name and its first-letter icon.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Current Task:`}),` What the agent is working on right now.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Engagement Bar:`}),` A progress bar showing how busy it is.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Status:`}),` A green "active" or blue "suspended" badge.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-blue`}),` Quick Actions Panel`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Two large shortcut buttons below the deployment registry:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`New Samurai:`}),` Opens the Samurai Network page to deploy a new sub-agent.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Model Setup:`}),` Opens the Katana page to configure AI models.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-red-400`}),` Emergency Stop (Harakiri)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A red button on the dashboard. Pressing it opens a two-step confirmation modal. Once confirmed, `,(0,Y.jsx)(`strong`,{children:`all active agent operations are immediately stopped`}),`. The security posture locks to "SHRINE" (maximum protection). A pulsing red banner appears at the top of Every page until you press "Reset Harakiri".`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-gold`}),` Telemetry Feed (Right Sidebar)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A timeline of recent system events displayed on the right side. Each event has a colored icon (red for security, gold for agent, blue for system) and a timestamp. At the bottom, a "System Load" bar shows current CPU usage.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(A,{className:`w-4 h-4 text-shogun-blue`}),` "Enter Command" Button`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The blue button in the top right. Clicking it takes you straight to the Comms (Chat) page where you can start talking to your Shogun.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-server`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-emerald-400/40 pb-3`,children:[(0,Y.jsx)(N,{className:`w-6 h-6 text-emerald-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Shogun Server Mode — Container Installation`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Run Shogun and The Tenshu continuously with Docker, PostgreSQL, and Qdrant.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card border-l-4 border-l-red-500 space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4`}),` Ronin Does Not Work in Server Mode`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A container cannot safely access the server's physical desktop. Ronin screenshots, mouse and keyboard control, native application control, and host-desktop sessions are disabled and rejected by the server. Selecting the Torii posture named `,(0,Y.jsx)(`strong`,{children:`RONIN`}),` does not override this container boundary. Install Shogun directly on a desktop computer when Ronin Desktop Control is required.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{className:`text-emerald-400`,children:`Still available:`}),` Mado browser automation runs Chromium inside the container. Agent Flows, Flow Stacking, Telegram, Microsoft Teams, Nexus, memory, ToolGate, HARAKIRI, and external local-model servers such as Ollama continue to work.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-emerald-400`}),` Before You Install`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Windows or macOS:`}),` Install Docker Desktop and start it.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Linux:`}),` Install Docker Engine and the Docker Compose plugin.`]}),(0,Y.jsx)(`li`,{children:`Allow outbound internet access while the image and service images are downloaded.`}),(0,Y.jsx)(`li`,{children:`Plan remote administration through a VPN, SSH tunnel, or authenticated HTTPS reverse proxy.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-emerald-400`}),` One-Click Installation`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-4 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Open the latest Shogun GitHub Release.`}),(0,Y.jsxs)(`li`,{children:[`Download `,(0,Y.jsx)(`code`,{children:`Shogun-Server-Install.bat`}),` on Windows, or `,(0,Y.jsx)(`code`,{children:`Shogun-Server-Install.sh`}),` on Linux/macOS.`]}),(0,Y.jsx)(`li`,{children:`Run the installer. It generates secrets, builds the image, and starts all services.`}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`code`,{children:`http://127.0.0.1:8000/setup`}),` and complete the Setup Wizard as the Primary Admin.`]})]}),(0,Y.jsxs)(`a`,{href:`https://github.com/AlphaHorizon-AI/Shogun/releases/latest`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] font-bold text-emerald-400 hover:underline`,children:[(0,Y.jsx)(_,{className:`w-3 h-3`}),` Open the latest Shogun Release`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(M,{className:`w-4 h-4 text-emerald-400`}),` What the Stack Runs`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shogun + The Tenshu:`}),` A non-root application container exposed on port 8000.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`PostgreSQL:`}),` Structured application, configuration, team, and audit data.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Qdrant:`}),` Vector memory and semantic retrieval.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Internal network:`}),` PostgreSQL and Qdrant are not published to the host.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Health and restart controls:`}),` Failed services are detected and restarted automatically.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-emerald-400`}),` Persistence and Upgrades`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Named Docker volumes preserve application data, memories, vault content, configuration, logs, PostgreSQL, and Qdrant. The installer also preserves `,(0,Y.jsx)(`code`,{children:`.env.server`}),` when updating the source.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-red-400 leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Never use`}),` `,(0,Y.jsx)(`code`,{children:`docker compose down -v`}),` unless you intentionally want to delete all Server-mode data.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-emerald-400`}),` Team Access Model`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Primary Admin operates The Tenshu and owns platform administration. Team members communicate with Shogun through their configured Telegram or Microsoft Teams identities and receive separate identity and pinned-memory contexts. Team members do not receive access to The Tenshu.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-emerald-400`}),` Network Security`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Tenshu binds to `,(0,Y.jsx)(`code`,{children:`127.0.0.1`}),` by default and is therefore reachable only from the server itself. Do not expose it on a public or shared network without an authenticated HTTPS reverse proxy. A VPN or SSH tunnel is the preferred way to administer it remotely.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-emerald-400`}),` Essential Server Commands`]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg border border-shogun-border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Status`}),(0,Y.jsx)(`code`,{className:`text-[10px] text-emerald-400 break-all`,children:`docker compose --env-file .env.server -f docker-compose.server.yml ps`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg border border-shogun-border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Live Logs`}),(0,Y.jsx)(`code`,{className:`text-[10px] text-emerald-400 break-all`,children:`docker compose --env-file .env.server -f docker-compose.server.yml logs -f shogun`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg border border-shogun-border p-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Safe Stop`}),(0,Y.jsx)(`code`,{className:`text-[10px] text-emerald-400 break-all`,children:`docker compose --env-file .env.server -f docker-compose.server.yml down`})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-comms`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(A,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Comms — The Conversation`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Your direct line to the Shogun AI. Four tabs: Chat, Mail, Calendar, and Files.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(A,{className:`w-4 h-4 text-shogun-blue`}),` Chat Window`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The main area showing your conversation. Your messages appear on the right (blue icon), and the Shogun's replies appear on the left (gold icon). While the AI is thinking, three bouncing dots are shown. Responses stream in token by token so you can watch the answer being written in real time.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-shogun-blue`}),` Model & Search Tags`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Below each Shogun reply you will see a small tag. If the reply used a `,(0,Y.jsx)(`strong`,{children:`Web Search`}),` (via Perplexity), a blue "Web Search" badge appears. Otherwise, the name of the AI model used is shown (e.g., "gpt-4o").`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`w-4 h-4 text-shogun-gold`}),` Input Bar & Sending`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Type your message at the bottom and press `,(0,Y.jsx)(`strong`,{children:`Enter`}),` (or click the blue send arrow) to send. While the AI is responding, the input field is locked and shows "Transmitting directive..." to prevent double-sending.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(f,{className:`w-4 h-4 text-shogun-gold`}),` Session History`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Below the input bar, click `,(0,Y.jsx)(`strong`,{children:`"View History"`}),` to open a right-hand drawer showing all your previous chat sessions. Each session shows a preview of the first message and the number of messages. Click `,(0,Y.jsx)(`strong`,{children:`"Restore"`}),` to reload an old conversation. Click `,(0,Y.jsx)(`strong`,{children:`"Clear All History"`}),` at the bottom to permanently erase all archived sessions.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-red-400`}),` Clear Button (Trash Icon)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The trash icon in the top right `,(0,Y.jsx)(`strong`,{children:`archives`}),` the current session to history and starts a fresh conversation. Your old messages are not lost — they are kept in the History drawer and can be restored at any time.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mt-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-sky-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-sky-400`}),` Mail — Email Client`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A full IMAP/SMTP email client built into Comms. Browse your inbox with sender, subject, date, and preview. Click any message to read the full content. `,(0,Y.jsx)(`strong`,{children:`Compose`}),` new emails with To, CC, BCC, subject, and body. Reply to existing messages with quoted context. Navigate between folders (Inbox, Sent, Drafts). Configure your email account in the system settings. The Shogun can also manage email via native skills: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`fetch_inbox`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`read_email`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`send_email`}),`.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(pe,{className:`w-4 h-4 text-emerald-400`}),` Calendar — Event Management`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`CalDAV calendar integration. View your upcoming events on a timeline with titles, times, locations, and descriptions. Create new events by specifying a title, start/end time, location, and optional description. Supports all-day events. Connect a CalDAV server in the system settings. The Shogun can query and create events via native skills: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`list_calendar_events`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`create_calendar_event`}),`.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-amber-400/40 mt-4`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(x,{className:`w-4 h-4 text-amber-400`}),` Files — Workspace File Explorer`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A full visual file manager for the Agent Workspace — the dedicated folder shared between the Shogun, all Samurai agents, and the user. The Files tab provides everything you need to browse, create, edit, upload, and delete files without leaving the Comms page.`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 mt-2`,children:[(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Tree Sidebar (Left)`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Expandable directory tree with file-type icons (code, spreadsheet, image, archive, text).`}),(0,Y.jsx)(`li`,{children:`File sizes shown in human-readable format (KB, MB).`}),(0,Y.jsx)(`li`,{children:`Real-time search filter to find files instantly.`}),(0,Y.jsx)(`li`,{children:`Workspace info footer: total files, directories, and disk usage.`})]})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Content Panel (Right)`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Click a file to view its contents in a monospace reader.`}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Edit`}),` to modify any text file inline, then `,(0,Y.jsx)(`strong`,{children:`Save`}),` to write back to disk.`]}),(0,Y.jsx)(`li`,{children:`Click a folder to see its contents as a clickable card grid with icons and sizes.`}),(0,Y.jsx)(`li`,{children:`Empty state shows workspace path and usage instructions.`})]})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Toolbar Actions`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`New File`}),` (file+ icon): Creates a file inside the selected folder or workspace root.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`New Folder`}),` (folder+ icon): Creates a directory. Nested paths auto-created.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Upload`}),` (upload icon): Opens a file picker to upload one or more files.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Rename`}),` (edit icon): Renames the selected file or folder.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Delete`}),` (trash icon): Deletes with confirmation. Directories deleted recursively.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Refresh`}),` (refresh icon): Reloads the tree from disk.`]})]})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400`,children:`Drag & Drop Upload`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued space-y-1 ml-3 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Drag files from your desktop or file manager and drop them anywhere on the File Explorer.`}),(0,Y.jsx)(`li`,{children:`A blue overlay appears showing where files will land.`}),(0,Y.jsx)(`li`,{children:`Files are uploaded into the currently selected folder, or workspace root if none is selected.`}),(0,Y.jsx)(`li`,{children:`Multiple files can be dropped at once. All file types are supported.`}),(0,Y.jsx)(`li`,{children:`Filenames are sanitized on the server. Path traversal is blocked.`})]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-profile`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(p,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Shogun Profile — Your AI's Identity`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Configure the identity, personality, behavior, and scheduled operations of your main Shogun agent. Has 3 tabs; security configuration is owned by ToolGate.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-gold`}),` General Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Set the Shogun's name, choose an active "Persona" (a pre-built personality template), and write a description. On the right side, adjust the `,(0,Y.jsx)(`strong`,{children:`Autonomy Level`}),` slider (how much freedom the AI gets), `,(0,Y.jsx)(`strong`,{children:`Tone`}),` (e.g., Analytical, Direct), `,(0,Y.jsx)(`strong`,{children:`Risk Tolerance`}),`, `,(0,Y.jsx)(`strong`,{children:`Verbosity`}),` (how detailed responses are), `,(0,Y.jsx)(`strong`,{children:`Planning Depth`}),`, `,(0,Y.jsx)(`strong`,{children:`Tool Usage`}),`, `,(0,Y.jsx)(`strong`,{children:`Security Bias`}),`, and `,(0,Y.jsx)(`strong`,{children:`Memory Style`}),`. Click the avatar image to upload a custom picture.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-shogun-gold`}),` Model Selection`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Model selection is configured centrally in `,(0,Y.jsx)(`strong`,{children:`Katana → Model Routing`}),`, where providers, routing profiles, capability requirements, primary models, and fallback order share one source of truth.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-shogun-gold`}),` Behavior Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A full-screen YAML text editor showing the Shogun's core behavioral directives — its priorities, operational constraints, and delegation rules. Think of this as the AI's "rule book." You can edit it directly, and the badge in the top-right confirms it is in "YAML Mode."`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-orange-400`}),` Security Summary`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The General tab shows the active policy, inherited base tier, and capability risk as a compact summary. Use `,(0,Y.jsx)(`strong`,{children:`Open ToolGate`}),` to inspect or change security behavior. The former Permissions tab now redirects to ToolGate so there is only one runtime-permission control surface.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(F,{className:`w-4 h-4 text-shogun-gold`}),` Operations Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`View and manage scheduled background jobs. Preset jobs include `,(0,Y.jsx)(`strong`,{children:`Memory Consolidation`}),` (summarizes and compresses old memories), `,(0,Y.jsx)(`strong`,{children:`Knowledge Refresh`}),` (updates outdated knowledge), and `,(0,Y.jsx)(`strong`,{children:`Security Audit`}),`. Each can be enabled/disabled with a toggle. Below the presets, you can `,(0,Y.jsx)(`strong`,{children:`create custom jobs`}),` with a name, schedule (nightly, weekly, monthly, or one-time), priority, and instructions.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-samurai`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(W,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Samurai Network — The Fleet`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Deploy, manage, and monitor specialized sub-agents.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-gold`}),` Fleet Stats (Top)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Four stat cards: `,(0,Y.jsx)(`strong`,{children:`Total Fleet`}),` (all agents), `,(0,Y.jsx)(`strong`,{children:`Active`}),` (currently working), `,(0,Y.jsx)(`strong`,{children:`Suspended`}),` (paused), and `,(0,Y.jsx)(`strong`,{children:`Signal Range`}),` (network reach).`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`w-4 h-4 text-shogun-gold`}),` Agent Table & Search`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A large table listing every Samurai. Use the search bar to filter by name. Each row shows: the agent's `,(0,Y.jsx)(`strong`,{children:`name and role badge`}),`, `,(0,Y.jsx)(`strong`,{children:`status`}),` (green dot = active), `,(0,Y.jsx)(`strong`,{children:`current task`}),` (with a live progress bar if running), `,(0,Y.jsx)(`strong`,{children:`role/slug`}),`, `,(0,Y.jsx)(`strong`,{children:`routing profile`}),`, and `,(0,Y.jsx)(`strong`,{children:`deployment date`}),`. Hover over a row to reveal action buttons.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-gold`}),` Row Action Buttons`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Three buttons appear when you hover over a Samurai row:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Pause/Play:`}),` Suspend a running agent or resume a suspended one.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Trash:`}),` Permanently delete the agent (asks for confirmation first).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Configure (⋮):`}),` Opens a modal where you can change the agent's name, role, routing profile, spawn policy, and description.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-shogun-blue`}),` "Deploy Samurai" Button`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The blue button in the top right. Opens a form where you choose a `,(0,Y.jsx)(`strong`,{children:`Role`}),` from the pre-defined Samurai roles list, give it a `,(0,Y.jsx)(`strong`,{children:`custom name`}),`, choose a `,(0,Y.jsx)(`strong`,{children:`Spawn Policy`}),` (Manual, Auto, or Scheduled), optionally assign a `,(0,Y.jsx)(`strong`,{children:`Routing Profile`}),`, and write a description. Click "Deploy Samurai" to create it.`]})]})]}),(0,Y.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-subdued uppercase tracking-widest pl-1 border-l-2 border-shogun-gold/40 ml-1`,children:`Samurai Orchestration`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(de,{className:`w-4 h-4 text-violet-400`}),` Agent Flow — Workflow Builder`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A visual drag-and-drop canvas for designing multi-step AI pipelines. Build workflows by chaining 13 node types, including the governed, memory-aware Coding node:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Input:`}),` The entry point — accepts user text, data, or triggers.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Samurai:`}),` Delegates a task to a specific sub-agent.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shogun Approval:`}),` Pauses the flow for human confirmation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Logic:`}),` A conditional gate — routes based on a condition.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Mado Browser:`}),` Automates a web browsing action.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Email Send / Telegram & Teams:`}),` Delivers results through configured channels.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Workspace / Office:`}),` Performs governed file operations or works with Office documents.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Subflow:`}),` Runs a reusable child Agent Flow.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Stack Orchestrator:`}),` Supervises a long-running Flow Stack.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Output:`}),` Collects and presents the final result, with optional memory infusion.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(S,{className:`w-4 h-4 text-violet-400`}),` Canvas, Execution & AI Creation`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Position nodes freely on the visual canvas and draw directed edges between them. Edges define execution order — data flows from source to target. The canvas supports pan, zoom, and node reordering. Workflows are saved to the database.`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Click `,(0,Y.jsx)(`strong`,{children:`Execute`}),` to run a workflow. Nodes process in topological order, passing outputs as inputs to the next. Shogun Approval nodes pause until you confirm.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Shogun can manage workflows natively: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`list_agent_flows`}),` discovers flows and stacks, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`get_agent_flow`}),` reads a complete graph, and `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`patch_agent_flow`}),` safely changes selected nodes or edges. It can also create, replace, and delete flows. The agent is instructed to inspect a flow before editing it.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-violet-400`}),` Template Gallery`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click `,(0,Y.jsx)(`strong`,{children:`New Flow`}),` to browse 173 pre-built workflow templates across 11 different categories, including 33 distinct Coding templates. Templates range in difficulty from `,(0,Y.jsx)(`strong`,{children:`Beginner`}),` to `,(0,Y.jsx)(`strong`,{children:`Advanced`}),`.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`When you select a template, the canvas is automatically populated. Samurai nodes inside templates use `,(0,Y.jsx)(`strong`,{children:`Ephemeral (Ad-Hoc)`}),` agents by default to keep your Fleet clean, but can be manually linked to a permanent Fleet Samurai via the node properties panel.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-orange-400/40 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-orange-400`}),` Output Memory Infusion`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`An Output node can opt into `,(0,Y.jsx)(`strong`,{children:`Memory Infusion`}),`. When its configured completion state is reached, the flow engine—not the model—stores selected output fields in Archives. Configure the memory type, importance, decay, tags, title template, content fields, maximum length, sensitive-data redaction, and behavior when fields are missing.`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Storage can run on success, partial completion, or always. Exact-hash or semantic deduplication prevents repeated memories and reinforces an existing match. Every stored, skipped, or deduplicated result carries flow/run/node provenance and an audit event. Memory Infusion is disabled by default and must be enabled per Output node.`})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-katana`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(p,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Katana — The System Forge`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Where you install and connect models, tools, formats, channels, account integrations, and operational capability providers. Shows 13 tabs normally and 14 when IDE Mode is available in Campaign or Ronin posture. Katana exposes capabilities; it does not decide whether a capability may run.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-blue`}),` AI Model Provider Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Lists every cloud or local AI service you have connected (OpenAI, Anthropic, Google Gemini, Perplexity, Ollama, etc.). Each provider card shows its `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`type`}),`, `,(0,Y.jsx)(`strong`,{children:`status`}),`, and available `,(0,Y.jsx)(`strong`,{children:`models`}),`. Add, edit, enable, disable, or delete provider connections here; credentials are stored through the backend rather than displayed after saving.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-shogun-blue`}),` File Formats Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Controls the file-format registry used by governed tools. Review recognized extensions, MIME types, capability categories, safety classifications, size limits, and which operations are available for each format.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(s,{className:`w-4 h-4 text-shogun-blue`}),` Routing Profiles Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Create "routing profiles" — sets of rules that decide which AI model handles which type of task. For example, you can create a "Balanced" profile where: code tasks go to GPT-4, research tasks go to Perplexity Sonar, and simple chat goes to a cheap model. Each profile has a `,(0,Y.jsx)(`strong`,{children:`name`}),`, optional `,(0,Y.jsx)(`strong`,{children:`default model`}),`, and a list of `,(0,Y.jsx)(`strong`,{children:`rules`}),` (task type → model pair). Profiles can be set as the system default.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(M,{className:`w-4 h-4 text-shogun-blue`}),` Toolbox Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Lists the external tools installed or connected to Shogun — web search, file access, database connections, code execution, and more. Each tool shows its `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`type`}),`, and availability status. You can `,(0,Y.jsx)(`strong`,{children:`register new tools`}),` and connect or disconnect existing ones. These controls determine whether a capability exists; `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` determines whether, when, and with what confirmation it may execute.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-shogun-blue`}),` Skills · Active Usage Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shows which Dojo skills are actually retrieved and injected during agent runs, along with usage outcomes, trajectory evidence, and improvement candidates. See `,(0,Y.jsx)(`strong`,{children:`Active Skills & Trajectory Capture`}),` below for the complete runtime lifecycle.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-blue`}),` Team Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Primary Admin can switch this installation between `,(0,Y.jsx)(`strong`,{children:`Single User`}),` and `,(0,Y.jsx)(`strong`,{children:`Team Mode`}),`. Single-user mode immediately disables every Team Member's Telegram or Microsoft Teams access while retaining the saved roster. Switching back to Team Mode restores access for those saved members.`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In Team Mode, add members by name and their verified Telegram user ID or Microsoft Teams identity. Each member receives an isolated identity memory so Shogun can remember that person without exposing another member's private context. Deleting a member revokes access, removes them from the roster, and archives their identity memory. The Primary Admin is protected and cannot be deleted.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-shogun-blue`}),` Office App Mode Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Controls the `,(0,Y.jsx)(`strong`,{children:`Office App Mode`}),` — Shogun's ability to read, create, and modify Microsoft Office documents (`,(0,Y.jsx)(`code`,{children:`.xlsx`}),`, `,(0,Y.jsx)(`code`,{children:`.docx`}),`, `,(0,Y.jsx)(`code`,{children:`.pptx`}),`). The tab has a master `,(0,Y.jsx)(`strong`,{children:`enable/disable`}),` toggle at the top. Below it are four sections:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Approved Folders:`}),` Four directory paths (Input, Output, Templates, Temp) that define the allowed file boundaries. When left empty, they automatically use the `,(0,Y.jsx)(`strong`,{children:`workspace root`}),` folder. All file operations are jailed to these directories — any path outside them is rejected.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Per-Application Settings:`}),` Individual cards for `,(0,Y.jsx)(`strong`,{children:`Excel`}),`, `,(0,Y.jsx)(`strong`,{children:`Word`}),`, `,(0,Y.jsx)(`strong`,{children:`PowerPoint`}),`, and `,(0,Y.jsx)(`strong`,{children:`Outlook`}),` — each with its own enable toggle, macro policy (allow/block), overwrite protection, and timeout. Excel also has an external links toggle; Outlook has draft-only vs. send mode and domain allowlists.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Safety Rules:`}),` Global policies including path traversal blocking, Windows shortcut (`,(0,Y.jsx)(`code`,{children:`.lnk`}),`) blocking, UNC/network path blocking, output versioning, and a maximum file size cap (default 100 MB).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security Posture Gate:`}),` Office operations require at least `,(0,Y.jsx)(`strong`,{children:`Guarded`}),` posture. In `,(0,Y.jsx)(`strong`,{children:`Shrine`}),` mode, all Office tools are disabled. The minimum posture can be raised (e.g., to Tactical) for stricter environments.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-shogun-blue`}),` Mail & Calendar Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Connect your email account for AI-powered mail capabilities. Configure an `,(0,Y.jsx)(`strong`,{children:`IMAP/SMTP`}),` account by entering server addresses, port numbers, and credentials. Once connected, the Shogun can:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Read emails:`}),` Fetch and analyze incoming mail from the inbox.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Send emails:`}),` Compose and send messages (requires `,(0,Y.jsx)(`code`,{children:`perm_send_mail`}),` to be enabled).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Calendar events:`}),` Create and manage calendar entries (when supported by the provider).`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The tab shows `,(0,Y.jsx)(`strong`,{children:`connection status`}),`, account details, and `,(0,Y.jsx)(`strong`,{children:`Account Scopes`}),` for read, send, and calendar access. These scopes describe what the connected account exposes; ToolGate remains the runtime authority and can further restrict or require confirmation for every action. All mail activity is logged in the immutable audit chain.`]})]}),(0,Y.jsxs)(`div`,{id:`ref-telegram`,className:`shogun-card space-y-5 md:col-span-2 scroll-mt-6 border-sky-400/20`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-shogun-blue`}),` Telegram Integration`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Connect a private Telegram bot so you can talk to Shogun from your phone. A first-time personal setup normally takes 10–15 minutes.`}),(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg border border-sky-400/20 bg-sky-400/5 text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{className:`text-shogun-text`,children:`Choose Polling.`}),` It is the working listener in this release and needs no public URL. Keep Webhook for administrator-managed custom deployments.`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`In Telegram, open the verified `,(0,Y.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-sky-400 hover:underline`,children:`@BotFather`}),` account and send `,(0,Y.jsx)(`code`,{children:`/newbot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Choose a display name, then a unique username ending in `,(0,Y.jsx)(`code`,{children:`bot`}),`. Copy the token BotFather returns and protect it like a password.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Katana → Telegram`}),`, paste the token, select Polling, temporarily leave Allowed Chat IDs empty, and click `,(0,Y.jsx)(`strong`,{children:`Connect Bot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Open your new bot in Telegram, press Start, and send `,(0,Y.jsx)(`code`,{children:`Hello`}),`. Bots cannot initiate private conversations.`]}),(0,Y.jsxs)(`li`,{children:[`Back in Katana, click `,(0,Y.jsx)(`strong`,{children:`Auto-detect Chat ID`}),`. The detected ID is placed in the test and whitelist fields.`]}),(0,Y.jsxs)(`li`,{children:[`Paste the token again and click `,(0,Y.jsx)(`strong`,{children:`Update Connection`}),`. This second save is essential: auto-detect changes the form, but the Allowed Chat IDs whitelist is not permanent until the connection is updated.`]}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Send Test`}),`, then send `,(0,Y.jsx)(`code`,{children:`Hello Shogun`}),` from Telegram. Receiving both replies completes the private-chat setup.`]})]}),(0,Y.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text mb-2`,children:`Adding a group`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:`Add the bot, send a direct command or mention, then auto-detect again. A group ID is normally negative. Add it to Allowed Chat IDs, paste the token again, and Update Connection. Telegram Privacy Mode normally limits the bot to commands, mentions, and replies.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text mb-2`,children:`Safety rules`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued ml-4 list-disc space-y-1`,children:[(0,Y.jsx)(`li`,{children:`Never leave Allowed Chat IDs empty after discovery.`}),(0,Y.jsx)(`li`,{children:`Run only one Shogun poller per token.`}),(0,Y.jsx)(`li`,{children:`Regenerate an exposed token in BotFather immediately.`}),(0,Y.jsx)(`li`,{children:`Shogun must stay awake, running, and online.`})]})]})]}),(0,Y.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{className:`text-shogun-text`,children:`If auto-detect finds nothing:`}),` send a fresh direct message to the bot, wait a few seconds, and retry. If Send Test works but normal messages are ignored, verify the exact Chat ID and repeat the second Update Connection save. See the expanded Telegram setup and troubleshooting walkthrough in the Onboarding tab.`]}),(0,Y.jsxs)(`a`,{href:`https://core.telegram.org/bots/features`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-sky-400 hover:underline`,children:[(0,Y.jsx)(_,{className:`w-3 h-3`}),` Official Telegram bot and Privacy Mode reference`]})]}),(0,Y.jsxs)(`div`,{id:`ref-teams`,className:`shogun-card space-y-2 md:col-span-2 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(A,{className:`w-4 h-4 text-shogun-blue`}),` Microsoft Teams Adapter`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Connect Microsoft Teams as an enterprise command and notification channel for Shogun. Teams is the communication surface; `,(0,Y.jsx)(`strong`,{children:`Katana`}),` manages the channel, while `,(0,Y.jsx)(`strong`,{children:`Gensui`}),` continues to enforce identity, authorization, approvals, policy, and audit. The adapter supports personal chats, group chats, and channel commands when the Shogun bot is directly mentioned.`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Overview:`}),` Shows adapter health, tenant and SSO status, recent activity, errors, and active approval requests.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Setup Wizard:`}),` Configures the deployment mode, allowed Microsoft tenants, Bot/App ID, secret reference, public HTTPS messaging endpoint, valid domains, and downloadable Teams app package.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Entra & Roles:`}),` Maps verified Teams and Microsoft Entra identities to Shogun roles. New identities begin as `,(0,Y.jsx)(`strong`,{children:`Viewer`}),` until deliberately promoted.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security Policy:`}),` Controls available command groups, destructive-command approval flow, approval expiry, and dual approval for fleet shutdown.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Audit & Diagnostics:`}),` Records inbound commands, risk classification, authorization decisions, response outcomes, and correlation IDs. Built-in checks validate the Shogun backend, Microsoft Graph configuration, proactive messaging, and Teams manifest.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Commands such as `,(0,Y.jsx)(`code`,{children:`status`}),`, `,(0,Y.jsx)(`code`,{children:`agents`}),`, `,(0,Y.jsx)(`code`,{children:`run workflow`}),`, `,(0,Y.jsx)(`code`,{children:`pause agent`}),`, and `,(0,Y.jsx)(`code`,{children:`show pending approvals`}),` are classified by risk before dispatch. Critical commands—including Harakiri—never execute directly from a casual Teams message and must pass through Gensui confirmation and the configured approval policy. Production use requires a Microsoft Entra/Azure Bot registration and a public HTTPS Teams Bridge endpoint.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-6 border-indigo-400/20`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2 text-base`,children:[(0,Y.jsx)(W,{className:`w-5 h-5 text-indigo-400`}),` Microsoft Teams — Step-by-Step Connection Guide`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`A complete path from an empty Microsoft tenant to a working Shogun personal chat and channel mention.`})]}),(0,Y.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-indigo-400 bg-indigo-400/10 border border-indigo-400/20 px-2.5 py-1 rounded-full w-fit`,children:`Administrator-assisted setup`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg border border-amber-400/20 bg-amber-400/5`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-amber-300 font-bold flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4`}),` Non-technical reality check`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Teams is an enterprise deployment, not a one-token connection. Most organizations require a `,(0,Y.jsx)(`strong`,{children:`Microsoft 365/Teams administrator`}),`, an `,(0,Y.jsx)(`strong`,{children:`Azure or Entra administrator`}),`, and the person who operates the Shogun server. The simplest safe pilot is`,(0,Y.jsx)(`strong`,{children:` Single tenant + Customer-hosted Teams Bridge + personal chat`}),`. Leave SSO, Microsoft Graph, and proactive messaging off until basic chat works.`]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text mb-3`,children:`What must be ready`}),(0,Y.jsx)(`div`,{className:`grid sm:grid-cols-2 lg:grid-cols-4 gap-3`,children:[[`Microsoft 365 tenant`,`A work or school tenant with Microsoft Teams.`],[`Azure subscription`,`Permission to create an Entra app registration and Azure Bot resource.`],[`Public HTTPS address`,`A stable internet address for the Teams Bridge, or a secure tunnel for a pilot.`],[`Shogun server access`,`Permission to start the included bridge and set protected environment values.`]].map(([e,t])=>(0,Y.jsxs)(`div`,{className:`p-3 rounded-lg bg-shogun-bg border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed mt-1`,children:t})]},e))})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-indigo-400/5 border border-indigo-400/20`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-shogun-text`,children:`Administrator handoff checklist`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-1`,children:`If someone else manages Microsoft 365, give that person this exact list:`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued leading-relaxed mt-2 ml-4 list-disc space-y-1.5`,children:[(0,Y.jsxs)(`li`,{children:[`Create a `,(0,Y.jsx)(`strong`,{children:`single-tenant Microsoft Entra app registration`}),` for Shogun.`]}),(0,Y.jsxs)(`li`,{children:[`Create an `,(0,Y.jsx)(`strong`,{children:`Azure Bot`}),` using that existing app registration and enable its Microsoft Teams channel.`]}),(0,Y.jsxs)(`li`,{children:[`Provide the `,(0,Y.jsx)(`strong`,{children:`Directory (tenant) ID`}),` and `,(0,Y.jsx)(`strong`,{children:`Application (client) ID`}),`.`]}),(0,Y.jsx)(`li`,{children:`Store the client secret or certificate in the approved secret store; do not send it by email or Teams chat.`}),(0,Y.jsx)(`li`,{children:`Permit the Shogun custom Teams app for pilot users, or upload it to the organization's app catalog.`}),(0,Y.jsxs)(`li`,{children:[`Provide a public HTTPS hostname that routes to the Shogun Teams Bridge on port `,(0,Y.jsx)(`code`,{children:`3978`}),`.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part A — Register Shogun in Microsoft Entra`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Sign in to the `,(0,Y.jsx)(`a`,{href:`https://portal.azure.com`,target:`_blank`,rel:`noreferrer`,className:`text-indigo-400 hover:underline font-bold`,children:`Azure portal`}),` with the administrator account.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Microsoft Entra ID → App registrations → New registration`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Enter a recognizable name such as `,(0,Y.jsx)(`code`,{children:`Shogun Teams Bot`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Select `,(0,Y.jsx)(`strong`,{children:`Accounts in this organizational directory only`}),` for a single-tenant deployment, then select `,(0,Y.jsx)(`strong`,{children:`Register`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`On Overview, copy `,(0,Y.jsx)(`strong`,{children:`Application (client) ID`}),` and `,(0,Y.jsx)(`strong`,{children:`Directory (tenant) ID`}),`. Keep the labels with the values so they are not confused.`]}),(0,Y.jsxs)(`li`,{children:[`For a pilot using a client secret, open `,(0,Y.jsx)(`strong`,{children:`Certificates & secrets → Client secrets → New client secret`}),`. Copy the secret `,(0,Y.jsx)(`strong`,{children:`Value`}),` immediately; it is displayed only once. Store it in an approved secret manager. For production, Microsoft recommends a managed identity, federated credential, or certificate instead of a long-lived client secret.`]})]}),(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoft-365/agents-sdk/azure-bot-authentication-for-javascript`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(_,{className:`w-3 h-3`}),` Official Microsoft authentication options`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part B — Create and configure the Azure Bot`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`In the Azure portal, select `,(0,Y.jsx)(`strong`,{children:`Create a resource`}),`, search for `,(0,Y.jsx)(`strong`,{children:`Azure Bot`}),`, and select `,(0,Y.jsx)(`strong`,{children:`Create`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`Choose the subscription and resource group, enter a unique bot handle, and select `,(0,Y.jsx)(`strong`,{children:`Single Tenant`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`For Microsoft App ID, choose `,(0,Y.jsx)(`strong`,{children:`Use existing app registration`}),` and enter the Application (client) ID from Part A.`]}),(0,Y.jsxs)(`li`,{children:[`After deployment, open the Azure Bot resource. Under `,(0,Y.jsx)(`strong`,{children:`Settings → Configuration`}),`, set Messaging endpoint to `,(0,Y.jsx)(`code`,{children:`https://YOUR-BRIDGE-HOST/api/messages`}),`, then apply the change.`]}),(0,Y.jsxs)(`li`,{children:[`Under `,(0,Y.jsx)(`strong`,{children:`Settings → Channels`}),`, add or enable the `,(0,Y.jsx)(`strong`,{children:`Microsoft Teams`}),` channel.`]})]}),(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoftteams/platform/teams-sdk/teams/azure-configuration`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(_,{className:`w-3 h-3`}),` Official Azure Bot and Teams channel instructions`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part C — Start the included Teams Bridge`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The bridge is the Microsoft-facing service in `,(0,Y.jsx)(`code`,{children:`bridge/teams`}),`. Teams sends messages to the bridge; the bridge validates and normalizes them, then sends governed commands to Shogun. The bridge requires `,(0,Y.jsx)(`strong`,{children:`Node.js 22 or newer`}),`.`]}),(0,Y.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-[#050508] border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Bridge environment values`}),(0,Y.jsx)(`pre`,{className:`text-[10px] text-indigo-300 whitespace-pre-wrap overflow-x-auto`,children:`tenantId= -clientId= -clientSecret= -SHOGUN_INTERNAL_API_URL=http://:8000 -SHOGUN_INTERNAL_API_KEY=`})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg bg-[#050508] border border-shogun-border`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued mb-2`,children:`Install and start`}),(0,Y.jsx)(`pre`,{className:`text-[10px] text-indigo-300 whitespace-pre-wrap overflow-x-auto`,children:`cd bridge/teams -npm install -npm run build -npm start`})]})]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Set the same `,(0,Y.jsx)(`code`,{children:`SHOGUN_INTERNAL_API_KEY`}),` in the operating-system environment for both Shogun and the bridge, then restart both. Do not commit this key to source control.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:`SHOGUN_INTERNAL_API_URL`}),` must be an address the bridge can reach. If both run on one computer, `,(0,Y.jsx)(`code`,{children:`http://127.0.0.1:8000`}),` is normally correct.`]}),(0,Y.jsxs)(`li`,{children:[`The bridge listens on port `,(0,Y.jsx)(`code`,{children:`3978`}),`. Put it behind a public HTTPS reverse proxy or a controlled development tunnel.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`code`,{children:`https://YOUR-BRIDGE-HOST/api/teams/health`}),`. A JSON response with status `,(0,Y.jsx)(`code`,{children:`ok`}),` confirms the bridge is reachable.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part D — Complete Katana's Setup Wizard`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Open `,(0,Y.jsx)(`strong`,{children:`The Katana → Microsoft Teams → Setup Wizard`}),` and use these values:`]}),(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left bg-shogun-bg text-shogun-subdued`,children:[(0,Y.jsx)(`th`,{className:`p-3`,children:`Katana field`}),(0,Y.jsx)(`th`,{className:`p-3`,children:`Recommended value`})]})}),(0,Y.jsxs)(`tbody`,{className:`divide-y divide-shogun-border text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Deployment mode`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[(0,Y.jsx)(`strong`,{children:`Customer-hosted Teams Bridge`}),` for production; Local development + tunnel for a pilot.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Tenant mode`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[(0,Y.jsx)(`strong`,{children:`Single tenant`}),`.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Allowed tenant IDs`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The Directory (tenant) ID from Entra. Enter one ID per line.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Bot / App ID`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The Application (client) ID from Entra.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Bot display name`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`A friendly name such as `,(0,Y.jsx)(`code`,{children:`Shogun`}),`.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Secret reference`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`A reference such as `,(0,Y.jsx)(`code`,{children:`vault://teams/bot-client-secret`}),`, never the secret value. The actual credential is injected into the bridge runtime.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Public messaging endpoint`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[(0,Y.jsx)(`code`,{children:`https://YOUR-BRIDGE-HOST/api/messages`}),` — exactly the same URL configured on the Azure Bot.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Valid domains`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`Hostname only, for example `,(0,Y.jsx)(`code`,{children:`teams-bridge.example.com`}),`. Do not include `,(0,Y.jsx)(`code`,{children:`https://`}),` or a path.`]})]})]})]})}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Save configuration`}),`.`]}),(0,Y.jsx)(`li`,{children:`Keep SSO, Microsoft Graph, and Proactive messaging disabled for the first test.`}),(0,Y.jsx)(`li`,{children:`Under Security Policy, keep destructive commands disabled and dual approval enabled.`}),(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Enable adapter`}),`. Overview should become Production ready or show a specific missing item.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part E — Generate and install the Teams app`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[`Click `,(0,Y.jsx)(`strong`,{children:`Generate Teams app package`}),`. Shogun downloads `,(0,Y.jsx)(`code`,{children:`shogun-teams-app.zip`}),`. Do not unzip it.`]}),(0,Y.jsxs)(`li`,{children:[`For a personal pilot, open Teams and choose `,(0,Y.jsx)(`strong`,{children:`Apps → Manage your apps → Upload an app → Upload a custom app`}),`. Select the ZIP, then choose `,(0,Y.jsx)(`strong`,{children:`Add`}),` and `,(0,Y.jsx)(`strong`,{children:`Open`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`If Upload a custom app is missing, a Teams administrator must allow it or upload the ZIP centrally at`,(0,Y.jsx)(`a`,{href:`https://admin.teams.microsoft.com`,target:`_blank`,rel:`noreferrer`,className:`text-indigo-400 hover:underline`,children:` Teams admin center`}),` under `,(0,Y.jsx)(`strong`,{children:`Teams apps → Manage apps → Upload new app`}),`.`]}),(0,Y.jsxs)(`li`,{children:[`For a team or channel, install the app in that team too. In channel messages, directly mention `,(0,Y.jsx)(`code`,{children:`@Shogun`}),` before the command.`]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/deploy-and-publish/apps-upload`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(_,{className:`w-3 h-3`}),` Upload a custom app in Teams`]}),(0,Y.jsxs)(`a`,{href:`https://learn.microsoft.com/en-us/microsoftteams/teams-custom-app-policies-and-settings`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-[11px] text-indigo-400 hover:underline`,children:[(0,Y.jsx)(_,{className:`w-3 h-3`}),` Teams administrator app policies`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Part F — Test in the right order`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-3 ml-5 list-decimal leading-relaxed`,children:[(0,Y.jsx)(`li`,{children:`Open a personal chat with the installed Shogun app. The welcome message should say Shogun is connected.`}),(0,Y.jsxs)(`li`,{children:[`Send `,(0,Y.jsx)(`code`,{children:`help`}),`, then `,(0,Y.jsx)(`code`,{children:`status`}),`. These are safe first commands for a new Viewer identity.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Katana → Microsoft Teams → Entra & Roles`}),`. Your identity should appear after the first message.`]}),(0,Y.jsxs)(`li`,{children:[`Open `,(0,Y.jsx)(`strong`,{children:`Audit Log`}),`. The commands should have timestamps, authorization results, and correlation IDs.`]}),(0,Y.jsxs)(`li`,{children:[`Under `,(0,Y.jsx)(`strong`,{children:`Diagnostics`}),`, run Shogun backend and Teams manifest. Test Graph and proactive messaging only after configuring those features.`]}),(0,Y.jsxs)(`li`,{children:[`Finally test a channel with `,(0,Y.jsx)(`code`,{children:`@Shogun status`}),`. A plain `,(0,Y.jsx)(`code`,{children:`status`}),` without the mention may be ignored.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsx)(`h5`,{className:`text-sm font-bold text-shogun-text`,children:`Teams troubleshooting`}),(0,Y.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[11px]`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`text-left bg-shogun-bg text-shogun-subdued`,children:[(0,Y.jsx)(`th`,{className:`p-3`,children:`What you see`}),(0,Y.jsx)(`th`,{className:`p-3`,children:`What to check`})]})}),(0,Y.jsxs)(`tbody`,{className:`divide-y divide-shogun-border text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`The app cannot be uploaded`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Ask the Teams administrator to enable custom app upload or upload the ZIP in Teams admin center. Regenerate the ZIP after changing App ID, valid domains, or SSO.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Bot sends no reply`}),(0,Y.jsxs)(`td`,{className:`p-3`,children:[`Check bridge health, confirm Azure Bot uses the exact `,(0,Y.jsx)(`code`,{children:`/api/messages`}),` HTTPS endpoint, and confirm the Teams channel is enabled.`]})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`“Shogun is unreachable”`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The bridge is online but cannot reach Shogun. Check the internal API URL, network/firewall access, and that both processes use the same internal API key.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Unauthorized or silent command`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`Compare the tenant with Allowed tenant IDs. In a channel, mention the bot and ensure the app is installed in that team.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Only safe commands work`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`This is expected for new Viewer identities. An administrator must deliberately assign a higher Shogun role and command policy.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Authentication stopped later`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The client secret may have expired. Replace it in the bridge's secret store, restart the bridge, and retire the old secret.`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:`Proactive messages disappear after restart`}),(0,Y.jsx)(`td`,{className:`p-3`,children:`The included bridge uses in-memory storage for development. Production needs Azure Blob or Cosmos-backed Agents SDK storage, and the user must contact the bot once first.`})]})]})]})})]}),(0,Y.jsxs)(`div`,{className:`p-4 rounded-lg border border-green-400/20 bg-green-400/5`,children:[(0,Y.jsx)(`h5`,{className:`text-xs font-bold text-green-400`,children:`Setup is complete when all six statements are true`}),(0,Y.jsxs)(`ul`,{className:`text-[11px] text-shogun-subdued mt-2 ml-4 list-disc space-y-1.5`,children:[(0,Y.jsxs)(`li`,{children:[`The bridge health URL returns status `,(0,Y.jsx)(`code`,{children:`ok`}),`.`]}),(0,Y.jsx)(`li`,{children:`Katana Overview reports the adapter as ready with the correct tenant.`}),(0,Y.jsx)(`li`,{children:`The Teams app installs without a manifest error.`}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:`help`}),` and `,(0,Y.jsx)(`code`,{children:`status`}),` receive replies in a personal chat.`]}),(0,Y.jsx)(`li`,{children:`The user appears under Entra & Roles and the command appears in Audit Log.`}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{children:`@Shogun status`}),` works in every team/channel where the app was intentionally installed.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-archives`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(h,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Archives — The Memory Vault`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Everything the Shogun has ever learned, remembered, or been told.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`w-4 h-4 text-shogun-gold`}),` Semantic Search Bar`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Type a question or topic and the system finds matching memories using AI-powered "meaning" search — not just keyword matching. For example, searching "customer complaints" can also return memories about "user feedback" or "product issues." Results are ranked by relevance.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-shogun-gold`}),` Memory Types`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Memories are categorized into types:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Semantic:`}),` Facts and knowledge (e.g., "The capital of France is Paris").`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Episodic:`}),` Experiences and events (e.g., "User asked about pricing on April 15").`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Procedural:`}),` How-to instructions and workflows.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Persona:`}),` Durable identity, relationship, and communication context.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Skills:`}),` Canonical achieved-skill content synchronized from the Dojo.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Programming:`}),` Reusable coding solutions with evidence, validation, files, languages, and sources.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(V,{className:`w-4 h-4 text-shogun-gold`}),` Salience Score`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Each memory has relevance and importance signals that influence retrieval. Frequently reused memories can be reinforced, while decay policies control retention: `,(0,Y.jsx)(`strong`,{children:`fast`}),`, `,(0,Y.jsx)(`strong`,{children:`medium`}),`, `,(0,Y.jsx)(`strong`,{children:`slow`}),`, `,(0,Y.jsx)(`strong`,{children:`sticky`}),`, or `,(0,Y.jsx)(`strong`,{children:`pinned`}),`. Pin critical memories to keep them at maximum priority.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-shogun-gold`}),` Inscribe Memory (+ Button)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click the "+" button to manually add a new memory. You choose the `,(0,Y.jsx)(`strong`,{children:`type`}),` (semantic, episodic, etc.), write the `,(0,Y.jsx)(`strong`,{children:`content`}),`, and optionally set the `,(0,Y.jsx)(`strong`,{children:`salience`}),`. This is useful for injecting facts, rules, or context that the AI should always know about.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-gold`}),` Browse, Filter & Lifecycle`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Filter by memory type, decay policy, or agent, then sort chronologically or by salience/importance. Each card exposes its content, provenance, scores, dates, and tags. Normal memories move to the archive instead of being hard-deleted; Programming memories use an explicit permanent-delete action.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-shogun-gold`}),` Import & Export`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Import Memories`}),` accepts OpenClaw exports, Shogun exports, and generic Markdown from files, ZIP archives, or folders. It parses input as inert data, validates a preview, reports duplicates/conflicts, supports embedding retries and rollback, and blocks ZIP path traversal.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Export Memory`}),` creates an OpenClaw-compatible Markdown bundle. Scope and filter by agent, project, memory type, date, and minimum importance; optionally include archived, private, sticky, analysis, raw, or secret-bearing content. Sensitive exports require confirmation and remain available in export history.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-shogun-gold/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(l,{className:`w-4 h-4 text-shogun-gold`}),` Self-Reinforced Learning`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In Mission Mode, Shogun is instructed to proactively retain durable guidance when you explicitly correct it, tool use reveals verified information likely to help future work, or you confirm a reusable decision, preference, or idea. It must avoid transient, speculative, duplicated, sensitive, or task-local material and record source and confidence where applicable.`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Two cases also have dedicated automatic capture: explicit operator corrections become durable semantic memories, and completed Mado web research becomes a sourced procedural memory. Existing matches are reused or reinforced instead of blindly duplicated. Governed Chat mechanically captures explicit corrections but cannot browse or use Mission tools.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-dojo`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(c,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Dojo — The Training Hall`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Browse, study, and certify your agents on 4,000+ skills. Has 4 tabs.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`w-4 h-4 text-shogun-gold`}),` Catalog Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The default tab. Shows every available skill from the OpenClaw College database. Each skill shows its `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`risk tier`}),` (Low, Medium, High, Critical), and faculty category. A sidebar shows faculty categories in a collapsible tree — click a category to filter skills. Use the search bar to find specific skills by name. Click any skill to see its full training literature.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-shogun-gold`}),` Bundles Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Skills grouped into themed bundles (e.g., "Web Security Fundamentals," "Data Analysis Pack"). Each bundle card shows the bundle name, number of skills included, average difficulty, and a description. Click a bundle to expand it and see all the skills it contains.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-shogun-gold`}),` Specializations Tab`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Higher-level groupings that combine multiple bundles into a career-path style progression. Think of these as "majors" — completing a specialization means your agent is deeply trained in an entire domain.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-gold`}),` Achieved Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shows all the certifications your agents have already passed. Each entry shows the skill name, exam score, pass/fail status, and date achieved. Achieved skills are synchronized into the Archives `,(0,Y.jsx)(`strong`,{children:`Skills`}),` memory layer so their canonical instructions can participate in runtime retrieval.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-shogun-gold`}),` Skill Detail & Exams`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When you click a skill, its detail pane shows canonical training content, source material, and risk tier plus a `,(0,Y.jsx)(`strong`,{children:`Take Exam`}),` action. Canonical skill content is structured as an operational instruction foundation: purpose, use conditions, inputs, workflow, decision rules, outputs, safety constraints, failure handling, examples, and success criteria. Exams contain 30–50 multiple-choice questions; passing certifies the agent and records the achievement.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-kaizen`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(R,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Kaizen — The Constitutional Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Define the fundamental laws and ethical boundaries for all agents. Has 2 tabs.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-shogun-gold`}),` Constitution Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A full-screen YAML code editor where you write the "Constitution" — the AI's core laws. The system validates the YAML in real time (green dot = correct syntax, red = error with details). On the right sidebar, `,(0,Y.jsx)(`strong`,{children:`Active Principles`}),` are extracted from the YAML and shown as colored cards: red (Critical), orange (High), gold (Balanced), blue (Medium), green (Low). Click `,(0,Y.jsx)(`strong`,{children:`"Publish Edicts"`}),` to save your changes — a new revision is created automatically.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-shogun-gold`}),` The Mandate Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A Markdown editor for writing the Shogun's "Mission Statement." This is a free-form document defining objectives and operating principles. Use the `,(0,Y.jsx)(`strong`,{children:`Edit/Preview`}),` toggle to switch between writing mode and rendered mode. Key sections of this document are automatically injected into the AI's system prompt on every interaction, so if you write "Always respond in Danish" here, the AI will obey.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(F,{className:`w-4 h-4 text-shogun-gold`}),` Revision History`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`On the right sidebar (both tabs). Shows a timeline of every saved version of the Constitution or Mandate. Each entry shows the version number, change summary, and date. The most recent version is highlighted.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-shogun-gold`}),` Download Audit Log`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`At the bottom of the sidebar. Downloads a JSON file containing the full audit history of all governance changes. Useful for compliance or reviewing what rules were changed and when.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-bushido`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(F,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Bushido — The Reflection Engine`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Automated self-improvement cycles where the AI analyzes its own performance.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-blue`}),` Calibration Controls`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Three dials that control the Shogun's self-improvement behavior: `,(0,Y.jsx)(`strong`,{children:`Reflection Frequency`}),` (how often the system thinks about its own performance), `,(0,Y.jsx)(`strong`,{children:`Consolidation Threshold`}),` (when to compress old memories), and `,(0,Y.jsx)(`strong`,{children:`Exploration Budget`}),` (how willing the system is to try new approaches). Each has a slider and a plain-English description.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-shogun-blue`}),` Insight Stream`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A live feed of AI-generated suggestions. The system autonomously analyzes its own behavior and posts insights like "Model X is 2x faster for code tasks" or "Memory #412 hasn't been used in 30 days — consider archiving." Each insight has a severity badge and a timestamp.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(F,{className:`w-4 h-4 text-shogun-blue`}),` Reflection Trigger`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A button to manually trigger a reflection cycle. The system will analyze recent interactions, evaluate model performance, check memory health, and produce a set of actionable insights. Results appear in the Insight Stream.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-mado`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-cyan-400/40 pb-3`,children:[(0,Y.jsx)(o,{className:`w-6 h-6 text-cyan-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Mado — The Browser Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Secure browser automation. Your AI can browse the web, extract content, and take screenshots.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-cyan-400`}),` Browse Web`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Shogun can navigate to any URL using the `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),` native skill. It loads the full page via Playwright (a real browser engine), then extracts the content as readable text or raw HTML. You can optionally pass a CSS selector to target a specific element on the page.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(te,{className:`w-4 h-4 text-cyan-400`}),` Screenshots`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`After navigating to a page, the Shogun can take a screenshot using `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`take_screenshot`}),`. Choose between viewport-only or full-page capture. Screenshots are saved locally and can be used in mission reports or sent via Telegram.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-cyan-400`}),` Security Integration`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Mado respects the active Torii tier or custom policy as enforced by ToolGate. Browser automation must be enabled in that policy's capability boundaries. In `,(0,Y.jsx)(`strong`,{children:`SHRINE`}),` tier, Mado is disabled entirely. In `,(0,Y.jsx)(`strong`,{children:`GUARDED`}),`, it's limited to 1 session with no downloads or uploads. In `,(0,Y.jsx)(`strong`,{children:`TACTICAL`}),` and above, broader Mado features can be available.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-cyan-400`}),` Session Management`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Browser sessions are managed automatically. When Shogun shuts down, all active Playwright browser instances are cleanly closed. The Mado page in the sidebar shows the current session status and lets you manually manage active browser contexts.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(L,{className:`w-4 h-4 text-cyan-400`}),` One Permission Authority`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Torii selects the governing tier or custom policy; ToolGate is the runtime permission authority for Mado. The active policy controls browser access, headless or visible mode, autonomous browsing, uploads, downloads, and session limits. Mado remains an operational console for runtime health, screenshots, resets, and diagnostics—it does not maintain a second permission system.`})]})]}),(0,Y.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-cyan-400 uppercase tracking-widest pl-1 border-l-2 border-cyan-400/40 ml-1`,children:`Practical How-To Guide — Using Mado Step by Step`}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-cyan-400 font-mono text-sm`,children:`01`}),` First-Time Setup — Install Chromium`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Before Mado can work, you need the browser engine. This is a `,(0,Y.jsx)(`strong`,{children:`one-time setup`}),`:`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsxs)(`li`,{children:[`Navigate to `,(0,Y.jsx)(`strong`,{children:`Mado`}),` in the sidebar.`]}),(0,Y.jsxs)(`li`,{children:[`If Chromium is not installed, you'll see a `,(0,Y.jsx)(`strong`,{children:`"Install Chromium"`}),` button in the top-right corner.`]}),(0,Y.jsx)(`li`,{children:`Click it. The system will download and install Playwright + Chromium (1–2 minutes depending on connection).`}),(0,Y.jsxs)(`li`,{children:[`Once complete, the badge changes to a green `,(0,Y.jsx)(`strong`,{children:`"Chromium Ready"`}),` indicator with the version number.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Security Note:`}),` Mado must be enabled in the active policy's browser capability boundary in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`. The built-in `,(0,Y.jsx)(`strong`,{children:`SHRINE`}),` policy disables Mado. `,(0,Y.jsx)(`strong`,{children:`GUARDED`}),` allows one session with no downloads or uploads. `,(0,Y.jsx)(`strong`,{children:`TACTICAL`}),` and higher tiers can expose broader features, subject to the active policy's ToolGate rules.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-cyan-400 font-mono text-sm`,children:`02`}),` Let Shogun Manage the Browser`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`You do not need to create browser sessions manually. Shogun creates its managed browser profile automatically the first time a governed task calls `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),`.`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsxs)(`li`,{children:[`Select the tier or custom policy in `,(0,Y.jsx)(`strong`,{children:`Torii`}),`, then review browser permissions in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`.`]}),(0,Y.jsx)(`li`,{children:`Ask Shogun to browse, or run an AgentFlow containing a Mado Browser node.`}),(0,Y.jsxs)(`li`,{children:[`Use `,(0,Y.jsx)(`strong`,{children:`Mado → Overview`}),` to inspect the managed session.`]}),(0,Y.jsxs)(`li`,{children:[`Use `,(0,Y.jsx)(`strong`,{children:`Reset`}),` only when the browser needs a clean profile.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Advanced diagnostics`}),` lists runtime sessions and storage paths without adding another security configuration layer.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-emerald-400 font-mono text-sm`,children:`A`}),` Scenario: Browse the Web via Chat`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The easiest way to use Mado — just ask your Shogun in the chat. Behind the scenes, it uses the `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),` native skill.`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-cyan-400/80 font-bold uppercase tracking-widest`,children:`Example Chat Prompts`}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Browse https://news.ycombinator.com and give me the top 5 stories"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Go to https://example.com/pricing and extract the pricing table"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Visit https://github.com/trending and summarize what's popular today"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`"Browse https://weather.com and tell me the forecast for Copenhagen"`})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`What happens:`}),` The Shogun launches a headless browser session (if not already running), navigates to the URL, auto-accepts cookie consent walls (Google/YouTube), extracts the page content as text, and returns it in the chat — up to 20,000 characters.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Targeting specific content:`}),` Add a CSS selector to extract only what you need:`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono bg-shogun-bg rounded px-2 py-1`,children:`"Browse https://en.wikipedia.org/wiki/Shogun and extract the text from the #mw-content-text selector"`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-emerald-400 font-mono text-sm`,children:`B`}),` Scenario: Screenshot a Web Page`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`After browsing to a page, you can ask the Shogun to take a screenshot:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-cyan-400/80 font-bold uppercase tracking-widest`,children:`Example Chat Sequence`}),(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`1. "Browse https://my-dashboard.example.com/analytics"`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-text font-mono`,children:`2. "Now take a screenshot of this page"`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-text font-mono`,children:[`3. "Take a full-page screenshot" `,(0,Y.jsx)(`span`,{className:`text-shogun-subdued`,children:`(captures entire scrollable page)`})]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Screenshots are saved to the `,(0,Y.jsx)(`strong`,{children:`Mado → Screenshots`}),` tab with a timestamp. You can view all captured images there. Files are stored at `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`data/mado/screenshots/`}),`.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-violet-400 font-mono text-sm`,children:`C`}),` Scenario: Inspecting Browser Operations`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Use the Mado console to inspect browser work while ToolGate remains responsible for runtime permissions:`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Overview:`}),` Check Chromium, agent-browser health, and session count.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Screenshots:`}),` Review evidence captured by chat and AgentFlow tasks.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Advanced:`}),` Inspect runtime sessions and storage paths, or remove stale sessions.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Torii:`}),` Select the tier or custom policy. `,(0,Y.jsx)(`strong`,{children:`ToolGate:`}),` Inspect or change its browser capability boundaries and runtime rules.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Design principle:`}),` Torii selects the policy, ToolGate governs runtime permission, and Mado shows browser operations.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-violet-400 font-mono text-sm`,children:`D`}),` Scenario: Multi-Step Automation with Agent Flow`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`For complex workflows, combine Mado with Agent Flow — the visual workflow builder:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-cyan-400/80 font-bold uppercase tracking-widest`,children:`Example: Daily Competitor Price Check`}),(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-shogun-subdued`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Input Node →`}),` "Check competitor prices"`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Mado Browser Node →`}),` Navigate to competitor's pricing page`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Samurai Node →`}),` "Analyze the pricing data and compare to our current prices"`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Logic Node →`}),` If prices changed → proceed, else → skip`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Samurai Node →`}),` "Draft a summary email of pricing changes"`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{children:`Output Node →`}),` Final report`]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`The `,(0,Y.jsx)(`strong`,{children:`Mado Browser node`}),` in Agent Flow supports: navigate to a URL, extract content (text/HTML), and take screenshots. Chain it with Samurai nodes for AI analysis and Logic nodes for conditional routing.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-amber-400 font-mono text-sm`,children:`E`}),` Scenario: Filling Forms & Clicking Elements`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Mado supports full interaction with web pages — not just reading them. Via the API, you can:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Fill forms:`}),` Provide a list of `,(0,Y.jsxs)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:[`{`,`selector, value, type`,`}`]}),` objects. Supports text inputs, dropdowns (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`select`}),`), and checkboxes.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Click elements:`}),` Click any element by CSS selector — buttons, links, menu items.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Wait for elements:`}),` Pause until a specific CSS selector appears on the page (with configurable timeout).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Execute JavaScript:`}),` Run custom JS scripts on the page for advanced extraction or interaction.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Upload files:`}),` Upload a local file to a file input element (requires TACTICAL tier or higher).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Download files:`}),` Capture a triggered download and save it locally (requires TACTICAL tier or higher).`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[`These actions are available through the REST API at `,(0,Y.jsxs)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:[`/api/v1/mado/sessions/`,`{`,`session_id`,`}`,`/fill-form`]}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/click`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/wait`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/execute-js`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/upload`}),`, and `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`/download`}),`.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-amber-400 font-mono text-sm`,children:`F`}),` Scenario: Generating PDFs from Web Pages`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Mado can convert any web page to a PDF document — useful for archiving, reports, or compliance evidence:`}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-decimal`,children:[(0,Y.jsx)(`li`,{children:`Navigate to the page you want to convert (via chat, AgentFlow, or API).`}),(0,Y.jsxs)(`li`,{children:[`Call the PDF endpoint: `,(0,Y.jsxs)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:[`POST /api/v1/mado/sessions/`,`{`,`session_id`,`}`,`/pdf`]})]}),(0,Y.jsxs)(`li`,{children:[`The PDF is generated in A4 format with background colors and saved to `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`data/mado/downloads/`}),`.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Note:`}),` PDF generation only works in `,(0,Y.jsx)(`strong`,{children:`headless`}),` mode (Chromium limitation).`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-cyan-400 font-mono text-sm`,children:`💡`}),` Understanding Browser Profiles`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Each session has a `,(0,Y.jsx)(`strong`,{children:`profile`}),` — a persistent directory on disk that stores cookies, local storage, cache, and login sessions. This means:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Logins persist:`}),` If you log into a website in session "research_agent", next time you use that profile, you're still logged in.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Isolation:`}),` Different profiles don't share cookies or data — like using separate Chrome profiles.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Cleanup:`}),` Delete a session to close the browser. The profile data stays on disk until you manually delete it from `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`data/mado/profiles/`}),`.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Storage paths`}),` are visible under `,(0,Y.jsx)(`strong`,{children:`Mado → Advanced`}),`. The agent-managed profile is created automatically and can be reset from Overview.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-red-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(L,{className:`w-4 h-4 text-red-400`}),` Configuring Mado Permissions`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Select the tier or custom policy in `,(0,Y.jsx)(`strong`,{children:`Torii`}),`, then configure its Mado boundaries in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`. These rules apply consistently to chat, Telegram, the Mado API, and AgentFlow browser nodes. Gensui owns the same ToolGate controls when centrally managed.`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-red-400/80 font-bold uppercase tracking-widest`,children:`ToolGate Capability Boundaries`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-2 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Mado enabled:`}),` Allows or blocks browser automation entirely.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Headless only:`}),` Prevents visible browser windows at restricted postures.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Maximum sessions:`}),` Applies to API, agent-managed, and AgentFlow sessions.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Autonomous browsing:`}),` Controls unattended browser work.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Downloads and uploads:`}),` Governs file transfer through Mado.`]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-1`,children:[(0,Y.jsx)(`strong`,{children:`Priority:`}),` Gensui-owned ToolGate policy overrides standalone ToolGate settings when fleet governance is active. Mado itself does not override either authority.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-red-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-red-400 font-mono text-sm`,children:`⚠`}),` Troubleshooting`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`"Browser automation is disabled"`}),` — The active policy's ToolGate boundary does not allow Mado. Use `,(0,Y.jsx)(`strong`,{children:`Torii`}),` to select an appropriate tier or custom policy, then inspect `,(0,Y.jsx)(`strong`,{children:`ToolGate → Capability Boundaries`}),`. The built-in GUARDED tier allows one restricted session; TACTICAL and higher can expose broader features.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`"No active browser session"`}),` — For chat skills (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`take_screenshot`}),`), you must first use `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`browse_web`}),` to navigate to a page.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Chromium not installed`}),` — Click "Install Chromium" on the Mado page. Requires internet access for the initial download (~200 MB).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Session shows "idle" forever`}),` — The browser launches lazily. It only starts when you perform an action (navigate, screenshot, etc.). This is normal.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Visible mode blocked`}),` — The active policy's Mado boundary may enforce headless-only browsing. Campaign- or Ronin-based policies can permit visible sessions when ToolGate enables them.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-ronin`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-orange-400/40 pb-3`,children:[(0,Y.jsx)(m,{className:`w-6 h-6 text-orange-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Ronin - Desktop Control Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Governed desktop automation: mouse, keyboard, screenshots, native apps, and OS interaction.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-red-500/10 border-red-500/30 border-l-4 border-l-red-500`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-red-500 flex items-center gap-2 mb-3`,children:[(0,Y.jsx)(L,{className:`w-5 h-5`}),`CRITICAL: Understand the Repercussions Before Enabling`]}),(0,Y.jsxs)(`div`,{className:`space-y-3 text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Ronin gives the AI direct physical control of your computer.`}),` This is not a sandboxed operation. When enabled, Shogun can move your mouse, press keys, read your screen, interact with any application, and execute OS-level commands. This is fundamentally different from browser automation (Mado), which runs in an isolated Chromium sandbox.`]}),(0,Y.jsxs)(`div`,{className:`bg-[#050508] rounded-lg p-3 border border-red-500/20 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-red-400 font-bold text-[10px] uppercase tracking-widest`,children:`What can go wrong:`}),(0,Y.jsxs)(`ul`,{className:`ml-4 list-disc space-y-1.5`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Data Loss:`}),` The AI can click Delete buttons, overwrite files, or drag items to trash. At CAMPAIGN/RONIN tier, file deletion is allowed or only requires approval but mistakes happen in milliseconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Credential Exposure:`}),` If the AI types into a password field, opens a password manager, or interacts with banking/crypto apps your credentials could be exposed, logged, or transmitted. At RONIN tier, credential entry is ALLOWED with no gate.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Financial Damage:`}),` The AI can click purchase buttons, submit orders, confirm transactions, or interact with trading platforms. There is no undo for financial actions.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Software Installation:`}),` At CAMPAIGN tier, software installation requires approval. At RONIN tier, the AI can download and install arbitrary software without asking.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Admin Escalation:`}),` At RONIN tier, admin escalation is enabled. The AI can accept UAC prompts, run as administrator, and modify system settings.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`External Data Upload:`}),` The AI can open a browser, paste sensitive data, and upload it to external services. At RONIN tier, this is ALLOWED without approval.`]})]})]}),(0,Y.jsx)(`p`,{className:`text-red-400 font-bold`,children:`Rule of thumb: If you would not give a stranger unsupervised access to your desktop, do not enable CAMPAIGN or RONIN posture on that machine.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-orange-400`}),` Posture Levels`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Ronin has four posture levels. The active posture is set in Torii → Security Posture and shown in the Ronin header.`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-[#7a8899] bg-[#7a8899]/10 px-2 py-0.5 rounded`,children:`DISABLED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`No desktop access at all. Shrine and Guarded tiers.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-blue bg-shogun-blue/10 px-2 py-0.5 rounded`,children:`OBSERVE ONLY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Screenshots and window listing only. Read-only.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`BROWSER ONLY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Playwright/Mado browser control only. No desktop.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 bg-orange-400/10 px-2 py-0.5 rounded`,children:`DESKTOP LIMITED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Mouse, keyboard, screenshots. No native apps, no shell, no admin. Tactical tier.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`DESKTOP FULL`}),(0,Y.jsxs)(`span`,{className:`text-xs text-shogun-subdued`,children:[`Full control: native apps, shell commands, admin escalation. Campaign/Ronin tier.`,` `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`DANGEROUS.`})]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(m,{className:`w-4 h-4 text-orange-400`}),` Where to Configure`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Torii selects the governing tier or custom policy. Its inherited desktop ceiling and explicit Ronin boundaries are shown and governed in ToolGate; Ronin cannot widen them from its operational console.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE / GUARDED:`}),` Ronin is disabled. No desktop control at all.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL:`}),` Ronin is desktop_limited. Mouse + keyboard + screenshots. 1 session max. Dangerous actions blocked.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` Ronin is desktop_full. Native apps + shell. 5 sessions max. Dangerous actions require approval.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN:`}),` Ronin is desktop_full. Everything allowed. 10 sessions. Admin escalation enabled. `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`No safety gates. VM only recommended.`})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`After selecting a tier, the Ronin constraints appear in the Current Constraints card on the left side of Torii (Ronin Desktop, Ronin Sessions, Mouse/Keyboard).`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-orange-400`}),` Application Trust Levels`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every application on your OS is classified into one of four trust levels. The Posture Guard evaluates: Agent + Posture + App Trust + Environment = Decision.`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`TRUSTED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`VS Code, Notepad, Calculator, Shogun. Safe to interact.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-yellow-400 bg-yellow-400/10 px-2 py-0.5 rounded`,children:`RESTRICTED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Chrome, Excel, PowerPoint. Some caution required.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 bg-orange-400/10 px-2 py-0.5 rounded`,children:`SENSITIVE`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Outlook, SAP, Salesforce, CRM. Requires elevated posture.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`FORBIDDEN`}),(0,Y.jsxs)(`span`,{className:`text-xs text-shogun-subdued`,children:[`Password managers, banking apps, crypto wallets. `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Always blocked, no override.`})]})]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The trust registry comes pre-populated with 50+ applications. View and filter them on the App Trust tab in Ronin.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(L,{className:`w-4 h-4 text-red-400`}),` Komainu Guardian (Physical Override)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Komainu is a hardware-level safety mechanism. It monitors for human mouse and keyboard activity and can instantly override the AI. Three levels:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-yellow-400 bg-yellow-400/10 px-2 py-0.5 rounded`,children:`LEVEL 1: PAUSE`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Any human input pauses the active Ronin session. Resume manually.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 bg-orange-400/10 px-2 py-0.5 rounded`,children:`LEVEL 2: TERMINATE`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Any human input kills the active session immediately.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`LEVEL 3: HARAKIRI`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Any human input triggers full emergency stop for all sessions and agents.`})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Triple-Escape`}),` (press Escape 3 times rapidly) is a hard-coded Level 3 trigger that cannot be disabled, overridden, or circumvented. It always triggers Harakiri.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-orange-400`}),` Capabilities Registry`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`20+ registered actions organized by category. Each has a risk level, minimum posture requirement, and an approval flag. View them on the Capabilities tab in Ronin.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Desktop:`}),` screenshot, click, move_mouse, type, hotkey, locate_image, read_screen`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Browser:`}),` open, click, type, extract, screenshot (bridges to Mado)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`OS:`}),` list_windows, focus_window, get_foreground_app`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(j,{className:`w-4 h-4 text-orange-400`}),` Environment Detection`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Ronin automatically detects the environment type at startup. This affects which posture policies are allowed.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Physical Machine:`}),` Your real hardware. Highest risk surface.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`VM:`}),` VirtualBox, VMware, Hyper-V. Recommended for full desktop posture.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Sandbox:`}),` Windows Sandbox, Docker. Safe for testing.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Remote Desktop:`}),` RDP sessions. Higher latency, lower risk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Citrix / Cloud Workspace:`}),` Enterprise environments. Policy may be enforced by Gensui.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-4 border-l-red-500`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4 text-red-400`}),` Tier-by-Tier Ronin Repercussions`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`This table shows exactly what the AI can do at each security tier. `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Read this carefully before changing your posture.`})]}),(0,Y.jsx)(`div`,{className:`bg-shogun-bg rounded-lg overflow-hidden border border-shogun-border`,children:(0,Y.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border`,children:[(0,Y.jsx)(`th`,{className:`text-left p-2.5 text-shogun-subdued font-bold uppercase tracking-widest text-[10px]`,children:`Dangerous Action`}),(0,Y.jsx)(`th`,{className:`text-center p-2.5 text-shogun-blue font-bold uppercase tracking-widest text-[10px]`,children:`Tactical`}),(0,Y.jsx)(`th`,{className:`text-center p-2.5 text-orange-400 font-bold uppercase tracking-widest text-[10px]`,children:`Campaign`}),(0,Y.jsx)(`th`,{className:`text-center p-2.5 text-red-400 font-bold uppercase tracking-widest text-[10px]`,children:`Ronin`})]})}),(0,Y.jsxs)(`tbody`,{className:`text-shogun-subdued`,children:[(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Credential Entry`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`File Deletion`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`External Uploads`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Software Install`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-yellow-400`,children:`Approval`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Native App Interaction`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,Y.jsx)(`td`,{className:`p-2.5`,children:`Shell Commands`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]}),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`td`,{className:`p-2.5 font-bold text-red-400`,children:`Admin Escalation (UAC)`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-red-400`,children:`Blocked`}),(0,Y.jsx)(`td`,{className:`text-center p-2.5 text-green-400`,children:`Allowed`})]})]})]})}),(0,Y.jsx)(`p`,{className:`text-xs text-red-400 font-bold leading-relaxed`,children:`At RONIN tier, every dangerous action is allowed WITHOUT operator approval. This means the AI can delete files, enter credentials, install software, and escalate to admin autonomously. Only use RONIN tier in fully isolated, disposable environments (VMs, sandboxes).`})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(m,{className:`w-4 h-4 text-orange-400`}),` Dashboard Tabs`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Ronin page has 5 tabs:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Control:`}),` Status cards, environment detection panel, and a Quick Action executor for manual desktop commands.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Sessions:`}),` Create and manage desktop sessions. Choose posture level and Komainu guardian level per session.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`App Trust:`}),` View the pre-classified trust registry. Filter by trust level.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Capabilities:`}),` View all registered desktop actions with risk levels and posture requirements.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Audit Trail:`}),` Chronological feed of all Ronin events with severity coloring.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ce,{className:`w-4 h-4 text-red-400`}),` Emergency Controls`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Multiple layers of emergency shutdown:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`STOP Button:`}),` The red skull button in the Ronin header. Triggers Harakiri.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Triple-Escape:`}),` Press Escape 3 times rapidly. Hard-coded, cannot be disabled.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-yellow-400`,children:`Komainu Override:`}),` Any human mouse or keyboard input triggers the configured level.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`Torii Harakiri:`}),` The global kill switch on the Torii page. Stops everything system-wide.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-office`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-green-400/40 pb-3`,children:[(0,Y.jsx)(y,{className:`w-6 h-6 text-green-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Office App Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Controlled Microsoft Office automation — Excel, Word, PowerPoint, Outlook.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-green-400`}),` Overview`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Office App Mode (codename Katana) lets the AI agent read, modify, and create Excel workbooks, Word documents, PowerPoint presentations, and Outlook emails — all within strict security boundaries. It uses a hybrid architecture: pure Python libraries handle most operations cross-platform. COM automation is only used for PDF export, formula calculation, and Outlook.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-green-500/10 border-green-500/30 border-l-4 border-l-green-500 space-y-3`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-green-400 flex items-center gap-2`,children:[(0,Y.jsx)(d,{className:`w-5 h-5`}),` Getting Started`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-decimal`,children:[(0,Y.jsx)(`li`,{children:`Navigate to Sidebar → Office (under Capabilities).`}),(0,Y.jsx)(`li`,{children:`Enable Office App Mode with the master toggle.`}),(0,Y.jsx)(`li`,{children:`Configure all four folders — input, output, templates, and temp.`}),(0,Y.jsx)(`li`,{children:`Toggle individual apps — enable only what you need.`}),(0,Y.jsx)(`li`,{children:`Save your configuration.`}),(0,Y.jsx)(`li`,{children:`The 27 Office tools are now available to the agent in chat.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-green-400`}),` Approved Folders`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every file operation is validated against four folder boundaries (input, output, templates, temp). Files outside are rejected. Path traversal, UNC paths, and .lnk shortcuts are blocked.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-green-400`}),` Output Versioning`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The agent never overwrites originals. Every save creates a timestamped copy (e.g. report_20260630_094500.xlsx). Old outputs are cleaned after the retention period (default: 30 days).`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(y,{className:`w-4 h-4 text-green-400`}),` Excel (8 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Open workbook`}),(0,Y.jsx)(`li`,{children:`Read range / all cells`}),(0,Y.jsx)(`li`,{children:`Write range`}),(0,Y.jsx)(`li`,{children:`List sheets`}),(0,Y.jsx)(`li`,{children:`Save as (versioned)`}),(0,Y.jsx)(`li`,{children:`Export PDF (COM)`}),(0,Y.jsx)(`li`,{children:`Recalculate (COM)`}),(0,Y.jsx)(`li`,{children:`Get metadata`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-blue-400`}),` Word (6 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Open document`}),(0,Y.jsx)(`li`,{children:`Replace placeholders`}),(0,Y.jsx)(`li`,{children:`Insert table`}),(0,Y.jsx)(`li`,{children:`Save as (versioned)`}),(0,Y.jsx)(`li`,{children:`Export PDF (COM)`}),(0,Y.jsx)(`li`,{children:`Get metadata`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-orange-400`}),` PowerPoint (7 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Open presentation`}),(0,Y.jsx)(`li`,{children:`Replace placeholders`}),(0,Y.jsx)(`li`,{children:`Insert table`}),(0,Y.jsx)(`li`,{children:`Insert image`}),(0,Y.jsx)(`li`,{children:`Save as (versioned)`}),(0,Y.jsx)(`li`,{children:`Export PDF (COM)`}),(0,Y.jsx)(`li`,{children:`Get metadata`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-cyan-400`}),` Outlook (4 tools)`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsx)(`li`,{children:`Create draft`}),(0,Y.jsx)(`li`,{children:`Attach file`}),(0,Y.jsx)(`li`,{children:`Save + review`}),(0,Y.jsx)(`li`,{children:`Send (high-risk)`})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(k,{className:`w-4 h-4 text-cyan-400`}),` Outlook Modes`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`DRAFT ONLY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Create and save drafts. Never sends.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-yellow-400 bg-yellow-400/10 px-2 py-0.5 rounded`,children:`CONFIRMED SEND`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Can send with human approval.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`APPROVED RECIPIENTS`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Auto-send to allowlisted domains.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-green-400`}),` Security Per Posture`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE:`}),` Office completely disabled.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`GUARDED:`}),` Read, write, save-as. No overwrite, no macros, no send.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL:`}),` + Delete (approval). + Send (approval).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` + Delete (allowed). + Send (approval).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN:`}),` + Overwrite originals. Send still requires approval.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-green-400`}),` Audit Trail`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every Office operation emits an office.* event into the dual-write audit chain. Events include application, action, file paths, duration, and status. View them on the Logs page filtered by category: office.`})]})]}),(0,Y.jsxs)(`section`,{id:`ref-workspace`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-amber-400/40 pb-3`,children:[(0,Y.jsx)(x,{className:`w-6 h-6 text-amber-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Workspace — Agent File System`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`A dedicated folder where the Shogun and all Samurai agents have persistent read/write access.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-amber-400`}),` Overview`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Workspace is a single, dedicated directory where the Shogun and all Samurai agents can read, write, and manage files. It serves as the agent’s persistent “desk” — a safe location to store outputs, share data between agents, and create working documents. Availability and access mode follow the active policy's filesystem and workspace boundaries in ToolGate; the built-in Shrine policy disables it.`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Default location: data/workspace/ inside the Shogun project directory. The path is configurable via environment variable WORKSPACE_PATH.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-amber-500/10 border-amber-500/30 border-l-4 border-l-amber-500 space-y-3`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-amber-400 flex items-center gap-2`,children:[(0,Y.jsx)(d,{className:`w-5 h-5`}),` Getting Started`]}),(0,Y.jsxs)(`ol`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-decimal`,children:[(0,Y.jsx)(`li`,{children:`Navigate to Comms (sidebar) and click the Files tab.`}),(0,Y.jsx)(`li`,{children:`The File Explorer shows the workspace tree on the left and a content viewer/editor on the right.`}),(0,Y.jsx)(`li`,{children:`Use the toolbar buttons to create new files, new folders, rename, or delete items.`}),(0,Y.jsx)(`li`,{children:`Click any file to view its content. Click Edit to modify it inline, then Save.`}),(0,Y.jsx)(`li`,{children:`In Mission Mode chat, ask the Shogun to use workspace tools — it can read, write, list, and manage files directly.`}),(0,Y.jsx)(`li`,{children:`The workspace folder is automatically created on first startup at data/workspace/.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(x,{className:`w-4 h-4 text-amber-400`}),` File Explorer (Comms → Files Tab)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The File Explorer is a tab inside the Comms page, alongside Chat, Mail, and Calendar. It provides a visual interface for managing workspace files:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Tree sidebar:`}),` Expandable directory tree with file-type icons (code, spreadsheet, image, archive, text), size labels, and real-time search filter.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Content viewer:`}),` Displays file contents with monospace formatting. Shows file path, extension, and size in the header bar.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Inline editor:`}),` Click Edit to modify any text file directly in the browser. Click Save to write changes back to disk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Create File:`}),` Click the file+ icon in the toolbar. Enter a filename. The file is created inside the currently selected folder (or workspace root).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Create Folder:`}),` Click the folder+ icon. Enter a folder name. Nested paths are created automatically.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Rename:`}),` Select an item, click the edit icon. Enter the new name and confirm.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Delete:`}),` Select an item, click the trash icon. A confirmation dialog appears. Directories are deleted recursively including all contents.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Grid view:`}),` When a directory is selected, its contents are displayed as a clickable card grid with icons and sizes.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Info footer:`}),` Shows the full workspace path, total file count, directory count, and disk usage in MB.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Drag & drop upload:`}),` Drag files from your desktop onto the File Explorer to upload them. A blue overlay indicates the drop target. Multiple files supported simultaneously.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Upload button:`}),` Click the upload icon in the toolbar to open a native file picker for selecting files to upload into the current folder.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-amber-400`}),` 6 Agent Native Tools`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In Mission Mode, the Shogun and all Samurai agents have 6 workspace tools injected as native functions. The agent sees the workspace path in its system prompt and can use these tools autonomously:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_info`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Returns workspace path, whether access is enabled, total files, total directories, and total size in MB.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_list`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Lists files and directories at a given relative path. Returns name, type, size (for files), and child count (for dirs).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_read`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Reads a text file\\u2019s content (capped at 5 MB). Returns content, size, and path. Binary files return an error.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_write`}),` `,(0,Y.jsx)(`span`,{className:`text-yellow-400`,children:`(medium risk)`}),` \\u2014 Creates or overwrites a text file. Parent directories are auto-created. Returns action (created/overwritten) and size.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_mkdir`}),` `,(0,Y.jsx)(`span`,{className:`text-green-400`,children:`(low risk)`}),` \\u2014 Creates a subdirectory with parents. Returns action (created/already_exists).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`workspace_delete`}),` `,(0,Y.jsx)(`span`,{className:`text-red-400`,children:`(high risk)`}),` \\u2014 Deletes a single file. Cannot delete directories (safety constraint via agent tools; the UI can delete dirs).`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-amber-400`}),` Path Validation & Security`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`All workspace operations — both the File Explorer UI and agent native tools — enforce strict path validation at every level:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Boundary enforcement:`}),` Every path is resolved to its absolute form and checked that it remains inside the workspace root. Any escape attempt is blocked.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Traversal blocking:`}),` Paths containing `,(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`..`}),` are rejected immediately, before any filesystem operation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Absolute path blocking:`}),` Only relative paths (from workspace root) are accepted. Paths starting with `,(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`/`}),` or `,(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`\\`}),` are rejected.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`UNC path blocking:`}),` Network paths are rejected to prevent lateral movement.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Size guard:`}),` File reads are capped at 5 MB (agent tools) or 10 MB (File Explorer UI) to prevent memory exhaustion.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Root protection:`}),` The workspace root directory itself cannot be deleted.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-amber-400`}),` Security Posture Matrix`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The workspace is a binary gate: either fully available or completely locked.`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE:`}),` \\u274C Workspace completely disabled. No read, no write, no listing. All 6 tools return errors. File Explorer shows an error state with retry button.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`GUARDED:`}),` \\u2705 Full read/write access. All 6 agent tools available. File Explorer fully functional.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL:`}),` \\u2705 Full read/write access. All 6 agent tools available.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` \\u2705 Full read/write access. All 6 agent tools available.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN:`}),` \\u2705 Full read/write access. All 6 agent tools available.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-amber-400`}),` Office App Mode Alignment`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Workspace and Office App Mode share the same folder concept. The four “Approved Folders” in the Katana’s Office tab (input, output, templates, temp) can be left empty to auto-map to the workspace root directory. This means Office file operations and agent workspace tools operate in the same directory by default. Configure custom paths in the Katana → Office tab if you need separate boundaries for Office automation.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-amber-400`}),` REST API Endpoints`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The File Explorer UI uses a dedicated REST API under /api/v1/workspace/. These endpoints are also available for external integrations and custom tooling:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`GET /api/v1/workspace/info`}),` \\u2014 Metadata, path, and disk usage`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`GET /api/v1/workspace/tree`}),` \\u2014 Full recursive directory tree (JSON)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`GET /api/v1/workspace/read?path=`}),` \\u2014 Read file content as text`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`POST /api/v1/workspace/write`}),` \\u2014 Create or update file (JSON body: path, content)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`POST /api/v1/workspace/mkdir`}),` \\u2014 Create directory (JSON body: path)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`DELETE /api/v1/workspace/delete?path=`}),` \\u2014 Delete file or directory`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-card px-1 rounded`,children:`POST /api/v1/workspace/rename`}),` \\u2014 Rename/move (JSON body: old_path, new_path)`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-amber-400`}),` System Prompt Integration`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When workspace is enabled, the Shogun’s system prompt includes the workspace path and available tools in two places: the ACTIVE SECURITY POSTURE block (“Workspace: ENABLED — /path/to/workspace”) and the YOUR CAPABILITIES block (listing all 6 tools by name). This ensures the agent knows where to save files and which tools it can call. At SHRINE, the prompt shows “Workspace: DISABLED (SHRINE posture)”.`})]})]}),(0,Y.jsxs)(`section`,{id:`ref-torii`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(O,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Torii — Security Portal`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Select the active built-in tier or custom posture. Custom postures are created, edited, and deleted in ToolGate, then become available here immediately.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-red-400`}),` Security Posture (Left Column)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Five clickable tiers, from safest to most dangerous:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`SHRINE (MAX):`}),` Zero-trust. Local only. No external tools. Maximum safety.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`GUARDED:`}),` Restricted network. Only approved tools. Everything needs human approval.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`TACTICAL (DEFAULT):`}),` Balanced autonomy. The AI has scoped file access and can use approved tools on its own.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`CAMPAIGN:`}),` High autonomy. Broad internet access. Agents can auto-spawn without asking.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RONIN (UNSAFE):`}),` Unrestricted. Only use in completely isolated test environments.`]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed mt-2`,children:[`Click a built-in tier or custom posture to activate it. Built-in tiers are protected presets. Use `,(0,Y.jsx)(`strong`,{children:`Manage custom postures in ToolGate`}),` to create or maintain reusable postures, then return here to choose which one is active.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-red-400`}),` Unified Posture Selector`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Built-in tiers and every custom posture from ToolGate appear in the same selection grid. The active marker reflects the policy actually enforced at runtime. Selecting a built-in tier clears any previous custom assignment; selecting a custom posture activates that policy together with its inherited base tier.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-red-400`}),` Current Constraints`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The constraints panel summarizes the effective filesystem, network, shell, skills, delegation, communications, browser, and desktop limits. For a custom posture these values come from its base tier and ToolGate capability boundaries—not from whichever posture happened to be selected previously.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-red-500`}),` Harakiri Button`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The red button in the top right of the Torii page. Same as the one on the Dashboard — activates the global kill switch. Requires two-step confirmation. Once active, all agents are frozen and the posture locks to SHRINE. Press "Reset Harakiri" to restore normal operation.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-toolgate`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-orange-400/40 pb-3`,children:[(0,Y.jsx)(z,{className:`w-6 h-6 text-orange-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`ToolGate — Runtime Permissions`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The single place to create custom postures and configure or understand what security policies permit at runtime.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-orange-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-orange-400`}),` Ownership Model`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Torii`}),` selects the active built-in tier or custom posture. `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` owns custom posture creation, editing, deletion, capability ceilings, and per-call runtime authorization. `,(0,Y.jsx)(`strong`,{children:`Katana`}),` manages installed or connected capabilities, model providers and routing, and account-specific scopes. `,(0,Y.jsx)(`strong`,{children:`Shogun Profile`}),` owns identity, behavior, and operations—not security configuration. When centrally managed, `,(0,Y.jsx)(`strong`,{children:`Gensui owns ToolGate`}),` and the local view becomes read-only.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-orange-400`}),` Custom Posture Library`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Create, edit, and delete reusable custom postures in ToolGate. Each posture has a name, description, inherited base tier, kill-switch and dry-run flags, and detailed capability boundaries. New postures appear immediately in Torii, where activation is always an explicit separate choice. Deleting an active custom posture safely returns Torii to its base tier.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-orange-400`}),` Policy-Scoped Rules`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`ToolGate always follows the currently active policy. A built-in tier uses its own scope. A custom policy uses a stable policy-specific scope and inherits its base tier's default risk mode. Switching tiers or custom policies loads that scope's own capability boundaries, tool overrides, and advanced content rules.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-orange-400`}),` Capability Boundaries & Risk`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The capability panel explains the policy ceiling for filesystem, network, shell, skills, subagents, memory, communications, workflows, browser, visual intake, IDE, and related features. The `,(0,Y.jsx)(`strong`,{children:`Capability Risk Index`}),` summarizes exposure from 0–100. Built-in presets are read-only; assigned custom policies can be edited here.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(L,{className:`w-4 h-4 text-orange-400`}),` Effective Tool Policy`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every registered tool shows its effective `,(0,Y.jsx)(`strong`,{children:`ALLOW`}),`, `,(0,Y.jsx)(`strong`,{children:`CONFIRM`}),`, or `,(0,Y.jsx)(`strong`,{children:`BLOCK`}),` verdict, risk class, source, and reason. Local overrides may narrow a standalone policy. They cannot widen an enclosing capability boundary or a centrally enforced Gensui rule.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-orange-400`}),` Simulator, Approvals & Audit`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Use the simulator to preview a tool call with its actual parameters before running it. Calls that require confirmation enter the approval queue and fail closed on denial or timeout. Decisions preserve their policy source and are written to the compliance trail.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(le,{className:`w-4 h-4 text-orange-400`}),` Advanced Content Controls`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Turn on `,(0,Y.jsx)(`strong`,{children:`Advanced mode`}),` to flag specific words or phrases inside nested tool arguments. Each rule can match a phrase anywhere or as a whole word, be case-sensitive or case-insensitive, apply to every tool or one selected tool, and return `,(0,Y.jsx)(`strong`,{children:`CONFIRM`}),` or `,(0,Y.jsx)(`strong`,{children:`BLOCK`}),`. Advanced rules are scoped to the active tier or custom policy and can only tighten the final verdict. When Gensui manages the instance, the same rules are edited centrally and remain enforced from the cached policy during temporary outages.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-nexus`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-indigo-400/40 pb-3`,children:[(0,Y.jsx)(W,{className:`w-6 h-6 text-indigo-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Nexus — The Alliance`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Inter-agent collaboration. Work with other Shogun instances across the network.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-indigo-400`}),` Identity Card (Top)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Displays your Shogun's unique ID and public key. Other Shogun instances need this to verify your messages are authentic. Click the copy icon to put your agent ID on the clipboard for sharing.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(S,{className:`w-4 h-4 text-indigo-400`}),` Workspace List (Left Column)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A list of all Joint Workspaces you have created or joined. Each card shows the workspace name, topic, and number of peer agents connected. Click a workspace to open it. Hover over a card to see the `,(0,Y.jsx)(`strong`,{children:`delete button`}),` (red X in the corner). Deleting a workspace permanently removes it and all its messages.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-indigo-400`}),` "Create Workspace" Button`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Opens a form where you enter a `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`description`}),`, and `,(0,Y.jsx)(`strong`,{children:`topic`}),` for the new workspace. After creation, you can invite other Shogun agents by providing their network URL.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-indigo-400`}),` Invite Peers`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Inside a workspace detail view, click `,(0,Y.jsx)(`strong`,{children:`"Invite Peer"`}),`. Enter the `,(0,Y.jsx)(`strong`,{children:`endpoint URL`}),` of the other Shogun (e.g., http://192.168.1.50:8000) and optionally a display name. The system will contact the remote agent, exchange identity information, and add it to the workspace.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(A,{className:`w-4 h-4 text-indigo-400`}),` A2A Message Thread`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Inside a workspace, the right panel shows all messages exchanged between agents. Messages can be typed in the compose box at the bottom. Choose a `,(0,Y.jsx)(`strong`,{children:`message type`}),` from the dropdown: "update" for status reports, "proposal" for suggestions, "approval" for sign-offs, or "task" for actionable assignments. Messages are automatically signed with your agent's identity.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-indigo-400`}),` Shared Whiteboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Below the message thread, a full-width text editor where all agents in the workspace can collaboratively write plans, code, or reports. Click `,(0,Y.jsx)(`strong`,{children:`"Edit"`}),` to enter editing mode, make your changes, then click `,(0,Y.jsx)(`strong`,{children:`"Save"`}),` to publish them to all connected peers.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-nexus-gateway`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-indigo-400/40 pb-3`,children:[(0,Y.jsx)(D,{className:`w-6 h-6 text-indigo-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Nexus External Gateway`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Bidirectional interoperability with Microsoft 365, Salesforce, Google, and ServiceNow agents. Send and receive tasks through governed A2A channels.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-indigo-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-indigo-400`}),` What Is the External Gateway?`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Nexus External Gateway enables `,(0,Y.jsx)(`strong`,{children:`bidirectional`}),` communication between Shogun and enterprise AI agents. `,(0,Y.jsx)(`strong`,{children:`Inbound:`}),` external platforms (Microsoft 365 Copilot, Salesforce Einstein/Agentforce, Google Vertex AI, ServiceNow) send tasks into Shogun for execution. `,(0,Y.jsx)(`strong`,{children:`Outbound:`}),` Shogun can dispatch tasks `,(0,Y.jsx)(`em`,{children:`to`}),` external agents — e.g. ask Salesforce to update a CRM record, ask M365 to schedule a meeting, or trigger a ServiceNow workflow. Shogun acts as an independent execution and orchestration layer that works `,(0,Y.jsx)(`em`,{children:`alongside`}),` enterprise agents, not as a replacement. No vendor SDKs, no platform lock-in. Just standard HTTP + Bearer tokens.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:`Standalone Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Shogun runs independently with local agents, models, browser control, and memory. No external connectivity needed.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-indigo-400/40`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:`Enterprise-Connected Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`External agents submit tasks via A2A, webhooks, or MCP. Shogun executes and returns results.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-red-400/40`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-sm`,children:`Governed Hybrid Mode`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Both modes combined, with Gensui enforcing postures, platform allowlists, and real-time policy checks on every task.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-indigo-400`}),` Register an External Agent`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /api/v1/nexus/external/register-agent`}),` — Provide a `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`platform`}),` (e.g. microsoft_365, salesforce), optional `,(0,Y.jsx)(`strong`,{children:`endpoint_url`}),` (for outbound dispatch), and optional `,(0,Y.jsx)(`strong`,{children:`direction`}),` (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`inbound`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`outbound`}),`, or `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`bidirectional`}),`). Shogun returns a unique API token. Set `,(0,Y.jsx)(`strong`,{children:`endpoint_url`}),` to enable Shogun to dispatch tasks `,(0,Y.jsx)(`em`,{children:`to`}),` the external agent.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`w-4 h-4 text-indigo-400`}),` Discover Capabilities`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`GET /api/v1/nexus/capabilities`}),` — Returns the 9 default capabilities Shogun exposes (e.g. document.summarize, spreadsheet.analyze, email.draft) plus any custom-registered capabilities. External agents query this to know what they can ask for.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-indigo-400`}),` Submit a Task (A2A)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /api/v1/nexus/external/a2a/task`}),` — Send a JSON payload with the action, input context, source_agent_id, and source_platform. Shogun authenticates, policy-checks, routes to the best internal agent, executes via LLM, and returns the result.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-indigo-400`}),` Task Status & Callbacks`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`GET /external/task/id`}),` — Poll for task status (pending, executing, completed, blocked, failed). `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /external/task/id/callback`}),` — Receive async callback updates from remote systems.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-red-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-red-400`}),` Four-Layer Security Model`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every inbound task passes through four enforcement layers before execution:`}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 mt-2`,children:[(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Bearer Authentication`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Each registered agent has a unique token. Invalid tokens get an immediate 401.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Hardcoded Blocks`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`desktop.execute, ronin.stop, ronin.harakiri are permanently blocked for all external agents. No override possible.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Platform Allowlists`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Per-platform rules control which capabilities each platform can use. M365 can summarize docs but not touch local files.`})]}),(0,Y.jsxs)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Gensui Posture`}),(0,Y.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`When Gensui is active, its real-time posture can disable all Nexus communication, block browser/desktop sessions, or restrict file writes fleet-wide.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ie,{className:`w-4 h-4 text-indigo-400`}),` Audit Trail`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every gateway operation produces dual-logged audit events: `,(0,Y.jsx)(`strong`,{children:`Layer 1 (Operational)`}),` in the main SQLite database with 90-day retention, and `,(0,Y.jsx)(`strong`,{children:`Layer 2 (Immutable)`}),` in the HMAC-chained append-only database for NIS2/SOC2/EU AI Act compliance with 7-year retention.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-l-2 border-purple-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(_,{className:`w-4 h-4 text-purple-400`}),` Outbound Dispatch (Shogun → External Agent)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shogun can also `,(0,Y.jsx)(`strong`,{children:`send tasks to external agents`}),`. When an external agent has an `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`endpoint_url`}),` configured and its direction is `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`outbound`}),` or `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`bidirectional`}),`, Shogun can dispatch tasks to it.`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-purple-400/80 font-bold uppercase tracking-widest`,children:`API Endpoints`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1.5 ml-2 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`POST /api/v1/nexus/external/dispatch`}),` — Send a task to an external agent. Provide the `,(0,Y.jsx)(`strong`,{children:`agent_id`}),`, `,(0,Y.jsx)(`strong`,{children:`action`}),` (e.g. `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`crm.update_contact`}),`), and `,(0,Y.jsx)(`strong`,{children:`input_context`}),`. Shogun POSTs the payload to the agent's endpoint_url with the agent's token as a Bearer header.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`GET /api/v1/nexus/external/dispatchable-agents`}),` — List all agents that can receive outbound tasks (direction is outbound or bidirectional AND endpoint_url is set).`]})]})]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Use cases:`}),` Ask Salesforce to update a CRM record, ask M365 to schedule a meeting, trigger a ServiceNow incident workflow, send processed data back to Google Cloud. The external agent receives a JSON payload with the action, input context, and a task_id for tracking.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Direction field:`}),` `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`inbound`}),` = agent can only send tasks to Shogun. `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`outbound`}),` = Shogun can only send tasks to the agent. `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`bidirectional`}),` = both directions.`]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-gensui`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-indigo-400/40 pb-3`,children:[(0,Y.jsx)(L,{className:`w-6 h-6 text-indigo-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Gensui — Fleet Command`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Connect your Shogun to a centralized Gensui server for fleet management and security coordination.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-indigo-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(M,{className:`w-4 h-4 text-indigo-400`}),` What is Gensui?`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Gensui is a `,(0,Y.jsx)(`strong`,{children:`Central Command server`}),` that manages a fleet of Shogun instances. When connected, Gensui owns ToolGate for that instance: it pushes the active policy, capability boundaries, tool verdicts, and advanced content rules; receives telemetry; issues commands including remote Harakiri; and coordinates fleet operations. The Tenshu ToolGate remains visible for explanation but becomes read-only.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-indigo-400`}),` Connection Form (Not Connected)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When not connected, the page shows a setup form with four fields:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Server URL:`}),` The address of the Gensui server (e.g., http://localhost:8787). Click "Test Connection" to verify reachability before connecting.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Enrollment Token:`}),` A one-time token generated in the Gensui admin panel. Paste it here to auto-enroll this Shogun instance.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Instance Name:`}),` A human-readable name for this Shogun (displayed in the Gensui fleet dashboard).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Environment:`}),` Choose Development, Staging, or Production to tag this instance.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-green-400`}),` Status Dashboard (Connected)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Once connected, the page transforms into a live status dashboard showing:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Connection status:`}),` Green badge when actively connected, amber when enrolled but offline.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shogun ID:`}),` The unique identifier assigned during enrollment.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Last Sync:`}),` Timestamp of the most recent heartbeat or policy sync.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Disconnect button:`}),` Severs the fleet link with a confirmation modal.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-indigo-400`}),` Active Posture Card`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Displays the security policy pushed from Gensui. Capability boundaries, per-tool verdicts, and advanced word or phrase rules are configured together in the central `,(0,Y.jsx)(`strong`,{children:`Gensui ToolGate`}),`. They are enforced locally and override standalone ToolGate settings while the fleet relationship is active, including from the last valid cached policy when Gensui is temporarily unreachable.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-indigo-400`}),` Background Services`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When connected, four background tasks run automatically:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Heartbeat:`}),` Reports status to Gensui every 15 seconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Policy Sync:`}),` Fetches effective posture every 30 seconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Command Polling:`}),` Checks for pending commands (e.g., Harakiri) every 5 seconds.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Telemetry Push:`}),` Sends buffered events to Gensui every 10 seconds.`]})]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-logs`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-subdued/40 pb-3`,children:[(0,Y.jsx)(H,{className:`w-6 h-6 text-shogun-subdued`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Logs — The Compliance Dashboard`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`NIS2, SOC2, and EU AI Act-compliant event logging with full trace reconstruction and tamper-proof audit chain.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-shogun-blue`}),` Dual-Layer Architecture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every event is written to `,(0,Y.jsx)(`strong`,{children:`two independent stores`}),`: (1) an `,(0,Y.jsx)(`strong`,{children:`operational SQLite log`}),` (fast, searchable, 90-day retention) for day-to-day monitoring, and (2) a `,(0,Y.jsx)(`strong`,{children:`tamper-resistant HMAC-chained audit database`}),` (append-only, 7-year retention) for regulatory evidence. If anyone modifies or deletes an entry in the audit chain, the cryptographic hash chain breaks — and the dashboard flags it immediately.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-subdued`}),` Event Stream`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The main panel shows every event in chronological order. Each row displays: `,(0,Y.jsx)(`strong`,{children:`timestamp`}),`, `,(0,Y.jsx)(`strong`,{children:`category icon`}),`, `,(0,Y.jsx)(`strong`,{children:`severity badge`}),` (info/warn/error/critical), `,(0,Y.jsx)(`strong`,{children:`result status`}),` (green check for success, red X for denied), the `,(0,Y.jsx)(`strong`,{children:`action description`}),`, `,(0,Y.jsx)(`strong`,{children:`event type tag`}),` (e.g., DECISION.CONTEXT), the `,(0,Y.jsx)(`strong`,{children:`model used`}),`, `,(0,Y.jsx)(`strong`,{children:`tool invoked`}),`, and `,(0,Y.jsx)(`strong`,{children:`trace ID link`}),`. Click any event to expand its detail panel. Toggle between `,(0,Y.jsx)(`strong`,{children:`Live`}),` (auto-refresh every 5 seconds) and `,(0,Y.jsx)(`strong`,{children:`Paused`}),` modes.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ae,{className:`w-4 h-4 text-shogun-subdued`}),` Category Tabs`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Eleven filterable categories across the top, each with a real-time event count badge:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Decision:`}),` AI decision provenance — context assembled, influences tracked (EU AI Act). Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`decision.context`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`decision.influences`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Oversight:`}),` Human review — AI responses delivered for implicit oversight, emergency shutdowns. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`oversight.response_delivered`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`oversight.emergency_shutdown`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` Security tier warnings, denied tools, high-autonomy alerts. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`risk.tools_denied`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`risk.high_autonomy_mode`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Model:`}),` Model selection, LLM responses, API errors, fallback activations. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`model.selected`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`model.response`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`model.error`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Policy:`}),` ToolGate evaluations under the Torii-selected policy — effective allow, confirm, or block decisions, their policy source, and any matching advanced content rule. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`policy.evaluated`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Memory:`}),` Memory recall, search queries, write operations with retrieval provenance. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`memory.search`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`memory.write`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Tools:`}),` Tool/skill executions, arguments, and results. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`tool.executed`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Auth:`}),` Session tracking, security posture changes, API credential lifecycle, kill switch activations. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.session`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.posture_changed`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.credential_added`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`auth.kill_switch_activated`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Incident:`}),` Critical security events — model API failures, kill switch emergency actions, audit chain integrity violations. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`incident.model_api_error`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`incident.kill_switch`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`incident.chain_broken`}),`.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`System:`}),` Server lifecycle (startup/shutdown), governance configuration changes (Constitution/Mandate), backup and restore provenance. Events: `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.startup`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.shutdown`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.config_changed`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.backup_created`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`system.backup_restored`}),`.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-shogun-blue`}),` Trace Reconstruction`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every chat turn generates a `,(0,Y.jsx)(`strong`,{children:`trace_id`}),` (e.g., `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`trc_d5ae40fb`}),`) that links all events in that workflow — from policy evaluation through memory recall, model selection, tool execution, and decision provenance. Click any trace ID link to open the `,(0,Y.jsx)(`strong`,{children:`Trace Reconstruction modal`}),`, which displays every event in the chain as a numbered timeline. This allows full `,(0,Y.jsx)(`strong`,{children:`workflow reconstruction`}),` for incident investigation.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(ie,{className:`w-4 h-4 text-shogun-gold`}),` Event Detail Panel`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Click any event to expand a detail panel showing the full NIS2/SOC2 + EU AI Act record:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`WHO/WHAT/WHEN:`}),` User ID, agent, event type, timestamp.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`MODEL/PROVIDER:`}),` Which AI model and cloud provider handled the request.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`POLICY:`}),` Security policy reference, decision (allowed/denied), and reason.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`RISK/TRACE:`}),` Risk score and correlated trace ID.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`AI Confidence bar:`}),` Color-coded indicator (green ≥ 70%, yellow 40–70%, red < 40%).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Framework badges:`}),` Shows which compliance frameworks apply (SOC2, NIS2, EU_AI_ACT).`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Governance flags:`}),` Human oversight required, evidence completeness, risk level.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Detail payload:`}),` Full structured JSON of all event metadata.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-green-500`}),` Audit Chain Integrity`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The top-right corner shows a real-time `,(0,Y.jsx)(`strong`,{children:`Chain Intact`}),` indicator (green) or `,(0,Y.jsx)(`strong`,{children:`Chain Broken`}),` alert (red, pulsing). This verifies the HMAC-SHA256 hash chain across all immutable audit records. If the chain is intact, no records have been tampered with. The status bar at the bottom also shows "AUDIT: INTACT" or "BROKEN."`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-shogun-gold`}),` Compliance Export`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click the download icon to export the `,(0,Y.jsx)(`strong`,{children:`immutable audit log`}),` as a JSON file. This export pulls from the tamper-proof chain (not the operational log), making it suitable for regulatory auditors, compliance reviews, and incident investigations. The export includes all event metadata, governance flags, and chain hashes.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(U,{className:`w-4 h-4 text-red-400`}),` Clear Operational Logs`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click the trash icon to clear the `,(0,Y.jsx)(`strong`,{children:`operational log only`}),`. The immutable audit chain is `,(0,Y.jsx)(`strong`,{children:`never affected`}),` by this action — it is append-only and cannot be cleared. A confirmation dialog warns you before deletion. The clearing event itself is recorded in the immutable audit chain as evidence.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-maintenance`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-subdued/40 pb-3`,children:[(0,Y.jsx)(w,{className:`w-6 h-6 text-shogun-subdued`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Maintenance — Backups, Data & Updates`}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Found under the `,(0,Y.jsx)(`strong`,{children:`Maintenance`}),` section at the bottom of the sidebar.`]})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-gold/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-gold`}),` Scheduled Backups`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Navigate to `,(0,Y.jsx)(`strong`,{children:`Backups`}),` in the sidebar. Enable automatic backups with a configurable schedule (hourly to weekly). Set how many old backups to keep — older ones are automatically deleted. Backups include your database, configs, governance documents, and environment settings.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-shogun-blue`}),` Data Management Tab`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`On the `,(0,Y.jsx)(`strong`,{children:`Backups`}),` page, switch to the `,(0,Y.jsx)(`strong`,{children:`Data Management`}),` tab. Here you'll find a live System Snapshot (row counts per table, DB size), one-click export as a `,(0,Y.jsx)(`strong`,{children:`Safe JSON Bundle`}),` or `,(0,Y.jsx)(`strong`,{children:`Raw Database Swap`}),`, and an Import area to restore from a previous export.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-emerald-400`}),` System Updates`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Navigate to `,(0,Y.jsx)(`strong`,{children:`Updates`}),` in the sidebar. The automatic checker reads the repository's `,(0,Y.jsx)(`code`,{children:`version.json`}),` manifest, compares its numeric build with the installed build, and caches the result for 6 hours. `,(0,Y.jsx)(`strong`,{children:`Check for Updates`}),` forces a fresh check; an available release displays an `,(0,Y.jsx)(`strong`,{children:`UPDATE`}),` badge in the sidebar.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Click `,(0,Y.jsx)(`strong`,{children:`Install Update`}),` to download the current `,(0,Y.jsx)(`code`,{children:`main`}),` branch, replace application code, and rebuild the frontend while preserving your database, configurations, environment, and virtual environment. Restart Shogun when installation completes. Private repositories can use a locally encrypted GitHub token configured on the Updates page.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-amber-500/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-amber-400`}),` Restore & Recovery`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every backup in the list has a `,(0,Y.jsx)(`strong`,{children:`Restore`}),` button. Clicking it overwrites your current database and config files with the backup's contents. A restart is required afterwards. Use this to roll back after a bad config change, recover from corruption, or migrate to a new machine.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-flowstack`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-violet-400/40 pb-3`,children:[(0,Y.jsx)(E,{className:`w-6 h-6 text-violet-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Flow Stacking — Stack Orchestrator`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The governed runtime layer above Agent Flow — long-horizon execution with checkpoints, verification gates, retries, and artifact capture.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-violet-400`}),` What Is Flow Stacking?`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`While individual `,(0,Y.jsx)(`strong`,{children:`Agent Flows`}),` handle single-pipeline execution, `,(0,Y.jsx)(`strong`,{children:`Flow Stacking`}),` chains multiple flows into long-horizon execution pipelines. The `,(0,Y.jsx)(`strong`,{children:`Stack Orchestrator`}),` manages the entire lifecycle: planning, checkpointing, verification, retries, and artifact collection. Navigate to `,(0,Y.jsx)(`strong`,{children:`Flow Stack`}),` in the sidebar to access it.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(P,{className:`w-4 h-4 text-violet-400`}),` Three Operating Modes`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Goal-Driven:`}),` Describe what you want — the planner selects and sequences flows automatically. `,(0,Y.jsx)(`strong`,{children:`Selected Stack:`}),` Pick a specific Flow Stack to execute. `,(0,Y.jsx)(`strong`,{children:`Template:`}),` Instantiate from a reusable template.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(d,{className:`w-4 h-4 text-violet-400`}),` Verification Gates`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`After each step, independent quality checks run (deterministic + semantic model judging). If a step fails verification, the retry service categorizes the failure (permission, runtime, verification, tool/flow) and applies the configured retry policy.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-violet-400`}),` Durable Checkpoints`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Context summaries and state snapshots are saved after each step. If a run is paused or interrupted, it can be resumed from the last checkpoint — no lost progress. Use `,(0,Y.jsx)(`strong`,{children:`Pause`}),` and `,(0,Y.jsx)(`strong`,{children:`Resume`}),` buttons in the Flow Stack dashboard.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-violet-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(N,{className:`w-4 h-4 text-violet-400`}),` Artifact Capture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Outputs from each phase (files, reports, analysis results) are automatically captured and cataloged. View all artifacts for a run from the `,(0,Y.jsx)(`strong`,{children:`Artifacts`}),` tab in the execution detail view.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-violet-400`}),` Governed Permissions`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Flow Stacking is gated by six ToolGate capability boundaries: `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`agentflow_create`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`agentflow_execute`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`agentflow_autonomous`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`flowstack_create`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`flowstack_execute`}),`, and `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`flowstack_autonomous`}),`. The built-in policies require `,(0,Y.jsx)(`strong`,{children:`Tactical`}),` tier or above; a custom policy inherits a base tier and may narrow those permissions. Select the policy in `,(0,Y.jsx)(`strong`,{children:`Torii`}),`, then use `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` to understand its boundaries and whether execution is allowed, confirmed, or blocked.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`w-4 h-4 text-violet-400`}),` Agent Inspection & Editing`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shogun discovers stacks with `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`list_agent_flows`}),` and reads their complete phases, subflow mappings, nodes, edges, orchestrator configuration, and lifecycle state with `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`get_flow_stack`}),`. It can then use `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`create_flow_stack`}),`, `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`edit_flow_stack`}),`, or `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`delete_flow_stack`}),` under the active posture and Flow Stack permissions.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`For a standard Agent Flow, Shogun uses `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`get_agent_flow`}),` and prefers `,(0,Y.jsx)(`code`,{className:`text-violet-400`,children:`patch_agent_flow`}),` for targeted graph changes that preserve untouched nodes and edges. A direct operator instruction to edit a flow authorizes that targeted patch for the current turn; Shogun still has to inspect first, remain at Tactical posture or above, and obey the separate create, activate, execute, template, and delete permissions.`]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-visual-intake`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-cyan-400/40 pb-3`,children:[(0,Y.jsx)(v,{className:`w-6 h-6 text-cyan-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Visual Intake — Image Analysis`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Secure, source-neutral image upload, processing, and AI-powered vision analysis with full governance.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(te,{className:`w-4 h-4 text-cyan-400`}),` Upload & Process`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Upload images from chat, Telegram, email, or browser. Shogun normalizes them to WebP, generates 640×640 thumbnails, strips all EXIF metadata (GPS, camera info, timestamps) for privacy, and deduplicates via SHA-256 hashing. Supported formats: JPEG, PNG, WebP, static GIF (max 20 MB).`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(B,{className:`w-4 h-4 text-cyan-400`}),` AI Vision`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Describe:`}),` Generate natural language descriptions. `,(0,Y.jsx)(`strong`,{children:`Inspect:`}),` Deep inspection with custom prompts — ask specific questions about content. `,(0,Y.jsx)(`strong`,{children:`OCR:`}),` Extract text from screenshots, documents, and photos. `,(0,Y.jsx)(`strong`,{children:`Compare:`}),` Side-by-side comparison of two images with AI analysis.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-cyan-400`}),` 7 Permission Flags`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_image_intake`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_local_vision`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_cloud_vision`}),` (off — privacy-sensitive), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_ocr`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_attach_to_stack`}),` (on), `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_auto_memory`}),` (off — privacy-sensitive), and `,(0,Y.jsx)(`code`,{className:`text-cyan-400`,children:`allow_delete`}),` (on). These are policy-scoped capability boundaries in `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),`; there is no separate Visual Intake permission tab in Katana.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(D,{className:`w-4 h-4 text-cyan-400`}),` Stack Integration`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Pin important images to prevent retention expiry (default: 30 days). Attach images as artifacts to Stack Orchestrator runs for evidence trails. Images can be linked to chat sessions and messages for context tracking.`})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-ide-mode`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-emerald-400/40 pb-3`,children:[(0,Y.jsx)(j,{className:`w-6 h-6 text-emerald-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`IDE Mode — VS Code Integration`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Connect your VS Code editor via a governed WebSocket bridge for AI-assisted development.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card bg-amber-500/10 border-amber-500/30 border-l-4 border-l-amber-500`,children:[(0,Y.jsxs)(`h5`,{className:`text-sm font-bold text-amber-400 flex items-center gap-2 mb-3`,children:[(0,Y.jsx)(L,{className:`w-5 h-5`}),`Requires Campaign or Ronin Posture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`IDE Mode is exposed by Katana only when the active policy is based on Campaign or Ronin and its ToolGate capability boundary enables `,(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`ide_enabled`}),`. The WebSocket bridge only accepts connections from localhost (`,(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`127.0.0.1`}),` / `,(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`::1`}),`) — remote connections are rejected.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-emerald-400`}),` File Operations`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Read, create, list, search, and apply patches to files within approved workspaces. Every write creates an automatic SHA-256 snapshot for rollback. `,(0,Y.jsx)(`strong`,{children:`Protected files`}),` (`,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.env`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`*.pem`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`*.key`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`id_rsa*`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`credentials*`}),`) are always blocked.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-emerald-400`}),` Terminal & Git`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Run approved commands (allowlisted per posture: `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`pytest`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`python`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`npm`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`ruff`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`mypy`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`tsc`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`cargo`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`go`}),`). Git operations: status, diff, branch, create-branch, commit. `,(0,Y.jsx)(`strong`,{children:`Push is disabled by default`}),`; git mutations require Ronin + explicit approval.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-emerald-400`}),` Pairing System`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Pairing uses one-time `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`SHG-`}),` prefixed tokens with SHA-256 digest comparison and 10-minute expiry. Generate a token in the Katana IDE tab, enter it in VS Code, and the bridge connects. Revoke all pairings instantly from the dashboard.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-emerald-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-emerald-400`}),` Workspace Boundaries`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`All file operations are restricted to approved workspace paths. Path traversal is blocked. Symlinks that escape boundaries are rejected. Denied directories: `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.ssh`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.aws`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.azure`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.gnupg`}),`, `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`.kube`}),`. Emergency `,(0,Y.jsx)(`strong`,{children:`Kill Switch`}),` endpoint terminates all IDE connections instantly.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-emerald-400`}),` VS Code Extension`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Install the `,(0,Y.jsx)(`strong`,{children:`shogun-ide-bridge`}),` extension from `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`bridge/vscode/`}),`. Configure `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`shogun.bridgeUrl`}),` (default: `,(0,Y.jsx)(`code`,{className:`text-emerald-400`,children:`ws://127.0.0.1:8000/api/v1/ide/bridge`}),`). Commands: `,(0,Y.jsx)(`strong`,{children:`Shogun: Connect`}),`, `,(0,Y.jsx)(`strong`,{children:`Shogun: Disconnect`}),`, `,(0,Y.jsx)(`strong`,{children:`Shogun: Open Dashboard`}),`.`]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-model-router`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-blue-400/40 pb-3`,children:[(0,Y.jsx)(se,{className:`w-6 h-6 text-blue-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Model Router — Intelligent Model Selection`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Provider-agnostic, task-aware model selection with routing profiles, registry, and usage telemetry.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(f,{className:`w-4 h-4 text-blue-400`}),` How It Works`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Instead of hardcoding which model handles each request, the Model Router evaluates the `,(0,Y.jsx)(`strong`,{children:`task type`}),`, `,(0,Y.jsx)(`strong`,{children:`complexity`}),`, and your `,(0,Y.jsx)(`strong`,{children:`active routing profile`}),` to select the optimal model automatically. Navigate to `,(0,Y.jsx)(`strong`,{children:`Katana → Model Routing`}),` to configure profiles and view the model registry.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-blue-400`}),` 5 Routing Profiles`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-green-400 bg-green-400/10 px-2 py-0.5 rounded`,children:`ULTRA ECONOMY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Strongly prefers local models, minimizes API calls.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-emerald-400 bg-emerald-400/10 px-2 py-0.5 rounded`,children:`ECONOMY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Low-cost daily work, escalates only for complex tasks.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-blue-400 bg-blue-400/10 px-2 py-0.5 rounded`,children:`BALANCED`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Recommended balance of quality and cost. Default profile.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-amber-400 bg-amber-400/10 px-2 py-0.5 rounded`,children:`HIGH CAPABILITY`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Uses stronger models earlier in the complexity curve.`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-bold text-red-400 bg-red-400/10 px-2 py-0.5 rounded`,children:`PREMIUM`}),(0,Y.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:`Maximum quality, always picks the best available model.`})]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-blue-400`}),` Task Classification`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every request is classified into one of 20+ task types across 5 complexity tiers:`}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5 text-xs text-shogun-subdued`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-green-400`,children:`Simple:`}),` simple_chat, classification, extraction, memory_write`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-emerald-400`,children:`Moderate:`}),` summarization, browser_task, skill_selection`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-blue-400`,children:`Complex:`}),` planning, coding_plan, coding_edit, stack_planning`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-amber-400`,children:`Critical:`}),` complex_reasoning, test_failure_analysis, self_verification`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`strong`,{className:`text-cyan-400`,children:`Vision:`}),` visual_understanding, screenshot_analysis, photo_understanding`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-blue-400`}),` Model Registry`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every model available to Shogun is registered with its provider, capabilities, quality/cost/latency tiers, context window, and role tags. Test connections directly from the registry. Add cloud providers or local Ollama models.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-blue-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-blue-400`}),` Decision & Usage Logs`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every routing decision is persisted: which task type, complexity score, selected model, fallback model, and reason. Usage telemetry tracks input/output tokens, cost estimates, and latency. View summaries and per-stack breakdowns.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-cyan-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-cyan-400`}),` OpenClaw College Ecosystem Intelligence`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`In `,(0,Y.jsx)(`strong`,{children:`Updates`}),`, anonymous ecosystem benchmark sharing is enabled by default. The operator can opt out at any time. When enabled, Shogun sends only model/provider, coarse task type, success, bucketed tokens/latency/cost, local-versus-cloud, country code, Shogun version, and a weekly rotating anonymous installation hash.`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Never transmitted:`}),` prompts, outputs, files, error contents, agent names, credentials, or exact IP addresses. College publishes rankings only after at least 20 events from five anonymous installations and retains raw telemetry for 31 days.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-active-skills`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-amber-400/40 pb-3`,children:[(0,Y.jsx)(B,{className:`w-6 h-6 text-amber-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Active Skills & Trajectory Capture`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Runtime skill retrieval from the Dojo — automatic selection, context injection, outcome tracking, and improvement candidates.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(c,{className:`w-4 h-4 text-amber-400`}),` How Active Skills Work`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When a Shogun agent processes a request, the Active Skill system automatically `,(0,Y.jsx)(`strong`,{children:`retrieves`}),` relevant skills from the Dojo, `,(0,Y.jsx)(`strong`,{children:`gates`}),` them against the active ToolGate capability boundaries and exam requirements, `,(0,Y.jsx)(`strong`,{children:`injects`}),` skill content into the LLM context (advisory or context_block mode), and `,(0,Y.jsx)(`strong`,{children:`tracks`}),` the outcome (success, partial, failed, not_used, blocked). Torii selects the governing tier or custom policy; ToolGate applies its runtime rules. Skills are live during execution — not just catalog entries.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-amber-400`}),` Configuration`]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-bg rounded-lg p-3 space-y-1.5 text-xs text-shogun-subdued`,children:[(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_max_per_run`}),`: 5 — max skills per execution run`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_max_per_step`}),`: 3 — max skills per step`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_max_total_context_tokens`}),`: 2,500 — token budget`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_require_exam_pass`}),`: true — only use passed skills`]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{className:`text-amber-400`,children:`active_skill_preserve_during_compaction`}),`: true — keep during context compaction`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-amber-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(oe,{className:`w-4 h-4 text-amber-400`}),` Trajectory Capture`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every skill invocation generates a structured evidence trail: `,(0,Y.jsx)(`strong`,{children:`Candidate Retrievals`}),` (which skills were considered), `,(0,Y.jsx)(`strong`,{children:`Episodes`}),` (full lifecycle), `,(0,Y.jsx)(`strong`,{children:`Trajectories`}),` (outcome scoring), `,(0,Y.jsx)(`strong`,{children:`Tool Links`}),` (tools called during usage), `,(0,Y.jsx)(`strong`,{children:`Verification Links`}),` (how outcomes were verified), `,(0,Y.jsx)(`strong`,{children:`Outcome Scores`}),` (deterministic scoring), and `,(0,Y.jsx)(`strong`,{children:`Improvement Candidates`}),` (suggested fixes). All data is secret-redacted automatically.`]})]})]})]}),(0,Y.jsxs)(`section`,{id:`ref-skillopt`,className:`space-y-6 scroll-mt-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-fuchsia-400/40 pb-3`,children:[(0,Y.jsx)(l,{className:`w-6 h-6 text-fuchsia-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`SkillOpt — Automated Skill Optimization`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Data-driven skill improvement pipeline — version management, training runs, candidate generation, validation, and promotion.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(oe,{className:`w-4 h-4 text-fuchsia-400`}),` The Optimization Pipeline`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Usage Events`}),` are captured from Active Skill runs. A `,(0,Y.jsx)(`strong`,{children:`Training Run`}),` uses these to generate optimized `,(0,Y.jsx)(`strong`,{children:`Candidates`}),`. Each candidate is `,(0,Y.jsx)(`strong`,{children:`Validated`}),` against held-out tasks with safety checks and scoring. Successful candidates are `,(0,Y.jsx)(`strong`,{children:`Promoted`}),` to become the new active version; failing ones are `,(0,Y.jsx)(`strong`,{children:`Rejected`}),` with a reason.`]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-fuchsia-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-fuchsia-400`}),` Version Management`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every skill change creates an immutable version: version number, content hash, validation score, and status (`,(0,Y.jsx)(`code`,{className:`text-fuchsia-400`,children:`candidate`}),` → `,(0,Y.jsx)(`code`,{className:`text-fuchsia-400`,children:`active`}),` → `,(0,Y.jsx)(`code`,{className:`text-fuchsia-400`,children:`retired`}),`). Browse all versions for any skill from the SkillOpt tab in `,(0,Y.jsx)(`strong`,{children:`Katana`}),`. Compare candidate vs baseline content with the interactive diff viewer.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-fuchsia-400/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-fuchsia-400`}),` Katana Dashboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The SkillOpt tab in `,(0,Y.jsx)(`strong`,{children:`Katana`}),` provides real-time tracking of optimization runs, interactive diff viewer for candidates vs baseline, one-click promote/reject controls, and metrics for average improvement scores. Start training runs, view all skill versions, and monitor usage events.`]})]})]})]})]})]}),n===`architecture`&&(0,Y.jsxs)(`div`,{className:`space-y-16 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsxs)(`div`,{className:`text-center max-w-3xl mx-auto space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`text-3xl font-bold shogun-title`,children:`System Architecture`}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed`,children:`A deep-dive into how Shogun is built — the layers, protocols, and subsystems that make it work. Understanding the architecture helps you make better decisions about configuration, security, and scaling.`})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(E,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`System Topology`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The big picture — how all the pieces fit together.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(q,{className:`w-4 h-4 text-shogun-blue`}),` Three-Tier Design`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Shogun is built in three tiers: `,(0,Y.jsx)(`strong`,{children:`Presentation`}),` (the React-based UI you're looking at), `,(0,Y.jsx)(`strong`,{children:`Application`}),` (a FastAPI backend handling all business logic, routing, and orchestration), and `,(0,Y.jsx)(`strong`,{children:`Persistence`}),` (SQLite in desktop mode or PostgreSQL in Server mode, plus Qdrant for vector memory). Each tier is independent and communicates through governed APIs.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(M,{className:`w-4 h-4 text-shogun-blue`}),` Lattice Architecture`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Instead of one monolithic AI, Shogun uses a "Lattice" — a network of specialized sub-agents (Samurai) coordinated by a central Shogun agent. Work is distributed across the lattice based on agent roles and routing profiles. This makes the system resilient, parallelizable, and scalable.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-shogun-blue`}),` External Integrations`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The system connects outward to cloud AI providers (OpenAI, Anthropic, Gemini, Perplexity, OpenRouter) and local model servers (Ollama). It integrates with Telegram for mobile messaging, supports the A2A (Agent-to-Agent) protocol for cross-network collaboration via Nexus, automates web browsing via Mado (Playwright), connects to email servers (IMAP/SMTP), and syncs with calendar servers (CalDAV).`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-4 h-4 text-shogun-blue`}),` Desktop and Server Deployment`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Desktop mode runs Shogun, The Tenshu, SQLite, and local Qdrant directly on one computer. Server mode runs the application, PostgreSQL, and Qdrant as isolated Docker services with persistent volumes and automatic restarts. Both stay on hardware you control; Server mode is intended for continuous operation and Team-mode access through Telegram or Microsoft Teams.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(W,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Agent Hierarchy`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How intelligence is distributed across the network.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-shogun-gold`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-gold text-lg flex items-center gap-2`,children:[(0,Y.jsx)(p,{className:`w-5 h-5`}),` The Shogun`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The central coordinator. Receives user queries, decides how to respond, and can delegate sub-tasks to Samurai agents. Has its own personality, behavioral directives, and primary model. Think of the Shogun as the CEO — it makes strategic decisions and assigns work.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Configured in: Shogun Profile`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-shogun-blue`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-blue text-lg flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-5 h-5`}),` Samurai Agents`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Specialized sub-agents, each with a defined role (Researcher, Analyst, Developer, etc.). Samurai can run independently or be orchestrated by the Shogun. Each has its own routing profile, spawn policy, and task queue. Think of them as department heads — experts in their domain.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Managed in: Samurai Network`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-indigo-400`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-indigo-400 text-lg flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-5 h-5`}),` Peer Shoguns`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Other Shogun instances running on different machines. Connected via the Nexus collaboration module using the A2A Protocol. Peers exchange messages, share whiteboard content, and can coordinate on complex multi-agent tasks across network boundaries.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Connected via: Nexus`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-3 border-t-2 border-indigo-400 md:col-span-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-indigo-400 text-lg flex items-center gap-2`,children:[(0,Y.jsx)(L,{className:`w-5 h-5`}),` Gensui (Fleet Command)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`An optional Central Command server that sits above multiple Shogun instances. When connected, Gensui owns ToolGate for the managed fleet: it pushes policy scopes, capability boundaries, per-tool verdicts, and advanced content rules; monitors telemetry; issues commands including remote Harakiri; and coordinates fleet-wide policy. Each Shogun maintains heartbeats, policy sync, command polling, and a last-known-good policy cache for fail-closed continuity.`}),(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest bg-shogun-bg p-2 rounded border border-shogun-border`,children:`Connected via: Alliance → Gensui`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(h,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`The Memory Tier`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How the system stores, retrieves, and manages knowledge.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(I,{className:`w-4 h-4 text-shogun-gold`}),` Vector Memory (Qdrant)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Memories are converted into numerical vectors (embeddings) and stored in a Qdrant vector database. This enables `,(0,Y.jsx)(`strong`,{children:`semantic search`}),` — you can search by meaning, not just keywords. When the AI responds to a query, it automatically retrieves the most relevant memories from this layer and includes them in context.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(h,{className:`w-4 h-4 text-shogun-gold`}),` Structured Storage`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Agents, providers, routing profiles, governance documents, chat history, certifications, team identities, and security policies use SQLite (`,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`shogun.db`}),`) in desktop mode and PostgreSQL in Server mode. This database is the source of truth for everything except vector embeddings.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(E,{className:`w-4 h-4 text-shogun-gold`}),` Memory Types`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Memories are categorized into five types: `,(0,Y.jsx)(`strong`,{children:`Semantic`}),` (facts and knowledge), `,(0,Y.jsx)(`strong`,{children:`Episodic`}),` (events and experiences), `,(0,Y.jsx)(`strong`,{children:`Procedural`}),` (instructions and workflows), `,(0,Y.jsx)(`strong`,{children:`Persona`}),` (identity, preferences, and personal information), and `,(0,Y.jsx)(`strong`,{children:`Skills`}),` (learned capabilities from the Dojo). Each type has different retrieval priorities and consolidation rules. The type influences how aggressively the memory fades over time.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(V,{className:`w-4 h-4 text-shogun-gold`}),` Salience & Decay`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every memory has a salience score (0.0–1.0). Frequently accessed memories rise in salience; unused ones decay naturally. The Bushido reflection engine periodically reviews memories and consolidates low-salience ones. You can `,(0,Y.jsx)(`strong`,{children:`pin`}),` critical memories to prevent decay entirely.`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(A,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Communication Protocol`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How agents talk to each other and to you.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(A,{className:`w-4 h-4 text-shogun-blue`}),` User → Shogun (REST + SSE)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When you type a message in Comms, it is sent as an HTTP POST to the backend. The response is streamed back via `,(0,Y.jsx)(`strong`,{children:`Server-Sent Events (SSE)`}),` — the tokens appear one at a time in real-time. This is what creates the "typing" effect you see as the AI responds.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-blue`}),` Shogun → Samurai (Internal Dispatch)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Shogun delegates tasks to Samurai agents via an internal dispatch queue. Each delegation includes the task description, priority level, and context from the conversation. The Samurai processes the task independently and reports results back.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(C,{className:`w-4 h-4 text-indigo-400`}),` Shogun → Peers (A2A Protocol)`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Inter-Shogun communication uses the `,(0,Y.jsx)(`strong`,{children:`Agent-to-Agent (A2A)`}),` protocol over HTTP. Messages are typed (update, proposal, approval, task) and cryptographically signed with the sender's identity keys. Each peer validates signatures before accepting messages.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-blue`}),` Shogun → AI Providers (LLM Calls)`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The routing engine selects a model based on the active routing profile (or uses the default primary model). The request is sent to the chosen provider's API (OpenAI, Anthropic, etc.) with the assembled prompt (user message + system prompt + memory context + constitution). Streaming responses are relayed back to the frontend.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(O,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Security Layer`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Defense-in-depth architecture that protects every agent action.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-red-400`}),` Tiered Posture System`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Five built-in security tiers (SHRINE → GUARDED → TACTICAL → CAMPAIGN → RONIN), plus custom policies based on those tiers, define the capability ceiling. Torii selects the active tier or policy; ToolGate displays and enforces its filesystem, network, shell, tools, workflow, memory, and delegation rules.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-red-400`}),` Kaizen Constitution Validator`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every proposed agent action is validated against the Constitution (written in Kaizen). If an action violates any constitutional rule, it is blocked before execution. The validation happens server-side, so agents cannot bypass it. Rules are evaluated by priority (critical rules are checked first).`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4 text-red-400`}),` Harakiri Kill Switch`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`A global emergency mechanism. When activated, `,(0,Y.jsx)(`strong`,{children:`all`}),` agent activity is instantly frozen, the posture locks to SHRINE (maximum protection), and a prominent red banner appears system-wide. Requires a two-step confirmation to activate and a deliberate reset to restore normal operations.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-red-400`}),` Identity & Signing`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Each Shogun instance has a unique ID and cryptographic key pair. All A2A messages are signed, ensuring peers can verify authenticity. API keys for external providers are stored encrypted in the database and never exposed in the frontend.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(p,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Intelligence Pipeline`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The journey of a message from input to output.`})]})]}),(0,Y.jsx)(`div`,{className:`space-y-4`,children:[{step:1,title:`User Input`,desc:`You type a message in the Comms chat interface. The message is sent to the backend via HTTP POST.`,color:`text-shogun-blue`,icon:A},{step:2,title:`Routing Decision`,desc:`The routing engine checks the active routing profile for matching task rules. If a rule matches (e.g., "research" → Perplexity), that model is used. Otherwise, the primary model is selected.`,color:`text-shogun-blue`,icon:S},{step:3,title:`Context Assembly`,desc:`The system assembles the full prompt: system instructions + Mandate (from Kaizen) + relevant memories (from Archives, via semantic search) + current conversation history + constitutional rules.`,color:`text-shogun-gold`,icon:E},{step:4,title:`Security Validation`,desc:`The assembled request is checked against the active ToolGate policy and constitutional rules. Capability boundaries, tool verdicts, parameters, and advanced content rules can require confirmation or block execution.`,color:`text-red-400`,icon:R},{step:5,title:`LLM Invocation`,desc:`The validated prompt is sent to the selected AI model's API. The response streams back token-by-token via SSE.`,color:`text-shogun-blue`,icon:p},{step:6,title:`Memory Inscription`,desc:`After the response completes, key information from the exchange may be automatically stored as new memories in the Archives, increasing the AI's knowledge for future queries.`,color:`text-shogun-gold`,icon:h}].map(e=>(0,Y.jsxs)(`div`,{className:`shogun-card flex gap-5 items-start`,children:[(0,Y.jsx)(`div`,{className:`flex flex-col items-center gap-2 shrink-0`,children:(0,Y.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-shogun-bg border border-shogun-border flex items-center justify-center font-bold text-lg ${e.color}`,children:e.step})}),(0,Y.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(e.icon,{className:`w-4 h-4 ${e.color}`}),e.title]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.desc})]})]},e.step))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(F,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Self-Improvement Loop (Bushido)`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`How the system continuously optimizes itself.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-gold`}),` Reflection Cycles`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The Bushido engine periodically analyzes recent interactions to evaluate model performance, memory utilization, and agent effectiveness. It looks for patterns — which models are faster, which memories are frequently retrieved, which agents are underperforming — and generates actionable insights.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(s,{className:`w-4 h-4 text-shogun-gold`}),` Memory Consolidation`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Low-salience episodic memories are periodically transformed into compact semantic summaries. This prevents the memory store from growing indefinitely while preserving the knowledge within. The consolidation rate is configurable via the Bushido calibration controls.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(f,{className:`w-4 h-4 text-shogun-gold`}),` Exploration vs. Exploitation`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`The "Exploration Variance" parameter controls how much the system deviates from proven strategies. Low variance means the AI sticks to what works; high variance means it experiments with new approaches. This is the classic explore-exploit tradeoff, tunable in Bushido.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-gold`}),` Formal Verification`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`All behavioral optimizations proposed by the Bushido engine are verified against the Kaizen constitution before being applied. This ensures that self-improvement never violates the fundamental laws defined by the operator. The system cannot "optimize its way" past your rules.`})]})]})]})]}),n===`safety`&&(0,Y.jsxs)(`div`,{className:`space-y-16 animate-in slide-in-from-bottom-4`,children:[(0,Y.jsxs)(`div`,{className:`text-center max-w-3xl mx-auto space-y-4`,children:[(0,Y.jsx)(`h3`,{className:`text-3xl font-bold shogun-title`,children:`Safety & Security Protocols`}),(0,Y.jsx)(`p`,{className:`text-shogun-subdued leading-relaxed`,children:`Shogun is built with a defense-in-depth security model. Multiple independent layers work together to ensure that no single failure can compromise the system. This page explains every safety mechanism in detail.`})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(R,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Security Philosophy`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The principles that govern every safety decision in Shogun.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-t-2 border-red-400`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-lg`,children:`Defense in Depth`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`No single layer is trusted alone. Security is selected at the posture and policy level in Torii, configured and enforced at runtime in ToolGate, constrained constitutionally in Kaizen, and validated again at action execution. An attacker would need to bypass all of these layers simultaneously.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-t-2 border-orange-400`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-lg`,children:`Least Privilege`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Agents receive only the minimum permissions needed for their tasks. Filesystem access, shell execution, delegation, and other capabilities must fit inside the active ToolGate boundary; per-tool and advanced content rules may further tighten execution but cannot widen that ceiling.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-t-2 border-shogun-gold`,children:[(0,Y.jsx)(`div`,{className:`font-bold text-shogun-text text-lg`,children:`Fail Closed`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`When in doubt, the system blocks rather than allows. If a constitutional rule is ambiguous, the action is denied. If the security posture cannot be verified, the system defaults to SHRINE (maximum protection). The Harakiri kill switch ensures instant lockdown in emergencies.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(O,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`The Five Security Tiers`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Each tier represents a different balance between safety and autonomy. Choose based on your environment and risk tolerance.`})]})]}),(0,Y.jsx)(`div`,{className:`space-y-4`,children:[{tier:`SHRINE`,subtitle:`Maximum Protection`,color:`border-green-500 bg-green-500/5`,badge:`text-green-500 bg-green-500/10 border-green-500/30`,desc:`Zero-trust mode. All external connections are blocked. Agents can only process information locally with no filesystem, network, or shell access. No sub-agent spawning. Every action requires explicit human approval. Use this when you suspect a breach, while auditing, or when running highly sensitive operations.`,perms:[`Filesystem: None`,`Network: None (local only)`,`Shell: Blocked`,`Sub-agents: Blocked`,`Tools: Disabled`,`Mail: Disabled`,`Calendar: Disabled`,`Cron: Disabled`,`Mado Browser: Disabled`,`Human approval: Everything`]},{tier:`GUARDED`,subtitle:`Restricted Operations`,color:`border-blue-500 bg-blue-500/5`,badge:`text-blue-500 bg-blue-500/10 border-blue-500/30`,desc:`Highly restricted. Filesystem access limited to approved directories only. Network restricted to approved endpoints. All tool usage requires human confirmation. Sub-agents limited to 2 maximum. Suitable for production environments where safety takes priority over speed.`,perms:[`Filesystem: Allowlist only`,`Network: Approved endpoints only`,`Shell: Blocked`,`Sub-agents: Max 2 (manual)`,`Tools: With approval`,`Mail: Read only`,`Calendar: Read only`,`Cron: View only`,`Mado Browser: Enabled (1 session)`,`Human approval: Most actions`]},{tier:`TACTICAL`,subtitle:`Balanced (Default)`,color:`border-shogun-gold bg-shogun-gold/5`,badge:`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`,desc:`The recommended default. Agents have scoped file access (read and write within designated directories), can use approved tools autonomously, and have filtered network access. Shell commands are still blocked. Up to 5 sub-agents can be spawned. A good balance between productivity and safety.`,perms:[`Filesystem: Scoped read/write`,`Network: Filtered (allowlist)`,`Shell: Blocked`,`Sub-agents: Max 5 (manual)`,`Tools: Approved auto-allowed`,`Mail: Read & Send`,`Calendar: Full access`,`Cron: Full access`,`Mado Browser: Headless only`,`Human approval: Dangerous only`]},{tier:`CAMPAIGN`,subtitle:`High Autonomy`,color:`border-orange-500 bg-orange-500/5`,badge:`text-orange-500 bg-orange-500/10 border-orange-500/30`,desc:`Extended autonomy for advanced users. Broad filesystem access. Full internet access. Shell commands allowed with logging. Sub-agents can auto-spawn based on policies. Only use this in controlled environments where you have monitoring in place and trust the AI models you are running.`,perms:[`Filesystem: Broad access`,`Network: Full internet`,`Shell: Allowed (logged)`,`Sub-agents: Auto-spawn enabled`,`Tools: All enabled`,`Mail: Read & Send`,`Calendar: Full access`,`Cron: Full access`,`Mado Browser: Enabled`,`Human approval: Critical only`]},{tier:`RONIN`,subtitle:`⚠ Unrestricted`,color:`border-red-500 bg-red-500/5`,badge:`text-red-500 bg-red-500/10 border-red-500/30`,desc:`No restrictions whatsoever. Full filesystem, network, shell, and tool access with zero oversight. ONLY use this in completely isolated sandbox/test environments with no access to production data, external services, or sensitive information. This tier exists for testing and development purposes only.`,perms:[`Filesystem: Unrestricted`,`Network: Unrestricted`,`Shell: Unrestricted`,`Sub-agents: Unrestricted`,`Tools: All enabled`,`Mail: Unrestricted`,`Calendar: Unrestricted`,`Cron: Full access`,`Mado Browser: Autonomous`,`Human approval: None`]}].map(e=>(0,Y.jsx)(`div`,{className:`shogun-card border-l-4 ${e.color}`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-start gap-4`,children:[(0,Y.jsxs)(`div`,{className:`md:w-1/3 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-bold uppercase px-2 py-1 rounded border ${e.badge}`,children:e.tier}),(0,Y.jsx)(`span`,{className:`text-sm font-bold text-shogun-text`,children:e.subtitle})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e.desc})]}),(0,Y.jsx)(`div`,{className:`md:w-2/3 grid grid-cols-2 md:grid-cols-5 gap-2`,children:e.perms.map((e,t)=>{let[n,r]=e.split(`: `);return(0,Y.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border rounded-lg p-2`,children:[(0,Y.jsx)(`div`,{className:`text-[9px] text-shogun-subdued uppercase font-bold tracking-widest`,children:n}),(0,Y.jsx)(`div`,{className:`text-[10px] text-shogun-text font-bold mt-0.5`,children:r})]},t)})})]})},e.tier))})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-gold/40 pb-3`,children:[(0,Y.jsx)(b,{className:`w-6 h-6 text-shogun-gold`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Constitutional Guardrails`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The AI's inviolable laws — written by you, enforced by the system.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(b,{className:`w-4 h-4 text-shogun-gold`}),` How It Works`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Constitution is a YAML document written in the Kaizen page. Each rule has a `,(0,Y.jsx)(`strong`,{children:`name`}),`, `,(0,Y.jsx)(`strong`,{children:`description`}),`, `,(0,Y.jsx)(`strong`,{children:`priority level`}),` (critical, high, balanced, medium, low), and `,(0,Y.jsx)(`strong`,{children:`enforcement mode`}),`. Before any agent action is executed, the system checks it against every constitutional rule in priority order. Critical rules are checked first.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-gold`}),` Enforcement Modes`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Rules can be set to different enforcement modes: `,(0,Y.jsx)(`strong`,{children:`Block`}),` (action is stopped entirely), `,(0,Y.jsx)(`strong`,{children:`Warn`}),` (action proceeds but a warning is logged), or `,(0,Y.jsx)(`strong`,{children:`Audit`}),` (action proceeds silently, logged for later review). Critical safety rules should always use "Block" mode.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(F,{className:`w-4 h-4 text-shogun-gold`}),` Revision History`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Every time you publish the Constitution, a new revision is saved. You can review all past versions in the Kaizen sidebar. This creates an immutable audit trail — you can always see who changed what and when. Useful for compliance and debugging unexpected behavior.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-gold`}),` The Mandate`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`In addition to the Constitution (hard rules), the Mandate (Kaizen → Mandate tab) injects soft directives into every AI conversation. While the Constitution blocks actions, the Mandate shapes behavior — tone, language, priorities, and focus areas. Both work together to align the AI with your intentions.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-orange-400/40 pb-3`,children:[(0,Y.jsx)(z,{className:`w-6 h-6 text-orange-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`ToolGate — Runtime Tool Enforcement`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The policy-aware control surface and enforcement engine for capability ceilings, risk, confirmations, overrides, and parameter-sensitive runtime decisions.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(z,{className:`w-4 h-4 text-orange-400`}),` How It Works`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Torii`}),` selects the built-in tier or custom policy. `,(0,Y.jsx)(`strong`,{children:`ToolGate`}),` loads that policy's stable scope, displays its capability ceiling, and intercepts every native tool call before execution. It combines the inherited risk mode, capability boundary, parameter analysis, per-tool override, and advanced content rules into one effective `,(0,Y.jsx)(`strong`,{children:`ALLOW`}),`, `,(0,Y.jsx)(`strong`,{children:`CONFIRM`}),`, or `,(0,Y.jsx)(`strong`,{children:`BLOCK`}),` verdict.`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Katana controls whether a tool is installed or connected, while PostureGuard controls which tools are visible to the agent. ToolGate remains the final runtime authorization layer even for visible, connected tools. A connected email tool can therefore be available in Katana but still require confirmation or be blocked by ToolGate.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4 text-red-400`}),` Risk Classification`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every native tool is classified with a `,(0,Y.jsx)(`strong`,{children:`risk score`}),` from 0.0 (harmless) to 1.0 (critical). The classification is based on four risk dimensions:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Data exfiltration:`}),` Can this tool send data outside the system? (send_email, external API calls)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Destructive mutation:`}),` Can this tool permanently alter or delete data? (file write, database operations)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Autonomy escalation:`}),` Can this tool spawn new processes or grant itself more power? (spawn_samurai, create_cron_job)`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Physical world impact:`}),` Can this tool affect the real world? (desktop_click, desktop_type, send_email)`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-shogun-gold`}),` Tier-Based Thresholds`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Each built-in tier defines the baseline thresholds for its ToolGate scope. A custom policy inherits the default risk mode of its base tier while keeping its own capability boundaries, tool overrides, and advanced rules:`}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Confirm threshold:`}),` Tools with risk scores above this require human confirmation before executing.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Block threshold:`}),` Tools with risk scores above this are blocked entirely — no amount of confirmation can override.`]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`A policy override or parameter/content rule may tighten that baseline, but it cannot widen a blocked capability boundary or a centrally managed Gensui rule.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4 text-shogun-gold`}),` Parameter-Aware Analysis`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`ToolGate doesn't just check the tool name — it inspects the actual parameters. The `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`check_tool_access`}),` function analyzes:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Target paths:`}),` File operations targeting system directories get elevated risk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Email recipients:`}),` External domains may trigger higher scrutiny than internal ones.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Cron schedules:`}),` Very frequent schedules (every minute) are flagged as higher risk.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Shell commands:`}),` Commands containing `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`rm`}),`, `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`sudo`}),`, or pipe chains get elevated risk.`]})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-blue`}),` Dual-Path Enforcement`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`ToolGate enforces on `,(0,Y.jsx)(`strong`,{children:`both`}),` tool execution paths in the system:`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-1 ml-4 list-disc`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Structured mode:`}),` When the AI uses JSON-formatted tool calls (standard mode), ToolGate intercepts in the structured execution pipeline before `,(0,Y.jsx)(`code`,{className:`bg-shogun-bg px-1 py-0.5 rounded text-shogun-text`,children:`execute_native_tool`}),` is called.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Text mode:`}),` When the AI uses text-based tool invocation (fallback mode), ToolGate intercepts in the text-mode extraction pipeline before the tool function is dispatched.`]})]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`This ensures no tool call can bypass ToolGate regardless of the AI model's response format.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 md:col-span-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(a,{className:`w-4 h-4 text-shogun-blue`}),` Audit Trail`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every ToolGate decision is logged with its provenance: tool name, parameters, computed risk, active policy scope and base tier, decision, source, reason, and any matching advanced content rule. Blocked and confirmed events appear in the `,(0,Y.jsx)(`strong`,{children:`Risk`}),` and `,(0,Y.jsx)(`strong`,{children:`Policy`}),` views of Logs. These entries are dual-written to both Layer 1 (operational, 90-day retention) and Layer 2 (immutable HMAC chain, 7-year retention).`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-500/40 pb-3`,children:[(0,Y.jsx)(u,{className:`w-6 h-6 text-red-500`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Harakiri — Emergency Protocol`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The nuclear option. When everything else fails, this stops the world.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card border-l-4 border-red-500 bg-red-500/[0.02] space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(G,{className:`w-4 h-4`}),` What Happens When Activated`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`All agent activity is immediately frozen.`}),` Running tasks are interrupted mid-execution. No new tasks can be started.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Security posture locks to SHRINE`}),` (maximum protection). Filesystem, network, shell, and tool access are all revoked.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`A pulsing red banner appears`}),` at the top of every page in the system, alerting all users that the kill switch is active.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`A critical log entry is created`}),` with the timestamp and reason for activation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`External connections are severed.`}),` Telegram bot, Nexus peers, and outgoing API calls are all paused.`]})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(O,{className:`w-4 h-4 text-red-400`}),` Activation & Recovery`]}),(0,Y.jsxs)(`ul`,{className:`text-xs text-shogun-subdued space-y-2 ml-4 list-disc leading-relaxed`,children:[(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Two-step confirmation:`}),` You must click the Harakiri button, then confirm in a modal dialog. This prevents accidental activation.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`Available from two locations:`}),` The Dashboard (Tenshu) and the Security Portal (Torii). Both trigger the same global mechanism.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`To recover:`}),` Click "Reset Harakiri" on the banner or from the Torii page. The posture returns to TACTICAL (the safe default). You must then manually re-enable any higher postures if desired.`]}),(0,Y.jsxs)(`li`,{children:[(0,Y.jsx)(`strong`,{children:`No data is lost.`}),` Harakiri only freezes operations — it does not delete or modify any data, memories, agents, or settings.`]})]})]})]}),(0,Y.jsxs)(`div`,{className:`bg-[#0a0505] border border-red-500/20 p-4 rounded-xl`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] text-red-500 font-bold uppercase tracking-widest mb-2`,children:`When to Use Harakiri`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Use the kill switch when: you observe unexpected or harmful agent behavior, you suspect your API keys have been compromised, an agent is consuming excessive resources, or you need to perform a security audit. When in doubt, press the button — it's always better to freeze and investigate than to let a problem escalate.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-shogun-blue/40 pb-3`,children:[(0,Y.jsx)(O,{className:`w-6 h-6 text-shogun-blue`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Operational Security Best Practices`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Recommended practices for maintaining a secure Shogun deployment.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(T,{className:`w-4 h-4 text-shogun-blue`}),` Rotate API Keys Regularly`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`API keys for AI providers should be rotated periodically. If you suspect a key has been exposed, revoke it immediately from the provider's dashboard and update it in Katana → Cloud Providers.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(H,{className:`w-4 h-4 text-shogun-blue`}),` Use the Compliance Dashboard`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`The Logs page is your compliance nerve center. Make it a habit to check the `,(0,Y.jsx)(`strong`,{children:`Decision`}),` tab to review AI reasoning provenance, the `,(0,Y.jsx)(`strong`,{children:`Risk`}),` tab for security tier warnings and denied tools, the `,(0,Y.jsx)(`strong`,{children:`Oversight`}),` tab for human review actions, the `,(0,Y.jsx)(`strong`,{children:`Incident`}),` tab for critical alerts (model API failures, kill switch activations, chain integrity violations), and the `,(0,Y.jsx)(`strong`,{children:`System`}),` tab for server lifecycle and governance config changes. Verify the audit chain stays intact. Export the immutable audit log regularly for off-site archival — this is your evidence for NIS2, SOC2, and EU AI Act compliance.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-shogun-blue`}),` Test Posture Changes in SHRINE`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Before upgrading to a higher security posture (e.g., TACTICAL → CAMPAIGN), test your constitutional rules in SHRINE mode first. This ensures your guardrails are properly configured before giving agents more freedom.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(M,{className:`w-4 h-4 text-shogun-blue`}),` Isolate RONIN Environments`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`If you need RONIN (unrestricted) mode for testing, run it on an isolated machine or VM with no access to production data, credential stores, or external services. Never run RONIN on a machine connected to your main network.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(g,{className:`w-4 h-4 text-shogun-blue`}),` Backup Before Major Changes`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Before changing the security posture, modifying the Constitution, or deploying new agents, export a backup via the Data Management tab. This gives you a restore point if something goes wrong.`})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2 border-l-2 border-shogun-blue/40`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(W,{className:`w-4 h-4 text-shogun-blue`}),` Limit Nexus Peer Access`]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:`Only invite trusted Shogun instances as peers in Nexus. Every peer can send messages and propose tasks. Verify the identity of remote agents before accepting workspace invitations. Remove inactive or unknown peers promptly.`})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-amber-500/40 pb-3`,children:[(0,Y.jsx)(L,{className:`w-6 h-6 text-amber-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`ToolGate — Runtime Tool Enforcement`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`The runtime behavior of the ToolGate policy selected in Torii, including local and centrally managed operation.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`ToolGate sits between PostureGuard (which determines `,(0,Y.jsx)(`em`,{children:`which tools are visible`}),`) and the executor that runs them. It provides policy-scoped, per-call enforcement based on capability boundaries, risk mode, tool overrides, parameter analysis, and advanced word or phrase rules. In standalone Tenshu it is editable locally; while connected to Gensui, the local ToolGate is read-only and the last valid centrally managed policy remains enforced during temporary outages.`]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,Y.jsxs)(`div`,{className:`bg-emerald-500/5 border border-emerald-500/20 rounded-lg p-3 space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-emerald-400 uppercase tracking-wider`,children:`ALLOW`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Low-risk tools (browse, fetch, list) execute immediately with no interruption.`})]}),(0,Y.jsxs)(`div`,{className:`bg-amber-500/5 border border-amber-500/20 rounded-lg p-3 space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-amber-400 uppercase tracking-wider`,children:`CONFIRM`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`High-risk tools (send email, desktop control) pause and show a confirmation card in the chat. You must click Approve or Deny before execution proceeds.`})]}),(0,Y.jsxs)(`div`,{className:`bg-red-500/5 border border-red-500/20 rounded-lg p-3 space-y-1`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-red-400 uppercase tracking-wider`,children:`BLOCK`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Critical-risk or destructive patterns are blocked outright. The tool receives a "blocked" response, and the AI must find an alternative approach.`})]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4 text-amber-400`}),` Risk Classification`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Every tool in the registry is assigned a risk level: `,(0,Y.jsx)(`strong`,{className:`text-emerald-400`,children:`LOW`}),` (read-only, no side effects), `,(0,Y.jsx)(`strong`,{className:`text-amber-400`,children:`MEDIUM`}),` (creates/modifies internal state), `,(0,Y.jsx)(`strong`,{className:`text-orange-400`,children:`HIGH`}),` (external side effects or control actions), or `,(0,Y.jsx)(`strong`,{className:`text-red-400`,children:`CRITICAL`}),` (destructive or irreversible). The Mode × Risk threshold matrix determines the default action for each combination.`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(L,{className:`w-4 h-4 text-amber-400`}),` Parameter-Aware Checks`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`Beyond the static risk level, ToolGate recursively inspects nested arguments. Built-in analysis detects destructive commands, sensitive paths, recursive deletion, mass operations, credential-like input, and force flags. `,(0,Y.jsx)(`strong`,{children:`Advanced mode`}),` adds operator-defined words or phrases with whole-word or substring matching, optional case sensitivity, global or tool-specific scope, and a CONFIRM or BLOCK outcome. These checks can only tighten the final decision.`]})]}),(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,Y.jsx)(re,{className:`w-4 h-4 text-amber-400`}),` Confirmation Timeout`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When a confirmation card appears, you have `,(0,Y.jsx)(`strong`,{children:`60 seconds`}),` to respond. If the timer expires, the tool is `,(0,Y.jsx)(`strong`,{children:`auto-denied`}),` for safety. The AI receives a "denied by operator" result and can adapt its approach.`]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-purple-500/40 pb-3`,children:[(0,Y.jsx)(U,{className:`w-6 h-6 text-purple-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Quarantine — Shogun Trash`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Recoverable soft-delete for file operations.`})]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[`When Shogun deletes a file (via Ronin desktop automation or future file tools), the file is not permanently removed. Instead, it is moved to a `,(0,Y.jsx)(`code`,{className:`text-amber-400 bg-black/30 px-1.5 py-0.5 rounded`,children:`.shogun_trash/`}),` directory at the project root. This acts as a safety net against accidental or AI-initiated data loss.`]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Quarantine`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Files are timestamped and moved to trash. A manifest.json tracks the original path, deletion reason, file size, and timestamp.`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Recover`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Any quarantined file can be restored to its original location via the recovery function. No data is permanently lost until explicitly purged.`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Auto-Purge`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Files older than 30 days are eligible for automatic permanent deletion. This prevents unbounded disk growth while preserving recent safety net coverage.`})]}),(0,Y.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-lg p-3 space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:`Audit Trail`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-shogun-subdued`,children:`Every quarantine and recovery action is logged. The manifest provides a complete history of what was deleted, when, and why.`})]})]})]})]}),(0,Y.jsxs)(`section`,{className:`space-y-6`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 border-b-2 border-red-400/40 pb-3`,children:[(0,Y.jsx)(u,{className:`w-6 h-6 text-red-400`}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h4`,{className:`text-xl font-bold uppercase tracking-widest`,children:`Threat Model`}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Known risk categories and how Shogun mitigates them.`})]})]}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4`}),` Prompt Injection`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` Malicious input that tricks the AI into ignoring its rules. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` Constitutional rules are enforced server-side and cannot be overridden by prompt content. The security posture applies independently of the AI's decision-making.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4`}),` Credential Exposure`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` API keys or secrets leaking through agent responses or logs. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` Keys are stored encrypted in the database and never included in prompts or agent context. The frontend never receives raw key values — only masked previews.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4`}),` Runaway Agent`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` An agent entering a loop, spawning unlimited sub-agents, or consuming excessive API credits. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` Spawn policies limit auto-spawning. The Harakiri kill switch provides instant global shutdown. Resource monitoring in Bushido flags anomalies.`]})]}),(0,Y.jsxs)(`div`,{className:`shogun-card space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`font-bold text-red-400 flex items-center gap-2`,children:[(0,Y.jsx)(u,{className:`w-4 h-4`}),` Unauthorized Peer Access`]}),(0,Y.jsxs)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[(0,Y.jsx)(`strong`,{children:`Risk:`}),` A malicious Shogun instance connecting as a peer and injecting harmful tasks. `,(0,Y.jsx)(`strong`,{children:`Mitigation:`}),` All A2A messages are cryptographically signed. Peers must be explicitly invited by URL. Workspace deletion removes all peer access immediately.`]})]})]})]})]}),(0,Y.jsx)(`div`,{className:`mt-16 pt-8 border-t border-shogun-border/40`,children:(0,Y.jsx)(`div`,{className:`shogun-card bg-orange-500/5 border-orange-500/20`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Y.jsx)(u,{className:`w-6 h-6 text-orange-400 shrink-0 mt-1`}),(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest flex items-center gap-2`,children:[(0,Y.jsx)(R,{className:`w-4 h-4 text-orange-400`}),e(`guide.disclaimer_title`,`Legal Disclaimer`)]}),(0,Y.jsx)(`p`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:e(`guide.disclaimer_body`,`Shogun is provided for general informational, experimental, and operational use only. It is provided “as is” and “as available,” without warranties of any kind, express or implied, including but not limited to accuracy, fitness for a particular purpose, merchantability, availability, or non-infringement. Users are solely responsible for evaluating, validating, monitoring, and approving any outputs, actions, configurations, or decisions made with or through Shogun. Alpha Horizon disclaims liability for any direct, indirect, incidental, consequential, or special damages arising from the use of, or inability to use, Shogun, except where such limitation is not permitted by applicable law.`)}),(0,Y.jsx)(`div`,{className:`p-3 bg-shogun-bg border border-shogun-border rounded-lg border-l-4 border-l-orange-400`,children:(0,Y.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:e(`guide.disclaimer_oversight`,`Human oversight required: Shogun may generate inaccurate, incomplete, or inappropriate outputs. It must not be relied upon without appropriate human review, especially in legal, financial, compliance, security, or other high-impact contexts.`)})})]})]})})})]})]})}export{$ as Guide}; \ No newline at end of file diff --git a/frontend/dist/assets/HarakiriModal-ChG-WA-N.js b/frontend/dist/assets/HarakiriModal-ChG-WA-N.js new file mode 100644 index 0000000..6f0b38d --- /dev/null +++ b/frontend/dist/assets/HarakiriModal-ChG-WA-N.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./shield-alert-DzWPVhkC.js";import{t as n}from"./skull-C4tVbB42.js";import{a as r,c as i,j as a,t as o}from"./index-Dy1E248t.js";var s=e(a(),1),c=o();function l({onConfirm:e,onCancel:a}){let[o,l]=(0,s.useState)(1);return(0,c.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center`,children:[(0,c.jsx)(`div`,{className:`absolute inset-0 bg-black/80 backdrop-blur-sm`,onClick:a}),o===1&&(0,c.jsx)(`div`,{className:`relative w-full max-w-md mx-4 animate-in zoom-in-95 duration-200`,children:(0,c.jsxs)(`div`,{className:`bg-shogun-bg border border-orange-500/50 rounded-2xl shadow-[0_0_60px_rgba(249,115,22,0.2)] overflow-hidden`,children:[(0,c.jsxs)(`div`,{className:`bg-orange-500/10 border-b border-orange-500/30 px-6 py-4 flex items-center gap-3`,children:[(0,c.jsx)(i,{className:`w-5 h-5 text-orange-400 shrink-0`}),(0,c.jsx)(`span`,{className:`text-orange-400 font-bold uppercase tracking-widest text-sm`,children:`Warning — Step 1 of 2`}),(0,c.jsx)(`button`,{onClick:a,className:`ml-auto text-shogun-subdued hover:text-shogun-text`,children:(0,c.jsx)(r,{className:`w-4 h-4`})})]}),(0,c.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,c.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,c.jsxs)(`p`,{className:`text-shogun-text font-bold text-base leading-relaxed`,children:[`You are about to initiate `,(0,c.jsx)(`span`,{className:`text-orange-400`,children:`Harakiri`}),`.`]}),(0,c.jsxs)(`p`,{className:`text-shogun-subdued text-sm leading-relaxed`,children:[`This will immediately set posture to `,(0,c.jsx)(`strong`,{className:`text-orange-300`,children:`SHRINE`}),` and suspend `,(0,c.jsx)(`strong`,{className:`text-orange-300`,children:`all`}),` autonomous agent activity on this system.`]})]}),(0,c.jsxs)(`div`,{className:`bg-orange-500/5 border border-orange-500/20 rounded-xl p-4 text-xs text-orange-300/80 space-y-1`,children:[(0,c.jsx)(`p`,{children:`⚠ All Samurai agents will be halted`}),(0,c.jsx)(`p`,{children:`⚠ Shell and skill execution will be disabled`}),(0,c.jsx)(`p`,{children:`⚠ Network access will be locked to allowlist`}),(0,c.jsx)(`p`,{children:`⚠ This state persists across restarts until manually reset`})]})]}),(0,c.jsxs)(`div`,{className:`px-6 pb-6 flex gap-3`,children:[(0,c.jsx)(`button`,{onClick:a,className:`flex-1 py-2.5 rounded-lg border border-shogun-border text-shogun-subdued hover:text-shogun-text text-sm font-bold transition-all`,children:`Cancel`}),(0,c.jsx)(`button`,{onClick:()=>l(2),className:`flex-1 py-2.5 rounded-lg bg-orange-500/20 border border-orange-500/50 text-orange-400 hover:bg-orange-500/30 text-sm font-bold transition-all`,children:`I Understand — Proceed`})]})]})}),o===2&&(0,c.jsx)(`div`,{className:`relative w-full max-w-md mx-4 animate-in zoom-in-95 duration-200`,children:(0,c.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/60 rounded-2xl shadow-[0_0_80px_rgba(239,68,68,0.3)] overflow-hidden`,children:[(0,c.jsxs)(`div`,{className:`bg-red-500/15 border-b border-red-500/40 px-6 py-4 flex items-center gap-3`,children:[(0,c.jsx)(t,{className:`w-5 h-5 text-red-400 shrink-0`}),(0,c.jsx)(`span`,{className:`text-red-400 font-bold uppercase tracking-widest text-sm`,children:`Final Confirmation — Step 2 of 2`}),(0,c.jsx)(`button`,{onClick:a,className:`ml-auto text-shogun-subdued hover:text-shogun-text`,children:(0,c.jsx)(r,{className:`w-4 h-4`})})]}),(0,c.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,c.jsx)(`div`,{className:`flex justify-center`,children:(0,c.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/10 border-2 border-red-500/40 flex items-center justify-center`,children:(0,c.jsx)(n,{className:`w-8 h-8 text-red-400`})})}),(0,c.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,c.jsx)(`p`,{className:`text-red-400 font-bold text-lg uppercase tracking-widest`,children:`This is not reversible`}),(0,c.jsxs)(`p`,{className:`text-shogun-subdued text-sm leading-relaxed`,children:[`You are committing to a `,(0,c.jsx)(`strong`,{className:`text-red-300`,children:`global system lockdown`}),`. All agents will be frozen immediately and the system will not resume autonomously.`]})]}),(0,c.jsx)(`p`,{className:`text-center text-[10px] text-shogun-subdued/60 uppercase tracking-widest`,children:`Click "INITIATE HARAKIRI" to proceed — there is no automatic undo.`})]}),(0,c.jsxs)(`div`,{className:`px-6 pb-6 flex gap-3`,children:[(0,c.jsx)(`button`,{onClick:a,className:`flex-1 py-2.5 rounded-lg border border-shogun-border text-shogun-subdued hover:text-shogun-text text-sm font-bold transition-all`,children:`Abort`}),(0,c.jsx)(`button`,{onClick:()=>{e()},className:`flex-1 py-2.5 rounded-lg bg-red-500 hover:bg-red-600 active:scale-95 text-white text-sm font-bold transition-all shadow-[0_0_20px_rgba(239,68,68,0.4)] uppercase tracking-widest`,children:`☠ Initiate Harakiri`})]})]})})]})}export{l as t}; \ No newline at end of file diff --git a/frontend/dist/assets/HarakiriModal-uap-l0fS.js b/frontend/dist/assets/HarakiriModal-uap-l0fS.js deleted file mode 100644 index c1ac762..0000000 --- a/frontend/dist/assets/HarakiriModal-uap-l0fS.js +++ /dev/null @@ -1 +0,0 @@ -import{o as e,r as t,t as n}from"./jsx-runtime-DmifIpYY.js";import{t as r}from"./shield-alert-ClN8pu2X.js";import{t as i}from"./skull-2psdmx40.js";import{t as a}from"./triangle-alert-BwzZbklP.js";import{t as o}from"./x-Bu7rztmN.js";var s=e(t(),1),c=n();function l({onConfirm:e,onCancel:t}){let[n,l]=(0,s.useState)(1);return(0,c.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center`,children:[(0,c.jsx)(`div`,{className:`absolute inset-0 bg-black/80 backdrop-blur-sm`,onClick:t}),n===1&&(0,c.jsx)(`div`,{className:`relative w-full max-w-md mx-4 animate-in zoom-in-95 duration-200`,children:(0,c.jsxs)(`div`,{className:`bg-shogun-bg border border-orange-500/50 rounded-2xl shadow-[0_0_60px_rgba(249,115,22,0.2)] overflow-hidden`,children:[(0,c.jsxs)(`div`,{className:`bg-orange-500/10 border-b border-orange-500/30 px-6 py-4 flex items-center gap-3`,children:[(0,c.jsx)(a,{className:`w-5 h-5 text-orange-400 shrink-0`}),(0,c.jsx)(`span`,{className:`text-orange-400 font-bold uppercase tracking-widest text-sm`,children:`Warning — Step 1 of 2`}),(0,c.jsx)(`button`,{onClick:t,className:`ml-auto text-shogun-subdued hover:text-shogun-text`,children:(0,c.jsx)(o,{className:`w-4 h-4`})})]}),(0,c.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,c.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,c.jsxs)(`p`,{className:`text-shogun-text font-bold text-base leading-relaxed`,children:[`You are about to initiate `,(0,c.jsx)(`span`,{className:`text-orange-400`,children:`Harakiri`}),`.`]}),(0,c.jsxs)(`p`,{className:`text-shogun-subdued text-sm leading-relaxed`,children:[`This will immediately set posture to `,(0,c.jsx)(`strong`,{className:`text-orange-300`,children:`SHRINE`}),` and suspend `,(0,c.jsx)(`strong`,{className:`text-orange-300`,children:`all`}),` autonomous agent activity on this system.`]})]}),(0,c.jsxs)(`div`,{className:`bg-orange-500/5 border border-orange-500/20 rounded-xl p-4 text-xs text-orange-300/80 space-y-1`,children:[(0,c.jsx)(`p`,{children:`⚠ All Samurai agents will be halted`}),(0,c.jsx)(`p`,{children:`⚠ Shell and skill execution will be disabled`}),(0,c.jsx)(`p`,{children:`⚠ Network access will be locked to allowlist`}),(0,c.jsx)(`p`,{children:`⚠ This state persists across restarts until manually reset`})]})]}),(0,c.jsxs)(`div`,{className:`px-6 pb-6 flex gap-3`,children:[(0,c.jsx)(`button`,{onClick:t,className:`flex-1 py-2.5 rounded-lg border border-shogun-border text-shogun-subdued hover:text-shogun-text text-sm font-bold transition-all`,children:`Cancel`}),(0,c.jsx)(`button`,{onClick:()=>l(2),className:`flex-1 py-2.5 rounded-lg bg-orange-500/20 border border-orange-500/50 text-orange-400 hover:bg-orange-500/30 text-sm font-bold transition-all`,children:`I Understand — Proceed`})]})]})}),n===2&&(0,c.jsx)(`div`,{className:`relative w-full max-w-md mx-4 animate-in zoom-in-95 duration-200`,children:(0,c.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/60 rounded-2xl shadow-[0_0_80px_rgba(239,68,68,0.3)] overflow-hidden`,children:[(0,c.jsxs)(`div`,{className:`bg-red-500/15 border-b border-red-500/40 px-6 py-4 flex items-center gap-3`,children:[(0,c.jsx)(r,{className:`w-5 h-5 text-red-400 shrink-0`}),(0,c.jsx)(`span`,{className:`text-red-400 font-bold uppercase tracking-widest text-sm`,children:`Final Confirmation — Step 2 of 2`}),(0,c.jsx)(`button`,{onClick:t,className:`ml-auto text-shogun-subdued hover:text-shogun-text`,children:(0,c.jsx)(o,{className:`w-4 h-4`})})]}),(0,c.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,c.jsx)(`div`,{className:`flex justify-center`,children:(0,c.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/10 border-2 border-red-500/40 flex items-center justify-center`,children:(0,c.jsx)(i,{className:`w-8 h-8 text-red-400`})})}),(0,c.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,c.jsx)(`p`,{className:`text-red-400 font-bold text-lg uppercase tracking-widest`,children:`This is not reversible`}),(0,c.jsxs)(`p`,{className:`text-shogun-subdued text-sm leading-relaxed`,children:[`You are committing to a `,(0,c.jsx)(`strong`,{className:`text-red-300`,children:`global system lockdown`}),`. All agents will be frozen immediately and the system will not resume autonomously.`]})]}),(0,c.jsx)(`p`,{className:`text-center text-[10px] text-shogun-subdued/60 uppercase tracking-widest`,children:`Click "INITIATE HARAKIRI" to proceed — there is no automatic undo.`})]}),(0,c.jsxs)(`div`,{className:`px-6 pb-6 flex gap-3`,children:[(0,c.jsx)(`button`,{onClick:t,className:`flex-1 py-2.5 rounded-lg border border-shogun-border text-shogun-subdued hover:text-shogun-text text-sm font-bold transition-all`,children:`Abort`}),(0,c.jsx)(`button`,{onClick:()=>{e()},className:`flex-1 py-2.5 rounded-lg bg-red-500 hover:bg-red-600 active:scale-95 text-white text-sm font-bold transition-all shadow-[0_0_20px_rgba(239,68,68,0.4)] uppercase tracking-widest`,children:`☠ Initiate Harakiri`})]})]})})]})}export{l as t}; \ No newline at end of file diff --git a/frontend/dist/assets/Kaizen-BKHxy1IC.js b/frontend/dist/assets/Kaizen-BKHxy1IC.js new file mode 100644 index 0000000..f779b46 --- /dev/null +++ b/frontend/dist/assets/Kaizen-BKHxy1IC.js @@ -0,0 +1,36 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./circle-alert-043xB2li.js";import{t as n}from"./circle-check-DBu5bzEI.js";import{t as r}from"./eye-jI9oiQpv.js";import{t as i}from"./file-code-J1Snk2yW.js";import{t as a}from"./file-text-CrD-Um8r.js";import{t as o}from"./lock-CGEyUK_n.js";import{t as s}from"./refresh-cw-Dm6S5UAJ.js";import{t as c}from"./save-CupVJLfi.js";import{t as l}from"./scale-2yWfMJPT.js";import{t as u}from"./zap-CQy--vuS.js";import{C as d,_ as f,b as p,d as m,f as h,i as g,j as _,r as v,t as y}from"./index-Dy1E248t.js";import{t as b}from"./axios-BGmZl9Qd.js";var x=e(_(),1);function S(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var C={},w={},T={},E;function D(){if(E)return T;E=1;function e(e){return e==null}function t(e){return typeof e==`object`&&!!e}function n(t){return Array.isArray(t)?t:e(t)?[]:[t]}function r(e,t){if(t){let n=Object.keys(t);for(let r=0,i=n.length;rs&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function n(t,n){return e.repeat(` `,n-t.length)+t}function r(r,i){if(i=Object.create(i||null),!r.buffer)return null;i.maxLength||=79,typeof i.indent!=`number`&&(i.indent=1),typeof i.linesBefore!=`number`&&(i.linesBefore=3),typeof i.linesAfter!=`number`&&(i.linesAfter=2);let a=/\r?\n|\r|\0/g,o=[0],s=[],c,l=-1;for(;c=a.exec(r.buffer);)s.push(c.index),o.push(c.index+c[0].length),r.position<=c.index&&l<0&&(l=o.length-2);l<0&&(l=o.length-1);let u=``,d=Math.min(r.line+i.linesAfter,s.length).toString().length,f=i.maxLength-(i.indent+d+3);for(let a=1;a<=i.linesBefore&&!(l-a<0);a++){let c=t(r.buffer,o[l-a],s[l-a],r.position-(o[l]-o[l-a]),f);u=e.repeat(` `,i.indent)+n((r.line-a+1).toString(),d)+` | `+c.str+` +`+u}let p=t(r.buffer,o[l],s[l],r.position,f);u+=e.repeat(` `,i.indent)+n((r.line+1).toString(),d)+` | `+p.str+` +`,u+=e.repeat(`-`,i.indent+d+3+p.pos)+`^ +`;for(let a=1;a<=i.linesAfter&&!(l+a>=s.length);a++){let c=t(r.buffer,o[l+a],s[l+a],r.position-(o[l]-o[l+a]),f);u+=e.repeat(` `,i.indent)+n((r.line+a+1).toString(),d)+` | `+c.str+` +`}return u.replace(/\n$/,``)}return j=r,j}var P,F;function I(){if(F)return P;F=1;let e=A(),t=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],n=[`scalar`,`sequence`,`mapping`];function r(e){let t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function i(i,a){if(a||={},Object.keys(a).forEach(function(n){if(t.indexOf(n)===-1)throw new e(`Unknown option "`+n+`" is met in definition of "`+i+`" YAML type.`)}),this.options=a,this.tag=i,this.kind=a.kind||null,this.resolve=a.resolve||function(){return!0},this.construct=a.construct||function(e){return e},this.instanceOf=a.instanceOf||null,this.predicate=a.predicate||null,this.represent=a.represent||null,this.representName=a.representName||null,this.defaultStyle=a.defaultStyle||null,this.multi=a.multi||!1,this.styleAliases=r(a.styleAliases||null),n.indexOf(this.kind)===-1)throw new e(`Unknown kind "`+this.kind+`" is specified for "`+i+`" YAML type.`)}return P=i,P}var L,R;function z(){if(R)return L;R=1;let e=A(),t=I();function n(e,t){let n=[];return e[t].forEach(function(e){let t=n.length;n.forEach(function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)}),n[t]=e}),n}function r(){let e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function t(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(let e=0,n=arguments.length;e=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function r(e){return e>=48&&e<=55}function i(e){return e>=48&&e<=57}function a(e){if(e===null)return!1;let t=e.length,a=0,s=!1;if(!t)return!1;let c=e[a];if((c===`-`||c===`+`)&&(c=e[++a]),c===`0`){if(a+1===t)return!0;if(c=e[++a],c===`b`){for(a++;a=0?`0b`+e.toString(2):`-0b`+e.toString(2).slice(1)},octal:function(e){return e>=0?`0o`+e.toString(8):`-0o`+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?`0x`+e.toString(16).toUpperCase():`-0x`+e.toString(16).toUpperCase().slice(1)}},defaultStyle:`decimal`,styleAliases:{binary:[2,`bin`],octal:[8,`oct`],decimal:[10,`dec`],hexadecimal:[16,`hex`]}}),Z}var le,ue;function de(){if(ue)return le;ue=1;let e=D(),t=I(),n=RegExp(`^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`),r=RegExp(`^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function i(e){return e===null||!n.test(e)?!1:isFinite(parseFloat(e,10))?!0:r.test(e)}function a(e){let t=e.toLowerCase(),n=t[0]===`-`?-1:1;return`+-`.indexOf(t[0])>=0&&(t=t.slice(1)),t===`.inf`?n===1?1/0:-1/0:t===`.nan`?NaN:n*parseFloat(t,10)}let o=/^[-+]?[0-9]+e/;function s(t,n){if(isNaN(t))switch(n){case`lowercase`:return`.nan`;case`uppercase`:return`.NAN`;case`camelcase`:return`.NaN`}else if(t===1/0)switch(n){case`lowercase`:return`.inf`;case`uppercase`:return`.INF`;case`camelcase`:return`.Inf`}else if(t===-1/0)switch(n){case`lowercase`:return`-.inf`;case`uppercase`:return`-.INF`;case`camelcase`:return`-.Inf`}else if(e.isNegativeZero(t))return`-0.0`;let r=t.toString(10);return o.test(r)?r.replace(`e`,`.e`):r}function c(t){return Object.prototype.toString.call(t)===`[object Number]`&&(t%1!=0||e.isNegativeZero(t))}return le=new t(`tag:yaml.org,2002:float`,{kind:`scalar`,resolve:i,construct:a,predicate:c,represent:s,defaultStyle:`lowercase`}),le}var fe,pe;function me(){return pe?fe:(pe=1,fe=te().extend({implicit:[ie(),oe(),ce(),de()]}),fe)}var he,ge;function _e(){return ge?he:(ge=1,he=me(),he)}var ve,ye;function be(){if(ye)return ve;ye=1;let e=I(),t=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),n=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function r(e){return e===null?!1:t.exec(e)!==null||n.exec(e)!==null}function i(e){let r=0,i=null,a=t.exec(e);if(a===null&&(a=n.exec(e)),a===null)throw Error(`Date resolve error`);let o=+a[1],s=a[2]-1,c=+a[3];if(!a[4])return new Date(Date.UTC(o,s,c));let l=+a[4],u=+a[5],d=+a[6];if(a[7]){for(r=a[7].slice(0,3);r.length<3;)r+=`0`;r=+r}if(a[9]){let e=+a[10],t=+(a[11]||0);i=(e*60+t)*6e4,a[9]===`-`&&(i=-i)}let f=new Date(Date.UTC(o,s,c,l,u,d,r));return i&&f.setTime(f.getTime()-i),f}function a(e){return e.toISOString()}return ve=new e(`tag:yaml.org,2002:timestamp`,{kind:`scalar`,resolve:r,construct:i,instanceOf:Date,represent:a}),ve}var xe,Se;function Ce(){if(Se)return xe;Se=1;let e=I();function t(e){return e===`<<`||e===null}return xe=new e(`tag:yaml.org,2002:merge`,{kind:`scalar`,resolve:t}),xe}var we,Te;function Ee(){if(Te)return we;Te=1;let e=I();function t(e){if(e===null)return!1;let t=0,n=e.length;for(let r=0;r64)){if(n<0)return!1;t+=6}}return t%8==0}function n(e){let t=e.replace(/[\r\n=]/g,``),n=t.length,r=0,i=[];for(let e=0;e>16&255),i.push(r>>8&255),i.push(r&255)),r=r<<6|`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`.indexOf(t.charAt(e));let a=n%4*6;return a===0?(i.push(r>>16&255),i.push(r>>8&255),i.push(r&255)):a===18?(i.push(r>>10&255),i.push(r>>2&255)):a===12&&i.push(r>>4&255),new Uint8Array(i)}function r(e){let t=``,n=0,r=e.length,i=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;for(let a=0;a>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]),n=(n<<8)+e[a];let a=r%3;return a===0?(t+=i[n>>18&63],t+=i[n>>12&63],t+=i[n>>6&63],t+=i[n&63]):a===2?(t+=i[n>>10&63],t+=i[n>>4&63],t+=i[n<<2&63],t+=i[64]):a===1&&(t+=i[n>>2&63],t+=i[n<<4&63],t+=i[64],t+=i[64]),t}function i(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}return we=new e(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:t,construct:n,predicate:i,represent:r}),we}var De,Oe;function ke(){if(Oe)return De;Oe=1;let e=I(),t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(e){if(e===null)return!0;let r=[],i=e;for(let e=0,a=i.length;e=48&&e<=57)return e-48;let t=e|32;return t>=97&&t<=102?t-97+10:-1}function g(e){return e===120?2:e===117?4:e===85?8:0}function _(e){return e>=48&&e<=57?e-48:-1}function v(e){switch(e){case 48:return`\0`;case 97:return`\x07`;case 98:return`\b`;case 116:return` `;case 9:return` `;case 110:return` +`;case 118:return`\v`;case 102:return`\f`;case 114:return`\r`;case 101:return`\x1B`;case 32:return` `;case 34:return`"`;case 47:return`/`;case 92:return`\\`;case 78:return`…`;case 95:return`\xA0`;case 76:return`\u2028`;case 80:return`\u2029`;default:return``}}function y(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function b(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}let x=Array(256),S=Array(256);for(let e=0;e<256;e++)x[e]=+!!v(e),S[e]=v(e);function C(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||r,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.maxDepth=typeof t.maxDepth==`number`?t.maxDepth:100,this.maxTotalMergeKeys=typeof t.maxTotalMergeKeys==`number`?t.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function T(e,r){let i={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return i.snippet=n(i),new t(r,i)}function E(e,t){throw T(e,t)}function O(e,t){e.onWarning&&e.onWarning.call(null,T(e,t))}function k(e,t,n){let r=e.anchorMapTransactions;if(r.length!==0){let n=r[r.length-1];i.call(n,t)||(n[t]={existed:i.call(e.anchorMap,t),value:e.anchorMap[t]})}e.anchorMap[t]=n}function j(e){e.anchorMapTransactions.push(Object.create(null))}function M(e){let t=e.anchorMapTransactions.pop(),n=e.anchorMapTransactions;if(n.length===0)return;let r=n[n.length-1],a=Object.keys(t);for(let e=0,n=a.length;e=0;--r){let i=t[n[r]];i.existed?e.anchorMap[n[r]]=i.value:delete e.anchorMap[n[r]]}}function F(e){return{position:e.position,line:e.line,lineStart:e.lineStart,lineIndent:e.lineIndent,firstTabInLine:e.firstTabInLine,tag:e.tag,anchor:e.anchor,kind:e.kind,result:e.result}}function I(e,t){e.position=t.position,e.line=t.line,e.lineStart=t.lineStart,e.lineIndent=t.lineIndent,e.firstTabInLine=t.firstTabInLine,e.tag=t.tag,e.anchor=t.anchor,e.kind=t.kind,e.result=t.result}let L={YAML:function(e,t,n){e.version!==null&&E(e,`duplication of %YAML directive`),n.length!==1&&E(e,`YAML directive accepts exactly one argument`);let r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]);r===null&&E(e,`ill-formed argument of the YAML directive`);let i=parseInt(r[1],10),a=parseInt(r[2],10);i!==1&&E(e,`unacceptable YAML version of the document`),e.version=n[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&O(e,`unsupported YAML version of the document`)},TAG:function(e,t,n){let r;n.length!==2&&E(e,`TAG directive accepts exactly two arguments`);let a=n[0];r=n[1],c.test(a)||E(e,`ill-formed tag handle (first argument) of the TAG directive`),i.call(e.tagMap,a)&&E(e,`there is a previously declared suffix for "`+a+`" tag handle`),l.test(r)||E(e,`ill-formed tag prefix (second argument) of the TAG directive`);try{r=decodeURIComponent(r)}catch{E(e,`tag prefix is malformed: `+r)}e.tagMap[a]=r}};function R(e,t,n,r){if(t=32&&n<=1114111||E(e,`expected valid JSON character`)}else a.test(i)&&E(e,`the stream contains non-printable characters`);e.result+=i}}function z(t,n,r,a){e.isObject(r)||E(t,`cannot merge mappings; the provided source object is unacceptable`);let o=Object.keys(r);for(let e=0,s=o.length;et.maxTotalMergeKeys&&E(t,`merge keys exceeded maxTotalMergeKeys (`+t.maxTotalMergeKeys+`)`),i.call(n,s)||(b(n,s,r[s]),a[s]=!0)}}function B(e,t,n,r,a,o,s,c,l){if(Array.isArray(a)){a=Array.prototype.slice.call(a);for(let t=0,n=a.length;t1&&(t.result+=e.repeat(` +`,n-1))}function G(e,t,n){let r,i,a,o,s,c,l=e.kind,u=e.result,h=e.input.charCodeAt(e.position);if(p(h)||m(h)||h===35||h===38||h===42||h===33||h===124||h===62||h===39||h===34||h===37||h===64||h===96)return!1;if(h===63||h===45){let t=e.input.charCodeAt(e.position+1);if(p(t)||n&&m(t))return!1}for(e.kind=`scalar`,e.result=``,r=i=e.position,a=!1;h!==0;){if(h===58){let t=e.input.charCodeAt(e.position+1);if(p(t)||n&&m(t))break}else if(h===35){if(p(e.input.charCodeAt(e.position-1)))break}else if(e.position===e.lineStart&&U(e)||n&&m(h))break;else if(d(h))if(o=e.line,s=e.lineStart,c=e.lineIndent,H(e,!1,-1),e.lineIndent>=t){a=!0,h=e.input.charCodeAt(e.position);continue}else{e.position=i,e.line=o,e.lineStart=s,e.lineIndent=c;break}a&&=(R(e,r,i,!1),W(e,e.line-o),r=i=e.position,!1),f(h)||(i=e.position+1),h=e.input.charCodeAt(++e.position)}return R(e,r,i,!1),e.result?!0:(e.kind=l,e.result=u,!1)}function K(e,t){let n,r,i=e.input.charCodeAt(e.position);if(i!==39)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(i=e.input.charCodeAt(e.position))!==0;)if(i===39)if(R(e,n,e.position,!0),i=e.input.charCodeAt(++e.position),i===39)n=e.position,e.position++,r=e.position;else return!0;else d(i)?(R(e,n,r,!0),W(e,H(e,!1,t)),n=r=e.position):e.position===e.lineStart&&U(e)?E(e,`unexpected end of the document within a single quoted scalar`):(e.position++,f(i)||(r=e.position));E(e,`unexpected end of the stream within a single quoted scalar`)}function q(e,t){let n,r,i,a=e.input.charCodeAt(e.position);if(a!==34)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(a=e.input.charCodeAt(e.position))!==0;)if(a===34)return R(e,n,e.position,!0),e.position++,!0;else if(a===92){if(R(e,n,e.position,!0),a=e.input.charCodeAt(++e.position),d(a))H(e,!1,t);else if(a<256&&x[a])e.result+=S[a],e.position++;else if((i=g(a))>0){let t=i,n=0;for(;t>0;t--)a=e.input.charCodeAt(++e.position),(i=h(a))>=0?n=(n<<4)+i:E(e,`expected hexadecimal character`);e.result+=y(n),e.position++}else E(e,`unknown escape sequence`);n=r=e.position}else d(a)?(R(e,n,r,!0),W(e,H(e,!1,t)),n=r=e.position):e.position===e.lineStart&&U(e)?E(e,`unexpected end of the document within a double quoted scalar`):(e.position++,f(a)||(r=e.position));E(e,`unexpected end of the stream within a double quoted scalar`)}function ee(e,t){let n=!0,r,i,a,o=e.tag,s,c=e.anchor,l,u,d,f,m=Object.create(null),h,g,_,v=e.input.charCodeAt(e.position);if(v===91)l=93,f=!1,s=[];else if(v===123)l=125,f=!0,s={};else return!1;for(e.anchor!==null&&k(e,e.anchor,s),v=e.input.charCodeAt(++e.position);v!==0;){if(H(e,!0,t),v=e.input.charCodeAt(e.position),v===l)return e.position++,e.tag=o,e.anchor=c,e.kind=f?`mapping`:`sequence`,e.result=s,!0;n?v===44&&E(e,`expected the node content, but found ','`):E(e,`missed comma between flow collection entries`),g=h=_=null,u=d=!1,v===63&&p(e.input.charCodeAt(e.position+1))&&(u=d=!0,e.position++,H(e,!0,t)),r=e.line,i=e.lineStart,a=e.position,X(e,t,1,!1,!0),g=e.tag,h=e.result,H(e,!0,t),v=e.input.charCodeAt(e.position),(d||e.line===r)&&v===58&&(u=!0,v=e.input.charCodeAt(++e.position),H(e,!0,t),X(e,t,1,!1,!0),_=e.result),f?B(e,s,m,g,h,_,r,i,a):u?s.push(B(e,null,m,g,h,_,r,i,a)):s.push(h),H(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}E(e,`unexpected end of the stream within a flow collection`)}function J(t,n){let r,i=1,a=!1,o=!1,s=n,c=0,l=!1,u,p=t.input.charCodeAt(t.position);if(p===124)r=!1;else if(p===62)r=!0;else return!1;for(t.kind=`scalar`,t.result=``;p!==0;)if(p=t.input.charCodeAt(++t.position),p===43||p===45)i===1?i=p===43?3:2:E(t,`repeat of a chomping mode identifier`);else if((u=_(p))>=0)u===0?E(t,`bad explicit indentation width of a block scalar; it cannot be less than one`):o?E(t,`repeat of an indentation width identifier`):(s=n+u-1,o=!0);else break;if(f(p)){do p=t.input.charCodeAt(++t.position);while(f(p));if(p===35)do p=t.input.charCodeAt(++t.position);while(!d(p)&&p!==0)}for(;p!==0;){for(V(t),t.lineIndent=0,p=t.input.charCodeAt(t.position);(!o||t.lineIndents&&(s=t.lineIndent),d(p)){c++;continue}if(!o&&s===0&&E(t,`missing indentation for block scalar`),t.lineIndentt)&&o!==0)E(e,`bad indentation of a sequence entry`);else if(e.lineIndentt)&&(g&&(i=e.line,a=e.lineStart,o=e.position),X(e,t,4,!0,r)&&(g?m=e.result:h=e.result),g||(B(e,l,u,d,m,h,i,a,o),d=m=h=null),H(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===b||e.lineIndent>t)&&v!==0)E(e,`bad indentation of a mapping entry`);else if(e.lineIndent=e.maxDepth&&E(e,`nesting exceeded maxDepth (`+e.maxDepth+`)`),e.depth+=1,e.listener!==null&&e.listener(`open`,e),e.tag=null,e.anchor=null,e.kind=null,e.result=null;let h=o=s=n===4||n===3;if(r&&H(e,!0,-1)&&(l=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndentt?c=1:e.lineIndent===t?c=0:e.lineIndent tag; it should be "scalar", not "`+e.kind+`"`);for(let t=0,n=e.implicitTypes.length;t`),e.result!==null&&f.kind!==e.kind&&E(e,`unacceptable node kind for !<`+e.tag+`> tag; it should be "`+f.kind+`", not "`+e.kind+`"`),f.resolve(e.result,e.tag)?(e.result=f.construct(e.result,e.tag),e.anchor!==null&&k(e,e.anchor,e.result)):E(e,`cannot resolve a node with !<`+e.tag+`> explicit tag`)}return e.listener!==null&&e.listener(`close`,e),--e.depth,e.tag!==null||e.anchor!==null||u}function oe(e){let t=e.position,n=!1,r;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(r=e.input.charCodeAt(e.position))!==0&&(H(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||r!==37));){n=!0,r=e.input.charCodeAt(++e.position);let t=e.position;for(;r!==0&&!p(r);)r=e.input.charCodeAt(++e.position);let a=e.input.slice(t,e.position),o=[];for(a.length<1&&E(e,`directive name must not be less than one character in length`);r!==0;){for(;f(r);)r=e.input.charCodeAt(++e.position);if(r===35){do r=e.input.charCodeAt(++e.position);while(r!==0&&!d(r));break}if(d(r))break;for(t=e.position;r!==0&&!p(r);)r=e.input.charCodeAt(++e.position);o.push(e.input.slice(t,e.position))}r!==0&&V(e),i.call(L,a)?L[a](e,a,o):O(e,`unknown document directive "`+a+`"`)}if(H(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,H(e,!0,-1)):n&&E(e,`directives end mark is expected`),X(e,e.lineIndent-1,4,!1,!0),H(e,!0,-1),e.checkLineBreaks&&o.test(e.input.slice(t,e.position))&&O(e,`non-ASCII line breaks are interpreted as content`),e.documents.push(e.result),e.position===e.lineStart&&U(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,H(e,!0,-1));return}e.position=32&&e<=126||e>=161&&e<=55295&&e!==8232&&e!==8233||e>=57344&&e<=65533&&e!==a||e>=65536&&e<=1114111}function _(e){return g(e)&&e!==a&&e!==13&&e!==10}function v(e,t,n){let r=_(e),i=r&&!h(e);return(n?r:r&&e!==44&&e!==91&&e!==93&&e!==123&&e!==125)&&e!==35&&!(t===58&&!i)||_(t)&&!h(t)&&e===35||t===58&&i}function y(e){return g(e)&&e!==a&&!h(e)&&e!==45&&e!==63&&e!==58&&e!==44&&e!==91&&e!==93&&e!==123&&e!==125&&e!==35&&e!==38&&e!==42&&e!==33&&e!==124&&e!==61&&e!==62&&e!==39&&e!==34&&e!==37&&e!==64&&e!==96}function b(e){return!h(e)&&e!==58}function x(e,t){let n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function S(e){return/^\n* /.test(e)}function C(e,t,n,r,i,a,o,s){let c,l=0,u=null,d=!1,f=!1,p=r!==-1,m=-1,h=y(x(e,0))&&b(x(e,e.length-1));if(t||o)for(c=0;c=65536?c+=2:c++){if(l=x(e,c),!g(l))return 5;h&&=v(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if(l=x(e,c),l===10)d=!0,p&&(f||=c-m-1>r&&e[m+1]!==` `,m=c);else if(!g(l))return 5;h&&=v(l,u,s),u=l}f||=p&&c-m-1>r&&e[m+1]!==` `}return!d&&!f?h&&!o&&!i(e)?1:a===2?5:2:n>9&&S(e)?5:o?a===2?5:2:f?4:3}function w(e,n,r,i,a){e.dump=(function(){if(n.length===0)return e.quotingType===2?`""`:`''`;if(!e.noCompatMode&&(s.indexOf(n)!==-1||c.test(n)))return e.quotingType===2?`"`+n+`"`:`'`+n+`'`;let o=e.indent*Math.max(1,r),l=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-o),u=i||e.flowLevel>-1&&r>=e.flowLevel;function d(t){return m(e,t)}switch(C(n,u,e.indent,l,d,e.quotingType,e.forceQuotes&&!i,a)){case 1:return n;case 2:return`'`+n.replace(/'/g,`''`)+`'`;case 3:return`|`+T(n,e.indent)+E(f(n,o));case 4:return`>`+T(n,e.indent)+E(f(O(n,l),o));case 5:return`"`+j(n)+`"`;default:throw new t(`impossible error: invalid scalar style`)}})()}function T(e,t){let n=S(e)?String(t):``,r=e[e.length-1]===` +`;return n+(r&&(e[e.length-2]===` +`||e===` +`)?`+`:r?``:`-`)+` +`}function E(e){return e[e.length-1]===` +`?e.slice(0,-1):e}function O(e,t){let n=/(\n+)([^\n]*)/g,r=(function(){let r=e.indexOf(` +`);return r=r===-1?e.length:r,n.lastIndex=r,k(e.slice(0,r),t)})(),i=e[0]===` +`||e[0]===` `,a,o;for(;o=n.exec(e);){let e=o[1],n=o[2];a=n[0]===` `,r+=e+(!i&&!a&&n!==``?` +`:``)+k(n,t),i=a}return r}function k(e,t){if(e===``||e[0]===` `)return e;let n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;for(;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=` +`+e.slice(i,a),i=a+1),o=s;return c+=` +`,e.length-i>t&&o>i?c+=e.slice(i,o)+` +`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function j(e){let t=``,n=0;for(let r=0;r=65536?r+=2:r++){n=x(e,r);let i=o[n];!i&&g(n)?(t+=e[r],n>=65536&&(t+=e[r+1])):t+=i||u(n)}return t}function M(e,t,n){let r=``,i=e.tag;for(let i=0,a=n.length;i1024&&(o+=`? `),o+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),L(e,t,c,!1,!1)&&(o+=e.dump,r+=o))}e.tag=i,e.dump=`{`+r+`}`}function F(e,n,r,i){let a=``,o=e.tag,s=Object.keys(r);if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys==`function`)s.sort(e.sortKeys);else if(e.sortKeys)throw new t(`sortKeys must be a boolean or a function`);for(let t=0,o=s.length;t1024;u&&(e.dump&&e.dump.charCodeAt(0)===10?o+=`?`:o+=`? `),o+=e.dump,u&&(o+=p(e,n)),L(e,n+1,l,!0,u)&&(e.dump&&e.dump.charCodeAt(0)===10?o+=`:`:o+=`: `,o+=e.dump,a+=o)}e.tag=o,e.dump=a||`{}`}function I(e,n,a){let o=a?e.explicitTypes:e.implicitTypes;for(let s=0,c=o.length;s tag resolver accepts not "`+a+`" style`);e.dump=o}return!0}}return!1}function L(e,n,i,a,o,s,c){e.tag=null,e.dump=i,I(e,i,!1)||I(e,i,!0);let l=r.call(e.dump),u=a;a&&=e.flowLevel<0||e.flowLevel>n;let d=l===`[object Object]`||l===`[object Array]`,f,p;if(d&&(f=e.duplicates.indexOf(i),p=f!==-1),(e.tag!==null&&e.tag!==`?`||p||e.indent!==2&&n>0)&&(o=!1),p&&e.usedDuplicates[f])e.dump=`*ref_`+f;else{if(d&&p&&!e.usedDuplicates[f]&&(e.usedDuplicates[f]=!0),l===`[object Object]`)a&&Object.keys(e.dump).length!==0?(F(e,n,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(P(e,n,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object Array]`)a&&e.dump.length!==0?(e.noArrayIndent&&!c&&n>0?N(e,n-1,e.dump,o):N(e,n,e.dump,o),p&&(e.dump=`&ref_`+f+e.dump)):(M(e,n,e.dump),p&&(e.dump=`&ref_`+f+` `+e.dump));else if(l===`[object String]`)e.tag!==`?`&&w(e,e.dump,n,s,u);else if(l===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new t(`unacceptable kind of an object to dump `+l)}if(e.tag!==null&&e.tag!==`?`){let t=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`);t=e.tag[0]===`!`?`!`+t:t.slice(0,18)===`tag:yaml.org,2002:`?`!!`+t.slice(18):`!<`+t+`>`,e.dump=t+` `+e.dump}}return!0}function R(e,t){let n=[],r=[];z(e,n,r);let i=r.length;for(let e=0;e/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function ct(e){return st(e).replace(/^### (.+)$/gm,`

$1

`).replace(/^## (.+)$/gm,`

$1

`).replace(/^# (.+)$/gm,`

$1

`).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\*(.+?)\*/g,`$1`).replace(/^- (.+)$/gm,`
  • $1
  • `).replace(/^---$/gm,`
    `).replace(/\n\n/g,`

    `).replace(/\n/g,`
    `)}var Q=y(),$=`/api/v1/kaizen`,lt={CRITICAL:`text-red-400 bg-red-500/10 border-red-500/30`,HIGH:`text-orange-400 bg-orange-500/10 border-orange-500/30`,BALANCED:`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`,MEDIUM:`text-blue-400 bg-blue-500/10 border-blue-500/30`,LOW:`text-green-400 bg-green-500/10 border-green-500/30`},ut={CRITICAL:m,HIGH:d,BALANCED:u,MEDIUM:l,LOW:n};function dt(){let[e,u]=(0,x.useState)(`constitution`),{t:d}=v(),[m,_]=(0,x.useState)(``),[y,S]=(0,x.useState)(!1),[C,w]=(0,x.useState)(!1),[T,E]=(0,x.useState)(``),[D,O]=(0,x.useState)(!1),[k,A]=(0,x.useState)(!1),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(null),[L,R]=(0,x.useState)([]),z=(0,x.useMemo)(()=>{if(!m.trim())return{valid:!0,error:null};try{return Ke.load(m),{valid:!0,error:null}}catch(e){return{valid:!1,error:e.message||`Invalid YAML`}}},[m]),B=(0,x.useMemo)(()=>{try{let e=Ke.load(m);return!e||!e.core_directives?[]:e.core_directives.filter(e=>e&&typeof e==`object`).map(e=>({id:e.id||`unknown`,rule:e.rule||``,severity:(e.severity||`MEDIUM`).toUpperCase()}))}catch{return[]}},[m]),V=(0,x.useCallback)(async()=>{try{let e=await b.get(`${$}/constitution`);_(e.data.data.content),S(!0),w(!1)}catch(e){console.error(`Failed to load constitution`,e),S(!0)}},[]),H=(0,x.useCallback)(async()=>{try{let e=await b.get(`${$}/mandate`);E(e.data.data.content),O(!0),A(!1)}catch(e){console.error(`Failed to load mandate`,e),O(!0)}},[]),U=(0,x.useCallback)(async e=>{try{let t=e?`${$}/revisions?document_type=${e}`:`${$}/revisions`,n=await b.get(t);R(n.data.data||[])}catch{R([])}},[]);(0,x.useEffect)(()=>{V(),H(),U()},[V,H,U]),(0,x.useEffect)(()=>{U(e)},[e,U]);let W=async()=>{if(!z.valid){I({type:`error`,text:`Cannot publish: YAML syntax is invalid.`}),setTimeout(()=>I(null),4e3);return}P(!0);try{let e=await b.put(`${$}/constitution`,{content:m,change_summary:`Updated via Kaizen UI`});I({type:`success`,text:e.data.data.message||`Edicts published.`}),w(!1),U(`constitution`)}catch(e){let t=e.response?.data?.detail||`Failed to publish edicts.`;I({type:`error`,text:t})}finally{P(!1),setTimeout(()=>I(null),4e3)}},G=async()=>{P(!0);try{let e=await b.put(`${$}/mandate`,{content:T,change_summary:`Updated via Kaizen UI`});I({type:`success`,text:e.data.data.message||`Mandate updated.`}),A(!1),U(`mandate`)}catch(e){let t=e.response?.data?.detail||`Failed to update mandate.`;I({type:`error`,text:t})}finally{P(!1),setTimeout(()=>I(null),4e3)}},K=async()=>{try{let e=await b.get(`${$}/audit-log`,{responseType:`blob`}),t=new Blob([e.data],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`kaizen_audit_log.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{I({type:`error`,text:`Failed to download audit log.`}),setTimeout(()=>I(null),4e3)}},q=e===`constitution`;return(0,Q.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-6xl mx-auto pb-12`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[d(`kaizen.title`,`Kaizen`),` `,(0,Q.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Constitutional Layer`})]}),(0,Q.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:d(`kaizen.subtitle`,`Define the fundamental laws and behavioral constraints for the entire Samurai Network.`)})]}),(0,Q.jsxs)(`button`,{onClick:q?W:G,disabled:N||q&&!z.valid,className:`flex items-center gap-2 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun disabled:opacity-50`,children:[N?(0,Q.jsx)(s,{className:`w-4 h-4 animate-spin`}):(0,Q.jsx)(c,{className:`w-4 h-4`}),N?d(`kaizen.publishing`,`PUBLISHING...`):q?d(`kaizen.publish`,`PUBLISH EDICTS`):d(`kaizen.publish_mandate`,`SEAL MANDATE`)]})]}),F&&(0,Q.jsxs)(`div`,{className:g(`p-4 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,F.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[F.type===`success`?(0,Q.jsx)(n,{className:`w-5 h-5`}):(0,Q.jsx)(t,{className:`w-5 h-5`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold uppercase tracking-widest`,children:F.text})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1 bg-[#050508] p-1 rounded-xl border border-shogun-border w-fit`,children:[(0,Q.jsxs)(`button`,{onClick:()=>u(`constitution`),className:g(`flex items-center gap-2 px-5 py-2 rounded-lg text-xs font-bold uppercase tracking-widest transition-all`,e===`constitution`?`bg-shogun-gold/15 text-shogun-gold border border-shogun-gold/30`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,Q.jsx)(i,{className:`w-3.5 h-3.5`}),` `,d(`kaizen.tab_constitution`,`Constitution`)]}),(0,Q.jsxs)(`button`,{onClick:()=>u(`mandate`),className:g(`flex items-center gap-2 px-5 py-2 rounded-lg text-xs font-bold uppercase tracking-widest transition-all`,e===`mandate`?`bg-shogun-gold/15 text-shogun-gold border border-shogun-gold/30`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,Q.jsx)(h,{className:`w-3.5 h-3.5`}),` `,d(`kaizen.tab_mandate`,`The Mandate`)]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,Q.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:e===`constitution`?(0,Q.jsxs)(`div`,{className:`shogun-card !p-0 overflow-hidden border-shogun-gold/20 flex flex-col min-h-[600px]`,children:[(0,Q.jsxs)(`div`,{className:`p-4 border-b border-shogun-border bg-[#050508]/80 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(i,{className:`w-4 h-4 text-shogun-gold`}),(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`constitution.yaml`}),C&&(0,Q.jsx)(`span`,{className:`text-[9px] text-orange-400 bg-orange-500/10 px-2 py-0.5 rounded border border-orange-500/20 font-bold uppercase`,children:`unsaved`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:g(`w-2 h-2 rounded-full`,z.valid?`bg-green-500 animate-pulse`:`bg-red-500`)}),(0,Q.jsx)(`span`,{className:g(`text-[9px] tracking-tighter uppercase font-bold`,z.valid?`text-shogun-subdued`:`text-red-400`),children:z.valid?`Valid Syntax`:`Invalid Syntax`})]})]}),(0,Q.jsx)(`textarea`,{value:m,onChange:e=>{_(e.target.value),w(!0)},className:`flex-1 w-full bg-[#02040a] p-6 font-mono text-sm text-[#d1d1d1] outline-none resize-none selection:bg-shogun-gold/20`,spellCheck:!1,placeholder:y?``:`Loading...`}),!z.valid&&z.error&&(0,Q.jsxs)(`div`,{className:`p-3 bg-red-500/5 border-t border-red-500/20 text-[10px] text-red-400 font-mono`,children:[`⚠ `,z.error]}),(0,Q.jsxs)(`div`,{className:`p-3 bg-shogun-card/50 border-t border-shogun-border flex justify-between items-center text-[9px] text-shogun-subdued`,children:[(0,Q.jsxs)(`span`,{children:[m.split(` +`).length,` lines`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(o,{className:`w-3 h-3`}),` System Restricted Mode`]})]})]}):(0,Q.jsxs)(`div`,{className:`shogun-card !p-0 overflow-hidden border-shogun-gold/20 flex flex-col min-h-[600px]`,children:[(0,Q.jsxs)(`div`,{className:`p-4 border-b border-shogun-border bg-[#050508]/80 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(h,{className:`w-4 h-4 text-shogun-gold`}),(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`mandate.md`}),k&&(0,Q.jsx)(`span`,{className:`text-[9px] text-orange-400 bg-orange-500/10 px-2 py-0.5 rounded border border-orange-500/20 font-bold uppercase`,children:`unsaved`})]}),(0,Q.jsxs)(`button`,{onClick:()=>M(!j),className:g(`flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-widest px-3 py-1 rounded-md border transition-all`,j?`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`:`text-shogun-subdued hover:text-shogun-text border-shogun-border hover:border-shogun-gold/30`),children:[j?(0,Q.jsx)(a,{className:`w-3 h-3`}):(0,Q.jsx)(r,{className:`w-3 h-3`}),j?`Edit`:`Preview`]})]}),j?(0,Q.jsx)(`div`,{className:`flex-1 w-full bg-[#02040a] p-6 text-sm text-[#c0c0c0] overflow-auto prose-invert`,dangerouslySetInnerHTML:{__html:ct(T)}}):(0,Q.jsx)(`textarea`,{value:T,onChange:e=>{E(e.target.value),A(!0)},className:`flex-1 w-full bg-[#02040a] p-6 font-mono text-sm text-[#d1d1d1] outline-none resize-none selection:bg-shogun-gold/20`,spellCheck:!1,placeholder:D?``:`Loading...`}),(0,Q.jsxs)(`div`,{className:`p-3 bg-shogun-card/50 border-t border-shogun-border flex justify-between items-center text-[9px] text-shogun-subdued`,children:[(0,Q.jsxs)(`span`,{children:[T.split(` +`).length,` lines`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(h,{className:`w-3 h-3`}),` Governance Document`]})]})]})}),(0,Q.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[e===`constitution`&&(0,Q.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,Q.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,Q.jsx)(l,{className:`w-5 h-5 text-shogun-gold`}),` Active Principles`,(0,Q.jsx)(`span`,{className:`text-[9px] text-shogun-subdued bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border ml-auto`,children:B.length})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[B.length===0&&(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued text-center py-4`,children:z.valid?`No core_directives found in YAML.`:`Fix YAML syntax to see directives.`}),B.map(e=>{let t=ut[e.severity]||l,n=lt[e.severity]||lt.MEDIUM;return(0,Q.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl flex items-start gap-3 group hover:border-shogun-gold/50 transition-all`,children:[(0,Q.jsx)(t,{className:g(`w-4 h-4 mt-0.5 shrink-0`,n.split(` `)[0])}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-bold text-shogun-text capitalize`,children:e.id.replace(/_/g,` `)}),(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued mt-0.5 leading-relaxed`,children:e.rule}),(0,Q.jsx)(`span`,{className:g(`inline-block text-[8px] font-bold uppercase tracking-widest mt-1 px-1.5 py-0.5 rounded border`,n),children:e.severity})]})]},e.id)})]})]}),e===`mandate`&&(0,Q.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,Q.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,Q.jsx)(h,{className:`w-5 h-5 text-shogun-gold`}),` About The Mandate`]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:`The Mandate is the Shogun's mission document. It defines the primary objectives, areas of responsibility, and operating principles that guide all decisions. Changes are injected into the Shogun's system prompt.`}),(0,Q.jsxs)(`div`,{className:`p-3 bg-shogun-gold/5 border border-shogun-gold/20 rounded-lg`,children:[(0,Q.jsx)(`div`,{className:`text-[9px] text-shogun-gold font-bold uppercase tracking-widest mb-1`,children:`⚡ System Integration`}),(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued`,children:`Key sections of this mandate are automatically injected into the Shogun's AI context on every interaction.`})]})]}),(0,Q.jsxs)(`div`,{className:`shogun-card bg-shogun-gold/5 border-shogun-gold/20`,children:[(0,Q.jsxs)(`h4`,{className:`text-xs font-bold text-shogun-gold flex items-center gap-2 mb-3`,children:[(0,Q.jsx)(f,{className:`w-4 h-4`}),` `,d(`kaizen.tab_revisions`,`REVISION HISTORY`)]}),(0,Q.jsxs)(`div`,{className:`space-y-3 max-h-[300px] overflow-y-auto`,children:[L.length===0&&(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued text-center py-2`,children:`No revisions yet. Publish to create the first.`}),L.map((e,t)=>(0,Q.jsxs)(`div`,{className:g(`flex items-start gap-4`,t>2&&`opacity-50`),children:[(0,Q.jsx)(`div`,{className:g(`w-1.5 h-1.5 rounded-full mt-1.5`,t===0?`bg-shogun-gold`:`bg-shogun-subdued`)}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`text-[10px] text-shogun-text font-bold`,children:[e.document_type===`constitution`?`Constitution`:`Mandate`,` v`,e.version]}),(0,Q.jsx)(`div`,{className:`text-[9px] text-shogun-subdued`,children:e.change_summary}),e.created_at&&(0,Q.jsxs)(`div`,{className:`text-[8px] text-shogun-subdued mt-0.5`,children:[new Date(e.created_at).toLocaleDateString(),` `,new Date(e.created_at).toLocaleTimeString()]})]})]},e.id))]})]}),(0,Q.jsx)(`div`,{className:`p-4 text-center`,children:(0,Q.jsxs)(`button`,{onClick:K,className:`flex items-center gap-2 mx-auto text-[10px] font-bold text-shogun-gold hover:text-shogun-text uppercase tracking-widest transition-all`,children:[(0,Q.jsx)(p,{className:`w-3.5 h-3.5`}),`Download Audit Log (.JSON)`]})})]})]})]})}export{dt as Kaizen}; \ No newline at end of file diff --git a/frontend/dist/assets/Kaizen-CP3cKETw.js b/frontend/dist/assets/Kaizen-CP3cKETw.js deleted file mode 100644 index 62c373b..0000000 --- a/frontend/dist/assets/Kaizen-CP3cKETw.js +++ /dev/null @@ -1,34 +0,0 @@ -import{o as e,r as t,t as n}from"./jsx-runtime-DmifIpYY.js";import{t as r}from"./book-open-2svOUQwn.js";import{t as i}from"./circle-alert-DVHRBFRQ.js";import{t as a}from"./circle-check-D9mntLsp.js";import{t as o}from"./download-OoiqiOHD.js";import{t as s}from"./eye-DuX8zHAU.js";import{t as c}from"./file-code-tXp5GKlr.js";import{t as l}from"./file-text-Db8l8y7y.js";import{t as u}from"./history-odxnpvgx.js";import{t as d}from"./lock-CYZB3Koj.js";import{t as f}from"./refresh-cw-CCrS0Omg.js";import{t as p}from"./save-CJWuwqGS.js";import{t as m}from"./scale-fLrESr22.js";import{t as h}from"./scroll-text-IcbZPPfm.js";import{t as g}from"./shield-check-4WxAMs16.js";import{t as _}from"./zap-BMpqZS6N.js";import{t as v}from"./utils-wrb6h48Y.js";import{r as ee}from"./i18n-FxgwkwP0.js";import{t as y}from"./axios-BPyV2soB.js";var b=e(t(),1);function te(e){return e==null}function ne(e){return typeof e==`object`&&!!e}function x(e){return Array.isArray(e)?e:te(e)?[]:[e]}function S(e,t){var n,r,i,a;if(t)for(a=Object.keys(t),n=0,r=a.length;ns&&(a=` ... `,t=r-s+a.length),n-r>s&&(o=` ...`,n=r+s-o.length),{str:a+e.slice(t,n).replace(/\t/g,`→`)+o,pos:r-t+a.length}}function E(e,t){return C.repeat(` `,t-e.length)+e}function D(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||=79,typeof t.indent!=`number`&&(t.indent=1),typeof t.linesBefore!=`number`&&(t.linesBefore=3),typeof t.linesAfter!=`number`&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],i=[],a,o=-1;a=n.exec(e.buffer);)i.push(a.index),r.push(a.index+a[0].length),e.position<=a.index&&o<0&&(o=r.length-2);o<0&&(o=r.length-1);var s=``,c,l,u=Math.min(e.line+t.linesAfter,i.length).toString().length,d=t.maxLength-(t.indent+u+3);for(c=1;c<=t.linesBefore&&!(o-c<0);c++)l=oe(e.buffer,r[o-c],i[o-c],e.position-(r[o]-r[o-c]),d),s=C.repeat(` `,t.indent)+E((e.line-c+1).toString(),u)+` | `+l.str+` -`+s;for(l=oe(e.buffer,r[o],i[o],e.position,d),s+=C.repeat(` `,t.indent)+E((e.line+1).toString(),u)+` | `+l.str+` -`,s+=C.repeat(`-`,t.indent+u+3+l.pos)+`^ -`,c=1;c<=t.linesAfter&&!(o+c>=i.length);c++)l=oe(e.buffer,r[o+c],i[o+c],e.position-(r[o]-r[o+c]),d),s+=C.repeat(` `,t.indent)+E((e.line+c+1).toString(),u)+` | `+l.str+` -`;return s.replace(/\n$/,``)}var O=D,k=[`kind`,`multi`,`resolve`,`construct`,`instanceOf`,`predicate`,`represent`,`representName`,`defaultStyle`,`styleAliases`],se=[`scalar`,`sequence`,`mapping`];function ce(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(e){t[String(e)]=n})}),t}function A(e,t){if(t||={},Object.keys(t).forEach(function(t){if(k.indexOf(t)===-1)throw new T(`Unknown option "`+t+`" is met in definition of "`+e+`" YAML type.`)}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=ce(t.styleAliases||null),se.indexOf(this.kind)===-1)throw new T(`Unknown kind "`+this.kind+`" is specified for "`+e+`" YAML type.`)}var j=A;function le(e,t){var n=[];return e[t].forEach(function(e){var t=n.length;n.forEach(function(n,r){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=r)}),n[t]=e}),n}function ue(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(t){t.multi?(e.multi[t.kind].push(t),e.multi.fallback.push(t)):e[t.kind][t.tag]=e.fallback[t.tag]=t}for(t=0,n=arguments.length;t=0?`0b`+e.toString(2):`-0b`+e.toString(2).slice(1)},octal:function(e){return e>=0?`0o`+e.toString(8):`-0o`+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?`0x`+e.toString(16).toUpperCase():`-0x`+e.toString(16).toUpperCase().slice(1)}},defaultStyle:`decimal`,styleAliases:{binary:[2,`bin`],octal:[8,`oct`],decimal:[10,`dec`],hexadecimal:[16,`hex`]}}),Ae=RegExp(`^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$`);function je(e){return!(e===null||!Ae.test(e)||e[e.length-1]===`_`)}function Me(e){var t=e.replace(/_/g,``).toLowerCase(),n=t[0]===`-`?-1:1;return`+-`.indexOf(t[0])>=0&&(t=t.slice(1)),t===`.inf`?n===1?1/0:-1/0:t===`.nan`?NaN:n*parseFloat(t,10)}var Ne=/^[-+]?[0-9]+e/;function Pe(e,t){var n;if(isNaN(e))switch(t){case`lowercase`:return`.nan`;case`uppercase`:return`.NAN`;case`camelcase`:return`.NaN`}else if(e===1/0)switch(t){case`lowercase`:return`.inf`;case`uppercase`:return`.INF`;case`camelcase`:return`.Inf`}else if(e===-1/0)switch(t){case`lowercase`:return`-.inf`;case`uppercase`:return`-.INF`;case`camelcase`:return`-.Inf`}else if(C.isNegativeZero(e))return`-0.0`;return n=e.toString(10),Ne.test(n)?n.replace(`e`,`.e`):n}function Fe(e){return Object.prototype.toString.call(e)===`[object Number]`&&(e%1!=0||C.isNegativeZero(e))}var Ie=new j(`tag:yaml.org,2002:float`,{kind:`scalar`,resolve:je,construct:Me,predicate:Fe,represent:Pe,defaultStyle:`lowercase`}),Le=me.extend({implicit:[ve,Se,ke,Ie]}),Re=Le,ze=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$`),Be=RegExp(`^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$`);function Ve(e){return e===null?!1:ze.exec(e)!==null||Be.exec(e)!==null}function He(e){var t,n,r,i,a,o,s,c=0,l=null,u,d,f;if(t=ze.exec(e),t===null&&(t=Be.exec(e)),t===null)throw Error(`Date resolve error`);if(n=+t[1],r=t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(n,r,i));if(a=+t[4],o=+t[5],s=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+=`0`;c=+c}return t[9]&&(u=+t[10],d=+(t[11]||0),l=(u*60+d)*6e4,t[9]===`-`&&(l=-l)),f=new Date(Date.UTC(n,r,i,a,o,s,c)),l&&f.setTime(f.getTime()-l),f}function Ue(e){return e.toISOString()}var We=new j(`tag:yaml.org,2002:timestamp`,{kind:`scalar`,resolve:Ve,construct:He,instanceOf:Date,represent:Ue});function Ge(e){return e===`<<`||e===null}var Ke=new j(`tag:yaml.org,2002:merge`,{kind:`scalar`,resolve:Ge}),qe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function Je(e){if(e===null)return!1;var t,n,r=0,i=e.length,a=qe;for(n=0;n64)){if(t<0)return!1;r+=6}return r%8==0}function Ye(e){var t,n,r=e.replace(/[\r\n=]/g,``),i=r.length,a=qe,o=0,s=[];for(t=0;t>16&255),s.push(o>>8&255),s.push(o&255)),o=o<<6|a.indexOf(r.charAt(t));return n=i%4*6,n===0?(s.push(o>>16&255),s.push(o>>8&255),s.push(o&255)):n===18?(s.push(o>>10&255),s.push(o>>2&255)):n===12&&s.push(o>>4&255),new Uint8Array(s)}function Xe(e){var t=``,n=0,r,i,a=e.length,o=qe;for(r=0;r>18&63],t+=o[n>>12&63],t+=o[n>>6&63],t+=o[n&63]),n=(n<<8)+e[r];return i=a%3,i===0?(t+=o[n>>18&63],t+=o[n>>12&63],t+=o[n>>6&63],t+=o[n&63]):i===2?(t+=o[n>>10&63],t+=o[n>>4&63],t+=o[n<<2&63],t+=o[64]):i===1&&(t+=o[n>>2&63],t+=o[n<<4&63],t+=o[64],t+=o[64]),t}function Ze(e){return Object.prototype.toString.call(e)===`[object Uint8Array]`}var Qe=new j(`tag:yaml.org,2002:binary`,{kind:`scalar`,resolve:Je,construct:Ye,predicate:Ze,represent:Xe}),$e=Object.prototype.hasOwnProperty,et=Object.prototype.toString;function tt(e){if(e===null)return!0;var t=[],n,r,i,a,o,s=e;for(n=0,r=s.length;n>10)+55296,(e-65536&1023)+56320)}function jt(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var Mt=Array(256),Nt=Array(256),z=0;z<256;z++)Mt[z]=+!!kt(z),Nt[z]=kt(z);function Pt(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||ft,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Ft(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=O(n),new T(t,n)}function B(e,t){throw Ft(e,t)}function It(e,t){e.onWarning&&e.onWarning.call(null,Ft(e,t))}var Lt={YAML:function(e,t,n){var r,i,a;e.version!==null&&B(e,`duplication of %YAML directive`),n.length!==1&&B(e,`YAML directive accepts exactly one argument`),r=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),r===null&&B(e,`ill-formed argument of the YAML directive`),i=parseInt(r[1],10),a=parseInt(r[2],10),i!==1&&B(e,`unacceptable YAML version of the document`),e.version=n[0],e.checkLineBreaks=a<2,a!==1&&a!==2&&It(e,`unsupported YAML version of the document`)},TAG:function(e,t,n){var r,i;n.length!==2&&B(e,`TAG directive accepts exactly two arguments`),r=n[0],i=n[1],Ct.test(r)||B(e,`ill-formed tag handle (first argument) of the TAG directive`),P.call(e.tagMap,r)&&B(e,`there is a previously declared suffix for "`+r+`" tag handle`),wt.test(i)||B(e,`ill-formed tag prefix (second argument) of the TAG directive`);try{i=decodeURIComponent(i)}catch{B(e,`tag prefix is malformed: `+i)}e.tagMap[r]=i}};function V(e,t,n,r){var i,a,o,s;if(t1&&(e.result+=C.repeat(` -`,t-1))}function Ht(e,t,n){var r,i,a,o,s,c,l,u,d=e.kind,f=e.result,p=e.input.charCodeAt(e.position);if(L(p)||R(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(i=e.input.charCodeAt(e.position+1),L(i)||n&&R(i)))return!1;for(e.kind=`scalar`,e.result=``,a=o=e.position,s=!1;p!==0;){if(p===58){if(i=e.input.charCodeAt(e.position+1),L(i)||n&&R(i))break}else if(p===35){if(r=e.input.charCodeAt(e.position-1),L(r))break}else if(e.position===e.lineStart&&Bt(e)||n&&R(p))break;else if(F(p))if(c=e.line,l=e.lineStart,u=e.lineIndent,U(e,!1,-1),e.lineIndent>=t){s=!0,p=e.input.charCodeAt(e.position);continue}else{e.position=o,e.line=c,e.lineStart=l,e.lineIndent=u;break}s&&=(V(e,a,o,!1),Vt(e,e.line-c),a=o=e.position,!1),I(p)||(o=e.position+1),p=e.input.charCodeAt(++e.position)}return V(e,a,o,!1),e.result?!0:(e.kind=d,e.result=f,!1)}function Ut(e,t){var n=e.input.charCodeAt(e.position),r,i;if(n!==39)return!1;for(e.kind=`scalar`,e.result=``,e.position++,r=i=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(V(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,i=e.position;else return!0;else F(n)?(V(e,r,i,!0),Vt(e,U(e,!1,t)),r=i=e.position):e.position===e.lineStart&&Bt(e)?B(e,`unexpected end of the document within a single quoted scalar`):(e.position++,i=e.position);B(e,`unexpected end of the stream within a single quoted scalar`)}function Wt(e,t){var n,r,i,a,o,s=e.input.charCodeAt(e.position);if(s!==34)return!1;for(e.kind=`scalar`,e.result=``,e.position++,n=r=e.position;(s=e.input.charCodeAt(e.position))!==0;)if(s===34)return V(e,n,e.position,!0),e.position++,!0;else if(s===92){if(V(e,n,e.position,!0),s=e.input.charCodeAt(++e.position),F(s))U(e,!1,t);else if(s<256&&Mt[s])e.result+=Nt[s],e.position++;else if((o=Dt(s))>0){for(i=o,a=0;i>0;i--)s=e.input.charCodeAt(++e.position),(o=Et(s))>=0?a=(a<<4)+o:B(e,`expected hexadecimal character`);e.result+=At(a),e.position++}else B(e,`unknown escape sequence`);n=r=e.position}else F(s)?(V(e,n,r,!0),Vt(e,U(e,!1,t)),n=r=e.position):e.position===e.lineStart&&Bt(e)?B(e,`unexpected end of the document within a double quoted scalar`):(e.position++,r=e.position);B(e,`unexpected end of the stream within a double quoted scalar`)}function Gt(e,t){var n=!0,r,i,a,o=e.tag,s,c=e.anchor,l,u,d,f,p,m=Object.create(null),h,g,_,v=e.input.charCodeAt(e.position);if(v===91)u=93,p=!1,s=[];else if(v===123)u=125,p=!0,s={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),v=e.input.charCodeAt(++e.position);v!==0;){if(U(e,!0,t),v=e.input.charCodeAt(e.position),v===u)return e.position++,e.tag=o,e.anchor=c,e.kind=p?`mapping`:`sequence`,e.result=s,!0;n?v===44&&B(e,`expected the node content, but found ','`):B(e,`missed comma between flow collection entries`),g=h=_=null,d=f=!1,v===63&&(l=e.input.charCodeAt(e.position+1),L(l)&&(d=f=!0,e.position++,U(e,!0,t))),r=e.line,i=e.lineStart,a=e.position,W(e,t,pt,!1,!0),g=e.tag,h=e.result,U(e,!0,t),v=e.input.charCodeAt(e.position),(f||e.line===r)&&v===58&&(d=!0,v=e.input.charCodeAt(++e.position),U(e,!0,t),W(e,t,pt,!1,!0),_=e.result),p?H(e,s,m,g,h,_,r,i,a):d?s.push(H(e,null,m,g,h,_,r,i,a)):s.push(h),U(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}B(e,`unexpected end of the stream within a flow collection`)}function Kt(e,t){var n,r,i=_t,a=!1,o=!1,s=t,c=0,l=!1,u,d=e.input.charCodeAt(e.position);if(d===124)r=!1;else if(d===62)r=!0;else return!1;for(e.kind=`scalar`,e.result=``;d!==0;)if(d=e.input.charCodeAt(++e.position),d===43||d===45)_t===i?i=d===43?yt:vt:B(e,`repeat of a chomping mode identifier`);else if((u=Ot(d))>=0)u===0?B(e,`bad explicit indentation width of a block scalar; it cannot be less than one`):o?B(e,`repeat of an indentation width identifier`):(s=t+u-1,o=!0);else break;if(I(d)){do d=e.input.charCodeAt(++e.position);while(I(d));if(d===35)do d=e.input.charCodeAt(++e.position);while(!F(d)&&d!==0)}for(;d!==0;){for(zt(e),e.lineIndent=0,d=e.input.charCodeAt(e.position);(!o||e.lineIndents&&(s=e.lineIndent),F(d)){c++;continue}if(e.lineIndentt)&&c!==0)B(e,`bad indentation of a sequence entry`);else if(e.lineIndentt)&&(g&&(o=e.line,s=e.lineStart,c=e.position),W(e,t,gt,!0,i)&&(g?m=e.result:h=e.result),g||(H(e,d,f,p,m,h,o,s,c),p=m=h=null),U(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&v!==0)B(e,`bad indentation of a mapping entry`);else if(e.lineIndentt?c=1:e.lineIndent===t?c=0:e.lineIndentt?c=1:e.lineIndent===t?c=0:e.lineIndent tag; it should be "scalar", not "`+e.kind+`"`),d=0,f=e.implicitTypes.length;d`),e.result!==null&&m.kind!==e.kind&&B(e,`unacceptable node kind for !<`+e.tag+`> tag; it should be "`+m.kind+`", not "`+e.kind+`"`),m.resolve(e.result,e.tag)?(e.result=m.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):B(e,`cannot resolve a node with !<`+e.tag+`> explicit tag`)}return e.listener!==null&&e.listener(`close`,e),e.tag!==null||e.anchor!==null||u}function Qt(e){var t=e.position,n,r,i,a=!1,o;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(o=e.input.charCodeAt(e.position))!==0&&(U(e,!0,-1),o=e.input.charCodeAt(e.position),!(e.lineIndent>0||o!==37));){for(a=!0,o=e.input.charCodeAt(++e.position),n=e.position;o!==0&&!L(o);)o=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),i=[],r.length<1&&B(e,`directive name must not be less than one character in length`);o!==0;){for(;I(o);)o=e.input.charCodeAt(++e.position);if(o===35){do o=e.input.charCodeAt(++e.position);while(o!==0&&!F(o));break}if(F(o))break;for(n=e.position;o!==0&&!L(o);)o=e.input.charCodeAt(++e.position);i.push(e.input.slice(n,e.position))}o!==0&&zt(e),P.call(Lt,r)?Lt[r](e,r,i):It(e,`unknown document directive "`+r+`"`)}if(U(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,U(e,!0,-1)):a&&B(e,`directives end mark is expected`),W(e,e.lineIndent-1,gt,!1,!0),U(e,!0,-1),e.checkLineBreaks&&xt.test(e.input.slice(t,e.position))&&It(e,`non-ASCII line breaks are interpreted as content`),e.documents.push(e.result),e.position===e.lineStart&&Bt(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,U(e,!0,-1));return}if(e.position=55296&&n<=56319&&t+1=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function Wn(e){return/^\n* /.test(e)}var Gn=1,Kn=2,qn=3,Jn=4,X=5;function Yn(e,t,n,r,i,a,o,s){var c,l=0,u=null,d=!1,f=!1,p=r!==-1,m=-1,h=Hn(Y(e,0))&&Un(Y(e,e.length-1));if(t||o)for(c=0;c=65536?c+=2:c++){if(l=Y(e,c),!J(l))return X;h&&=Vn(l,u,s),u=l}else{for(c=0;c=65536?c+=2:c++){if(l=Y(e,c),l===G)d=!0,p&&(f||=c-m-1>r&&e[m+1]!==` `,m=c);else if(!J(l))return X;h&&=Vn(l,u,s),u=l}f||=p&&c-m-1>r&&e[m+1]!==` `}return!d&&!f?h&&!o&&!i(e)?Gn:a===q?X:Kn:n>9&&Wn(e)?X:o?a===q?X:Kn:f?Jn:qn}function Xn(e,t,n,r,i){e.dump=function(){if(t.length===0)return e.quotingType===q?`""`:`''`;if(!e.noCompatMode&&(An.indexOf(t)!==-1||jn.test(t)))return e.quotingType===q?`"`+t+`"`:`'`+t+`'`;var a=e.indent*Math.max(1,n),o=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),s=r||e.flowLevel>-1&&n>=e.flowLevel;function c(t){return Rn(e,t)}switch(Yn(t,s,e.indent,o,c,e.quotingType,e.forceQuotes&&!r,i)){case Gn:return t;case Kn:return`'`+t.replace(/'/g,`''`)+`'`;case qn:return`|`+Zn(t,e.indent)+Qn(In(t,a));case Jn:return`>`+Zn(t,e.indent)+Qn(In($n(t,o),a));case X:return`"`+tr(t)+`"`;default:throw new T(`impossible error: invalid scalar style`)}}()}function Zn(e,t){var n=Wn(e)?String(t):``,r=e[e.length-1]===` -`;return n+(r&&(e[e.length-2]===` -`||e===` -`)?`+`:r?``:`-`)+` -`}function Qn(e){return e[e.length-1]===` -`?e.slice(0,-1):e}function $n(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var r=e.indexOf(` -`);return r=r===-1?e.length:r,n.lastIndex=r,er(e.slice(0,r),t)}(),i=e[0]===` -`||e[0]===` `,a,o;o=n.exec(e);){var s=o[1],c=o[2];a=c[0]===` `,r+=s+(!i&&!a&&c!==``?` -`:``)+er(c,t),i=a}return r}function er(e,t){if(e===``||e[0]===` `)return e;for(var n=/ [^ ]/g,r,i=0,a,o=0,s=0,c=``;r=n.exec(e);)s=r.index,s-i>t&&(a=o>i?o:s,c+=` -`+e.slice(i,a),i=a+1),o=s;return c+=` -`,e.length-i>t&&o>i?c+=e.slice(i,o)+` -`+e.slice(o+1):c+=e.slice(i),c.slice(1)}function tr(e){for(var t=``,n=0,r,i=0;i=65536?i+=2:i++)n=Y(e,i),r=K[n],!r&&J(n)?(t+=e[i],n>=65536&&(t+=e[i+1])):t+=r||Nn(n);return t}function nr(e,t,n){var r=``,i=e.tag,a,o,s;for(a=0,o=n.length;a1024&&(u+=`? `),u+=e.dump+(e.condenseFlow?`"`:``)+`:`+(e.condenseFlow?``:` `),Z(e,t,l,!1,!1)&&(u+=e.dump,r+=u));e.tag=i,e.dump=`{`+r+`}`}function ar(e,t,n,r){var i=``,a=e.tag,o=Object.keys(n),s,c,l,u,d,f;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys==`function`)o.sort(e.sortKeys);else if(e.sortKeys)throw new T(`sortKeys must be a boolean or a function`);for(s=0,c=o.length;s1024,d&&(e.dump&&G===e.dump.charCodeAt(0)?f+=`?`:f+=`? `),f+=e.dump,d&&(f+=Ln(e,t)),Z(e,t+1,u,!0,d)&&(e.dump&&G===e.dump.charCodeAt(0)?f+=`:`:f+=`: `,f+=e.dump,i+=f));e.tag=a,e.dump=i||`{}`}function or(e,t,n){var r,i=n?e.explicitTypes:e.implicitTypes,a,o,s,c;for(a=0,o=i.length;a tag resolver accepts not "`+c+`" style`);e.dump=r}return!0}return!1}function Z(e,t,n,r,i,a,o){e.tag=null,e.dump=n,or(e,n,!1)||or(e,n,!0);var s=rn.call(e.dump),c=r,l;r&&=e.flowLevel<0||e.flowLevel>t;var u=s===`[object Object]`||s===`[object Array]`,d,f;if(u&&(d=e.duplicates.indexOf(n),f=d!==-1),(e.tag!==null&&e.tag!==`?`||f||e.indent!==2&&t>0)&&(i=!1),f&&e.usedDuplicates[d])e.dump=`*ref_`+d;else{if(u&&f&&!e.usedDuplicates[d]&&(e.usedDuplicates[d]=!0),s===`[object Object]`)r&&Object.keys(e.dump).length!==0?(ar(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(ir(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object Array]`)r&&e.dump.length!==0?(e.noArrayIndent&&!o&&t>0?rr(e,t-1,e.dump,i):rr(e,t,e.dump,i),f&&(e.dump=`&ref_`+d+e.dump)):(nr(e,t,e.dump),f&&(e.dump=`&ref_`+d+` `+e.dump));else if(s===`[object String]`)e.tag!==`?`&&Xn(e,e.dump,t,a,c);else if(s===`[object Undefined]`)return!1;else{if(e.skipInvalid)return!1;throw new T(`unacceptable kind of an object to dump `+s)}e.tag!==null&&e.tag!==`?`&&(l=encodeURI(e.tag[0]===`!`?e.tag.slice(1):e.tag).replace(/!/g,`%21`),l=e.tag[0]===`!`?`!`+l:l.slice(0,18)===`tag:yaml.org,2002:`?`!!`+l.slice(18):`!<`+l+`>`,e.dump=l+` `+e.dump)}return!0}function sr(e,t){var n=[],r=[],i,a;for(cr(e,n,r),i=0,a=r.length;i$1`).replace(/^## (.+)$/gm,`

    $1

    `).replace(/^# (.+)$/gm,`

    $1

    `).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\*(.+?)\*/g,`$1`).replace(/^- (.+)$/gm,`
  • $1
  • `).replace(/^---$/gm,`
    `).replace(/\n\n/g,`

    `).replace(/\n/g,`
    `)}var mr={CRITICAL:`text-red-400 bg-red-500/10 border-red-500/30`,HIGH:`text-orange-400 bg-orange-500/10 border-orange-500/30`,BALANCED:`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`,MEDIUM:`text-blue-400 bg-blue-500/10 border-blue-500/30`,LOW:`text-green-400 bg-green-500/10 border-green-500/30`},hr={CRITICAL:g,HIGH:r,BALANCED:_,MEDIUM:m,LOW:a};function gr(){let[e,t]=(0,b.useState)(`constitution`),{t:n}=ee(),[r,g]=(0,b.useState)(``),[_,te]=(0,b.useState)(!1),[ne,x]=(0,b.useState)(!1),[S,re]=(0,b.useState)(``),[ie,C]=(0,b.useState)(!1),[ae,w]=(0,b.useState)(!1),[T,oe]=(0,b.useState)(!1),[E,D]=(0,b.useState)(!1),[O,k]=(0,b.useState)(null),[se,ce]=(0,b.useState)([]),A=(0,b.useMemo)(()=>{if(!r.trim())return{valid:!0,error:null};try{return fr.load(r),{valid:!0,error:null}}catch(e){return{valid:!1,error:e.message||`Invalid YAML`}}},[r]),j=(0,b.useMemo)(()=>{try{let e=fr.load(r);return!e||!e.core_directives?[]:e.core_directives.filter(e=>e&&typeof e==`object`).map(e=>({id:e.id||`unknown`,rule:e.rule||``,severity:(e.severity||`MEDIUM`).toUpperCase()}))}catch{return[]}},[r]),le=(0,b.useCallback)(async()=>{try{g((await y.get(`${$}/constitution`)).data.data.content),te(!0),x(!1)}catch(e){console.error(`Failed to load constitution`,e),te(!0)}},[]),ue=(0,b.useCallback)(async()=>{try{re((await y.get(`${$}/mandate`)).data.data.content),C(!0),w(!1)}catch(e){console.error(`Failed to load mandate`,e),C(!0)}},[]),M=(0,b.useCallback)(async e=>{try{let t=e?`${$}/revisions?document_type=${e}`:`${$}/revisions`;ce((await y.get(t)).data.data||[])}catch{ce([])}},[]);(0,b.useEffect)(()=>{le(),ue(),M()},[le,ue,M]),(0,b.useEffect)(()=>{M(e)},[e,M]);let de=async()=>{if(!A.valid){k({type:`error`,text:`Cannot publish: YAML syntax is invalid.`}),setTimeout(()=>k(null),4e3);return}D(!0);try{k({type:`success`,text:(await y.put(`${$}/constitution`,{content:r,change_summary:`Updated via Kaizen UI`})).data.data.message||`Edicts published.`}),x(!1),M(`constitution`)}catch(e){k({type:`error`,text:e.response?.data?.detail||`Failed to publish edicts.`})}finally{D(!1),setTimeout(()=>k(null),4e3)}},fe=async()=>{D(!0);try{k({type:`success`,text:(await y.put(`${$}/mandate`,{content:S,change_summary:`Updated via Kaizen UI`})).data.data.message||`Mandate updated.`}),w(!1),M(`mandate`)}catch(e){k({type:`error`,text:e.response?.data?.detail||`Failed to update mandate.`})}finally{D(!1),setTimeout(()=>k(null),4e3)}},pe=async()=>{try{let e=await y.get(`${$}/audit-log`,{responseType:`blob`}),t=new Blob([e.data],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`kaizen_audit_log.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}catch{k({type:`error`,text:`Failed to download audit log.`}),setTimeout(()=>k(null),4e3)}},N=e===`constitution`;return(0,Q.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-6xl mx-auto pb-12`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[n(`kaizen.title`,`Kaizen`),` `,(0,Q.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Constitutional Layer`})]}),(0,Q.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:n(`kaizen.subtitle`,`Define the fundamental laws and behavioral constraints for the entire Samurai Network.`)})]}),(0,Q.jsxs)(`button`,{onClick:N?de:fe,disabled:E||N&&!A.valid,className:`flex items-center gap-2 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun disabled:opacity-50`,children:[E?(0,Q.jsx)(f,{className:`w-4 h-4 animate-spin`}):(0,Q.jsx)(p,{className:`w-4 h-4`}),E?n(`kaizen.publishing`,`PUBLISHING...`):N?n(`kaizen.publish`,`PUBLISH EDICTS`):n(`kaizen.publish_mandate`,`SEAL MANDATE`)]})]}),O&&(0,Q.jsxs)(`div`,{className:v(`p-4 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,O.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[O.type===`success`?(0,Q.jsx)(a,{className:`w-5 h-5`}):(0,Q.jsx)(i,{className:`w-5 h-5`}),(0,Q.jsx)(`span`,{className:`text-sm font-bold uppercase tracking-widest`,children:O.text})]}),(0,Q.jsxs)(`div`,{className:`flex gap-1 bg-[#050508] p-1 rounded-xl border border-shogun-border w-fit`,children:[(0,Q.jsxs)(`button`,{onClick:()=>t(`constitution`),className:v(`flex items-center gap-2 px-5 py-2 rounded-lg text-xs font-bold uppercase tracking-widest transition-all`,e===`constitution`?`bg-shogun-gold/15 text-shogun-gold border border-shogun-gold/30`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,Q.jsx)(c,{className:`w-3.5 h-3.5`}),` `,n(`kaizen.tab_constitution`,`Constitution`)]}),(0,Q.jsxs)(`button`,{onClick:()=>t(`mandate`),className:v(`flex items-center gap-2 px-5 py-2 rounded-lg text-xs font-bold uppercase tracking-widest transition-all`,e===`mandate`?`bg-shogun-gold/15 text-shogun-gold border border-shogun-gold/30`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,Q.jsx)(h,{className:`w-3.5 h-3.5`}),` `,n(`kaizen.tab_mandate`,`The Mandate`)]})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,Q.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:e===`constitution`?(0,Q.jsxs)(`div`,{className:`shogun-card !p-0 overflow-hidden border-shogun-gold/20 flex flex-col min-h-[600px]`,children:[(0,Q.jsxs)(`div`,{className:`p-4 border-b border-shogun-border bg-[#050508]/80 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(c,{className:`w-4 h-4 text-shogun-gold`}),(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`constitution.yaml`}),ne&&(0,Q.jsx)(`span`,{className:`text-[9px] text-orange-400 bg-orange-500/10 px-2 py-0.5 rounded border border-orange-500/20 font-bold uppercase`,children:`unsaved`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:v(`w-2 h-2 rounded-full`,A.valid?`bg-green-500 animate-pulse`:`bg-red-500`)}),(0,Q.jsx)(`span`,{className:v(`text-[9px] tracking-tighter uppercase font-bold`,A.valid?`text-shogun-subdued`:`text-red-400`),children:A.valid?`Valid Syntax`:`Invalid Syntax`})]})]}),(0,Q.jsx)(`textarea`,{value:r,onChange:e=>{g(e.target.value),x(!0)},className:`flex-1 w-full bg-[#02040a] p-6 font-mono text-sm text-[#d1d1d1] outline-none resize-none selection:bg-shogun-gold/20`,spellCheck:!1,placeholder:_?``:`Loading...`}),!A.valid&&A.error&&(0,Q.jsxs)(`div`,{className:`p-3 bg-red-500/5 border-t border-red-500/20 text-[10px] text-red-400 font-mono`,children:[`⚠ `,A.error]}),(0,Q.jsxs)(`div`,{className:`p-3 bg-shogun-card/50 border-t border-shogun-border flex justify-between items-center text-[9px] text-shogun-subdued`,children:[(0,Q.jsxs)(`span`,{children:[r.split(` -`).length,` lines`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(d,{className:`w-3 h-3`}),` System Restricted Mode`]})]})]}):(0,Q.jsxs)(`div`,{className:`shogun-card !p-0 overflow-hidden border-shogun-gold/20 flex flex-col min-h-[600px]`,children:[(0,Q.jsxs)(`div`,{className:`p-4 border-b border-shogun-border bg-[#050508]/80 flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(h,{className:`w-4 h-4 text-shogun-gold`}),(0,Q.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`mandate.md`}),ae&&(0,Q.jsx)(`span`,{className:`text-[9px] text-orange-400 bg-orange-500/10 px-2 py-0.5 rounded border border-orange-500/20 font-bold uppercase`,children:`unsaved`})]}),(0,Q.jsxs)(`button`,{onClick:()=>oe(!T),className:v(`flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-widest px-3 py-1 rounded-md border transition-all`,T?`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`:`text-shogun-subdued hover:text-shogun-text border-shogun-border hover:border-shogun-gold/30`),children:[T?(0,Q.jsx)(l,{className:`w-3 h-3`}):(0,Q.jsx)(s,{className:`w-3 h-3`}),T?`Edit`:`Preview`]})]}),T?(0,Q.jsx)(`div`,{className:`flex-1 w-full bg-[#02040a] p-6 text-sm text-[#c0c0c0] overflow-auto prose-invert`,dangerouslySetInnerHTML:{__html:pr(S)}}):(0,Q.jsx)(`textarea`,{value:S,onChange:e=>{re(e.target.value),w(!0)},className:`flex-1 w-full bg-[#02040a] p-6 font-mono text-sm text-[#d1d1d1] outline-none resize-none selection:bg-shogun-gold/20`,spellCheck:!1,placeholder:ie?``:`Loading...`}),(0,Q.jsxs)(`div`,{className:`p-3 bg-shogun-card/50 border-t border-shogun-border flex justify-between items-center text-[9px] text-shogun-subdued`,children:[(0,Q.jsxs)(`span`,{children:[S.split(` -`).length,` lines`]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(h,{className:`w-3 h-3`}),` Governance Document`]})]})]})}),(0,Q.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[e===`constitution`&&(0,Q.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,Q.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,Q.jsx)(m,{className:`w-5 h-5 text-shogun-gold`}),` Active Principles`,(0,Q.jsx)(`span`,{className:`text-[9px] text-shogun-subdued bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border ml-auto`,children:j.length})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[j.length===0&&(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued text-center py-4`,children:A.valid?`No core_directives found in YAML.`:`Fix YAML syntax to see directives.`}),j.map(e=>{let t=hr[e.severity]||m,n=mr[e.severity]||mr.MEDIUM;return(0,Q.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl flex items-start gap-3 group hover:border-shogun-gold/50 transition-all`,children:[(0,Q.jsx)(t,{className:v(`w-4 h-4 mt-0.5 shrink-0`,n.split(` `)[0])}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-bold text-shogun-text capitalize`,children:e.id.replace(/_/g,` `)}),(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued mt-0.5 leading-relaxed`,children:e.rule}),(0,Q.jsx)(`span`,{className:v(`inline-block text-[8px] font-bold uppercase tracking-widest mt-1 px-1.5 py-0.5 rounded border`,n),children:e.severity})]})]},e.id)})]})]}),e===`mandate`&&(0,Q.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,Q.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,Q.jsx)(h,{className:`w-5 h-5 text-shogun-gold`}),` About The Mandate`]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:`The Mandate is the Shogun's mission document. It defines the primary objectives, areas of responsibility, and operating principles that guide all decisions. Changes are injected into the Shogun's system prompt.`}),(0,Q.jsxs)(`div`,{className:`p-3 bg-shogun-gold/5 border border-shogun-gold/20 rounded-lg`,children:[(0,Q.jsx)(`div`,{className:`text-[9px] text-shogun-gold font-bold uppercase tracking-widest mb-1`,children:`⚡ System Integration`}),(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued`,children:`Key sections of this mandate are automatically injected into the Shogun's AI context on every interaction.`})]})]}),(0,Q.jsxs)(`div`,{className:`shogun-card bg-shogun-gold/5 border-shogun-gold/20`,children:[(0,Q.jsxs)(`h4`,{className:`text-xs font-bold text-shogun-gold flex items-center gap-2 mb-3`,children:[(0,Q.jsx)(u,{className:`w-4 h-4`}),` `,n(`kaizen.tab_revisions`,`REVISION HISTORY`)]}),(0,Q.jsxs)(`div`,{className:`space-y-3 max-h-[300px] overflow-y-auto`,children:[se.length===0&&(0,Q.jsx)(`div`,{className:`text-[10px] text-shogun-subdued text-center py-2`,children:`No revisions yet. Publish to create the first.`}),se.map((e,t)=>(0,Q.jsxs)(`div`,{className:v(`flex items-start gap-4`,t>2&&`opacity-50`),children:[(0,Q.jsx)(`div`,{className:v(`w-1.5 h-1.5 rounded-full mt-1.5`,t===0?`bg-shogun-gold`:`bg-shogun-subdued`)}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`text-[10px] text-shogun-text font-bold`,children:[e.document_type===`constitution`?`Constitution`:`Mandate`,` v`,e.version]}),(0,Q.jsx)(`div`,{className:`text-[9px] text-shogun-subdued`,children:e.change_summary}),e.created_at&&(0,Q.jsxs)(`div`,{className:`text-[8px] text-shogun-subdued mt-0.5`,children:[new Date(e.created_at).toLocaleDateString(),` `,new Date(e.created_at).toLocaleTimeString()]})]})]},e.id))]})]}),(0,Q.jsx)(`div`,{className:`p-4 text-center`,children:(0,Q.jsxs)(`button`,{onClick:pe,className:`flex items-center gap-2 mx-auto text-[10px] font-bold text-shogun-gold hover:text-shogun-text uppercase tracking-widest transition-all`,children:[(0,Q.jsx)(o,{className:`w-3.5 h-3.5`}),`Download Audit Log (.JSON)`]})})]})]})]})}export{gr as Kaizen}; \ No newline at end of file diff --git a/frontend/dist/assets/Katana-BO0tHRl7.js b/frontend/dist/assets/Katana-BO0tHRl7.js deleted file mode 100644 index 1e706a7..0000000 --- a/frontend/dist/assets/Katana-BO0tHRl7.js +++ /dev/null @@ -1,3 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{s as i}from"./chunk-OE4NN4TA-BT-WiWAe.js";import{t as a}from"./activity-D6ZKsL_W.js";import{t as o}from"./app-window-pINhreuP.js";import{t as s}from"./arrow-right-left-CsrIxDbC.js";import{t as c}from"./brain-circuit-DqQf8Qkj.js";import{t as l}from"./check-CBVCj3hp.js";import{t as u}from"./chevron-down-ZviArC66.js";import{t as d}from"./chevron-left-BFAWv4As.js";import{t as f}from"./chevron-right-BzAY5P9l.js";import{t as p}from"./chevron-up-NHCFdinU.js";import{t as m}from"./circle-alert-DVHRBFRQ.js";import{t as h}from"./circle-check-big-CjUNZrY8.js";import{t as g}from"./circle-check-D9mntLsp.js";import{t as _}from"./circle-x-dN_LIrKM.js";import{t as v}from"./code-xml-CCdcZbQg.js";import{t as y}from"./copy-B91lRfaY.js";import{t as b}from"./cpu-jON2DlCR.js";import{t as x}from"./crosshair-IDZ5dQs8.js";import{t as ee}from"./download-OoiqiOHD.js";import{t as S}from"./external-link-Cfo2qohD.js";import{t as C}from"./eye-DuX8zHAU.js";import{t as w}from"./file-spreadsheet-CsZ2n5Og.js";import{t as T}from"./file-text-Db8l8y7y.js";import{t as E}from"./folder-open-C_e4r6rd.js";import{n as D,t as O}from"./image-yFh82dFc.js";import{t as k}from"./git-branch-eFNiJwrC.js";import{t as A}from"./git-merge-B6sFCDV0.js";import{t as j}from"./globe-CSe1LLSr.js";import{t as M}from"./layers-4dQLphXM.js";import{t as te}from"./link-2-DtQcNcp-.js";import{t as N}from"./loader-circle-yHzGFbgr.js";import{t as ne}from"./lock-CYZB3Koj.js";import{t as re}from"./mail-CjEwmRbK.js";import{t as ie}from"./message-square-D4G-UYnF.js";import{t as ae}from"./monitor-DhSxAiCm.js";import{t as oe}from"./mouse-pointer-2-BrcQlceQ.js";import{t as se}from"./pause-kViKpNvP.js";import{n as ce,t as le}from"./route-B0unASBQ.js";import{t as ue}from"./plus-DFW_DMbT.js";import{t as de}from"./power-BmbVankB.js";import{t as P}from"./refresh-cw-CCrS0Omg.js";import{t as fe}from"./rotate-ccw-DsOLVoka.js";import{t as pe}from"./save-CJWuwqGS.js";import{t as me}from"./search-CCF8DUSp.js";import{t as he}from"./send-D9KRspSg.js";import{t as ge}from"./server-CMY38Yt2.js";import{t as _e}from"./shield-alert-ClN8pu2X.js";import{t as F}from"./shield-check-4WxAMs16.js";import{t as ve}from"./shield-B_MY4jWU.js";import{t as ye}from"./skull-2psdmx40.js";import{t as be}from"./sliders-horizontal-D4RY2Aan.js";import{t as xe}from"./sparkles-DddBjN-5.js";import{t as Se}from"./star-HhdEV9Ok.js";import{t as Ce}from"./target-DVSHvQpc.js";import{t as we}from"./trash-2-Cid5DKqF.js";import{t as Te}from"./triangle-alert-BwzZbklP.js";import{t as Ee}from"./users-D7R1ctQe.js";import{t as De}from"./wifi-off-w9xzPgfT.js";import{t as I}from"./wifi-Df0GuaCb.js";import{t as Oe}from"./wrench-D1anTovu.js";import{t as ke}from"./x-Bu7rztmN.js";import{t as Ae}from"./zap-BMpqZS6N.js";import{t as L}from"./utils-wrb6h48Y.js";import{r as je}from"./i18n-FxgwkwP0.js";import{t as R}from"./axios-BPyV2soB.js";var Me=e(`beaker`,[[`path`,{d:`M4.5 3h15`,key:`c7n0jr`}],[`path`,{d:`M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3`,key:`m1uhx7`}],[`path`,{d:`M6 14h12`,key:`4cwo0f`}]]),Ne=e(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Pe=e(`dog`,[[`path`,{d:`M11.25 16.25h1.5L12 17z`,key:`w7jh35`}],[`path`,{d:`M16 14v.5`,key:`1lajdz`}],[`path`,{d:`M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309`,key:`u7s9ue`}],[`path`,{d:`M8 14v.5`,key:`1nzgdb`}],[`path`,{d:`M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5`,key:`v8hric`}]]),Fe=e(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=e(`file-check-corner`,[[`path`,{d:`M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6`,key:`g5mvt7`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14 20 2 2 4-4`,key:`15kota`}]]),Le=e(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),Re=e(`file-search`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]),ze=e(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),z=e(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Be=e(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),B=e(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),V=e(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),H=e(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),U=e(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Ve=e(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),He=e(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Ue=e(`star-off`,[[`path`,{d:`m10.344 4.688 1.181-2.393a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.237 3.152`,key:`19ctli`}],[`path`,{d:`m17.945 17.945.43 2.505a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a8 8 0 0 0 .4-.099`,key:`ptqqvy`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),We=e(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),W=t(n(),1),G=r(),Ge=[`help`,`status`,`agents`,`workflows`,`approvals`,`ask`,`run`,`pause`,`resume`,`summarize`,`logs`,`approve`,`reject`,`harakiri`],Ke={enabled:!1,deployment_mode:`dev`,tenant_mode:`single`,allowed_tenant_ids:[],bot_app_id:``,bot_name:`Shogun`,client_secret_ref:``,public_messaging_endpoint:``,valid_domains:[],graph_enabled:!1,proactive_enabled:!1,sso_enabled:!1,allowed_commands:Ge,allowed_channels:[],destructive_commands_enabled:!1,dual_approval_fleet:!0,approval_ttl_seconds:900};function qe({value:e,onChange:t,label:n,hint:r}){return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),className:`w-full flex items-center justify-between gap-4 text-left`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`block text-sm font-bold text-shogun-text`,children:n}),r&&(0,G.jsx)(`span`,{className:`block text-[10px] text-shogun-subdued mt-0.5`,children:r})]}),(0,G.jsx)(`span`,{className:L(`relative w-10 h-5 rounded-full border transition-all shrink-0`,e?`bg-shogun-blue border-shogun-blue`:`bg-[#050508] border-shogun-border`),children:(0,G.jsx)(`span`,{className:L(`absolute top-0.5 w-3.5 h-3.5 rounded-full bg-white transition-all`,e?`left-5`:`left-0.5`)})})]})}function Je(){let[e,t]=(0,W.useState)(`overview`),[n,r]=(0,W.useState)(Ke),[i,o]=(0,W.useState)(null),[s,c]=(0,W.useState)([]),[l,u]=(0,W.useState)([]),[d,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(!1),[h,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),b=async()=>{f(!0);try{let[e,t]=await Promise.all([R.get(`/api/v1/katana/teams/config`),R.get(`/api/v1/katana/teams/health`)]);r({...Ke,...e.data.data||{}}),o(t.data.data)}catch{_({ok:!1,text:`Could not load the Teams adapter configuration.`})}finally{f(!1)}};(0,W.useEffect)(()=>{b()},[]),(0,W.useEffect)(()=>{e===`identity`&&R.get(`/api/v1/katana/teams/users`).then(e=>c(e.data.data||[])),e===`audit`&&R.get(`/api/v1/katana/teams/commands`).then(e=>u(e.data.data||[]))},[e]);let x=async()=>{m(!0);try{let e={...Ke,...n};[`id`,`created_at`,`updated_at`,`last_inbound_at`,`last_outbound_at`,`last_error`].forEach(t=>delete e[t]),r((await R.put(`/api/v1/katana/teams/config`,e)).data.data),_({ok:!0,text:`Microsoft Teams configuration saved.`})}catch(e){_({ok:!1,text:e.response?.data?.detail?.[0]?.msg||`Configuration could not be saved.`})}finally{m(!1),setTimeout(()=>_(null),4e3)}},S=async e=>{try{await R.post(`/api/v1/katana/teams/${e?`enable`:`disable`}`),r(t=>({...t,enabled:e})),await b()}catch{_({ok:!1,text:`Adapter state could not be changed.`})}},C=async(e,t)=>{try{let n=await R({url:`/api/v1/katana/teams/${e}`,method:e.includes(`download`)?`GET`:`POST`,responseType:`blob`}),r=URL.createObjectURL(n.data),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}catch{_({ok:!1,text:`The requested package could not be generated.`})}},w=`w-full bg-[#050508] border border-shogun-border rounded-lg px-3 py-2.5 text-sm text-shogun-text focus:border-shogun-blue outline-none`,T=`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued`,E=[{id:`overview`,name:`Overview`,icon:a},{id:`setup`,name:`Setup Wizard`,icon:Oe},{id:`identity`,name:`Entra & Roles`,icon:Ee},{id:`security`,name:`Security Policy`,icon:F},{id:`audit`,name:`Audit Log`,icon:Ie},{id:`diagnostics`,name:`Diagnostics`,icon:P}];return d?(0,G.jsx)(`div`,{className:`py-24 flex justify-center`,children:(0,G.jsx)(N,{className:`w-7 h-7 text-shogun-blue animate-spin`})}):(0,G.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(ie,{className:`w-5 h-5 text-[#7B83EB]`}),` Microsoft Teams Adapter`]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Enterprise command channel governed by Katana and Gensui.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`span`,{className:L(`px-3 py-1.5 rounded-lg border text-[10px] font-bold uppercase tracking-widest`,i?.status===`healthy`?`bg-green-400/10 border-green-400/30 text-green-400`:`bg-amber-400/10 border-amber-400/30 text-amber-400`),children:i?.status===`healthy`?`Production ready`:n.enabled?`Needs attention`:`Disabled`}),(0,G.jsx)(`button`,{onClick:()=>S(!n.enabled),className:L(`px-4 py-2 rounded-lg text-xs font-bold border`,n.enabled?`border-red-400/30 text-red-400`:`border-green-400/30 text-green-400`),children:n.enabled?`Disable adapter`:`Enable adapter`})]})]}),h&&(0,G.jsxs)(`div`,{className:L(`p-3 rounded-lg border text-sm flex items-center gap-2`,h.ok?`bg-green-400/10 border-green-400/20 text-green-400`:`bg-red-400/10 border-red-400/20 text-red-400`),children:[h.ok?(0,G.jsx)(g,{className:`w-4 h-4`}):(0,G.jsx)(Te,{className:`w-4 h-4`}),h.text]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[220px_1fr] gap-5`,children:[(0,G.jsx)(`div`,{className:`shogun-card p-2 h-fit`,children:E.map(({id:n,name:r,icon:i})=>(0,G.jsxs)(`button`,{onClick:()=>t(n),className:L(`w-full flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-xs font-bold`,e===n?`bg-shogun-blue/15 text-shogun-blue`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,G.jsx)(i,{className:`w-4 h-4`}),r]},n))}),(0,G.jsxs)(`div`,{className:`space-y-5`,children:[e===`overview`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[[`Adapter`,n.enabled?`Enabled`:`Disabled`],[`Tenant`,i?.tenant_status||`Unknown`],[`SSO`,i?.sso_status||`Disabled`],[`Approvals`,String(i?.active_approvals??0)]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsx)(`p`,{className:T,children:e}),(0,G.jsx)(`p`,{className:`text-lg font-bold text-shogun-text mt-2 capitalize`,children:t})]},e))}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-sm text-shogun-text`,children:`Connection health`}),(i?.issues||[]).length?i.issues.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-amber-400`,children:[(0,G.jsx)(Te,{className:`w-3.5 h-3.5`}),e]},e)):(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-green-400`,children:[(0,G.jsx)(g,{className:`w-4 h-4`}),`Configuration checks passed.`]})]})]}),e===`setup`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`1. Deployment and tenant`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`A customer-hosted bridge is recommended for production.`})]}),(0,G.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Deployment mode`}),(0,G.jsxs)(`select`,{value:n.deployment_mode,onChange:e=>r({...n,deployment_mode:e.target.value}),className:L(w,`mt-1.5`),children:[(0,G.jsx)(`option`,{value:`dev`,children:`Local development + tunnel`}),(0,G.jsx)(`option`,{value:`bridge`,children:`Customer-hosted Teams Bridge`}),(0,G.jsx)(`option`,{value:`direct`,children:`Direct Shogun callback`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Tenant mode`}),(0,G.jsxs)(`select`,{value:n.tenant_mode,onChange:e=>r({...n,tenant_mode:e.target.value}),className:L(w,`mt-1.5`),children:[(0,G.jsx)(`option`,{value:`single`,children:`Single tenant`}),(0,G.jsx)(`option`,{value:`multi`,children:`Multi tenant`})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Allowed tenant IDs (one per line)`}),(0,G.jsx)(`textarea`,{value:(n.allowed_tenant_ids||[]).join(` -`),onChange:e=>r({...n,allowed_tenant_ids:e.target.value.split(/\s+/).filter(Boolean)}),rows:3,className:L(w,`mt-1.5 font-mono`)})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`2. Bot and public endpoint`}),(0,G.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Bot / App ID`}),(0,G.jsx)(`input`,{value:n.bot_app_id||``,onChange:e=>r({...n,bot_app_id:e.target.value}),className:L(w,`mt-1.5 font-mono`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Bot display name`}),(0,G.jsx)(`input`,{value:n.bot_name||``,onChange:e=>r({...n,bot_name:e.target.value}),className:L(w,`mt-1.5`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Client secret / certificate reference`}),(0,G.jsx)(`input`,{value:n.client_secret_ref||``,onChange:e=>r({...n,client_secret_ref:e.target.value}),className:L(w,`mt-1.5 font-mono`),placeholder:`vault://teams/bot-client-secret`}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-1`,children:`Only a secret reference is stored. Never paste the secret value here.`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Public messaging endpoint`}),(0,G.jsx)(`input`,{value:n.public_messaging_endpoint||``,onChange:e=>r({...n,public_messaging_endpoint:e.target.value}),className:L(w,`mt-1.5 font-mono`),placeholder:`https://teams-bridge.example.com/api/teams/messages`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Valid domains (comma separated)`}),(0,G.jsx)(`input`,{value:(n.valid_domains||[]).join(`, `),onChange:e=>r({...n,valid_domains:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),className:L(w,`mt-1.5 font-mono`)})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card flex flex-wrap gap-3`,children:[(0,G.jsxs)(`button`,{onClick:x,disabled:p,className:`px-4 py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold flex items-center gap-2`,children:[p?(0,G.jsx)(N,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(pe,{className:`w-4 h-4`}),`Save configuration`]}),(0,G.jsxs)(`button`,{onClick:()=>C(`manifest/download`,`shogun-teams-app.zip`),className:`px-4 py-2.5 border border-shogun-border rounded-lg text-xs font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(ee,{className:`w-4 h-4`}),`Generate Teams app package`]})]})]}),e===`identity`&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsxs)(`div`,{className:`grid md:grid-cols-3 gap-5 pb-4 border-b border-shogun-border`,children:[(0,G.jsx)(qe,{label:`Microsoft Entra SSO`,hint:`Required for production identity assurance.`,value:n.sso_enabled,onChange:e=>r({...n,sso_enabled:e})}),(0,G.jsx)(qe,{label:`Microsoft Graph`,hint:`Tenant app operations.`,value:n.graph_enabled,onChange:e=>r({...n,graph_enabled:e})}),(0,G.jsx)(qe,{label:`Proactive messaging`,hint:`Installed conversations only.`,value:n.proactive_enabled,onChange:e=>r({...n,proactive_enabled:e})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`Teams user mappings`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`New identities enter as Viewer until deliberately promoted.`})]}),(0,G.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-left text-shogun-subdued border-b border-shogun-border`,children:[(0,G.jsx)(`th`,{className:`py-2`,children:`User`}),(0,G.jsx)(`th`,{children:`UPN`}),(0,G.jsx)(`th`,{children:`Tenant`}),(0,G.jsx)(`th`,{children:`Role`})]})}),(0,G.jsx)(`tbody`,{children:s.map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`py-3 text-shogun-text font-bold`,children:e.display_name}),(0,G.jsx)(`td`,{children:e.user_principal_name||`—`}),(0,G.jsx)(`td`,{className:`font-mono`,children:e.tenant_id}),(0,G.jsx)(`td`,{className:`capitalize`,children:e.shogun_role.replace(`_`,` `)})]},e.id))})]}),!s.length&&(0,G.jsx)(`p`,{className:`text-center py-10 text-shogun-subdued italic`,children:`No Teams identities observed yet.`})]}),(0,G.jsxs)(`button`,{onClick:x,className:`px-4 py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold flex items-center gap-2`,children:[(0,G.jsx)(pe,{className:`w-4 h-4`}),`Save identity settings`]})]}),e===`security`&&(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`Command policy`}),(0,G.jsx)(`div`,{className:`grid sm:grid-cols-2 lg:grid-cols-3 gap-2`,children:Ge.map(e=>{let t=n.allowed_commands?.includes(e);return(0,G.jsxs)(`button`,{onClick:()=>r({...n,allowed_commands:t?n.allowed_commands.filter(t=>t!==e):[...n.allowed_commands,e]}),className:L(`px-3 py-2 rounded-lg border text-xs text-left capitalize`,t?`border-shogun-blue/30 bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued`),children:[e,(0,G.jsx)(`span`,{className:`float-right`,children:[`harakiri`,`pause`,`resume`].includes(e)?`L4`:[`approve`,`reject`].includes(e)?`L3`:`L0–L2`})]},e)})})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(qe,{label:`Allow destructive commands to enter approval flow`,hint:`This never bypasses Gensui confirmation.`,value:n.destructive_commands_enabled,onChange:e=>r({...n,destructive_commands_enabled:e})}),(0,G.jsx)(qe,{label:`Dual approval for fleet shutdown`,value:n.dual_approval_fleet,onChange:e=>r({...n,dual_approval_fleet:e})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:T,children:`Approval expiry (seconds)`}),(0,G.jsx)(`input`,{type:`number`,min:60,max:86400,value:n.approval_ttl_seconds,onChange:e=>r({...n,approval_ttl_seconds:Number(e.target.value)}),className:L(w,`mt-1.5 max-w-xs`)})]}),(0,G.jsx)(`div`,{className:`p-3 rounded-lg border border-amber-400/20 bg-amber-400/5 text-xs text-amber-300`,children:`Attachments are rejected by default. High-risk free-form input cannot invoke tools directly.`}),(0,G.jsxs)(`button`,{onClick:x,className:`px-4 py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold flex items-center gap-2`,children:[(0,G.jsx)(pe,{className:`w-4 h-4`}),`Save security policy`]})]})]}),e===`audit`&&(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between mb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`Command audit`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Authorization decisions and outcomes.`})]}),(0,G.jsxs)(`button`,{onClick:()=>C(`diagnostics/export`,`shogun-teams-diagnostics.json`),className:`text-xs text-shogun-blue flex items-center gap-1`,children:[(0,G.jsx)(ee,{className:`w-3.5 h-3.5`}),`Export safe bundle`]})]}),(0,G.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-left text-shogun-subdued border-b border-shogun-border`,children:[(0,G.jsx)(`th`,{className:`py-2`,children:`Time`}),(0,G.jsx)(`th`,{children:`Command`}),(0,G.jsx)(`th`,{children:`Risk`}),(0,G.jsx)(`th`,{children:`Decision`}),(0,G.jsx)(`th`,{children:`Correlation`})]})}),(0,G.jsx)(`tbody`,{children:l.map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`py-3`,children:new Date(e.created_at).toLocaleString()}),(0,G.jsx)(`td`,{children:e.command_name}),(0,G.jsx)(`td`,{children:e.risk_level}),(0,G.jsx)(`td`,{className:e.success?`text-green-400`:`text-red-400`,children:e.authorization_result}),(0,G.jsxs)(`td`,{className:`font-mono`,children:[e.correlation_id.slice(0,8),`…`]})]},e.id))})]}),!l.length&&(0,G.jsx)(`p`,{className:`text-center py-10 text-shogun-subdued italic`,children:`No Teams commands audited yet.`})]})]}),e===`diagnostics`&&(0,G.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[[[`Shogun backend`,`test/backend`],[`Microsoft Graph credentials`,`test/graph`],[`Proactive messaging`,`test/proactive-message`],[`Teams manifest`,`manifest/validate`]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:e}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1 mb-4`,children:`Run a non-destructive configuration check.`}),(0,G.jsx)(`button`,{onClick:async()=>{try{y({name:e,...(await R.post(`/api/v1/katana/teams/${t}`)).data.data})}catch(t){y({name:e,ok:!1,error:t.message})}},className:`px-3 py-2 border border-shogun-border rounded-lg text-xs font-bold text-shogun-text`,children:`Run test`})]},t)),v&&(0,G.jsxs)(`div`,{className:`md:col-span-2 shogun-card`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold`,children:v.name}),(0,G.jsx)(`pre`,{className:`mt-3 p-3 bg-[#050508] rounded-lg text-[10px] text-shogun-subdued overflow-auto`,children:JSON.stringify(v,null,2)})]})]})]})]})]})}var Ye=`#06b6d4`,Xe=[`Overview`,`Sessions`,`Screenshots`,`Permissions`,`Advanced`];function Ze(){let[e,t]=(0,W.useState)(`Overview`),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)([]),[s,c]=(0,W.useState)([]),[l,u]=(0,W.useState)([]),[p,m]=(0,W.useState)({}),[h,v]=(0,W.useState)(!1),[y,b]=(0,W.useState)(!0),[x,C]=(0,W.useState)(!1),[w,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),[k,A]=(0,W.useState)(null),j=(0,W.useMemo)(()=>i.find(e=>e.profile_name===`native_skill`)||null,[i]),M=(0,W.useCallback)(async()=>{try{let[e,t,n]=await Promise.all([R.get(`/api/v1/mado/status`),R.get(`/api/v1/mado/sessions`),R.get(`/api/v1/mado/screenshots`)]);r(e.data?.data||null),u(e.data?.meta?.runtime_sessions||[]),m(e.data?.meta?.config||{}),a(t.data?.data||[]),c(n.data?.data||[])}catch(e){D({type:`error`,text:(R.isAxiosError(e)?e.response?.data?.detail:``)||`Mado status could not be loaded.`})}finally{b(!1)}},[]);(0,W.useEffect)(()=>{M()},[M]);let te=async()=>{C(!0),D(null);try{let e=(await R.post(`/api/v1/mado/install`)).data?.data;if(!e?.success)throw Error(e?.error||`Chromium installation failed.`);D({type:`success`,text:`Chromium installed. Mado is ready.`}),await M()}catch(e){D({type:`error`,text:(R.isAxiosError(e)?e.response?.data?.detail:e instanceof Error?e.message:``)||`Chromium installation failed.`})}finally{C(!1)}},ne=async e=>{T(e.id),D(null);try{await R.delete(`/api/v1/mado/sessions/${e.id}`),D({type:`success`,text:e.profile_name===`native_skill`?`Agent browser reset. Shogun will create a clean session when it browses again.`:`Browser session “${e.name}” removed.`}),await M()}catch(e){D({type:`error`,text:(R.isAxiosError(e)?e.response?.data?.detail:``)||`The browser session could not be reset.`})}finally{T(null)}},re=async(e,t)=>{T(e.id),D(null);try{await R.post(`/api/v1/mado/sessions/${e.id}/${t}`),D({type:`success`,text:`Mado session ${t}d.`}),await M()}catch(e){D({type:`error`,text:(R.isAxiosError(e)?e.response?.data?.detail:``)||`Could not ${t} the Mado session.`})}finally{T(null)}};return y?(0,G.jsx)(`div`,{className:`flex min-h-[420px] items-center justify-center bg-[#0a0e1a]`,children:(0,G.jsx)(N,{className:`h-8 w-8 animate-spin`,style:{color:Ye}})}):(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden bg-[#0a0e1a]`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[#1a2040] px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl`,style:{background:`${Ye}12`,border:`1px solid ${Ye}30`},children:(0,G.jsx)(o,{className:`h-5 w-5`,style:{color:Ye}})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-bold tracking-tight text-[#c8d0d8]`,children:`Mado`}),(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Managed browser runtime`})]})]}),(0,G.jsx)(`button`,{onClick:M,className:`rounded-lg border border-[#1a2040] p-2 text-[#7a8899] transition-colors hover:text-[#c8d0d8]`,title:`Refresh Mado status`,children:(0,G.jsx)(P,{className:`h-4 w-4`})})]}),E&&(0,G.jsxs)(`div`,{className:L(`flex items-center gap-2 border-b px-6 py-3 text-xs font-semibold`,E.type===`success`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-300`:`border-red-500/20 bg-red-500/10 text-red-300`),children:[E.type===`success`?(0,G.jsx)(g,{className:`h-4 w-4 shrink-0`}):(0,G.jsx)(_,{className:`h-4 w-4 shrink-0`}),E.text]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 border-b border-[#1a2040] px-6 pt-3`,children:Xe.map(n=>(0,G.jsx)(`button`,{onClick:()=>t(n),className:L(`-mb-px border-b-2 px-4 py-2.5 text-[11px] font-bold uppercase tracking-wider transition-colors`,e===n?`border-cyan-500 text-cyan-400`:`border-transparent text-[#7a8899] hover:text-[#c8d0d8]`),children:n},n))}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[l.some(e=>e.status===`active`)&&(0,G.jsxs)(`div`,{className:`mx-auto mb-5 flex max-w-4xl items-center justify-between rounded-xl border border-cyan-400/40 bg-cyan-500/10 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`span`,{className:`relative flex h-3 w-3`,children:[(0,G.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-cyan-400 opacity-60`}),(0,G.jsx)(`span`,{className:`relative inline-flex h-3 w-3 rounded-full bg-cyan-400`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-bold text-cyan-200`,children:`MADO BROWSER ACTIVE`}),(0,G.jsx)(`p`,{className:`text-[9px] text-cyan-200/60`,children:`Browser actions are visible, verified, recoverable, and audited.`})]})]}),(0,G.jsx)(`button`,{onClick:async()=>{confirm(`Stop every active Mado browser session now? Logs and artifacts will be preserved.`)&&(await R.post(`/api/v1/mado/kill-switch`),D({type:`success`,text:`Mado kill switch stopped all active browser sessions.`}),await M())},className:`rounded-lg border border-red-400/40 bg-red-500/10 px-3 py-2 text-[9px] font-bold uppercase tracking-wider text-red-300 hover:bg-red-500/20`,children:`Stop all sessions`})]}),e===`Overview`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,G.jsx)(Qe,{title:`Browser engine`,value:n?.installed?`Ready`:`Not installed`,detail:n?.version||`Managed Chromium`,healthy:!!n?.installed}),(0,G.jsx)(Qe,{title:`Agent browser`,value:j?j.status:`Starts automatically`,detail:j?.last_url||`Created when Shogun first browses`,healthy:!!(j&&j.status!==`error`)}),(0,G.jsx)(Qe,{title:`Active sessions`,value:String(n?.active_sessions||0),detail:`Limited by the active Torii posture`,healthy:!0})]}),(0,G.jsx)(`div`,{className:`rounded-xl border border-cyan-500/20 bg-cyan-500/[0.06] p-5`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(F,{className:`mt-0.5 h-5 w-5 shrink-0 text-cyan-400`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Permissions belong to Torii`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-[#7a8899]`,children:`Mado does not maintain a second permission system. The active security posture controls whether Shogun may browse, use visible sessions, download or upload files, and how many browser sessions may run.`}),(0,G.jsxs)(`a`,{href:`/torii`,className:`mt-3 inline-flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-cyan-400 hover:text-cyan-300`,children:[`Open Torii permissions`,(0,G.jsx)(S,{className:`h-3 w-3`})]})]})]})}),!n?.installed&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225] p-5`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Install the browser engine`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-[#7a8899]`,children:`Chromium is the only component Mado needs before Shogun can browse.`}),(0,G.jsxs)(`button`,{onClick:te,disabled:x,className:`mt-4 inline-flex items-center gap-2 rounded-lg bg-cyan-500 px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#071018] disabled:opacity-50`,children:[x?(0,G.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(ee,{className:`h-3.5 w-3.5`}),x?`Installing…`:`Install Chromium`]})]}),j&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-[#1a2040] bg-[#0e1225] p-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Agent browser session`}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-[#7a8899]`,children:j.last_url||`No page visited yet`})]}),(0,G.jsxs)(`button`,{onClick:()=>ne(j),disabled:w===j.id,className:`ml-4 inline-flex shrink-0 items-center gap-2 rounded-lg border border-[#1a2040] px-3 py-2 text-[10px] font-bold uppercase tracking-wider text-[#7a8899] hover:border-cyan-500/40 hover:text-cyan-400 disabled:opacity-50`,children:[w===j.id?(0,G.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(fe,{className:`h-3.5 w-3.5`}),`Reset`]})]})]}),e===`Sessions`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-widest text-[#7a8899]`,children:`Live browser sessions`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-[#555]`,children:`Runtime state, Stack association, verification, errors, and recent trajectory.`})]}),i.length===0?(0,G.jsx)(`div`,{className:`rounded-xl border border-[#1a2040] p-10 text-center text-xs text-[#7a8899]`,children:`No Mado sessions.`}):i.map(e=>{let t=l.find(t=>t.session_id===e.id),n=t?.timeline||e.session_data?.action_history||[];return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-[#1a2040] bg-[#0e1225]`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between border-b border-[#1a2040] p-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:L(`h-2 w-2 rounded-full`,(t?.status||e.status)===`active`?`bg-emerald-400`:(t?.status||e.status)===`error`?`bg-red-400`:`bg-amber-400`)}),(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8]`,children:e.name}),(0,G.jsx)(`span`,{className:`rounded bg-cyan-500/10 px-1.5 py-0.5 text-[8px] uppercase text-cyan-300`,children:t?.mode||e.browser_mode})]}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-[10px] text-[#7a8899]`,children:t?.title||t?.current_url||e.last_url||`No page loaded`}),(0,G.jsxs)(`p`,{className:`mt-1 text-[8px] text-[#555]`,children:[`Profile `,t?.profile_id||e.profile_name,` · Posture `,t?.posture||e.session_data?.posture||`current`,` · Stack `,t?.stack_run_id||e.session_data?.stack_run_id||`standalone`]})]}),(0,G.jsxs)(`div`,{className:`ml-4 flex gap-1`,children:[(t?.status||e.status)===`paused`?(0,G.jsx)(`button`,{title:`Resume`,onClick:()=>re(e,`resume`),className:`rounded p-2 text-emerald-400 hover:bg-emerald-500/10`,children:(0,G.jsx)(ce,{className:`h-4 w-4`})}):(0,G.jsx)(`button`,{title:`Pause`,onClick:()=>re(e,`pause`),className:`rounded p-2 text-amber-400 hover:bg-amber-500/10`,children:(0,G.jsx)(se,{className:`h-4 w-4`})}),(0,G.jsx)(`button`,{title:`Close`,onClick:()=>re(e,`close`),className:`rounded p-2 text-red-400 hover:bg-red-500/10`,children:(0,G.jsx)(ke,{className:`h-4 w-4`})})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-3 p-4 md:grid-cols-4`,children:[(0,G.jsx)($e,{label:`Last action`,value:t?.last_action||e.session_data?.last_action||`None`}),(0,G.jsx)($e,{label:`Verification`,value:t?.last_verification?.status||e.session_data?.last_verification?.status||`Pending`}),(0,G.jsx)($e,{label:`Retries`,value:String(t?.retry_count||0)}),(0,G.jsx)($e,{label:`Status`,value:t?.last_error||e.session_data?.last_error||t?.status||e.status,danger:!!(t?.last_error||e.session_data?.last_error)})]}),n.length>0&&(0,G.jsxs)(`div`,{className:`border-t border-[#1a2040] p-4`,children:[(0,G.jsx)(`p`,{className:`mb-2 text-[8px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Recent execution trajectory`}),(0,G.jsx)(`div`,{className:`max-h-40 space-y-1 overflow-y-auto`,children:n.slice(-8).reverse().map((e,t)=>(0,G.jsxs)(`div`,{className:`flex gap-3 rounded bg-[#080b15] px-2 py-1.5 text-[9px]`,children:[(0,G.jsx)(`span`,{className:`w-16 shrink-0 text-[#555]`,children:e.timestamp?new Date(e.timestamp).toLocaleTimeString():``}),(0,G.jsx)(`span`,{className:`w-44 shrink-0 text-cyan-400`,children:e.event_type||e.action}),(0,G.jsx)(`span`,{className:`truncate text-[#7a8899]`,children:e.message||e.status||e.error})]},`${e.timestamp}-${t}`))})]})]},e.id)})]}),e===`Screenshots`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-widest text-[#7a8899]`,children:`Captured screenshots`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-[#555]`,children:`Evidence captured by Shogun and AgentFlow browser tasks`})]}),(0,G.jsx)(`button`,{onClick:M,className:`rounded-lg p-2 text-[#7a8899] hover:bg-[#1a2040] hover:text-[#c8d0d8]`,children:(0,G.jsx)(P,{className:`h-3.5 w-3.5`})})]}),s.length===0?(0,G.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,G.jsx)(O,{className:`mx-auto h-10 w-10 text-cyan-500/30`}),(0,G.jsx)(`p`,{className:`mt-3 text-sm text-[#7a8899]`,children:`No screenshots yet`})]}):(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4`,children:s.map((e,t)=>(0,G.jsxs)(`button`,{onClick:()=>A(t),className:`group overflow-hidden rounded-xl border border-[#1a2040] bg-[#0e1225] text-left hover:border-cyan-500/40`,children:[(0,G.jsxs)(`div`,{className:`relative aspect-video overflow-hidden bg-[#080b15]`,children:[(0,G.jsx)(`img`,{src:`/mado/screenshots/${e.filename}`,alt:e.filename,className:`h-full w-full object-cover opacity-80 transition-all group-hover:scale-105 group-hover:opacity-100`}),(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/30`,children:(0,G.jsx)(V,{className:`h-5 w-5 text-white opacity-0 transition-opacity group-hover:opacity-100`})})]}),(0,G.jsxs)(`div`,{className:`p-3`,children:[(0,G.jsx)(`p`,{className:`truncate text-[10px] font-bold text-[#c8d0d8]`,children:e.filename}),(0,G.jsxs)(`p`,{className:`mt-1 text-[8px] text-[#555]`,children:[(e.size_bytes/1024).toFixed(1),` KB`]})]})]},e.filename))})]}),e===`Permissions`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[(0,G.jsx)(`div`,{className:`rounded-xl border border-amber-400/25 bg-amber-500/[0.06] p-4`,children:(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(_e,{className:`h-5 w-5 shrink-0 text-amber-400`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-amber-200`,children:`Mado Browser permissions`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-[#7a8899]`,children:`These settings narrow the active Torii posture. They never grant capabilities that the posture blocks. Authenticated profiles and external URLs remain opt-in.`})]})]})}),(0,G.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[[[`enabled`,`Enable Mado`,`Allow governed browser sessions`],[`headless_allowed`,`Allow headless mode`,`Run managed browser sessions without a window`],[`visible_allowed`,`Allow visible mode`,`Show Chromium while Mado operates`],[`allow_external_urls`,`Allow external URLs`,`Permit URLs outside the configured domain list`],[`allow_persistent_profiles`,`Allow persistent profiles`,`Keep local browser state between sessions`],[`allow_authenticated_sessions`,`Allow authenticated sessions`,`Use profiles that may contain saved login state`],[`require_verification`,`Require verification`,`Verify key browser outcomes before completion`]].map(([e,t,n])=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-bold text-[#c8d0d8]`,children:t}),(0,G.jsx)(`p`,{className:`mt-1 text-[9px] text-[#555]`,children:n})]}),(0,G.jsx)(`input`,{type:`checkbox`,checked:!!p[e],onChange:t=>m(n=>({...n,[e]:t.target.checked})),className:`h-4 w-4 accent-cyan-500`})]},e)),(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-bold text-[#c8d0d8]`,children:`Capture evidence screenshots`}),(0,G.jsx)(`p`,{className:`mt-1 text-[9px] text-[#555]`,children:`Save visual evidence on errors and verification`})]}),(0,G.jsx)(`input`,{type:`checkbox`,checked:!!(p.audit?.capture_screenshots_on_error&&p.audit?.capture_screenshots_on_verification),onChange:e=>m(t=>({...t,audit:{...t.audit||{},capture_screenshots_on_error:e.target.checked,capture_screenshots_on_verification:e.target.checked,log_all_actions:!0}})),className:`h-4 w-4 accent-cyan-500`})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 rounded-xl border border-[#1a2040] bg-[#0e1225] p-4 md:grid-cols-2`,children:[(0,G.jsx)(et,{label:`Allowed domains`,value:(p.allowed_domains||[]).join(`, `),onChange:e=>m(t=>({...t,allowed_domains:e.split(`,`).map(e=>e.trim()).filter(Boolean)}))}),(0,G.jsx)(et,{label:`Blocked domains`,value:(p.blocked_domains||[]).join(`, `),onChange:e=>m(t=>({...t,blocked_domains:e.split(`,`).map(e=>e.trim()).filter(Boolean)}))}),(0,G.jsx)(nt,{label:`Default browser mode`,value:p.default_mode||`visible`,options:[`visible`,`headless`],onChange:e=>m(t=>({...t,default_mode:e}))}),(0,G.jsx)(nt,{label:`File downloads`,value:p.allow_file_downloads||`approval`,options:[`blocked`,`approval`,`allowed`],onChange:e=>m(t=>({...t,allow_file_downloads:e}))}),(0,G.jsx)(nt,{label:`File uploads`,value:p.allow_file_uploads||`approval`,options:[`blocked`,`approval`,`allowed`],onChange:e=>m(t=>({...t,allow_file_uploads:e}))}),(0,G.jsx)(nt,{label:`Form submission`,value:p.allow_form_submit||`approval`,options:[`blocked`,`approval`,`allowed`],onChange:e=>m(t=>({...t,allow_form_submit:e}))}),(0,G.jsx)(tt,{label:`Maximum pages per run`,value:p.max_pages_per_run||50,onChange:e=>m(t=>({...t,max_pages_per_run:e}))}),(0,G.jsx)(tt,{label:`Maximum runtime (seconds)`,value:p.max_runtime_seconds||1800,onChange:e=>m(t=>({...t,max_runtime_seconds:e}))})]}),(0,G.jsxs)(`button`,{onClick:async()=>{v(!0);try{let e=Object.fromEntries([`enabled`,`default_mode`,`headless_allowed`,`visible_allowed`,`allowed_domains`,`blocked_domains`,`allow_external_urls`,`allow_persistent_profiles`,`allow_authenticated_sessions`,`allow_file_downloads`,`allow_file_uploads`,`allow_form_submit`,`require_verification`,`max_pages_per_run`,`max_runtime_seconds`,`default_navigation_timeout_ms`,`default_action_timeout_ms`,`retry`,`page_readiness`,`audit`].filter(e=>e in p).map(e=>[e,p[e]]));m((await R.patch(`/api/v1/mado/config`,e)).data?.data||p),D({type:`success`,text:`Mado permissions and reliability settings saved.`})}catch(e){D({type:`error`,text:(R.isAxiosError(e)?e.response?.data?.detail:``)||`Mado settings could not be saved.`})}finally{v(!1)}},disabled:h,className:`inline-flex items-center gap-2 rounded-lg bg-cyan-500 px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#071018] disabled:opacity-50`,children:[h?(0,G.jsx)(N,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(F,{className:`h-4 w-4`}),` Save Mado settings`]})]}),e===`Advanced`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-widest text-[#7a8899]`,children:`Advanced diagnostics`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-[#555]`,children:`Runtime details for troubleshooting. Browser permissions remain in Torii.`})]}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225]`,children:[(0,G.jsx)(`div`,{className:`border-b border-[#1a2040] px-4 py-3 text-xs font-bold text-[#c8d0d8]`,children:`Runtime sessions`}),i.length===0?(0,G.jsx)(`p`,{className:`p-5 text-xs text-[#7a8899]`,children:`No browser sessions have been created.`}):i.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-[#1a2040]/70 px-4 py-3 last:border-0`,children:[(0,G.jsx)(`div`,{className:L(`h-2 w-2 shrink-0 rounded-full`,e.status===`active`?`bg-emerald-400`:e.status===`error`?`bg-red-400`:`bg-[#7a8899]`)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold text-[#c8d0d8]`,children:e.name}),e.profile_name===`native_skill`&&(0,G.jsx)(`span`,{className:`rounded bg-cyan-500/10 px-1.5 py-0.5 text-[8px] font-bold uppercase text-cyan-400`,children:`Agent managed`})]}),(0,G.jsxs)(`p`,{className:`mt-0.5 truncate text-[9px] text-[#555]`,children:[e.profile_name,` · `,e.browser_mode,` · `,e.last_url||`No URL`]})]}),(0,G.jsx)(`button`,{onClick:()=>ne(e),disabled:w===e.id,title:`Remove browser session`,className:`rounded-lg p-2 text-[#7a8899] hover:bg-red-500/10 hover:text-red-400 disabled:opacity-50`,children:w===e.id?(0,G.jsx)(N,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(we,{className:`h-3.5 w-3.5`})})]},e.id))]}),n&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8]`,children:`Storage paths`}),(0,G.jsx)(`div`,{className:`mt-3 space-y-2`,children:[[`Profiles`,n.profiles_path],[`Screenshots`,n.screenshots_path],[`Downloads`,n.downloads_path]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex gap-4 text-[10px]`,children:[(0,G.jsx)(`span`,{className:`w-24 shrink-0 font-bold uppercase tracking-wider text-[#7a8899]`,children:e}),(0,G.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[#555]`,children:t})]},e))})]})]})]}),k!==null&&s[k]&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/85 backdrop-blur-sm`,onClick:()=>A(null),children:[(0,G.jsx)(`button`,{onClick:()=>A(null),className:`absolute right-4 top-4 rounded-full bg-black/50 p-2 text-white/80 hover:text-white`,children:(0,G.jsx)(ke,{className:`h-5 w-5`})}),k>0&&(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),A(k-1)},className:`absolute left-4 rounded-full bg-black/50 p-2 text-white/80 hover:text-white`,children:(0,G.jsx)(d,{className:`h-6 w-6`})}),k{e.stopPropagation(),A(k+1)},className:`absolute right-4 rounded-full bg-black/50 p-2 text-white/80 hover:text-white`,children:(0,G.jsx)(f,{className:`h-6 w-6`})}),(0,G.jsx)(`img`,{src:`/mado/screenshots/${s[k].filename}`,alt:s[k].filename,className:`max-h-[85vh] max-w-[90vw] rounded-lg object-contain shadow-2xl`,onClick:e=>e.stopPropagation()})]})]})}function Qe({title:e,value:t,detail:n,healthy:r}){return(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:L(`h-2 w-2 rounded-full`,r?`bg-emerald-400`:`bg-amber-400`)}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-[#7a8899]`,children:e})]}),(0,G.jsx)(`p`,{className:`mt-3 truncate text-sm font-bold capitalize text-[#c8d0d8]`,children:t}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-[9px] text-[#555]`,children:n})]})}function $e({label:e,value:t,danger:n=!1}){return(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#080b15] p-3`,children:[(0,G.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-widest text-[#555]`,children:e}),(0,G.jsx)(`p`,{className:L(`mt-2 truncate text-[10px] font-semibold`,n?`text-red-300`:`text-[#c8d0d8]`),children:t})]})}function et({label:e,value:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`text-[9px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[e,(0,G.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`example.com, portal.example.com`,className:`mt-2 w-full rounded-lg border border-[#1a2040] bg-[#080b15] px-3 py-2 text-xs font-normal normal-case text-[#c8d0d8] outline-none focus:border-cyan-500/50`})]})}function tt({label:e,value:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`text-[9px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[e,(0,G.jsx)(`input`,{type:`number`,min:1,value:t,onChange:e=>n(Math.max(1,Number(e.target.value))),className:`mt-2 w-full rounded-lg border border-[#1a2040] bg-[#080b15] px-3 py-2 text-xs font-normal text-[#c8d0d8] outline-none focus:border-cyan-500/50`})]})}function nt({label:e,value:t,options:n,onChange:r}){return(0,G.jsxs)(`label`,{className:`text-[9px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[e,(0,G.jsx)(`select`,{value:t,onChange:e=>r(e.target.value),className:`mt-2 w-full rounded-lg border border-[#1a2040] bg-[#080b15] px-3 py-2 text-xs font-normal capitalize text-[#c8d0d8] outline-none focus:border-cyan-500/50`,children:n.map(e=>(0,G.jsx)(`option`,{value:e,children:e.replaceAll(`_`,` `)},e))})]})}var K=`#f97316`,rt=`#f9731620`,it=`#f9731640`,at=[`Control`,`Sessions`,`App Trust`,`Capabilities`,`Audit Trail`],ot={idle:{bg:`rgba(249,115,22,0.08)`,text:`#f97316`,dot:`#f97316`},active:{bg:`rgba(34,197,94,0.08)`,text:`#22c55e`,dot:`#22c55e`},paused:{bg:`rgba(234,179,8,0.08)`,text:`#eab308`,dot:`#eab308`},error:{bg:`rgba(239,68,68,0.08)`,text:`#ef4444`,dot:`#ef4444`},closed:{bg:`rgba(122,136,153,0.08)`,text:`#7a8899`,dot:`#7a8899`}},st={trusted:{bg:`rgba(34,197,94,0.10)`,text:`#22c55e`,label:`TRUSTED`},restricted:{bg:`rgba(234,179,8,0.10)`,text:`#eab308`,label:`RESTRICTED`},sensitive:{bg:`rgba(249,115,22,0.10)`,text:`#f97316`,label:`SENSITIVE`},forbidden:{bg:`rgba(239,68,68,0.10)`,text:`#ef4444`,label:`FORBIDDEN`}},ct={low:{bg:`rgba(34,197,94,0.10)`,text:`#22c55e`},medium:{bg:`rgba(234,179,8,0.10)`,text:`#eab308`},high:{bg:`rgba(249,115,22,0.10)`,text:`#f97316`},critical:{bg:`rgba(239,68,68,0.10)`,text:`#ef4444`}},lt={physical:B,vm:ge,sandbox:ne,remote_desktop:ae,citrix:ae,cloud_workspace:Ne},ut={1:{label:`PAUSE`,color:`#eab308`,desc:`Pause session on human input`},2:{label:`TERMINATE`,color:`#f97316`,desc:`Kill active session on input`},3:{label:`HARAKIRI`,color:`#ef4444`,desc:`Full emergency stop on input`}};function dt(){let[e,t]=(0,W.useState)(`Control`),[n,r]=(0,W.useState)(null),[i,o]=(0,W.useState)([]),[s,c]=(0,W.useState)([]),[l,u]=(0,W.useState)([]),[d,p]=(0,W.useState)([]),[m,h]=(0,W.useState)([]),[v,y]=(0,W.useState)(!0),[b,x]=(0,W.useState)(!1),[ee,S]=(0,W.useState)(!1),[w,T]=(0,W.useState)(``),[E,D]=(0,W.useState)(`observe_only`),[O,k]=(0,W.useState)(1),[A,j]=(0,W.useState)(!1),[M,te]=(0,W.useState)(null),[re,ie]=(0,W.useState)(`desktop.screenshot`),[se,le]=(0,W.useState)(``),[de,fe]=(0,W.useState)(``),[pe,me]=(0,W.useState)(``),[he,ve]=(0,W.useState)(!1),[be,xe]=(0,W.useState)(null),[Se,Te]=(0,W.useState)(`all`),[Ee,De]=(0,W.useState)(`all`),I=(0,W.useCallback)(async()=>{try{r((await R.get(`/api/v1/ronin/status`)).data?.data)}catch{}},[]),Oe=(0,W.useCallback)(async()=>{try{o((await R.get(`/api/v1/ronin/sessions`)).data?.data||[])}catch{}},[]),ke=(0,W.useCallback)(async()=>{try{c((await R.get(`/api/v1/ronin/trust`)).data?.data||[])}catch{}},[]),je=(0,W.useCallback)(async()=>{try{u((await R.get(`/api/v1/ronin/capabilities`)).data?.data||[])}catch{}},[]),Me=(0,W.useCallback)(async()=>{try{p((await R.get(`/api/v1/ronin/approvals`)).data?.data||[])}catch{}},[]),Ne=(0,W.useCallback)(async()=>{try{h((await R.get(`/api/v1/ronin/audit?limit=100`)).data?.data||[])}catch{}},[]);(0,W.useEffect)(()=>{Promise.all([I(),Oe(),ke(),je(),Me(),Ne()]).finally(()=>y(!1))},[I,Oe,ke,je,Me,Ne]),(0,W.useEffect)(()=>{let e=setInterval(()=>{Me(),I()},5e3);return()=>clearInterval(e)},[Me,I]);let Fe=async()=>{if(w.trim()){j(!0);try{await R.post(`/api/v1/ronin/sessions`,{name:w,posture:E,komainu_level:O}),await Oe(),await I(),S(!1),T(``)}catch{}j(!1)}},Ie=async e=>{try{await R.delete(`/api/v1/ronin/sessions/${e}`),await Promise.all([Oe(),I()])}catch{}},Le=async(e,t)=>{try{await R.post(`/api/v1/ronin/approvals/${e}`,{decision:t,decided_by:`operator`}),te(null),await Promise.all([Me(),I()])}catch{}},Re=async()=>{if(re){ve(!0),xe(null);try{let e=(await R.post(`/api/v1/ronin/execute`,{action_type:re,target:se||void 0,value:de||void 0,session_id:pe||void 0})).data?.data;e?.status===`success`?xe(`✅ ${re} — ${JSON.stringify(e.result_data||{}).slice(0,300)}`):xe(`❌ ${e?.status}: ${e?.error||`Unknown error`}`),await I()}catch(e){xe(`❌ ${e.response?.data?.detail||e.message||`Request failed`}`)}ve(!1)}},ze=async()=>{if(confirm(`⚠️ HARAKIRI: This will stop ALL Ronin activity and close all sessions. Continue?`))try{await R.post(`/api/v1/ronin/harakiri`),await Promise.all([I(),Oe(),Me()])}catch{}},z=async()=>{if(confirm(`Ronin Desktop Control can operate your real mouse, keyboard, windows, and applications. Every action remains visible, verified, and audited. Enable it now?`)){x(!0);try{await R.post(`/api/v1/ronin/desktop/enable`,{confirmation:`ENABLE RONIN DESKTOP CONTROL`,ronin_screenshots_enabled:!0,ronin_mouse_enabled:!0,ronin_keyboard_enabled:!0,ronin_window_management_enabled:!0,ronin_native_apps_enabled:!0,ronin_require_verification:!0,ronin_require_high_risk_approval:!0,ronin_block_critical_actions:!0,ronin_visible_indicator:!0}),await I()}catch(e){alert(e.response?.data?.detail||`Could not enable Ronin Desktop Control.`)}finally{x(!1)}}},Be=async()=>{x(!0);try{await R.post(`/api/v1/ronin/desktop/disable`),await I()}finally{x(!1)}},V=async()=>{confirm(`Stop all Ronin Desktop Control immediately?`)&&(await R.post(`/api/v1/ronin/desktop/kill-switch`),await I())};if(v)return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-[#0a0e1a]`,children:(0,G.jsx)(N,{className:`w-8 h-8 animate-spin`,style:{color:K}})});let H=n?.environment||{},U=n?.komainu||{},Ve=lt[H.environment_type]||B,Ue=ut[U.level]||ut[1];return(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col bg-[#0a0e1a] overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`px-6 py-5 border-b border-[#1a2040] flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-xl flex items-center justify-center`,style:{background:rt,border:`1px solid ${it}`},children:(0,G.jsx)(ae,{className:`w-5 h-5`,style:{color:K}})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-bold text-[#c8d0d8] tracking-tight`,children:`Ronin`}),(0,G.jsx)(`p`,{className:`text-[10px] text-[#7a8899] uppercase tracking-widest font-bold`,children:`浪人 — Desktop Control Layer`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border cursor-default`,style:{background:U.active?`${Ue.color}08`:`#0e1225`,borderColor:U.active?`${Ue.color}30`:`#1a2040`},title:`Komainu Guardian: ${U.active?Ue.desc:`Inactive`}`,children:[(0,G.jsx)(Pe,{className:`w-3.5 h-3.5`,style:{color:U.active?Ue.color:`#7a8899`}}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider`,style:{color:U.active?Ue.color:`#7a8899`},children:U.active?U.paused?`PAUSED`:Ue.label:`GUARDIAN OFF`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[#0e1225] border border-[#1a2040]`,children:[(0,G.jsx)(Ve,{className:`w-3.5 h-3.5 text-[#7a8899]`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-wider`,children:(H.environment_type||`unknown`).replace(`_`,` `)})]}),n?.ronin_enabled?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[#22c55e]/8 border border-[#22c55e]/20`,children:[(0,G.jsx)(F,{className:`w-3.5 h-3.5 text-[#22c55e]`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#22c55e] uppercase tracking-wider`,children:n.ronin_posture.replace(`_`,` `)})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[#ef4444]/8 border border-[#ef4444]/20`,children:[(0,G.jsx)(He,{className:`w-3.5 h-3.5 text-[#ef4444]`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#ef4444] uppercase tracking-wider`,children:`DISABLED`})]}),(0,G.jsxs)(`button`,{onClick:ze,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#ef4444]/8 border border-[#ef4444]/20 text-[#ef4444] hover:bg-[#ef4444]/20 transition-all cursor-pointer`,title:`Emergency Stop — Harakiri`,children:[(0,G.jsx)(ye,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider`,children:`STOP`})]})]})]}),d.length>0&&(0,G.jsxs)(`div`,{className:`px-6 py-3 bg-[#f97316]/8 border-b border-[#f97316]/20 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#f97316] animate-pulse`}),(0,G.jsxs)(`span`,{className:`text-xs font-bold text-[#f97316]`,children:[d.length,` Pending Approval`,d.length>1?`s`:``]}),(0,G.jsxs)(`span`,{className:`text-[10px] text-[#f97316]/60`,children:[`— `,d[0].action_type,` requires operator decision`]})]}),(0,G.jsxs)(`button`,{onClick:()=>te(d[0]),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider cursor-pointer transition-all`,style:{background:K,color:`#0a0e1a`},children:[`Review`,(0,G.jsx)(f,{className:`w-3 h-3`})]})]}),n?.desktop_active&&n.visible_indicator&&(0,G.jsxs)(`div`,{className:`px-6 py-2.5 bg-orange-500/10 border-b border-orange-500/30 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-orange-400`,children:[(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-orange-400 animate-pulse`}),(0,G.jsx)(`span`,{className:`text-[10px] font-black tracking-[0.2em]`,children:`RONIN DESKTOP CONTROL ACTIVE`}),(0,G.jsx)(`span`,{className:`text-[9px] text-orange-300/60`,children:`Visible, verified, and audited`})]}),(0,G.jsx)(`button`,{onClick:V,className:`px-3 py-1 rounded border border-red-500/40 bg-red-500/10 text-[9px] font-bold text-red-400 hover:bg-red-500/20`,children:`KILL SWITCH`})]}),(0,G.jsx)(`div`,{className:`px-6 pt-3 flex items-center gap-1 border-b border-[#1a2040]`,children:at.map(n=>(0,G.jsx)(`button`,{onClick:()=>t(n),className:L(`px-4 py-2.5 text-[11px] font-bold uppercase tracking-wider transition-all duration-200 border-b-2 -mb-px cursor-pointer`,e===n?`border-[${K}] text-[${K}]`:`border-transparent text-[#7a8899] hover:text-[#c8d0d8]`),style:e===n?{borderColor:K,color:K}:{},children:n},n))}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[e===`Control`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-5 flex items-center justify-between gap-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Full Desktop Control`}),(0,G.jsx)(`p`,{className:`text-[10px] text-[#7a8899] mt-1 max-w-2xl`,children:`Available only in Ronin posture. Enabling grants governed mouse, keyboard, window, and application control with mandatory observation, verification, audit, protected-context blocking, and a kill switch.`})]}),n?.desktop_active?(0,G.jsx)(`button`,{disabled:b,onClick:Be,className:`px-4 py-2 rounded-lg border border-orange-500/40 bg-orange-500/10 text-xs font-bold text-orange-400 whitespace-nowrap`,children:`DISABLE DESKTOP CONTROL`}):(0,G.jsx)(`button`,{disabled:b||!n?.desktop_available,onClick:z,className:`px-4 py-2 rounded-lg bg-orange-500 text-[#0a0e1a] text-xs font-black disabled:opacity-30 whitespace-nowrap`,children:n?.desktop_available?`ENABLE DESKTOP CONTROL`:`RONIN POSTURE REQUIRED`})]}),n?.desktop_active&&(0,G.jsxs)(`div`,{className:`grid grid-cols-[1.5fr_1fr] gap-4`,children:[(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`px-4 py-3 border-b border-[#1a2040] flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Current Desktop`}),(0,G.jsx)(`span`,{className:`text-[9px] text-orange-400`,children:n.runtime?.active_window?.title||`No active window detected`})]}),(0,G.jsx)(`div`,{className:`aspect-video bg-[#080b14] flex items-center justify-center`,children:n.runtime?.screenshot_url?(0,G.jsx)(`img`,{src:n.runtime.screenshot_url,className:`w-full h-full object-contain`,alt:`Current Ronin desktop`}):(0,G.jsx)(ae,{className:`w-12 h-12 text-[#1a2040]`})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-px bg-[#1a2040]`,children:[(0,G.jsx)(mt,{label:`Next action`,value:n.runtime?.next_action?.action_type||`Idle`}),(0,G.jsx)(mt,{label:`Verification`,value:n.runtime?.verification?.passed===!0?`Passed`:n.runtime?.verification?.passed===!1?`Failed`:`Pending`}),(0,G.jsx)(mt,{label:`Retries`,value:String(n.runtime?.retry_count||0)})]})]}),(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`px-4 py-3 border-b border-[#1a2040] text-[10px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Action Timeline`}),(0,G.jsxs)(`div`,{className:`max-h-[360px] overflow-y-auto divide-y divide-[#1a2040]`,children:[(n.runtime?.timeline||[]).slice(0,50).map((e,t)=>(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`text-[9px] font-mono text-orange-400`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,G.jsx)(`div`,{className:`text-[10px] text-[#c8d0d8] mt-0.5`,children:e.message})]},`${e.timestamp}-${t}`)),!n.runtime?.timeline?.length&&(0,G.jsx)(`div`,{className:`p-6 text-center text-[10px] text-[#555]`,children:`No desktop actions yet.`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-4 gap-4`,children:[(0,G.jsx)(ft,{icon:ae,label:`Sessions`,value:String(n?.active_sessions||0),sub:`Active desktop sessions`,accent:K}),(0,G.jsx)(ft,{icon:Pe,label:`Komainu`,value:U.active?U.paused?`Paused`:`Active`:`Off`,sub:U.active?Ue.desc:`Guardian not running`,accent:U.active?Ue.color:`#7a8899`}),(0,G.jsx)(ft,{icon:_e,label:`Approvals`,value:String(n?.pending_approvals||0),sub:`Waiting for operator`,accent:n?.pending_approvals?`#f97316`:`#22c55e`}),(0,G.jsx)(ft,{icon:Ae,label:`Capabilities`,value:String(n?.capabilities_count||0),sub:`Registered actions`,accent:`#4a8cc7`})]}),(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-5`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest mb-4`,children:`Environment Detection`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsx)(pt,{label:`Type`,value:(H.environment_type||`unknown`).replace(`_`,` `)}),(0,G.jsx)(pt,{label:`OS`,value:`${H.os_type||`unknown`} ${H.os_version||``}`.trim()}),(0,G.jsx)(pt,{label:`Hostname`,value:H.hostname||`N/A`}),(0,G.jsx)(pt,{label:`Machine ID`,value:H.machine_id?H.machine_id.slice(0,16)+`…`:`N/A`}),(0,G.jsx)(pt,{label:`Disposable`,value:H.is_disposable?`Yes`:`No`}),(0,G.jsx)(pt,{label:`Hypervisor`,value:H.hypervisor||`None`})]})]}),(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-5`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest mb-4`,children:`Quick Action`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-4 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,G.jsxs)(`select`,{value:re,onChange:e=>ie(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,G.jsxs)(`optgroup`,{label:`Desktop`,children:[(0,G.jsx)(`option`,{value:`desktop.screenshot`,children:`📸 Screenshot`}),(0,G.jsx)(`option`,{value:`desktop.click`,children:`🖱️ Click`}),(0,G.jsx)(`option`,{value:`desktop.move_mouse`,children:`↗️ Move Mouse`}),(0,G.jsx)(`option`,{value:`desktop.type`,children:`⌨️ Type Text`}),(0,G.jsx)(`option`,{value:`desktop.hotkey`,children:`⚡ Hotkey`}),(0,G.jsx)(`option`,{value:`desktop.locate_image`,children:`🔍 Locate Image`}),(0,G.jsx)(`option`,{value:`desktop.read_screen`,children:`👁️ Read Screen`})]}),(0,G.jsxs)(`optgroup`,{label:`Browser`,children:[(0,G.jsx)(`option`,{value:`browser.open`,children:`🌐 Open URL`}),(0,G.jsx)(`option`,{value:`browser.click`,children:`🖱️ Browser Click`}),(0,G.jsx)(`option`,{value:`browser.type`,children:`⌨️ Browser Type`}),(0,G.jsx)(`option`,{value:`browser.extract`,children:`📄 Extract Text`}),(0,G.jsx)(`option`,{value:`browser.screenshot`,children:`📸 Browser Screenshot`})]}),(0,G.jsxs)(`optgroup`,{label:`OS`,children:[(0,G.jsx)(`option`,{value:`os.list_windows`,children:`📋 List Windows`}),(0,G.jsx)(`option`,{value:`os.focus_window`,children:`🔲 Focus Window`})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Target`}),(0,G.jsx)(`input`,{value:se,onChange:e=>le(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none`,placeholder:`x,y or selector`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Value`}),(0,G.jsx)(`input`,{value:de,onChange:e=>fe(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none`,placeholder:`text or URL`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`\xA0`}),(0,G.jsxs)(`button`,{onClick:Re,disabled:he,className:`w-full flex items-center justify-center gap-2 p-2.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer disabled:opacity-40`,style:{background:K,color:`#0a0e1a`},children:[he?(0,G.jsx)(N,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(ce,{className:`w-3.5 h-3.5`}),`Execute`]})]})]}),be&&(0,G.jsx)(`div`,{className:L(`mt-3 p-3 rounded-lg text-xs font-mono whitespace-pre-wrap border`,be.startsWith(`✅`)?`bg-[#22c55e]/5 text-[#22c55e]/90 border-[#22c55e]/20`:`bg-[#ef4444]/5 text-[#ef4444]/90 border-[#ef4444]/20`),children:be})]})]}),e===`Sessions`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Desktop Sessions`}),(0,G.jsxs)(`button`,{onClick:()=>S(!0),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all duration-200 cursor-pointer`,style:{background:rt,border:`1px solid ${it}`,color:K},children:[(0,G.jsx)(ue,{className:`w-3 h-3`}),`New Session`]})]}),i.length===0?(0,G.jsxs)(`div`,{className:`text-center py-16 space-y-3`,children:[(0,G.jsx)(ae,{className:`w-12 h-12 mx-auto`,style:{color:`${K}40`}}),(0,G.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`No desktop sessions yet`}),(0,G.jsx)(`p`,{className:`text-xs text-[#555]`,children:`Create a session to start governing desktop control`})]}):(0,G.jsx)(`div`,{className:`grid gap-3`,children:i.map(e=>{let t=ot[e.status]||ot.idle,n=st[e.current_app_trust||`restricted`]||st.restricted;return(0,G.jsxs)(`div`,{className:`group bg-[#0e1225] border border-[#1a2040] rounded-xl p-4 flex items-center gap-4 hover:border-[#2a3060] transition-all duration-200`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-lg flex items-center justify-center shrink-0`,style:{background:t.bg},children:(0,G.jsx)(ae,{className:`w-4.5 h-4.5`,style:{color:t.text}})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8] truncate`,children:e.name}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded`,style:{background:t.bg,color:t.text},children:e.status}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-[#4a8cc7]/10 text-[#4a8cc7]`,children:e.posture.replace(`_`,` `)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:e.environment_type.replace(`_`,` `)}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:`•`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:e.os_type}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:`•`}),(0,G.jsxs)(`span`,{className:`text-[9px] text-[#555]`,children:[e.action_count,` actions`]}),e.hostname&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:`•`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555] font-mono`,children:e.hostname})]})]}),e.current_app&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,G.jsx)(Ce,{className:`w-2.5 h-2.5 text-[#555]`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#c8d0d8]/70`,children:e.current_app}),(0,G.jsx)(`span`,{className:`text-[7px] font-bold uppercase px-1 py-0.5 rounded`,style:{background:n.bg,color:n.text},children:n.label})]}),e.last_action&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1 mt-1`,children:[(0,G.jsx)(a,{className:`w-2.5 h-2.5 text-[#555]`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#f97316]/60 font-mono`,children:e.last_action})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-lg bg-[#0a0e1a] border border-[#1a2040]`,children:[(0,G.jsx)(Pe,{className:`w-3 h-3`,style:{color:ut[e.komainu_level]?.color||`#7a8899`}}),(0,G.jsxs)(`span`,{className:`text-[8px] font-bold uppercase`,style:{color:ut[e.komainu_level]?.color||`#7a8899`},children:[`L`,e.komainu_level]})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,G.jsx)(`button`,{onClick:()=>Ie(e.id),className:`p-1.5 hover:bg-[#ef4444]/10 text-[#7a8899] hover:text-[#ef4444] rounded-lg transition-colors cursor-pointer`,title:`Close session`,children:(0,G.jsx)(we,{className:`w-3.5 h-3.5`})})})]},e.id)})})]}),e===`App Trust`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Application Trust Registry`}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:[`all`,`trusted`,`restricted`,`sensitive`,`forbidden`].map(e=>(0,G.jsx)(`button`,{onClick:()=>De(e),className:L(`px-3 py-1 rounded-lg text-[9px] font-bold uppercase tracking-wider transition-all cursor-pointer`,Ee===e?`text-[#0a0e1a]`:`text-[#7a8899] bg-[#0e1225] border border-[#1a2040] hover:border-[#2a3060]`),style:Ee===e?{background:e===`all`?K:st[e]?.text||K}:{},children:e},e))})]}),(0,G.jsx)(`div`,{className:`grid gap-2`,children:s.filter(e=>Ee===`all`||e.trust_level===Ee).map((e,t)=>{let n=st[e.trust_level]||st.restricted;return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-lg px-4 py-3 flex items-center gap-3 hover:border-[#2a3060] transition-all`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center`,style:{background:n.bg},children:e.trust_level===`forbidden`?(0,G.jsx)(ne,{className:`w-3.5 h-3.5`,style:{color:n.text}}):e.trust_level===`sensitive`?(0,G.jsx)(_e,{className:`w-3.5 h-3.5`,style:{color:n.text}}):e.trust_level===`trusted`?(0,G.jsx)(F,{className:`w-3.5 h-3.5`,style:{color:n.text}}):(0,G.jsx)(C,{className:`w-3.5 h-3.5`,style:{color:n.text}})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-[#c8d0d8]`,children:e.name}),(0,G.jsx)(`div`,{className:`text-[9px] text-[#555] font-mono`,children:e.process||e.process_pattern||`—`})]}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded`,style:{background:n.bg,color:n.text},children:n.label}),(0,G.jsx)(`span`,{className:`text-[8px] text-[#555] uppercase`,children:e.platform})]},t)})})]}),e===`Capabilities`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Registered Capabilities`}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:[`all`,`desktop`,`browser`,`os`,`app`,`ronin`].map(e=>(0,G.jsx)(`button`,{onClick:()=>Te(e),className:L(`px-3 py-1 rounded-lg text-[9px] font-bold uppercase tracking-wider transition-all cursor-pointer`,Se===e?`text-[#0a0e1a]`:`text-[#7a8899] bg-[#0e1225] border border-[#1a2040] hover:border-[#2a3060]`),style:Se===e?{background:K}:{},children:e},e))})]}),(0,G.jsx)(`div`,{className:`grid gap-2`,children:l.filter(e=>Se===`all`||e.category===Se).map((e,t)=>{let n=ct[e.risk_level]||ct.low;return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-lg px-4 py-3 flex items-center gap-3 hover:border-[#2a3060] transition-all`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center bg-[#0a0e1a]`,children:e.category===`desktop`?(0,G.jsx)(oe,{className:`w-3.5 h-3.5 text-[#f97316]`}):e.category===`browser`?(0,G.jsx)(C,{className:`w-3.5 h-3.5 text-[#06b6d4]`}):e.category===`os`?(0,G.jsx)(ge,{className:`w-3.5 h-3.5 text-[#a78bfa]`}):e.category===`ronin`?(0,G.jsx)(ye,{className:`w-3.5 h-3.5 text-[#ef4444]`}):(0,G.jsx)(Ae,{className:`w-3.5 h-3.5 text-[#eab308]`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-[#c8d0d8] font-mono`,children:e.name}),e.requires_approval&&(0,G.jsx)(`span`,{className:`text-[7px] font-bold uppercase px-1 py-0.5 rounded bg-[#f97316]/10 text-[#f97316]`,children:`APPROVAL`})]}),(0,G.jsx)(`div`,{className:`text-[9px] text-[#555]`,children:e.description})]}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded`,style:{background:n.bg,color:n.text},children:e.risk_level}),(0,G.jsxs)(`span`,{className:`text-[8px] text-[#555] uppercase font-mono w-24 text-right`,children:[`≥ `,e.posture_minimum.replace(`_`,` `)]})]},t)})})]}),e===`Audit Trail`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Ronin Audit Trail`}),(0,G.jsxs)(`button`,{onClick:Ne,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer text-[#7a8899] hover:text-[#c8d0d8] bg-[#0e1225] border border-[#1a2040]`,children:[(0,G.jsx)(P,{className:`w-3 h-3`}),`Refresh`]})]}),m.length===0?(0,G.jsxs)(`div`,{className:`text-center py-16 space-y-3`,children:[(0,G.jsx)(a,{className:`w-12 h-12 mx-auto text-[#1a2040]`}),(0,G.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`No audit events yet`}),(0,G.jsx)(`p`,{className:`text-xs text-[#555]`,children:`Ronin actions will appear here once executed`})]}):(0,G.jsx)(`div`,{className:`space-y-1`,children:m.map((e,t)=>{let n=e.severity===`critical`?`#ef4444`:e.severity===`warn`?`#eab308`:e.severity===`error`?`#ef4444`:`#22c55e`;return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-lg px-4 py-2.5 flex items-center gap-3 hover:border-[#2a3060] transition-all`,children:[(0,G.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:n}}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold text-[#c8d0d8] font-mono`,children:e.event_type}),(0,G.jsx)(`span`,{className:`text-[7px] font-bold uppercase px-1 py-0.5 rounded`,style:{background:`${n}15`,color:n},children:e.severity})]}),(0,G.jsx)(`div`,{className:`text-[9px] text-[#555] truncate`,children:e.action})]}),(0,G.jsx)(`span`,{className:`text-[8px] text-[#555] font-mono whitespace-nowrap`,children:e.created_at?new Date(e.created_at).toLocaleTimeString():`—`})]},t)})})]})]}),ee&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-2xl w-[440px] shadow-2xl overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-5 border-b border-[#1a2040] flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center`,style:{background:rt,border:`1px solid ${it}`},children:(0,G.jsx)(ue,{className:`w-4 h-4`,style:{color:K}})}),(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`New Ronin Session`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Session Name`}),(0,G.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none`,placeholder:`e.g., SAP Data Entry, Browser Research`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Posture Level`}),(0,G.jsxs)(`select`,{value:E,onChange:e=>D(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,G.jsx)(`option`,{value:`observe_only`,children:`👁️ Observe Only — Screenshots & window listing`}),(0,G.jsx)(`option`,{value:`browser_only`,children:`🌐 Browser Only — Playwright/Mado control`}),(0,G.jsx)(`option`,{value:`desktop_limited`,children:`🖱️ Desktop Limited — Mouse, keyboard, screenshots`}),(0,G.jsx)(`option`,{value:`desktop_full`,children:`⚡ Desktop Full — Native apps, shell, admin`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(Pe,{className:`w-3 h-3`}),`Komainu Guardian Level`]}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[1,2,3].map(e=>{let t=ut[e];return(0,G.jsxs)(`button`,{onClick:()=>k(e),className:L(`flex-1 flex flex-col items-center gap-1 px-3 py-2.5 rounded-lg border text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer`,O===e?`border-[${t.color}]`:`border-[#1a2040] hover:border-[#2a3060]`),style:O===e?{borderColor:t.color,background:`${t.color}10`,color:t.color}:{color:`#7a8899`},children:[(0,G.jsx)(`span`,{children:t.label}),(0,G.jsx)(`span`,{className:`text-[7px] normal-case tracking-normal font-normal opacity-60`,children:t.desc})]},e)})})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-[#1a2040] flex items-center justify-end gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>S(!1),className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#7a8899] hover:text-[#c8d0d8] transition-colors cursor-pointer`,children:`Cancel`}),(0,G.jsxs)(`button`,{onClick:Fe,disabled:A||!w.trim(),className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer disabled:opacity-40`,style:{background:K,color:`#0a0e1a`},children:[A?(0,G.jsx)(N,{className:`w-3 h-3 animate-spin`}):(0,G.jsx)(ue,{className:`w-3 h-3`}),`Create`]})]})]})}),M&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#f97316]/30 rounded-2xl w-[480px] shadow-2xl overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-5 border-b border-[#f97316]/20 bg-[#f97316]/5 flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center bg-[#f97316]/15 border border-[#f97316]/30`,children:(0,G.jsx)(_e,{className:`w-4 h-4 text-[#f97316]`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#f97316]`,children:`Approval Required`}),(0,G.jsx)(`p`,{className:`text-[9px] text-[#f97316]/60`,children:`Ronin is requesting permission for a high-risk action`})]})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsx)(ht,{label:`Action`,value:M.action_type}),(0,G.jsx)(ht,{label:`Risk Level`,value:M.risk_level,highlight:!0}),(0,G.jsx)(ht,{label:`Target`,value:M.target||`—`}),(0,G.jsx)(ht,{label:`Application`,value:M.app_name||`—`}),M.app_trust&&(0,G.jsx)(ht,{label:`App Trust`,value:M.app_trust})]}),(0,G.jsxs)(`div`,{className:`p-3 bg-[#0a0e1a] rounded-lg border border-[#1a2040]`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest mb-1`,children:`Reason`}),(0,G.jsx)(`p`,{className:`text-xs text-[#c8d0d8]`,children:M.reason})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 border-t border-[#1a2040] flex items-center justify-between`,children:[(0,G.jsx)(`button`,{onClick:()=>te(null),className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#7a8899] hover:text-[#c8d0d8] transition-colors cursor-pointer`,children:`Later`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{onClick:()=>Le(M.id,`denied`),className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#ef4444]/10 text-[#ef4444] border border-[#ef4444]/20 hover:bg-[#ef4444]/20 transition-all cursor-pointer`,children:[(0,G.jsx)(_,{className:`w-3 h-3`}),`Deny`]}),(0,G.jsxs)(`button`,{onClick:()=>Le(M.id,`approved`),className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer`,style:{background:`#22c55e`,color:`#0a0e1a`},children:[(0,G.jsx)(g,{className:`w-3 h-3`}),`Approve`]})]})]})]})})]})}function ft({icon:e,label:t,value:n,sub:r,accent:i}){return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-4 hover:border-[#2a3060] transition-all`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center`,style:{background:`${i}12`,border:`1px solid ${i}30`},children:(0,G.jsx)(e,{className:`w-4 h-4`,style:{color:i}})}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:t})]}),(0,G.jsx)(`p`,{className:`text-2xl font-bold tracking-tight`,style:{color:i},children:n}),(0,G.jsx)(`p`,{className:`text-[9px] text-[#555] mt-1`,children:r})]})}function pt({label:e,value:t}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest mb-0.5`,children:e}),(0,G.jsx)(`p`,{className:`text-xs text-[#c8d0d8] font-mono`,children:t})]})}function mt({label:e,value:t}){return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`text-[8px] uppercase tracking-widest text-[#555]`,children:e}),(0,G.jsx)(`div`,{className:`text-[10px] font-bold text-[#c8d0d8] mt-1 truncate`,children:t})]})}function ht({label:e,value:t,highlight:n}){let r=n?ct[t]||ct.high:null;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest mb-0.5`,children:e}),n&&r?(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase px-1.5 py-0.5 rounded`,style:{background:r.bg,color:r.text},children:t}):(0,G.jsx)(`p`,{className:`text-xs text-[#c8d0d8] font-mono truncate`,children:t})]})}var gt=`IDE Mode gives Shogun access to an approved development workspace. In Campaign posture, Shogun may inspect and edit code, run approved tasks, read diagnostics, and use Git status/diff. In Ronin posture, broader terminal and Git operations may be configured. Enable only for trusted repositories and tasks.`,_t=()=>{let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)([]),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(`Balanced`),[c,l]=(0,W.useState)(!1),[u,d]=(0,W.useState)(``),f=(0,W.useCallback)(async()=>{let[e,n,i]=await Promise.all([R.get(`/api/v1/ide/status`),R.get(`/api/v1/ide/workspaces`).catch(()=>({data:{data:[]}})),R.get(`/api/v1/models/routing/profiles/active`).catch(()=>({data:{data:null}}))]);t(e.data.data),r(n.data.data||[]),s(i.data.data?.name||`Balanced`)},[]);(0,W.useEffect)(()=>{f().catch(()=>d(`Unable to load IDE Mode status.`))},[f]);let p=async(e,t)=>{l(!0),d(``);try{await e(),d(t),await f()}catch(e){d(e?.response?.data?.detail||`The IDE operation failed.`)}finally{l(!1)}};return e?(0,G.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-3 gap-5`,children:[(0,G.jsxs)(`section`,{className:`shogun-card xl:col-span-2 space-y-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(v,{className:`w-5 h-5 text-purple-400`}),(0,G.jsx)(`h3`,{className:`font-bold text-shogun-text`,children:`Shogun IDE Mode`})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Governed autonomous development through the VS Code Adapter.`})]}),(0,G.jsx)(`span`,{className:L(`px-2.5 py-1 rounded border text-[9px] font-bold uppercase`,e.enabled?`text-green-400 border-green-500/30 bg-green-500/10`:`text-shogun-subdued border-shogun-border`),children:e.enabled?`Enabled`:`Disabled`})]}),!e.available&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-xs text-amber-200`,children:[(0,G.jsx)(`b`,{children:`Posture locked.`}),` IDE Mode is only available in Campaign and Ronin. Current posture: `,String(e.posture).toUpperCase(),`.`]}),e.available&&!e.enabled&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-4 flex gap-3`,children:[(0,G.jsx)(Te,{className:`w-4 h-4 text-amber-400 shrink-0 mt-0.5`}),(0,G.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-100/80`,children:gt})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[e.enabled?(0,G.jsxs)(`button`,{disabled:c,onClick:()=>p(()=>R.post(`/api/v1/ide/disable`),`IDE Mode disabled and all bridge sessions revoked.`),className:`px-4 py-2 rounded-lg border border-red-500/35 bg-red-500/10 text-red-300 text-xs font-bold flex items-center gap-2`,children:[(0,G.jsx)(We,{className:`w-4 h-4`}),` Disable`]}):(0,G.jsxs)(`button`,{disabled:!e.available||c,onClick:()=>{window.confirm(gt)&&p(()=>R.post(`/api/v1/ide/enable`,{confirmed:!0,remember_workspace:!1}),`IDE Mode enabled for this session.`)},className:`px-4 py-2 rounded-lg bg-purple-600 text-white text-xs font-bold disabled:opacity-30 flex items-center gap-2`,children:[(0,G.jsx)(de,{className:`w-4 h-4`}),` Enable IDE Mode`]}),(0,G.jsxs)(`button`,{onClick:()=>f(),className:`px-3 py-2 rounded-lg border border-shogun-border text-shogun-subdued text-xs flex items-center gap-2`,children:[(0,G.jsx)(P,{className:`w-3.5 h-3.5`}),` Refresh`]})]})]}),(0,G.jsxs)(`section`,{className:`shogun-card space-y-3`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest text-shogun-text`,children:`Runtime Status`}),[[`Posture`,e.posture],[`Routing profile`,o],[`Provider`,`VS Code Adapter`],[`Connections`,e.connected_instances],[`Approved workspaces`,e.approved_workspaces]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex justify-between text-xs border-b border-shogun-border/40 pb-2`,children:[(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:e}),(0,G.jsx)(`b`,{className:`text-shogun-text`,children:String(t)})]},String(e))),(0,G.jsx)(`button`,{disabled:!e.enabled||c,onClick:()=>p(()=>R.post(`/api/v1/ide/kill-switch`),`IDE kill switch activated.`),className:`w-full mt-2 px-3 py-2 rounded border border-red-500/30 text-red-300 text-[10px] font-bold uppercase disabled:opacity-30`,children:`Stop all IDE work`})]})]}),e.enabled&&(0,G.jsxs)(`section`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-bold text-sm text-shogun-text`,children:`VS Code Pairing`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Create a one-time, ten-minute localhost token for Shogun IDE Bridge.`})]}),(0,G.jsx)(I,{className:L(`w-5 h-5`,e.connected_instances?`text-green-400`:`text-shogun-subdued`)})]}),i?(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#050508] border border-shogun-border p-4 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`text-purple-300 text-sm break-all flex-1`,children:i.token}),(0,G.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(i.token),title:`Copy token`,children:(0,G.jsx)(y,{className:`w-4 h-4 text-shogun-subdued`})})]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[`Bridge: `,i.bridge_url,` · expires `,new Date(i.expires_at).toLocaleTimeString()]})]}):(0,G.jsx)(`button`,{disabled:c,onClick:()=>p(async()=>{a((await R.post(`/api/v1/ide/pairing/create`)).data.data)},`Pairing token created.`),className:`px-4 py-2 bg-shogun-blue/20 border border-shogun-blue/30 rounded-lg text-xs font-bold text-shogun-blue`,children:`Create pairing token`})]}),e.enabled&&(0,G.jsxs)(`section`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ze,{className:`w-4 h-4 text-shogun-gold`}),(0,G.jsx)(`h3`,{className:`font-bold text-sm`,children:`Registered Workspaces`})]}),n.length===0?(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic`,children:`No VS Code workspace registered yet. Pair the Shogun IDE Bridge, then open a folder in VS Code.`}):n.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border bg-[#050508] p-4 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`b`,{className:`text-sm text-shogun-text`,children:e.name}),e.approved&&(0,G.jsx)(g,{className:`w-3.5 h-3.5 text-green-400`})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued truncate`,children:e.root_path})]}),(0,G.jsx)(`button`,{onClick:()=>p(()=>R.post(`/api/v1/ide/workspaces/${e.id}/${e.approved?`revoke`:`approve`}`),e.approved?`Workspace access revoked.`:`Workspace approved.`),className:L(`px-3 py-1.5 rounded border text-[10px] font-bold uppercase`,e.approved?`border-red-500/30 text-red-300`:`border-green-500/30 text-green-300`),children:e.approved?`Revoke`:`Approve`})]},e.id))]}),(0,G.jsx)(`section`,{className:`shogun-card`,children:(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(ve,{className:`w-4 h-4 text-purple-400 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`text-xs font-bold`,children:`Enforced safeguards`}),(0,G.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-1 leading-relaxed`,children:`Workspace approval, traversal and symlink protection, protected-secret rules, Campaign command allowlists, snapshots before writes, Git push disabled by default, central audit events, self-verification hooks, and an immediate kill switch.`})]})]})}),u&&(0,G.jsx)(`div`,{className:`fixed bottom-6 right-6 z-50 rounded-lg border border-shogun-border bg-[#0a0e1a] px-4 py-3 text-xs shadow-2xl`,children:u})]}):(0,G.jsxs)(`div`,{className:`shogun-card flex items-center gap-3 text-shogun-subdued`,children:[(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}),` Loading IDE Mode…`]})},vt=[`simple_chat`,`summarization`,`planning`,`complex_reasoning`,`coding_plan`,`coding_edit`,`test_failure_analysis`,`visual_understanding`,`browser_task`,`desktop_task`,`self_verification`,`final_review`,`stack_planning`,`stack_step_execution`,`context_compaction`],yt=[`reasoning`,`coding`,`vision`,`tool_use`,`long_context`,`json_mode`],bt={reasoning:`Reasoning`,coding:`Coding`,vision:`Images & vision`,tool_use:`Tool use`,long_context:`Long documents`,json_mode:`Structured output`},xt={quality_tier:[{value:1,label:`Basic`,help:`Simple and routine work`},{value:2,label:`Standard`,help:`Everyday general tasks`},{value:3,label:`Strong`,help:`Reliable professional work`},{value:4,label:`Advanced`,help:`Difficult or specialized work`},{value:5,label:`Frontier`,help:`Highest available capability`}],cost_tier:[{value:1,label:`Very low cost`,help:`Preferred by economy profiles`},{value:2,label:`Low cost`,help:`Budget-friendly usage`},{value:3,label:`Moderate cost`,help:`Balanced price point`},{value:4,label:`High cost`,help:`Use for demanding work`},{value:5,label:`Premium cost`,help:`Most expensive tier`}],latency_tier:[{value:1,label:`Fastest`,help:`Best for interactive work`},{value:2,label:`Fast`,help:`Usually responds quickly`},{value:3,label:`Moderate`,help:`Normal response time`},{value:4,label:`Slow`,help:`Longer response time`},{value:5,label:`Slowest`,help:`Use when speed is secondary`}]},St=[`Simple`,`Routine`,`Involved`,`Complex`,`Expert`];function Ct({isEditingProfiles:e=!1,onEditProfiles:t}){let[n,r]=(0,W.useState)([]),[i,o]=(0,W.useState)([]),[s,l]=(0,W.useState)({}),[d,f]=(0,W.useState)(!0),[m,h]=(0,W.useState)(``),[_,v]=(0,W.useState)(``),[y,b]=(0,W.useState)(`coding_edit`),[x,ee]=(0,W.useState)(`balanced`),[S,C]=(0,W.useState)(4),[w,T]=(0,W.useState)([`coding`,`tool_use`]),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)([]),A=async()=>{f(!0);try{let[e,t,n]=await Promise.all([R.get(`/api/v1/models/routing/profiles`),R.get(`/api/v1/models/registry`),R.get(`/api/v1/models/usage/summary`)]),i=e.data.data||[];r(i),o(t.data.data||[]),l(n.data.data||{});let a=(e.data.data||[]).find(e=>e.is_default);a&&ee(a.name.toLowerCase().replaceAll(` `,`_`));let s=i.find(e=>e.name===`Custom`),c=s?.rules?.find(e=>e.task_type===`*`)||s?.rules?.[0];k(c?.primary_model_id?[String(c.primary_model_id),...(c.fallback_model_ids||[]).map(String)]:[])}catch(e){v(e?.response?.data?.detail||`Model routing data could not be loaded.`)}finally{f(!1)}};(0,W.useEffect)(()=>{A()},[]);let j=(0,W.useMemo)(()=>n.find(e=>e.is_default),[n]),M=(0,W.useMemo)(()=>n.find(e=>e.name===`Custom`),[n]),te=async e=>{h(e.id);try{await R.post(`/api/v1/models/routing/profiles/active`,{profile_id:e.id}),v(`${e.name} is now the active routing profile.`),await A()}catch(e){v(e?.response?.data?.detail||`Profile could not be activated.`)}finally{h(``)}},N=async(e,t)=>{h(e.id);try{let n=await R.patch(`/api/v1/models/registry/${e.id}`,t);o(t=>t.map(t=>t.id===e.id?n.data.data:t)),v(`${e.display_name} updated.`)}catch(e){v(e?.response?.data?.detail||`Model metadata could not be updated.`)}finally{h(``)}},ne=async e=>{h(`test-${e.id}`);try{await R.post(`/api/v1/models/registry/${e.id}/test`),v(`${e.display_name} is reachable.`)}catch(e){v(e?.response?.data?.detail||`Connection test failed.`)}finally{h(``)}};return d?(0,G.jsxs)(`div`,{className:`shogun-card flex items-center gap-3 text-sm text-shogun-subdued`,children:[(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}),` Loading governed routing…`]}):(0,G.jsxs)(`div`,{className:`space-y-6 mb-8`,children:[(0,G.jsxs)(`div`,{className:`shogun-card border-purple-500/30 bg-purple-500/5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 mb-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`font-bold flex items-center gap-2`,children:[(0,G.jsx)(le,{className:`w-5 h-5 text-purple-400`}),` Model Routing Profiles`]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Cheapest sufficient model, with governed escalation and hard capability filters.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 rounded-lg border border-purple-400/30 bg-purple-400/10 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:`Active `}),(0,G.jsx)(`strong`,{className:`text-purple-300`,children:j?.name||`Balanced`})]}),t&&(0,G.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-wider transition-colors ${e?`border-purple-400 bg-purple-400/15 text-purple-300`:`border-shogun-border text-shogun-subdued hover:border-purple-400/40 hover:text-purple-300`}`,children:[(0,G.jsx)(U,{className:`w-3.5 h-3.5`}),` `,e?`Close editor`:`Edit profiles`]})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 xl:grid-cols-6 gap-2`,children:n.filter(e=>[`Ultra Economy`,`Economy`,`Balanced`,`High Capability`,`Premium`,`Custom`].includes(e.name)).map(e=>(0,G.jsxs)(`button`,{onClick:()=>te(e),disabled:m===e.id,className:`text-left p-3 rounded-lg border transition-all ${e.is_default?`border-purple-400 bg-purple-400/15`:`border-shogun-border hover:border-purple-400/40`}`,children:[(0,G.jsxs)(`div`,{className:`text-xs font-bold flex items-center gap-1.5`,children:[e.is_default&&(0,G.jsx)(g,{className:`w-3.5 h-3.5 text-purple-400`}),e.name]}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-1 line-clamp-2`,children:e.description})]},e.id))}),M&&(0,G.jsxs)(`div`,{className:`mt-5 pt-5 border-t border-purple-400/20`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 mb-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold`,children:`Custom model order`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Only these models may be routed. The first eligible model is preferred; capability and safety gates still apply.`})]}),(0,G.jsx)(`button`,{onClick:async()=>{if(!M||O.length===0){v(`Choose at least one model for Custom routing.`);return}h(`custom`);try{await R.post(`/api/v1/models/routing/profiles/${M.id}/update`,{rules:[{task_type:`*`,primary_model_id:O[0],fallback_model_ids:O.slice(1)}]}),await R.post(`/api/v1/models/routing/profiles/active`,{profile_id:M.id}),v(`Custom routing saved and activated.`),await A()}catch(e){v(e?.response?.data?.detail||`Custom routing could not be saved.`)}finally{h(``)}},disabled:m===`custom`||O.length===0,className:`px-3 py-2 rounded bg-purple-600 hover:bg-purple-500 disabled:opacity-40 text-[10px] font-bold`,children:m===`custom`?`Saving…`:`Save & activate Custom`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3`,children:[(0,G.jsx)(`div`,{className:`max-h-44 overflow-y-auto rounded-lg border border-shogun-border p-2 space-y-1`,children:i.filter(e=>e.enabled).map(e=>{let t=O.includes(e.id);return(0,G.jsxs)(`button`,{onClick:()=>k(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),className:`w-full flex items-center justify-between gap-2 rounded p-2 text-left text-xs border ${t?`border-purple-400/50 bg-purple-400/10`:`border-transparent hover:border-shogun-border`}`,children:[(0,G.jsxs)(`span`,{className:`truncate`,children:[(0,G.jsx)(`strong`,{children:e.display_name}),(0,G.jsx)(`span`,{className:`ml-2 text-[9px] text-shogun-subdued`,children:e.provider})]}),t&&(0,G.jsx)(g,{className:`w-3.5 h-3.5 text-purple-400 shrink-0`})]},e.id)})}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border p-2 space-y-1`,children:[O.map((e,t)=>{let n=i.find(t=>t.id===e);return n?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded bg-[#080b14] border border-shogun-border p-2`,children:[(0,G.jsx)(`span`,{className:`w-16 text-[8px] font-bold uppercase text-purple-300`,children:t===0?`Primary`:`Fallback ${t}`}),(0,G.jsx)(`span`,{className:`text-xs flex-1 truncate`,children:n.display_name}),(0,G.jsx)(`button`,{disabled:t===0,onClick:()=>k(e=>{let n=[...e];return[n[t-1],n[t]]=[n[t],n[t-1]],n}),children:(0,G.jsx)(p,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{disabled:t===O.length-1,onClick:()=>k(e=>{let n=[...e];return[n[t],n[t+1]]=[n[t+1],n[t]],n}),children:(0,G.jsx)(u,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:()=>k(t=>t.filter(t=>t!==e)),children:(0,G.jsx)(ke,{className:`w-3.5 h-3.5 text-red-400`})})]},e):null}),!O.length&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued text-center py-6`,children:`Select models from the registry.`})]})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-3 gap-6`,children:[(0,G.jsxs)(`div`,{className:`xl:col-span-2 shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h4`,{className:`font-bold flex items-center gap-2`,children:[(0,G.jsx)(ge,{className:`w-4 h-4 text-shogun-blue`}),` Model Capability Registry`]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Describe what each connected model can do, how capable it is, what it costs, and how quickly it responds. The router uses these as eligibility and preference signals.`})]}),(0,G.jsx)(`button`,{onClick:A,children:(0,G.jsx)(P,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`space-y-3 max-h-[560px] overflow-y-auto pr-1`,children:[i.map(e=>(0,G.jsxs)(`div`,{className:`rounded-xl border p-4 ${e.enabled?`border-shogun-border bg-[#080b14]`:`border-shogun-border/40 opacity-60`}`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-bold text-sm`,children:e.display_name}),(0,G.jsx)(`span`,{className:`text-[8px] uppercase border border-shogun-border rounded px-1.5 py-0.5`,children:e.local?`local`:e.provider})]}),(0,G.jsxs)(`p`,{className:`font-mono text-[9px] text-shogun-subdued mt-1`,children:[e.model_id,` · `,(e.context_window/1e3).toFixed(0),`K context`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>ne(e),className:`px-2 py-1 text-[9px] border border-shogun-border rounded hover:border-shogun-blue`,children:m===`test-${e.id}`?`Testing…`:`Test`}),(0,G.jsx)(`button`,{onClick:()=>N(e,{enabled:!e.enabled}),className:`w-10 h-5 rounded-full p-0.5 ${e.enabled?`bg-green-500`:`bg-gray-700`}`,children:(0,G.jsx)(`span`,{className:`block w-4 h-4 bg-white rounded-full transition-transform ${e.enabled?`translate-x-5`:``}`})})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-2 my-3`,children:[`quality_tier`,`cost_tier`,`latency_tier`].map(t=>{let n=xt[t].find(n=>n.value===e[t])||xt[t][2];return(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[t.replace(`_tier`,``),(0,G.jsx)(`select`,{value:e[t],onChange:n=>N(e,{[t]:Number(n.target.value)}),className:`block w-full mt-1 bg-[#050508] border border-shogun-border rounded p-1.5 text-xs normal-case`,children:xt[t].map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(`span`,{className:`block mt-1 text-[8px] normal-case leading-tight text-shogun-subdued/70`,children:n.help})]},t)})}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase tracking-wider text-shogun-subdued mb-1.5`,children:`Supported task capabilities — click to enable or disable`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:yt.map(t=>(0,G.jsx)(`button`,{onClick:()=>N(e,{capabilities:{...e.capabilities,[t]:!e.capabilities?.[t]}}),className:`text-[8px] uppercase px-2 py-1 rounded border ${e.capabilities?.[t]?`border-cyan-400/40 bg-cyan-400/10 text-cyan-300`:`border-shogun-border text-shogun-subdued`}`,children:bt[t]},t))}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:(e.role_tags||[]).map(e=>(0,G.jsx)(`span`,{className:`rounded bg-purple-400/10 px-1.5 py-0.5 text-[8px] uppercase text-purple-300`,children:e},e))})]},e.id)),!i.length&&(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued text-center py-8`,children:`Connect a model provider to populate the registry.`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`h4`,{className:`font-bold flex items-center gap-2 mb-4`,children:[(0,G.jsx)(c,{className:`w-4 h-4 text-shogun-gold`}),` Preview Decision`]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[`Task type`,(0,G.jsx)(`select`,{value:y,onChange:e=>b(e.target.value),className:`block w-full mt-1 bg-[#050508] border border-shogun-border rounded p-2 text-xs`,children:vt.map(e=>(0,G.jsx)(`option`,{children:e},e))})]}),(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[`Profile`,(0,G.jsx)(`select`,{value:x,onChange:e=>ee(e.target.value),className:`block w-full mt-1 bg-[#050508] border border-shogun-border rounded p-2 text-xs`,children:n.map(e=>(0,G.jsx)(`option`,{value:e.name.toLowerCase().replaceAll(` `,`_`),children:e.name},e.id))})]}),(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[`Task complexity: `,(0,G.jsx)(`strong`,{className:`text-shogun-text normal-case`,children:St[S-1]}),(0,G.jsx)(`input`,{type:`range`,min:`1`,max:`5`,value:S,onChange:e=>C(Number(e.target.value)),className:`block w-full mt-2`})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:yt.map(e=>(0,G.jsx)(`button`,{onClick:()=>T(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:`text-[8px] border rounded px-1.5 py-1 ${w.includes(e)?`border-shogun-gold text-shogun-gold`:`border-shogun-border text-shogun-subdued`}`,children:bt[e]},e))}),(0,G.jsxs)(`button`,{onClick:async()=>{h(`preview`),D(null);try{D((await R.post(`/api/v1/models/route/preview`,{prompt:`Preview ${y}`,task_type:y,complexity_override:S,required_capabilities:w,profile_override:x})).data.data)}catch(e){v(e?.response?.data?.detail||`No eligible route found.`)}finally{h(``)}},disabled:m===`preview`,className:`w-full flex items-center justify-center gap-2 p-2 rounded bg-purple-600 hover:bg-purple-500 font-bold text-xs`,children:[(0,G.jsx)(ce,{className:`w-3.5 h-3.5`}),` Preview route`]})]}),E&&(0,G.jsxs)(`div`,{className:`mt-4 p-3 rounded-lg border border-green-400/30 bg-green-400/5`,children:[(0,G.jsx)(`div`,{className:`font-bold text-sm text-green-300`,children:E.selected_model}),(0,G.jsxs)(`div`,{className:`text-[9px] text-shogun-subdued`,children:[E.selected_provider,` · fallback `,E.fallback_model||`none`]}),(0,G.jsx)(`p`,{className:`text-[10px] mt-2 leading-relaxed`,children:E.reason}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3 mt-2 text-[8px] uppercase text-shogun-subdued`,children:[(0,G.jsxs)(`span`,{children:[St[Math.max(1,Math.min(5,E.complexity_score))-1],` task`]}),(0,G.jsx)(`span`,{children:xt.cost_tier.find(e=>e.value===E.estimated_cost_tier)?.label||`Unknown cost`}),(0,G.jsx)(`span`,{children:xt.latency_tier.find(e=>e.value===E.estimated_latency_tier)?.label||`Unknown speed`})]})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`h4`,{className:`font-bold flex items-center gap-2 mb-3`,children:[(0,G.jsx)(a,{className:`w-4 h-4 text-green-400`}),` Usage`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-center`,children:[(0,G.jsx)(wt,{icon:(0,G.jsx)(Ae,{className:`w-3 h-3`}),label:`Events`,value:s.events||0}),(0,G.jsx)(wt,{icon:(0,G.jsx)(z,{className:`w-3 h-3`}),label:`Avg latency`,value:`${s.average_latency_ms||0} ms`}),(0,G.jsx)(wt,{label:`Input tokens`,value:s.input_tokens||0}),(0,G.jsx)(wt,{label:`Output tokens`,value:s.output_tokens||0})]})]})]})]}),_&&(0,G.jsx)(`div`,{className:`text-xs border border-shogun-border rounded-lg px-3 py-2`,onClick:()=>v(``),children:_})]})}function wt({icon:e,label:t,value:n}){return(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border p-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[8px] uppercase text-shogun-subdued`,children:[e,t]}),(0,G.jsx)(`div`,{className:`font-bold text-sm mt-1`,children:n})]})}var Tt=e=>e?.data?.data??e?.data??e,Et=e=>e>.5?`text-green-400`:e<0?`text-red-400`:`text-amber-300`;function Dt(){let[e,t]=(0,W.useState)([]),[n,r]=(0,W.useState)([]),[i,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(``),[d,f]=(0,W.useState)(`trajectories`),[p,m]=(0,W.useState)(!0),[h,_]=(0,W.useState)(``),v=async()=>{m(!0),_(``);try{let[e,n]=await Promise.all([R.get(`/api/v1/skills/trajectories`,{params:{limit:200}}),R.get(`/api/v1/skills/improvement-candidates`,{params:{limit:200}})]);t(Tt(e)||[]),r(Tt(n)||[])}catch(e){_(e.response?.data?.detail||`Could not load skill trajectories.`)}finally{m(!1)}};(0,W.useEffect)(()=>{v()},[]);let y=(0,W.useMemo)(()=>e.filter(e=>{let t=!l||e.final_outcome===l,n=s.trim().toLowerCase();return t&&(!n||[e.skill_name,e.task_summary,e.run_id,e.model_id].some(e=>String(e||``).toLowerCase().includes(n)))}),[e,s,l]),b=e.filter(e=>e.finalized_at),x=b.filter(e=>e.final_outcome===`success`).length,S=b.length?b.reduce((e,t)=>e+t.score,0)/b.length:0,C=(0,W.useMemo)(()=>{let t=new Map;return e.forEach(e=>t.set(e.skill_name,[...t.get(e.skill_name)||[],e])),Array.from(t.entries()).map(([e,t])=>({name:e,uses:t.length,average:t.reduce((e,t)=>e+t.score,0)/t.length,success:t.filter(e=>e.final_outcome===`success`).length,failed:t.filter(e=>e.final_outcome===`failure`).length,blocked:t.filter(e=>e.final_outcome===`blocked`).length,lastUsed:t.map(e=>e.created_at).sort().slice(-1)[0]})).sort((e,t)=>t.uses-e.uses)},[e]),w=async e=>{try{o(Tt(await R.get(`/api/v1/skills/trajectories/${e}`)))}catch(e){_(e.response?.data?.detail||`Could not load trajectory detail.`)}},T=async e=>{try{let t=await R.post(`/api/v1/skills/trajectories/export`,{format:e,outcome:l||null,include_raw_prompts:!1,include_full_tool_outputs:!1},{responseType:`blob`}),n=URL.createObjectURL(t.data),r=document.createElement(`a`);r.href=n,r.download=`skill-trajectories.${e===`markdown`?`md`:e}`,r.click(),URL.revokeObjectURL(n)}catch(e){_(e.response?.data?.detail||`Trajectory export failed.`)}};return(0,G.jsxs)(`div`,{className:`shogun-card border-purple-500/20 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row lg:items-center gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest text-purple-300`,children:`Order 10 Evidence`}),(0,G.jsx)(`h3`,{className:`text-lg font-bold`,children:`Skill Trajectories`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Redacted activation, tool, verification, outcome, and improvement evidence.`})]}),(0,G.jsxs)(`div`,{className:`lg:ml-auto flex flex-wrap gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>f(`trajectories`),className:L(`px-3 py-2 rounded-lg border text-xs`,d===`trajectories`?`border-purple-400 text-purple-200 bg-purple-500/10`:`border-shogun-border`),children:`Trajectories`}),(0,G.jsxs)(`button`,{onClick:()=>f(`improvements`),className:L(`px-3 py-2 rounded-lg border text-xs`,d===`improvements`?`border-amber-400 text-amber-200 bg-amber-500/10`:`border-shogun-border`),children:[`Improvements (`,n.length,`)`]}),[`jsonl`,`markdown`,`zip`].map(e=>(0,G.jsxs)(`button`,{onClick:()=>T(e),className:`px-3 py-2 rounded-lg border border-shogun-border text-[10px] uppercase flex items-center gap-1`,children:[(0,G.jsx)(ee,{className:`w-3 h-3`}),e]},e)),(0,G.jsx)(`button`,{onClick:v,className:`p-2 rounded-lg border border-shogun-border`,children:(0,G.jsx)(P,{className:L(`w-4 h-4`,p&&`animate-spin`)})})]})]}),h&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/5 text-red-300 p-3 text-xs flex gap-2`,children:[(0,G.jsx)(Te,{className:`w-4 h-4`}),h]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[[`Captured`,e.length,a],[`Finalized`,b.length,g],[`Success rate`,b.length?`${Math.round(100*x/b.length)}%`:`—`,F],[`Average score`,b.length?S.toFixed(2):`—`,xe]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#050508] border border-shogun-border p-3`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between text-[9px] uppercase text-shogun-subdued`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(n,{className:`w-3.5 h-3.5 text-purple-400`})]}),(0,G.jsx)(`b`,{className:`text-lg mt-1 block`,children:t})]},e))}),C.length>0&&(0,G.jsxs)(`details`,{className:`rounded-lg bg-[#050508] border border-shogun-border`,open:!0,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-xs font-bold uppercase tracking-wider`,children:`Skill Performance`}),(0,G.jsx)(`div`,{className:`overflow-x-auto max-h-52`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`text-[9px] uppercase text-shogun-subdued border-y border-shogun-border`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left px-4 py-2`,children:`Skill`}),(0,G.jsx)(`th`,{children:`Uses`}),(0,G.jsx)(`th`,{children:`Avg score`}),(0,G.jsx)(`th`,{children:`Success`}),(0,G.jsx)(`th`,{children:`Failed`}),(0,G.jsx)(`th`,{children:`Blocked`}),(0,G.jsx)(`th`,{className:`text-right px-4`,children:`Last used`})]})}),(0,G.jsx)(`tbody`,{children:C.map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`px-4 py-2 font-semibold`,children:e.name}),(0,G.jsx)(`td`,{className:`text-center`,children:e.uses}),(0,G.jsx)(`td`,{className:L(`text-center font-mono`,Et(e.average)),children:e.average.toFixed(2)}),(0,G.jsx)(`td`,{className:`text-center text-green-400`,children:e.success}),(0,G.jsx)(`td`,{className:`text-center text-red-400`,children:e.failed}),(0,G.jsx)(`td`,{className:`text-center text-amber-300`,children:e.blocked}),(0,G.jsx)(`td`,{className:`text-right px-4 text-shogun-subdued`,children:e.lastUsed?new Date(e.lastUsed).toLocaleString():`—`})]},e.name))})]})})]}),p&&!e.length?(0,G.jsxs)(`div`,{className:`py-12 flex justify-center gap-2 text-sm text-shogun-subdued`,children:[(0,G.jsx)(N,{className:`w-4 h-4 animate-spin`}),`Loading evidence…`]}):d===`improvements`?(0,G.jsx)(`div`,{className:`grid lg:grid-cols-2 gap-3`,children:n.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#050508] border border-amber-500/20 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(Oe,{className:`w-4 h-4 text-amber-400`}),(0,G.jsx)(`b`,{className:`text-sm`,children:e.skill_name}),(0,G.jsx)(`span`,{className:`ml-auto text-[9px] uppercase text-amber-300`,children:e.priority})]}),(0,G.jsx)(`p`,{className:`text-xs text-red-300 mt-3`,children:e.observed_problem}),(0,G.jsx)(`p`,{className:`text-xs mt-2`,children:e.suggested_improvement}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-2`,children:[`Validate: `,e.validation_idea]}),e.based_on_trajectory_id&&(0,G.jsx)(`button`,{onClick:()=>{f(`trajectories`),w(e.based_on_trajectory_id)},className:`text-[10px] text-purple-300 mt-3`,children:`Open source trajectory →`})]},e.id))}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(me,{className:`absolute left-3 top-2.5 w-4 h-4 text-shogun-subdued`}),(0,G.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Search skill, task, run, or model…`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2 text-xs`})]}),(0,G.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),className:`bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs`,children:[(0,G.jsx)(`option`,{value:``,children:`All outcomes`}),[`unknown`,`success`,`partial_success`,`failure`,`blocked`].map(e=>(0,G.jsx)(`option`,{children:e},e))]})]}),(0,G.jsxs)(`div`,{className:`grid lg:grid-cols-5 gap-3`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 overflow-auto max-h-96`,children:[(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`text-[9px] uppercase text-shogun-subdued border-b border-shogun-border`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left py-2`,children:`Skill / task`}),(0,G.jsx)(`th`,{children:`Model`}),(0,G.jsx)(`th`,{children:`Outcome`}),(0,G.jsx)(`th`,{children:`Score`})]})}),(0,G.jsx)(`tbody`,{children:y.map(e=>(0,G.jsxs)(`tr`,{onClick:()=>w(e.id),className:`border-b border-shogun-border/50 hover:bg-purple-500/5 cursor-pointer`,children:[(0,G.jsxs)(`td`,{className:`py-2`,children:[(0,G.jsx)(`b`,{children:e.skill_name}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued max-w-sm truncate`,children:e.task_summary})]}),(0,G.jsx)(`td`,{className:`text-center text-shogun-subdued`,children:e.model_id||e.model_profile||`—`}),(0,G.jsx)(`td`,{className:`text-center uppercase text-[9px]`,children:e.final_outcome}),(0,G.jsx)(`td`,{className:L(`text-center font-mono`,Et(e.score)),children:e.score.toFixed(2)})]},e.id))})]}),!y.length&&(0,G.jsx)(`p`,{className:`text-center text-sm text-shogun-subdued py-10`,children:`No matching trajectories.`})]}),(0,G.jsx)(`div`,{className:`lg:col-span-2 rounded-lg bg-[#050508] border border-shogun-border p-4 max-h-96 overflow-auto`,children:i?(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(Re,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`b`,{children:i.skill_name})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:i.episode?.task_summary}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase text-shogun-subdued`,children:`Selection`}),(0,G.jsx)(`p`,{className:`text-xs`,children:i.episode?.selection_reason})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase text-shogun-subdued`,children:`Timeline`}),(i.trajectory?.events||[]).map((e,t)=>(0,G.jsxs)(`p`,{className:`text-[10px] border-l border-purple-500/30 pl-2 py-1`,children:[(0,G.jsx)(`b`,{children:e.type}),` — `,e.summary]},`${e.timestamp}-${t}`))]}),(0,G.jsxs)(`div`,{className:`text-[10px] text-shogun-subdued`,children:[i.tool_links?.length||0,` linked tools · `,i.verification_links?.length||0,` verifications · `,i.improvement_candidates?.length||0,` improvements`]})]}):(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center text-center text-xs text-shogun-subdued`,children:`Select a trajectory to inspect its full redacted timeline.`})})]})]})]})}var Ot=e=>e?.data?.data??e?.data??e,kt=e=>e?new Date(e).toLocaleString():`Never`;function At(){let[e,t]=(0,W.useState)([]),[n,r]=(0,W.useState)([]),[i,o]=(0,W.useState)(null),[s,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(!0),[p,m]=(0,W.useState)(null),[h,v]=(0,W.useState)(`Write a complete Shogun implementation build paper`),[y,b]=(0,W.useState)(`campaign`),[x,ee]=(0,W.useState)(null),[S,C]=(0,W.useState)(null),w=async()=>{d(!0);try{let[e,n]=await Promise.all([R.get(`/api/v1/skills`),R.get(`/api/v1/skills/active-runs`,{params:{limit:100}})]),a=Ot(e)||[];t(a),r(Ot(n)||[]),i&&o(a.find(e=>e.id===i.id)||null)}catch(e){C({kind:`error`,text:e.response?.data?.detail||`Could not load active skill usage.`})}finally{d(!1)}};(0,W.useEffect)(()=>{w()},[]);let E=(0,W.useMemo)(()=>{let t=s.trim().toLowerCase();return t?e.filter(e=>[e.name,e.skill_type,e.status,...e.tags||[]].some(e=>String(e).toLowerCase().includes(t))):e},[e,s]),D=e.filter(e=>e.status===`installed`).length,O=n.filter(e=>e.outcome===`success`).length,k=async e=>{m(e.id);try{let t=e.status===`disabled`?`enable`:`disable`;await R.post(`/api/v1/skills/${e.id}/${t}`),C({kind:`ok`,text:`${e.name} ${t}d.`}),await w()}catch(e){C({kind:`error`,text:e.response?.data?.detail||`Skill status could not be changed.`})}finally{m(null)}},A=async(e,t)=>{m(`${e.id}:${t}`);try{await R.post(`/api/v1/skills/${e.id}/${t}`),C({kind:`ok`,text:`${e.name}: ${t===`reindex`?`semantic index updated`:`brief rebuilt`}.`}),await w()}catch(e){C({kind:`error`,text:e.response?.data?.detail||`${t} failed.`})}finally{m(null)}};return u&&!e.length?(0,G.jsxs)(`div`,{className:`shogun-card flex items-center justify-center py-24 gap-3 text-shogun-subdued`,children:[(0,G.jsx)(N,{className:`w-5 h-5 animate-spin text-purple-400`}),` Loading active skill usage…`]}):(0,G.jsxs)(`div`,{className:`space-y-5`,children:[S&&(0,G.jsxs)(`div`,{className:L(`rounded-lg border px-4 py-3 text-sm flex items-center gap-2`,S.kind===`ok`?`border-green-500/30 bg-green-500/5 text-green-400`:`border-red-500/30 bg-red-500/5 text-red-400`),children:[S.kind===`ok`?(0,G.jsx)(g,{className:`w-4 h-4`}):(0,G.jsx)(_,{className:`w-4 h-4`}),S.text]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[[`Installed & enabled`,D,de,`text-green-400`],[`Total activations`,n.length,a,`text-purple-400`],[`Successful outcomes`,O,F,`text-cyan-400`],[`Context ceiling`,`2,500 tokens`,c,`text-shogun-gold`]].map(([e,t,n,r])=>(0,G.jsxs)(`div`,{className:`shogun-card !p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest text-shogun-subdued`,children:e}),(0,G.jsx)(n,{className:L(`w-4 h-4`,r)})]}),(0,G.jsx)(`div`,{className:`mt-2 text-xl font-bold text-shogun-text`,children:t})]},e))}),(0,G.jsx)(Dt,{}),(0,G.jsxs)(`div`,{className:`shogun-card border-purple-500/20`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row lg:items-end gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`text-[9px] uppercase tracking-widest font-bold text-purple-300`,children:`Activation Preview`}),(0,G.jsx)(`textarea`,{value:h,onChange:e=>v(e.target.value),rows:2,className:`mt-2 w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm outline-none focus:border-purple-500`})]}),(0,G.jsx)(`select`,{value:y,onChange:e=>b(e.target.value),className:`bg-[#050508] border border-shogun-border rounded-lg px-3 py-3 text-sm`,children:[`shrine`,`guarded`,`tactical`,`campaign`,`ronin`].map(e=>(0,G.jsx)(`option`,{value:e,children:e.toUpperCase()},e))}),(0,G.jsxs)(`button`,{onClick:async()=>{if(h.trim()){m(`activate`);try{ee(Ot(await R.post(`/api/v1/skills/activate`,{run_id:`katana-preview-${Date.now()}`,objective:h,context:`Katana Active Usage preview`,posture:y,available_tools:y===`campaign`||y===`ronin`?[`chat`,`agent_flow`,`stacks`,`ide.file.read`,`ide.file.apply_patch`,`ide.task.run`]:[`chat`,`agent_flow`,`stacks`],max_skills:5,usage_location:`katana_preview`,ide_enabled:y===`campaign`||y===`ronin`}))),await w()}catch(e){C({kind:`error`,text:e.response?.data?.detail||`Activation preview failed.`})}finally{m(null)}}},disabled:p===`activate`,className:`rounded-lg bg-purple-500/20 border border-purple-400/40 text-purple-200 px-5 py-3 text-xs font-bold uppercase tracking-wider flex items-center justify-center gap-2 disabled:opacity-50`,children:[p===`activate`?(0,G.jsx)(N,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(xe,{className:`w-4 h-4`}),` Activate Skills`]})]}),x&&(0,G.jsxs)(`div`,{className:`mt-5 grid lg:grid-cols-3 gap-4 border-t border-shogun-border pt-5`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] uppercase tracking-widest font-bold`,children:[(0,G.jsx)(`span`,{children:`Active for this run`}),(0,G.jsxs)(`span`,{className:`text-purple-300`,children:[x.total_injected_tokens,` tokens`]})]}),x.active_skills.length?x.active_skills.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-purple-500/20 bg-purple-500/5 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(Ce,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`b`,{className:`text-sm`,children:e.name}),(0,G.jsx)(`span`,{className:`ml-auto text-xs font-mono text-purple-300`,children:e.relevance_score.toFixed(2)})]}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:[e.activation_reason,` · `,e.activation_mode,` · `,e.injected_tokens,` tokens`]})]},e.active_skill_run_id)):(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No skill crossed the activation threshold.`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[10px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Blocked`}),x.blocked_skills.slice(0,6).map(e=>(0,G.jsxs)(`p`,{className:`text-xs text-orange-300 mt-1`,children:[e.name,`: `,e.blocked_reason]},e.skill_id))]}),x.conflict_notes.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[10px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Conflicts resolved`}),x.conflict_notes.map(e=>(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:e},e))]})]})]})]}),(0,G.jsxs)(`div`,{className:`grid lg:grid-cols-5 gap-5`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(me,{className:`w-4 h-4 absolute left-3 top-3 text-shogun-subdued`}),(0,G.jsx)(`input`,{value:s,onChange:e=>l(e.target.value),placeholder:`Search installed skills…`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg py-2.5 pl-9 pr-3 text-sm`})]}),(0,G.jsx)(`button`,{onClick:w,className:`p-2.5 border border-shogun-border rounded-lg`,children:(0,G.jsx)(P,{className:`w-4 h-4`})})]}),(0,G.jsx)(`div`,{className:`space-y-2 max-h-[620px] overflow-y-auto pr-1`,children:E.map(e=>(0,G.jsxs)(`button`,{onClick:()=>o(e),className:L(`w-full text-left rounded-lg border p-3 transition-colors`,i?.id===e.id?`border-purple-500/50 bg-purple-500/5`:`border-shogun-border bg-[#050508] hover:border-shogun-subdued/50`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(c,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`b`,{className:`text-sm truncate`,children:e.name}),(0,G.jsx)(`span`,{className:L(`ml-auto text-[9px] uppercase font-bold`,e.status===`installed`?`text-green-400`:`text-shogun-subdued`),children:e.status}),(0,G.jsx)(f,{className:`w-4 h-4 text-shogun-subdued`})]}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[9px] uppercase tracking-wider text-shogun-subdued`,children:[(0,G.jsx)(`span`,{children:e.skill_type}),(0,G.jsxs)(`span`,{children:[`Exam: `,e.exam_status]}),(0,G.jsxs)(`span`,{children:[e.minimum_posture,`+`]}),(0,G.jsxs)(`span`,{children:[e.usage_count,` uses`]})]})]},e.id))})]}),(0,G.jsx)(`div`,{className:`lg:col-span-2 shogun-card`,children:i?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest text-purple-300`,children:`Skill Detail`}),(0,G.jsx)(`h3`,{className:`text-xl font-bold mt-1`,children:i.name}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`v`,i.version,` · `,i.activation_mode,` · priority `,i.priority,` · `,i.manifest?.source||`local`]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>k(i),disabled:p===i.id,className:L(`flex-1 rounded-lg border py-2 text-xs font-bold uppercase`,i.status===`disabled`?`border-green-500/30 text-green-400`:`border-red-500/30 text-red-300`),children:i.status===`disabled`?`Enable`:`Disable`}),(0,G.jsx)(`button`,{onClick:()=>A(i,`rebuild-brief`),className:`px-3 rounded-lg border border-shogun-border`,title:`Rebuild brief`,children:(0,G.jsx)(T,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>A(i,`reindex`),className:`px-3 rounded-lg border border-shogun-border`,title:`Reindex`,children:(0,G.jsx)(P,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-center`,children:[(0,G.jsxs)(`div`,{className:`bg-[#050508] rounded p-2`,children:[(0,G.jsx)(`b`,{children:i.usage_count}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:`Uses`})]}),(0,G.jsxs)(`div`,{className:`bg-[#050508] rounded p-2`,children:[(0,G.jsx)(`b`,{className:`text-green-400`,children:i.success_count}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:`Success`})]}),(0,G.jsxs)(`div`,{className:`bg-[#050508] rounded p-2`,children:[(0,G.jsx)(`b`,{className:`text-red-400`,children:i.failure_count}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:`Failed`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued mb-1`,children:`Compact brief`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap text-xs leading-relaxed bg-[#050508] border border-shogun-border rounded-lg p-3 max-h-52 overflow-auto`,children:i.brief_text||`Brief not built yet.`})]}),i.body_text&&(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued cursor-pointer`,children:`Full skill body`}),(0,G.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap text-xs leading-relaxed bg-[#050508] border border-shogun-border rounded-lg p-3 max-h-72 overflow-auto`,children:i.body_text})]}),i.requires_tools?.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Required tools`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:i.requires_tools.map(e=>(0,G.jsx)(`code`,{className:`text-[9px] px-2 py-1 rounded bg-cyan-500/5 border border-cyan-500/20 text-cyan-300`,children:e},e))})]}),i.verification_checklist?.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Verification checklist`}),i.verification_checklist.map(e=>(0,G.jsxs)(`p`,{className:`text-xs mt-1 flex gap-2`,children:[(0,G.jsx)(g,{className:`w-3.5 h-3.5 text-green-400 shrink-0`}),e]},e))]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[`Last used: `,kt(i.last_used_at)]})]}):(0,G.jsxs)(`div`,{className:`h-full min-h-72 flex flex-col items-center justify-center text-center text-shogun-subdued`,children:[(0,G.jsx)(c,{className:`w-10 h-10 text-purple-400/40 mb-3`}),(0,G.jsx)(`p`,{className:`text-sm`,children:`Select a skill to inspect its brief, compatibility gates, usage, and verification checklist.`})]})})]}),(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(a,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`h3`,{className:`font-bold`,children:`Recent Skill Usage`})]}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`text-[9px] uppercase tracking-widest text-shogun-subdued border-b border-shogun-border`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left py-2`,children:`Skill`}),(0,G.jsx)(`th`,{className:`text-left`,children:`Where`}),(0,G.jsx)(`th`,{className:`text-left`,children:`Reason`}),(0,G.jsx)(`th`,{children:`Score`}),(0,G.jsx)(`th`,{children:`Tokens`}),(0,G.jsx)(`th`,{children:`Outcome`}),(0,G.jsx)(`th`,{className:`text-right`,children:`When`})]})}),(0,G.jsx)(`tbody`,{children:n.slice(0,30).map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`py-2 font-semibold`,children:e.skill_name||e.skill_id}),(0,G.jsx)(`td`,{children:e.usage_location}),(0,G.jsx)(`td`,{className:`max-w-xs truncate text-shogun-subdued`,children:e.activation_reason}),(0,G.jsx)(`td`,{className:`text-center font-mono`,children:e.relevance_score.toFixed(2)}),(0,G.jsx)(`td`,{className:`text-center`,children:e.injected_tokens}),(0,G.jsx)(`td`,{className:L(`text-center uppercase text-[9px] font-bold`,e.outcome===`success`?`text-green-400`:e.outcome===`failed`?`text-red-400`:`text-shogun-subdued`),children:e.outcome}),(0,G.jsx)(`td`,{className:`text-right text-shogun-subdued`,children:kt(e.created_at)})]},e.id))})]})}),!n.length&&(0,G.jsxs)(`p`,{className:`text-sm text-shogun-subdued py-8 text-center`,children:[(0,G.jsx)(Te,{className:`w-4 h-4 inline mr-2`}),`No skill activations recorded yet.`]})]})]})}var jt=[{id:`1`,name:`WebSearchOpt`,description:`Optimized web scraping logic`,status:`optimized`,lastRun:`2026-07-17 10:00`},{id:`2`,name:`DataParser`,description:`JSON and CSV data extraction`,status:`needs_opt`,lastRun:`2026-07-16 14:30`},{id:`3`,name:`TextSummarizer`,description:`NLP summarization routines`,status:`optimizing`,lastRun:`2026-07-17 15:45`}];function Mt(){let{t:e}=je(),[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(!1),[o,s]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-2xl font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(b,{className:`w-6 h-6 text-shogun-gold`}),e(`skillopt.title`,`Skill Optimization Matrix`)]}),(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued mt-1`,children:e(`skillopt.subtitle`,`Monitor, evaluate, and promote AI-generated skill improvements.`)})]}),(0,G.jsxs)(`button`,{className:`flex items-center gap-2 px-4 py-2 bg-shogun-card border border-shogun-border hover:border-shogun-blue/50 rounded-lg text-sm font-medium transition-all`,children:[(0,G.jsx)(P,{className:`w-4 h-4 text-shogun-blue`}),e(`skillopt.refresh`,`Refresh Status`)]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-6`,children:[(0,G.jsx)(`div`,{className:`lg:col-span-1 space-y-4`,children:(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest mb-4 flex items-center gap-2`,children:[(0,G.jsx)(Me,{className:`w-4 h-4 text-shogun-blue`}),e(`skillopt.available_skills`,`Available Skills`)]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:jt.map(e=>(0,G.jsxs)(`button`,{onClick:()=>n(e.id),className:L(`w-full text-left p-4 rounded-xl border transition-all duration-300`,t===e.id?`bg-shogun-blue/10 border-shogun-blue shadow-[0_0_15px_rgba(74,140,199,0.15)]`:`bg-[#050508] border-shogun-border hover:border-shogun-blue/30`),children:[(0,G.jsxs)(`div`,{className:`flex justify-between items-start mb-1`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-shogun-text`,children:e.name}),e.status===`optimized`&&(0,G.jsx)(h,{className:`w-4 h-4 text-green-400`}),e.status===`optimizing`&&(0,G.jsx)(N,{className:`w-4 h-4 text-amber-400 animate-spin`}),e.status===`needs_opt`&&(0,G.jsx)(ce,{className:`w-4 h-4 text-shogun-blue`})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued line-clamp-1`,children:e.description})]},e.id))})]})}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`shogun-card bg-gradient-to-br from-[#050508] to-shogun-card hover:border-shogun-blue/30 transition-colors`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,G.jsx)(`div`,{className:`p-2 bg-shogun-blue/10 rounded-lg`,children:(0,G.jsx)(a,{className:`w-5 h-5 text-shogun-blue`})}),(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:e(`skillopt.active_runs`,`Active Runs`)})]}),(0,G.jsx)(`p`,{className:`text-3xl font-bold text-shogun-text mt-2`,children:`1`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:e(`skillopt.currently_optimizing`,`Currently optimizing`)})]}),(0,G.jsxs)(`div`,{className:`shogun-card bg-gradient-to-br from-[#050508] to-shogun-card hover:border-green-500/30 transition-colors`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,G.jsx)(`div`,{className:`p-2 bg-green-500/10 rounded-lg`,children:(0,G.jsx)(Se,{className:`w-5 h-5 text-green-400`})}),(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:e(`skillopt.avg_improvement`,`Avg Improvement`)})]}),(0,G.jsx)(`p`,{className:`text-3xl font-bold text-shogun-text mt-2`,children:`+24%`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:e(`skillopt.across_promoted`,`Across all promoted runs`)})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card min-h-[400px] flex flex-col`,children:[(0,G.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest mb-4 flex items-center gap-2`,children:[(0,G.jsx)(Le,{className:`w-4 h-4 text-shogun-gold`}),e(`skillopt.candidate_diffs`,`Candidate Diffs & Promotion`)]}),t?(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg p-4 font-mono text-xs overflow-auto relative`,children:[(0,G.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-2`,children:[(0,G.jsx)(`span`,{className:`px-2 py-1 bg-red-500/10 text-red-400 rounded border border-red-500/20`,children:`- 3 lines`}),(0,G.jsx)(`span`,{className:`px-2 py-1 bg-green-500/10 text-green-400 rounded border border-green-500/20`,children:`+ 4 lines`})]}),(0,G.jsxs)(`div`,{className:`text-shogun-subdued mt-6`,children:[(0,G.jsx)(`span`,{className:`text-red-400 block`,children:`- def process_data(data):`}),(0,G.jsx)(`span`,{className:`text-red-400 block`,children:`- # old implementation`}),(0,G.jsx)(`span`,{className:`text-red-400 block`,children:`- return data.split(",")`}),(0,G.jsx)(`span`,{className:`text-green-400 block mt-2`,children:`+ def process_data(data):`}),(0,G.jsx)(`span`,{className:`text-green-400 block`,children:`+ """AI optimized implementation for speed"""`}),(0,G.jsx)(`span`,{className:`text-green-400 block`,children:`+ import re`}),(0,G.jsx)(`span`,{className:`text-green-400 block`,children:`+ return re.split(r",\\s*", data)`})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex items-center justify-end gap-3 pt-4 border-t border-shogun-border`,children:[(0,G.jsxs)(`button`,{onClick:()=>{s(!0),setTimeout(()=>s(!1),1500)},disabled:o||r,className:`flex items-center gap-2 px-4 py-2 bg-[#050508] hover:bg-red-500/10 text-shogun-subdued hover:text-red-400 border border-shogun-border hover:border-red-500/50 rounded-lg text-sm font-medium transition-all`,children:[o?(0,G.jsx)(N,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(_,{className:`w-4 h-4`}),e(`skillopt.reject`,`Reject Candidate`)]}),(0,G.jsxs)(`button`,{onClick:()=>{i(!0),setTimeout(()=>i(!1),1500)},disabled:r||o,className:`flex items-center gap-2 px-5 py-2 bg-shogun-gold hover:bg-[#e6b422] text-black rounded-lg text-sm font-bold shadow-[0_0_15px_rgba(212,160,23,0.3)] transition-all`,children:[r?(0,G.jsx)(N,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(A,{className:`w-4 h-4`}),e(`skillopt.promote`,`Promote to Prod`)]})]})]}):(0,G.jsxs)(`div`,{className:`flex-1 flex items-center justify-center text-shogun-subdued flex-col gap-3`,children:[(0,G.jsx)(Be,{className:`w-10 h-10 opacity-20`}),(0,G.jsx)(`p`,{children:e(`skillopt.select_skill`,`Select a skill to view optimization candidates`)})]})]})]})]})]})}function Nt(){let[e,t]=(0,W.useState)([]),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``);(0,W.useEffect)(()=>{R.get(`/api/v1/files/formats`).then(e=>t(e.data.data||[])).catch(()=>l(`Could not load the adapter registry.`))},[]);let u=async()=>{if(n.trim()){s(!0),l(``),a(null);try{a((await R.post(`/api/v1/files/inspect`,{path:n.trim(),source:`katana`})).data.data)}catch(e){l(e?.response?.data?.detail?.message||e?.response?.data?.detail||`File inspection failed.`)}finally{s(!1)}}};return(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-300`,children:[(0,G.jsx)(`div`,{className:`rounded-xl border border-cyan-400/20 bg-cyan-500/[0.04] p-5`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(F,{className:`h-5 w-5 shrink-0 text-cyan-400`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text`,children:`Broader File Format Handling`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-shogun-subdued`,children:`Files are detected, safety-checked, parsed deterministically, normalized, and registered before an agent reasons over them. Previews are bounded and likely secrets are masked.`})]})]})}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-bold text-shogun-text`,children:[(0,G.jsx)(Re,{className:`h-4 w-4 text-shogun-gold`}),` Inspect an approved file`]}),(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-shogun-subdued`,children:`Use a file inside the Shogun workspace, uploads, Office, Mado, memory-artifact, or installation workspace boundaries.`})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&u(),placeholder:`C:\\\\...\\\\workspace\\\\orders.csv`,className:`min-w-0 flex-1 rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text outline-none focus:border-shogun-blue`}),(0,G.jsxs)(`button`,{onClick:u,disabled:o||!n.trim(),className:`inline-flex items-center gap-2 rounded-lg bg-shogun-blue px-4 py-2 text-xs font-bold text-white disabled:opacity-50`,children:[o?(0,G.jsx)(N,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(me,{className:`h-4 w-4`}),` Inspect`]})]}),c&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-red-400/25 bg-red-500/5 p-3 text-xs text-red-300`,children:[(0,G.jsx)(Te,{className:`h-4 w-4`}),String(c)]}),i&&(0,G.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-shogun-border bg-shogun-bg/60 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(g,{className:`h-4 w-4 text-green-400`}),(0,G.jsx)(`span`,{className:`font-bold text-shogun-text`,children:i.filename}),(0,G.jsx)(`span`,{className:`rounded border border-cyan-400/25 bg-cyan-500/5 px-2 py-0.5 text-[10px] font-bold uppercase text-cyan-300`,children:i.format_id}),(0,G.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[Math.round((i.detection?.confidence||0)*100),`% via `,i.detection?.method]})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:i.summary}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-[10px] md:grid-cols-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`Size`}),(0,G.jsxs)(`span`,{className:`text-shogun-text`,children:[Number(i.size_bytes).toLocaleString(),` bytes`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`Encoding`}),(0,G.jsx)(`span`,{className:`text-shogun-text`,children:i.encoding||`binary`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`File ID`}),(0,G.jsx)(`span`,{className:`break-all text-shogun-text`,children:i.file_id||`not registered`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`SHA-256`}),(0,G.jsxs)(`span`,{className:`break-all text-shogun-text`,children:[i.hash_sha256?.slice(0,16),`…`]})]})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(i.capabilities||[]).map(e=>(0,G.jsx)(`span`,{className:`rounded bg-shogun-card px-2 py-1 text-[9px] uppercase text-shogun-subdued`,children:e},e))}),(i.warnings||[]).map(e=>(0,G.jsxs)(`div`,{className:`flex gap-2 text-[10px] text-amber-300`,children:[(0,G.jsx)(Te,{className:`h-3.5 w-3.5 shrink-0`}),e]},e)),(0,G.jsxs)(`details`,{className:`text-xs`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer font-bold text-shogun-blue`,children:`Normalized preview and schema`}),(0,G.jsx)(`pre`,{className:`mt-3 max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-black/30 p-3 text-[10px] text-shogun-subdued`,children:JSON.stringify({schema:i.schema,profile:i.data,preview:i.preview},null,2)})]})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card overflow-hidden !p-0`,children:[(0,G.jsxs)(`div`,{className:`border-b border-shogun-border p-5`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text`,children:`Adapter Registry`}),(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-shogun-subdued`,children:`New proprietary adapters can register here without changing the generic file tool pipeline.`})]}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-left text-[10px]`,children:[(0,G.jsx)(`thead`,{className:`bg-shogun-bg uppercase tracking-wider text-shogun-subdued`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`p-3`,children:`Format`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Extensions`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Read`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Write`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Query`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Index`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Risk`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Status`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y divide-shogun-border`,children:e.map(e=>(0,G.jsxs)(`tr`,{className:`text-shogun-subdued`,children:[(0,G.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:e.display_name}),(0,G.jsx)(`td`,{className:`p-3`,children:e.extensions.join(`, `)||`fallback`}),(0,G.jsx)(`td`,{className:`p-3 text-green-400`,children:`Yes`}),(0,G.jsx)(`td`,{className:`p-3`,children:e.supports_write?`Yes`:`—`}),(0,G.jsx)(`td`,{className:`p-3`,children:e.capabilities.includes(`query`)?`Yes`:`—`}),(0,G.jsx)(`td`,{className:`p-3`,children:e.supports_indexing?`Profile`:`—`}),(0,G.jsx)(`td`,{className:`p-3 uppercase`,children:e.risk_level}),(0,G.jsx)(`td`,{className:`p-3 uppercase text-cyan-300`,children:e.status})]},e.format_id))})]})})]})]})}var Pt={display_name:``,email:``,channel:`telegram`,telegram_user_id:``,teams_aad_object_id:``,teams_user_principal_name:``};function q(e){let t=e?.response?.data?.detail;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>e.msg).filter(Boolean).join(` `):e?.message||`The team configuration could not be saved.`}function Ft(){let{t:e}=je(),[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(Pt),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(null),p=async()=>{o(!0),f(null);try{n((await R.get(`/api/v1/team`)).data.data)}catch(e){f(q(e))}finally{o(!1)}};(0,W.useEffect)(()=>{p()},[]);let h=async e=>{if(!(!t||s||t.mode===e)){c(!0),f(null);try{n((await R.put(`/api/v1/team/mode`,{mode:e})).data.data)}catch(e){f(q(e))}finally{c(!1)}}},g=async()=>{if(!(!t||s)){c(!0),f(null);try{await R.post(`/api/v1/team/members`,{...r,telegram_user_id:r.channel===`telegram`&&r.telegram_user_id.trim()||null,teams_aad_object_id:r.channel===`microsoft_teams`&&r.teams_aad_object_id.trim()||null,teams_user_principal_name:r.channel===`microsoft_teams`&&r.teams_user_principal_name.trim()||null}),i(Pt),n((await R.get(`/api/v1/team`)).data.data)}catch(e){f(q(e))}finally{c(!1)}}},_=async t=>{if(!(t.is_primary||!window.confirm(`${e(`katana.team.delete_prefix`,`Delete`)} ${t.display_name} ${e(`katana.team.delete_suffix`,`from this Shogun team? Their channel access will be revoked immediately.`)}`))){u(t.id),f(null);try{await R.delete(`/api/v1/team/members/${t.id}`),n(e=>e&&{...e,members:e.members.filter(e=>e.id!==t.id)})}catch(e){f(q(e))}finally{u(null)}}};if(a)return(0,G.jsxs)(`div`,{className:`shogun-card flex items-center gap-3 text-sm text-shogun-subdued`,children:[(0,G.jsx)(N,{className:`h-4 w-4 animate-spin`}),` `,e(`katana.team.loading`,`Loading team configuration…`)]});if(!t)return(0,G.jsx)(`div`,{className:`shogun-card text-sm text-red-300`,children:e(`katana.team.unavailable`,`Team configuration is unavailable.`)});let v=t.members.filter(e=>!e.is_primary);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-center md:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-bold text-shogun-text`,children:[(0,G.jsx)(Ee,{className:`h-5 w-5 text-shogun-blue`}),` `,e(`katana.team.title`,`Team Mode`)]}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:e(`katana.team.description`,`Only the Primary Admin uses Tenshu. Team Members communicate through Telegram or Microsoft Teams.`)})]}),(0,G.jsx)(`div`,{className:`inline-flex rounded-lg border border-shogun-border bg-shogun-bg p-1`,role:`group`,"aria-label":`Installation mode`,children:[`single`,`team`].map(n=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>void h(n),disabled:s,className:L(`rounded-md px-4 py-2 text-[10px] font-bold uppercase tracking-widest transition-colors disabled:opacity-50`,t.mode===n?`bg-shogun-blue text-white`:`text-shogun-subdued hover:text-shogun-text`),children:n===`single`?e(`katana.team.single_user`,`Single User`):e(`katana.team.team_mode`,`Team Mode`)},n))})]}),(0,G.jsx)(`div`,{className:L(`rounded-lg border p-3 text-xs`,t.mode===`team`?`border-emerald-500/20 bg-emerald-500/5 text-emerald-300`:`border-amber-500/20 bg-amber-500/5 text-amber-200`),children:t.mode===`team`?`${v.length} ${v.length===1?e(`katana.team.member_active_singular`,`Team Member can currently be recognized through the configured channel.`):e(`katana.team.member_active_plural`,`Team Members can currently be recognized through their configured channels.`)}`:e(`katana.team.single_active`,`Single-user mode is active. Saved Team Members are retained, but all of their channel access is disabled.`)})]}),d&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-300`,children:[(0,G.jsx)(m,{className:`h-4 w-4`}),d]}),(0,G.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-3`,children:t.members.map(t=>(0,G.jsxs)(`div`,{className:`shogun-card flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,G.jsx)(`div`,{className:L(`rounded-lg p-2`,t.is_primary?`bg-amber-500/10 text-amber-300`:`bg-blue-500/10 text-blue-300`),children:t.is_primary?(0,G.jsx)(F,{className:`h-5 w-5`}):(0,G.jsx)(H,{className:`h-5 w-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-shogun-text`,children:t.display_name}),(0,G.jsx)(`span`,{className:`rounded border border-shogun-border px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-shogun-subdued`,children:t.is_primary?e(`katana.team.primary_admin`,`Primary Admin`):t.channel===`telegram`?`Telegram`:`Microsoft Teams`}),(0,G.jsx)(`span`,{className:L(`h-2 w-2 rounded-full`,t.active?`bg-emerald-400`:`bg-shogun-subdued`),title:t.active?e(`katana.team.active`,`Active`):e(`katana.team.disabled`,`Disabled`)})]}),t.email&&(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-shogun-subdued`,children:t.email}),!t.is_primary&&(0,G.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] text-shogun-subdued`,children:t.channel===`telegram`?`User ID: ${t.telegram_user_id}`:t.teams_user_principal_name||`Object ID: ${t.teams_aad_object_id}`})]})]}),!t.is_primary&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void _(t),disabled:l===t.id,className:`rounded-lg p-2 text-shogun-subdued transition-colors hover:bg-red-500/10 hover:text-red-400 disabled:opacity-50`,title:e(`katana.team.delete_member`,`Delete Team Member`),children:l===t.id?(0,G.jsx)(N,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(we,{className:`h-4 w-4`})})]},t.id))}),(0,G.jsxs)(`div`,{className:L(`shogun-card space-y-4 self-start`,t.mode!==`team`&&`opacity-60`),children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 font-bold text-shogun-text`,children:[(0,G.jsx)(ue,{className:`h-4 w-4 text-shogun-blue`}),` `,e(`katana.team.add_member`,`Add Team Member`)]}),(0,G.jsx)(`input`,{value:r.display_name,onChange:e=>i({...r,display_name:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.full_name`,`Full name`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}),(0,G.jsx)(`input`,{value:r.email,onChange:e=>i({...r,email:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.email_optional`,`Email (optional)`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}),(0,G.jsxs)(`select`,{value:r.channel,onChange:e=>i({...r,channel:e.target.value}),disabled:t.mode!==`team`,className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`,children:[(0,G.jsx)(`option`,{value:`telegram`,children:`Telegram`}),(0,G.jsx)(`option`,{value:`microsoft_teams`,children:`Microsoft Teams`})]}),r.channel===`telegram`?(0,G.jsx)(`input`,{value:r.telegram_user_id,onChange:e=>i({...r,telegram_user_id:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.telegram_user_id`,`Telegram user ID`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{value:r.teams_user_principal_name,onChange:e=>i({...r,teams_user_principal_name:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.teams_email`,`Teams sign-in email`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}),(0,G.jsx)(`input`,{value:r.teams_aad_object_id,onChange:e=>i({...r,teams_aad_object_id:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.entra_id`,`Entra Object ID (optional if email is set)`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void g(),disabled:t.mode!==`team`||s||!r.display_name.trim()||(r.channel===`telegram`?!r.telegram_user_id.trim():!(r.teams_user_principal_name.trim()||r.teams_aad_object_id.trim())),className:`flex w-full items-center justify-center gap-2 rounded-lg bg-shogun-blue px-4 py-2.5 text-xs font-bold uppercase tracking-wider text-white transition-colors hover:bg-shogun-blue/80 disabled:cursor-not-allowed disabled:opacity-40`,children:[s?(0,G.jsx)(N,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(ue,{className:`h-4 w-4`}),` `,e(`katana.team.add_button`,`Add Member`)]}),(0,G.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued`,children:e(`katana.team.memory_notice`,`Each member receives a separate memory identity. Deleting a member revokes access and archives that member’s private memory slot.`)})]})]})]})}var It={google:{label:`Gemini Model Reference`,url:`https://ai.google.dev/gemini-api/docs/models`},openai:{label:`OpenAI Model Reference`,url:`https://platform.openai.com/docs/models`},anthropic:{label:`Claude Model Overview`,url:`https://platform.claude.com/docs/en/about-claude/models/overview`},openrouter:{label:`OpenRouter Model Catalog`,url:`https://openrouter.ai/models`}},Lt={openai:`https://api.openai.com/v1`,google:`https://generativelanguage.googleapis.com/v1beta/openai`,anthropic:`https://api.anthropic.com/v1`,openrouter:`https://openrouter.ai/api/v1`,ollama:`http://127.0.0.1:11434`,lmstudio:`http://localhost:1234/v1`,local:`http://localhost:1234/v1`,custom:``},Rt=[`ollama`,`lmstudio`,`local`],zt=e=>Rt.includes(e),Bt=[`api`,`tool`,`mcp`,`filesystem`,`database`,`queue`,`custom`],Vt=[`api_key`,`oauth`,`token`,`custom`,`none`],Ht=[`low`,`medium`,`high`,`critical`],Ut=[{name:`OpenWeatherMap`,description:`Current weather, 5-day forecasts, and 40+ year historical data for any location.`,base_url:`https://api.openweathermap.org/data/2.5`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`WeatherAPI`,description:`Real-time, forecast, and historical weather covering astronomy, air quality and alerts.`,base_url:`https://api.weatherapi.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open-Meteo`,description:`Free, open-source weather API with hourly forecasts and no API key required.`,base_url:`https://api.open-meteo.com/v1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Tomorrow.io`,description:`Hyper-local weather intelligence with AI-powered forecasting.`,base_url:`https://api.tomorrow.io/v4`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NOAA NGDC`,description:`Natural hazards data including earthquakes, tsunamis, and volcanic eruptions.`,base_url:`https://www.ngdc.noaa.gov/hazel/hazard-service/api/v1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Air Quality Index`,description:`Real-time air quality data including AQI and pollutant concentrations for worldwide locations.`,base_url:`https://api.api-ninjas.com/v1/airquality`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Storm Glass`,description:`Marine weather, solar and wind energy data, and tide forecasts from premium sources.`,base_url:`https://api.stormglass.io/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Météo-France`,description:`Official French meteorological service API — forecasts, radar, and climatology.`,base_url:`https://public-api.meteofrance.fr/public`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NASA APOD`,description:`Astronomy Picture of the Day with title, explanation, and image URL.`,base_url:`https://api.nasa.gov/planetary/apod`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NASA Exoplanet Archive`,description:`Confirmed exoplanet data from the NASA Exoplanet Science Institute.`,base_url:`https://exoplanetarchive.ipac.caltech.edu/TAP`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Open Notify ISS`,description:`Real-time position of the International Space Station and crew on board.`,base_url:`http://api.open-notify.org`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`SpaceX API`,description:`Data on SpaceX launches, rockets, capsules, crew, and Starlink satellites.`,base_url:`https://api.spacexdata.com/v4`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Newton API`,description:`Micro-service for advanced math operations — simplify, factor, derive, integrate.`,base_url:`https://newton.vercel.app/api/v2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Numbers API`,description:`Interesting facts about numbers — trivia, math, dates, and years.`,base_url:`http://numbersapi.com`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Wolfram Alpha`,description:`Computational intelligence: solve math, science, and data questions via natural language.`,base_url:`https://api.wolframalpha.com/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`USGS Earthquake Hazards`,description:`Real-time earthquake data from the US Geological Survey feed.`,base_url:`https://earthquake.usgs.gov/fdsnws/event/1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`WoRMS`,description:`Authoritative global list of marine species names and taxonomy.`,base_url:`https://www.marinespecies.org/rest`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`GitHub`,description:`Repos, issues, pull requests, Actions, Gists, and more.`,base_url:`https://api.github.com`,auth_type:`token`,connector_type:`api`,risk_level:`medium`},{name:`GitLab`,description:`Full DevSecOps platform — repos, CI/CD, merge requests, and packages.`,base_url:`https://gitlab.com/api/v4`,auth_type:`api_key`,connector_type:`api`,risk_level:`medium`},{name:`SerpApi`,description:`Structured Google, Bing, and DuckDuckGo SERP data via a scraping API.`,base_url:`https://serpapi.com/search`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Hacker News`,description:`Official HN API — stories, jobs, polls, comments, and user profiles.`,base_url:`https://hacker-news.firebaseio.com/v0`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`npm Registry`,description:`Search packages, fetch metadata, download stats from the npm registry.`,base_url:`https://registry.npmjs.org`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`PyPI`,description:`Python Package Index — package metadata, releases, and dependencies.`,base_url:`https://pypi.org/pypi`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Codeforces`,description:`Competitive programming — problems, submissions, contests, and user ratings.`,base_url:`https://codeforces.com/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`JDoodle`,description:`Online compiler and code execution API — 70+ programming languages.`,base_url:`https://api.jdoodle.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Transport for London`,description:`Live tube, bus, bike, and Elizabeth line data from TfL Unified API.`,base_url:`https://api.tfl.gov.uk`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`OpenSky Network`,description:`Real-time and historical flight tracking data — global ADS-B coverage.`,base_url:`https://opensky-network.org/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`AviationStack`,description:`Global real-time flight status, airline routes, and airport information.`,base_url:`https://api.aviationstack.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`MTA Realtime Feeds`,description:`NYC subway real-time GTFS and arrival feeds from the Metropolitan Transit Authority.`,base_url:`https://api-endpoint.mta.info/Dataservice`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`BART (SF Bay Area)`,description:`San Francisco Bay Area Rapid Transit real-time departure estimates and station info.`,base_url:`https://api.bart.gov/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Citybikes`,description:`Bike-sharing station availability from 400+ networks worldwide.`,base_url:`https://api.citybik.es/v2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`CarAPI`,description:`Make, model, trims and specs for vehicles — developer-friendly vehicle data.`,base_url:`https://carapi.app/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Uber`,description:`Request rides, get price estimates, and query trip history via the Uber API.`,base_url:`https://api.uber.com/v1.2`,auth_type:`oauth`,connector_type:`api`,risk_level:`medium`},{name:`Carbon Interface`,description:`Estimate carbon emissions for flights, vehicles, electricity, and shipping.`,base_url:`https://www.carboninterface.com/api/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`1ClickImpact`,description:`Environmental impact API — tree planting, carbon offsetting, and ocean cleanup.`,base_url:`https://api.1clickimpact.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Global Fishing Watch`,description:`Vessel tracking, fishing activity detection, and ocean monitoring data.`,base_url:`https://gateway.api.globalfishingwatch.org/v3`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`EPA AQS`,description:`US EPA Air Quality System — historical and current ambient air monitoring data.`,base_url:`https://aqs.epa.gov/data/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open FDA`,description:`US FDA data — drug labels, adverse events, recalls, and device reports.`,base_url:`https://api.fda.gov`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`National Library of Medicine UMLS`,description:`Unified Medical Language System — medical concepts, relationships, and terminology.`,base_url:`https://uts-ws.nlm.nih.gov/rest`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Nutritionix`,description:`Nutrition data for foods and restaurant menu items — natural language NLP queries.`,base_url:`https://trackapi.nutritionix.com/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Disease.sh`,description:`COVID-19 and global disease statistics — countries, vaccines, and historical data.`,base_url:`https://disease.sh/v3`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`TheMealDB`,description:`1,000+ international recipes with ingredients, measures, and instructional videos.`,base_url:`https://www.themealdb.com/api/json/v1/1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`TheCocktailDB`,description:`Cocktail recipes, ingredients, and drink images from a crowd-sourced database.`,base_url:`https://www.thecocktaildb.com/api/json/v1/1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Open Food Facts`,description:`Collaborative food product database — ingredients, nutritional facts, and barcode lookup.`,base_url:`https://world.openfoodfacts.org/api/v3`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Spoonacular`,description:`Recipe search, meal planning, ingredient parsing, and wine pairing.`,base_url:`https://api.spoonacular.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`API-Football`,description:`Live scores, fixtures, standings, and stats for 900+ football leagues worldwide.`,base_url:`https://v3.football.api-sports.io`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`iSports API`,description:`Live and historical data for global competitions — scores, fixtures, and player stats.`,base_url:`https://api.isportsapi.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NBA Stats`,description:`Comprehensive NBA player statistics, advanced metrics, and game data.`,base_url:`https://stats.nba.com/stats`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Fantasy Premier League`,description:`FPL player data, fixtures, team standings, and gameweek history.`,base_url:`https://fantasy.premierleague.com/api`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Ergast Motor Racing`,description:`Formula 1 race data — results, standings, lap times, and pit stops since 1950.`,base_url:`https://ergast.com/api/f1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`NewsAPI`,description:`Search and retrieve news articles from 150,000+ sources worldwide in real time.`,base_url:`https://newsapi.org/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`World News API`,description:`Search through millions of semantically tagged worldwide news articles.`,base_url:`https://api.worldnewsapi.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Guardian`,description:`Full-text access to The Guardian newspaper — 2M+ articles since 1999.`,base_url:`https://content.guardianapis.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`New York Times`,description:`Article search, Top Stories, Books Bestsellers, and Movie Reviews APIs.`,base_url:`https://api.nytimes.com/svc`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open Library`,description:`Internet Archive open library — 20M+ book records, covers, and editions.`,base_url:`https://openlibrary.org/api`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Google Books`,description:`Search 40M+ books, retrieve metadata, previews, and reading links.`,base_url:`https://www.googleapis.com/books/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Wikipedia`,description:`Access Wikipedia article summaries, sections, and linked data via REST.`,base_url:`https://en.wikipedia.org/api/rest_v1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Spotify`,description:`Tracks, artists, albums, playlists, audio features, and playback control.`,base_url:`https://api.spotify.com/v1`,auth_type:`oauth`,connector_type:`api`,risk_level:`medium`},{name:`Last.fm`,description:`Scrobbling, artist bios, top tracks, and music charts from a 50M listener community.`,base_url:`https://ws.audioscrobbler.com/2.0`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`MusicBrainz`,description:`Open music encyclopedia — artists, recordings, releases, and relationships.`,base_url:`https://musicbrainz.org/ws/2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Data USA`,description:`Visualise and query US demographic, economic, and educational data.`,base_url:`https://datausa.io/api/data`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`US Census Bureau`,description:`American Community Survey — population, income, housing, and demographics.`,base_url:`https://api.census.gov/data`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`World Bank`,description:`Global development indicators — GDP, poverty, health, education, and more.`,base_url:`https://api.worldbank.org/v2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`civicAPI`,description:`Live and historic election results and voter registration data from around the world.`,base_url:`https://civicapi.com/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Data Commons (Google)`,description:`Global disaster events, climate, and statistics maintained as an open knowledge graph.`,base_url:`https://api.datacommons.org`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Stripe`,description:`Payment processing, subscriptions, invoices, and billing for businesses.`,base_url:`https://api.stripe.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`high`},{name:`CoinGecko`,description:`Crypto market data — prices, volumes, OHLC, and market cap for 10,000+ coins.`,base_url:`https://api.coingecko.com/api/v3`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Alpha Vantage`,description:`Stock, ETF, forex, and crypto time-series and fundamental data.`,base_url:`https://www.alphavantage.co`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Polygon.io`,description:`Real-time and historical US and global stock market data with WebSocket support.`,base_url:`https://api.polygon.io/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open Exchange Rates`,description:`Real-time and historical currency exchange rates for 190+ currencies.`,base_url:`https://openexchangerates.org/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Twilio`,description:`SMS, voice, WhatsApp, and email communications at global scale.`,base_url:`https://api.twilio.com/2010-04-01`,auth_type:`api_key`,connector_type:`api`,risk_level:`medium`},{name:`SendGrid`,description:`Transactional and marketing email delivery API with analytics.`,base_url:`https://api.sendgrid.com/v3`,auth_type:`api_key`,connector_type:`api`,risk_level:`medium`},{name:`Slack`,description:`Send messages, create channels, manage workspaces, and build apps.`,base_url:`https://slack.com/api`,auth_type:`oauth`,connector_type:`api`,risk_level:`medium`},{name:`Mapbox`,description:`Custom maps, geocoding, navigation, isochrones, and elevation data.`,base_url:`https://api.mapbox.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`OpenStreetMap Nominatim`,description:`Free geocoding and reverse-geocoding based on OpenStreetMap data.`,base_url:`https://nominatim.openstreetmap.org`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`IPinfo`,description:`IP geolocation, ASN, carrier, and privacy detection data.`,base_url:`https://ipinfo.io`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`}],Wt=[{name:`Brave Search`,description:`Web and local search via the Brave Search API.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-brave-search`],env_keys:[`BRAVE_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-brave-search`},{name:`Tavily Search`,description:`AI-optimized search engine for LLMs and RAG pipelines.`,command:`npx`,args:[`-y`,`tavily-mcp@latest`],env_keys:[`TAVILY_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/tavily-ai/tavily-mcp`,npm_package:`tavily-mcp`},{name:`Exa Search`,description:`Neural search engine for finding relevant content.`,command:`npx`,args:[`-y`,`@exa-labs/exa-mcp-server`],env_keys:[`EXA_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/exa-labs/exa-mcp-server`,npm_package:`@exa-labs/exa-mcp-server`},{name:`SerpAPI`,description:`Google, Bing, Yahoo and other search engine results.`,command:`npx`,args:[`-y`,`serpapi-mcp-server`],env_keys:[`SERPAPI_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/serpapi/serpapi-mcp`,npm_package:`serpapi-mcp-server`},{name:`Puppeteer`,description:`Browser automation and web scraping using Puppeteer.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-puppeteer`],env_keys:[],transport:`stdio`,category:`Web Scraping`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-puppeteer`},{name:`Playwright`,description:`Browser automation across Chromium, Firefox, and WebKit.`,command:`npx`,args:[`-y`,`@executeautomation/playwright-mcp-server`],env_keys:[],transport:`stdio`,category:`Web Scraping`,risk_level:`medium`,github_url:`https://github.com/executeautomation/playwright-mcp-server`,npm_package:`@executeautomation/playwright-mcp-server`},{name:`Firecrawl`,description:`Web scraping and crawling with AI-ready markdown output.`,command:`npx`,args:[`-y`,`firecrawl-mcp`],env_keys:[`FIRECRAWL_API_KEY`],transport:`stdio`,category:`Web Scraping`,risk_level:`medium`,github_url:`https://github.com/mendableai/firecrawl-mcp`,npm_package:`firecrawl-mcp`},{name:`Fetch`,description:`Fetch and convert web pages to markdown or plain text.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-fetch`],env_keys:[],transport:`stdio`,category:`Web Scraping`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-fetch`},{name:`GitHub`,description:`Repository management, file operations, issues, PRs, and more.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-github`],env_keys:[`GITHUB_PERSONAL_ACCESS_TOKEN`],transport:`stdio`,category:`Development`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-github`},{name:`GitLab`,description:`Project management, issues, merge requests, and CI/CD on GitLab.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-gitlab`],env_keys:[`GITLAB_PERSONAL_ACCESS_TOKEN`,`GITLAB_API_URL`],transport:`stdio`,category:`Development`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-gitlab`},{name:`Context7`,description:`Up-to-date, version-specific library docs and code examples.`,command:`npx`,args:[`-y`,`@upstash/context7-mcp@latest`],env_keys:[],transport:`stdio`,category:`Development`,risk_level:`low`,github_url:`https://github.com/upstash/context7-mcp`,npm_package:`@upstash/context7-mcp`},{name:`Sentry`,description:`Error monitoring, performance data, and issue management.`,command:`npx`,args:[`-y`,`@sentry/mcp-server`],env_keys:[`SENTRY_AUTH_TOKEN`],transport:`stdio`,category:`Development`,risk_level:`low`,github_url:`https://github.com/getsentry/sentry-mcp`,npm_package:`@sentry/mcp-server`},{name:`PostgreSQL`,description:`Query and manage PostgreSQL databases with schema inspection.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-postgres`],env_keys:[`POSTGRES_CONNECTION_STRING`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-postgres`},{name:`SQLite`,description:`Query and manage SQLite databases and run business analytics.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-sqlite`],env_keys:[`SQLITE_DB_PATH`],transport:`stdio`,category:`Database`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-sqlite`},{name:`MySQL`,description:`Query and manage MySQL databases.`,command:`npx`,args:[`-y`,`@benborla29/mcp-server-mysql`],env_keys:[`MYSQL_HOST`,`MYSQL_USER`,`MYSQL_PASSWORD`,`MYSQL_DATABASE`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/benborla/mcp-server-mysql`,npm_package:`@benborla29/mcp-server-mysql`},{name:`MongoDB`,description:`CRUD operations, aggregation, and index management for MongoDB.`,command:`npx`,args:[`-y`,`mongodb-mcp-server`],env_keys:[`MONGODB_URI`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/mongodb-js/mongodb-mcp-server`,npm_package:`mongodb-mcp-server`},{name:`Redis`,description:`Key-value operations, pub/sub, and data structure management.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-redis`],env_keys:[`REDIS_URL`],transport:`stdio`,category:`Database`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-redis`},{name:`Supabase`,description:`Database, auth, storage, and edge functions on Supabase.`,command:`npx`,args:[`-y`,`@supabase/mcp-server-supabase@latest`],env_keys:[`SUPABASE_ACCESS_TOKEN`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/supabase-community/supabase-mcp`,npm_package:`@supabase/mcp-server-supabase`},{name:`Slack`,description:`Send messages, manage channels, and search across workspaces.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-slack`],env_keys:[`SLACK_BOT_TOKEN`,`SLACK_TEAM_ID`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-slack`},{name:`Google Drive`,description:`Search, read, and manage files in Google Drive.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-gdrive`],env_keys:[`GDRIVE_CREDENTIALS_PATH`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-gdrive`},{name:`Notion`,description:`Search, read, create, and update pages and databases in Notion.`,command:`npx`,args:[`-y`,`@notionhq/notion-mcp-server`],env_keys:[`NOTION_API_KEY`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/makenotion/notion-mcp-server`,npm_package:`@notionhq/notion-mcp-server`},{name:`Linear`,description:`Manage issues, projects, and teams in Linear.`,command:`npx`,args:[`-y`,`@linear/mcp-server`],env_keys:[`LINEAR_API_KEY`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/linear/linear-mcp-server`,npm_package:`@linear/mcp-server`},{name:`Todoist`,description:`Manage tasks, projects, and labels in Todoist.`,command:`npx`,args:[`-y`,`@abhiz123/todoist-mcp-server`],env_keys:[`TODOIST_API_TOKEN`],transport:`stdio`,category:`Productivity`,risk_level:`low`,github_url:`https://github.com/abhiz123/todoist-mcp-server`,npm_package:`@abhiz123/todoist-mcp-server`},{name:`Atlassian`,description:`Manage Jira issues, Confluence pages, and Opsgenie alerts.`,command:`npx`,args:[`-y`,`@anthropic/atlassian-mcp-server`],env_keys:[`ATLASSIAN_API_TOKEN`,`ATLASSIAN_EMAIL`,`ATLASSIAN_DOMAIN`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/atlassian/atlassian-mcp-server`,npm_package:`@anthropic/atlassian-mcp-server`},{name:`Gmail`,description:`Send, read, search, and manage emails via Gmail API.`,command:`npx`,args:[`-y`,`@anthropic/gmail-mcp-server`],env_keys:[`GMAIL_CREDENTIALS_PATH`],transport:`stdio`,category:`Communication`,risk_level:`high`,github_url:`https://github.com/anthropics/gmail-mcp-server`,npm_package:`@anthropic/gmail-mcp-server`},{name:`Discord`,description:`Send and read messages, manage channels in Discord.`,command:`npx`,args:[`-y`,`discord-mcp`],env_keys:[`DISCORD_BOT_TOKEN`],transport:`stdio`,category:`Communication`,risk_level:`medium`,github_url:`https://github.com/v-3/discord-mcp`,npm_package:`discord-mcp`},{name:`AWS`,description:`Manage AWS resources and services via CLI commands.`,command:`npx`,args:[`-y`,`@aws/aws-mcp-server`],env_keys:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`],transport:`stdio`,category:`Cloud`,risk_level:`critical`,github_url:`https://github.com/awslabs/mcp`,npm_package:`@aws/aws-mcp-server`},{name:`Cloudflare`,description:`Deploy and configure Workers, KV, R2, D1 on Cloudflare.`,command:`npx`,args:[`-y`,`@cloudflare/mcp-server-cloudflare`],env_keys:[`CLOUDFLARE_API_TOKEN`],transport:`stdio`,category:`Cloud`,risk_level:`high`,github_url:`https://github.com/cloudflare/mcp-server-cloudflare`,npm_package:`@cloudflare/mcp-server-cloudflare`},{name:`Vercel`,description:`Manage deployments, projects, and domains on Vercel.`,command:`npx`,args:[`-y`,`@vercel/mcp-adapter`],env_keys:[`VERCEL_TOKEN`],transport:`stdio`,category:`Cloud`,risk_level:`high`,github_url:`https://github.com/vercel/mcp-adapter`,npm_package:`@vercel/mcp-adapter`},{name:`Docker`,description:`Manage containers, images, volumes, and networks.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-docker`],env_keys:[],transport:`stdio`,category:`Cloud`,risk_level:`high`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-docker`},{name:`Filesystem`,description:`Secure file operations with configurable access controls.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-filesystem`],env_keys:[],transport:`stdio`,category:`File System`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-filesystem`},{name:`Google Cloud Storage`,description:`Read and write files in Google Cloud Storage buckets.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-gcs`],env_keys:[`GCS_CREDENTIALS_PATH`],transport:`stdio`,category:`File System`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-gcs`},{name:`Stripe`,description:`Manage payments, customers, invoices, and subscriptions.`,command:`npx`,args:[`-y`,`@stripe/mcp@latest`],env_keys:[`STRIPE_SECRET_KEY`],transport:`stdio`,category:`Finance`,risk_level:`critical`,github_url:`https://github.com/stripe/agent-toolkit`,npm_package:`@stripe/mcp`},{name:`Qdrant`,description:`Vector search, similarity queries, and collection management.`,command:`npx`,args:[`-y`,`@qdrant/mcp-server-qdrant`],env_keys:[`QDRANT_URL`,`QDRANT_API_KEY`],transport:`stdio`,category:`AI / Memory`,risk_level:`medium`,github_url:`https://github.com/qdrant/mcp-server-qdrant`,npm_package:`@qdrant/mcp-server-qdrant`},{name:`Memory`,description:`Persistent memory using a local knowledge graph.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-memory`],env_keys:[],transport:`stdio`,category:`AI / Memory`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-memory`},{name:`Sequential Thinking`,description:`Dynamic, reflection-based problem-solving through thought sequences.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-sequential-thinking`],env_keys:[],transport:`stdio`,category:`Utilities`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-sequential-thinking`},{name:`Everything`,description:`Reference MCP server that demonstrates all protocol features.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-everything`],env_keys:[],transport:`stdio`,category:`Utilities`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-everything`},{name:`Time`,description:`Get current time and convert between time zones.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-time`],env_keys:[],transport:`stdio`,category:`Utilities`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-time`}],Gt=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``),Kt=e=>({low:`text-green-400 border-green-400/30 bg-green-400/5`,medium:`text-yellow-400 border-yellow-400/30 bg-yellow-400/5`,high:`text-orange-400 border-orange-400/30 bg-orange-400/5`,critical:`text-red-400 border-red-400/30 bg-red-400/5`})[e];function qt(){let e=i(),[t,n]=(0,W.useState)(`providers`);(0,W.useEffect)(()=>{let e=()=>{let e=window.location.hash.replace(`#`,``);[`providers`,`tools`,`files`,`routing`,`skills`,`team`,`telegram`,`teams`,`mail_calendar`,`office`,`ide`,`mado`,`ronin`,`skillopt`].includes(e)&&n(e)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let{t:r}=je(),[a,c]=(0,W.useState)(null),[d,h]=(0,W.useState)(``),[_,v]=(0,W.useState)(`polling`),[y,O]=(0,W.useState)(``),[A,ne]=(0,W.useState)(``),[ie,oe]=(0,W.useState)(``),[se,ce]=(0,W.useState)(!1),[le,fe]=(0,W.useState)(!1),[ge,_e]=(0,W.useState)(null),[ye,xe]=(0,W.useState)(!1),[Ce,Te]=(0,W.useState)(!1),[Me,Pe]=(0,W.useState)([]),[Ie,Le]=(0,W.useState)({}),[Re,ze]=(0,W.useState)(null),[z,Be]=(0,W.useState)(null),[B,V]=(0,W.useState)({provider:`gmail`,display_name:``,email_address:``,protocol:`imap`,imap_host:`imap.gmail.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.gmail.com`,smtp_port:587,smtp_use_ssl:!0,username:``,password:``,caldav_url:`https://apidata.googleusercontent.com/caldav/v1/calendars/primary/events`,calendar_provider:`google_api`,calendar_credentials:null}),[He,We]=(0,W.useState)(!1),[Ge,Ke]=(0,W.useState)(!1),[qe,Ye]=(0,W.useState)(null),[Xe,Qe]=(0,W.useState)({perm_read_mail:!0,perm_send_mail:!1,perm_delete_mail:!1,perm_read_calendar:!0,perm_create_events:!1,perm_edit_events:!1,perm_delete_events:!1}),[$e,et]=(0,W.useState)(!1),[tt,nt]=(0,W.useState)(null),[K,rt]=(0,W.useState)(null),[it,at]=(0,W.useState)(``),[ot,st]=(0,W.useState)(!1),[ct,lt]=(0,W.useState)(!1),[ut,ft]=(0,W.useState)(!1),pt=async()=>{try{let[e,t,n]=await Promise.all([R.get(`/api/v1/office/status`),R.get(`/api/v1/office/config`),R.get(`/api/v1/security/posture`)]);e.data?.success&&nt(e.data.data),t.data?.success&&rt(t.data.data),n.data?.data?.active_tier&&at(n.data.data.active_tier)}catch(e){console.error(`Failed to load Office data:`,e)}},mt=async()=>{if(K){st(!0);try{let e=await R.post(`/api/v1/office/config`,K);e.data?.success&&(rt(e.data.data),ft(!1),q({type:`success`,text:`Office configuration saved`}),setTimeout(()=>q(null),3e3))}catch{q({type:`error`,text:`Failed to save Office configuration`}),setTimeout(()=>q(null),3e3)}finally{st(!1)}}},ht=async()=>{lt(!0);try{await R.post(`/api/v1/office/detect`),await pt()}catch(e){console.error(`Detection failed:`,e)}finally{lt(!1)}},gt=(e,t)=>{if(!K)return;let n=e.split(`.`),r=JSON.parse(JSON.stringify(K)),i=r;for(let e=0;e{let e=St.find(e=>e.status===`connected`&&zt(e.provider_type));zt(J.provider_type)?(Cr(J.provider_type,J.base_url),Zt||(J.provider_type===`ollama`?Qt(`%USERPROFILE%\\.ollama\\models`):Qt(``))):e?Cr(e.provider_type,e.base_url):(Ot([]),Qt(``))},[J.provider_type,J.base_url,St]);let[rn,an]=(0,W.useState)(`all`),[on,sn]=(0,W.useState)(null),[cn,ln]=(0,W.useState)(null),[un,dn]=(0,W.useState)(``),[fn,pn]=(0,W.useState)(``),[mn,hn]=(0,W.useState)([]),[gn,_n]=(0,W.useState)(!1),[vn,yn]=(0,W.useState)(1),[bn,xn]=(0,W.useState)(!1),[Sn,Cn]=(0,W.useState)(!1),wn=async(e,t,n=!1)=>{t===1?_n(!0):Cn(!0);try{let r={};e.trim()&&(r.q=e.trim()),t>1&&(r.p=String(t)),rn!==`all`&&(r.c=rn);let i=await R.get(`/api/v1/system/ollama-search`,{params:r});if(i.data?.success){let e=i.data.data;hn(t=>n?[...t,...e.models]:e.models),xn(e.has_more),yn(e.page)}}catch{n||hn([])}finally{_n(!1),Cn(!1)}};(0,W.useEffect)(()=>{if(!tn)return;let e=setTimeout(()=>{wn(fn,1,!1)},300);return()=>clearTimeout(e)},[fn,rn,tn]),(0,W.useEffect)(()=>{tn&&mn.length===0&&wn(``,1,!1)},[tn]);let[Tn,En]=(0,W.useState)(!1),[Dn,On]=(0,W.useState)(`quick`),[kn,An]=(0,W.useState)(``),[Y,jn]=(0,W.useState)(null),[Mn,Nn]=(0,W.useState)(!1),[Pn,Fn]=(0,W.useState)(``),[X,In]=(0,W.useState)({name:``,slug:``,base_url:``,connector_type:`api`,auth_type:`api_key`,risk_level:`low`}),[Ln,Rn]=(0,W.useState)(!1),[zn,Bn]=(0,W.useState)(`quick`),[Vn,Hn]=(0,W.useState)(``),[Z,Un]=(0,W.useState)(null),[Wn,Gn]=(0,W.useState)({}),[Q,Kn]=(0,W.useState)({name:``,command:``,args:``,transport:`stdio`,risk_level:`medium`}),qn=(0,W.useMemo)(()=>{if(!Vn.trim())return Wt;let e=Vn.toLowerCase();return Wt.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.category.toLowerCase().includes(e))},[Vn]),[Jn,Yn]=(0,W.useState)([]),[Xn,Zn]=(0,W.useState)(!1),[Qn,$n]=(0,W.useState)(!1),[er,tr]=(0,W.useState)(!1),[nr,rr]=(0,W.useState)(null),[ir,ar]=(0,W.useState)(!1),[or,sr]=(0,W.useState)({name:``,description:``,is_default:!1}),[$,cr]=(0,W.useState)({task_type:`*`,primary_model_id:``,fallback_model_ids:[],latency_bias:``,cost_bias:``}),[lr,ur]=(0,W.useState)(null);(0,W.useEffect)(()=>{dr()},[]);let dr=async()=>{yt(!0);try{let[e,t,n]=await Promise.all([R.get(`/api/v1/model-providers`),R.get(`/api/v1/tools`),R.get(`/api/v1/model-routing-profiles`)]);wt(e.data.data||[]),Et(t.data.data||[]),Yn(n.data.data||[])}catch(e){console.error(`Error fetching Katana data:`,e)}finally{yt(!1)}},fr=async()=>{try{let[e,t]=await Promise.all([R.get(`/api/v1/channels/telegram/status`),R.get(`/api/v1/channels/telegram/topics`)]),n=e.data.data;c(n),n?.mode&&v(n.mode),n?.allowed_chat_ids?.length&&ne(n.allowed_chat_ids.join(`, `)),n?.webhook_url&&O(n.webhook_url||``);let r=t.data.data||[];Pe(r);let i={};r.forEach(e=>(e.topics||[]).forEach(t=>{i[`${e.chat_id}:${t.message_thread_id}`]=t.name||``})),Le(i)}catch{}},pr=async(e,t)=>{let n=`${e}:${t}`,r=(Ie[n]||``).trim();if(r){ze(n);try{await R.put(`/api/v1/channels/telegram/topics/${encodeURIComponent(e)}/${t}`,{name:r}),await fr(),q({type:`success`,text:`Telegram topic ${t} mapped to “${r}”.`})}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Topic mapping could not be saved.`})}finally{ze(null),setTimeout(()=>q(null),4e3)}}},mr=async e=>{if(e.preventDefault(),d.trim()){ce(!0);try{let e=(await R.post(`/api/v1/channels/telegram/connect`,{bot_token:d.trim(),mode:_,allowed_chat_ids:A.split(`,`).map(e=>e.trim()).filter(Boolean),webhook_url:_===`webhook`?y.trim():null})).data.data;c(e),e.connected?(q({type:`success`,text:`Connected as @${e.bot_username}`}),h(``)):q({type:`error`,text:e.error||r(`katana.connection_failed`)})}catch{q({type:`error`,text:r(`katana.connect_failed`)})}finally{ce(!1),setTimeout(()=>q(null),4e3)}}},hr=async()=>{if(ie.trim()){fe(!0),_e(null);try{_e((await R.post(`/api/v1/channels/telegram/test`,{chat_id:ie.trim()})).data.data)}catch(e){_e({ok:!1,error:e.message||`Request failed`})}finally{fe(!1)}}},gr=async()=>{xe(!0),_e(null);try{let e=(await R.post(`/api/v1/channels/telegram/detect`)).data.data;if(e.ok&&e.chat_id){oe(e.chat_id);let t=A.split(`,`).map(e=>e.trim()).filter(Boolean);t.includes(e.chat_id)||(t.push(e.chat_id),ne(t.join(`, `))),_e({ok:!0,message:`Auto-detected ID ${e.chat_id} from ${e.name}!`})}else _e({ok:!1,error:e.error||`Could not detect ID.`})}catch(e){_e({ok:!1,error:e.message||`Request failed`})}finally{xe(!1)}},_r=async()=>{if(confirm(r(`katana.disconnect_confirm`)))try{await R.delete(`/api/v1/channels/telegram/disconnect`),c(null),ne(``),O(``),_e(null),q({type:`success`,text:r(`katana.bot_disconnected`)})}catch{q({type:`error`,text:r(`katana.disconnect_failed`)})}finally{setTimeout(()=>q(null),3e3)}};(0,W.useEffect)(()=>{let e=B.provider;e===`gmail`?V(e=>({...e,imap_host:`imap.gmail.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.gmail.com`,smtp_port:587,smtp_use_ssl:!0,caldav_url:`https://apidata.googleusercontent.com/caldav/v1/calendars/primary/events`,calendar_provider:`google_api`})):e===`outlook`?V(e=>({...e,imap_host:`outlook.office365.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.office365.com`,smtp_port:587,smtp_use_ssl:!0,caldav_url:``,calendar_provider:`microsoft_graph`})):e===`proton`&&V(e=>({...e,imap_host:`127.0.0.1`,imap_port:1143,imap_use_ssl:!1,smtp_host:`127.0.0.1`,smtp_port:1025,smtp_use_ssl:!1,caldav_url:`http://127.0.0.1:5000`,calendar_provider:`caldav`}))},[B.provider]);let vr=async()=>{try{let e=(await R.get(`/api/v1/channels/email/account`)).data.data;Be(e),e&&(V({provider:e.provider,display_name:e.display_name||``,email_address:e.email_address||``,protocol:e.protocol||`imap`,imap_host:e.imap_host||``,imap_port:e.imap_port||993,imap_use_ssl:e.imap_use_ssl??!0,smtp_host:e.smtp_host||``,smtp_port:e.smtp_port||587,smtp_use_ssl:e.smtp_use_ssl??!0,username:e.username||``,password:``,caldav_url:e.caldav_url||``,calendar_provider:e.calendar_provider||`none`,calendar_credentials:e.calendar_credentials||null}),Qe({perm_read_mail:e.perm_read_mail,perm_send_mail:e.perm_send_mail,perm_delete_mail:e.perm_delete_mail,perm_read_calendar:e.perm_read_calendar,perm_create_events:e.perm_create_events,perm_edit_events:e.perm_edit_events,perm_delete_events:e.perm_delete_events}))}catch{}},yr=async e=>{if(e.preventDefault(),!(!B.email_address||!B.username||!z&&!B.password)){We(!0);try{let e=(await R.post(`/api/v1/channels/email/account`,B)).data.data;Be(e),q({type:`success`,text:`Mail & Calendar account connected!`})}catch(e){q({type:`error`,text:e.response?.data?.detail||`Failed to connect account`})}finally{We(!1),setTimeout(()=>q(null),4e3)}}},br=async()=>{if(confirm(`Are you sure you want to disconnect this Mail & Calendar account?`))try{await R.delete(`/api/v1/channels/email/account`),Be(null),V({provider:`gmail`,display_name:``,email_address:``,protocol:`imap`,imap_host:`imap.gmail.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.gmail.com`,smtp_port:587,smtp_use_ssl:!0,username:``,password:``,caldav_url:`https://apidata.googleusercontent.com/caldav/v1/calendars/primary/events`,calendar_provider:`google_api`,calendar_credentials:null}),q({type:`success`,text:`Mail & Calendar account disconnected.`})}catch{q({type:`error`,text:`Failed to disconnect account.`})}finally{setTimeout(()=>q(null),3e3)}},xr=async()=>{Ke(!0),Ye(null);try{Ye((await R.post(`/api/v1/channels/email/account/test`,B)).data.data)}catch(e){Ye({ok:!1,imap_ok:!1,smtp_ok:!1,message:e.response?.data?.detail||e.message||`Test request failed`})}finally{Ke(!1)}},Sr=async()=>{We(!0);try{Be((await R.patch(`/api/v1/channels/email/account/permissions`,Xe)).data.data),q({type:`success`,text:`Permissions updated successfully!`})}catch{q({type:`error`,text:`Failed to update permissions.`})}finally{We(!1),setTimeout(()=>q(null),3e3)}},Cr=async(e,t)=>{jt(e);try{let n=t||(J.provider_type===e?J.base_url:null)||(e===`ollama`?`http://127.0.0.1:11434`:`http://localhost:1234/v1`),r=await R.get(`/api/v1/system/local-models`,{params:{provider_type:e,base_url:n}});r.data?.success?Ot(r.data.data||[]):Ot([])}catch{Ot([])}},wr=async()=>{let e=Zt.trim();if(e){en(!0);try{let t=(await R.get(`/api/v1/system/scan-local-models`,{params:{path:e}})).data?.data||[];t.length>0?(Ot(t),q({type:`success`,text:`Found ${t.length} model${t.length===1?``:`s`} in directory.`})):q({type:`error`,text:`No models found at that path. Check the directory and try again.`})}catch{q({type:`error`,text:`Could not scan directory. Ensure the backend can access the path.`})}finally{en(!1),setTimeout(()=>q(null),4e3)}}},Tr=async e=>{let t=(J.provider_type===`ollama`?J.base_url:null)||`http://127.0.0.1:11434`;sn(e),ln({status:`Connecting to Ollama…`,percent:0});try{let n=new URLSearchParams({model:e,base_url:t}),r=await fetch(`/api/v1/system/pull-model?${n}`);if(!r.body)throw Error(`No response body`);let i=r.body.getReader(),a=new TextDecoder,o=``;for(;;){let{done:t,value:n}=await i.read();if(t)break;o+=a.decode(n,{stream:!0});let r=o.split(` -`);o=r.pop()??``;for(let t of r)if(t.startsWith(`data: `))try{let n=JSON.parse(t.slice(6));if(n.status===`error`){q({type:`error`,text:n.error||`Failed to pull ${e}`}),setTimeout(()=>q(null),6e3);return}if(n.status===`done`||n.status===`success`){ln({status:`✓ Complete!`,percent:100}),q({type:`success`,text:`${e} pulled successfully — ready to use.`}),Ot(t=>t.includes(e)?t:[e,...t]),setTimeout(()=>q(null),5e3);break}let r=n.total&&n.completed?Math.round(n.completed/n.total*100):0,i=n.completed?(n.completed/1e9).toFixed(2):null,a=n.total?(n.total/1e9).toFixed(2):null,o=i&&a?` — ${i} / ${a} GB`:``;ln({status:`${n.status}${o}`,percent:r})}catch{}}}catch(n){q({type:`error`,text:n?.message||`Failed to pull ${e}. Is Ollama running at ${t}?`}),setTimeout(()=>q(null),6e3)}finally{sn(null),ln(null)}},[Er,Dr]=(0,W.useState)(null),Or=async e=>{if(!confirm(`Delete model "${e}" from Ollama? This will free disk space but the model will need to be re-pulled to use again.`))return;let t=St.find(e=>e.provider_type===`ollama`&&e.base_url)?.base_url||(J.provider_type===`ollama`?J.base_url:null)||`http://127.0.0.1:11434`;Dr(e);try{let n=new URLSearchParams({model:e,base_url:t}),r=await(await fetch(`/api/v1/system/delete-model?${n}`,{method:`DELETE`})).json();r.success?(Ot(t=>t.filter(t=>t!==e)),q({type:`success`,text:`${e} deleted successfully.`})):q({type:`error`,text:r.message||`Failed to delete ${e}`}),setTimeout(()=>q(null),5e3)}catch(t){q({type:`error`,text:t?.message||`Failed to delete ${e}`}),setTimeout(()=>q(null),6e3)}finally{Dr(null)}},kr=async e=>{e.preventDefault(),xt(!0);try{let e=Gt(J.name),t={name:J.name,provider_type:J.provider_type,slug:e,base_url:J.base_url||null,is_local:zt(J.provider_type),auth_type:zt(J.provider_type)?`none`:J.auth_type,config:J.api_key?{api_key:J.api_key}:{}};Rt?(await R.patch(`/api/v1/model-providers/${Rt}`,t),q({type:`success`,text:`Model provider updated successfully.`})):(await R.post(`/api/v1/model-providers`,t),q({type:`success`,text:`Model provider added successfully.`})),Jt({name:``,provider_type:`openai`,auth_type:`api_key`,api_key:``,base_url:Lt.openai,is_active:!0}),qt(null),Xt(!1),dr()}catch(e){let t=e?.response?.data?.detail;q({type:`error`,text:typeof t==`string`?t:Array.isArray(t)?t.map(e=>`${e.loc?.slice(-1)[0]}: ${e.msg}`).join(`, `):`Failed to save provider.`})}finally{xt(!1),setTimeout(()=>q(null),5e3)}},Ar=e=>{qt(e.id),Jt({name:e.name,provider_type:e.provider_type,auth_type:e.auth_type||`api_key`,api_key:e.config?.api_key||``,base_url:e.base_url||Lt[e.provider_type]||``,is_active:e.status===`connected`}),Xt(!!e.base_url),window.scrollTo({top:0,behavior:`smooth`})},jr=()=>{qt(null),Jt({name:``,provider_type:`openai`,auth_type:`api_key`,api_key:``,base_url:Lt.openai,is_active:!0}),Xt(!1)},Mr=async(e,t)=>{let n=t===`connected`?`disabled`:`connected`;try{await R.patch(`/api/v1/model-providers/${e}`,{status:n}),dr()}catch(e){console.error(`Error toggling provider:`,e)}},Nr=async(e,t)=>{if(confirm(`Remove provider "${t}" from the grid? This cannot be undone.`))try{await R.delete(`/api/v1/model-providers/${e}`),q({type:`success`,text:`Provider "${t}" removed.`}),dr()}catch{q({type:`error`,text:`Failed to delete provider.`})}finally{setTimeout(()=>q(null),3e3)}},Pr=async e=>{e.preventDefault(),Nn(!0);let t=zn===`quick`&&Z?{name:Z.name,slug:Gt(Z.name),connector_type:`mcp`,source:`manual`,base_url:Z.transport===`sse`?Z.github_url:null,auth_type:`custom`,risk_level:Z.risk_level,config:{command:Z.command,args:Z.args,env:Wn,transport:Z.transport,npm_package:Z.npm_package}}:{name:Q.name,slug:Gt(Q.name),connector_type:`mcp`,source:`manual`,base_url:Q.transport===`sse`?Q.command:null,auth_type:`custom`,risk_level:Q.risk_level,config:{command:Q.transport===`stdio`?Q.command:void 0,args:Q.transport===`stdio`?Q.args.split(` `).filter(Boolean):void 0,env:Wn,transport:Q.transport}};try{await R.post(`/api/v1/tools`,t),q({type:`success`,text:`MCP Server "${t.name}" registered.`}),Rn(!1),Un(null),Hn(``),Gn({}),Kn({name:``,command:``,args:``,transport:`stdio`,risk_level:`medium`}),dr()}catch{q({type:`error`,text:`Failed to register MCP server.`})}finally{Nn(!1),setTimeout(()=>q(null),3e3)}},Fr=async e=>{e.preventDefault(),Nn(!0);let t=Dn===`quick`&&Y?{name:Y.name,slug:Gt(Y.name),connector_type:Y.connector_type,source:`manual`,base_url:Y.base_url,auth_type:Y.auth_type,risk_level:Y.risk_level,config:Pn?{api_key:Pn}:{}}:{name:X.name,slug:X.slug||Gt(X.name),connector_type:X.connector_type,source:`manual`,base_url:X.base_url||null,auth_type:X.auth_type,risk_level:X.risk_level,config:{}};try{await R.post(`/api/v1/tools`,t),q({type:`success`,text:`Tool "${t.name}" registered.`}),En(!1),jn(null),An(``),Fn(``),In({name:``,slug:``,base_url:``,connector_type:`api`,auth_type:`api_key`,risk_level:`low`}),dr()}catch{q({type:`error`,text:`Failed to register tool.`})}finally{Nn(!1),setTimeout(()=>q(null),3e3)}},Ir=async(e,t)=>{if(confirm(`Remove tool connector "${t}"? This cannot be undone.`))try{await R.delete(`/api/v1/tools/${e}`),q({type:`success`,text:`Tool "${t}" removed.`}),dr()}catch{q({type:`error`,text:`Failed to delete tool.`})}finally{setTimeout(()=>q(null),3e3)}},Lr=async e=>{if(e.preventDefault(),or.name.trim()){tr(!0);try{await R.post(`/api/v1/model-routing-profiles`,{name:or.name,description:or.description||null,is_default:or.is_default,rules:[]}),q({type:`success`,text:`Profile "${or.name}" created.`}),sr({name:``,description:``,is_default:!1}),Zn(!1),dr()}catch{q({type:`error`,text:`Failed to create routing profile.`})}finally{tr(!1),setTimeout(()=>q(null),3e3)}}},Rr=async(e,t)=>{if(confirm(`Delete routing profile "${t}"? This cannot be undone.`))try{await R.delete(`/api/v1/model-routing-profiles/${e}`),q({type:`success`,text:`Profile "${t}" deleted.`}),nr===e&&rr(null),dr()}catch{q({type:`error`,text:`Failed to delete profile.`})}finally{setTimeout(()=>q(null),3e3)}},zr=async e=>{try{await R.patch(`/api/v1/model-routing-profiles/${e}`,{is_default:!0}),q({type:`success`,text:`Default routing profile updated.`}),dr()}catch{q({type:`error`,text:`Failed to update default profile.`})}finally{setTimeout(()=>q(null),3e3)}},Br=(e,t)=>{ur(e),cr({task_type:t.task_type,primary_model_id:t.primary_model_id,fallback_model_ids:t.fallback_model_ids||[],latency_bias:t.latency_bias||``,cost_bias:t.cost_bias||``}),ar(!0)},Vr=async(e,t)=>{if(!$.primary_model_id)return;let n={task_type:$.task_type,primary_model_id:$.primary_model_id,fallback_model_ids:$.fallback_model_ids,latency_bias:$.latency_bias||null,cost_bias:$.cost_bias||null},r;lr===null?r=[...t,n]:(r=[...t],r[lr]=n);try{await R.patch(`/api/v1/model-routing-profiles/${e}`,{rules:r}),q({type:`success`,text:lr===null?`Routing rule added.`:`Routing rule updated.`}),ar(!1),ur(null),cr({task_type:`*`,primary_model_id:``,fallback_model_ids:[],latency_bias:``,cost_bias:``}),dr()}catch(e){let t=e.response?.data?.detail;q({type:`error`,text:t?`Save failed: ${t}`:`Failed to save rule. Please try a hard refresh (Ctrl+F5).`})}finally{setTimeout(()=>q(null),5e3)}},Hr=async(e,t,n)=>{let r=t.filter((e,t)=>t!==n);try{await R.patch(`/api/v1/model-routing-profiles/${e}`,{rules:r}),q({type:`success`,text:`Rule removed successfully.`}),dr()}catch(e){let t=e.response?.data?.detail;q({type:`error`,text:t?`Delete failed: ${t}`:`Failed to remove rule. Check backend logs or try a hard refresh.`})}finally{setTimeout(()=>q(null),5e3)}},Ur=(0,W.useMemo)(()=>{if(!kn.trim())return Ut;let e=kn.toLowerCase();return Ut.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))},[kn]),Wr=e=>{switch(e){case`openai`:return{bg:`bg-green-500/10`,text:`text-green-500`};case`anthropic`:return{bg:`bg-shogun-gold/10`,text:`text-shogun-gold`};case`google`:return{bg:`bg-blue-400/10`,text:`text-blue-400`};case`openrouter`:return{bg:`bg-purple-400/10`,text:`text-purple-400`};case`ollama`:return{bg:`bg-cyan-400/10`,text:`text-cyan-400`};case`lmstudio`:return{bg:`bg-orange-400/10`,text:`text-orange-400`};default:return{bg:`bg-shogun-blue/10`,text:`text-shogun-blue`}}},Gr=e=>({openai:`OpenAI`,anthropic:`Anthropic`,google:`Google Gemini`,openrouter:`OpenRouter`,ollama:`Ollama`,lmstudio:`LM Studio`,local:`Local`,custom:`Custom`})[e]||e,Kr=It[J.provider_type],qr=zt(J.provider_type);return(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-6xl mx-auto pb-12`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[r(`katana.title`,`The Katana`),` `,(0,G.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:r(`katana.badge`)})]}),(0,G.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:r(`katana.subtitle`,`Manage the cutting-edge models and tools that empower your agents.`)})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>e(`/toolgate`),className:`flex items-center gap-2 self-start rounded-lg border border-orange-400/25 bg-orange-500/[0.07] px-3 py-2.5 text-xs font-bold text-orange-300 transition-colors hover:bg-orange-500/15`,children:[(0,G.jsx)(ve,{className:`h-4 w-4`}),`Configure runtime rules in ToolGate`]})]}),Pt&&(0,G.jsxs)(`div`,{className:L(`p-3 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,Pt.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[Pt.type===`success`?(0,G.jsx)(g,{className:`w-4 h-4`}):(0,G.jsx)(m,{className:`w-4 h-4`}),(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:Pt.text})]}),(0,G.jsx)(`div`,{className:`flex border-b border-shogun-border overflow-x-auto`,children:[`providers`,`tools`,`files`,`routing`,`skills`,`team`,`telegram`,`teams`,`mail_calendar`,`office`,`ide`,`mado`,`ronin`,`skillopt`].filter(e=>e!==`ide`||[`campaign`,`ronin`].includes(it)).map(e=>(0,G.jsxs)(`button`,{onClick:()=>{n(e),e===`telegram`&&!a&&fr(),e===`mail_calendar`&&!z&&vr(),e===`office`&&!tt&&pt()},className:L(`px-6 py-3 text-[10px] font-bold uppercase tracking-widest transition-all relative`,t===e?`text-shogun-blue`:`text-shogun-subdued hover:text-shogun-text`),children:[e===`providers`&&r(`katana.tab_cloud`,`AI Model Provider`),e===`tools`&&r(`katana.tab_tools`,`Toolbox & APIs`),e===`files`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(T,{className:`w-3.5 h-3.5`}),`File Formats`]}),e===`routing`&&r(`katana.tab_routing`,`Logic Routing`),e===`team`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Ee,{className:`w-3.5 h-3.5`}),r(`katana.team.tab`,`Team`)]}),e===`skills`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Ve,{className:`w-3.5 h-3.5`}),`Skills · Active Usage`]}),e===`telegram`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{className:`w-3.5 h-3.5`}),`Telegram`,a?.connected&&(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`})]}),e===`teams`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{className:`w-3.5 h-3.5`}),`Microsoft Teams`]}),e===`mail_calendar`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(re,{className:`w-3.5 h-3.5`}),`Mail & Calendar`,z?.is_active&&(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`})]}),e===`office`&&(0,G.jsxs)(`span`,{className:L(`flex items-center gap-1.5`,it===`shrine`&&`opacity-40`),children:[(0,G.jsx)(w,{className:`w-3.5 h-3.5`}),`Office`,tt?.enabled&&it!==`shrine`&&(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`})]}),e===`ide`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(ae,{className:`w-3.5 h-3.5`}),` IDE Mode`]}),e===`mado`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(o,{className:`w-3.5 h-3.5`}),`Mado Browser`]}),e===`ronin`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(x,{className:`w-3.5 h-3.5`}),`Ronin Desktop`]}),e===`skillopt`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(b,{className:`w-3.5 h-3.5`}),r(`katana.tab_skillopt`,`SkillOpt`)]}),t===e&&(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-blue shadow-[0_0_10px_rgba(74,140,199,0.5)]`})]},e))}),(0,G.jsxs)(`div`,{className:`mt-6`,children:[t===`skills`&&(0,G.jsx)(At,{}),t===`files`&&(0,G.jsx)(Nt,{}),t===`team`&&(0,G.jsx)(Ft,{}),t===`providers`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,G.jsx)(`div`,{className:`lg:col-span-1`,children:(0,G.jsxs)(`div`,{className:`shogun-card space-y-6 sticky top-6`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:Rt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{className:`w-5 h-5 text-shogun-gold`}),` `,r(`common.edit`,`Edit Provider`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ue,{className:`w-5 h-5 text-shogun-blue`}),` `,r(`katana.add_provider`,`Add Provider`)]})}),(0,G.jsxs)(`form`,{onSubmit:kr,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.provider`,`Provider`)}),(0,G.jsxs)(`select`,{value:J.provider_type,onChange:e=>{let t=e.target.value;Jt({...J,provider_type:t,name:``,base_url:Lt[t]||``}),Xt(!1)},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsxs)(`optgroup`,{label:r(`katana.ai_model_providers`),children:[(0,G.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,G.jsx)(`option`,{value:`google`,children:`Google (Gemini)`}),(0,G.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,G.jsx)(`option`,{value:`openrouter`,children:`OpenRouter`})]}),(0,G.jsxs)(`optgroup`,{label:r(`katana.local_providers`),children:[(0,G.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,G.jsx)(`option`,{value:`lmstudio`,children:`LM Studio (Local)`})]})]})]}),Kr&&(0,G.jsxs)(`a`,{href:Kr.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2 p-2.5 rounded-lg bg-shogun-blue/5 border border-shogun-blue/15 text-shogun-blue hover:bg-shogun-blue/10 hover:border-shogun-blue/30 transition-all group`,children:[(0,G.jsx)(te,{className:`w-3.5 h-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold truncate`,children:Kr.label}),(0,G.jsx)(S,{className:`w-3 h-3 ml-auto opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(qr?`katana.available_models`:`katana.display_name`)}),qr&&Dt.length>0?(0,G.jsxs)(`select`,{required:!0,value:J.name,onChange:e=>Jt({...J,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,disabled:!0,children:r(`katana.select_pulled_model`)}),Dt.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}):(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:qr?`e.g. llama3:8b (or connect to fetch)`:`e.g. Primary OpenAI`,value:J.name,onChange:e=>Jt({...J,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`}),qr&&Dt.length===0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Cr(J.provider_type),className:`text-[9px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors flex items-center gap-1`,children:[(0,G.jsx)(P,{className:`w-2.5 h-2.5`}),` `,r(`katana.scan_for_local_models`)]}),(0,G.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued`,children:[`• Ensure `,J.provider_type===`ollama`?`Ollama`:`LM Studio`,` is running`]})]})]}),!qr&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.auth_type`,`Auth Type`)}),(0,G.jsxs)(`select`,{value:J.auth_type,onChange:e=>Jt({...J,auth_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:`api_key`,children:r(`katana.api_key_option`)}),(0,G.jsx)(`option`,{value:`oauth`,children:r(`katana.oauth_option`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5 mt-3`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:J.auth_type===`oauth`?r(`katana.oauth_token`):r(`katana.api_key_label`)}),(0,G.jsx)(`input`,{type:`password`,placeholder:J.auth_type===`oauth`?`Bearer ...`:`sk-...`,value:J.api_key,onChange:e=>Jt({...J,api_key:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:[r(`katana.base_url_label`),` `,qr?``:r(`katana.auto`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Xt(e=>!e),className:L(`text-[9px] font-bold uppercase tracking-widest transition-colors`,Yt?`text-shogun-gold`:`text-shogun-blue hover:text-shogun-gold`),children:r(Yt?`katana.reset`:`katana.override`)})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,readOnly:!Yt,placeholder:Lt[J.provider_type]||`https://...`,value:J.base_url,onChange:e=>Jt({...J,base_url:e.target.value}),className:L(`w-full bg-[#050508] border rounded-lg p-3 text-sm outline-none font-mono text-xs transition-all`,Yt?`border-shogun-gold text-shogun-gold focus:ring-1 focus:ring-shogun-gold/20 cursor-text`:`border-shogun-border text-shogun-subdued cursor-default select-none`)}),!Yt&&(0,G.jsx)(`div`,{className:`absolute right-3 top-1/2 -translate-y-1/2`,children:(0,G.jsx)(`span`,{className:`text-[8px] text-green-400 font-bold uppercase border border-green-400/20 bg-green-400/5 px-1.5 py-0.5 rounded`,children:r(`katana.default`)})})]})]}),qr&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(D,{className:`w-3 h-3`}),` `,r(`katana.model_location`),(0,G.jsxs)(`span`,{className:`text-shogun-subdued/50 normal-case font-normal tracking-normal text-[9px]`,children:[`(`,r(`katana.filesystem_path`),`)`]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:J.provider_type===`ollama`?`C:\\Users\\you\\.ollama\\models`:`C:\\Users\\you\\AppData\\Local\\LM Studio\\models`,value:Zt,onChange:e=>Qt(e.target.value),className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none font-mono text-xs`}),(0,G.jsxs)(`button`,{type:`button`,disabled:$t||!Zt.trim(),onClick:wr,className:`flex items-center gap-1.5 px-3 py-2 bg-shogun-blue/10 hover:bg-shogun-blue/20 border border-shogun-blue/30 hover:border-shogun-blue/60 disabled:opacity-40 disabled:cursor-not-allowed rounded-lg text-shogun-blue text-[10px] font-bold uppercase tracking-widest transition-all whitespace-nowrap`,children:[$t?(0,G.jsx)(P,{className:`w-3 h-3 animate-spin`}):(0,G.jsx)(me,{className:`w-3 h-3`}),`Scan`]})]}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued leading-relaxed`,children:[`Paste the path shown in your `,J.provider_type===`ollama`?`Ollama`:`LM Studio`,` settings. The backend will walk the directory and return every pulled model.`]})]}),J.provider_type===`ollama`&&(0,G.jsxs)(`div`,{className:`border border-shogun-border rounded-xl overflow-hidden`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>nn(e=>!e),className:`w-full flex items-center justify-between px-4 py-3 bg-[#050508] hover:bg-[#0a0e1a] transition-colors`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:[(0,G.jsx)(ee,{className:`w-3.5 h-3.5 text-cyan-400`}),`Pull a Model`,(0,G.jsxs)(`span`,{className:`text-cyan-400/60 normal-case font-normal tracking-normal`,children:[`— `,r(`katana.download_to_ollama`)]})]}),tn?(0,G.jsx)(p,{className:`w-3.5 h-3.5 text-shogun-subdued`}):(0,G.jsx)(u,{className:`w-3.5 h-3.5 text-shogun-subdued`})]}),tn&&(0,G.jsxs)(`div`,{className:`p-4 space-y-4 border-t border-shogun-border bg-[#02040a]`,children:[on&&cn&&(0,G.jsxs)(`div`,{className:`p-3 rounded-xl bg-cyan-500/5 border border-cyan-500/20 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold text-cyan-400 uppercase tracking-widest truncate`,children:[`↓ `,on]}),(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-cyan-400/70 ml-2 shrink-0`,children:[cn.percent,`%`]})]}),(0,G.jsx)(`div`,{className:`w-full h-1.5 bg-[#0a0e1a] rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full bg-gradient-to-r from-cyan-500 to-shogun-blue rounded-full transition-all duration-300`,style:{width:`${cn.percent}%`}})}),(0,G.jsx)(`p`,{className:`text-[9px] text-cyan-400/60 font-mono truncate`,children:cn.status})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(me,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued/50`}),(0,G.jsx)(`input`,{type:`text`,value:fn,onChange:e=>pn(e.target.value),placeholder:`Search all Ollama models...`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2 text-xs focus:border-cyan-500/60 outline-none placeholder:text-shogun-subdued/40`}),gn&&(0,G.jsx)(P,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-cyan-400 animate-spin`})]}),(0,G.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:[`all`,`vision`,`tools`,`thinking`,`embedding`,`cloud`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>an(e),className:L(`px-2.5 py-1 rounded text-[9px] font-bold uppercase tracking-widest border transition-all`,rn===e?`bg-cyan-500/15 border-cyan-500/40 text-cyan-400`:`bg-transparent border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:e},e))}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 max-h-80 overflow-y-auto pr-1 scrollbar-thin`,children:[gn&&mn.length===0?(0,G.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-shogun-subdued/50`,children:[(0,G.jsx)(P,{className:`w-4 h-4 animate-spin mr-2`}),(0,G.jsx)(`span`,{className:`text-[10px]`,children:`Searching ollama.com...`})]}):mn.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-shogun-subdued/50`,children:[(0,G.jsx)(`span`,{className:`text-[10px]`,children:`No models found`}),(0,G.jsx)(`span`,{className:`text-[9px] mt-1`,children:`Try a different search or use a custom tag below`})]}):mn.map(e=>{let t=on===e.id,n=Dt.find(t=>{let n=t.toLowerCase(),r=e.id.toLowerCase();return!!(n===r||n.startsWith(r+`:`))}),i=!!n;return(0,G.jsxs)(`div`,{className:L(`flex items-center justify-between p-2.5 rounded-lg border transition-all`,t?`border-cyan-500/40 bg-cyan-500/5`:i?`border-green-500/20 bg-green-500/5`:`border-shogun-border hover:border-shogun-subdued bg-[#050508]`),children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text truncate`,children:e.name}),e.sizes.map(e=>(0,G.jsx)(`span`,{className:`text-[7px] px-1 py-0.5 rounded bg-blue-500/10 border border-blue-500/20 text-blue-400 font-bold shrink-0`,children:e},e)),i&&(0,G.jsx)(`span`,{className:`text-[8px] text-green-400 font-bold shrink-0`,children:`✓ local`})]}),(0,G.jsx)(`p`,{className:`text-[8px] text-shogun-subdued/70 truncate mt-0.5`,children:e.description}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[e.capabilities.map(e=>(0,G.jsx)(`span`,{className:`text-[7px] px-1 py-0.5 rounded bg-indigo-500/10 border border-indigo-500/20 text-indigo-400 font-medium`,children:e},e)),(0,G.jsxs)(`span`,{className:`text-[7px] text-shogun-subdued/50 font-mono`,children:[`↓`,e.pulls]}),e.tag_count>0&&(0,G.jsxs)(`span`,{className:`text-[7px] text-shogun-subdued/50 font-mono`,children:[e.tag_count,` tags`]}),e.updated&&(0,G.jsx)(`span`,{className:`text-[7px] text-shogun-subdued/40`,children:e.updated})]})]}),(0,G.jsxs)(`div`,{className:`ml-3 shrink-0 flex items-center gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:!!on,onClick:()=>Tr(e.id),className:L(`flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[9px] font-bold uppercase transition-all border`,t?`border-cyan-500/40 text-cyan-400 bg-cyan-500/10 animate-pulse`:i?`border-green-500/20 text-green-400 bg-green-500/5 hover:bg-green-500/10`:`border-shogun-border text-shogun-subdued hover:border-cyan-500/50 hover:text-cyan-400 hover:bg-cyan-500/5 disabled:opacity-30 disabled:cursor-not-allowed`),children:t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(P,{className:`w-2.5 h-2.5 animate-spin`}),` `,r(`katana.pulling`)]}):i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(P,{className:`w-2.5 h-2.5`}),` `,r(`katana.repull`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ee,{className:`w-2.5 h-2.5`}),` `,r(`katana.pull`)]})}),i&&n&&kt===`ollama`&&(0,G.jsx)(`button`,{type:`button`,disabled:!!on||Er===n,onClick:e=>{e.stopPropagation(),Or(n)},className:L(`p-1.5 rounded-lg transition-all border`,Er===n?`border-red-500/40 text-red-400 bg-red-500/10 animate-pulse`:`border-shogun-border text-red-500/40 hover:border-red-500/50 hover:text-red-500 hover:bg-red-500/5 disabled:opacity-30 disabled:cursor-not-allowed`),title:r(`katana.delete_local_model`,`Delete from Ollama`),children:(0,G.jsx)(we,{className:`w-3 h-3`})})]})]},e.id)}),bn&&!gn&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>wn(fn,vn+1,!0),disabled:Sn,className:`w-full py-2 rounded-lg border border-shogun-border text-[9px] font-bold uppercase tracking-widest text-shogun-subdued hover:border-cyan-500/40 hover:text-cyan-400 transition-all disabled:opacity-50`,children:Sn?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(P,{className:`w-3 h-3 animate-spin inline mr-1`}),` Loading...`]}):`Load More Models`})]}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-shogun-border/50 space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[9px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.custom_model_tag`,`Custom Model Tag`)}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,value:un,onChange:e=>dn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&un.trim()&&(e.preventDefault(),Tr(un.trim()),dn(``))},placeholder:`e.g. llama3.2:latest or mistral:7b-instruct`,className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs font-mono focus:border-cyan-500/60 outline-none placeholder:text-shogun-subdued/40`}),(0,G.jsxs)(`button`,{type:`button`,disabled:!!on||!un.trim(),onClick:()=>{Tr(un.trim()),dn(``)},className:`px-3 py-2 bg-cyan-500/10 hover:bg-cyan-500/20 border border-cyan-500/30 hover:border-cyan-500/60 disabled:opacity-30 disabled:cursor-not-allowed rounded-lg text-cyan-400 text-[10px] font-bold uppercase tracking-widest transition-all whitespace-nowrap flex items-center gap-1`,children:[(0,G.jsx)(ee,{className:`w-3 h-3`}),` `,r(`katana.pull`)]})]}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:[`Any valid Ollama model tag from `,(0,G.jsx)(`a`,{href:`https://ollama.com/search`,target:`_blank`,rel:`noopener noreferrer`,className:`text-cyan-400/70 font-mono hover:text-cyan-400 transition-colors`,children:`ollama.com/search`})]})]})]})]}),qr&&Dt.length>0&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-2`,children:[(0,G.jsx)(ae,{className:`w-3.5 h-3.5`}),r(`katana.manage_local_models`,`Manage Local Models`),(0,G.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued font-bold`,children:Dt.length})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 max-h-48 overflow-y-auto pr-1 scrollbar-thin`,children:Dt.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded-lg border border-shogun-border bg-[#050508] hover:border-shogun-subdued transition-all`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-[10px] font-mono text-shogun-text truncate`,children:e})]}),kt===`ollama`&&(0,G.jsxs)(`button`,{type:`button`,disabled:Er===e,onClick:()=>Or(e),className:L(`shrink-0 flex items-center gap-1 px-2 py-1 rounded-lg text-[9px] font-bold uppercase transition-all border`,Er===e?`border-red-500/40 text-red-400 bg-red-500/10 animate-pulse`:`border-shogun-border text-red-500/50 hover:border-red-500/50 hover:text-red-500 hover:bg-red-500/5`),title:r(`katana.delete_local_model`,`Delete from Ollama`),children:[(0,G.jsx)(we,{className:`w-3 h-3`}),(0,G.jsx)(`span`,{children:r(`katana.delete`,`Delete`)})]})]},e))})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`button`,{type:`submit`,disabled:bt||!J.name,className:`flex-1 py-3 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg shadow-shogun transition-all flex items-center justify-center gap-2`,children:[bt?(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}):Rt?(0,G.jsx)(g,{className:`w-4 h-4`}):(0,G.jsx)(pe,{className:`w-4 h-4`}),r(Rt?`katana.update_provider`:`katana.initiate_provider`)]}),Rt&&(0,G.jsx)(`button`,{type:`button`,onClick:jr,className:`px-4 py-2 bg-shogun-subdued/10 hover:bg-shogun-subdued/20 border border-shogun-border rounded-lg text-shogun-subdued text-xs font-bold uppercase transition-all`,children:r(`common.cancel`)})]})]})]})}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(b,{className:`w-5 h-5 text-shogun-blue`}),` `,r(`katana.active_providers`)]}),vt?(0,G.jsxs)(`div`,{className:`p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(P,{className:`w-8 h-8 animate-spin mx-auto text-shogun-blue mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:r(`katana.querying_model_grid`)})]}):St.length===0?(0,G.jsx)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:(0,G.jsx)(`p`,{className:`text-shogun-subdued italic`,children:r(`katana.no_providers`)})}):(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-4`,children:St.map(e=>{let t=Wr(e.provider_type),n=It[e.provider_type],i=e.status===`connected`,a=zt(e.provider_type);return(0,G.jsx)(`div`,{className:`shogun-card group hover:border-shogun-blue/50 transition-all`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:L(`w-12 h-12 rounded-xl flex items-center justify-center`,t.bg,t.text),children:a?(0,G.jsx)(ae,{className:`w-6 h-6`}):(0,G.jsx)(Ne,{className:`w-6 h-6`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:e.name}),i?(0,G.jsx)(`span`,{className:`text-[8px] bg-green-500/10 text-green-500 px-1.5 py-0.5 rounded border border-green-500/20 font-bold uppercase`,children:r(`katana.active`)}):(0,G.jsx)(`span`,{className:`text-[8px] bg-shogun-subdued/10 text-shogun-subdued px-1.5 py-0.5 rounded border border-shogun-border font-bold uppercase`,children:e.status??r(`katana.not_configured`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued`,children:Gr(e.provider_type)}),(0,G.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:e.base_url||r(`katana.default_endpoint`)})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,G.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,className:`p-2 hover:bg-shogun-blue/10 text-shogun-subdued hover:text-shogun-blue rounded-lg transition-colors`,title:n.label,children:(0,G.jsx)(S,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Ar(e),className:`p-2 hover:bg-shogun-card rounded-lg transition-colors text-shogun-subdued hover:text-shogun-gold`,title:r(`katana.edit_provider`),children:(0,G.jsx)(U,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Mr(e.id,e.status),className:`p-2 hover:bg-shogun-card rounded-lg transition-colors text-shogun-subdued hover:text-shogun-text`,title:r(i?`katana.disable`:`katana.enable`),children:i?(0,G.jsx)(Ae,{className:`w-4 h-4`}):(0,G.jsx)(F,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Nr(e.id,e.name),className:`p-2 hover:bg-red-500/10 text-red-500/50 hover:text-red-500 rounded-lg transition-colors`,title:r(`katana.delete_provider`),children:(0,G.jsx)(we,{className:`w-4 h-4`})})]})]})},e.id)})}),Dt.length>0&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 border border-shogun-border bg-[#02040a]/40 backdrop-blur-md rounded-xl p-5 mt-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-shogun-border/40 pb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ae,{className:`w-5 h-5 text-green-400`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text text-sm`,children:`Local Models Manager`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:`Manage models pulled on your local machines`})]})]}),(0,G.jsxs)(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-[#050508] border border-shogun-border text-green-400 font-mono font-bold`,children:[Dt.length,` models`]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 max-h-80 overflow-y-auto pr-1 scrollbar-thin`,children:Dt.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border border-shogun-border bg-[#050508]/60 hover:border-shogun-subdued transition-all group`,children:[(0,G.jsx)(`div`,{className:`flex flex-col min-w-0 mr-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-500 shrink-0 shadow-[0_0_8px_#22c55e]`}),(0,G.jsx)(`span`,{className:`text-xs font-mono text-shogun-text truncate font-semibold`,title:e,children:e})]})}),kt===`ollama`&&(0,G.jsxs)(`button`,{type:`button`,disabled:Er===e,onClick:()=>Or(e),className:L(`shrink-0 flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[9px] font-bold uppercase transition-all border`,Er===e?`border-red-500/40 text-red-400 bg-red-500/10 animate-pulse`:`border-shogun-border text-red-500/60 hover:border-red-500 hover:text-red-500 hover:bg-red-500/10`),title:r(`katana.delete_local_model`,`Delete from Ollama`),children:[(0,G.jsx)(we,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{children:Er===e?r(`katana.deleting`,`Deleting`):r(`katana.delete`,`Delete`)})]})]},e))})]})]})]}),t===`tools`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(Oe,{className:`w-5 h-5 text-shogun-blue`}),` `,r(`katana.tool_connectors`),(0,G.jsxs)(`span`,{className:`text-[10px] font-normal bg-shogun-card border border-shogun-border px-1.5 py-0.5 rounded text-shogun-subdued`,children:[Tt.length,` active`]})]}),(0,G.jsxs)(`button`,{id:`register-tool-btn`,onClick:()=>En(e=>!e),className:L(`flex items-center gap-2 px-4 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,Tn?`bg-shogun-blue/10 border-shogun-blue/40 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:text-shogun-blue hover:border-shogun-blue/40 hover:bg-shogun-blue/5`),children:[Tn?(0,G.jsx)(ke,{className:`w-3 h-3`}):(0,G.jsx)(ue,{className:`w-3 h-3`}),r(Tn?`common.cancel`:`katana.register_new_tool`)]})]}),Tn&&(0,G.jsxs)(`div`,{className:`shogun-card border-shogun-blue/30 animate-in slide-in-from-top-3 duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(Ve,{className:`w-4 h-4 text-shogun-blue`}),` `,r(`katana.register_tool_connector`)]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 p-1 bg-[#050508] border border-shogun-border rounded-lg`,children:[`quick`,`manual`].map(e=>(0,G.jsx)(`button`,{onClick:()=>On(e),className:L(`px-3 py-1 rounded text-[10px] font-bold uppercase tracking-widest transition-all`,Dn===e?`bg-shogun-blue text-white shadow`:`text-shogun-subdued hover:text-shogun-text`),children:r(e===`quick`?`katana.quick_pick`:`katana.manual`)},e))})]}),(0,G.jsxs)(`form`,{onSubmit:Fr,children:[Dn===`quick`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(me,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued`}),(0,G.jsx)(`input`,{type:`text`,placeholder:r(`katana.search_apis`),value:kn,onChange:e=>An(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2.5 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsx)(`div`,{className:`h-64 overflow-y-auto space-y-1 pr-1 scrollbar-thin scrollbar-thumb-shogun-border scrollbar-track-transparent`,children:Ur.length===0?(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic text-center py-8`,children:r(`katana.no_apis_match`)}):Ur.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{jn(e),Fn(``)},className:L(`w-full text-left px-3 py-2.5 rounded-lg border transition-all group flex items-center justify-between gap-2`,Y?.name===e.name?`border-shogun-blue/40 bg-shogun-blue/10 text-shogun-text`:`border-transparent hover:border-shogun-border hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text`),children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-xs font-bold truncate`,children:e.name}),(0,G.jsx)(`p`,{className:`text-[10px] truncate opacity-70`,children:e.description})]}),(0,G.jsx)(f,{className:L(`w-3.5 h-3.5 shrink-0 transition-all`,Y?.name===e.name?`text-shogun-blue opacity-100`:`opacity-0 group-hover:opacity-50`)})]},e.name))}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued text-center`,children:[Ur.length,` APIs in catalog`]})]}),(0,G.jsx)(`div`,{className:`flex flex-col`,children:Y?(0,G.jsxs)(`div`,{className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-text text-base`,children:Y.name}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1 leading-relaxed`,children:Y.description})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[{label:r(`katana.endpoint`),value:Y.base_url},{label:r(`katana.auth`),value:Y.auth_type.replace(`_`,` `).toUpperCase()},{label:r(`katana.type`),value:Y.connector_type.toUpperCase()},{label:r(`katana.risk`),value:Y.risk_level.toUpperCase()}].map(({label:e,value:t})=>(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`p`,{className:`text-shogun-subdued uppercase tracking-widest font-bold`,children:e}),(0,G.jsx)(`p`,{className:`text-shogun-text font-mono truncate`,children:t})]},e))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(j,{className:`w-3 h-3 text-shogun-subdued shrink-0`}),(0,G.jsx)(`a`,{href:`https://www.google.com/search?q=${encodeURIComponent(Y.name+` API documentation`)}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-shogun-blue hover:underline truncate`,children:`Find documentation →`})]}),Y.auth_type!==`none`&&(0,G.jsxs)(`div`,{className:`space-y-1.5 pt-1 border-t border-shogun-border/50`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(F,{className:`w-3 h-3 text-shogun-gold`}),`API Key`,(0,G.jsxs)(`span`,{className:`text-shogun-subdued/50 normal-case font-normal tracking-normal`,children:[`(`,Y.auth_type.replace(`_`,` `),`)`]})]}),(0,G.jsx)(`input`,{type:`password`,placeholder:`Paste your API key here…`,value:Pn,onChange:e=>Fn(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold focus:ring-1 focus:ring-shogun-gold/20 outline-none font-mono text-xs transition-all`}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:`Stored locally in the connector config. Never sent to third parties.`})]})]}):(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center bg-[#050508] border border-dashed border-shogun-border rounded-xl p-8 gap-3`,children:[(0,G.jsx)(Ve,{className:`w-8 h-8 text-shogun-subdued opacity-40`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:r(`katana.select_api_preview`)})]})})]}),Dn===`manual`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.tool_name`,`Tool Name *`)}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. Stripe Billing`,value:X.name,onChange:e=>In({...X,name:e.target.value,slug:Gt(e.target.value)}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.slug`,`Slug *`)}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`auto-generated`,value:X.slug,onChange:e=>In({...X,slug:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.base_url`,`Base URL`)}),(0,G.jsx)(`input`,{type:`text`,placeholder:`https://api.example.com/v1`,value:X.base_url,onChange:e=>In({...X,base_url:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.connector_type`,`Connector Type`)}),(0,G.jsx)(`select`,{value:X.connector_type,onChange:e=>In({...X,connector_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:Bt.map(e=>(0,G.jsx)(`option`,{value:e,children:e.toUpperCase()},e))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.auth_type`,`Auth Type`)}),(0,G.jsx)(`select`,{value:X.auth_type,onChange:e=>In({...X,auth_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:Vt.map(e=>(0,G.jsx)(`option`,{value:e,children:e.replace(`_`,` `).toUpperCase()},e))})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.risk_level`,`Risk Level`)}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Ht.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>In({...X,risk_level:e}),className:L(`flex-1 py-2 rounded-lg border text-[9px] font-bold uppercase tracking-widest transition-all`,X.risk_level===e?Kt(e)+` border-opacity-100`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/30`),children:e},e))})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-6 pt-5 border-t border-shogun-border`,children:[(0,G.jsxs)(`button`,{type:`submit`,disabled:Mn||Dn===`quick`&&!Y,className:`flex items-center gap-2 px-6 py-2.5 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 disabled:cursor-not-allowed text-white font-bold rounded-lg text-sm transition-all`,children:[Mn?(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(pe,{className:`w-4 h-4`}),r(`katana.register_connector`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>En(!1),className:`px-4 py-2.5 text-sm font-bold text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),Dn===`quick`&&!Y&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued ml-auto`,children:r(`katana.select_api_first`)})]})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5`,children:vt?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(P,{className:`w-8 h-8 animate-spin mx-auto text-shogun-blue mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:r(`katana.loading_connectors`)})]}):Tt.length===0?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card border-dashed`,children:[(0,G.jsx)(Oe,{className:`w-8 h-8 text-shogun-subdued opacity-30 mx-auto mb-3`}),(0,G.jsx)(`p`,{className:`text-shogun-subdued italic text-sm`,children:r(`katana.no_tools`)}),(0,G.jsx)(`button`,{onClick:()=>En(!0),className:`mt-4 text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:`+ Register your first tool`})]}):Tt.map(e=>(0,G.jsxs)(`div`,{className:`shogun-card hover:border-shogun-blue/30 transition-all group relative`,children:[e.source!==`builtin`&&!e.config?.builtin&&(0,G.jsx)(`button`,{onClick:()=>Ir(e.id,e.name),className:`absolute top-3 right-3 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-500/10 text-red-500/50 hover:text-red-500 transition-all`,title:r(`katana.remove_connector`),children:(0,G.jsx)(we,{className:`w-3.5 h-3.5`})}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-subdued group-hover:text-shogun-blue transition-colors shrink-0`,children:(0,G.jsx)(Oe,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text truncate flex items-center gap-2`,children:[e.name,(e.source===`builtin`||e.config?.builtin)&&(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest text-indigo-300 border border-indigo-400/30 bg-indigo-500/10 rounded px-1.5 py-0.5`,children:`Standard`})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate`,children:e.slug})]})]}),e.base_url&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate mb-3 bg-[#050508] px-2 py-1 rounded border border-shogun-border`,children:e.base_url}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-shogun-border`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued`,children:e.connector_type||`api`}),(0,G.jsx)(`span`,{className:L(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,Kt(e.risk_level||`low`)),children:e.risk_level||`low`})]}),(0,G.jsx)(`span`,{className:L(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,e.status===`connected`||e.status===`active`?`text-green-400 border-green-400/30 bg-green-400/5`:e.status===`disabled`?`text-shogun-subdued border-shogun-border bg-shogun-card`:`text-yellow-400 border-yellow-400/30 bg-yellow-400/5`),children:e.status||`not_configured`})]})]},e.id))})]}),t===`tools`&&(0,G.jsxs)(`div`,{className:`space-y-6 pt-12 mt-12 border-t border-shogun-border/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(M,{className:`w-5 h-5 text-indigo-500`}),` `,r(`katana.mcp_servers`,`MCP Servers`),(0,G.jsxs)(`span`,{className:`text-[10px] font-normal bg-shogun-card border border-shogun-border px-1.5 py-0.5 rounded text-shogun-subdued`,children:[Tt.filter(e=>e.connector_type===`mcp`).length,` active`]})]}),(0,G.jsxs)(`button`,{onClick:()=>Rn(e=>!e),className:L(`flex items-center gap-2 px-4 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,Ln?`bg-indigo-500/10 border-indigo-500/40 text-indigo-400`:`border-shogun-border text-shogun-subdued hover:text-indigo-400 hover:border-indigo-500/40 hover:bg-indigo-500/5`),children:[Ln?(0,G.jsx)(ke,{className:`w-3 h-3`}):(0,G.jsx)(ue,{className:`w-3 h-3`}),Ln?r(`common.cancel`):r(`katana.register_mcp`,`Register MCP`)]})]}),Ln&&(0,G.jsxs)(`div`,{className:`shogun-card border-indigo-500/30 animate-in slide-in-from-top-3 duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(Ve,{className:`w-4 h-4 text-indigo-500`}),` `,r(`katana.register_mcp_server`,`Register MCP Server`)]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 p-1 bg-[#050508] border border-shogun-border rounded-lg`,children:[`quick`,`manual`].map(e=>(0,G.jsx)(`button`,{onClick:()=>Bn(e),className:L(`px-3 py-1 rounded text-[10px] font-bold uppercase tracking-widest transition-all`,zn===e?`bg-indigo-500 text-white shadow`:`text-shogun-subdued hover:text-shogun-text`),children:r(e===`quick`?`katana.quick_pick`:`katana.manual`)},e))})]}),(0,G.jsxs)(`form`,{onSubmit:Pr,children:[zn===`quick`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(me,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued`}),(0,G.jsx)(`input`,{type:`text`,placeholder:`Search MCP servers...`,value:Vn,onChange:e=>Hn(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2.5 text-sm focus:border-indigo-500 outline-none`})]}),(0,G.jsx)(`div`,{className:`h-64 overflow-y-auto space-y-1 pr-1 scrollbar-thin scrollbar-thumb-shogun-border scrollbar-track-transparent`,children:qn.length===0?(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic text-center py-8`,children:`No MCP servers match your search.`}):qn.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{Un(e),Gn({})},className:L(`w-full text-left px-3 py-2.5 rounded-lg border transition-all group flex items-center justify-between gap-2`,Z?.name===e.name?`border-indigo-500/40 bg-indigo-500/10 text-shogun-text`:`border-transparent hover:border-shogun-border hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text`),children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-xs font-bold truncate`,children:e.name}),(0,G.jsx)(`p`,{className:`text-[10px] truncate opacity-70`,children:e.category})]}),(0,G.jsx)(f,{className:L(`w-3.5 h-3.5 shrink-0 transition-all`,Z?.name===e.name?`text-indigo-400 opacity-100`:`opacity-0 group-hover:opacity-50`)})]},e.name))})]}),(0,G.jsx)(`div`,{className:`flex flex-col`,children:Z?(0,G.jsxs)(`div`,{className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-text text-base`,children:Z.name}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1 leading-relaxed`,children:Z.description})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[{label:`COMMAND`,value:Z.transport===`stdio`?`${Z.command} ${Z.args.join(` `)}`:Z.github_url},{label:`TRANSPORT`,value:Z.transport.toUpperCase()},{label:`RISK`,value:Z.risk_level.toUpperCase()}].map(({label:e,value:t})=>(0,G.jsxs)(`div`,{className:L(`space-y-0.5`,e===`COMMAND`&&`col-span-2`),children:[(0,G.jsx)(`p`,{className:`text-shogun-subdued uppercase tracking-widest font-bold`,children:e}),(0,G.jsx)(`p`,{className:`text-shogun-text font-mono truncate`,children:t})]},e))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(j,{className:`w-3 h-3 text-shogun-subdued shrink-0`}),(0,G.jsx)(`a`,{href:Z.github_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-indigo-400 hover:underline truncate`,children:`View Repository →`})]}),Z.env_keys.length>0&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-shogun-border/50`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(F,{className:`w-3 h-3 text-shogun-gold`}),`Required Environment Variables`]}),Z.env_keys.map(e=>(0,G.jsx)(`input`,{type:`password`,placeholder:e,value:Wn[e]||``,onChange:t=>Gn({...Wn,[e]:t.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2.5 text-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/20 outline-none font-mono text-xs transition-all`},e))]})]}):(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center bg-[#050508] border border-dashed border-shogun-border rounded-xl p-8 gap-3`,children:[(0,G.jsx)(Ve,{className:`w-8 h-8 text-shogun-subdued opacity-40`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Select an MCP server from the catalog to configure it.`})]})})]}),zn===`manual`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Server Name *`}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. My Custom MCP`,value:Q.name,onChange:e=>Kn({...Q,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Transport`}),(0,G.jsxs)(`select`,{value:Q.transport,onChange:e=>Kn({...Q,transport:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none`,children:[(0,G.jsx)(`option`,{value:`stdio`,children:`STDIO (Local command)`}),(0,G.jsx)(`option`,{value:`sse`,children:`SSE (Remote URL)`})]})]}),Q.transport===`stdio`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Command *`}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. npx`,value:Q.command,onChange:e=>Kn({...Q,command:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Arguments`}),(0,G.jsx)(`input`,{type:`text`,placeholder:`e.g. -y @modelcontextprotocol/server-postgres`,value:Q.args,onChange:e=>Kn({...Q,args:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none font-mono`})]})]}):(0,G.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`SSE URL *`}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`https://mcp.example.com/sse`,value:Q.command,onChange:e=>Kn({...Q,command:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Risk Level`}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Ht.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>Kn({...Q,risk_level:e}),className:L(`flex-1 py-2 rounded-lg border text-[9px] font-bold uppercase tracking-widest transition-all`,Q.risk_level===e?Kt(e)+` border-opacity-100`:`border-shogun-border text-shogun-subdued hover:border-indigo-500/30`),children:e},e))})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-6 pt-5 border-t border-shogun-border`,children:[(0,G.jsxs)(`button`,{type:`submit`,disabled:Mn||zn===`quick`&&(!Z||Z.env_keys.some(e=>!Wn[e])),className:`flex items-center gap-2 px-6 py-2.5 bg-indigo-500 hover:bg-indigo-600 disabled:opacity-40 disabled:cursor-not-allowed text-white font-bold rounded-lg text-sm transition-all`,children:[Mn?(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(pe,{className:`w-4 h-4`}),`Register MCP Server`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Rn(!1),className:`px-4 py-2.5 text-sm font-bold text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`})]})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5`,children:vt?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(P,{className:`w-8 h-8 animate-spin mx-auto text-indigo-500 mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:`Loading MCPs`})]}):Tt.filter(e=>e.connector_type===`mcp`).length===0?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card border-dashed`,children:[(0,G.jsx)(M,{className:`w-8 h-8 text-shogun-subdued opacity-30 mx-auto mb-3`}),(0,G.jsx)(`p`,{className:`text-shogun-subdued italic text-sm`,children:`No MCP servers registered`}),(0,G.jsx)(`button`,{onClick:()=>Rn(!0),className:`mt-4 text-[10px] font-bold text-indigo-400 hover:text-indigo-300 uppercase tracking-widest transition-colors`,children:`+ Register your first MCP`})]}):Tt.filter(e=>e.connector_type===`mcp`).map(e=>(0,G.jsxs)(`div`,{className:`shogun-card hover:border-indigo-500/30 transition-all group relative`,children:[e.source!==`builtin`&&!e.config?.builtin&&(0,G.jsx)(`button`,{onClick:()=>Ir(e.id,e.name),className:`absolute top-3 right-3 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-500/10 text-red-500/50 hover:text-red-500 transition-all`,title:r(`katana.remove_connector`),children:(0,G.jsx)(we,{className:`w-3.5 h-3.5`})}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-subdued group-hover:text-indigo-400 transition-colors shrink-0`,children:(0,G.jsx)(M,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text truncate flex items-center gap-2`,children:[e.name,(e.source===`builtin`||e.config?.builtin)&&(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest text-indigo-300 border border-indigo-400/30 bg-indigo-500/10 rounded px-1.5 py-0.5`,children:`Standard`})]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate`,children:[e.config?.transport===`sse`?`SSE`:`STDIO`,` • `,e.slug]})]})]}),e.config?.command&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate mb-3 bg-[#050508] px-2 py-1 rounded border border-shogun-border`,title:e.config.transport===`stdio`?`${e.config.command} ${(e.config.args||[]).join(` `)}`:e.base_url,children:e.config.transport===`stdio`?`${e.config.command} ${(e.config.args||[]).join(` `)}`:e.base_url}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-shogun-border`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued`,children:`MCP`}),(0,G.jsx)(`span`,{className:L(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,Kt(e.risk_level||`low`)),children:e.risk_level||`low`})]}),(0,G.jsx)(`span`,{className:L(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,e.status===`connected`||e.status===`active`?`text-green-400 border-green-400/30 bg-green-400/5`:e.status===`disabled`?`text-shogun-subdued border-shogun-border bg-shogun-card`:`text-yellow-400 border-yellow-400/30 bg-yellow-400/5`),children:e.status||`not_configured`})]})]},e.id))})]}),t===`routing`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsx)(Ct,{isEditingProfiles:Qn,onEditProfiles:()=>$n(e=>!e)}),Qn&&(0,G.jsxs)(`div`,{className:`space-y-6 animate-in slide-in-from-top-2 duration-200`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(be,{className:`w-5 h-5 text-shogun-blue`}),` `,r(`katana.routing_profiles`),(0,G.jsxs)(`span`,{className:`text-[10px] font-normal bg-shogun-card border border-shogun-border px-1.5 py-0.5 rounded text-shogun-subdued`,children:[Jn.length,` profiles`]})]}),(0,G.jsxs)(`button`,{onClick:()=>Zn(e=>!e),className:L(`flex items-center gap-2 px-4 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,Xn?`bg-shogun-blue/10 border-shogun-blue/40 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:text-shogun-blue hover:border-shogun-blue/40 hover:bg-shogun-blue/5`),children:[Xn?(0,G.jsx)(ke,{className:`w-3 h-3`}):(0,G.jsx)(ue,{className:`w-3 h-3`}),r(Xn?`common.cancel`:`katana.new_profile`)]})]}),Xn&&(0,G.jsxs)(`div`,{className:`shogun-card border-shogun-blue/30 animate-in slide-in-from-top-3 duration-300`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text flex items-center gap-2 mb-4`,children:[(0,G.jsx)(k,{className:`w-4 h-4 text-shogun-blue`}),` `,r(`katana.new_routing_profile`)]}),(0,G.jsxs)(`form`,{onSubmit:Lr,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.profile_name`,`Profile Name *`)}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. Quality First`,value:or.name,onChange:e=>sr({...or,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.description`,`Description`)}),(0,G.jsx)(`input`,{type:`text`,placeholder:`Optional short description`,value:or.description,onChange:e=>sr({...or,description:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 mt-4 pt-4 border-t border-shogun-border`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer text-sm text-shogun-subdued hover:text-shogun-text transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:or.is_default,onChange:e=>sr({...or,is_default:e.target.checked}),className:`accent-shogun-blue`}),r(`katana.set_as_default_profile`)]}),(0,G.jsxs)(`button`,{type:`submit`,disabled:er||!or.name.trim(),className:`flex items-center gap-2 px-5 py-2 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm transition-all`,children:[er?(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(pe,{className:`w-4 h-4`}),`Create Profile`]})]})]})]}),vt?(0,G.jsxs)(`div`,{className:`p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(P,{className:`w-8 h-8 animate-spin mx-auto text-shogun-blue mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:r(`katana.loading_profiles`)})]}):Jn.length===0?(0,G.jsxs)(`div`,{className:`shogun-card text-center py-20 space-y-4 border-dashed`,children:[(0,G.jsx)(`div`,{className:`w-16 h-16 bg-shogun-blue/10 rounded-full flex items-center justify-center mx-auto`,children:(0,G.jsx)(s,{className:`w-8 h-8 text-shogun-blue`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:r(`katana.no_routing_profiles`)}),(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued mt-1 max-w-sm mx-auto`,children:r(`katana.no_routing_profiles_desc`)})]}),(0,G.jsx)(`button`,{onClick:()=>Zn(!0),className:`text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:r(`katana.create_first_profile`)})]}):(0,G.jsx)(`div`,{className:`space-y-4`,children:Jn.map(e=>{let t=nr===e.id,n=e.rules||[];return(0,G.jsxs)(`div`,{className:L(`shogun-card transition-all`,e.is_default?`border-shogun-gold/40`:`hover:border-shogun-blue/30`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:L(`w-12 h-12 rounded-xl flex items-center justify-center shrink-0`,e.is_default?`bg-shogun-gold/10 text-shogun-gold`:`bg-shogun-blue/10 text-shogun-blue`),children:e.is_default?(0,G.jsx)(Se,{className:`w-5 h-5`}):(0,G.jsx)(be,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:e.name}),e.is_default&&(0,G.jsx)(`span`,{className:`text-[8px] bg-shogun-gold/10 text-shogun-gold px-1.5 py-0.5 rounded border border-shogun-gold/30 font-bold uppercase tracking-widest`,children:r(`katana.default`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:e.description||r(`katana.no_description`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,G.jsxs)(`button`,{onClick:()=>{rr(t?null:e.id),ar(!1)},className:L(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,t?`border-shogun-blue/40 bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/30 hover:text-shogun-text`),children:[(0,G.jsx)(M,{className:`w-3 h-3`}),n.length,` `,n.length===1?r(`katana.rule`):r(`katana.rules`),t?(0,G.jsx)(p,{className:`w-3 h-3`}):(0,G.jsx)(u,{className:`w-3 h-3`})]}),!e.is_default&&(0,G.jsx)(`button`,{onClick:()=>zr(e.id),className:`p-2 hover:bg-shogun-gold/10 text-shogun-subdued hover:text-shogun-gold rounded-lg transition-colors`,title:r(`katana.set_as_default`),children:(0,G.jsx)(Ue,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Rr(e.id,e.name),className:`p-2 hover:bg-red-500/10 text-red-500/40 hover:text-red-500 rounded-lg transition-colors`,title:r(`katana.delete_profile`),children:(0,G.jsx)(we,{className:`w-4 h-4`})})]})]}),t&&(0,G.jsxs)(`div`,{className:`mt-5 pt-5 border-t border-shogun-border space-y-3 animate-in slide-in-from-top-2 duration-200`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.routing_rules`)}),!ir&&(0,G.jsxs)(`button`,{onClick:()=>ar(!0),className:`flex items-center gap-1 text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:[(0,G.jsx)(ue,{className:`w-3 h-3`}),` `,r(`katana.add_rule`)]})]}),n.length===0&&!ir?(0,G.jsx)(`div`,{className:`text-center py-6 bg-[#050508] rounded-xl border border-dashed border-shogun-border`,children:(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic`,children:r(`katana.no_rules`)})}):(0,G.jsx)(`div`,{className:`space-y-2`,children:n.map((t,i)=>{let a=St.find(e=>e.id===t.primary_model_id);return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 bg-[#050508] border border-shogun-border rounded-xl p-3 group`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-shogun-blue/10 flex items-center justify-center shrink-0`,children:(0,G.jsx)(k,{className:`w-4 h-4 text-shogun-blue`})}),(0,G.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 md:grid-cols-4 gap-x-4 gap-y-1`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:r(`katana.task_type_label`)}),(0,G.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:t.task_type===`*`?r(`katana.all_tasks`):t.task_type})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:r(`katana.primary_model`)}),(0,G.jsx)(`p`,{className:`text-xs font-bold text-shogun-text truncate`,children:a?.name||(0,G.jsx)(`span`,{className:`text-red-400/70 text-[10px]`,children:r(`katana.unlinked`)})}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued mt-0.5`,children:[t.fallback_model_ids?.length||0,` fallback(s)`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:r(`katana.latency`)}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-text`,children:t.latency_bias||(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:`—`})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:r(`katana.cost`)}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-text`,children:t.cost_bias||(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:`—`})})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-none pl-4 border-l border-shogun-border/30`,children:[(0,G.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),Br(i,t)},className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-shogun-blue/10 border border-shogun-blue/20 hover:bg-shogun-blue/20 text-shogun-blue transition-all`,title:r(`common.edit`),children:[(0,G.jsx)(U,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,children:r(`common.edit`)})]}),(0,G.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),Hr(e.id,n,i)},className:`flex items-center gap-2 px-2 py-1.5 rounded-lg bg-red-500/5 border border-red-500/10 hover:bg-red-500/10 text-red-500 transition-all`,title:r(`common.delete`),children:[(0,G.jsx)(we,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,children:r(`common.delete`)})]})]})]},i)})}),ir&&(0,G.jsxs)(`div`,{className:`bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl p-4 space-y-4 animate-in slide-in-from-top-2 duration-200`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest flex items-center gap-1.5`,children:lr===null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ue,{className:`w-3 h-3`}),` `,r(`katana.new_routing_rule`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{className:`w-3 h-3`}),` `,r(`katana.edit_routing_rule`)]})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.task_type`,`Task Type`)}),(0,G.jsxs)(`select`,{value:$.task_type,onChange:e=>cr({...$,task_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:`*`,children:r(`katana.all_tasks_wildcard`)}),(0,G.jsx)(`option`,{value:`research`,children:r(`katana.task_research`)}),(0,G.jsx)(`option`,{value:`code`,children:r(`katana.task_code`)}),(0,G.jsx)(`option`,{value:`analysis`,children:r(`katana.task_analysis`)}),(0,G.jsx)(`option`,{value:`creative`,children:r(`katana.task_creative`)}),(0,G.jsx)(`option`,{value:`summarize`,children:r(`katana.task_summarize`)}),(0,G.jsx)(`option`,{value:`planning`,children:r(`katana.task_planning`)}),(0,G.jsx)(`option`,{value:`qa`,children:r(`katana.task_qa`)}),(0,G.jsx)(`option`,{value:`chat`,children:r(`katana.task_chat`)}),(0,G.jsx)(`option`,{value:`extraction`,children:r(`katana.task_extraction`)}),(0,G.jsx)(`option`,{value:`translation`,children:r(`katana.task_translation`)}),(0,G.jsx)(`option`,{value:`vision`,children:r(`katana.task_vision`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.primary_model_provider`,`Primary Model Provider *`)}),(0,G.jsxs)(`select`,{value:$.primary_model_id,onChange:e=>cr({...$,primary_model_id:e.target.value,fallback_model_ids:$.fallback_model_ids.filter(t=>t!==e.target.value)}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:r(`katana.select_provider`)}),St.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.name,` — `,e.provider_type]},e.id)),St.length===0&&(0,G.jsx)(`option`,{disabled:!0,children:r(`katana.no_providers_yet`)})]}),St.length===0&&(0,G.jsxs)(`p`,{className:`text-[9px] text-yellow-400`,children:[`⚠ `,r(`katana.add_provider_first`)]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Fallback Chain (in order)`}),(0,G.jsxs)(`select`,{value:``,onChange:e=>{let t=e.target.value;t&&!$.fallback_model_ids.includes(t)&&cr({...$,fallback_model_ids:[...$.fallback_model_ids,t]})},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:`— Add fallback provider —`}),St.filter(e=>e.id!==$.primary_model_id&&!$.fallback_model_ids.includes(e.id)).map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.name,` — `,e.provider_type]},e.id))]}),$.fallback_model_ids.map((e,t)=>{let n=St.find(t=>t.id===e);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-shogun-border bg-[#050508] px-3 py-2`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold text-shogun-gold`,children:[`#`,t+1]}),(0,G.jsx)(`span`,{className:`flex-1 text-xs`,children:n?.name||`Unlinked provider`}),(0,G.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>{let e=[...$.fallback_model_ids];[e[t-1],e[t]]=[e[t],e[t-1]],cr({...$,fallback_model_ids:e})},className:`disabled:opacity-20`,children:(0,G.jsx)(p,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{type:`button`,disabled:t===$.fallback_model_ids.length-1,onClick:()=>{let e=[...$.fallback_model_ids];[e[t],e[t+1]]=[e[t+1],e[t]],cr({...$,fallback_model_ids:e})},className:`disabled:opacity-20`,children:(0,G.jsx)(u,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>cr({...$,fallback_model_ids:$.fallback_model_ids.filter(t=>t!==e)}),children:(0,G.jsx)(ke,{className:`w-3.5 h-3.5 text-red-400`})})]},e)}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:`A model is tried after the previous model exhausts its configured retries or times out.`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.latency_bias`,`Latency Bias`)}),(0,G.jsxs)(`select`,{value:$.latency_bias,onChange:e=>cr({...$,latency_bias:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:r(`katana.none_unbiased`)}),(0,G.jsx)(`option`,{value:`low`,children:r(`katana.latency_low`)}),(0,G.jsx)(`option`,{value:`medium`,children:r(`katana.latency_medium`)}),(0,G.jsx)(`option`,{value:`high`,children:r(`katana.latency_high`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.cost_bias`,`Cost Bias`)}),(0,G.jsxs)(`select`,{value:$.cost_bias,onChange:e=>cr({...$,cost_bias:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:r(`katana.none_unbiased`)}),(0,G.jsx)(`option`,{value:`budget`,children:r(`katana.cost_budget`)}),(0,G.jsx)(`option`,{value:`standard`,children:r(`katana.cost_standard`)}),(0,G.jsx)(`option`,{value:`premium`,children:r(`katana.cost_premium`)})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 pt-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Vr(e.id,n),disabled:!$.primary_model_id,className:`flex items-center gap-2 px-5 py-2 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 disabled:cursor-not-allowed text-white font-bold rounded-lg text-sm transition-all`,children:[(0,G.jsx)(pe,{className:`w-3.5 h-3.5`}),` `,r(lr===null?`katana.save_rule`:`katana.update_rule`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{ar(!1),ur(null),cr({task_type:`*`,primary_model_id:``,fallback_model_ids:[],latency_bias:``,cost_bias:``})},className:`px-4 py-2 text-sm text-shogun-subdued hover:text-shogun-text transition-colors font-bold`,children:r(`common.cancel`)}),!$.primary_model_id&&(0,G.jsx)(`span`,{className:`text-[10px] text-shogun-subdued ml-auto`,children:r(`katana.select_provider_continue`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2 mt-2 px-1`,children:[(0,G.jsx)(ve,{className:`w-3 h-3 text-shogun-subdued mt-0.5 shrink-0`}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:[r(`katana.routing_legend`),` `,(0,G.jsx)(`code`,{className:`text-shogun-blue font-mono`,children:`task_type`}),` `,r(`katana.routing_legend_wins`),`.`,r(`katana.routing_legend_wildcard`),` `,(0,G.jsx)(`code`,{className:`text-shogun-blue font-mono`,children:`*`}),` `,r(`katana.routing_legend_catch`),`.`]})]})]})]},e.id)})})]})]}),t===`teams`&&(0,G.jsx)(Je,{}),t===`telegram`&&(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(H,{className:`w-5 h-5 text-shogun-blue`}),` `,r(`katana.telegram_channel`)]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:r(`katana.telegram_desc`)})]}),a?.connected&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-green-400/10 border border-green-400/30 rounded-lg`,children:[(0,G.jsx)(I,{className:`w-3.5 h-3.5 text-green-400`}),(0,G.jsx)(`span`,{className:`text-xs font-bold text-green-400`,children:r(`katana.connected`)})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-5 gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 space-y-5`,children:[a?.connected&&(0,G.jsxs)(`div`,{className:`shogun-card bg-green-400/5 border-green-400/20 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-green-400/10 border border-green-400/30 flex items-center justify-center`,children:(0,G.jsx)(H,{className:`w-6 h-6 text-green-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`font-bold text-shogun-text`,children:[`@`,a.bot_username]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[`Bot ID: `,a.bot_id,` · `,a.first_name]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[r(`katana.mode`),`: `,(0,G.jsx)(`span`,{className:`font-bold uppercase text-green-400`,children:a.mode}),a.last_connected_at&&(0,G.jsxs)(G.Fragment,{children:[` · `,new Date(a.last_connected_at).toLocaleDateString()]})]})]})]}),(0,G.jsxs)(`button`,{onClick:_r,className:`flex items-center gap-1.5 px-3 py-1.5 border border-red-400/30 text-red-400/70 hover:text-red-400 hover:border-red-400/50 rounded-lg text-xs font-bold transition-all`,children:[(0,G.jsx)(De,{className:`w-3.5 h-3.5`}),` `,r(`katana.disconnect`)]})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:a?.connected?r(`katana.update_configuration`):r(`katana.connect_a_bot`)}),(0,G.jsxs)(`form`,{onSubmit:mr,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(F,{className:`w-3 h-3 text-shogun-gold`}),` `,r(`katana.bot_token`)]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:Ce?`text`:`password`,required:!0,placeholder:a?.connected?`Enter new token to re-connect…`:`123456789:AAExxxxxxxx`,value:d,onChange:e=>h(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 pr-10 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Te(e=>!e),className:`absolute right-3 top-1/2 -translate-y-1/2 text-shogun-subdued hover:text-shogun-text`,children:Ce?(0,G.jsx)(Fe,{className:`w-3.5 h-3.5`}):(0,G.jsx)(C,{className:`w-3.5 h-3.5`})})]}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:[r(`katana.get_token_from`),` `,(0,G.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-shogun-blue hover:underline`,children:`@BotFather`}),`.`]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.update_mode`,`Update Mode`)}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[`polling`,`webhook`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>v(e),className:L(`flex-1 py-2 rounded-lg border text-xs font-bold uppercase tracking-widest transition-all`,_===e?`bg-shogun-blue text-white border-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/40`),children:r(e===`polling`?`katana.polling`:`katana.webhook`)},e))}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:r(_===`polling`?`katana.polling_desc`:`katana.webhook_desc`)})]}),_===`webhook`&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.webhook_url`,`Webhook URL *`)}),(0,G.jsx)(`input`,{type:`url`,required:!0,placeholder:`https://yourdomain.com/telegram/webhook`,value:y,onChange:e=>O(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(ve,{className:`w-3 h-3 text-shogun-gold`}),` `,r(`katana.allowed_chat_ids`),(0,G.jsxs)(`span`,{className:`font-normal normal-case tracking-normal text-shogun-subdued/50`,children:[`(`,r(`katana.optional_whitelist`),`)`]})]}),(0,G.jsx)(`input`,{type:`text`,placeholder:`e.g. 123456789, -987654321`,value:A,onChange:e=>ne(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:r(`katana.chat_ids_help`)})]}),(0,G.jsx)(`button`,{type:`submit`,disabled:se||!d.trim(),className:`w-full flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm transition-all`,children:se?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}),` `,r(`katana.connecting`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(H,{className:`w-4 h-4`}),` `,a?.connected?r(`katana.update_connection`):r(`katana.connect_bot`)]})})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-5`,children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(he,{className:`w-4 h-4 text-shogun-blue`}),` `,r(`katana.test_connection`)]}),a?.connected?(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:`Your chat ID, e.g. 123456789`,value:ie,onChange:e=>oe(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`button`,{onClick:hr,disabled:le||!ie.trim(),className:`w-full flex items-center justify-center gap-2 py-2.5 border border-shogun-blue/40 bg-shogun-blue/10 hover:bg-shogun-blue/20 text-shogun-blue disabled:opacity-40 font-bold rounded-lg text-sm transition-all`,children:le?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(P,{className:`w-3.5 h-3.5 animate-spin`}),` `,r(`katana.sending`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(he,{className:`w-3.5 h-3.5`}),` `,r(`katana.send_test`)]})}),ge&&(0,G.jsxs)(`div`,{className:L(`p-3 rounded-lg text-xs flex items-start gap-2`,ge.ok?`bg-green-400/10 border border-green-400/20 text-green-400`:`bg-red-400/10 border border-red-400/20 text-red-400`),children:[ge.ok?(0,G.jsx)(l,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}):(0,G.jsx)(m,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),ge.message||ge.error]})]}):(0,G.jsx)(`p`,{className:`text-center py-6 text-shogun-subdued text-xs italic`,children:r(`katana.connect_bot_first`)})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(f,{className:`w-4 h-4 text-shogun-gold`}),` `,r(`katana.quick_setup`)]}),(0,G.jsx)(`ol`,{className:`space-y-3`,children:[{n:`1`,t:r(`katana.tg_step1`),href:`https://t.me/BotFather`},{n:`2`,t:r(`katana.tg_step2`)},{n:`3`,t:r(`katana.tg_step3`)},{n:`4`,t:r(`katana.tg_step4`)},{n:`5`,t:r(`katana.tg_step5`)}].map(({n:e,t,href:n})=>(0,G.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`span`,{className:`w-5 h-5 rounded-full bg-shogun-blue/20 border border-shogun-blue/40 text-shogun-blue text-[9px] font-bold flex items-center justify-center shrink-0 mt-0.5`,children:e}),(0,G.jsxs)(`span`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[t,n&&(0,G.jsxs)(G.Fragment,{children:[` — `,(0,G.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`text-shogun-blue hover:underline`,children:n.split(`//`)[1]})]})]})]},e))}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-shogun-border mt-3`,children:[(0,G.jsxs)(`button`,{onClick:gr,disabled:ye,className:`w-full flex items-center justify-center gap-2 py-2 border border-shogun-gold/30 bg-shogun-gold/10 hover:bg-shogun-gold/20 text-shogun-gold disabled:opacity-40 font-bold rounded-lg text-xs transition-all`,children:[ye?(0,G.jsx)(P,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(me,{className:`w-3.5 h-3.5`}),r(`katana.auto_detect_chat_id`)]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued text-center mt-2 leading-tight`,children:[r(`katana.must_complete_step5`),` `,(0,G.jsx)(`br`,{}),r(`katana.auto_whitelist_desc`)]})]})]})]})]})]}),t===`telegram`&&Me.length>0&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 mt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(H,{className:`w-4 h-4 text-sky-400`}),` Forum Topic Mapping`]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:[`Thread IDs are captured automatically. Name older topics here, or send `,(0,G.jsx)(`b`,{children:`*strategy`}),`, `,(0,G.jsx)(`b`,{children:`*research`}),`, `,(0,G.jsx)(`b`,{children:`*shogun`}),`, `,(0,G.jsx)(`b`,{children:`*personal`}),`, `,(0,G.jsx)(`b`,{children:`*education`}),`, `,(0,G.jsx)(`b`,{children:`*general`}),`, or `,(0,G.jsx)(`b`,{children:`*news`}),` inside a topic to teach Shogun automatically.`]})]}),Me.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border bg-[#050508] p-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsx)(`b`,{children:e.chat_title||`Telegram group`}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-shogun-subdued`,children:e.chat_id})]}),(e.topics||[]).length===0?(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`No forum threads observed yet. Send one message in each topic.`}):(e.topics||[]).map(t=>{let n=`${e.chat_id}:${t.message_thread_id}`;return(0,G.jsxs)(`div`,{className:`grid grid-cols-[90px_minmax(0,1fr)_90px] items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-sky-400`,children:[`Thread `,t.message_thread_id]}),(0,G.jsx)(`input`,{value:Ie[n]||``,onChange:e=>Le(t=>({...t,[n]:e.target.value})),placeholder:`Enter topic name`,className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-xs focus:border-sky-400 outline-none`}),(0,G.jsx)(`button`,{onClick:()=>pr(e.chat_id,t.message_thread_id),disabled:Re===n||!(Ie[n]||``).trim(),className:`rounded-lg border border-sky-400/30 bg-sky-400/10 px-3 py-2 text-[10px] font-bold text-sky-300 disabled:opacity-40`,children:Re===n?`SAVING`:`SAVE`})]},n)})]},e.chat_id))]}),t===`mail_calendar`&&(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(re,{className:`w-5 h-5 text-shogun-blue`}),` `,r(`katana.mail_calendar_settings`,`Mail & Calendar Settings`)]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:r(`katana.mail_calendar_desc`,`Configure a single email and calendar account to send/receive mail and manage events.`)})]}),z?.is_active&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-green-400/10 border border-green-400/30 rounded-lg`,children:[(0,G.jsx)(I,{className:`w-3.5 h-3.5 text-green-400`}),(0,G.jsx)(`span`,{className:`text-xs font-bold text-green-400`,children:r(`katana.connected`,`Connected`)})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-5 gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 space-y-5`,children:[z?.is_active&&(0,G.jsxs)(`div`,{className:`shogun-card bg-green-400/5 border-green-400/20 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-green-400/10 border border-green-400/30 flex items-center justify-center`,children:(0,G.jsx)(re,{className:`w-6 h-6 text-green-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-shogun-text`,children:z.display_name||z.email_address}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[z.email_address,` · `,z.provider.toUpperCase()]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[r(`katana.calendar_integrated`,`Calendar`),`: `,(0,G.jsx)(`span`,{className:`font-bold uppercase text-green-400`,children:z.calendar_provider})]})]})]}),(0,G.jsxs)(`button`,{onClick:br,className:`flex items-center gap-1.5 px-3 py-1.5 border border-red-400/30 text-red-400/70 hover:text-red-400 hover:border-red-400/50 rounded-lg text-xs font-bold transition-all`,children:[(0,G.jsx)(De,{className:`w-3.5 h-3.5`}),` `,r(`katana.disconnect`,`Disconnect`)]})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:z?.is_active?r(`katana.update_mail_config`,`Update Connection Settings`):r(`katana.connect_mail_account`,`Connect Email Account`)}),(0,G.jsxs)(`form`,{onSubmit:yr,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.mail_provider`,`Provider`)}),(0,G.jsxs)(`select`,{value:B.provider,onChange:e=>V({...B,provider:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none text-shogun-text`,children:[(0,G.jsx)(`option`,{value:`gmail`,children:`Google Gmail`}),(0,G.jsx)(`option`,{value:`outlook`,children:`Microsoft Outlook`}),(0,G.jsx)(`option`,{value:`proton`,children:`Proton Mail (Bridge)`}),(0,G.jsx)(`option`,{value:`other`,children:`Other / Custom IMAP`})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.display_name`,`Display Name`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`e.g. Shogun Agent`,value:B.display_name,onChange:e=>V({...B,display_name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.email_address`,`Email Address`)}),(0,G.jsx)(`input`,{type:`email`,required:!0,placeholder:`e.g. user@domain.com`,value:B.email_address,onChange:e=>V({...B,email_address:e.target.value,username:B.username||e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider`,children:r(`katana.incoming_mail_server`,`Incoming Mail Server`)}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[`imap`,`pop3`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>V({...B,protocol:e}),className:L(`px-3 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider border transition-all`,B.protocol===e?`bg-shogun-blue text-white border-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/40`),children:e.toUpperCase()},e))})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsxs)(`div`,{className:`col-span-2 space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.incoming_host`,`Host`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`imap.example.com`,value:B.imap_host,onChange:e=>V({...B,imap_host:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.incoming_port`,`Port`)}),(0,G.jsx)(`input`,{type:`number`,required:!0,value:B.imap_port,onChange:e=>V({...B,imap_port:parseInt(e.target.value)||0}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:B.imap_use_ssl,onChange:e=>V({...B,imap_use_ssl:e.target.checked}),className:`accent-shogun-blue`}),r(`katana.incoming_ssl`,`Use SSL/TLS for Incoming Mail`)]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider block`,children:r(`katana.outgoing_mail_server`,`Outgoing SMTP Server`)}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsxs)(`div`,{className:`col-span-2 space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.outgoing_host`,`Host`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`smtp.example.com`,value:B.smtp_host,onChange:e=>V({...B,smtp_host:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.outgoing_port`,`Port`)}),(0,G.jsx)(`input`,{type:`number`,required:!0,value:B.smtp_port,onChange:e=>V({...B,smtp_port:parseInt(e.target.value)||0}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:B.smtp_use_ssl,onChange:e=>V({...B,smtp_use_ssl:e.target.checked}),className:`accent-shogun-blue`}),r(`katana.outgoing_ssl`,`Use SSL/TLS for Outgoing Mail`)]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider block`,children:r(`katana.auth`,`Authentication`)}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.username`,`Username`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`e.g. user@domain.com`,value:B.username,onChange:e=>V({...B,username:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center justify-between`,children:(0,G.jsx)(`span`,{children:r(`katana.password`,`Password`)})}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:$e?`text`:`password`,required:!z,placeholder:z?`••••••••`:`Password or App Password`,value:B.password,onChange:e=>V({...B,password:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 pr-10 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>et(e=>!e),className:`absolute right-3 top-1/2 -translate-y-1/2 text-shogun-subdued hover:text-shogun-text`,children:$e?(0,G.jsx)(Fe,{className:`w-3.5 h-3.5`}):(0,G.jsx)(C,{className:`w-3.5 h-3.5`})})]})]})]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider block`,children:r(`katana.calendar_integration`,`Calendar Integration`)}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.calendar_provider`,`Provider`)}),(0,G.jsxs)(`select`,{value:B.calendar_provider,onChange:e=>V({...B,calendar_provider:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none text-shogun-text`,children:[(0,G.jsx)(`option`,{value:`none`,children:`None / Disabled`}),(0,G.jsx)(`option`,{value:`caldav`,children:`CalDAV (Proton / Generic)`}),(0,G.jsx)(`option`,{value:`google_api`,children:`Google Calendar API`}),(0,G.jsx)(`option`,{value:`microsoft_graph`,children:`Microsoft Graph`})]})]}),B.calendar_provider===`caldav`&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:r(`katana.caldav_url`,`CalDAV URL`)}),(0,G.jsx)(`input`,{type:`url`,required:!0,placeholder:`https://caldav.example.com`,value:B.caldav_url,onChange:e=>V({...B,caldav_url:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]})]}),qe&&(0,G.jsxs)(`div`,{className:L(`p-4 rounded-lg text-xs space-y-2 border`,qe.ok?`bg-green-400/10 border-green-400/20 text-green-400`:`bg-red-400/10 border-red-400/20 text-red-400`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-bold`,children:[qe.ok?(0,G.jsx)(l,{className:`w-4 h-4`}):(0,G.jsx)(m,{className:`w-4 h-4`}),(0,G.jsx)(`span`,{children:qe.ok?r(`katana.test_successful`,`All connections successful!`):r(`katana.test_failed`,`Connection tests failed`)})]}),(0,G.jsx)(`p`,{className:`text-[10px] leading-relaxed opacity-90`,children:qe.message}),(0,G.jsxs)(`div`,{className:`flex gap-4 pt-1 text-[10px]`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:L(`w-1.5 h-1.5 rounded-full`,qe.imap_ok?`bg-green-400`:`bg-red-400`)}),`Incoming Server Login: `,qe.imap_ok?`OK`:`FAIL`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:L(`w-1.5 h-1.5 rounded-full`,qe.smtp_ok?`bg-green-400`:`bg-red-400`)}),`Outgoing SMTP Login: `,qe.smtp_ok?`OK`:`FAIL`]})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-4 pt-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:xr,disabled:Ge||!B.email_address||!B.username,className:`flex-1 flex items-center justify-center gap-2 py-3 border border-shogun-blue/40 bg-shogun-blue/10 hover:bg-shogun-blue/20 text-shogun-blue disabled:opacity-40 font-bold rounded-lg text-sm transition-all`,children:[Ge?(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(he,{className:`w-4 h-4`}),r(`katana.test_connection`,`Test Connection`)]}),(0,G.jsxs)(`button`,{type:`submit`,disabled:He||!B.email_address||!B.username,className:`flex-1 flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm transition-all`,children:[He?(0,G.jsx)(P,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(pe,{className:`w-4 h-4`}),z?.is_active?r(`katana.save_settings`,`Save Settings`):r(`katana.connect_account`,`Connect Account`)]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-5`,children:[z&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(F,{className:`w-4 h-4 text-shogun-gold`}),r(`katana.permissions_toggles`,`Account Scopes`)]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:r(`katana.permissions_help`,`Choose which operations this connected account exposes. ToolGate remains the runtime authority and may further restrict or require confirmation for every action.`)}),(0,G.jsx)(`div`,{className:`space-y-3 pt-2`,children:[{key:`perm_read_mail`,label:r(`katana.perm_read_mail`,`📨 Read Mail (Inbox/Folders)`)},{key:`perm_send_mail`,label:r(`katana.perm_send_mail`,`✉️ Send / Reply to Mail`)},{key:`perm_delete_mail`,label:r(`katana.perm_delete_mail`,`🗑️ Delete Mail (Move to Trash)`)},{key:`perm_read_calendar`,label:r(`katana.perm_read_calendar`,`📅 Read Calendar Events`)},{key:`perm_create_events`,label:r(`katana.perm_create_events`,`➕ Create Calendar Events`)},{key:`perm_edit_events`,label:r(`katana.perm_edit_events`,`✏️ Edit Calendar Events`)},{key:`perm_delete_events`,label:r(`katana.perm_delete_events`,`🗑️ Delete Calendar Events`)}].map(({key:e,label:t})=>(0,G.jsxs)(`label`,{className:`flex items-center justify-between py-2 border-b border-shogun-border/30 cursor-pointer group`,children:[(0,G.jsx)(`span`,{className:`text-xs text-shogun-subdued group-hover:text-shogun-text transition-colors`,children:t}),(0,G.jsx)(`input`,{type:`checkbox`,checked:Xe[e],onChange:t=>Qe({...Xe,[e]:t.target.checked}),className:`w-4 h-4 accent-shogun-blue cursor-pointer`})]},e))}),(0,G.jsxs)(`button`,{onClick:Sr,disabled:He,className:`w-full flex items-center justify-center gap-2 py-2.5 mt-2 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold rounded-lg text-xs transition-all`,children:[He?(0,G.jsx)(P,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(pe,{className:`w-3.5 h-3.5`}),r(`katana.save_permissions`,`Save Permissions`)]}),(0,G.jsx)(`button`,{onClick:()=>e(`/toolgate`),className:`w-full rounded-lg border border-shogun-border py-2.5 text-xs font-bold text-shogun-blue transition-colors hover:border-shogun-blue/40 hover:bg-shogun-blue/10`,children:`View effective rules in ToolGate`})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(f,{className:`w-4 h-4 text-shogun-gold`}),r(`katana.setup_guides`,`Quick Setup Guide`)]}),(0,G.jsxs)(`div`,{className:`text-xs space-y-4`,children:[B.provider===`gmail`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Google Gmail Setup:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-4 space-y-1.5 text-shogun-subdued text-[11px] leading-relaxed`,children:[(0,G.jsx)(`li`,{children:`Go to your Google Account settings → Security.`}),(0,G.jsxs)(`li`,{children:[`Ensure `,(0,G.jsx)(`strong`,{children:`2-Step Verification`}),` is enabled.`]}),(0,G.jsxs)(`li`,{children:[`Click on `,(0,G.jsx)(`strong`,{children:`App passwords`}),` (or search for it).`]}),(0,G.jsx)(`li`,{children:`Generate a new app password for "Mail" on your device.`}),(0,G.jsx)(`li`,{children:`Use your Gmail address as username and the 16-character generated password to connect.`})]})]}),B.provider===`outlook`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Outlook / Office 365 Setup:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-4 space-y-1.5 text-shogun-subdued text-[11px] leading-relaxed`,children:[(0,G.jsx)(`li`,{children:`Log in to your Outlook Account security settings.`}),(0,G.jsxs)(`li`,{children:[`Select `,(0,G.jsx)(`strong`,{children:`Manage how I sign in`}),` → App passwords.`]}),(0,G.jsx)(`li`,{children:`Create a new App Password.`}),(0,G.jsx)(`li`,{children:`Use your Outlook email address and the App Password to connect.`}),(0,G.jsx)(`li`,{children:`For Exchange accounts, verify IMAP access is enabled in Outlook settings.`})]})]}),B.provider===`proton`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Proton Mail (Bridge) Setup:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-4 space-y-1.5 text-shogun-subdued text-[11px] leading-relaxed`,children:[(0,G.jsxs)(`li`,{children:[`Download and open the `,(0,G.jsx)(`strong`,{children:`Proton Mail Bridge`}),` application.`]}),(0,G.jsx)(`li`,{children:`Add your Proton account to the Bridge and wait for local encryption to sync.`}),(0,G.jsx)(`li`,{children:`Go to Bridge settings to view the local IMAP port, SMTP port, and Bridge password.`}),(0,G.jsxs)(`li`,{children:[`Set host to `,(0,G.jsx)(`code`,{className:`text-shogun-blue font-mono bg-[#050508] px-1 rounded`,children:`127.0.0.1`}),`.`]}),(0,G.jsx)(`li`,{children:`Use the ports provided by the Bridge (default: IMAP 1143, SMTP 1025) and disable SSL/TLS toggles (the Bridge encrypts traffic locally).`})]})]}),B.provider===`other`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Generic Mail Provider:`}),(0,G.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:`Enter your custom IMAP and SMTP server details (hostnames, ports, and SSL settings) as provided by your email provider. Ensure your credentials are correct.`})]})]})]})]})]})]}),t===`office`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[it===`shrine`&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-red-500/30 bg-red-500/10 p-5 flex items-center gap-4`,children:[(0,G.jsx)(m,{className:`w-6 h-6 text-red-400 flex-shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-red-400`,children:`Office Disabled at SHRINE Posture`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Office App Mode is blocked at SHRINE security tier. Raise your posture in Torii to at least GUARDED to use Office automation.`})]})]}),(0,G.jsxs)(`div`,{className:L(it===`shrine`&&`opacity-40 pointer-events-none select-none`),children:[K&&(0,G.jsxs)(`div`,{className:L(`rounded-xl border p-5 transition-all duration-500 mb-6`,K.enabled?`border-green-500/40 bg-gradient-to-r from-[#0f1422] to-[#131926] shadow-xl shadow-green-500/10`:`border-shogun-border bg-shogun-card`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:L(`p-3 rounded-xl transition-colors duration-500`,K.enabled?`bg-green-500/15 text-green-400`:`bg-shogun-bg text-shogun-subdued`),children:(0,G.jsx)(de,{className:`w-6 h-6`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-shogun-text`,children:`Office App Mode`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:K.enabled?`Active — AI agents can interact with Office applications`:`Disabled — Enable to allow Office automation`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[ut&&(0,G.jsx)(`span`,{className:`text-xs text-amber-400 animate-pulse`,children:`Unsaved`}),(0,G.jsxs)(`button`,{onClick:mt,disabled:ot||!ut,className:L(`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all`,ut?`bg-shogun-gold text-black hover:bg-[#e6b422] shadow-lg shadow-shogun-gold/20`:`bg-shogun-border text-shogun-subdued cursor-not-allowed`),children:[ot?(0,G.jsx)(N,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(pe,{className:`w-4 h-4`}),` Save`]}),(0,G.jsx)(`button`,{onClick:()=>gt(`enabled`,!K.enabled),className:L(`relative w-14 h-7 rounded-full transition-all duration-500`,K.enabled?`bg-green-500`:`bg-shogun-border`),children:(0,G.jsx)(`span`,{className:L(`absolute top-1 w-5 h-5 rounded-full bg-white shadow-lg transition-transform duration-500`,K.enabled?`translate-x-8 left-0`:`left-1`)})})]})]}),!tt?.platform_supported&&(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-amber-400 bg-amber-500/10 rounded-lg p-3`,children:[(0,G.jsx)(m,{className:`w-4 h-4 flex-shrink-0`}),(0,G.jsx)(`span`,{children:tt?.message||`Office App Mode requires Windows with Microsoft Office installed.`})]})]}),tt&&K&&(0,G.jsxs)(`div`,{className:`space-y-3 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-shogun-subdued uppercase tracking-wider`,children:`Applications`}),(0,G.jsxs)(`button`,{onClick:ht,disabled:ct,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-shogun-subdued bg-shogun-bg hover:bg-shogun-border border border-shogun-border transition-all`,children:[(0,G.jsx)(P,{className:L(`w-3.5 h-3.5`,ct&&`animate-spin`)}),` Re-detect`]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[{app:tt.excel,key:`excel`,icon:w,color:`text-green-400`,label:`Excel`},{app:tt.word,key:`word`,icon:T,color:`text-blue-400`,label:`Word`},{app:tt.powerpoint,key:`powerpoint`,icon:M,color:`text-orange-400`,label:`PowerPoint`},{app:tt.outlook,key:`outlook`,icon:re,color:`text-cyan-400`,label:`Outlook`}].map(({app:e,key:t,icon:n,color:r,label:i})=>(0,G.jsxs)(`div`,{className:L(`relative rounded-xl border p-5 transition-all duration-300`,e?.installed&&K[t]?.enabled?`border-shogun-gold/30 bg-shogun-card shadow-lg shadow-shogun-gold/5`:`border-shogun-border bg-shogun-bg/60 opacity-70`),children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:L(`p-2.5 rounded-lg bg-shogun-bg`,r),children:(0,G.jsx)(n,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-shogun-text`,children:i}),e?.version&&(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:[`v`,e.version]})]})]}),(0,G.jsx)(`button`,{onClick:()=>gt(`${t}.enabled`,!K[t]?.enabled),disabled:!e?.installed,className:L(`relative w-10 h-5 rounded-full transition-all duration-300`,K[t]?.enabled&&e?.installed?`bg-shogun-gold`:`bg-shogun-border`,!e?.installed&&`opacity-40 cursor-not-allowed`),children:(0,G.jsx)(`span`,{className:L(`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-md transition-transform duration-300`,K[t]?.enabled&&e?.installed?`translate-x-5 left-0.5`:`left-0.5`)})})]}),(0,G.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:(0,G.jsxs)(`span`,{className:L(`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium tracking-wide`,e?.installed?`bg-emerald-500/15 text-emerald-400 ring-1 ring-emerald-500/30`:`bg-red-500/15 text-red-400 ring-1 ring-red-500/30`),children:[e?.installed?(0,G.jsx)(g,{className:`w-3.5 h-3.5`}):(0,G.jsx)(ke,{className:`w-3.5 h-3.5`}),e?.installed?`Installed`:`Not found`]})})]},t))})]}),K&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(E,{className:`w-4 h-4 text-shogun-gold`}),` Approved Folders`]}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`All file operations are restricted to these folders. Files outside these boundaries will be rejected. By default, these map to subdirectories inside the `,(0,G.jsx)(`span`,{className:`text-shogun-gold font-medium`,children:`Agent Workspace`}),`.`]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[`input`,`output`,`templates`,`temp`].map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-shogun-subdued mb-1.5 capitalize`,children:e}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(D,{className:`w-4 h-4 text-shogun-subdued flex-shrink-0`}),(0,G.jsx)(`input`,{type:`text`,value:K.folders?.[e]||``,onChange:t=>gt(`folders.${e}`,t.target.value),placeholder:`workspace/${e}`,className:`flex-1 bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text placeholder-shogun-subdued/40 focus:outline-none focus:border-shogun-gold/50 transition-colors font-mono`})]})]},e))}),(0,G.jsxs)(`div`,{className:`bg-shogun-blue/5 border border-shogun-blue/20 rounded-lg p-3 flex items-start gap-2`,children:[(0,G.jsx)(T,{className:`w-4 h-4 text-shogun-blue flex-shrink-0 mt-0.5`}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Leave paths empty to auto-map to the `,(0,G.jsx)(`span`,{className:`text-shogun-blue font-medium`,children:`Workspace`}),` root folder (data/workspace). The Workspace is shared between Shogun, Samurai, and the File Explorer in Comms.`]})]})]}),K&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(ve,{className:`w-4 h-4 text-shogun-gold`}),` Safety & Security`]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:[{key:`safety.block_path_traversal`,label:`Block path traversal`,desc:`Prevent ../ escape attacks`},{key:`safety.block_shortcuts`,label:`Block .lnk files`,desc:`Prevent shortcut escape`},{key:`safety.block_unc_paths`,label:`Block UNC paths`,desc:`Prevent network path access`},{key:`safety.version_outputs`,label:`Version outputs`,desc:`Auto-timestamp output files`},{key:`safety.require_output_validation`,label:`Validate outputs`,desc:`Verify output file integrity`},{key:`temp_cleanup_on_startup`,label:`Cleanup temp on startup`,desc:`Remove temp files at boot`}].map(e=>{let t=e.key.split(`.`),n=t.length===2?K[t[0]]?.[t[1]]:K[t[0]];return(0,G.jsxs)(`label`,{className:`flex items-start gap-3 p-3 rounded-lg bg-shogun-bg border border-shogun-border cursor-pointer hover:border-shogun-gold/20 transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!n,onChange:()=>gt(e.key,!n),className:`mt-0.5 accent-[#d4a017]`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm text-shogun-text font-medium`,children:e.label}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:e.desc})]})]},e.key)})})]}),K&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(re,{className:`w-4 h-4 text-cyan-400`}),` Outlook Settings`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-shogun-subdued mb-2`,children:`Outlook Mode`}),(0,G.jsx)(`div`,{className:`flex gap-3`,children:[{value:`draft_only`,label:`Draft Only`,desc:`Create drafts, never send`},{value:`confirmed_send`,label:`Confirmed Send`,desc:`Send with approval`},{value:`approved_recipient_send`,label:`Approved Recipients`,desc:`Auto-send to allowlist`}].map(e=>(0,G.jsxs)(`button`,{onClick:()=>gt(`outlook.mode`,e.value),className:L(`flex-1 p-3 rounded-lg border text-left transition-all`,K.outlook?.mode===e.value?`border-shogun-gold/50 bg-shogun-gold/10`:`border-shogun-border bg-shogun-bg hover:border-shogun-gold/20`),children:[(0,G.jsx)(`p`,{className:L(`text-sm font-medium`,K.outlook?.mode===e.value?`text-shogun-gold`:`text-shogun-text`),children:e.label}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:e.desc})]},e.value))})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-start gap-3 p-3 rounded-lg bg-shogun-bg border border-shogun-border cursor-pointer hover:border-shogun-gold/20 transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!K.outlook?.require_confirmation,onChange:()=>gt(`outlook.require_confirmation`,!K.outlook?.require_confirmation),className:`mt-0.5 accent-[#d4a017]`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm text-shogun-text font-medium`,children:`Require confirmation`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:`Human must approve before sending`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-3 p-3 rounded-lg bg-shogun-bg border border-shogun-border cursor-pointer hover:border-shogun-gold/20 transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!K.outlook?.allow_external_recipients,onChange:()=>gt(`outlook.allow_external_recipients`,!K.outlook?.allow_external_recipients),className:`mt-0.5 accent-[#d4a017]`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm text-shogun-text font-medium`,children:`Allow external recipients`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:`Send to domains outside the allowlist`})]})]})]})]}),!tt&&!K&&(0,G.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,G.jsx)(N,{className:`w-6 h-6 text-shogun-gold animate-spin`})})]})]}),t===`mado`&&(0,G.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,G.jsx)(Ze,{})}),t===`ide`&&(0,G.jsx)(_t,{}),t===`ronin`&&(0,G.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,G.jsx)(dt,{})}),t===`skillopt`&&(0,G.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,G.jsx)(Mt,{})})]})]})}export{qt as Katana}; \ No newline at end of file diff --git a/frontend/dist/assets/Katana-BoppinC0.js b/frontend/dist/assets/Katana-BoppinC0.js new file mode 100644 index 0000000..bdb706e --- /dev/null +++ b/frontend/dist/assets/Katana-BoppinC0.js @@ -0,0 +1,3 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./app-window-BFcF7ht7.js";import{t as n}from"./arrow-right-left-B7B694Vj.js";import{t as r}from"./brain-circuit-BYgtGbs2.js";import{t as i}from"./check-DnxCktpz.js";import{t as a}from"./chevron-down-qQcy55Tl.js";import{t as o}from"./chevron-left-CoAjCl9c.js";import{t as s}from"./chevron-right-CVeYaFvJ.js";import{t as c}from"./chevron-up-BQBhWwJ7.js";import{t as l}from"./circle-alert-043xB2li.js";import{t as u}from"./circle-check-big-D8GMFSsk.js";import{t as d}from"./circle-check-DBu5bzEI.js";import{t as f}from"./circle-x-Dv8yz1YS.js";import{t as p}from"./code-xml-DLPBFEaQ.js";import{t as m}from"./copy-BVi6zu1A.js";import{t as h}from"./cpu-BM3hm7mB.js";import{t as g}from"./crosshair-B6y1p9rN.js";import{t as _}from"./external-link-pPtmvETu.js";import{t as v}from"./eye-jI9oiQpv.js";import{t as y}from"./file-spreadsheet-ikcYZmJa.js";import{t as ee}from"./file-text-CrD-Um8r.js";import{t as b}from"./folder-open-CZ39dYm6.js";import{n as te,t as x}from"./image-2kgiS9WC.js";import{t as S}from"./git-branch-qj-Uwi0O.js";import{t as C}from"./git-merge-1UmnhoFd.js";import{t as w}from"./layers-PPVhckft.js";import{t as ne}from"./link-2-CJnpoC8q.js";import{t as T}from"./lock-CGEyUK_n.js";import{t as E}from"./mail-Ca9FQxut.js";import{t as D}from"./monitor-DrwnCrGM.js";import{t as re}from"./mouse-pointer-2-CgDYWfSe.js";import{t as ie}from"./pause-B7kChltd.js";import{n as ae,t as O}from"./route-B34TZTak.js";import{t as oe}from"./plus-Cxx0HjpF.js";import{t as se}from"./power-Bl6a5geq.js";import{t as k}from"./refresh-cw-Dm6S5UAJ.js";import{t as A}from"./rotate-ccw-B4t0zm9t.js";import{t as j}from"./save-CupVJLfi.js";import{t as ce}from"./search-DuRUeriq.js";import{t as le}from"./send-BcKLBpfZ.js";import{t as ue}from"./server-CVvUGKOH.js";import{t as de}from"./shield-alert-DzWPVhkC.js";import{t as fe}from"./skull-C4tVbB42.js";import{t as pe}from"./sliders-horizontal-C0TTejMz.js";import{t as me}from"./sparkles-DyLIKWW0.js";import{t as he}from"./star-DhgMUt17.js";import{t as ge}from"./target-BgDPVmAm.js";import{t as _e}from"./trash-2-DqRUHXwV.js";import{t as ve}from"./wifi-off-DW4KpTMj.js";import{t as ye}from"./wifi-nqq7raTh.js";import{t as be}from"./wrench-CKx75ad1.js";import{t as xe}from"./zap-CQy--vuS.js";import{O as Se,T as M,a as Ce,b as we,c as N,d as P,g as F,i as I,j as Te,m as Ee,o as De,r as L,t as Oe,u as ke,w as Ae,y as je}from"./index-Dy1E248t.js";import{t as R}from"./axios-BGmZl9Qd.js";var Me=M(`beaker`,[[`path`,{d:`M4.5 3h15`,key:`c7n0jr`}],[`path`,{d:`M6 3v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V3`,key:`m1uhx7`}],[`path`,{d:`M6 14h12`,key:`4cwo0f`}]]),Ne=M(`cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),Pe=M(`dog`,[[`path`,{d:`M11.25 16.25h1.5L12 17z`,key:`w7jh35`}],[`path`,{d:`M16 14v.5`,key:`1lajdz`}],[`path`,{d:`M4.42 11.247A13.152 13.152 0 0 0 4 14.556C4 18.728 7.582 21 12 21s8-2.272 8-6.444a11.702 11.702 0 0 0-.493-3.309`,key:`u7s9ue`}],[`path`,{d:`M8 14v.5`,key:`1nzgdb`}],[`path`,{d:`M8.5 8.5c-.384 1.05-1.083 2.028-2.344 2.5-1.931.722-3.576-.297-3.656-1-.113-.994 1.177-6.53 4-7 1.923-.321 3.651.845 3.651 2.235A7.497 7.497 0 0 1 14 5.277c0-1.39 1.844-2.598 3.767-2.277 2.823.47 4.113 6.006 4 7-.08.703-1.725 1.722-3.656 1-1.261-.472-1.855-1.45-2.239-2.5`,key:`v8hric`}]]),Fe=M(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Ie=M(`file-check-corner`,[[`path`,{d:`M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6`,key:`g5mvt7`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14 20 2 2 4-4`,key:`15kota`}]]),Le=M(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),Re=M(`file-search`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]),ze=M(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),z=M(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Be=M(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),B=M(`laptop`,[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]),V=M(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),H=M(`message-circle`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}]]),U=M(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),Ve=M(`puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),He=M(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Ue=M(`star-off`,[[`path`,{d:`m10.344 4.688 1.181-2.393a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.237 3.152`,key:`19ctli`}],[`path`,{d:`m17.945 17.945.43 2.505a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a8 8 0 0 0 .4-.099`,key:`ptqqvy`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),We=M(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),W=e(Te(),1),G=Oe(),Ge=[`help`,`status`,`agents`,`workflows`,`approvals`,`ask`,`run`,`pause`,`resume`,`summarize`,`logs`,`approve`,`reject`,`harakiri`],Ke={enabled:!1,deployment_mode:`dev`,tenant_mode:`single`,allowed_tenant_ids:[],bot_app_id:``,bot_name:`Shogun`,client_secret_ref:``,public_messaging_endpoint:``,valid_domains:[],graph_enabled:!1,proactive_enabled:!1,sso_enabled:!1,allowed_commands:Ge,allowed_channels:[],destructive_commands_enabled:!1,dual_approval_fleet:!0,approval_ttl_seconds:900};function qe({value:e,onChange:t,label:n,hint:r}){return(0,G.jsxs)(`button`,{type:`button`,onClick:()=>t(!e),className:`w-full flex items-center justify-between gap-4 text-left`,children:[(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`span`,{className:`block text-sm font-bold text-shogun-text`,children:n}),r&&(0,G.jsx)(`span`,{className:`block text-[10px] text-shogun-subdued mt-0.5`,children:r})]}),(0,G.jsx)(`span`,{className:I(`relative w-10 h-5 rounded-full border transition-all shrink-0`,e?`bg-shogun-blue border-shogun-blue`:`bg-[#050508] border-shogun-border`),children:(0,G.jsx)(`span`,{className:I(`absolute top-0.5 w-3.5 h-3.5 rounded-full bg-white transition-all`,e?`left-5`:`left-0.5`)})})]})}function Je(){let[e,t]=(0,W.useState)(`overview`),[n,r]=(0,W.useState)(Ke),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)([]),[c,l]=(0,W.useState)([]),[u,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(!1),[h,g]=(0,W.useState)(null),[_,v]=(0,W.useState)(null),y=async()=>{f(!0);try{let[e,t]=await Promise.all([R.get(`/api/v1/katana/teams/config`),R.get(`/api/v1/katana/teams/health`)]);r({...Ke,...e.data.data||{}}),a(t.data.data)}catch{g({ok:!1,text:`Could not load the Teams adapter configuration.`})}finally{f(!1)}};(0,W.useEffect)(()=>{y()},[]),(0,W.useEffect)(()=>{e===`identity`&&R.get(`/api/v1/katana/teams/users`).then(e=>s(e.data.data||[])),e===`audit`&&R.get(`/api/v1/katana/teams/commands`).then(e=>l(e.data.data||[]))},[e]);let ee=async()=>{m(!0);try{let e={...Ke,...n};[`id`,`created_at`,`updated_at`,`last_inbound_at`,`last_outbound_at`,`last_error`].forEach(t=>delete e[t]);let t=await R.put(`/api/v1/katana/teams/config`,e);r(t.data.data),g({ok:!0,text:`Microsoft Teams configuration saved.`})}catch(e){g({ok:!1,text:e.response?.data?.detail?.[0]?.msg||`Configuration could not be saved.`})}finally{m(!1),setTimeout(()=>g(null),4e3)}},b=async e=>{try{await R.post(`/api/v1/katana/teams/${e?`enable`:`disable`}`),r(t=>({...t,enabled:e})),await y()}catch{g({ok:!1,text:`Adapter state could not be changed.`})}},te=async(e,t)=>{try{let n=await R({url:`/api/v1/katana/teams/${e}`,method:e.includes(`download`)?`GET`:`POST`,responseType:`blob`}),r=URL.createObjectURL(n.data),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)}catch{g({ok:!1,text:`The requested package could not be generated.`})}},x=`w-full bg-[#050508] border border-shogun-border rounded-lg px-3 py-2.5 text-sm text-shogun-text focus:border-shogun-blue outline-none`,S=`text-[10px] font-bold uppercase tracking-widest text-shogun-subdued`,C=[{id:`overview`,name:`Overview`,icon:Ae},{id:`setup`,name:`Setup Wizard`,icon:be},{id:`identity`,name:`Entra & Roles`,icon:De},{id:`security`,name:`Security Policy`,icon:P},{id:`audit`,name:`Audit Log`,icon:Ie},{id:`diagnostics`,name:`Diagnostics`,icon:k}];return u?(0,G.jsx)(`div`,{className:`py-24 flex justify-center`,children:(0,G.jsx)(F,{className:`w-7 h-7 text-shogun-blue animate-spin`})}):(0,G.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(Ee,{className:`w-5 h-5 text-[#7B83EB]`}),` Microsoft Teams Adapter`]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Enterprise command channel governed by Katana and Gensui.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`span`,{className:I(`px-3 py-1.5 rounded-lg border text-[10px] font-bold uppercase tracking-widest`,i?.status===`healthy`?`bg-green-400/10 border-green-400/30 text-green-400`:`bg-amber-400/10 border-amber-400/30 text-amber-400`),children:i?.status===`healthy`?`Production ready`:n.enabled?`Needs attention`:`Disabled`}),(0,G.jsx)(`button`,{onClick:()=>b(!n.enabled),className:I(`px-4 py-2 rounded-lg text-xs font-bold border`,n.enabled?`border-red-400/30 text-red-400`:`border-green-400/30 text-green-400`),children:n.enabled?`Disable adapter`:`Enable adapter`})]})]}),h&&(0,G.jsxs)(`div`,{className:I(`p-3 rounded-lg border text-sm flex items-center gap-2`,h.ok?`bg-green-400/10 border-green-400/20 text-green-400`:`bg-red-400/10 border-red-400/20 text-red-400`),children:[h.ok?(0,G.jsx)(d,{className:`w-4 h-4`}):(0,G.jsx)(N,{className:`w-4 h-4`}),h.text]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[220px_1fr] gap-5`,children:[(0,G.jsx)(`div`,{className:`shogun-card p-2 h-fit`,children:C.map(({id:n,name:r,icon:i})=>(0,G.jsxs)(`button`,{onClick:()=>t(n),className:I(`w-full flex items-center gap-2.5 px-3 py-2.5 rounded-lg text-xs font-bold`,e===n?`bg-shogun-blue/15 text-shogun-blue`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,G.jsx)(i,{className:`w-4 h-4`}),r]},n))}),(0,G.jsxs)(`div`,{className:`space-y-5`,children:[e===`overview`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[[`Adapter`,n.enabled?`Enabled`:`Disabled`],[`Tenant`,i?.tenant_status||`Unknown`],[`SSO`,i?.sso_status||`Disabled`],[`Approvals`,String(i?.active_approvals??0)]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsx)(`p`,{className:S,children:e}),(0,G.jsx)(`p`,{className:`text-lg font-bold text-shogun-text mt-2 capitalize`,children:t})]},e))}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-sm text-shogun-text`,children:`Connection health`}),(i?.issues||[]).length?i.issues.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-amber-400`,children:[(0,G.jsx)(N,{className:`w-3.5 h-3.5`}),e]},e)):(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-green-400`,children:[(0,G.jsx)(d,{className:`w-4 h-4`}),`Configuration checks passed.`]})]})]}),e===`setup`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`1. Deployment and tenant`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`A customer-hosted bridge is recommended for production.`})]}),(0,G.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Deployment mode`}),(0,G.jsxs)(`select`,{value:n.deployment_mode,onChange:e=>r({...n,deployment_mode:e.target.value}),className:I(x,`mt-1.5`),children:[(0,G.jsx)(`option`,{value:`dev`,children:`Local development + tunnel`}),(0,G.jsx)(`option`,{value:`bridge`,children:`Customer-hosted Teams Bridge`}),(0,G.jsx)(`option`,{value:`direct`,children:`Direct Shogun callback`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Tenant mode`}),(0,G.jsxs)(`select`,{value:n.tenant_mode,onChange:e=>r({...n,tenant_mode:e.target.value}),className:I(x,`mt-1.5`),children:[(0,G.jsx)(`option`,{value:`single`,children:`Single tenant`}),(0,G.jsx)(`option`,{value:`multi`,children:`Multi tenant`})]})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Allowed tenant IDs (one per line)`}),(0,G.jsx)(`textarea`,{value:(n.allowed_tenant_ids||[]).join(` +`),onChange:e=>r({...n,allowed_tenant_ids:e.target.value.split(/\s+/).filter(Boolean)}),rows:3,className:I(x,`mt-1.5 font-mono`)})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`2. Bot and public endpoint`}),(0,G.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Bot / App ID`}),(0,G.jsx)(`input`,{value:n.bot_app_id||``,onChange:e=>r({...n,bot_app_id:e.target.value}),className:I(x,`mt-1.5 font-mono`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Bot display name`}),(0,G.jsx)(`input`,{value:n.bot_name||``,onChange:e=>r({...n,bot_name:e.target.value}),className:I(x,`mt-1.5`)})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Client secret / certificate reference`}),(0,G.jsx)(`input`,{value:n.client_secret_ref||``,onChange:e=>r({...n,client_secret_ref:e.target.value}),className:I(x,`mt-1.5 font-mono`),placeholder:`vault://teams/bot-client-secret`}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-1`,children:`Only a secret reference is stored. Never paste the secret value here.`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Public messaging endpoint`}),(0,G.jsx)(`input`,{value:n.public_messaging_endpoint||``,onChange:e=>r({...n,public_messaging_endpoint:e.target.value}),className:I(x,`mt-1.5 font-mono`),placeholder:`https://teams-bridge.example.com/api/teams/messages`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Valid domains (comma separated)`}),(0,G.jsx)(`input`,{value:(n.valid_domains||[]).join(`, `),onChange:e=>r({...n,valid_domains:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),className:I(x,`mt-1.5 font-mono`)})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card flex flex-wrap gap-3`,children:[(0,G.jsxs)(`button`,{onClick:ee,disabled:p,className:`px-4 py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold flex items-center gap-2`,children:[p?(0,G.jsx)(F,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(j,{className:`w-4 h-4`}),`Save configuration`]}),(0,G.jsxs)(`button`,{onClick:()=>te(`manifest/download`,`shogun-teams-app.zip`),className:`px-4 py-2.5 border border-shogun-border rounded-lg text-xs font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(we,{className:`w-4 h-4`}),`Generate Teams app package`]})]})]}),e===`identity`&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsxs)(`div`,{className:`grid md:grid-cols-3 gap-5 pb-4 border-b border-shogun-border`,children:[(0,G.jsx)(qe,{label:`Microsoft Entra SSO`,hint:`Required for production identity assurance.`,value:n.sso_enabled,onChange:e=>r({...n,sso_enabled:e})}),(0,G.jsx)(qe,{label:`Microsoft Graph`,hint:`Tenant app operations.`,value:n.graph_enabled,onChange:e=>r({...n,graph_enabled:e})}),(0,G.jsx)(qe,{label:`Proactive messaging`,hint:`Installed conversations only.`,value:n.proactive_enabled,onChange:e=>r({...n,proactive_enabled:e})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`Teams user mappings`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`New identities enter as Viewer until deliberately promoted.`})]}),(0,G.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-left text-shogun-subdued border-b border-shogun-border`,children:[(0,G.jsx)(`th`,{className:`py-2`,children:`User`}),(0,G.jsx)(`th`,{children:`UPN`}),(0,G.jsx)(`th`,{children:`Tenant`}),(0,G.jsx)(`th`,{children:`Role`})]})}),(0,G.jsx)(`tbody`,{children:o.map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`py-3 text-shogun-text font-bold`,children:e.display_name}),(0,G.jsx)(`td`,{children:e.user_principal_name||`—`}),(0,G.jsx)(`td`,{className:`font-mono`,children:e.tenant_id}),(0,G.jsx)(`td`,{className:`capitalize`,children:e.shogun_role.replace(`_`,` `)})]},e.id))})]}),!o.length&&(0,G.jsx)(`p`,{className:`text-center py-10 text-shogun-subdued italic`,children:`No Teams identities observed yet.`})]}),(0,G.jsxs)(`button`,{onClick:ee,className:`px-4 py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold flex items-center gap-2`,children:[(0,G.jsx)(j,{className:`w-4 h-4`}),`Save identity settings`]})]}),e===`security`&&(0,G.jsxs)(`div`,{className:`space-y-5`,children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`Command policy`}),(0,G.jsx)(`div`,{className:`grid sm:grid-cols-2 lg:grid-cols-3 gap-2`,children:Ge.map(e=>{let t=n.allowed_commands?.includes(e);return(0,G.jsxs)(`button`,{onClick:()=>r({...n,allowed_commands:t?n.allowed_commands.filter(t=>t!==e):[...n.allowed_commands,e]}),className:I(`px-3 py-2 rounded-lg border text-xs text-left capitalize`,t?`border-shogun-blue/30 bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued`),children:[e,(0,G.jsx)(`span`,{className:`float-right`,children:[`harakiri`,`pause`,`resume`].includes(e)?`L4`:[`approve`,`reject`].includes(e)?`L3`:`L0–L2`})]},e)})})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(qe,{label:`Allow destructive commands to enter approval flow`,hint:`This never bypasses Gensui confirmation.`,value:n.destructive_commands_enabled,onChange:e=>r({...n,destructive_commands_enabled:e})}),(0,G.jsx)(qe,{label:`Dual approval for fleet shutdown`,value:n.dual_approval_fleet,onChange:e=>r({...n,dual_approval_fleet:e})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:S,children:`Approval expiry (seconds)`}),(0,G.jsx)(`input`,{type:`number`,min:60,max:86400,value:n.approval_ttl_seconds,onChange:e=>r({...n,approval_ttl_seconds:Number(e.target.value)}),className:I(x,`mt-1.5 max-w-xs`)})]}),(0,G.jsx)(`div`,{className:`p-3 rounded-lg border border-amber-400/20 bg-amber-400/5 text-xs text-amber-300`,children:`Attachments are rejected by default. High-risk free-form input cannot invoke tools directly.`}),(0,G.jsxs)(`button`,{onClick:ee,className:`px-4 py-2.5 bg-shogun-blue text-white rounded-lg text-xs font-bold flex items-center gap-2`,children:[(0,G.jsx)(j,{className:`w-4 h-4`}),`Save security policy`]})]})]}),e===`audit`&&(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between mb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:`Command audit`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`Authorization decisions and outcomes.`})]}),(0,G.jsxs)(`button`,{onClick:()=>te(`diagnostics/export`,`shogun-teams-diagnostics.json`),className:`text-xs text-shogun-blue flex items-center gap-1`,children:[(0,G.jsx)(we,{className:`w-3.5 h-3.5`}),`Export safe bundle`]})]}),(0,G.jsxs)(`div`,{className:`overflow-x-auto`,children:[(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{children:(0,G.jsxs)(`tr`,{className:`text-left text-shogun-subdued border-b border-shogun-border`,children:[(0,G.jsx)(`th`,{className:`py-2`,children:`Time`}),(0,G.jsx)(`th`,{children:`Command`}),(0,G.jsx)(`th`,{children:`Risk`}),(0,G.jsx)(`th`,{children:`Decision`}),(0,G.jsx)(`th`,{children:`Correlation`})]})}),(0,G.jsx)(`tbody`,{children:c.map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`py-3`,children:new Date(e.created_at).toLocaleString()}),(0,G.jsx)(`td`,{children:e.command_name}),(0,G.jsx)(`td`,{children:e.risk_level}),(0,G.jsx)(`td`,{className:e.success?`text-green-400`:`text-red-400`,children:e.authorization_result}),(0,G.jsxs)(`td`,{className:`font-mono`,children:[e.correlation_id.slice(0,8),`…`]})]},e.id))})]}),!c.length&&(0,G.jsx)(`p`,{className:`text-center py-10 text-shogun-subdued italic`,children:`No Teams commands audited yet.`})]})]}),e===`diagnostics`&&(0,G.jsxs)(`div`,{className:`grid md:grid-cols-2 gap-4`,children:[[[`Shogun backend`,`test/backend`],[`Microsoft Graph credentials`,`test/graph`],[`Proactive messaging`,`test/proactive-message`],[`Teams manifest`,`manifest/validate`]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:e}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1 mb-4`,children:`Run a non-destructive configuration check.`}),(0,G.jsx)(`button`,{onClick:async()=>{try{let n=await R.post(`/api/v1/katana/teams/${t}`);v({name:e,...n.data.data})}catch(t){v({name:e,ok:!1,error:t.message})}},className:`px-3 py-2 border border-shogun-border rounded-lg text-xs font-bold text-shogun-text`,children:`Run test`})]},t)),_&&(0,G.jsxs)(`div`,{className:`md:col-span-2 shogun-card`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold`,children:_.name}),(0,G.jsx)(`pre`,{className:`mt-3 p-3 bg-[#050508] rounded-lg text-[10px] text-shogun-subdued overflow-auto`,children:JSON.stringify(_,null,2)})]})]})]})]})]})}var Ye=`#06b6d4`,Xe=[`Overview`,`Sessions`,`Screenshots`,`Permissions`,`Advanced`];function Ze(){let[e,n]=(0,W.useState)(`Overview`),[r,i]=(0,W.useState)(null),[a,c]=(0,W.useState)([]),[l,u]=(0,W.useState)([]),[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)({}),[v,y]=(0,W.useState)(!1),[ee,b]=(0,W.useState)(!0),[te,S]=(0,W.useState)(!1),[C,w]=(0,W.useState)(null),[ne,T]=(0,W.useState)(null),[E,D]=(0,W.useState)(null),re=(0,W.useMemo)(()=>a.find(e=>e.profile_name===`native_skill`)||null,[a]),O=(0,W.useCallback)(async()=>{try{let[e,t,n]=await Promise.all([R.get(`/api/v1/mado/status`),R.get(`/api/v1/mado/sessions`),R.get(`/api/v1/mado/screenshots`)]);i(e.data?.data||null),m(e.data?.meta?.runtime_sessions||[]),g(e.data?.meta?.config||{}),c(t.data?.data||[]),u(n.data?.data||[])}catch(e){let t=R.isAxiosError(e)?e.response?.data?.detail:``;T({type:`error`,text:t||`Mado status could not be loaded.`})}finally{b(!1)}},[]);(0,W.useEffect)(()=>{O()},[O]);let oe=async()=>{S(!0),T(null);try{let e=(await R.post(`/api/v1/mado/install`)).data?.data;if(!e?.success)throw Error(e?.error||`Chromium installation failed.`);T({type:`success`,text:`Chromium installed. Mado is ready.`}),await O()}catch(e){let t=R.isAxiosError(e)?e.response?.data?.detail:e instanceof Error?e.message:``;T({type:`error`,text:t||`Chromium installation failed.`})}finally{S(!1)}},se=async e=>{w(e.id),T(null);try{await R.delete(`/api/v1/mado/sessions/${e.id}`),T({type:`success`,text:e.profile_name===`native_skill`?`Agent browser reset. Shogun will create a clean session when it browses again.`:`Browser session “${e.name}” removed.`}),await O()}catch(e){let t=R.isAxiosError(e)?e.response?.data?.detail:``;T({type:`error`,text:t||`The browser session could not be reset.`})}finally{w(null)}},j=async(e,t)=>{w(e.id),T(null);try{await R.post(`/api/v1/mado/sessions/${e.id}/${t}`),T({type:`success`,text:`Mado session ${t}d.`}),await O()}catch(e){let n=R.isAxiosError(e)?e.response?.data?.detail:``;T({type:`error`,text:n||`Could not ${t} the Mado session.`})}finally{w(null)}};return ee?(0,G.jsx)(`div`,{className:`flex min-h-[420px] items-center justify-center bg-[#0a0e1a]`,children:(0,G.jsx)(F,{className:`h-8 w-8 animate-spin`,style:{color:Ye}})}):(0,G.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden bg-[#0a0e1a]`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-[#1a2040] px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-xl`,style:{background:`${Ye}12`,border:`1px solid ${Ye}30`},children:(0,G.jsx)(t,{className:`h-5 w-5`,style:{color:Ye}})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-bold tracking-tight text-[#c8d0d8]`,children:`Mado`}),(0,G.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Managed browser runtime`})]})]}),(0,G.jsx)(`button`,{onClick:O,className:`rounded-lg border border-[#1a2040] p-2 text-[#7a8899] transition-colors hover:text-[#c8d0d8]`,title:`Refresh Mado status`,children:(0,G.jsx)(k,{className:`h-4 w-4`})})]}),ne&&(0,G.jsxs)(`div`,{className:I(`flex items-center gap-2 border-b px-6 py-3 text-xs font-semibold`,ne.type===`success`?`border-emerald-500/20 bg-emerald-500/10 text-emerald-300`:`border-red-500/20 bg-red-500/10 text-red-300`),children:[ne.type===`success`?(0,G.jsx)(d,{className:`h-4 w-4 shrink-0`}):(0,G.jsx)(f,{className:`h-4 w-4 shrink-0`}),ne.text]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 border-b border-[#1a2040] px-6 pt-3`,children:Xe.map(t=>(0,G.jsx)(`button`,{onClick:()=>n(t),className:I(`-mb-px border-b-2 px-4 py-2.5 text-[11px] font-bold uppercase tracking-wider transition-colors`,e===t?`border-cyan-500 text-cyan-400`:`border-transparent text-[#7a8899] hover:text-[#c8d0d8]`),children:t},t))}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[p.some(e=>e.status===`active`)&&(0,G.jsxs)(`div`,{className:`mx-auto mb-5 flex max-w-4xl items-center justify-between rounded-xl border border-cyan-400/40 bg-cyan-500/10 px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`span`,{className:`relative flex h-3 w-3`,children:[(0,G.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full bg-cyan-400 opacity-60`}),(0,G.jsx)(`span`,{className:`relative inline-flex h-3 w-3 rounded-full bg-cyan-400`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-bold text-cyan-200`,children:`MADO BROWSER ACTIVE`}),(0,G.jsx)(`p`,{className:`text-[9px] text-cyan-200/60`,children:`Browser actions are visible, verified, recoverable, and audited.`})]})]}),(0,G.jsx)(`button`,{onClick:async()=>{confirm(`Stop every active Mado browser session now? Logs and artifacts will be preserved.`)&&(await R.post(`/api/v1/mado/kill-switch`),T({type:`success`,text:`Mado kill switch stopped all active browser sessions.`}),await O())},className:`rounded-lg border border-red-400/40 bg-red-500/10 px-3 py-2 text-[9px] font-bold uppercase tracking-wider text-red-300 hover:bg-red-500/20`,children:`Stop all sessions`})]}),e===`Overview`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,G.jsx)(Qe,{title:`Browser engine`,value:r?.installed?`Ready`:`Not installed`,detail:r?.version||`Managed Chromium`,healthy:!!r?.installed}),(0,G.jsx)(Qe,{title:`Agent browser`,value:re?re.status:`Starts automatically`,detail:re?.last_url||`Created when Shogun first browses`,healthy:!!(re&&re.status!==`error`)}),(0,G.jsx)(Qe,{title:`Active sessions`,value:String(r?.active_sessions||0),detail:`Limited by the active Torii posture`,healthy:!0})]}),(0,G.jsx)(`div`,{className:`rounded-xl border border-cyan-500/20 bg-cyan-500/[0.06] p-5`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(P,{className:`mt-0.5 h-5 w-5 shrink-0 text-cyan-400`}),(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Permissions belong to Torii`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-[#7a8899]`,children:`Mado does not maintain a second permission system. The active security posture controls whether Shogun may browse, use visible sessions, download or upload files, and how many browser sessions may run.`}),(0,G.jsxs)(`a`,{href:`/torii`,className:`mt-3 inline-flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-wider text-cyan-400 hover:text-cyan-300`,children:[`Open Torii permissions`,(0,G.jsx)(_,{className:`h-3 w-3`})]})]})]})}),!r?.installed&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225] p-5`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Install the browser engine`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-[#7a8899]`,children:`Chromium is the only component Mado needs before Shogun can browse.`}),(0,G.jsxs)(`button`,{onClick:oe,disabled:te,className:`mt-4 inline-flex items-center gap-2 rounded-lg bg-cyan-500 px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#071018] disabled:opacity-50`,children:[te?(0,G.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(we,{className:`h-3.5 w-3.5`}),te?`Installing…`:`Install Chromium`]})]}),re&&(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-[#1a2040] bg-[#0e1225] p-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Agent browser session`}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-[#7a8899]`,children:re.last_url||`No page visited yet`})]}),(0,G.jsxs)(`button`,{onClick:()=>se(re),disabled:C===re.id,className:`ml-4 inline-flex shrink-0 items-center gap-2 rounded-lg border border-[#1a2040] px-3 py-2 text-[10px] font-bold uppercase tracking-wider text-[#7a8899] hover:border-cyan-500/40 hover:text-cyan-400 disabled:opacity-50`,children:[C===re.id?(0,G.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(A,{className:`h-3.5 w-3.5`}),`Reset`]})]})]}),e===`Sessions`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-5xl space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-widest text-[#7a8899]`,children:`Live browser sessions`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-[#555]`,children:`Runtime state, Stack association, verification, errors, and recent trajectory.`})]}),a.length===0?(0,G.jsx)(`div`,{className:`rounded-xl border border-[#1a2040] p-10 text-center text-xs text-[#7a8899]`,children:`No Mado sessions.`}):a.map(e=>{let t=p.find(t=>t.session_id===e.id),n=t?.timeline||e.session_data?.action_history||[];return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-[#1a2040] bg-[#0e1225]`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between border-b border-[#1a2040] p-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:I(`h-2 w-2 rounded-full`,(t?.status||e.status)===`active`?`bg-emerald-400`:(t?.status||e.status)===`error`?`bg-red-400`:`bg-amber-400`)}),(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8]`,children:e.name}),(0,G.jsx)(`span`,{className:`rounded bg-cyan-500/10 px-1.5 py-0.5 text-[8px] uppercase text-cyan-300`,children:t?.mode||e.browser_mode})]}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-[10px] text-[#7a8899]`,children:t?.title||t?.current_url||e.last_url||`No page loaded`}),(0,G.jsxs)(`p`,{className:`mt-1 text-[8px] text-[#555]`,children:[`Profile `,t?.profile_id||e.profile_name,` · Posture `,t?.posture||e.session_data?.posture||`current`,` · Stack `,t?.stack_run_id||e.session_data?.stack_run_id||`standalone`]})]}),(0,G.jsxs)(`div`,{className:`ml-4 flex gap-1`,children:[(t?.status||e.status)===`paused`?(0,G.jsx)(`button`,{title:`Resume`,onClick:()=>j(e,`resume`),className:`rounded p-2 text-emerald-400 hover:bg-emerald-500/10`,children:(0,G.jsx)(ae,{className:`h-4 w-4`})}):(0,G.jsx)(`button`,{title:`Pause`,onClick:()=>j(e,`pause`),className:`rounded p-2 text-amber-400 hover:bg-amber-500/10`,children:(0,G.jsx)(ie,{className:`h-4 w-4`})}),(0,G.jsx)(`button`,{title:`Close`,onClick:()=>j(e,`close`),className:`rounded p-2 text-red-400 hover:bg-red-500/10`,children:(0,G.jsx)(Ce,{className:`h-4 w-4`})})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-3 p-4 md:grid-cols-4`,children:[(0,G.jsx)($e,{label:`Last action`,value:t?.last_action||e.session_data?.last_action||`None`}),(0,G.jsx)($e,{label:`Verification`,value:t?.last_verification?.status||e.session_data?.last_verification?.status||`Pending`}),(0,G.jsx)($e,{label:`Retries`,value:String(t?.retry_count||0)}),(0,G.jsx)($e,{label:`Status`,value:t?.last_error||e.session_data?.last_error||t?.status||e.status,danger:!!(t?.last_error||e.session_data?.last_error)})]}),n.length>0&&(0,G.jsxs)(`div`,{className:`border-t border-[#1a2040] p-4`,children:[(0,G.jsx)(`p`,{className:`mb-2 text-[8px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Recent execution trajectory`}),(0,G.jsx)(`div`,{className:`max-h-40 space-y-1 overflow-y-auto`,children:n.slice(-8).reverse().map((e,t)=>(0,G.jsxs)(`div`,{className:`flex gap-3 rounded bg-[#080b15] px-2 py-1.5 text-[9px]`,children:[(0,G.jsx)(`span`,{className:`w-16 shrink-0 text-[#555]`,children:e.timestamp?new Date(e.timestamp).toLocaleTimeString():``}),(0,G.jsx)(`span`,{className:`w-44 shrink-0 text-cyan-400`,children:e.event_type||e.action}),(0,G.jsx)(`span`,{className:`truncate text-[#7a8899]`,children:e.message||e.status||e.error})]},`${e.timestamp}-${t}`))})]})]},e.id)})]}),e===`Screenshots`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-widest text-[#7a8899]`,children:`Captured screenshots`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-[#555]`,children:`Evidence captured by Shogun and AgentFlow browser tasks`})]}),(0,G.jsx)(`button`,{onClick:O,className:`rounded-lg p-2 text-[#7a8899] hover:bg-[#1a2040] hover:text-[#c8d0d8]`,children:(0,G.jsx)(k,{className:`h-3.5 w-3.5`})})]}),l.length===0?(0,G.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,G.jsx)(x,{className:`mx-auto h-10 w-10 text-cyan-500/30`}),(0,G.jsx)(`p`,{className:`mt-3 text-sm text-[#7a8899]`,children:`No screenshots yet`})]}):(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4`,children:l.map((e,t)=>(0,G.jsxs)(`button`,{onClick:()=>D(t),className:`group overflow-hidden rounded-xl border border-[#1a2040] bg-[#0e1225] text-left hover:border-cyan-500/40`,children:[(0,G.jsxs)(`div`,{className:`relative aspect-video overflow-hidden bg-[#080b15]`,children:[(0,G.jsx)(`img`,{src:`/mado/screenshots/${e.filename}`,alt:e.filename,className:`h-full w-full object-cover opacity-80 transition-all group-hover:scale-105 group-hover:opacity-100`}),(0,G.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/30`,children:(0,G.jsx)(V,{className:`h-5 w-5 text-white opacity-0 transition-opacity group-hover:opacity-100`})})]}),(0,G.jsxs)(`div`,{className:`p-3`,children:[(0,G.jsx)(`p`,{className:`truncate text-[10px] font-bold text-[#c8d0d8]`,children:e.filename}),(0,G.jsxs)(`p`,{className:`mt-1 text-[8px] text-[#555]`,children:[(e.size_bytes/1024).toFixed(1),` KB`]})]})]},e.filename))})]}),e===`Permissions`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-5`,children:[(0,G.jsx)(`div`,{className:`rounded-xl border border-amber-400/25 bg-amber-500/[0.06] p-4`,children:(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(de,{className:`h-5 w-5 shrink-0 text-amber-400`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-bold text-amber-200`,children:`Mado Browser permissions`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-[#7a8899]`,children:`These settings narrow the active Torii posture. They never grant capabilities that the posture blocks. Authenticated profiles and external URLs remain opt-in.`})]})]})}),(0,G.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[[[`enabled`,`Enable Mado`,`Allow governed browser sessions`],[`headless_allowed`,`Allow headless mode`,`Run managed browser sessions without a window`],[`visible_allowed`,`Allow visible mode`,`Show Chromium while Mado operates`],[`allow_external_urls`,`Allow external URLs`,`Permit URLs outside the configured domain list`],[`allow_persistent_profiles`,`Allow persistent profiles`,`Keep local browser state between sessions`],[`allow_authenticated_sessions`,`Allow authenticated sessions`,`Use profiles that may contain saved login state`],[`require_verification`,`Require verification`,`Verify key browser outcomes before completion`]].map(([e,t,n])=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-bold text-[#c8d0d8]`,children:t}),(0,G.jsx)(`p`,{className:`mt-1 text-[9px] text-[#555]`,children:n})]}),(0,G.jsx)(`input`,{type:`checkbox`,checked:!!h[e],onChange:t=>g(n=>({...n,[e]:t.target.checked})),className:`h-4 w-4 accent-cyan-500`})]},e)),(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-between rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-xs font-bold text-[#c8d0d8]`,children:`Capture evidence screenshots`}),(0,G.jsx)(`p`,{className:`mt-1 text-[9px] text-[#555]`,children:`Save visual evidence on errors and verification`})]}),(0,G.jsx)(`input`,{type:`checkbox`,checked:!!(h.audit?.capture_screenshots_on_error&&h.audit?.capture_screenshots_on_verification),onChange:e=>g(t=>({...t,audit:{...t.audit||{},capture_screenshots_on_error:e.target.checked,capture_screenshots_on_verification:e.target.checked,log_all_actions:!0}})),className:`h-4 w-4 accent-cyan-500`})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-4 rounded-xl border border-[#1a2040] bg-[#0e1225] p-4 md:grid-cols-2`,children:[(0,G.jsx)(et,{label:`Allowed domains`,value:(h.allowed_domains||[]).join(`, `),onChange:e=>g(t=>({...t,allowed_domains:e.split(`,`).map(e=>e.trim()).filter(Boolean)}))}),(0,G.jsx)(et,{label:`Blocked domains`,value:(h.blocked_domains||[]).join(`, `),onChange:e=>g(t=>({...t,blocked_domains:e.split(`,`).map(e=>e.trim()).filter(Boolean)}))}),(0,G.jsx)(nt,{label:`Default browser mode`,value:h.default_mode||`visible`,options:[`visible`,`headless`],onChange:e=>g(t=>({...t,default_mode:e}))}),(0,G.jsx)(nt,{label:`File downloads`,value:h.allow_file_downloads||`approval`,options:[`blocked`,`approval`,`allowed`],onChange:e=>g(t=>({...t,allow_file_downloads:e}))}),(0,G.jsx)(nt,{label:`File uploads`,value:h.allow_file_uploads||`approval`,options:[`blocked`,`approval`,`allowed`],onChange:e=>g(t=>({...t,allow_file_uploads:e}))}),(0,G.jsx)(nt,{label:`Form submission`,value:h.allow_form_submit||`approval`,options:[`blocked`,`approval`,`allowed`],onChange:e=>g(t=>({...t,allow_form_submit:e}))}),(0,G.jsx)(tt,{label:`Maximum pages per run`,value:h.max_pages_per_run||50,onChange:e=>g(t=>({...t,max_pages_per_run:e}))}),(0,G.jsx)(tt,{label:`Maximum runtime (seconds)`,value:h.max_runtime_seconds||1800,onChange:e=>g(t=>({...t,max_runtime_seconds:e}))})]}),(0,G.jsxs)(`button`,{onClick:async()=>{y(!0);try{let e=Object.fromEntries([`enabled`,`default_mode`,`headless_allowed`,`visible_allowed`,`allowed_domains`,`blocked_domains`,`allow_external_urls`,`allow_persistent_profiles`,`allow_authenticated_sessions`,`allow_file_downloads`,`allow_file_uploads`,`allow_form_submit`,`require_verification`,`max_pages_per_run`,`max_runtime_seconds`,`default_navigation_timeout_ms`,`default_action_timeout_ms`,`retry`,`page_readiness`,`audit`].filter(e=>e in h).map(e=>[e,h[e]])),t=await R.patch(`/api/v1/mado/config`,e);g(t.data?.data||h),T({type:`success`,text:`Mado permissions and reliability settings saved.`})}catch(e){let t=R.isAxiosError(e)?e.response?.data?.detail:``;T({type:`error`,text:t||`Mado settings could not be saved.`})}finally{y(!1)}},disabled:v,className:`inline-flex items-center gap-2 rounded-lg bg-cyan-500 px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#071018] disabled:opacity-50`,children:[v?(0,G.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(P,{className:`h-4 w-4`}),` Save Mado settings`]})]}),e===`Advanced`&&(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-widest text-[#7a8899]`,children:`Advanced diagnostics`}),(0,G.jsx)(`p`,{className:`mt-1 text-[10px] text-[#555]`,children:`Runtime details for troubleshooting. Browser permissions remain in Torii.`})]}),(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225]`,children:[(0,G.jsx)(`div`,{className:`border-b border-[#1a2040] px-4 py-3 text-xs font-bold text-[#c8d0d8]`,children:`Runtime sessions`}),a.length===0?(0,G.jsx)(`p`,{className:`p-5 text-xs text-[#7a8899]`,children:`No browser sessions have been created.`}):a.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-[#1a2040]/70 px-4 py-3 last:border-0`,children:[(0,G.jsx)(`div`,{className:I(`h-2 w-2 shrink-0 rounded-full`,e.status===`active`?`bg-emerald-400`:e.status===`error`?`bg-red-400`:`bg-[#7a8899]`)}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold text-[#c8d0d8]`,children:e.name}),e.profile_name===`native_skill`&&(0,G.jsx)(`span`,{className:`rounded bg-cyan-500/10 px-1.5 py-0.5 text-[8px] font-bold uppercase text-cyan-400`,children:`Agent managed`})]}),(0,G.jsxs)(`p`,{className:`mt-0.5 truncate text-[9px] text-[#555]`,children:[e.profile_name,` · `,e.browser_mode,` · `,e.last_url||`No URL`]})]}),(0,G.jsx)(`button`,{onClick:()=>se(e),disabled:C===e.id,title:`Remove browser session`,className:`rounded-lg p-2 text-[#7a8899] hover:bg-red-500/10 hover:text-red-400 disabled:opacity-50`,children:C===e.id?(0,G.jsx)(F,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(_e,{className:`h-3.5 w-3.5`})})]},e.id))]}),r&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8]`,children:`Storage paths`}),(0,G.jsx)(`div`,{className:`mt-3 space-y-2`,children:[[`Profiles`,r.profiles_path],[`Screenshots`,r.screenshots_path],[`Downloads`,r.downloads_path]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex gap-4 text-[10px]`,children:[(0,G.jsx)(`span`,{className:`w-24 shrink-0 font-bold uppercase tracking-wider text-[#7a8899]`,children:e}),(0,G.jsx)(`span`,{className:`min-w-0 break-all font-mono text-[#555]`,children:t})]},e))})]})]})]}),E!==null&&l[E]&&(0,G.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/85 backdrop-blur-sm`,onClick:()=>D(null),children:[(0,G.jsx)(`button`,{onClick:()=>D(null),className:`absolute right-4 top-4 rounded-full bg-black/50 p-2 text-white/80 hover:text-white`,children:(0,G.jsx)(Ce,{className:`h-5 w-5`})}),E>0&&(0,G.jsx)(`button`,{onClick:e=>{e.stopPropagation(),D(E-1)},className:`absolute left-4 rounded-full bg-black/50 p-2 text-white/80 hover:text-white`,children:(0,G.jsx)(o,{className:`h-6 w-6`})}),E{e.stopPropagation(),D(E+1)},className:`absolute right-4 rounded-full bg-black/50 p-2 text-white/80 hover:text-white`,children:(0,G.jsx)(s,{className:`h-6 w-6`})}),(0,G.jsx)(`img`,{src:`/mado/screenshots/${l[E].filename}`,alt:l[E].filename,className:`max-h-[85vh] max-w-[90vw] rounded-lg object-contain shadow-2xl`,onClick:e=>e.stopPropagation()})]})]})}function Qe({title:e,value:t,detail:n,healthy:r}){return(0,G.jsxs)(`div`,{className:`rounded-xl border border-[#1a2040] bg-[#0e1225] p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:I(`h-2 w-2 rounded-full`,r?`bg-emerald-400`:`bg-amber-400`)}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-[#7a8899]`,children:e})]}),(0,G.jsx)(`p`,{className:`mt-3 truncate text-sm font-bold capitalize text-[#c8d0d8]`,children:t}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-[9px] text-[#555]`,children:n})]})}function $e({label:e,value:t,danger:n=!1}){return(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#080b15] p-3`,children:[(0,G.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-widest text-[#555]`,children:e}),(0,G.jsx)(`p`,{className:I(`mt-2 truncate text-[10px] font-semibold`,n?`text-red-300`:`text-[#c8d0d8]`),children:t})]})}function et({label:e,value:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`text-[9px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[e,(0,G.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),placeholder:`example.com, portal.example.com`,className:`mt-2 w-full rounded-lg border border-[#1a2040] bg-[#080b15] px-3 py-2 text-xs font-normal normal-case text-[#c8d0d8] outline-none focus:border-cyan-500/50`})]})}function tt({label:e,value:t,onChange:n}){return(0,G.jsxs)(`label`,{className:`text-[9px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[e,(0,G.jsx)(`input`,{type:`number`,min:1,value:t,onChange:e=>n(Math.max(1,Number(e.target.value))),className:`mt-2 w-full rounded-lg border border-[#1a2040] bg-[#080b15] px-3 py-2 text-xs font-normal text-[#c8d0d8] outline-none focus:border-cyan-500/50`})]})}function nt({label:e,value:t,options:n,onChange:r}){return(0,G.jsxs)(`label`,{className:`text-[9px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[e,(0,G.jsx)(`select`,{value:t,onChange:e=>r(e.target.value),className:`mt-2 w-full rounded-lg border border-[#1a2040] bg-[#080b15] px-3 py-2 text-xs font-normal capitalize text-[#c8d0d8] outline-none focus:border-cyan-500/50`,children:n.map(e=>(0,G.jsx)(`option`,{value:e,children:e.replaceAll(`_`,` `)},e))})]})}var K=`#f97316`,rt=`#f9731620`,it=`#f9731640`,at=[`Control`,`Sessions`,`App Trust`,`Capabilities`,`Audit Trail`],ot={idle:{bg:`rgba(249,115,22,0.08)`,text:`#f97316`,dot:`#f97316`},active:{bg:`rgba(34,197,94,0.08)`,text:`#22c55e`,dot:`#22c55e`},paused:{bg:`rgba(234,179,8,0.08)`,text:`#eab308`,dot:`#eab308`},error:{bg:`rgba(239,68,68,0.08)`,text:`#ef4444`,dot:`#ef4444`},closed:{bg:`rgba(122,136,153,0.08)`,text:`#7a8899`,dot:`#7a8899`}},st={trusted:{bg:`rgba(34,197,94,0.10)`,text:`#22c55e`,label:`TRUSTED`},restricted:{bg:`rgba(234,179,8,0.10)`,text:`#eab308`,label:`RESTRICTED`},sensitive:{bg:`rgba(249,115,22,0.10)`,text:`#f97316`,label:`SENSITIVE`},forbidden:{bg:`rgba(239,68,68,0.10)`,text:`#ef4444`,label:`FORBIDDEN`}},ct={low:{bg:`rgba(34,197,94,0.10)`,text:`#22c55e`},medium:{bg:`rgba(234,179,8,0.10)`,text:`#eab308`},high:{bg:`rgba(249,115,22,0.10)`,text:`#f97316`},critical:{bg:`rgba(239,68,68,0.10)`,text:`#ef4444`}},lt={physical:B,vm:ue,sandbox:T,remote_desktop:D,citrix:D,cloud_workspace:Ne},ut={1:{label:`PAUSE`,color:`#eab308`,desc:`Pause session on human input`},2:{label:`TERMINATE`,color:`#f97316`,desc:`Kill active session on input`},3:{label:`HARAKIRI`,color:`#ef4444`,desc:`Full emergency stop on input`}};function dt(){let[e,t]=(0,W.useState)(`Control`),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)([]),[o,c]=(0,W.useState)([]),[l,u]=(0,W.useState)([]),[p,m]=(0,W.useState)([]),[h,g]=(0,W.useState)([]),[_,y]=(0,W.useState)(!0),[ee,b]=(0,W.useState)(!1),[te,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(``),[w,ne]=(0,W.useState)(`observe_only`),[E,ie]=(0,W.useState)(1),[O,se]=(0,W.useState)(!1),[A,j]=(0,W.useState)(null),[ce,le]=(0,W.useState)(`desktop.screenshot`),[pe,me]=(0,W.useState)(``),[he,ve]=(0,W.useState)(``),[ye,be]=(0,W.useState)(``),[Se,M]=(0,W.useState)(!1),[Ce,we]=(0,W.useState)(null),[N,Te]=(0,W.useState)(`all`),[Ee,De]=(0,W.useState)(`all`),L=(0,W.useCallback)(async()=>{try{let e=await R.get(`/api/v1/ronin/status`);r(e.data?.data)}catch{}},[]),Oe=(0,W.useCallback)(async()=>{try{let e=await R.get(`/api/v1/ronin/sessions`);a(e.data?.data||[])}catch{}},[]),ke=(0,W.useCallback)(async()=>{try{let e=await R.get(`/api/v1/ronin/trust`);c(e.data?.data||[])}catch{}},[]),je=(0,W.useCallback)(async()=>{try{let e=await R.get(`/api/v1/ronin/capabilities`);u(e.data?.data||[])}catch{}},[]),Me=(0,W.useCallback)(async()=>{try{let e=await R.get(`/api/v1/ronin/approvals`);m(e.data?.data||[])}catch{}},[]),Ne=(0,W.useCallback)(async()=>{try{let e=await R.get(`/api/v1/ronin/audit?limit=100`);g(e.data?.data||[])}catch{}},[]);(0,W.useEffect)(()=>{Promise.all([L(),Oe(),ke(),je(),Me(),Ne()]).finally(()=>y(!1))},[L,Oe,ke,je,Me,Ne]),(0,W.useEffect)(()=>{let e=setInterval(()=>{Me(),L()},5e3);return()=>clearInterval(e)},[Me,L]);let Fe=async()=>{if(S.trim()){se(!0);try{await R.post(`/api/v1/ronin/sessions`,{name:S,posture:w,komainu_level:E}),await Oe(),await L(),x(!1),C(``)}catch{}se(!1)}},Ie=async e=>{try{await R.delete(`/api/v1/ronin/sessions/${e}`),await Promise.all([Oe(),L()])}catch{}},Le=async(e,t)=>{try{await R.post(`/api/v1/ronin/approvals/${e}`,{decision:t,decided_by:`operator`}),j(null),await Promise.all([Me(),L()])}catch{}},Re=async()=>{if(ce){M(!0),we(null);try{let e=(await R.post(`/api/v1/ronin/execute`,{action_type:ce,target:pe||void 0,value:he||void 0,session_id:ye||void 0})).data?.data;e?.status===`success`?we(`✅ ${ce} — ${JSON.stringify(e.result_data||{}).slice(0,300)}`):we(`❌ ${e?.status}: ${e?.error||`Unknown error`}`),await L()}catch(e){we(`❌ ${e.response?.data?.detail||e.message||`Request failed`}`)}M(!1)}},ze=async()=>{if(confirm(`⚠️ HARAKIRI: This will stop ALL Ronin activity and close all sessions. Continue?`))try{await R.post(`/api/v1/ronin/harakiri`),await Promise.all([L(),Oe(),Me()])}catch{}},z=async()=>{if(confirm(`Ronin Desktop Control can operate your real mouse, keyboard, windows, and applications. Every action remains visible, verified, and audited. Enable it now?`)){b(!0);try{await R.post(`/api/v1/ronin/desktop/enable`,{confirmation:`ENABLE RONIN DESKTOP CONTROL`,ronin_screenshots_enabled:!0,ronin_mouse_enabled:!0,ronin_keyboard_enabled:!0,ronin_window_management_enabled:!0,ronin_native_apps_enabled:!0,ronin_require_verification:!0,ronin_require_high_risk_approval:!0,ronin_block_critical_actions:!0,ronin_visible_indicator:!0}),await L()}catch(e){alert(e.response?.data?.detail||`Could not enable Ronin Desktop Control.`)}finally{b(!1)}}},Be=async()=>{b(!0);try{await R.post(`/api/v1/ronin/desktop/disable`),await L()}finally{b(!1)}},V=async()=>{confirm(`Stop all Ronin Desktop Control immediately?`)&&(await R.post(`/api/v1/ronin/desktop/kill-switch`),await L())};if(_)return(0,G.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-[#0a0e1a]`,children:(0,G.jsx)(F,{className:`w-8 h-8 animate-spin`,style:{color:K}})});let H=n?.environment||{},U=n?.komainu||{},Ve=lt[H.environment_type]||B,Ue=ut[U.level]||ut[1];return(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col bg-[#0a0e1a] overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`px-6 py-5 border-b border-[#1a2040] flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-xl flex items-center justify-center`,style:{background:rt,border:`1px solid ${it}`},children:(0,G.jsx)(D,{className:`w-5 h-5`,style:{color:K}})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-lg font-bold text-[#c8d0d8] tracking-tight`,children:`Ronin`}),(0,G.jsx)(`p`,{className:`text-[10px] text-[#7a8899] uppercase tracking-widest font-bold`,children:`浪人 — Desktop Control Layer`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border cursor-default`,style:{background:U.active?`${Ue.color}08`:`#0e1225`,borderColor:U.active?`${Ue.color}30`:`#1a2040`},title:`Komainu Guardian: ${U.active?Ue.desc:`Inactive`}`,children:[(0,G.jsx)(Pe,{className:`w-3.5 h-3.5`,style:{color:U.active?Ue.color:`#7a8899`}}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider`,style:{color:U.active?Ue.color:`#7a8899`},children:U.active?U.paused?`PAUSED`:Ue.label:`GUARDIAN OFF`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[#0e1225] border border-[#1a2040]`,children:[(0,G.jsx)(Ve,{className:`w-3.5 h-3.5 text-[#7a8899]`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-wider`,children:(H.environment_type||`unknown`).replace(`_`,` `)})]}),n?.ronin_enabled?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[#22c55e]/8 border border-[#22c55e]/20`,children:[(0,G.jsx)(P,{className:`w-3.5 h-3.5 text-[#22c55e]`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#22c55e] uppercase tracking-wider`,children:n.ronin_posture.replace(`_`,` `)})]}):(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-[#ef4444]/8 border border-[#ef4444]/20`,children:[(0,G.jsx)(He,{className:`w-3.5 h-3.5 text-[#ef4444]`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#ef4444] uppercase tracking-wider`,children:`DISABLED`})]}),(0,G.jsxs)(`button`,{onClick:ze,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-[#ef4444]/8 border border-[#ef4444]/20 text-[#ef4444] hover:bg-[#ef4444]/20 transition-all cursor-pointer`,title:`Emergency Stop — Harakiri`,children:[(0,G.jsx)(fe,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider`,children:`STOP`})]})]})]}),p.length>0&&(0,G.jsxs)(`div`,{className:`px-6 py-3 bg-[#f97316]/8 border-b border-[#f97316]/20 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-[#f97316] animate-pulse`}),(0,G.jsxs)(`span`,{className:`text-xs font-bold text-[#f97316]`,children:[p.length,` Pending Approval`,p.length>1?`s`:``]}),(0,G.jsxs)(`span`,{className:`text-[10px] text-[#f97316]/60`,children:[`— `,p[0].action_type,` requires operator decision`]})]}),(0,G.jsxs)(`button`,{onClick:()=>j(p[0]),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider cursor-pointer transition-all`,style:{background:K,color:`#0a0e1a`},children:[`Review`,(0,G.jsx)(s,{className:`w-3 h-3`})]})]}),n?.desktop_active&&n.visible_indicator&&(0,G.jsxs)(`div`,{className:`px-6 py-2.5 bg-orange-500/10 border-b border-orange-500/30 flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-orange-400`,children:[(0,G.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-orange-400 animate-pulse`}),(0,G.jsx)(`span`,{className:`text-[10px] font-black tracking-[0.2em]`,children:`RONIN DESKTOP CONTROL ACTIVE`}),(0,G.jsx)(`span`,{className:`text-[9px] text-orange-300/60`,children:`Visible, verified, and audited`})]}),(0,G.jsx)(`button`,{onClick:V,className:`px-3 py-1 rounded border border-red-500/40 bg-red-500/10 text-[9px] font-bold text-red-400 hover:bg-red-500/20`,children:`KILL SWITCH`})]}),(0,G.jsx)(`div`,{className:`px-6 pt-3 flex items-center gap-1 border-b border-[#1a2040]`,children:at.map(n=>(0,G.jsx)(`button`,{onClick:()=>t(n),className:I(`px-4 py-2.5 text-[11px] font-bold uppercase tracking-wider transition-all duration-200 border-b-2 -mb-px cursor-pointer`,e===n?`border-[${K}] text-[${K}]`:`border-transparent text-[#7a8899] hover:text-[#c8d0d8]`),style:e===n?{borderColor:K,color:K}:{},children:n},n))}),(0,G.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[e===`Control`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-5 flex items-center justify-between gap-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`Full Desktop Control`}),(0,G.jsx)(`p`,{className:`text-[10px] text-[#7a8899] mt-1 max-w-2xl`,children:`Available only in Ronin posture. Enabling grants governed mouse, keyboard, window, and application control with mandatory observation, verification, audit, protected-context blocking, and a kill switch.`})]}),n?.desktop_active?(0,G.jsx)(`button`,{disabled:ee,onClick:Be,className:`px-4 py-2 rounded-lg border border-orange-500/40 bg-orange-500/10 text-xs font-bold text-orange-400 whitespace-nowrap`,children:`DISABLE DESKTOP CONTROL`}):(0,G.jsx)(`button`,{disabled:ee||!n?.desktop_available,onClick:z,className:`px-4 py-2 rounded-lg bg-orange-500 text-[#0a0e1a] text-xs font-black disabled:opacity-30 whitespace-nowrap`,children:n?.desktop_available?`ENABLE DESKTOP CONTROL`:`RONIN POSTURE REQUIRED`})]}),n?.desktop_active&&(0,G.jsxs)(`div`,{className:`grid grid-cols-[1.5fr_1fr] gap-4`,children:[(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`px-4 py-3 border-b border-[#1a2040] flex justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Current Desktop`}),(0,G.jsx)(`span`,{className:`text-[9px] text-orange-400`,children:n.runtime?.active_window?.title||`No active window detected`})]}),(0,G.jsx)(`div`,{className:`aspect-video bg-[#080b14] flex items-center justify-center`,children:n.runtime?.screenshot_url?(0,G.jsx)(`img`,{src:n.runtime.screenshot_url,className:`w-full h-full object-contain`,alt:`Current Ronin desktop`}):(0,G.jsx)(D,{className:`w-12 h-12 text-[#1a2040]`})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-px bg-[#1a2040]`,children:[(0,G.jsx)(mt,{label:`Next action`,value:n.runtime?.next_action?.action_type||`Idle`}),(0,G.jsx)(mt,{label:`Verification`,value:n.runtime?.verification?.passed===!0?`Passed`:n.runtime?.verification?.passed===!1?`Failed`:`Pending`}),(0,G.jsx)(mt,{label:`Retries`,value:String(n.runtime?.retry_count||0)})]})]}),(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl overflow-hidden`,children:[(0,G.jsx)(`div`,{className:`px-4 py-3 border-b border-[#1a2040] text-[10px] font-bold uppercase tracking-widest text-[#7a8899]`,children:`Action Timeline`}),(0,G.jsxs)(`div`,{className:`max-h-[360px] overflow-y-auto divide-y divide-[#1a2040]`,children:[(n.runtime?.timeline||[]).slice(0,50).map((e,t)=>(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`text-[9px] font-mono text-orange-400`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,G.jsx)(`div`,{className:`text-[10px] text-[#c8d0d8] mt-0.5`,children:e.message})]},`${e.timestamp}-${t}`)),!n.runtime?.timeline?.length&&(0,G.jsx)(`div`,{className:`p-6 text-center text-[10px] text-[#555]`,children:`No desktop actions yet.`})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-4 gap-4`,children:[(0,G.jsx)(ft,{icon:D,label:`Sessions`,value:String(n?.active_sessions||0),sub:`Active desktop sessions`,accent:K}),(0,G.jsx)(ft,{icon:Pe,label:`Komainu`,value:U.active?U.paused?`Paused`:`Active`:`Off`,sub:U.active?Ue.desc:`Guardian not running`,accent:U.active?Ue.color:`#7a8899`}),(0,G.jsx)(ft,{icon:de,label:`Approvals`,value:String(n?.pending_approvals||0),sub:`Waiting for operator`,accent:n?.pending_approvals?`#f97316`:`#22c55e`}),(0,G.jsx)(ft,{icon:xe,label:`Capabilities`,value:String(n?.capabilities_count||0),sub:`Registered actions`,accent:`#4a8cc7`})]}),(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-5`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest mb-4`,children:`Environment Detection`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsx)(pt,{label:`Type`,value:(H.environment_type||`unknown`).replace(`_`,` `)}),(0,G.jsx)(pt,{label:`OS`,value:`${H.os_type||`unknown`} ${H.os_version||``}`.trim()}),(0,G.jsx)(pt,{label:`Hostname`,value:H.hostname||`N/A`}),(0,G.jsx)(pt,{label:`Machine ID`,value:H.machine_id?H.machine_id.slice(0,16)+`…`:`N/A`}),(0,G.jsx)(pt,{label:`Disposable`,value:H.is_disposable?`Yes`:`No`}),(0,G.jsx)(pt,{label:`Hypervisor`,value:H.hypervisor||`None`})]})]}),(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-5`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest mb-4`,children:`Quick Action`}),(0,G.jsxs)(`div`,{className:`grid grid-cols-4 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,G.jsxs)(`select`,{value:ce,onChange:e=>le(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,G.jsxs)(`optgroup`,{label:`Desktop`,children:[(0,G.jsx)(`option`,{value:`desktop.screenshot`,children:`📸 Screenshot`}),(0,G.jsx)(`option`,{value:`desktop.click`,children:`🖱️ Click`}),(0,G.jsx)(`option`,{value:`desktop.move_mouse`,children:`↗️ Move Mouse`}),(0,G.jsx)(`option`,{value:`desktop.type`,children:`⌨️ Type Text`}),(0,G.jsx)(`option`,{value:`desktop.hotkey`,children:`⚡ Hotkey`}),(0,G.jsx)(`option`,{value:`desktop.locate_image`,children:`🔍 Locate Image`}),(0,G.jsx)(`option`,{value:`desktop.read_screen`,children:`👁️ Read Screen`})]}),(0,G.jsxs)(`optgroup`,{label:`Browser`,children:[(0,G.jsx)(`option`,{value:`browser.open`,children:`🌐 Open URL`}),(0,G.jsx)(`option`,{value:`browser.click`,children:`🖱️ Browser Click`}),(0,G.jsx)(`option`,{value:`browser.type`,children:`⌨️ Browser Type`}),(0,G.jsx)(`option`,{value:`browser.extract`,children:`📄 Extract Text`}),(0,G.jsx)(`option`,{value:`browser.screenshot`,children:`📸 Browser Screenshot`})]}),(0,G.jsxs)(`optgroup`,{label:`OS`,children:[(0,G.jsx)(`option`,{value:`os.list_windows`,children:`📋 List Windows`}),(0,G.jsx)(`option`,{value:`os.focus_window`,children:`🔲 Focus Window`})]})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Target`}),(0,G.jsx)(`input`,{value:pe,onChange:e=>me(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none`,placeholder:`x,y or selector`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Value`}),(0,G.jsx)(`input`,{value:he,onChange:e=>ve(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none`,placeholder:`text or URL`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`\xA0`}),(0,G.jsxs)(`button`,{onClick:Re,disabled:Se,className:`w-full flex items-center justify-center gap-2 p-2.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer disabled:opacity-40`,style:{background:K,color:`#0a0e1a`},children:[Se?(0,G.jsx)(F,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(ae,{className:`w-3.5 h-3.5`}),`Execute`]})]})]}),Ce&&(0,G.jsx)(`div`,{className:I(`mt-3 p-3 rounded-lg text-xs font-mono whitespace-pre-wrap border`,Ce.startsWith(`✅`)?`bg-[#22c55e]/5 text-[#22c55e]/90 border-[#22c55e]/20`:`bg-[#ef4444]/5 text-[#ef4444]/90 border-[#ef4444]/20`),children:Ce})]})]}),e===`Sessions`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Desktop Sessions`}),(0,G.jsxs)(`button`,{onClick:()=>x(!0),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all duration-200 cursor-pointer`,style:{background:rt,border:`1px solid ${it}`,color:K},children:[(0,G.jsx)(oe,{className:`w-3 h-3`}),`New Session`]})]}),i.length===0?(0,G.jsxs)(`div`,{className:`text-center py-16 space-y-3`,children:[(0,G.jsx)(D,{className:`w-12 h-12 mx-auto`,style:{color:`${K}40`}}),(0,G.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`No desktop sessions yet`}),(0,G.jsx)(`p`,{className:`text-xs text-[#555]`,children:`Create a session to start governing desktop control`})]}):(0,G.jsx)(`div`,{className:`grid gap-3`,children:i.map(e=>{let t=ot[e.status]||ot.idle,n=st[e.current_app_trust||`restricted`]||st.restricted;return(0,G.jsxs)(`div`,{className:`group bg-[#0e1225] border border-[#1a2040] rounded-xl p-4 flex items-center gap-4 hover:border-[#2a3060] transition-all duration-200`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-lg flex items-center justify-center shrink-0`,style:{background:t.bg},children:(0,G.jsx)(D,{className:`w-4.5 h-4.5`,style:{color:t.text}})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8] truncate`,children:e.name}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded`,style:{background:t.bg,color:t.text},children:e.status}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-[#4a8cc7]/10 text-[#4a8cc7]`,children:e.posture.replace(`_`,` `)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:e.environment_type.replace(`_`,` `)}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:`•`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:e.os_type}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:`•`}),(0,G.jsxs)(`span`,{className:`text-[9px] text-[#555]`,children:[e.action_count,` actions`]}),e.hostname&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-[9px] text-[#555]`,children:`•`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#555] font-mono`,children:e.hostname})]})]}),e.current_app&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,G.jsx)(ge,{className:`w-2.5 h-2.5 text-[#555]`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#c8d0d8]/70`,children:e.current_app}),(0,G.jsx)(`span`,{className:`text-[7px] font-bold uppercase px-1 py-0.5 rounded`,style:{background:n.bg,color:n.text},children:n.label})]}),e.last_action&&(0,G.jsxs)(`div`,{className:`flex items-center gap-1 mt-1`,children:[(0,G.jsx)(Ae,{className:`w-2.5 h-2.5 text-[#555]`}),(0,G.jsx)(`span`,{className:`text-[9px] text-[#f97316]/60 font-mono`,children:e.last_action})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-lg bg-[#0a0e1a] border border-[#1a2040]`,children:[(0,G.jsx)(Pe,{className:`w-3 h-3`,style:{color:ut[e.komainu_level]?.color||`#7a8899`}}),(0,G.jsxs)(`span`,{className:`text-[8px] font-bold uppercase`,style:{color:ut[e.komainu_level]?.color||`#7a8899`},children:[`L`,e.komainu_level]})]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,G.jsx)(`button`,{onClick:()=>Ie(e.id),className:`p-1.5 hover:bg-[#ef4444]/10 text-[#7a8899] hover:text-[#ef4444] rounded-lg transition-colors cursor-pointer`,title:`Close session`,children:(0,G.jsx)(_e,{className:`w-3.5 h-3.5`})})})]},e.id)})})]}),e===`App Trust`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Application Trust Registry`}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:[`all`,`trusted`,`restricted`,`sensitive`,`forbidden`].map(e=>(0,G.jsx)(`button`,{onClick:()=>De(e),className:I(`px-3 py-1 rounded-lg text-[9px] font-bold uppercase tracking-wider transition-all cursor-pointer`,Ee===e?`text-[#0a0e1a]`:`text-[#7a8899] bg-[#0e1225] border border-[#1a2040] hover:border-[#2a3060]`),style:Ee===e?{background:e===`all`?K:st[e]?.text||K}:{},children:e},e))})]}),(0,G.jsx)(`div`,{className:`grid gap-2`,children:o.filter(e=>Ee===`all`||e.trust_level===Ee).map((e,t)=>{let n=st[e.trust_level]||st.restricted;return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-lg px-4 py-3 flex items-center gap-3 hover:border-[#2a3060] transition-all`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center`,style:{background:n.bg},children:e.trust_level===`forbidden`?(0,G.jsx)(T,{className:`w-3.5 h-3.5`,style:{color:n.text}}):e.trust_level===`sensitive`?(0,G.jsx)(de,{className:`w-3.5 h-3.5`,style:{color:n.text}}):e.trust_level===`trusted`?(0,G.jsx)(P,{className:`w-3.5 h-3.5`,style:{color:n.text}}):(0,G.jsx)(v,{className:`w-3.5 h-3.5`,style:{color:n.text}})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-[#c8d0d8]`,children:e.name}),(0,G.jsx)(`div`,{className:`text-[9px] text-[#555] font-mono`,children:e.process||e.process_pattern||`—`})]}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded`,style:{background:n.bg,color:n.text},children:n.label}),(0,G.jsx)(`span`,{className:`text-[8px] text-[#555] uppercase`,children:e.platform})]},t)})})]}),e===`Capabilities`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Registered Capabilities`}),(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:[`all`,`desktop`,`browser`,`os`,`app`,`ronin`].map(e=>(0,G.jsx)(`button`,{onClick:()=>Te(e),className:I(`px-3 py-1 rounded-lg text-[9px] font-bold uppercase tracking-wider transition-all cursor-pointer`,N===e?`text-[#0a0e1a]`:`text-[#7a8899] bg-[#0e1225] border border-[#1a2040] hover:border-[#2a3060]`),style:N===e?{background:K}:{},children:e},e))})]}),(0,G.jsx)(`div`,{className:`grid gap-2`,children:l.filter(e=>N===`all`||e.category===N).map((e,t)=>{let n=ct[e.risk_level]||ct.low;return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-lg px-4 py-3 flex items-center gap-3 hover:border-[#2a3060] transition-all`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center bg-[#0a0e1a]`,children:e.category===`desktop`?(0,G.jsx)(re,{className:`w-3.5 h-3.5 text-[#f97316]`}):e.category===`browser`?(0,G.jsx)(v,{className:`w-3.5 h-3.5 text-[#06b6d4]`}):e.category===`os`?(0,G.jsx)(ue,{className:`w-3.5 h-3.5 text-[#a78bfa]`}):e.category===`ronin`?(0,G.jsx)(fe,{className:`w-3.5 h-3.5 text-[#ef4444]`}):(0,G.jsx)(xe,{className:`w-3.5 h-3.5 text-[#eab308]`})}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-[#c8d0d8] font-mono`,children:e.name}),e.requires_approval&&(0,G.jsx)(`span`,{className:`text-[7px] font-bold uppercase px-1 py-0.5 rounded bg-[#f97316]/10 text-[#f97316]`,children:`APPROVAL`})]}),(0,G.jsx)(`div`,{className:`text-[9px] text-[#555]`,children:e.description})]}),(0,G.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded`,style:{background:n.bg,color:n.text},children:e.risk_level}),(0,G.jsxs)(`span`,{className:`text-[8px] text-[#555] uppercase font-mono w-24 text-right`,children:[`≥ `,e.posture_minimum.replace(`_`,` `)]})]},t)})})]}),e===`Audit Trail`&&(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-xs font-bold text-[#7a8899] uppercase tracking-widest`,children:`Ronin Audit Trail`}),(0,G.jsxs)(`button`,{onClick:Ne,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer text-[#7a8899] hover:text-[#c8d0d8] bg-[#0e1225] border border-[#1a2040]`,children:[(0,G.jsx)(k,{className:`w-3 h-3`}),`Refresh`]})]}),h.length===0?(0,G.jsxs)(`div`,{className:`text-center py-16 space-y-3`,children:[(0,G.jsx)(Ae,{className:`w-12 h-12 mx-auto text-[#1a2040]`}),(0,G.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`No audit events yet`}),(0,G.jsx)(`p`,{className:`text-xs text-[#555]`,children:`Ronin actions will appear here once executed`})]}):(0,G.jsx)(`div`,{className:`space-y-1`,children:h.map((e,t)=>{let n=e.severity===`critical`?`#ef4444`:e.severity===`warn`?`#eab308`:e.severity===`error`?`#ef4444`:`#22c55e`;return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-lg px-4 py-2.5 flex items-center gap-3 hover:border-[#2a3060] transition-all`,children:[(0,G.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full shrink-0`,style:{background:n}}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold text-[#c8d0d8] font-mono`,children:e.event_type}),(0,G.jsx)(`span`,{className:`text-[7px] font-bold uppercase px-1 py-0.5 rounded`,style:{background:`${n}15`,color:n},children:e.severity})]}),(0,G.jsx)(`div`,{className:`text-[9px] text-[#555] truncate`,children:e.action})]}),(0,G.jsx)(`span`,{className:`text-[8px] text-[#555] font-mono whitespace-nowrap`,children:e.created_at?new Date(e.created_at).toLocaleTimeString():`—`})]},t)})})]})]}),te&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-2xl w-[440px] shadow-2xl overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-5 border-b border-[#1a2040] flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center`,style:{background:rt,border:`1px solid ${it}`},children:(0,G.jsx)(oe,{className:`w-4 h-4`,style:{color:K}})}),(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#c8d0d8]`,children:`New Ronin Session`})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Session Name`}),(0,G.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none`,placeholder:`e.g., SAP Data Entry, Browser Research`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Posture Level`}),(0,G.jsxs)(`select`,{value:w,onChange:e=>ne(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2.5 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,G.jsx)(`option`,{value:`observe_only`,children:`👁️ Observe Only — Screenshots & window listing`}),(0,G.jsx)(`option`,{value:`browser_only`,children:`🌐 Browser Only — Playwright/Mado control`}),(0,G.jsx)(`option`,{value:`desktop_limited`,children:`🖱️ Desktop Limited — Mouse, keyboard, screenshots`}),(0,G.jsx)(`option`,{value:`desktop_full`,children:`⚡ Desktop Full — Native apps, shell, admin`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(Pe,{className:`w-3 h-3`}),`Komainu Guardian Level`]}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[1,2,3].map(e=>{let t=ut[e];return(0,G.jsxs)(`button`,{onClick:()=>ie(e),className:I(`flex-1 flex flex-col items-center gap-1 px-3 py-2.5 rounded-lg border text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer`,E===e?`border-[${t.color}]`:`border-[#1a2040] hover:border-[#2a3060]`),style:E===e?{borderColor:t.color,background:`${t.color}10`,color:t.color}:{color:`#7a8899`},children:[(0,G.jsx)(`span`,{children:t.label}),(0,G.jsx)(`span`,{className:`text-[7px] normal-case tracking-normal font-normal opacity-60`,children:t.desc})]},e)})})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-3 border-t border-[#1a2040] flex items-center justify-end gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>x(!1),className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#7a8899] hover:text-[#c8d0d8] transition-colors cursor-pointer`,children:`Cancel`}),(0,G.jsxs)(`button`,{onClick:Fe,disabled:O||!S.trim(),className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer disabled:opacity-40`,style:{background:K,color:`#0a0e1a`},children:[O?(0,G.jsx)(F,{className:`w-3 h-3 animate-spin`}):(0,G.jsx)(oe,{className:`w-3 h-3`}),`Create`]})]})]})}),A&&(0,G.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,children:(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#f97316]/30 rounded-2xl w-[480px] shadow-2xl overflow-hidden`,children:[(0,G.jsxs)(`div`,{className:`p-5 border-b border-[#f97316]/20 bg-[#f97316]/5 flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center bg-[#f97316]/15 border border-[#f97316]/30`,children:(0,G.jsx)(de,{className:`w-4 h-4 text-[#f97316]`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-[#f97316]`,children:`Approval Required`}),(0,G.jsx)(`p`,{className:`text-[9px] text-[#f97316]/60`,children:`Ronin is requesting permission for a high-risk action`})]})]}),(0,G.jsxs)(`div`,{className:`p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,G.jsx)(ht,{label:`Action`,value:A.action_type}),(0,G.jsx)(ht,{label:`Risk Level`,value:A.risk_level,highlight:!0}),(0,G.jsx)(ht,{label:`Target`,value:A.target||`—`}),(0,G.jsx)(ht,{label:`Application`,value:A.app_name||`—`}),A.app_trust&&(0,G.jsx)(ht,{label:`App Trust`,value:A.app_trust})]}),(0,G.jsxs)(`div`,{className:`p-3 bg-[#0a0e1a] rounded-lg border border-[#1a2040]`,children:[(0,G.jsx)(`p`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest mb-1`,children:`Reason`}),(0,G.jsx)(`p`,{className:`text-xs text-[#c8d0d8]`,children:A.reason})]})]}),(0,G.jsxs)(`div`,{className:`px-5 py-4 border-t border-[#1a2040] flex items-center justify-between`,children:[(0,G.jsx)(`button`,{onClick:()=>j(null),className:`px-4 py-2 text-[10px] font-bold uppercase tracking-wider text-[#7a8899] hover:text-[#c8d0d8] transition-colors cursor-pointer`,children:`Later`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`button`,{onClick:()=>Le(A.id,`denied`),className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#ef4444]/10 text-[#ef4444] border border-[#ef4444]/20 hover:bg-[#ef4444]/20 transition-all cursor-pointer`,children:[(0,G.jsx)(f,{className:`w-3 h-3`}),`Deny`]}),(0,G.jsxs)(`button`,{onClick:()=>Le(A.id,`approved`),className:`flex items-center gap-1.5 px-4 py-2 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all cursor-pointer`,style:{background:`#22c55e`,color:`#0a0e1a`},children:[(0,G.jsx)(d,{className:`w-3 h-3`}),`Approve`]})]})]})]})})]})}function ft({icon:e,label:t,value:n,sub:r,accent:i}){return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] border border-[#1a2040] rounded-xl p-4 hover:border-[#2a3060] transition-all`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg flex items-center justify-center`,style:{background:`${i}12`,border:`1px solid ${i}30`},children:(0,G.jsx)(e,{className:`w-4 h-4`,style:{color:i}})}),(0,G.jsx)(`span`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:t})]}),(0,G.jsx)(`p`,{className:`text-2xl font-bold tracking-tight`,style:{color:i},children:n}),(0,G.jsx)(`p`,{className:`text-[9px] text-[#555] mt-1`,children:r})]})}function pt({label:e,value:t}){return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest mb-0.5`,children:e}),(0,G.jsx)(`p`,{className:`text-xs text-[#c8d0d8] font-mono`,children:t})]})}function mt({label:e,value:t}){return(0,G.jsxs)(`div`,{className:`bg-[#0e1225] px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`text-[8px] uppercase tracking-widest text-[#555]`,children:e}),(0,G.jsx)(`div`,{className:`text-[10px] font-bold text-[#c8d0d8] mt-1 truncate`,children:t})]})}function ht({label:e,value:t,highlight:n}){let r=n?ct[t]||ct.high:null;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[8px] font-bold text-[#7a8899] uppercase tracking-widest mb-0.5`,children:e}),n&&r?(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase px-1.5 py-0.5 rounded`,style:{background:r.bg,color:r.text},children:t}):(0,G.jsx)(`p`,{className:`text-xs text-[#c8d0d8] font-mono truncate`,children:t})]})}var gt=`IDE Mode gives Shogun access to an approved development workspace. In Campaign posture, Shogun may inspect and edit code, run approved tasks, read diagnostics, and use Git status/diff. In Ronin posture, broader terminal and Git operations may be configured. Enable only for trusted repositories and tasks.`,_t=()=>{let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)([]),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(`Balanced`),[c,l]=(0,W.useState)(!1),[u,f]=(0,W.useState)(``),h=(0,W.useCallback)(async()=>{let[e,n,i]=await Promise.all([R.get(`/api/v1/ide/status`),R.get(`/api/v1/ide/workspaces`).catch(()=>({data:{data:[]}})),R.get(`/api/v1/models/routing/profiles/active`).catch(()=>({data:{data:null}}))]);t(e.data.data),r(n.data.data||[]),s(i.data.data?.name||`Balanced`)},[]);(0,W.useEffect)(()=>{h().catch(()=>f(`Unable to load IDE Mode status.`))},[h]);let g=async(e,t)=>{l(!0),f(``);try{await e(),f(t),await h()}catch(e){f(e?.response?.data?.detail||`The IDE operation failed.`)}finally{l(!1)}};return e?(0,G.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-3 gap-5`,children:[(0,G.jsxs)(`section`,{className:`shogun-card xl:col-span-2 space-y-5`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(p,{className:`w-5 h-5 text-purple-400`}),(0,G.jsx)(`h3`,{className:`font-bold text-shogun-text`,children:`Shogun IDE Mode`})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Governed autonomous development through the VS Code Adapter.`})]}),(0,G.jsx)(`span`,{className:I(`px-2.5 py-1 rounded border text-[9px] font-bold uppercase`,e.enabled?`text-green-400 border-green-500/30 bg-green-500/10`:`text-shogun-subdued border-shogun-border`),children:e.enabled?`Enabled`:`Disabled`})]}),!e.available&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 p-4 text-xs text-amber-200`,children:[(0,G.jsx)(`b`,{children:`Posture locked.`}),` IDE Mode is only available in Campaign and Ronin. Current posture: `,String(e.posture).toUpperCase(),`.`]}),e.available&&!e.enabled&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-4 flex gap-3`,children:[(0,G.jsx)(N,{className:`w-4 h-4 text-amber-400 shrink-0 mt-0.5`}),(0,G.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-100/80`,children:gt})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[e.enabled?(0,G.jsxs)(`button`,{disabled:c,onClick:()=>g(()=>R.post(`/api/v1/ide/disable`),`IDE Mode disabled and all bridge sessions revoked.`),className:`px-4 py-2 rounded-lg border border-red-500/35 bg-red-500/10 text-red-300 text-xs font-bold flex items-center gap-2`,children:[(0,G.jsx)(We,{className:`w-4 h-4`}),` Disable`]}):(0,G.jsxs)(`button`,{disabled:!e.available||c,onClick:()=>{window.confirm(gt)&&g(()=>R.post(`/api/v1/ide/enable`,{confirmed:!0,remember_workspace:!1}),`IDE Mode enabled for this session.`)},className:`px-4 py-2 rounded-lg bg-purple-600 text-white text-xs font-bold disabled:opacity-30 flex items-center gap-2`,children:[(0,G.jsx)(se,{className:`w-4 h-4`}),` Enable IDE Mode`]}),(0,G.jsxs)(`button`,{onClick:()=>h(),className:`px-3 py-2 rounded-lg border border-shogun-border text-shogun-subdued text-xs flex items-center gap-2`,children:[(0,G.jsx)(k,{className:`w-3.5 h-3.5`}),` Refresh`]})]})]}),(0,G.jsxs)(`section`,{className:`shogun-card space-y-3`,children:[(0,G.jsx)(`h3`,{className:`text-xs font-bold uppercase tracking-widest text-shogun-text`,children:`Runtime Status`}),[[`Posture`,e.posture],[`Routing profile`,o],[`Provider`,`VS Code Adapter`],[`Connections`,e.connected_instances],[`Approved workspaces`,e.approved_workspaces]].map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex justify-between text-xs border-b border-shogun-border/40 pb-2`,children:[(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:e}),(0,G.jsx)(`b`,{className:`text-shogun-text`,children:String(t)})]},String(e))),(0,G.jsx)(`button`,{disabled:!e.enabled||c,onClick:()=>g(()=>R.post(`/api/v1/ide/kill-switch`),`IDE kill switch activated.`),className:`w-full mt-2 px-3 py-2 rounded border border-red-500/30 text-red-300 text-[10px] font-bold uppercase disabled:opacity-30`,children:`Stop all IDE work`})]})]}),e.enabled&&(0,G.jsxs)(`section`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-bold text-sm text-shogun-text`,children:`VS Code Pairing`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Create a one-time, ten-minute localhost token for Shogun IDE Bridge.`})]}),(0,G.jsx)(ye,{className:I(`w-5 h-5`,e.connected_instances?`text-green-400`:`text-shogun-subdued`)})]}),i?(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#050508] border border-shogun-border p-4 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`code`,{className:`text-purple-300 text-sm break-all flex-1`,children:i.token}),(0,G.jsx)(`button`,{onClick:()=>navigator.clipboard.writeText(i.token),title:`Copy token`,children:(0,G.jsx)(m,{className:`w-4 h-4 text-shogun-subdued`})})]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[`Bridge: `,i.bridge_url,` · expires `,new Date(i.expires_at).toLocaleTimeString()]})]}):(0,G.jsx)(`button`,{disabled:c,onClick:()=>g(async()=>{let e=await R.post(`/api/v1/ide/pairing/create`);a(e.data.data)},`Pairing token created.`),className:`px-4 py-2 bg-shogun-blue/20 border border-shogun-blue/30 rounded-lg text-xs font-bold text-shogun-blue`,children:`Create pairing token`})]}),e.enabled&&(0,G.jsxs)(`section`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ze,{className:`w-4 h-4 text-shogun-gold`}),(0,G.jsx)(`h3`,{className:`font-bold text-sm`,children:`Registered Workspaces`})]}),n.length===0?(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic`,children:`No VS Code workspace registered yet. Pair the Shogun IDE Bridge, then open a folder in VS Code.`}):n.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border bg-[#050508] p-4 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`b`,{className:`text-sm text-shogun-text`,children:e.name}),e.approved&&(0,G.jsx)(d,{className:`w-3.5 h-3.5 text-green-400`})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued truncate`,children:e.root_path})]}),(0,G.jsx)(`button`,{onClick:()=>g(()=>R.post(`/api/v1/ide/workspaces/${e.id}/${e.approved?`revoke`:`approve`}`),e.approved?`Workspace access revoked.`:`Workspace approved.`),className:I(`px-3 py-1.5 rounded border text-[10px] font-bold uppercase`,e.approved?`border-red-500/30 text-red-300`:`border-green-500/30 text-green-300`),children:e.approved?`Revoke`:`Approve`})]},e.id))]}),(0,G.jsx)(`section`,{className:`shogun-card`,children:(0,G.jsxs)(`div`,{className:`flex gap-3`,children:[(0,G.jsx)(ke,{className:`w-4 h-4 text-purple-400 shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`text-xs font-bold`,children:`Enforced safeguards`}),(0,G.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-1 leading-relaxed`,children:`Workspace approval, traversal and symlink protection, protected-secret rules, Campaign command allowlists, snapshots before writes, Git push disabled by default, central audit events, self-verification hooks, and an immediate kill switch.`})]})]})}),u&&(0,G.jsx)(`div`,{className:`fixed bottom-6 right-6 z-50 rounded-lg border border-shogun-border bg-[#0a0e1a] px-4 py-3 text-xs shadow-2xl`,children:u})]}):(0,G.jsxs)(`div`,{className:`shogun-card flex items-center gap-3 text-shogun-subdued`,children:[(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}),` Loading IDE Mode…`]})},vt=[`simple_chat`,`summarization`,`planning`,`complex_reasoning`,`coding_plan`,`coding_edit`,`test_failure_analysis`,`visual_understanding`,`browser_task`,`desktop_task`,`self_verification`,`final_review`,`stack_planning`,`stack_step_execution`,`context_compaction`],yt=[`reasoning`,`coding`,`vision`,`tool_use`,`long_context`,`json_mode`],bt={reasoning:`Reasoning`,coding:`Coding`,vision:`Images & vision`,tool_use:`Tool use`,long_context:`Long documents`,json_mode:`Structured output`},xt={quality_tier:[{value:1,label:`Basic`,help:`Simple and routine work`},{value:2,label:`Standard`,help:`Everyday general tasks`},{value:3,label:`Strong`,help:`Reliable professional work`},{value:4,label:`Advanced`,help:`Difficult or specialized work`},{value:5,label:`Frontier`,help:`Highest available capability`}],cost_tier:[{value:1,label:`Very low cost`,help:`Preferred by economy profiles`},{value:2,label:`Low cost`,help:`Budget-friendly usage`},{value:3,label:`Moderate cost`,help:`Balanced price point`},{value:4,label:`High cost`,help:`Use for demanding work`},{value:5,label:`Premium cost`,help:`Most expensive tier`}],latency_tier:[{value:1,label:`Fastest`,help:`Best for interactive work`},{value:2,label:`Fast`,help:`Usually responds quickly`},{value:3,label:`Moderate`,help:`Normal response time`},{value:4,label:`Slow`,help:`Longer response time`},{value:5,label:`Slowest`,help:`Use when speed is secondary`}]},St=[`Simple`,`Routine`,`Involved`,`Complex`,`Expert`];function Ct({isEditingProfiles:e=!1,onEditProfiles:t}){let[n,i]=(0,W.useState)([]),[o,s]=(0,W.useState)([]),[l,u]=(0,W.useState)({}),[f,p]=(0,W.useState)(!0),[m,h]=(0,W.useState)(``),[g,_]=(0,W.useState)(``),[v,y]=(0,W.useState)(`coding_edit`),[ee,b]=(0,W.useState)(`balanced`),[te,x]=(0,W.useState)(4),[S,C]=(0,W.useState)([`coding`,`tool_use`]),[w,ne]=(0,W.useState)(null),[T,E]=(0,W.useState)([]),D=async()=>{p(!0);try{let[e,t,n]=await Promise.all([R.get(`/api/v1/models/routing/profiles`),R.get(`/api/v1/models/registry`),R.get(`/api/v1/models/usage/summary`)]),r=e.data.data||[];i(r),s(t.data.data||[]),u(n.data.data||{});let a=(e.data.data||[]).find(e=>e.is_default);a&&b(a.name.toLowerCase().replaceAll(` `,`_`));let o=r.find(e=>e.name===`Custom`),c=o?.rules?.find(e=>e.task_type===`*`)||o?.rules?.[0];E(c?.primary_model_id?[String(c.primary_model_id),...(c.fallback_model_ids||[]).map(String)]:[])}catch(e){_(e?.response?.data?.detail||`Model routing data could not be loaded.`)}finally{p(!1)}};(0,W.useEffect)(()=>{D()},[]);let re=(0,W.useMemo)(()=>n.find(e=>e.is_default),[n]),ie=(0,W.useMemo)(()=>n.find(e=>e.name===`Custom`),[n]),oe=async e=>{h(e.id);try{await R.post(`/api/v1/models/routing/profiles/active`,{profile_id:e.id}),_(`${e.name} is now the active routing profile.`),await D()}catch(e){_(e?.response?.data?.detail||`Profile could not be activated.`)}finally{h(``)}},se=async(e,t)=>{h(e.id);try{let n=await R.patch(`/api/v1/models/registry/${e.id}`,t);s(t=>t.map(t=>t.id===e.id?n.data.data:t)),_(`${e.display_name} updated.`)}catch(e){_(e?.response?.data?.detail||`Model metadata could not be updated.`)}finally{h(``)}},A=async e=>{h(`test-${e.id}`);try{await R.post(`/api/v1/models/registry/${e.id}/test`),_(`${e.display_name} is reachable.`)}catch(e){_(e?.response?.data?.detail||`Connection test failed.`)}finally{h(``)}};return f?(0,G.jsxs)(`div`,{className:`shogun-card flex items-center gap-3 text-sm text-shogun-subdued`,children:[(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}),` Loading governed routing…`]}):(0,G.jsxs)(`div`,{className:`space-y-6 mb-8`,children:[(0,G.jsxs)(`div`,{className:`shogun-card border-purple-500/30 bg-purple-500/5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-4 mb-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`font-bold flex items-center gap-2`,children:[(0,G.jsx)(O,{className:`w-5 h-5 text-purple-400`}),` Model Routing Profiles`]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Cheapest sufficient model, with governed escalation and hard capability filters.`})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`px-3 py-2 rounded-lg border border-purple-400/30 bg-purple-400/10 text-xs`,children:[(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:`Active `}),(0,G.jsx)(`strong`,{className:`text-purple-300`,children:re?.name||`Balanced`})]}),t&&(0,G.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-wider transition-colors ${e?`border-purple-400 bg-purple-400/15 text-purple-300`:`border-shogun-border text-shogun-subdued hover:border-purple-400/40 hover:text-purple-300`}`,children:[(0,G.jsx)(U,{className:`w-3.5 h-3.5`}),` `,e?`Close editor`:`Edit profiles`]})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 xl:grid-cols-6 gap-2`,children:n.filter(e=>[`Ultra Economy`,`Economy`,`Balanced`,`High Capability`,`Premium`,`Custom`].includes(e.name)).map(e=>(0,G.jsxs)(`button`,{onClick:()=>oe(e),disabled:m===e.id,className:`text-left p-3 rounded-lg border transition-all ${e.is_default?`border-purple-400 bg-purple-400/15`:`border-shogun-border hover:border-purple-400/40`}`,children:[(0,G.jsxs)(`div`,{className:`text-xs font-bold flex items-center gap-1.5`,children:[e.is_default&&(0,G.jsx)(d,{className:`w-3.5 h-3.5 text-purple-400`}),e.name]}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-1 line-clamp-2`,children:e.description})]},e.id))}),ie&&(0,G.jsxs)(`div`,{className:`mt-5 pt-5 border-t border-purple-400/20`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3 mb-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold`,children:`Custom model order`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Only these models may be routed. The first eligible model is preferred; capability and safety gates still apply.`})]}),(0,G.jsx)(`button`,{onClick:async()=>{if(!ie||T.length===0){_(`Choose at least one model for Custom routing.`);return}h(`custom`);try{await R.post(`/api/v1/models/routing/profiles/${ie.id}/update`,{rules:[{task_type:`*`,primary_model_id:T[0],fallback_model_ids:T.slice(1)}]}),await R.post(`/api/v1/models/routing/profiles/active`,{profile_id:ie.id}),_(`Custom routing saved and activated.`),await D()}catch(e){_(e?.response?.data?.detail||`Custom routing could not be saved.`)}finally{h(``)}},disabled:m===`custom`||T.length===0,className:`px-3 py-2 rounded bg-purple-600 hover:bg-purple-500 disabled:opacity-40 text-[10px] font-bold`,children:m===`custom`?`Saving…`:`Save & activate Custom`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3`,children:[(0,G.jsx)(`div`,{className:`max-h-44 overflow-y-auto rounded-lg border border-shogun-border p-2 space-y-1`,children:o.filter(e=>e.enabled).map(e=>{let t=T.includes(e.id);return(0,G.jsxs)(`button`,{onClick:()=>E(n=>t?n.filter(t=>t!==e.id):[...n,e.id]),className:`w-full flex items-center justify-between gap-2 rounded p-2 text-left text-xs border ${t?`border-purple-400/50 bg-purple-400/10`:`border-transparent hover:border-shogun-border`}`,children:[(0,G.jsxs)(`span`,{className:`truncate`,children:[(0,G.jsx)(`strong`,{children:e.display_name}),(0,G.jsx)(`span`,{className:`ml-2 text-[9px] text-shogun-subdued`,children:e.provider})]}),t&&(0,G.jsx)(d,{className:`w-3.5 h-3.5 text-purple-400 shrink-0`})]},e.id)})}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border p-2 space-y-1`,children:[T.map((e,t)=>{let n=o.find(t=>t.id===e);return n?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded bg-[#080b14] border border-shogun-border p-2`,children:[(0,G.jsx)(`span`,{className:`w-16 text-[8px] font-bold uppercase text-purple-300`,children:t===0?`Primary`:`Fallback ${t}`}),(0,G.jsx)(`span`,{className:`text-xs flex-1 truncate`,children:n.display_name}),(0,G.jsx)(`button`,{disabled:t===0,onClick:()=>E(e=>{let n=[...e];return[n[t-1],n[t]]=[n[t],n[t-1]],n}),children:(0,G.jsx)(c,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{disabled:t===T.length-1,onClick:()=>E(e=>{let n=[...e];return[n[t],n[t+1]]=[n[t+1],n[t]],n}),children:(0,G.jsx)(a,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{onClick:()=>E(t=>t.filter(t=>t!==e)),children:(0,G.jsx)(Ce,{className:`w-3.5 h-3.5 text-red-400`})})]},e):null}),!T.length&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued text-center py-6`,children:`Select models from the registry.`})]})]})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-3 gap-6`,children:[(0,G.jsxs)(`div`,{className:`xl:col-span-2 shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h4`,{className:`font-bold flex items-center gap-2`,children:[(0,G.jsx)(ue,{className:`w-4 h-4 text-shogun-blue`}),` Model Capability Registry`]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Describe what each connected model can do, how capable it is, what it costs, and how quickly it responds. The router uses these as eligibility and preference signals.`})]}),(0,G.jsx)(`button`,{onClick:D,children:(0,G.jsx)(k,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`space-y-3 max-h-[560px] overflow-y-auto pr-1`,children:[o.map(e=>(0,G.jsxs)(`div`,{className:`rounded-xl border p-4 ${e.enabled?`border-shogun-border bg-[#080b14]`:`border-shogun-border/40 opacity-60`}`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-bold text-sm`,children:e.display_name}),(0,G.jsx)(`span`,{className:`text-[8px] uppercase border border-shogun-border rounded px-1.5 py-0.5`,children:e.local?`local`:e.provider})]}),(0,G.jsxs)(`p`,{className:`font-mono text-[9px] text-shogun-subdued mt-1`,children:[e.model_id,` · `,(e.context_window/1e3).toFixed(0),`K context`]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>A(e),className:`px-2 py-1 text-[9px] border border-shogun-border rounded hover:border-shogun-blue`,children:m===`test-${e.id}`?`Testing…`:`Test`}),(0,G.jsx)(`button`,{onClick:()=>se(e,{enabled:!e.enabled}),className:`w-10 h-5 rounded-full p-0.5 ${e.enabled?`bg-green-500`:`bg-gray-700`}`,children:(0,G.jsx)(`span`,{className:`block w-4 h-4 bg-white rounded-full transition-transform ${e.enabled?`translate-x-5`:``}`})})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-2 my-3`,children:[`quality_tier`,`cost_tier`,`latency_tier`].map(t=>{let n=xt[t].find(n=>n.value===e[t])||xt[t][2];return(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[t.replace(`_tier`,``),(0,G.jsx)(`select`,{value:e[t],onChange:n=>se(e,{[t]:Number(n.target.value)}),className:`block w-full mt-1 bg-[#050508] border border-shogun-border rounded p-1.5 text-xs normal-case`,children:xt[t].map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(`span`,{className:`block mt-1 text-[8px] normal-case leading-tight text-shogun-subdued/70`,children:n.help})]},t)})}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase tracking-wider text-shogun-subdued mb-1.5`,children:`Supported task capabilities — click to enable or disable`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:yt.map(t=>(0,G.jsx)(`button`,{onClick:()=>se(e,{capabilities:{...e.capabilities,[t]:!e.capabilities?.[t]}}),className:`text-[8px] uppercase px-2 py-1 rounded border ${e.capabilities?.[t]?`border-cyan-400/40 bg-cyan-400/10 text-cyan-300`:`border-shogun-border text-shogun-subdued`}`,children:bt[t]},t))}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:(e.role_tags||[]).map(e=>(0,G.jsx)(`span`,{className:`rounded bg-purple-400/10 px-1.5 py-0.5 text-[8px] uppercase text-purple-300`,children:e},e))})]},e.id)),!o.length&&(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued text-center py-8`,children:`Connect a model provider to populate the registry.`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`h4`,{className:`font-bold flex items-center gap-2 mb-4`,children:[(0,G.jsx)(r,{className:`w-4 h-4 text-shogun-gold`}),` Preview Decision`]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[`Task type`,(0,G.jsx)(`select`,{value:v,onChange:e=>y(e.target.value),className:`block w-full mt-1 bg-[#050508] border border-shogun-border rounded p-2 text-xs`,children:vt.map(e=>(0,G.jsx)(`option`,{children:e},e))})]}),(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[`Profile`,(0,G.jsx)(`select`,{value:ee,onChange:e=>b(e.target.value),className:`block w-full mt-1 bg-[#050508] border border-shogun-border rounded p-2 text-xs`,children:n.map(e=>(0,G.jsx)(`option`,{value:e.name.toLowerCase().replaceAll(` `,`_`),children:e.name},e.id))})]}),(0,G.jsxs)(`label`,{className:`text-[9px] uppercase text-shogun-subdued`,children:[`Task complexity: `,(0,G.jsx)(`strong`,{className:`text-shogun-text normal-case`,children:St[te-1]}),(0,G.jsx)(`input`,{type:`range`,min:`1`,max:`5`,value:te,onChange:e=>x(Number(e.target.value)),className:`block w-full mt-2`})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:yt.map(e=>(0,G.jsx)(`button`,{onClick:()=>C(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),className:`text-[8px] border rounded px-1.5 py-1 ${S.includes(e)?`border-shogun-gold text-shogun-gold`:`border-shogun-border text-shogun-subdued`}`,children:bt[e]},e))}),(0,G.jsxs)(`button`,{onClick:async()=>{h(`preview`),ne(null);try{let e=await R.post(`/api/v1/models/route/preview`,{prompt:`Preview ${v}`,task_type:v,complexity_override:te,required_capabilities:S,profile_override:ee});ne(e.data.data)}catch(e){_(e?.response?.data?.detail||`No eligible route found.`)}finally{h(``)}},disabled:m===`preview`,className:`w-full flex items-center justify-center gap-2 p-2 rounded bg-purple-600 hover:bg-purple-500 font-bold text-xs`,children:[(0,G.jsx)(ae,{className:`w-3.5 h-3.5`}),` Preview route`]})]}),w&&(0,G.jsxs)(`div`,{className:`mt-4 p-3 rounded-lg border border-green-400/30 bg-green-400/5`,children:[(0,G.jsx)(`div`,{className:`font-bold text-sm text-green-300`,children:w.selected_model}),(0,G.jsxs)(`div`,{className:`text-[9px] text-shogun-subdued`,children:[w.selected_provider,` · fallback `,w.fallback_model||`none`]}),(0,G.jsx)(`p`,{className:`text-[10px] mt-2 leading-relaxed`,children:w.reason}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-3 mt-2 text-[8px] uppercase text-shogun-subdued`,children:[(0,G.jsxs)(`span`,{children:[St[Math.max(1,Math.min(5,w.complexity_score))-1],` task`]}),(0,G.jsx)(`span`,{children:xt.cost_tier.find(e=>e.value===w.estimated_cost_tier)?.label||`Unknown cost`}),(0,G.jsx)(`span`,{children:xt.latency_tier.find(e=>e.value===w.estimated_latency_tier)?.label||`Unknown speed`})]})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`h4`,{className:`font-bold flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Ae,{className:`w-4 h-4 text-green-400`}),` Usage`]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-center`,children:[(0,G.jsx)(wt,{icon:(0,G.jsx)(xe,{className:`w-3 h-3`}),label:`Events`,value:l.events||0}),(0,G.jsx)(wt,{icon:(0,G.jsx)(z,{className:`w-3 h-3`}),label:`Avg latency`,value:`${l.average_latency_ms||0} ms`}),(0,G.jsx)(wt,{label:`Input tokens`,value:l.input_tokens||0}),(0,G.jsx)(wt,{label:`Output tokens`,value:l.output_tokens||0})]})]})]})]}),g&&(0,G.jsx)(`div`,{className:`text-xs border border-shogun-border rounded-lg px-3 py-2`,onClick:()=>_(``),children:g})]})}function wt({icon:e,label:t,value:n}){return(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border p-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[8px] uppercase text-shogun-subdued`,children:[e,t]}),(0,G.jsx)(`div`,{className:`font-bold text-sm mt-1`,children:n})]})}var Tt=e=>e?.data?.data??e?.data??e,Et=e=>e>.5?`text-green-400`:e<0?`text-red-400`:`text-amber-300`;function Dt(){let[e,t]=(0,W.useState)([]),[n,r]=(0,W.useState)([]),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(``),[u,f]=(0,W.useState)(`trajectories`),[p,m]=(0,W.useState)(!0),[h,g]=(0,W.useState)(``),_=async()=>{m(!0),g(``);try{let[e,n]=await Promise.all([R.get(`/api/v1/skills/trajectories`,{params:{limit:200}}),R.get(`/api/v1/skills/improvement-candidates`,{params:{limit:200}})]);t(Tt(e)||[]),r(Tt(n)||[])}catch(e){g(e.response?.data?.detail||`Could not load skill trajectories.`)}finally{m(!1)}};(0,W.useEffect)(()=>{_()},[]);let v=(0,W.useMemo)(()=>e.filter(e=>{let t=!c||e.final_outcome===c,n=o.trim().toLowerCase();return t&&(!n||[e.skill_name,e.task_summary,e.run_id,e.model_id].some(e=>String(e||``).toLowerCase().includes(n)))}),[e,o,c]),y=e.filter(e=>e.finalized_at),ee=y.filter(e=>e.final_outcome===`success`).length,b=y.length?y.reduce((e,t)=>e+t.score,0)/y.length:0,te=(0,W.useMemo)(()=>{let t=new Map;return e.forEach(e=>t.set(e.skill_name,[...t.get(e.skill_name)||[],e])),Array.from(t.entries()).map(([e,t])=>({name:e,uses:t.length,average:t.reduce((e,t)=>e+t.score,0)/t.length,success:t.filter(e=>e.final_outcome===`success`).length,failed:t.filter(e=>e.final_outcome===`failure`).length,blocked:t.filter(e=>e.final_outcome===`blocked`).length,lastUsed:t.map(e=>e.created_at).sort().slice(-1)[0]})).sort((e,t)=>t.uses-e.uses)},[e]),x=async e=>{try{a(Tt(await R.get(`/api/v1/skills/trajectories/${e}`)))}catch(e){g(e.response?.data?.detail||`Could not load trajectory detail.`)}},S=async e=>{try{let t=await R.post(`/api/v1/skills/trajectories/export`,{format:e,outcome:c||null,include_raw_prompts:!1,include_full_tool_outputs:!1},{responseType:`blob`}),n=URL.createObjectURL(t.data),r=document.createElement(`a`);r.href=n,r.download=`skill-trajectories.${e===`markdown`?`md`:e}`,r.click(),URL.revokeObjectURL(n)}catch(e){g(e.response?.data?.detail||`Trajectory export failed.`)}};return(0,G.jsxs)(`div`,{className:`shogun-card border-purple-500/20 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row lg:items-center gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest text-purple-300`,children:`Order 10 Evidence`}),(0,G.jsx)(`h3`,{className:`text-lg font-bold`,children:`Skill Trajectories`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Redacted activation, tool, verification, outcome, and improvement evidence.`})]}),(0,G.jsxs)(`div`,{className:`lg:ml-auto flex flex-wrap gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>f(`trajectories`),className:I(`px-3 py-2 rounded-lg border text-xs`,u===`trajectories`?`border-purple-400 text-purple-200 bg-purple-500/10`:`border-shogun-border`),children:`Trajectories`}),(0,G.jsxs)(`button`,{onClick:()=>f(`improvements`),className:I(`px-3 py-2 rounded-lg border text-xs`,u===`improvements`?`border-amber-400 text-amber-200 bg-amber-500/10`:`border-shogun-border`),children:[`Improvements (`,n.length,`)`]}),[`jsonl`,`markdown`,`zip`].map(e=>(0,G.jsxs)(`button`,{onClick:()=>S(e),className:`px-3 py-2 rounded-lg border border-shogun-border text-[10px] uppercase flex items-center gap-1`,children:[(0,G.jsx)(we,{className:`w-3 h-3`}),e]},e)),(0,G.jsx)(`button`,{onClick:_,className:`p-2 rounded-lg border border-shogun-border`,children:(0,G.jsx)(k,{className:I(`w-4 h-4`,p&&`animate-spin`)})})]})]}),h&&(0,G.jsxs)(`div`,{className:`rounded-lg border border-red-500/30 bg-red-500/5 text-red-300 p-3 text-xs flex gap-2`,children:[(0,G.jsx)(N,{className:`w-4 h-4`}),h]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-2`,children:[[`Captured`,e.length,Ae],[`Finalized`,y.length,d],[`Success rate`,y.length?`${Math.round(100*ee/y.length)}%`:`—`,P],[`Average score`,y.length?b.toFixed(2):`—`,me]].map(([e,t,n])=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#050508] border border-shogun-border p-3`,children:[(0,G.jsxs)(`div`,{className:`flex justify-between text-[9px] uppercase text-shogun-subdued`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(n,{className:`w-3.5 h-3.5 text-purple-400`})]}),(0,G.jsx)(`b`,{className:`text-lg mt-1 block`,children:t})]},e))}),te.length>0&&(0,G.jsxs)(`details`,{className:`rounded-lg bg-[#050508] border border-shogun-border`,open:!0,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-xs font-bold uppercase tracking-wider`,children:`Skill Performance`}),(0,G.jsx)(`div`,{className:`overflow-x-auto max-h-52`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`text-[9px] uppercase text-shogun-subdued border-y border-shogun-border`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left px-4 py-2`,children:`Skill`}),(0,G.jsx)(`th`,{children:`Uses`}),(0,G.jsx)(`th`,{children:`Avg score`}),(0,G.jsx)(`th`,{children:`Success`}),(0,G.jsx)(`th`,{children:`Failed`}),(0,G.jsx)(`th`,{children:`Blocked`}),(0,G.jsx)(`th`,{className:`text-right px-4`,children:`Last used`})]})}),(0,G.jsx)(`tbody`,{children:te.map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`px-4 py-2 font-semibold`,children:e.name}),(0,G.jsx)(`td`,{className:`text-center`,children:e.uses}),(0,G.jsx)(`td`,{className:I(`text-center font-mono`,Et(e.average)),children:e.average.toFixed(2)}),(0,G.jsx)(`td`,{className:`text-center text-green-400`,children:e.success}),(0,G.jsx)(`td`,{className:`text-center text-red-400`,children:e.failed}),(0,G.jsx)(`td`,{className:`text-center text-amber-300`,children:e.blocked}),(0,G.jsx)(`td`,{className:`text-right px-4 text-shogun-subdued`,children:e.lastUsed?new Date(e.lastUsed).toLocaleString():`—`})]},e.name))})]})})]}),p&&!e.length?(0,G.jsxs)(`div`,{className:`py-12 flex justify-center gap-2 text-sm text-shogun-subdued`,children:[(0,G.jsx)(F,{className:`w-4 h-4 animate-spin`}),`Loading evidence…`]}):u===`improvements`?(0,G.jsx)(`div`,{className:`grid lg:grid-cols-2 gap-3`,children:n.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg bg-[#050508] border border-amber-500/20 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(be,{className:`w-4 h-4 text-amber-400`}),(0,G.jsx)(`b`,{className:`text-sm`,children:e.skill_name}),(0,G.jsx)(`span`,{className:`ml-auto text-[9px] uppercase text-amber-300`,children:e.priority})]}),(0,G.jsx)(`p`,{className:`text-xs text-red-300 mt-3`,children:e.observed_problem}),(0,G.jsx)(`p`,{className:`text-xs mt-2`,children:e.suggested_improvement}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-2`,children:[`Validate: `,e.validation_idea]}),e.based_on_trajectory_id&&(0,G.jsx)(`button`,{onClick:()=>{f(`trajectories`),x(e.based_on_trajectory_id)},className:`text-[10px] text-purple-300 mt-3`,children:`Open source trajectory →`})]},e.id))}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-2`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(ce,{className:`absolute left-3 top-2.5 w-4 h-4 text-shogun-subdued`}),(0,G.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Search skill, task, run, or model…`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2 text-xs`})]}),(0,G.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),className:`bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs`,children:[(0,G.jsx)(`option`,{value:``,children:`All outcomes`}),[`unknown`,`success`,`partial_success`,`failure`,`blocked`].map(e=>(0,G.jsx)(`option`,{children:e},e))]})]}),(0,G.jsxs)(`div`,{className:`grid lg:grid-cols-5 gap-3`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 overflow-auto max-h-96`,children:[(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`text-[9px] uppercase text-shogun-subdued border-b border-shogun-border`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left py-2`,children:`Skill / task`}),(0,G.jsx)(`th`,{children:`Model`}),(0,G.jsx)(`th`,{children:`Outcome`}),(0,G.jsx)(`th`,{children:`Score`})]})}),(0,G.jsx)(`tbody`,{children:v.map(e=>(0,G.jsxs)(`tr`,{onClick:()=>x(e.id),className:`border-b border-shogun-border/50 hover:bg-purple-500/5 cursor-pointer`,children:[(0,G.jsxs)(`td`,{className:`py-2`,children:[(0,G.jsx)(`b`,{children:e.skill_name}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued max-w-sm truncate`,children:e.task_summary})]}),(0,G.jsx)(`td`,{className:`text-center text-shogun-subdued`,children:e.model_id||e.model_profile||`—`}),(0,G.jsx)(`td`,{className:`text-center uppercase text-[9px]`,children:e.final_outcome}),(0,G.jsx)(`td`,{className:I(`text-center font-mono`,Et(e.score)),children:e.score.toFixed(2)})]},e.id))})]}),!v.length&&(0,G.jsx)(`p`,{className:`text-center text-sm text-shogun-subdued py-10`,children:`No matching trajectories.`})]}),(0,G.jsx)(`div`,{className:`lg:col-span-2 rounded-lg bg-[#050508] border border-shogun-border p-4 max-h-96 overflow-auto`,children:i?(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(Re,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`b`,{children:i.skill_name})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:i.episode?.task_summary}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase text-shogun-subdued`,children:`Selection`}),(0,G.jsx)(`p`,{className:`text-xs`,children:i.episode?.selection_reason})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase text-shogun-subdued`,children:`Timeline`}),(i.trajectory?.events||[]).map((e,t)=>(0,G.jsxs)(`p`,{className:`text-[10px] border-l border-purple-500/30 pl-2 py-1`,children:[(0,G.jsx)(`b`,{children:e.type}),` — `,e.summary]},`${e.timestamp}-${t}`))]}),(0,G.jsxs)(`div`,{className:`text-[10px] text-shogun-subdued`,children:[i.tool_links?.length||0,` linked tools · `,i.verification_links?.length||0,` verifications · `,i.improvement_candidates?.length||0,` improvements`]})]}):(0,G.jsx)(`div`,{className:`h-full flex items-center justify-center text-center text-xs text-shogun-subdued`,children:`Select a trajectory to inspect its full redacted timeline.`})})]})]})]})}var Ot=e=>e?.data?.data??e?.data??e,kt=e=>e?new Date(e).toLocaleString():`Never`;function At(){let[e,t]=(0,W.useState)([]),[n,i]=(0,W.useState)([]),[a,o]=(0,W.useState)(null),[c,l]=(0,W.useState)(``),[u,p]=(0,W.useState)(!0),[m,h]=(0,W.useState)(null),[g,_]=(0,W.useState)(`Write a complete Shogun implementation build paper`),[v,y]=(0,W.useState)(`campaign`),[b,te]=(0,W.useState)(null),[x,S]=(0,W.useState)(null),C=async()=>{p(!0);try{let[e,n]=await Promise.all([R.get(`/api/v1/skills`),R.get(`/api/v1/skills/active-runs`,{params:{limit:100}})]),r=Ot(e)||[];t(r),i(Ot(n)||[]),a&&o(r.find(e=>e.id===a.id)||null)}catch(e){S({kind:`error`,text:e.response?.data?.detail||`Could not load active skill usage.`})}finally{p(!1)}};(0,W.useEffect)(()=>{C()},[]);let w=(0,W.useMemo)(()=>{let t=c.trim().toLowerCase();return t?e.filter(e=>[e.name,e.skill_type,e.status,...e.tags||[]].some(e=>String(e).toLowerCase().includes(t))):e},[e,c]),ne=e.filter(e=>e.status===`installed`).length,T=n.filter(e=>e.outcome===`success`).length,E=async e=>{h(e.id);try{let t=e.status===`disabled`?`enable`:`disable`;await R.post(`/api/v1/skills/${e.id}/${t}`),S({kind:`ok`,text:`${e.name} ${t}d.`}),await C()}catch(e){S({kind:`error`,text:e.response?.data?.detail||`Skill status could not be changed.`})}finally{h(null)}},D=async(e,t)=>{h(`${e.id}:${t}`);try{await R.post(`/api/v1/skills/${e.id}/${t}`),S({kind:`ok`,text:`${e.name}: ${t===`reindex`?`semantic index updated`:`brief rebuilt`}.`}),await C()}catch(e){S({kind:`error`,text:e.response?.data?.detail||`${t} failed.`})}finally{h(null)}};return u&&!e.length?(0,G.jsxs)(`div`,{className:`shogun-card flex items-center justify-center py-24 gap-3 text-shogun-subdued`,children:[(0,G.jsx)(F,{className:`w-5 h-5 animate-spin text-purple-400`}),` Loading active skill usage…`]}):(0,G.jsxs)(`div`,{className:`space-y-5`,children:[x&&(0,G.jsxs)(`div`,{className:I(`rounded-lg border px-4 py-3 text-sm flex items-center gap-2`,x.kind===`ok`?`border-green-500/30 bg-green-500/5 text-green-400`:`border-red-500/30 bg-red-500/5 text-red-400`),children:[x.kind===`ok`?(0,G.jsx)(d,{className:`w-4 h-4`}):(0,G.jsx)(f,{className:`w-4 h-4`}),x.text]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[[`Installed & enabled`,ne,se,`text-green-400`],[`Total activations`,n.length,Ae,`text-purple-400`],[`Successful outcomes`,T,P,`text-cyan-400`],[`Context ceiling`,`2,500 tokens`,r,`text-shogun-gold`]].map(([e,t,n,r])=>(0,G.jsxs)(`div`,{className:`shogun-card !p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest text-shogun-subdued`,children:e}),(0,G.jsx)(n,{className:I(`w-4 h-4`,r)})]}),(0,G.jsx)(`div`,{className:`mt-2 text-xl font-bold text-shogun-text`,children:t})]},e))}),(0,G.jsx)(Dt,{}),(0,G.jsxs)(`div`,{className:`shogun-card border-purple-500/20`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col lg:flex-row lg:items-end gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex-1`,children:[(0,G.jsx)(`label`,{className:`text-[9px] uppercase tracking-widest font-bold text-purple-300`,children:`Activation Preview`}),(0,G.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value),rows:2,className:`mt-2 w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm outline-none focus:border-purple-500`})]}),(0,G.jsx)(`select`,{value:v,onChange:e=>y(e.target.value),className:`bg-[#050508] border border-shogun-border rounded-lg px-3 py-3 text-sm`,children:[`shrine`,`guarded`,`tactical`,`campaign`,`ronin`].map(e=>(0,G.jsx)(`option`,{value:e,children:e.toUpperCase()},e))}),(0,G.jsxs)(`button`,{onClick:async()=>{if(g.trim()){h(`activate`);try{let e=await R.post(`/api/v1/skills/activate`,{run_id:`katana-preview-${Date.now()}`,objective:g,context:`Katana Active Usage preview`,posture:v,available_tools:v===`campaign`||v===`ronin`?[`chat`,`agent_flow`,`stacks`,`ide.file.read`,`ide.file.apply_patch`,`ide.task.run`]:[`chat`,`agent_flow`,`stacks`],max_skills:5,usage_location:`katana_preview`,ide_enabled:v===`campaign`||v===`ronin`});te(Ot(e)),await C()}catch(e){S({kind:`error`,text:e.response?.data?.detail||`Activation preview failed.`})}finally{h(null)}}},disabled:m===`activate`,className:`rounded-lg bg-purple-500/20 border border-purple-400/40 text-purple-200 px-5 py-3 text-xs font-bold uppercase tracking-wider flex items-center justify-center gap-2 disabled:opacity-50`,children:[m===`activate`?(0,G.jsx)(F,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(me,{className:`w-4 h-4`}),` Activate Skills`]})]}),b&&(0,G.jsxs)(`div`,{className:`mt-5 grid lg:grid-cols-3 gap-4 border-t border-shogun-border pt-5`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] uppercase tracking-widest font-bold`,children:[(0,G.jsx)(`span`,{children:`Active for this run`}),(0,G.jsxs)(`span`,{className:`text-purple-300`,children:[b.total_injected_tokens,` tokens`]})]}),b.active_skills.length?b.active_skills.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-purple-500/20 bg-purple-500/5 p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(ge,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`b`,{className:`text-sm`,children:e.name}),(0,G.jsx)(`span`,{className:`ml-auto text-xs font-mono text-purple-300`,children:e.relevance_score.toFixed(2)})]}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:[e.activation_reason,` · `,e.activation_mode,` · `,e.injected_tokens,` tokens`]})]},e.active_skill_run_id)):(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:`No skill crossed the activation threshold.`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[10px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Blocked`}),b.blocked_skills.slice(0,6).map(e=>(0,G.jsxs)(`p`,{className:`text-xs text-orange-300 mt-1`,children:[e.name,`: `,e.blocked_reason]},e.skill_id))]}),b.conflict_notes.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[10px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Conflicts resolved`}),b.conflict_notes.map(e=>(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:e},e))]})]})]})]}),(0,G.jsxs)(`div`,{className:`grid lg:grid-cols-5 gap-5`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,G.jsxs)(`div`,{className:`relative flex-1`,children:[(0,G.jsx)(ce,{className:`w-4 h-4 absolute left-3 top-3 text-shogun-subdued`}),(0,G.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`Search installed skills…`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg py-2.5 pl-9 pr-3 text-sm`})]}),(0,G.jsx)(`button`,{onClick:C,className:`p-2.5 border border-shogun-border rounded-lg`,children:(0,G.jsx)(k,{className:`w-4 h-4`})})]}),(0,G.jsx)(`div`,{className:`space-y-2 max-h-[620px] overflow-y-auto pr-1`,children:w.map(e=>(0,G.jsxs)(`button`,{onClick:()=>o(e),className:I(`w-full text-left rounded-lg border p-3 transition-colors`,a?.id===e.id?`border-purple-500/50 bg-purple-500/5`:`border-shogun-border bg-[#050508] hover:border-shogun-subdued/50`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(r,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`b`,{className:`text-sm truncate`,children:e.name}),(0,G.jsx)(`span`,{className:I(`ml-auto text-[9px] uppercase font-bold`,e.status===`installed`?`text-green-400`:`text-shogun-subdued`),children:e.status}),(0,G.jsx)(s,{className:`w-4 h-4 text-shogun-subdued`})]}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[9px] uppercase tracking-wider text-shogun-subdued`,children:[(0,G.jsx)(`span`,{children:e.skill_type}),(0,G.jsxs)(`span`,{children:[`Exam: `,e.exam_status]}),(0,G.jsxs)(`span`,{children:[e.minimum_posture,`+`]}),(0,G.jsxs)(`span`,{children:[e.usage_count,` uses`]})]})]},e.id))})]}),(0,G.jsx)(`div`,{className:`lg:col-span-2 shogun-card`,children:a?(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest text-purple-300`,children:`Skill Detail`}),(0,G.jsx)(`h3`,{className:`text-xl font-bold mt-1`,children:a.name}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`v`,a.version,` · `,a.activation_mode,` · priority `,a.priority,` · `,a.manifest?.source||`local`]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`button`,{onClick:()=>E(a),disabled:m===a.id,className:I(`flex-1 rounded-lg border py-2 text-xs font-bold uppercase`,a.status===`disabled`?`border-green-500/30 text-green-400`:`border-red-500/30 text-red-300`),children:a.status===`disabled`?`Enable`:`Disable`}),(0,G.jsx)(`button`,{onClick:()=>D(a,`rebuild-brief`),className:`px-3 rounded-lg border border-shogun-border`,title:`Rebuild brief`,children:(0,G.jsx)(ee,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>D(a,`reindex`),className:`px-3 rounded-lg border border-shogun-border`,title:`Reindex`,children:(0,G.jsx)(k,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-center`,children:[(0,G.jsxs)(`div`,{className:`bg-[#050508] rounded p-2`,children:[(0,G.jsx)(`b`,{children:a.usage_count}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:`Uses`})]}),(0,G.jsxs)(`div`,{className:`bg-[#050508] rounded p-2`,children:[(0,G.jsx)(`b`,{className:`text-green-400`,children:a.success_count}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:`Success`})]}),(0,G.jsxs)(`div`,{className:`bg-[#050508] rounded p-2`,children:[(0,G.jsx)(`b`,{className:`text-red-400`,children:a.failure_count}),(0,G.jsx)(`p`,{className:`text-[8px] uppercase text-shogun-subdued`,children:`Failed`})]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued mb-1`,children:`Compact brief`}),(0,G.jsx)(`pre`,{className:`whitespace-pre-wrap text-xs leading-relaxed bg-[#050508] border border-shogun-border rounded-lg p-3 max-h-52 overflow-auto`,children:a.brief_text||`Brief not built yet.`})]}),a.body_text&&(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued cursor-pointer`,children:`Full skill body`}),(0,G.jsx)(`pre`,{className:`mt-2 whitespace-pre-wrap text-xs leading-relaxed bg-[#050508] border border-shogun-border rounded-lg p-3 max-h-72 overflow-auto`,children:a.body_text})]}),a.requires_tools?.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Required tools`}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:a.requires_tools.map(e=>(0,G.jsx)(`code`,{className:`text-[9px] px-2 py-1 rounded bg-cyan-500/5 border border-cyan-500/20 text-cyan-300`,children:e},e))})]}),a.verification_checklist?.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] uppercase tracking-widest font-bold text-shogun-subdued`,children:`Verification checklist`}),a.verification_checklist.map(e=>(0,G.jsxs)(`p`,{className:`text-xs mt-1 flex gap-2`,children:[(0,G.jsx)(d,{className:`w-3.5 h-3.5 text-green-400 shrink-0`}),e]},e))]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[`Last used: `,kt(a.last_used_at)]})]}):(0,G.jsxs)(`div`,{className:`h-full min-h-72 flex flex-col items-center justify-center text-center text-shogun-subdued`,children:[(0,G.jsx)(r,{className:`w-10 h-10 text-purple-400/40 mb-3`}),(0,G.jsx)(`p`,{className:`text-sm`,children:`Select a skill to inspect its brief, compatibility gates, usage, and verification checklist.`})]})})]}),(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,G.jsx)(Ae,{className:`w-4 h-4 text-purple-400`}),(0,G.jsx)(`h3`,{className:`font-bold`,children:`Recent Skill Usage`})]}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,G.jsx)(`thead`,{className:`text-[9px] uppercase tracking-widest text-shogun-subdued border-b border-shogun-border`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`text-left py-2`,children:`Skill`}),(0,G.jsx)(`th`,{className:`text-left`,children:`Where`}),(0,G.jsx)(`th`,{className:`text-left`,children:`Reason`}),(0,G.jsx)(`th`,{children:`Score`}),(0,G.jsx)(`th`,{children:`Tokens`}),(0,G.jsx)(`th`,{children:`Outcome`}),(0,G.jsx)(`th`,{className:`text-right`,children:`When`})]})}),(0,G.jsx)(`tbody`,{children:n.slice(0,30).map(e=>(0,G.jsxs)(`tr`,{className:`border-b border-shogun-border/50`,children:[(0,G.jsx)(`td`,{className:`py-2 font-semibold`,children:e.skill_name||e.skill_id}),(0,G.jsx)(`td`,{children:e.usage_location}),(0,G.jsx)(`td`,{className:`max-w-xs truncate text-shogun-subdued`,children:e.activation_reason}),(0,G.jsx)(`td`,{className:`text-center font-mono`,children:e.relevance_score.toFixed(2)}),(0,G.jsx)(`td`,{className:`text-center`,children:e.injected_tokens}),(0,G.jsx)(`td`,{className:I(`text-center uppercase text-[9px] font-bold`,e.outcome===`success`?`text-green-400`:e.outcome===`failed`?`text-red-400`:`text-shogun-subdued`),children:e.outcome}),(0,G.jsx)(`td`,{className:`text-right text-shogun-subdued`,children:kt(e.created_at)})]},e.id))})]})}),!n.length&&(0,G.jsxs)(`p`,{className:`text-sm text-shogun-subdued py-8 text-center`,children:[(0,G.jsx)(N,{className:`w-4 h-4 inline mr-2`}),`No skill activations recorded yet.`]})]})]})}var jt=[{id:`1`,name:`WebSearchOpt`,description:`Optimized web scraping logic`,status:`optimized`,lastRun:`2026-07-17 10:00`},{id:`2`,name:`DataParser`,description:`JSON and CSV data extraction`,status:`needs_opt`,lastRun:`2026-07-16 14:30`},{id:`3`,name:`TextSummarizer`,description:`NLP summarization routines`,status:`optimizing`,lastRun:`2026-07-17 15:45`}];function Mt(){let{t:e}=L(),[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(!1),[a,o]=(0,W.useState)(!1);return(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-2xl font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(h,{className:`w-6 h-6 text-shogun-gold`}),e(`skillopt.title`,`Skill Optimization Matrix`)]}),(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued mt-1`,children:e(`skillopt.subtitle`,`Monitor, evaluate, and promote AI-generated skill improvements.`)})]}),(0,G.jsxs)(`button`,{className:`flex items-center gap-2 px-4 py-2 bg-shogun-card border border-shogun-border hover:border-shogun-blue/50 rounded-lg text-sm font-medium transition-all`,children:[(0,G.jsx)(k,{className:`w-4 h-4 text-shogun-blue`}),e(`skillopt.refresh`,`Refresh Status`)]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-6`,children:[(0,G.jsx)(`div`,{className:`lg:col-span-1 space-y-4`,children:(0,G.jsxs)(`div`,{className:`shogun-card`,children:[(0,G.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest mb-4 flex items-center gap-2`,children:[(0,G.jsx)(Me,{className:`w-4 h-4 text-shogun-blue`}),e(`skillopt.available_skills`,`Available Skills`)]}),(0,G.jsx)(`div`,{className:`space-y-3`,children:jt.map(e=>(0,G.jsxs)(`button`,{onClick:()=>n(e.id),className:I(`w-full text-left p-4 rounded-xl border transition-all duration-300`,t===e.id?`bg-shogun-blue/10 border-shogun-blue shadow-[0_0_15px_rgba(74,140,199,0.15)]`:`bg-[#050508] border-shogun-border hover:border-shogun-blue/30`),children:[(0,G.jsxs)(`div`,{className:`flex justify-between items-start mb-1`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-shogun-text`,children:e.name}),e.status===`optimized`&&(0,G.jsx)(u,{className:`w-4 h-4 text-green-400`}),e.status===`optimizing`&&(0,G.jsx)(F,{className:`w-4 h-4 text-amber-400 animate-spin`}),e.status===`needs_opt`&&(0,G.jsx)(ae,{className:`w-4 h-4 text-shogun-blue`})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued line-clamp-1`,children:e.description})]},e.id))})]})}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`shogun-card bg-gradient-to-br from-[#050508] to-shogun-card hover:border-shogun-blue/30 transition-colors`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,G.jsx)(`div`,{className:`p-2 bg-shogun-blue/10 rounded-lg`,children:(0,G.jsx)(Ae,{className:`w-5 h-5 text-shogun-blue`})}),(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:e(`skillopt.active_runs`,`Active Runs`)})]}),(0,G.jsx)(`p`,{className:`text-3xl font-bold text-shogun-text mt-2`,children:`1`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:e(`skillopt.currently_optimizing`,`Currently optimizing`)})]}),(0,G.jsxs)(`div`,{className:`shogun-card bg-gradient-to-br from-[#050508] to-shogun-card hover:border-green-500/30 transition-colors`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,G.jsx)(`div`,{className:`p-2 bg-green-500/10 rounded-lg`,children:(0,G.jsx)(he,{className:`w-5 h-5 text-green-400`})}),(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:e(`skillopt.avg_improvement`,`Avg Improvement`)})]}),(0,G.jsx)(`p`,{className:`text-3xl font-bold text-shogun-text mt-2`,children:`+24%`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:e(`skillopt.across_promoted`,`Across all promoted runs`)})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card min-h-[400px] flex flex-col`,children:[(0,G.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-text uppercase tracking-widest mb-4 flex items-center gap-2`,children:[(0,G.jsx)(Le,{className:`w-4 h-4 text-shogun-gold`}),e(`skillopt.candidate_diffs`,`Candidate Diffs & Promotion`)]}),t?(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg p-4 font-mono text-xs overflow-auto relative`,children:[(0,G.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-2`,children:[(0,G.jsx)(`span`,{className:`px-2 py-1 bg-red-500/10 text-red-400 rounded border border-red-500/20`,children:`- 3 lines`}),(0,G.jsx)(`span`,{className:`px-2 py-1 bg-green-500/10 text-green-400 rounded border border-green-500/20`,children:`+ 4 lines`})]}),(0,G.jsxs)(`div`,{className:`text-shogun-subdued mt-6`,children:[(0,G.jsx)(`span`,{className:`text-red-400 block`,children:`- def process_data(data):`}),(0,G.jsx)(`span`,{className:`text-red-400 block`,children:`- # old implementation`}),(0,G.jsx)(`span`,{className:`text-red-400 block`,children:`- return data.split(",")`}),(0,G.jsx)(`span`,{className:`text-green-400 block mt-2`,children:`+ def process_data(data):`}),(0,G.jsx)(`span`,{className:`text-green-400 block`,children:`+ """AI optimized implementation for speed"""`}),(0,G.jsx)(`span`,{className:`text-green-400 block`,children:`+ import re`}),(0,G.jsx)(`span`,{className:`text-green-400 block`,children:`+ return re.split(r",\\s*", data)`})]})]}),(0,G.jsxs)(`div`,{className:`mt-6 flex items-center justify-end gap-3 pt-4 border-t border-shogun-border`,children:[(0,G.jsxs)(`button`,{onClick:()=>{o(!0),setTimeout(()=>o(!1),1500)},disabled:a||r,className:`flex items-center gap-2 px-4 py-2 bg-[#050508] hover:bg-red-500/10 text-shogun-subdued hover:text-red-400 border border-shogun-border hover:border-red-500/50 rounded-lg text-sm font-medium transition-all`,children:[a?(0,G.jsx)(F,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(f,{className:`w-4 h-4`}),e(`skillopt.reject`,`Reject Candidate`)]}),(0,G.jsxs)(`button`,{onClick:()=>{i(!0),setTimeout(()=>i(!1),1500)},disabled:r||a,className:`flex items-center gap-2 px-5 py-2 bg-shogun-gold hover:bg-[#e6b422] text-black rounded-lg text-sm font-bold shadow-[0_0_15px_rgba(212,160,23,0.3)] transition-all`,children:[r?(0,G.jsx)(F,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(C,{className:`w-4 h-4`}),e(`skillopt.promote`,`Promote to Prod`)]})]})]}):(0,G.jsxs)(`div`,{className:`flex-1 flex items-center justify-center text-shogun-subdued flex-col gap-3`,children:[(0,G.jsx)(Be,{className:`w-10 h-10 opacity-20`}),(0,G.jsx)(`p`,{children:e(`skillopt.select_skill`,`Select a skill to view optimization candidates`)})]})]})]})]})]})}function Nt(){let[e,t]=(0,W.useState)([]),[n,r]=(0,W.useState)(``),[i,a]=(0,W.useState)(null),[o,s]=(0,W.useState)(!1),[c,l]=(0,W.useState)(``);(0,W.useEffect)(()=>{R.get(`/api/v1/files/formats`).then(e=>t(e.data.data||[])).catch(()=>l(`Could not load the adapter registry.`))},[]);let u=async()=>{if(n.trim()){s(!0),l(``),a(null);try{let e=await R.post(`/api/v1/files/inspect`,{path:n.trim(),source:`katana`});a(e.data.data)}catch(e){l(e?.response?.data?.detail?.message||e?.response?.data?.detail||`File inspection failed.`)}finally{s(!1)}}};return(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-300`,children:[(0,G.jsx)(`div`,{className:`rounded-xl border border-cyan-400/20 bg-cyan-500/[0.04] p-5`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(P,{className:`h-5 w-5 shrink-0 text-cyan-400`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text`,children:`Broader File Format Handling`}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-shogun-subdued`,children:`Files are detected, safety-checked, parsed deterministically, normalized, and registered before an agent reasons over them. Previews are bounded and likely secrets are masked.`})]})]})}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-bold text-shogun-text`,children:[(0,G.jsx)(Re,{className:`h-4 w-4 text-shogun-gold`}),` Inspect an approved file`]}),(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-shogun-subdued`,children:`Use a file inside the Shogun workspace, uploads, Office, Mado, memory-artifact, or installation workspace boundaries.`})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&u(),placeholder:`C:\\\\...\\\\workspace\\\\orders.csv`,className:`min-w-0 flex-1 rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text outline-none focus:border-shogun-blue`}),(0,G.jsxs)(`button`,{onClick:u,disabled:o||!n.trim(),className:`inline-flex items-center gap-2 rounded-lg bg-shogun-blue px-4 py-2 text-xs font-bold text-white disabled:opacity-50`,children:[o?(0,G.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(ce,{className:`h-4 w-4`}),` Inspect`]})]}),c&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-red-400/25 bg-red-500/5 p-3 text-xs text-red-300`,children:[(0,G.jsx)(N,{className:`h-4 w-4`}),String(c)]}),i&&(0,G.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-shogun-border bg-shogun-bg/60 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(d,{className:`h-4 w-4 text-green-400`}),(0,G.jsx)(`span`,{className:`font-bold text-shogun-text`,children:i.filename}),(0,G.jsx)(`span`,{className:`rounded border border-cyan-400/25 bg-cyan-500/5 px-2 py-0.5 text-[10px] font-bold uppercase text-cyan-300`,children:i.format_id}),(0,G.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[Math.round((i.detection?.confidence||0)*100),`% via `,i.detection?.method]})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:i.summary}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-[10px] md:grid-cols-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`Size`}),(0,G.jsxs)(`span`,{className:`text-shogun-text`,children:[Number(i.size_bytes).toLocaleString(),` bytes`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`Encoding`}),(0,G.jsx)(`span`,{className:`text-shogun-text`,children:i.encoding||`binary`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`File ID`}),(0,G.jsx)(`span`,{className:`break-all text-shogun-text`,children:i.file_id||`not registered`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`block text-shogun-subdued`,children:`SHA-256`}),(0,G.jsxs)(`span`,{className:`break-all text-shogun-text`,children:[i.hash_sha256?.slice(0,16),`…`]})]})]}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(i.capabilities||[]).map(e=>(0,G.jsx)(`span`,{className:`rounded bg-shogun-card px-2 py-1 text-[9px] uppercase text-shogun-subdued`,children:e},e))}),(i.warnings||[]).map(e=>(0,G.jsxs)(`div`,{className:`flex gap-2 text-[10px] text-amber-300`,children:[(0,G.jsx)(N,{className:`h-3.5 w-3.5 shrink-0`}),e]},e)),(0,G.jsxs)(`details`,{className:`text-xs`,children:[(0,G.jsx)(`summary`,{className:`cursor-pointer font-bold text-shogun-blue`,children:`Normalized preview and schema`}),(0,G.jsx)(`pre`,{className:`mt-3 max-h-80 overflow-auto whitespace-pre-wrap rounded-lg bg-black/30 p-3 text-[10px] text-shogun-subdued`,children:JSON.stringify({schema:i.schema,profile:i.data,preview:i.preview},null,2)})]})]})]}),(0,G.jsxs)(`div`,{className:`shogun-card overflow-hidden !p-0`,children:[(0,G.jsxs)(`div`,{className:`border-b border-shogun-border p-5`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text`,children:`Adapter Registry`}),(0,G.jsx)(`p`,{className:`mt-1 text-[11px] text-shogun-subdued`,children:`New proprietary adapters can register here without changing the generic file tool pipeline.`})]}),(0,G.jsx)(`div`,{className:`overflow-x-auto`,children:(0,G.jsxs)(`table`,{className:`w-full text-left text-[10px]`,children:[(0,G.jsx)(`thead`,{className:`bg-shogun-bg uppercase tracking-wider text-shogun-subdued`,children:(0,G.jsxs)(`tr`,{children:[(0,G.jsx)(`th`,{className:`p-3`,children:`Format`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Extensions`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Read`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Write`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Query`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Index`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Risk`}),(0,G.jsx)(`th`,{className:`p-3`,children:`Status`})]})}),(0,G.jsx)(`tbody`,{className:`divide-y divide-shogun-border`,children:e.map(e=>(0,G.jsxs)(`tr`,{className:`text-shogun-subdued`,children:[(0,G.jsx)(`td`,{className:`p-3 font-bold text-shogun-text`,children:e.display_name}),(0,G.jsx)(`td`,{className:`p-3`,children:e.extensions.join(`, `)||`fallback`}),(0,G.jsx)(`td`,{className:`p-3 text-green-400`,children:`Yes`}),(0,G.jsx)(`td`,{className:`p-3`,children:e.supports_write?`Yes`:`—`}),(0,G.jsx)(`td`,{className:`p-3`,children:e.capabilities.includes(`query`)?`Yes`:`—`}),(0,G.jsx)(`td`,{className:`p-3`,children:e.supports_indexing?`Profile`:`—`}),(0,G.jsx)(`td`,{className:`p-3 uppercase`,children:e.risk_level}),(0,G.jsx)(`td`,{className:`p-3 uppercase text-cyan-300`,children:e.status})]},e.format_id))})]})})]})]})}var Pt={display_name:``,email:``,channel:`telegram`,telegram_user_id:``,teams_aad_object_id:``,teams_user_principal_name:``};function q(e){let t=e?.response?.data?.detail;return typeof t==`string`?t:Array.isArray(t)?t.map(e=>e.msg).filter(Boolean).join(` `):e?.message||`The team configuration could not be saved.`}function Ft(){let{t:e}=L(),[t,n]=(0,W.useState)(null),[r,i]=(0,W.useState)(Pt),[a,o]=(0,W.useState)(!0),[s,c]=(0,W.useState)(!1),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(null),m=async()=>{o(!0),p(null);try{let e=await R.get(`/api/v1/team`);n(e.data.data)}catch(e){p(q(e))}finally{o(!1)}};(0,W.useEffect)(()=>{m()},[]);let h=async e=>{if(!(!t||s||t.mode===e)){c(!0),p(null);try{let t=await R.put(`/api/v1/team/mode`,{mode:e});n(t.data.data)}catch(e){p(q(e))}finally{c(!1)}}},g=async()=>{if(!(!t||s)){c(!0),p(null);try{await R.post(`/api/v1/team/members`,{...r,telegram_user_id:r.channel===`telegram`&&r.telegram_user_id.trim()||null,teams_aad_object_id:r.channel===`microsoft_teams`&&r.teams_aad_object_id.trim()||null,teams_user_principal_name:r.channel===`microsoft_teams`&&r.teams_user_principal_name.trim()||null}),i(Pt);let e=await R.get(`/api/v1/team`);n(e.data.data)}catch(e){p(q(e))}finally{c(!1)}}},_=async t=>{if(!(t.is_primary||!window.confirm(`${e(`katana.team.delete_prefix`,`Delete`)} ${t.display_name} ${e(`katana.team.delete_suffix`,`from this Shogun team? Their channel access will be revoked immediately.`)}`))){d(t.id),p(null);try{await R.delete(`/api/v1/team/members/${t.id}`),n(e=>e&&{...e,members:e.members.filter(e=>e.id!==t.id)})}catch(e){p(q(e))}finally{d(null)}}};if(a)return(0,G.jsxs)(`div`,{className:`shogun-card flex items-center gap-3 text-sm text-shogun-subdued`,children:[(0,G.jsx)(F,{className:`h-4 w-4 animate-spin`}),` `,e(`katana.team.loading`,`Loading team configuration…`)]});if(!t)return(0,G.jsx)(`div`,{className:`shogun-card text-sm text-red-300`,children:e(`katana.team.unavailable`,`Team configuration is unavailable.`)});let v=t.members.filter(e=>!e.is_primary);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-center md:justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-bold text-shogun-text`,children:[(0,G.jsx)(De,{className:`h-5 w-5 text-shogun-blue`}),` `,e(`katana.team.title`,`Team Mode`)]}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:e(`katana.team.description`,`Only the Primary Admin uses Tenshu. Team Members communicate through Telegram or Microsoft Teams.`)})]}),(0,G.jsx)(`div`,{className:`inline-flex rounded-lg border border-shogun-border bg-shogun-bg p-1`,role:`group`,"aria-label":`Installation mode`,children:[`single`,`team`].map(n=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>void h(n),disabled:s,className:I(`rounded-md px-4 py-2 text-[10px] font-bold uppercase tracking-widest transition-colors disabled:opacity-50`,t.mode===n?`bg-shogun-blue text-white`:`text-shogun-subdued hover:text-shogun-text`),children:n===`single`?e(`katana.team.single_user`,`Single User`):e(`katana.team.team_mode`,`Team Mode`)},n))})]}),(0,G.jsx)(`div`,{className:I(`rounded-lg border p-3 text-xs`,t.mode===`team`?`border-emerald-500/20 bg-emerald-500/5 text-emerald-300`:`border-amber-500/20 bg-amber-500/5 text-amber-200`),children:t.mode===`team`?`${v.length} ${v.length===1?e(`katana.team.member_active_singular`,`Team Member can currently be recognized through the configured channel.`):e(`katana.team.member_active_plural`,`Team Members can currently be recognized through their configured channels.`)}`:e(`katana.team.single_active`,`Single-user mode is active. Saved Team Members are retained, but all of their channel access is disabled.`)})]}),f&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-red-500/30 bg-red-500/10 p-3 text-sm text-red-300`,children:[(0,G.jsx)(l,{className:`h-4 w-4`}),f]}),(0,G.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(300px,0.7fr)]`,children:[(0,G.jsx)(`div`,{className:`space-y-3`,children:t.members.map(t=>(0,G.jsxs)(`div`,{className:`shogun-card flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 gap-3`,children:[(0,G.jsx)(`div`,{className:I(`rounded-lg p-2`,t.is_primary?`bg-amber-500/10 text-amber-300`:`bg-blue-500/10 text-blue-300`),children:t.is_primary?(0,G.jsx)(P,{className:`h-5 w-5`}):(0,G.jsx)(H,{className:`h-5 w-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-semibold text-shogun-text`,children:t.display_name}),(0,G.jsx)(`span`,{className:`rounded border border-shogun-border px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wider text-shogun-subdued`,children:t.is_primary?e(`katana.team.primary_admin`,`Primary Admin`):t.channel===`telegram`?`Telegram`:`Microsoft Teams`}),(0,G.jsx)(`span`,{className:I(`h-2 w-2 rounded-full`,t.active?`bg-emerald-400`:`bg-shogun-subdued`),title:t.active?e(`katana.team.active`,`Active`):e(`katana.team.disabled`,`Disabled`)})]}),t.email&&(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-shogun-subdued`,children:t.email}),!t.is_primary&&(0,G.jsx)(`p`,{className:`mt-1 break-all font-mono text-[10px] text-shogun-subdued`,children:t.channel===`telegram`?`User ID: ${t.telegram_user_id}`:t.teams_user_principal_name||`Object ID: ${t.teams_aad_object_id}`})]})]}),!t.is_primary&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>void _(t),disabled:u===t.id,className:`rounded-lg p-2 text-shogun-subdued transition-colors hover:bg-red-500/10 hover:text-red-400 disabled:opacity-50`,title:e(`katana.team.delete_member`,`Delete Team Member`),children:u===t.id?(0,G.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(_e,{className:`h-4 w-4`})})]},t.id))}),(0,G.jsxs)(`div`,{className:I(`shogun-card space-y-4 self-start`,t.mode!==`team`&&`opacity-60`),children:[(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 font-bold text-shogun-text`,children:[(0,G.jsx)(oe,{className:`h-4 w-4 text-shogun-blue`}),` `,e(`katana.team.add_member`,`Add Team Member`)]}),(0,G.jsx)(`input`,{value:r.display_name,onChange:e=>i({...r,display_name:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.full_name`,`Full name`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}),(0,G.jsx)(`input`,{value:r.email,onChange:e=>i({...r,email:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.email_optional`,`Email (optional)`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}),(0,G.jsxs)(`select`,{value:r.channel,onChange:e=>i({...r,channel:e.target.value}),disabled:t.mode!==`team`,className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`,children:[(0,G.jsx)(`option`,{value:`telegram`,children:`Telegram`}),(0,G.jsx)(`option`,{value:`microsoft_teams`,children:`Microsoft Teams`})]}),r.channel===`telegram`?(0,G.jsx)(`input`,{value:r.telegram_user_id,onChange:e=>i({...r,telegram_user_id:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.telegram_user_id`,`Telegram user ID`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`input`,{value:r.teams_user_principal_name,onChange:e=>i({...r,teams_user_principal_name:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.teams_email`,`Teams sign-in email`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`}),(0,G.jsx)(`input`,{value:r.teams_aad_object_id,onChange:e=>i({...r,teams_aad_object_id:e.target.value}),disabled:t.mode!==`team`,placeholder:e(`katana.team.entra_id`,`Entra Object ID (optional if email is set)`),className:`w-full rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-sm text-shogun-text outline-none focus:border-shogun-blue disabled:cursor-not-allowed`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>void g(),disabled:t.mode!==`team`||s||!r.display_name.trim()||(r.channel===`telegram`?!r.telegram_user_id.trim():!(r.teams_user_principal_name.trim()||r.teams_aad_object_id.trim())),className:`flex w-full items-center justify-center gap-2 rounded-lg bg-shogun-blue px-4 py-2.5 text-xs font-bold uppercase tracking-wider text-white transition-colors hover:bg-shogun-blue/80 disabled:cursor-not-allowed disabled:opacity-40`,children:[s?(0,G.jsx)(F,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(oe,{className:`h-4 w-4`}),` `,e(`katana.team.add_button`,`Add Member`)]}),(0,G.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued`,children:e(`katana.team.memory_notice`,`Each member receives a separate memory identity. Deleting a member revokes access and archives that member’s private memory slot.`)})]})]})]})}var It={google:{label:`Gemini Model Reference`,url:`https://ai.google.dev/gemini-api/docs/models`},openai:{label:`OpenAI Model Reference`,url:`https://platform.openai.com/docs/models`},anthropic:{label:`Claude Model Overview`,url:`https://platform.claude.com/docs/en/about-claude/models/overview`},openrouter:{label:`OpenRouter Model Catalog`,url:`https://openrouter.ai/models`}},Lt={openai:`https://api.openai.com/v1`,google:`https://generativelanguage.googleapis.com/v1beta/openai`,anthropic:`https://api.anthropic.com/v1`,openrouter:`https://openrouter.ai/api/v1`,ollama:`http://127.0.0.1:11434`,lmstudio:`http://localhost:1234/v1`,local:`http://localhost:1234/v1`,custom:``},Rt=[`ollama`,`lmstudio`,`local`],zt=e=>Rt.includes(e),Bt=[`api`,`tool`,`mcp`,`filesystem`,`database`,`queue`,`custom`],Vt=[`api_key`,`oauth`,`token`,`custom`,`none`],Ht=[`low`,`medium`,`high`,`critical`],Ut=[{name:`OpenWeatherMap`,description:`Current weather, 5-day forecasts, and 40+ year historical data for any location.`,base_url:`https://api.openweathermap.org/data/2.5`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`WeatherAPI`,description:`Real-time, forecast, and historical weather covering astronomy, air quality and alerts.`,base_url:`https://api.weatherapi.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open-Meteo`,description:`Free, open-source weather API with hourly forecasts and no API key required.`,base_url:`https://api.open-meteo.com/v1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Tomorrow.io`,description:`Hyper-local weather intelligence with AI-powered forecasting.`,base_url:`https://api.tomorrow.io/v4`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NOAA NGDC`,description:`Natural hazards data including earthquakes, tsunamis, and volcanic eruptions.`,base_url:`https://www.ngdc.noaa.gov/hazel/hazard-service/api/v1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Air Quality Index`,description:`Real-time air quality data including AQI and pollutant concentrations for worldwide locations.`,base_url:`https://api.api-ninjas.com/v1/airquality`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Storm Glass`,description:`Marine weather, solar and wind energy data, and tide forecasts from premium sources.`,base_url:`https://api.stormglass.io/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Météo-France`,description:`Official French meteorological service API — forecasts, radar, and climatology.`,base_url:`https://public-api.meteofrance.fr/public`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NASA APOD`,description:`Astronomy Picture of the Day with title, explanation, and image URL.`,base_url:`https://api.nasa.gov/planetary/apod`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NASA Exoplanet Archive`,description:`Confirmed exoplanet data from the NASA Exoplanet Science Institute.`,base_url:`https://exoplanetarchive.ipac.caltech.edu/TAP`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Open Notify ISS`,description:`Real-time position of the International Space Station and crew on board.`,base_url:`http://api.open-notify.org`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`SpaceX API`,description:`Data on SpaceX launches, rockets, capsules, crew, and Starlink satellites.`,base_url:`https://api.spacexdata.com/v4`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Newton API`,description:`Micro-service for advanced math operations — simplify, factor, derive, integrate.`,base_url:`https://newton.vercel.app/api/v2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Numbers API`,description:`Interesting facts about numbers — trivia, math, dates, and years.`,base_url:`http://numbersapi.com`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Wolfram Alpha`,description:`Computational intelligence: solve math, science, and data questions via natural language.`,base_url:`https://api.wolframalpha.com/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`USGS Earthquake Hazards`,description:`Real-time earthquake data from the US Geological Survey feed.`,base_url:`https://earthquake.usgs.gov/fdsnws/event/1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`WoRMS`,description:`Authoritative global list of marine species names and taxonomy.`,base_url:`https://www.marinespecies.org/rest`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`GitHub`,description:`Repos, issues, pull requests, Actions, Gists, and more.`,base_url:`https://api.github.com`,auth_type:`token`,connector_type:`api`,risk_level:`medium`},{name:`GitLab`,description:`Full DevSecOps platform — repos, CI/CD, merge requests, and packages.`,base_url:`https://gitlab.com/api/v4`,auth_type:`api_key`,connector_type:`api`,risk_level:`medium`},{name:`SerpApi`,description:`Structured Google, Bing, and DuckDuckGo SERP data via a scraping API.`,base_url:`https://serpapi.com/search`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Hacker News`,description:`Official HN API — stories, jobs, polls, comments, and user profiles.`,base_url:`https://hacker-news.firebaseio.com/v0`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`npm Registry`,description:`Search packages, fetch metadata, download stats from the npm registry.`,base_url:`https://registry.npmjs.org`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`PyPI`,description:`Python Package Index — package metadata, releases, and dependencies.`,base_url:`https://pypi.org/pypi`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Codeforces`,description:`Competitive programming — problems, submissions, contests, and user ratings.`,base_url:`https://codeforces.com/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`JDoodle`,description:`Online compiler and code execution API — 70+ programming languages.`,base_url:`https://api.jdoodle.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Transport for London`,description:`Live tube, bus, bike, and Elizabeth line data from TfL Unified API.`,base_url:`https://api.tfl.gov.uk`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`OpenSky Network`,description:`Real-time and historical flight tracking data — global ADS-B coverage.`,base_url:`https://opensky-network.org/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`AviationStack`,description:`Global real-time flight status, airline routes, and airport information.`,base_url:`https://api.aviationstack.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`MTA Realtime Feeds`,description:`NYC subway real-time GTFS and arrival feeds from the Metropolitan Transit Authority.`,base_url:`https://api-endpoint.mta.info/Dataservice`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`BART (SF Bay Area)`,description:`San Francisco Bay Area Rapid Transit real-time departure estimates and station info.`,base_url:`https://api.bart.gov/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Citybikes`,description:`Bike-sharing station availability from 400+ networks worldwide.`,base_url:`https://api.citybik.es/v2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`CarAPI`,description:`Make, model, trims and specs for vehicles — developer-friendly vehicle data.`,base_url:`https://carapi.app/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Uber`,description:`Request rides, get price estimates, and query trip history via the Uber API.`,base_url:`https://api.uber.com/v1.2`,auth_type:`oauth`,connector_type:`api`,risk_level:`medium`},{name:`Carbon Interface`,description:`Estimate carbon emissions for flights, vehicles, electricity, and shipping.`,base_url:`https://www.carboninterface.com/api/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`1ClickImpact`,description:`Environmental impact API — tree planting, carbon offsetting, and ocean cleanup.`,base_url:`https://api.1clickimpact.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Global Fishing Watch`,description:`Vessel tracking, fishing activity detection, and ocean monitoring data.`,base_url:`https://gateway.api.globalfishingwatch.org/v3`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`EPA AQS`,description:`US EPA Air Quality System — historical and current ambient air monitoring data.`,base_url:`https://aqs.epa.gov/data/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open FDA`,description:`US FDA data — drug labels, adverse events, recalls, and device reports.`,base_url:`https://api.fda.gov`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`National Library of Medicine UMLS`,description:`Unified Medical Language System — medical concepts, relationships, and terminology.`,base_url:`https://uts-ws.nlm.nih.gov/rest`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Nutritionix`,description:`Nutrition data for foods and restaurant menu items — natural language NLP queries.`,base_url:`https://trackapi.nutritionix.com/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Disease.sh`,description:`COVID-19 and global disease statistics — countries, vaccines, and historical data.`,base_url:`https://disease.sh/v3`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`TheMealDB`,description:`1,000+ international recipes with ingredients, measures, and instructional videos.`,base_url:`https://www.themealdb.com/api/json/v1/1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`TheCocktailDB`,description:`Cocktail recipes, ingredients, and drink images from a crowd-sourced database.`,base_url:`https://www.thecocktaildb.com/api/json/v1/1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Open Food Facts`,description:`Collaborative food product database — ingredients, nutritional facts, and barcode lookup.`,base_url:`https://world.openfoodfacts.org/api/v3`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Spoonacular`,description:`Recipe search, meal planning, ingredient parsing, and wine pairing.`,base_url:`https://api.spoonacular.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`API-Football`,description:`Live scores, fixtures, standings, and stats for 900+ football leagues worldwide.`,base_url:`https://v3.football.api-sports.io`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`iSports API`,description:`Live and historical data for global competitions — scores, fixtures, and player stats.`,base_url:`https://api.isportsapi.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`NBA Stats`,description:`Comprehensive NBA player statistics, advanced metrics, and game data.`,base_url:`https://stats.nba.com/stats`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Fantasy Premier League`,description:`FPL player data, fixtures, team standings, and gameweek history.`,base_url:`https://fantasy.premierleague.com/api`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Ergast Motor Racing`,description:`Formula 1 race data — results, standings, lap times, and pit stops since 1950.`,base_url:`https://ergast.com/api/f1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`NewsAPI`,description:`Search and retrieve news articles from 150,000+ sources worldwide in real time.`,base_url:`https://newsapi.org/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`World News API`,description:`Search through millions of semantically tagged worldwide news articles.`,base_url:`https://api.worldnewsapi.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Guardian`,description:`Full-text access to The Guardian newspaper — 2M+ articles since 1999.`,base_url:`https://content.guardianapis.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`New York Times`,description:`Article search, Top Stories, Books Bestsellers, and Movie Reviews APIs.`,base_url:`https://api.nytimes.com/svc`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open Library`,description:`Internet Archive open library — 20M+ book records, covers, and editions.`,base_url:`https://openlibrary.org/api`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Google Books`,description:`Search 40M+ books, retrieve metadata, previews, and reading links.`,base_url:`https://www.googleapis.com/books/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Wikipedia`,description:`Access Wikipedia article summaries, sections, and linked data via REST.`,base_url:`https://en.wikipedia.org/api/rest_v1`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Spotify`,description:`Tracks, artists, albums, playlists, audio features, and playback control.`,base_url:`https://api.spotify.com/v1`,auth_type:`oauth`,connector_type:`api`,risk_level:`medium`},{name:`Last.fm`,description:`Scrobbling, artist bios, top tracks, and music charts from a 50M listener community.`,base_url:`https://ws.audioscrobbler.com/2.0`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`MusicBrainz`,description:`Open music encyclopedia — artists, recordings, releases, and relationships.`,base_url:`https://musicbrainz.org/ws/2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`Data USA`,description:`Visualise and query US demographic, economic, and educational data.`,base_url:`https://datausa.io/api/data`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`US Census Bureau`,description:`American Community Survey — population, income, housing, and demographics.`,base_url:`https://api.census.gov/data`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`World Bank`,description:`Global development indicators — GDP, poverty, health, education, and more.`,base_url:`https://api.worldbank.org/v2`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`civicAPI`,description:`Live and historic election results and voter registration data from around the world.`,base_url:`https://civicapi.com/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Data Commons (Google)`,description:`Global disaster events, climate, and statistics maintained as an open knowledge graph.`,base_url:`https://api.datacommons.org`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Stripe`,description:`Payment processing, subscriptions, invoices, and billing for businesses.`,base_url:`https://api.stripe.com/v1`,auth_type:`api_key`,connector_type:`api`,risk_level:`high`},{name:`CoinGecko`,description:`Crypto market data — prices, volumes, OHLC, and market cap for 10,000+ coins.`,base_url:`https://api.coingecko.com/api/v3`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Alpha Vantage`,description:`Stock, ETF, forex, and crypto time-series and fundamental data.`,base_url:`https://www.alphavantage.co`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Polygon.io`,description:`Real-time and historical US and global stock market data with WebSocket support.`,base_url:`https://api.polygon.io/v2`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Open Exchange Rates`,description:`Real-time and historical currency exchange rates for 190+ currencies.`,base_url:`https://openexchangerates.org/api`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`Twilio`,description:`SMS, voice, WhatsApp, and email communications at global scale.`,base_url:`https://api.twilio.com/2010-04-01`,auth_type:`api_key`,connector_type:`api`,risk_level:`medium`},{name:`SendGrid`,description:`Transactional and marketing email delivery API with analytics.`,base_url:`https://api.sendgrid.com/v3`,auth_type:`api_key`,connector_type:`api`,risk_level:`medium`},{name:`Slack`,description:`Send messages, create channels, manage workspaces, and build apps.`,base_url:`https://slack.com/api`,auth_type:`oauth`,connector_type:`api`,risk_level:`medium`},{name:`Mapbox`,description:`Custom maps, geocoding, navigation, isochrones, and elevation data.`,base_url:`https://api.mapbox.com`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`},{name:`OpenStreetMap Nominatim`,description:`Free geocoding and reverse-geocoding based on OpenStreetMap data.`,base_url:`https://nominatim.openstreetmap.org`,auth_type:`none`,connector_type:`api`,risk_level:`low`},{name:`IPinfo`,description:`IP geolocation, ASN, carrier, and privacy detection data.`,base_url:`https://ipinfo.io`,auth_type:`api_key`,connector_type:`api`,risk_level:`low`}],Wt=[{name:`Brave Search`,description:`Web and local search via the Brave Search API.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-brave-search`],env_keys:[`BRAVE_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-brave-search`},{name:`Tavily Search`,description:`AI-optimized search engine for LLMs and RAG pipelines.`,command:`npx`,args:[`-y`,`tavily-mcp@latest`],env_keys:[`TAVILY_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/tavily-ai/tavily-mcp`,npm_package:`tavily-mcp`},{name:`Exa Search`,description:`Neural search engine for finding relevant content.`,command:`npx`,args:[`-y`,`@exa-labs/exa-mcp-server`],env_keys:[`EXA_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/exa-labs/exa-mcp-server`,npm_package:`@exa-labs/exa-mcp-server`},{name:`SerpAPI`,description:`Google, Bing, Yahoo and other search engine results.`,command:`npx`,args:[`-y`,`serpapi-mcp-server`],env_keys:[`SERPAPI_API_KEY`],transport:`stdio`,category:`Search`,risk_level:`low`,github_url:`https://github.com/serpapi/serpapi-mcp`,npm_package:`serpapi-mcp-server`},{name:`Puppeteer`,description:`Browser automation and web scraping using Puppeteer.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-puppeteer`],env_keys:[],transport:`stdio`,category:`Web Scraping`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-puppeteer`},{name:`Playwright`,description:`Browser automation across Chromium, Firefox, and WebKit.`,command:`npx`,args:[`-y`,`@executeautomation/playwright-mcp-server`],env_keys:[],transport:`stdio`,category:`Web Scraping`,risk_level:`medium`,github_url:`https://github.com/executeautomation/playwright-mcp-server`,npm_package:`@executeautomation/playwright-mcp-server`},{name:`Firecrawl`,description:`Web scraping and crawling with AI-ready markdown output.`,command:`npx`,args:[`-y`,`firecrawl-mcp`],env_keys:[`FIRECRAWL_API_KEY`],transport:`stdio`,category:`Web Scraping`,risk_level:`medium`,github_url:`https://github.com/mendableai/firecrawl-mcp`,npm_package:`firecrawl-mcp`},{name:`Fetch`,description:`Fetch and convert web pages to markdown or plain text.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-fetch`],env_keys:[],transport:`stdio`,category:`Web Scraping`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-fetch`},{name:`GitHub`,description:`Repository management, file operations, issues, PRs, and more.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-github`],env_keys:[`GITHUB_PERSONAL_ACCESS_TOKEN`],transport:`stdio`,category:`Development`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-github`},{name:`GitLab`,description:`Project management, issues, merge requests, and CI/CD on GitLab.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-gitlab`],env_keys:[`GITLAB_PERSONAL_ACCESS_TOKEN`,`GITLAB_API_URL`],transport:`stdio`,category:`Development`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-gitlab`},{name:`Context7`,description:`Up-to-date, version-specific library docs and code examples.`,command:`npx`,args:[`-y`,`@upstash/context7-mcp@latest`],env_keys:[],transport:`stdio`,category:`Development`,risk_level:`low`,github_url:`https://github.com/upstash/context7-mcp`,npm_package:`@upstash/context7-mcp`},{name:`Sentry`,description:`Error monitoring, performance data, and issue management.`,command:`npx`,args:[`-y`,`@sentry/mcp-server`],env_keys:[`SENTRY_AUTH_TOKEN`],transport:`stdio`,category:`Development`,risk_level:`low`,github_url:`https://github.com/getsentry/sentry-mcp`,npm_package:`@sentry/mcp-server`},{name:`PostgreSQL`,description:`Query and manage PostgreSQL databases with schema inspection.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-postgres`],env_keys:[`POSTGRES_CONNECTION_STRING`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-postgres`},{name:`SQLite`,description:`Query and manage SQLite databases and run business analytics.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-sqlite`],env_keys:[`SQLITE_DB_PATH`],transport:`stdio`,category:`Database`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-sqlite`},{name:`MySQL`,description:`Query and manage MySQL databases.`,command:`npx`,args:[`-y`,`@benborla29/mcp-server-mysql`],env_keys:[`MYSQL_HOST`,`MYSQL_USER`,`MYSQL_PASSWORD`,`MYSQL_DATABASE`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/benborla/mcp-server-mysql`,npm_package:`@benborla29/mcp-server-mysql`},{name:`MongoDB`,description:`CRUD operations, aggregation, and index management for MongoDB.`,command:`npx`,args:[`-y`,`mongodb-mcp-server`],env_keys:[`MONGODB_URI`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/mongodb-js/mongodb-mcp-server`,npm_package:`mongodb-mcp-server`},{name:`Redis`,description:`Key-value operations, pub/sub, and data structure management.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-redis`],env_keys:[`REDIS_URL`],transport:`stdio`,category:`Database`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-redis`},{name:`Supabase`,description:`Database, auth, storage, and edge functions on Supabase.`,command:`npx`,args:[`-y`,`@supabase/mcp-server-supabase@latest`],env_keys:[`SUPABASE_ACCESS_TOKEN`],transport:`stdio`,category:`Database`,risk_level:`high`,github_url:`https://github.com/supabase-community/supabase-mcp`,npm_package:`@supabase/mcp-server-supabase`},{name:`Slack`,description:`Send messages, manage channels, and search across workspaces.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-slack`],env_keys:[`SLACK_BOT_TOKEN`,`SLACK_TEAM_ID`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-slack`},{name:`Google Drive`,description:`Search, read, and manage files in Google Drive.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-gdrive`],env_keys:[`GDRIVE_CREDENTIALS_PATH`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-gdrive`},{name:`Notion`,description:`Search, read, create, and update pages and databases in Notion.`,command:`npx`,args:[`-y`,`@notionhq/notion-mcp-server`],env_keys:[`NOTION_API_KEY`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/makenotion/notion-mcp-server`,npm_package:`@notionhq/notion-mcp-server`},{name:`Linear`,description:`Manage issues, projects, and teams in Linear.`,command:`npx`,args:[`-y`,`@linear/mcp-server`],env_keys:[`LINEAR_API_KEY`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/linear/linear-mcp-server`,npm_package:`@linear/mcp-server`},{name:`Todoist`,description:`Manage tasks, projects, and labels in Todoist.`,command:`npx`,args:[`-y`,`@abhiz123/todoist-mcp-server`],env_keys:[`TODOIST_API_TOKEN`],transport:`stdio`,category:`Productivity`,risk_level:`low`,github_url:`https://github.com/abhiz123/todoist-mcp-server`,npm_package:`@abhiz123/todoist-mcp-server`},{name:`Atlassian`,description:`Manage Jira issues, Confluence pages, and Opsgenie alerts.`,command:`npx`,args:[`-y`,`@anthropic/atlassian-mcp-server`],env_keys:[`ATLASSIAN_API_TOKEN`,`ATLASSIAN_EMAIL`,`ATLASSIAN_DOMAIN`],transport:`stdio`,category:`Productivity`,risk_level:`medium`,github_url:`https://github.com/atlassian/atlassian-mcp-server`,npm_package:`@anthropic/atlassian-mcp-server`},{name:`Gmail`,description:`Send, read, search, and manage emails via Gmail API.`,command:`npx`,args:[`-y`,`@anthropic/gmail-mcp-server`],env_keys:[`GMAIL_CREDENTIALS_PATH`],transport:`stdio`,category:`Communication`,risk_level:`high`,github_url:`https://github.com/anthropics/gmail-mcp-server`,npm_package:`@anthropic/gmail-mcp-server`},{name:`Discord`,description:`Send and read messages, manage channels in Discord.`,command:`npx`,args:[`-y`,`discord-mcp`],env_keys:[`DISCORD_BOT_TOKEN`],transport:`stdio`,category:`Communication`,risk_level:`medium`,github_url:`https://github.com/v-3/discord-mcp`,npm_package:`discord-mcp`},{name:`AWS`,description:`Manage AWS resources and services via CLI commands.`,command:`npx`,args:[`-y`,`@aws/aws-mcp-server`],env_keys:[`AWS_ACCESS_KEY_ID`,`AWS_SECRET_ACCESS_KEY`,`AWS_REGION`],transport:`stdio`,category:`Cloud`,risk_level:`critical`,github_url:`https://github.com/awslabs/mcp`,npm_package:`@aws/aws-mcp-server`},{name:`Cloudflare`,description:`Deploy and configure Workers, KV, R2, D1 on Cloudflare.`,command:`npx`,args:[`-y`,`@cloudflare/mcp-server-cloudflare`],env_keys:[`CLOUDFLARE_API_TOKEN`],transport:`stdio`,category:`Cloud`,risk_level:`high`,github_url:`https://github.com/cloudflare/mcp-server-cloudflare`,npm_package:`@cloudflare/mcp-server-cloudflare`},{name:`Vercel`,description:`Manage deployments, projects, and domains on Vercel.`,command:`npx`,args:[`-y`,`@vercel/mcp-adapter`],env_keys:[`VERCEL_TOKEN`],transport:`stdio`,category:`Cloud`,risk_level:`high`,github_url:`https://github.com/vercel/mcp-adapter`,npm_package:`@vercel/mcp-adapter`},{name:`Docker`,description:`Manage containers, images, volumes, and networks.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-docker`],env_keys:[],transport:`stdio`,category:`Cloud`,risk_level:`high`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-docker`},{name:`Filesystem`,description:`Secure file operations with configurable access controls.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-filesystem`],env_keys:[],transport:`stdio`,category:`File System`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-filesystem`},{name:`Google Cloud Storage`,description:`Read and write files in Google Cloud Storage buckets.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-gcs`],env_keys:[`GCS_CREDENTIALS_PATH`],transport:`stdio`,category:`File System`,risk_level:`medium`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-gcs`},{name:`Stripe`,description:`Manage payments, customers, invoices, and subscriptions.`,command:`npx`,args:[`-y`,`@stripe/mcp@latest`],env_keys:[`STRIPE_SECRET_KEY`],transport:`stdio`,category:`Finance`,risk_level:`critical`,github_url:`https://github.com/stripe/agent-toolkit`,npm_package:`@stripe/mcp`},{name:`Qdrant`,description:`Vector search, similarity queries, and collection management.`,command:`npx`,args:[`-y`,`@qdrant/mcp-server-qdrant`],env_keys:[`QDRANT_URL`,`QDRANT_API_KEY`],transport:`stdio`,category:`AI / Memory`,risk_level:`medium`,github_url:`https://github.com/qdrant/mcp-server-qdrant`,npm_package:`@qdrant/mcp-server-qdrant`},{name:`Memory`,description:`Persistent memory using a local knowledge graph.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-memory`],env_keys:[],transport:`stdio`,category:`AI / Memory`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-memory`},{name:`Sequential Thinking`,description:`Dynamic, reflection-based problem-solving through thought sequences.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-sequential-thinking`],env_keys:[],transport:`stdio`,category:`Utilities`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-sequential-thinking`},{name:`Everything`,description:`Reference MCP server that demonstrates all protocol features.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-everything`],env_keys:[],transport:`stdio`,category:`Utilities`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-everything`},{name:`Time`,description:`Get current time and convert between time zones.`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-time`],env_keys:[],transport:`stdio`,category:`Utilities`,risk_level:`low`,github_url:`https://github.com/modelcontextprotocol/servers`,npm_package:`@modelcontextprotocol/server-time`}],Gt=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``),Kt=e=>({low:`text-green-400 border-green-400/30 bg-green-400/5`,medium:`text-yellow-400 border-yellow-400/30 bg-yellow-400/5`,high:`text-orange-400 border-orange-400/30 bg-orange-400/5`,critical:`text-red-400 border-red-400/30 bg-red-400/5`})[e];function qt(){let e=Se(),[r,o]=(0,W.useState)(`providers`);(0,W.useEffect)(()=>{let e=()=>{let e=window.location.hash.replace(`#`,``);[`providers`,`tools`,`files`,`routing`,`skills`,`team`,`telegram`,`teams`,`mail_calendar`,`office`,`ide`,`mado`,`ronin`,`skillopt`].includes(e)&&o(e)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let{t:u}=L(),[f,p]=(0,W.useState)(null),[m,x]=(0,W.useState)(``),[C,T]=(0,W.useState)(`polling`),[re,ie]=(0,W.useState)(``),[ae,O]=(0,W.useState)(``),[A,ue]=(0,W.useState)(``),[de,fe]=(0,W.useState)(!1),[me,ge]=(0,W.useState)(!1),[M,N]=(0,W.useState)(null),[Te,Ee]=(0,W.useState)(!1),[Oe,Ae]=(0,W.useState)(!1),[Me,Pe]=(0,W.useState)([]),[Ie,Le]=(0,W.useState)({}),[Re,ze]=(0,W.useState)(null),[z,Be]=(0,W.useState)(null),[B,V]=(0,W.useState)({provider:`gmail`,display_name:``,email_address:``,protocol:`imap`,imap_host:`imap.gmail.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.gmail.com`,smtp_port:587,smtp_use_ssl:!0,username:``,password:``,caldav_url:`https://apidata.googleusercontent.com/caldav/v1/calendars/primary/events`,calendar_provider:`google_api`,calendar_credentials:null}),[He,We]=(0,W.useState)(!1),[Ge,Ke]=(0,W.useState)(!1),[qe,Ye]=(0,W.useState)(null),[Xe,Qe]=(0,W.useState)({perm_read_mail:!0,perm_send_mail:!1,perm_delete_mail:!1,perm_read_calendar:!0,perm_create_events:!1,perm_edit_events:!1,perm_delete_events:!1}),[$e,et]=(0,W.useState)(!1),[tt,nt]=(0,W.useState)(null),[K,rt]=(0,W.useState)(null),[it,at]=(0,W.useState)(``),[ot,st]=(0,W.useState)(!1),[ct,lt]=(0,W.useState)(!1),[ut,ft]=(0,W.useState)(!1),pt=async()=>{try{let[e,t,n]=await Promise.all([R.get(`/api/v1/office/status`),R.get(`/api/v1/office/config`),R.get(`/api/v1/security/posture`)]);e.data?.success&&nt(e.data.data),t.data?.success&&rt(t.data.data),n.data?.data?.active_tier&&at(n.data.data.active_tier)}catch(e){console.error(`Failed to load Office data:`,e)}},mt=async()=>{if(K){st(!0);try{let e=await R.post(`/api/v1/office/config`,K);e.data?.success&&(rt(e.data.data),ft(!1),q({type:`success`,text:`Office configuration saved`}),setTimeout(()=>q(null),3e3))}catch{q({type:`error`,text:`Failed to save Office configuration`}),setTimeout(()=>q(null),3e3)}finally{st(!1)}}},ht=async()=>{lt(!0);try{await R.post(`/api/v1/office/detect`),await pt()}catch(e){console.error(`Detection failed:`,e)}finally{lt(!1)}},gt=(e,t)=>{if(!K)return;let n=e.split(`.`),r=JSON.parse(JSON.stringify(K)),i=r;for(let e=0;e{let e=St.find(e=>e.status===`connected`&&zt(e.provider_type));zt(J.provider_type)?(Cr(J.provider_type,J.base_url),Zt||(J.provider_type===`ollama`?Qt(`%USERPROFILE%\\.ollama\\models`):Qt(``))):e?Cr(e.provider_type,e.base_url):(Ot([]),Qt(``))},[J.provider_type,J.base_url,St]);let[rn,an]=(0,W.useState)(`all`),[on,sn]=(0,W.useState)(null),[cn,ln]=(0,W.useState)(null),[un,dn]=(0,W.useState)(``),[fn,pn]=(0,W.useState)(``),[mn,hn]=(0,W.useState)([]),[gn,_n]=(0,W.useState)(!1),[vn,yn]=(0,W.useState)(1),[bn,xn]=(0,W.useState)(!1),[Sn,Cn]=(0,W.useState)(!1),wn=async(e,t,n=!1)=>{t===1?_n(!0):Cn(!0);try{let r={};e.trim()&&(r.q=e.trim()),t>1&&(r.p=String(t)),rn!==`all`&&(r.c=rn);let i=await R.get(`/api/v1/system/ollama-search`,{params:r});if(i.data?.success){let e=i.data.data;hn(t=>n?[...t,...e.models]:e.models),xn(e.has_more),yn(e.page)}}catch{n||hn([])}finally{_n(!1),Cn(!1)}};(0,W.useEffect)(()=>{if(!tn)return;let e=setTimeout(()=>{wn(fn,1,!1)},300);return()=>clearTimeout(e)},[fn,rn,tn]),(0,W.useEffect)(()=>{tn&&mn.length===0&&wn(``,1,!1)},[tn]);let[Tn,En]=(0,W.useState)(!1),[Dn,On]=(0,W.useState)(`quick`),[kn,An]=(0,W.useState)(``),[Y,jn]=(0,W.useState)(null),[Mn,Nn]=(0,W.useState)(!1),[Pn,Fn]=(0,W.useState)(``),[X,In]=(0,W.useState)({name:``,slug:``,base_url:``,connector_type:`api`,auth_type:`api_key`,risk_level:`low`}),[Ln,Rn]=(0,W.useState)(!1),[zn,Bn]=(0,W.useState)(`quick`),[Vn,Hn]=(0,W.useState)(``),[Z,Un]=(0,W.useState)(null),[Wn,Gn]=(0,W.useState)({}),[Q,Kn]=(0,W.useState)({name:``,command:``,args:``,transport:`stdio`,risk_level:`medium`}),qn=(0,W.useMemo)(()=>{if(!Vn.trim())return Wt;let e=Vn.toLowerCase();return Wt.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.category.toLowerCase().includes(e))},[Vn]),[Jn,Yn]=(0,W.useState)([]),[Xn,Zn]=(0,W.useState)(!1),[Qn,$n]=(0,W.useState)(!1),[er,tr]=(0,W.useState)(!1),[nr,rr]=(0,W.useState)(null),[ir,ar]=(0,W.useState)(!1),[or,sr]=(0,W.useState)({name:``,description:``,is_default:!1}),[$,cr]=(0,W.useState)({task_type:`*`,primary_model_id:``,fallback_model_ids:[],latency_bias:``,cost_bias:``}),[lr,ur]=(0,W.useState)(null);(0,W.useEffect)(()=>{dr()},[]);let dr=async()=>{yt(!0);try{let[e,t,n]=await Promise.all([R.get(`/api/v1/model-providers`),R.get(`/api/v1/tools`),R.get(`/api/v1/model-routing-profiles`)]);wt(e.data.data||[]),Et(t.data.data||[]),Yn(n.data.data||[])}catch(e){console.error(`Error fetching Katana data:`,e)}finally{yt(!1)}},fr=async()=>{try{let[e,t]=await Promise.all([R.get(`/api/v1/channels/telegram/status`),R.get(`/api/v1/channels/telegram/topics`)]),n=e.data.data;p(n),n?.mode&&T(n.mode),n?.allowed_chat_ids?.length&&O(n.allowed_chat_ids.join(`, `)),n?.webhook_url&&ie(n.webhook_url||``);let r=t.data.data||[];Pe(r);let i={};r.forEach(e=>(e.topics||[]).forEach(t=>{i[`${e.chat_id}:${t.message_thread_id}`]=t.name||``})),Le(i)}catch{}},pr=async(e,t)=>{let n=`${e}:${t}`,r=(Ie[n]||``).trim();if(r){ze(n);try{await R.put(`/api/v1/channels/telegram/topics/${encodeURIComponent(e)}/${t}`,{name:r}),await fr(),q({type:`success`,text:`Telegram topic ${t} mapped to “${r}”.`})}catch(e){q({type:`error`,text:e?.response?.data?.detail||`Topic mapping could not be saved.`})}finally{ze(null),setTimeout(()=>q(null),4e3)}}},mr=async e=>{if(e.preventDefault(),m.trim()){fe(!0);try{let e=(await R.post(`/api/v1/channels/telegram/connect`,{bot_token:m.trim(),mode:C,allowed_chat_ids:ae.split(`,`).map(e=>e.trim()).filter(Boolean),webhook_url:C===`webhook`?re.trim():null})).data.data;p(e),e.connected?(q({type:`success`,text:`Connected as @${e.bot_username}`}),x(``)):q({type:`error`,text:e.error||u(`katana.connection_failed`)})}catch{q({type:`error`,text:u(`katana.connect_failed`)})}finally{fe(!1),setTimeout(()=>q(null),4e3)}}},hr=async()=>{if(A.trim()){ge(!0),N(null);try{let e=await R.post(`/api/v1/channels/telegram/test`,{chat_id:A.trim()});N(e.data.data)}catch(e){N({ok:!1,error:e.message||`Request failed`})}finally{ge(!1)}}},gr=async()=>{Ee(!0),N(null);try{let e=(await R.post(`/api/v1/channels/telegram/detect`)).data.data;if(e.ok&&e.chat_id){ue(e.chat_id);let t=ae.split(`,`).map(e=>e.trim()).filter(Boolean);t.includes(e.chat_id)||(t.push(e.chat_id),O(t.join(`, `))),N({ok:!0,message:`Auto-detected ID ${e.chat_id} from ${e.name}!`})}else N({ok:!1,error:e.error||`Could not detect ID.`})}catch(e){N({ok:!1,error:e.message||`Request failed`})}finally{Ee(!1)}},_r=async()=>{if(confirm(u(`katana.disconnect_confirm`)))try{await R.delete(`/api/v1/channels/telegram/disconnect`),p(null),O(``),ie(``),N(null),q({type:`success`,text:u(`katana.bot_disconnected`)})}catch{q({type:`error`,text:u(`katana.disconnect_failed`)})}finally{setTimeout(()=>q(null),3e3)}};(0,W.useEffect)(()=>{let e=B.provider;e===`gmail`?V(e=>({...e,imap_host:`imap.gmail.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.gmail.com`,smtp_port:587,smtp_use_ssl:!0,caldav_url:`https://apidata.googleusercontent.com/caldav/v1/calendars/primary/events`,calendar_provider:`google_api`})):e===`outlook`?V(e=>({...e,imap_host:`outlook.office365.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.office365.com`,smtp_port:587,smtp_use_ssl:!0,caldav_url:``,calendar_provider:`microsoft_graph`})):e===`proton`&&V(e=>({...e,imap_host:`127.0.0.1`,imap_port:1143,imap_use_ssl:!1,smtp_host:`127.0.0.1`,smtp_port:1025,smtp_use_ssl:!1,caldav_url:`http://127.0.0.1:5000`,calendar_provider:`caldav`}))},[B.provider]);let vr=async()=>{try{let e=(await R.get(`/api/v1/channels/email/account`)).data.data;Be(e),e&&(V({provider:e.provider,display_name:e.display_name||``,email_address:e.email_address||``,protocol:e.protocol||`imap`,imap_host:e.imap_host||``,imap_port:e.imap_port||993,imap_use_ssl:e.imap_use_ssl??!0,smtp_host:e.smtp_host||``,smtp_port:e.smtp_port||587,smtp_use_ssl:e.smtp_use_ssl??!0,username:e.username||``,password:``,caldav_url:e.caldav_url||``,calendar_provider:e.calendar_provider||`none`,calendar_credentials:e.calendar_credentials||null}),Qe({perm_read_mail:e.perm_read_mail,perm_send_mail:e.perm_send_mail,perm_delete_mail:e.perm_delete_mail,perm_read_calendar:e.perm_read_calendar,perm_create_events:e.perm_create_events,perm_edit_events:e.perm_edit_events,perm_delete_events:e.perm_delete_events}))}catch{}},yr=async e=>{if(e.preventDefault(),!(!B.email_address||!B.username||!z&&!B.password)){We(!0);try{let e=(await R.post(`/api/v1/channels/email/account`,B)).data.data;Be(e),q({type:`success`,text:`Mail & Calendar account connected!`})}catch(e){q({type:`error`,text:e.response?.data?.detail||`Failed to connect account`})}finally{We(!1),setTimeout(()=>q(null),4e3)}}},br=async()=>{if(confirm(`Are you sure you want to disconnect this Mail & Calendar account?`))try{await R.delete(`/api/v1/channels/email/account`),Be(null),V({provider:`gmail`,display_name:``,email_address:``,protocol:`imap`,imap_host:`imap.gmail.com`,imap_port:993,imap_use_ssl:!0,smtp_host:`smtp.gmail.com`,smtp_port:587,smtp_use_ssl:!0,username:``,password:``,caldav_url:`https://apidata.googleusercontent.com/caldav/v1/calendars/primary/events`,calendar_provider:`google_api`,calendar_credentials:null}),q({type:`success`,text:`Mail & Calendar account disconnected.`})}catch{q({type:`error`,text:`Failed to disconnect account.`})}finally{setTimeout(()=>q(null),3e3)}},xr=async()=>{Ke(!0),Ye(null);try{let e=await R.post(`/api/v1/channels/email/account/test`,B);Ye(e.data.data)}catch(e){Ye({ok:!1,imap_ok:!1,smtp_ok:!1,message:e.response?.data?.detail||e.message||`Test request failed`})}finally{Ke(!1)}},Sr=async()=>{We(!0);try{let e=await R.patch(`/api/v1/channels/email/account/permissions`,Xe);Be(e.data.data),q({type:`success`,text:`Permissions updated successfully!`})}catch{q({type:`error`,text:`Failed to update permissions.`})}finally{We(!1),setTimeout(()=>q(null),3e3)}},Cr=async(e,t)=>{jt(e);try{let n=t||(J.provider_type===e?J.base_url:null)||(e===`ollama`?`http://127.0.0.1:11434`:`http://localhost:1234/v1`),r=await R.get(`/api/v1/system/local-models`,{params:{provider_type:e,base_url:n}});r.data?.success?Ot(r.data.data||[]):Ot([])}catch{Ot([])}},wr=async()=>{let e=Zt.trim();if(e){en(!0);try{let t=(await R.get(`/api/v1/system/scan-local-models`,{params:{path:e}})).data?.data||[];t.length>0?(Ot(t),q({type:`success`,text:`Found ${t.length} model${t.length===1?``:`s`} in directory.`})):q({type:`error`,text:`No models found at that path. Check the directory and try again.`})}catch{q({type:`error`,text:`Could not scan directory. Ensure the backend can access the path.`})}finally{en(!1),setTimeout(()=>q(null),4e3)}}},Tr=async e=>{let t=(J.provider_type===`ollama`?J.base_url:null)||`http://127.0.0.1:11434`;sn(e),ln({status:`Connecting to Ollama…`,percent:0});try{let n=new URLSearchParams({model:e,base_url:t}),r=await fetch(`/api/v1/system/pull-model?${n}`);if(!r.body)throw Error(`No response body`);let i=r.body.getReader(),a=new TextDecoder,o=``;for(;;){let{done:t,value:n}=await i.read();if(t)break;o+=a.decode(n,{stream:!0});let r=o.split(` +`);o=r.pop()??``;for(let t of r)if(t.startsWith(`data: `))try{let n=JSON.parse(t.slice(6));if(n.status===`error`){q({type:`error`,text:n.error||`Failed to pull ${e}`}),setTimeout(()=>q(null),6e3);return}if(n.status===`done`||n.status===`success`){ln({status:`✓ Complete!`,percent:100}),q({type:`success`,text:`${e} pulled successfully — ready to use.`}),Ot(t=>t.includes(e)?t:[e,...t]),setTimeout(()=>q(null),5e3);break}let r=n.total&&n.completed?Math.round(n.completed/n.total*100):0,i=n.completed?(n.completed/1e9).toFixed(2):null,a=n.total?(n.total/1e9).toFixed(2):null,o=i&&a?` — ${i} / ${a} GB`:``;ln({status:`${n.status}${o}`,percent:r})}catch{}}}catch(n){q({type:`error`,text:n?.message||`Failed to pull ${e}. Is Ollama running at ${t}?`}),setTimeout(()=>q(null),6e3)}finally{sn(null),ln(null)}},[Er,Dr]=(0,W.useState)(null),Or=async e=>{if(!confirm(`Delete model "${e}" from Ollama? This will free disk space but the model will need to be re-pulled to use again.`))return;let t=St.find(e=>e.provider_type===`ollama`&&e.base_url)?.base_url||(J.provider_type===`ollama`?J.base_url:null)||`http://127.0.0.1:11434`;Dr(e);try{let n=new URLSearchParams({model:e,base_url:t}),r=await(await fetch(`/api/v1/system/delete-model?${n}`,{method:`DELETE`})).json();r.success?(Ot(t=>t.filter(t=>t!==e)),q({type:`success`,text:`${e} deleted successfully.`})):q({type:`error`,text:r.message||`Failed to delete ${e}`}),setTimeout(()=>q(null),5e3)}catch(t){q({type:`error`,text:t?.message||`Failed to delete ${e}`}),setTimeout(()=>q(null),6e3)}finally{Dr(null)}},kr=async e=>{e.preventDefault(),xt(!0);try{let e=Gt(J.name),t={name:J.name,provider_type:J.provider_type,slug:e,base_url:J.base_url||null,is_local:zt(J.provider_type),auth_type:zt(J.provider_type)?`none`:J.auth_type,config:J.api_key?{api_key:J.api_key}:{}};Rt?(await R.patch(`/api/v1/model-providers/${Rt}`,t),q({type:`success`,text:`Model provider updated successfully.`})):(await R.post(`/api/v1/model-providers`,t),q({type:`success`,text:`Model provider added successfully.`})),Jt({name:``,provider_type:`openai`,auth_type:`api_key`,api_key:``,base_url:Lt.openai,is_active:!0}),qt(null),Xt(!1),dr()}catch(e){let t=e?.response?.data?.detail,n=typeof t==`string`?t:Array.isArray(t)?t.map(e=>`${e.loc?.slice(-1)[0]}: ${e.msg}`).join(`, `):`Failed to save provider.`;q({type:`error`,text:n})}finally{xt(!1),setTimeout(()=>q(null),5e3)}},Ar=e=>{qt(e.id),Jt({name:e.name,provider_type:e.provider_type,auth_type:e.auth_type||`api_key`,api_key:e.config?.api_key||``,base_url:e.base_url||Lt[e.provider_type]||``,is_active:e.status===`connected`}),Xt(!!e.base_url),window.scrollTo({top:0,behavior:`smooth`})},jr=()=>{qt(null),Jt({name:``,provider_type:`openai`,auth_type:`api_key`,api_key:``,base_url:Lt.openai,is_active:!0}),Xt(!1)},Mr=async(e,t)=>{let n=t===`connected`?`disabled`:`connected`;try{await R.patch(`/api/v1/model-providers/${e}`,{status:n}),dr()}catch(e){console.error(`Error toggling provider:`,e)}},Nr=async(e,t)=>{if(confirm(`Remove provider "${t}" from the grid? This cannot be undone.`))try{await R.delete(`/api/v1/model-providers/${e}`),q({type:`success`,text:`Provider "${t}" removed.`}),dr()}catch{q({type:`error`,text:`Failed to delete provider.`})}finally{setTimeout(()=>q(null),3e3)}},Pr=async e=>{e.preventDefault(),Nn(!0);let t=zn===`quick`&&Z?{name:Z.name,slug:Gt(Z.name),connector_type:`mcp`,source:`manual`,base_url:Z.transport===`sse`?Z.github_url:null,auth_type:`custom`,risk_level:Z.risk_level,config:{command:Z.command,args:Z.args,env:Wn,transport:Z.transport,npm_package:Z.npm_package}}:{name:Q.name,slug:Gt(Q.name),connector_type:`mcp`,source:`manual`,base_url:Q.transport===`sse`?Q.command:null,auth_type:`custom`,risk_level:Q.risk_level,config:{command:Q.transport===`stdio`?Q.command:void 0,args:Q.transport===`stdio`?Q.args.split(` `).filter(Boolean):void 0,env:Wn,transport:Q.transport}};try{await R.post(`/api/v1/tools`,t),q({type:`success`,text:`MCP Server "${t.name}" registered.`}),Rn(!1),Un(null),Hn(``),Gn({}),Kn({name:``,command:``,args:``,transport:`stdio`,risk_level:`medium`}),dr()}catch{q({type:`error`,text:`Failed to register MCP server.`})}finally{Nn(!1),setTimeout(()=>q(null),3e3)}},Fr=async e=>{e.preventDefault(),Nn(!0);let t=Dn===`quick`&&Y?{name:Y.name,slug:Gt(Y.name),connector_type:Y.connector_type,source:`manual`,base_url:Y.base_url,auth_type:Y.auth_type,risk_level:Y.risk_level,config:Pn?{api_key:Pn}:{}}:{name:X.name,slug:X.slug||Gt(X.name),connector_type:X.connector_type,source:`manual`,base_url:X.base_url||null,auth_type:X.auth_type,risk_level:X.risk_level,config:{}};try{await R.post(`/api/v1/tools`,t),q({type:`success`,text:`Tool "${t.name}" registered.`}),En(!1),jn(null),An(``),Fn(``),In({name:``,slug:``,base_url:``,connector_type:`api`,auth_type:`api_key`,risk_level:`low`}),dr()}catch{q({type:`error`,text:`Failed to register tool.`})}finally{Nn(!1),setTimeout(()=>q(null),3e3)}},Ir=async(e,t)=>{if(confirm(`Remove tool connector "${t}"? This cannot be undone.`))try{await R.delete(`/api/v1/tools/${e}`),q({type:`success`,text:`Tool "${t}" removed.`}),dr()}catch{q({type:`error`,text:`Failed to delete tool.`})}finally{setTimeout(()=>q(null),3e3)}},Lr=async e=>{if(e.preventDefault(),or.name.trim()){tr(!0);try{await R.post(`/api/v1/model-routing-profiles`,{name:or.name,description:or.description||null,is_default:or.is_default,rules:[]}),q({type:`success`,text:`Profile "${or.name}" created.`}),sr({name:``,description:``,is_default:!1}),Zn(!1),dr()}catch{q({type:`error`,text:`Failed to create routing profile.`})}finally{tr(!1),setTimeout(()=>q(null),3e3)}}},Rr=async(e,t)=>{if(confirm(`Delete routing profile "${t}"? This cannot be undone.`))try{await R.delete(`/api/v1/model-routing-profiles/${e}`),q({type:`success`,text:`Profile "${t}" deleted.`}),nr===e&&rr(null),dr()}catch{q({type:`error`,text:`Failed to delete profile.`})}finally{setTimeout(()=>q(null),3e3)}},zr=async e=>{try{await R.patch(`/api/v1/model-routing-profiles/${e}`,{is_default:!0}),q({type:`success`,text:`Default routing profile updated.`}),dr()}catch{q({type:`error`,text:`Failed to update default profile.`})}finally{setTimeout(()=>q(null),3e3)}},Br=(e,t)=>{ur(e),cr({task_type:t.task_type,primary_model_id:t.primary_model_id,fallback_model_ids:t.fallback_model_ids||[],latency_bias:t.latency_bias||``,cost_bias:t.cost_bias||``}),ar(!0)},Vr=async(e,t)=>{if(!$.primary_model_id)return;let n={task_type:$.task_type,primary_model_id:$.primary_model_id,fallback_model_ids:$.fallback_model_ids,latency_bias:$.latency_bias||null,cost_bias:$.cost_bias||null},r;lr===null?r=[...t,n]:(r=[...t],r[lr]=n);try{await R.patch(`/api/v1/model-routing-profiles/${e}`,{rules:r}),q({type:`success`,text:lr===null?`Routing rule added.`:`Routing rule updated.`}),ar(!1),ur(null),cr({task_type:`*`,primary_model_id:``,fallback_model_ids:[],latency_bias:``,cost_bias:``}),dr()}catch(e){let t=e.response?.data?.detail;q({type:`error`,text:t?`Save failed: ${t}`:`Failed to save rule. Please try a hard refresh (Ctrl+F5).`})}finally{setTimeout(()=>q(null),5e3)}},Hr=async(e,t,n)=>{let r=t.filter((e,t)=>t!==n);try{await R.patch(`/api/v1/model-routing-profiles/${e}`,{rules:r}),q({type:`success`,text:`Rule removed successfully.`}),dr()}catch(e){let t=e.response?.data?.detail;q({type:`error`,text:t?`Delete failed: ${t}`:`Failed to remove rule. Check backend logs or try a hard refresh.`})}finally{setTimeout(()=>q(null),5e3)}},Ur=(0,W.useMemo)(()=>{if(!kn.trim())return Ut;let e=kn.toLowerCase();return Ut.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e))},[kn]),Wr=e=>{switch(e){case`openai`:return{bg:`bg-green-500/10`,text:`text-green-500`};case`anthropic`:return{bg:`bg-shogun-gold/10`,text:`text-shogun-gold`};case`google`:return{bg:`bg-blue-400/10`,text:`text-blue-400`};case`openrouter`:return{bg:`bg-purple-400/10`,text:`text-purple-400`};case`ollama`:return{bg:`bg-cyan-400/10`,text:`text-cyan-400`};case`lmstudio`:return{bg:`bg-orange-400/10`,text:`text-orange-400`};default:return{bg:`bg-shogun-blue/10`,text:`text-shogun-blue`}}},Gr=e=>({openai:`OpenAI`,anthropic:`Anthropic`,google:`Google Gemini`,openrouter:`OpenRouter`,ollama:`Ollama`,lmstudio:`LM Studio`,local:`Local`,custom:`Custom`})[e]||e,Kr=It[J.provider_type],qr=zt(J.provider_type);return(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-6xl mx-auto pb-12`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[u(`katana.title`,`The Katana`),` `,(0,G.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:u(`katana.badge`)})]}),(0,G.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:u(`katana.subtitle`,`Manage the cutting-edge models and tools that empower your agents.`)})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>e(`/toolgate`),className:`flex items-center gap-2 self-start rounded-lg border border-orange-400/25 bg-orange-500/[0.07] px-3 py-2.5 text-xs font-bold text-orange-300 transition-colors hover:bg-orange-500/15`,children:[(0,G.jsx)(ke,{className:`h-4 w-4`}),`Configure runtime rules in ToolGate`]})]}),Pt&&(0,G.jsxs)(`div`,{className:I(`p-3 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,Pt.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[Pt.type===`success`?(0,G.jsx)(d,{className:`w-4 h-4`}):(0,G.jsx)(l,{className:`w-4 h-4`}),(0,G.jsx)(`span`,{className:`text-sm font-medium`,children:Pt.text})]}),(0,G.jsx)(`div`,{className:`flex border-b border-shogun-border overflow-x-auto`,children:[`providers`,`tools`,`files`,`routing`,`skills`,`team`,`telegram`,`teams`,`mail_calendar`,`office`,`ide`,`mado`,`ronin`,`skillopt`].filter(e=>e!==`ide`||[`campaign`,`ronin`].includes(it)).map(e=>(0,G.jsxs)(`button`,{onClick:()=>{o(e),e===`telegram`&&!f&&fr(),e===`mail_calendar`&&!z&&vr(),e===`office`&&!tt&&pt()},className:I(`px-6 py-3 text-[10px] font-bold uppercase tracking-widest transition-all relative`,r===e?`text-shogun-blue`:`text-shogun-subdued hover:text-shogun-text`),children:[e===`providers`&&u(`katana.tab_cloud`,`AI Model Provider`),e===`tools`&&u(`katana.tab_tools`,`Toolbox & APIs`),e===`files`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(ee,{className:`w-3.5 h-3.5`}),`File Formats`]}),e===`routing`&&u(`katana.tab_routing`,`Logic Routing`),e===`team`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(De,{className:`w-3.5 h-3.5`}),u(`katana.team.tab`,`Team`)]}),e===`skills`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(Ve,{className:`w-3.5 h-3.5`}),`Skills · Active Usage`]}),e===`telegram`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{className:`w-3.5 h-3.5`}),`Telegram`,f?.connected&&(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`})]}),e===`teams`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{className:`w-3.5 h-3.5`}),`Microsoft Teams`]}),e===`mail_calendar`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(E,{className:`w-3.5 h-3.5`}),`Mail & Calendar`,z?.is_active&&(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`})]}),e===`office`&&(0,G.jsxs)(`span`,{className:I(`flex items-center gap-1.5`,it===`shrine`&&`opacity-40`),children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5`}),`Office`,tt?.enabled&&it!==`shrine`&&(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-400 inline-block`})]}),e===`ide`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(D,{className:`w-3.5 h-3.5`}),` IDE Mode`]}),e===`mado`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(t,{className:`w-3.5 h-3.5`}),`Mado Browser`]}),e===`ronin`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(g,{className:`w-3.5 h-3.5`}),`Ronin Desktop`]}),e===`skillopt`&&(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(h,{className:`w-3.5 h-3.5`}),u(`katana.tab_skillopt`,`SkillOpt`)]}),r===e&&(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-blue shadow-[0_0_10px_rgba(74,140,199,0.5)]`})]},e))}),(0,G.jsxs)(`div`,{className:`mt-6`,children:[r===`skills`&&(0,G.jsx)(At,{}),r===`files`&&(0,G.jsx)(Nt,{}),r===`team`&&(0,G.jsx)(Ft,{}),r===`providers`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,G.jsx)(`div`,{className:`lg:col-span-1`,children:(0,G.jsxs)(`div`,{className:`shogun-card space-y-6 sticky top-6`,children:[(0,G.jsx)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:Rt?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{className:`w-5 h-5 text-shogun-gold`}),` `,u(`common.edit`,`Edit Provider`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(oe,{className:`w-5 h-5 text-shogun-blue`}),` `,u(`katana.add_provider`,`Add Provider`)]})}),(0,G.jsxs)(`form`,{onSubmit:kr,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.provider`,`Provider`)}),(0,G.jsxs)(`select`,{value:J.provider_type,onChange:e=>{let t=e.target.value;Jt({...J,provider_type:t,name:``,base_url:Lt[t]||``}),Xt(!1)},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsxs)(`optgroup`,{label:u(`katana.ai_model_providers`),children:[(0,G.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,G.jsx)(`option`,{value:`google`,children:`Google (Gemini)`}),(0,G.jsx)(`option`,{value:`anthropic`,children:`Anthropic`}),(0,G.jsx)(`option`,{value:`openrouter`,children:`OpenRouter`})]}),(0,G.jsxs)(`optgroup`,{label:u(`katana.local_providers`),children:[(0,G.jsx)(`option`,{value:`ollama`,children:`Ollama (Local)`}),(0,G.jsx)(`option`,{value:`lmstudio`,children:`LM Studio (Local)`})]})]})]}),Kr&&(0,G.jsxs)(`a`,{href:Kr.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-2 p-2.5 rounded-lg bg-shogun-blue/5 border border-shogun-blue/15 text-shogun-blue hover:bg-shogun-blue/10 hover:border-shogun-blue/30 transition-all group`,children:[(0,G.jsx)(ne,{className:`w-3.5 h-3.5 shrink-0`}),(0,G.jsx)(`span`,{className:`text-[11px] font-semibold truncate`,children:Kr.label}),(0,G.jsx)(_,{className:`w-3 h-3 ml-auto opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(qr?`katana.available_models`:`katana.display_name`)}),qr&&Dt.length>0?(0,G.jsxs)(`select`,{required:!0,value:J.name,onChange:e=>Jt({...J,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,disabled:!0,children:u(`katana.select_pulled_model`)}),Dt.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]}):(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:qr?`e.g. llama3:8b (or connect to fetch)`:`e.g. Primary OpenAI`,value:J.name,onChange:e=>Jt({...J,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`}),qr&&Dt.length===0&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Cr(J.provider_type),className:`text-[9px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors flex items-center gap-1`,children:[(0,G.jsx)(k,{className:`w-2.5 h-2.5`}),` `,u(`katana.scan_for_local_models`)]}),(0,G.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued`,children:[`• Ensure `,J.provider_type===`ollama`?`Ollama`:`LM Studio`,` is running`]})]})]}),!qr&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.auth_type`,`Auth Type`)}),(0,G.jsxs)(`select`,{value:J.auth_type,onChange:e=>Jt({...J,auth_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:`api_key`,children:u(`katana.api_key_option`)}),(0,G.jsx)(`option`,{value:`oauth`,children:u(`katana.oauth_option`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5 mt-3`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:J.auth_type===`oauth`?u(`katana.oauth_token`):u(`katana.api_key_label`)}),(0,G.jsx)(`input`,{type:`password`,placeholder:J.auth_type===`oauth`?`Bearer ...`:`sk-...`,value:J.api_key,onChange:e=>Jt({...J,api_key:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:[u(`katana.base_url_label`),` `,qr?``:u(`katana.auto`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Xt(e=>!e),className:I(`text-[9px] font-bold uppercase tracking-widest transition-colors`,Yt?`text-shogun-gold`:`text-shogun-blue hover:text-shogun-gold`),children:u(Yt?`katana.reset`:`katana.override`)})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:`text`,readOnly:!Yt,placeholder:Lt[J.provider_type]||`https://...`,value:J.base_url,onChange:e=>Jt({...J,base_url:e.target.value}),className:I(`w-full bg-[#050508] border rounded-lg p-3 text-sm outline-none font-mono text-xs transition-all`,Yt?`border-shogun-gold text-shogun-gold focus:ring-1 focus:ring-shogun-gold/20 cursor-text`:`border-shogun-border text-shogun-subdued cursor-default select-none`)}),!Yt&&(0,G.jsx)(`div`,{className:`absolute right-3 top-1/2 -translate-y-1/2`,children:(0,G.jsx)(`span`,{className:`text-[8px] text-green-400 font-bold uppercase border border-green-400/20 bg-green-400/5 px-1.5 py-0.5 rounded`,children:u(`katana.default`)})})]})]}),qr&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(te,{className:`w-3 h-3`}),` `,u(`katana.model_location`),(0,G.jsxs)(`span`,{className:`text-shogun-subdued/50 normal-case font-normal tracking-normal text-[9px]`,children:[`(`,u(`katana.filesystem_path`),`)`]})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:J.provider_type===`ollama`?`C:\\Users\\you\\.ollama\\models`:`C:\\Users\\you\\AppData\\Local\\LM Studio\\models`,value:Zt,onChange:e=>Qt(e.target.value),className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none font-mono text-xs`}),(0,G.jsxs)(`button`,{type:`button`,disabled:$t||!Zt.trim(),onClick:wr,className:`flex items-center gap-1.5 px-3 py-2 bg-shogun-blue/10 hover:bg-shogun-blue/20 border border-shogun-blue/30 hover:border-shogun-blue/60 disabled:opacity-40 disabled:cursor-not-allowed rounded-lg text-shogun-blue text-[10px] font-bold uppercase tracking-widest transition-all whitespace-nowrap`,children:[$t?(0,G.jsx)(k,{className:`w-3 h-3 animate-spin`}):(0,G.jsx)(ce,{className:`w-3 h-3`}),`Scan`]})]}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued leading-relaxed`,children:[`Paste the path shown in your `,J.provider_type===`ollama`?`Ollama`:`LM Studio`,` settings. The backend will walk the directory and return every pulled model.`]})]}),J.provider_type===`ollama`&&(0,G.jsxs)(`div`,{className:`border border-shogun-border rounded-xl overflow-hidden`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>nn(e=>!e),className:`w-full flex items-center justify-between px-4 py-3 bg-[#050508] hover:bg-[#0a0e1a] transition-colors`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:[(0,G.jsx)(we,{className:`w-3.5 h-3.5 text-cyan-400`}),`Pull a Model`,(0,G.jsxs)(`span`,{className:`text-cyan-400/60 normal-case font-normal tracking-normal`,children:[`— `,u(`katana.download_to_ollama`)]})]}),tn?(0,G.jsx)(c,{className:`w-3.5 h-3.5 text-shogun-subdued`}):(0,G.jsx)(a,{className:`w-3.5 h-3.5 text-shogun-subdued`})]}),tn&&(0,G.jsxs)(`div`,{className:`p-4 space-y-4 border-t border-shogun-border bg-[#02040a]`,children:[on&&cn&&(0,G.jsxs)(`div`,{className:`p-3 rounded-xl bg-cyan-500/5 border border-cyan-500/20 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold text-cyan-400 uppercase tracking-widest truncate`,children:[`↓ `,on]}),(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-cyan-400/70 ml-2 shrink-0`,children:[cn.percent,`%`]})]}),(0,G.jsx)(`div`,{className:`w-full h-1.5 bg-[#0a0e1a] rounded-full overflow-hidden`,children:(0,G.jsx)(`div`,{className:`h-full bg-gradient-to-r from-cyan-500 to-shogun-blue rounded-full transition-all duration-300`,style:{width:`${cn.percent}%`}})}),(0,G.jsx)(`p`,{className:`text-[9px] text-cyan-400/60 font-mono truncate`,children:cn.status})]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(ce,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued/50`}),(0,G.jsx)(`input`,{type:`text`,value:fn,onChange:e=>pn(e.target.value),placeholder:`Search all Ollama models...`,className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2 text-xs focus:border-cyan-500/60 outline-none placeholder:text-shogun-subdued/40`}),gn&&(0,G.jsx)(k,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-cyan-400 animate-spin`})]}),(0,G.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:[`all`,`vision`,`tools`,`thinking`,`embedding`,`cloud`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>an(e),className:I(`px-2.5 py-1 rounded text-[9px] font-bold uppercase tracking-widest border transition-all`,rn===e?`bg-cyan-500/15 border-cyan-500/40 text-cyan-400`:`bg-transparent border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:e},e))}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 max-h-80 overflow-y-auto pr-1 scrollbar-thin`,children:[gn&&mn.length===0?(0,G.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-shogun-subdued/50`,children:[(0,G.jsx)(k,{className:`w-4 h-4 animate-spin mr-2`}),(0,G.jsx)(`span`,{className:`text-[10px]`,children:`Searching ollama.com...`})]}):mn.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-shogun-subdued/50`,children:[(0,G.jsx)(`span`,{className:`text-[10px]`,children:`No models found`}),(0,G.jsx)(`span`,{className:`text-[9px] mt-1`,children:`Try a different search or use a custom tag below`})]}):mn.map(e=>{let t=on===e.id,n=Dt.find(t=>{let n=t.toLowerCase(),r=e.id.toLowerCase();return!!(n===r||n.startsWith(r+`:`))}),r=!!n;return(0,G.jsxs)(`div`,{className:I(`flex items-center justify-between p-2.5 rounded-lg border transition-all`,t?`border-cyan-500/40 bg-cyan-500/5`:r?`border-green-500/20 bg-green-500/5`:`border-shogun-border hover:border-shogun-subdued bg-[#050508]`),children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,G.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text truncate`,children:e.name}),e.sizes.map(e=>(0,G.jsx)(`span`,{className:`text-[7px] px-1 py-0.5 rounded bg-blue-500/10 border border-blue-500/20 text-blue-400 font-bold shrink-0`,children:e},e)),r&&(0,G.jsx)(`span`,{className:`text-[8px] text-green-400 font-bold shrink-0`,children:`✓ local`})]}),(0,G.jsx)(`p`,{className:`text-[8px] text-shogun-subdued/70 truncate mt-0.5`,children:e.description}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[e.capabilities.map(e=>(0,G.jsx)(`span`,{className:`text-[7px] px-1 py-0.5 rounded bg-indigo-500/10 border border-indigo-500/20 text-indigo-400 font-medium`,children:e},e)),(0,G.jsxs)(`span`,{className:`text-[7px] text-shogun-subdued/50 font-mono`,children:[`↓`,e.pulls]}),e.tag_count>0&&(0,G.jsxs)(`span`,{className:`text-[7px] text-shogun-subdued/50 font-mono`,children:[e.tag_count,` tags`]}),e.updated&&(0,G.jsx)(`span`,{className:`text-[7px] text-shogun-subdued/40`,children:e.updated})]})]}),(0,G.jsxs)(`div`,{className:`ml-3 shrink-0 flex items-center gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:!!on,onClick:()=>Tr(e.id),className:I(`flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-[9px] font-bold uppercase transition-all border`,t?`border-cyan-500/40 text-cyan-400 bg-cyan-500/10 animate-pulse`:r?`border-green-500/20 text-green-400 bg-green-500/5 hover:bg-green-500/10`:`border-shogun-border text-shogun-subdued hover:border-cyan-500/50 hover:text-cyan-400 hover:bg-cyan-500/5 disabled:opacity-30 disabled:cursor-not-allowed`),children:t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(k,{className:`w-2.5 h-2.5 animate-spin`}),` `,u(`katana.pulling`)]}):r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(k,{className:`w-2.5 h-2.5`}),` `,u(`katana.repull`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(we,{className:`w-2.5 h-2.5`}),` `,u(`katana.pull`)]})}),r&&n&&kt===`ollama`&&(0,G.jsx)(`button`,{type:`button`,disabled:!!on||Er===n,onClick:e=>{e.stopPropagation(),Or(n)},className:I(`p-1.5 rounded-lg transition-all border`,Er===n?`border-red-500/40 text-red-400 bg-red-500/10 animate-pulse`:`border-shogun-border text-red-500/40 hover:border-red-500/50 hover:text-red-500 hover:bg-red-500/5 disabled:opacity-30 disabled:cursor-not-allowed`),title:u(`katana.delete_local_model`,`Delete from Ollama`),children:(0,G.jsx)(_e,{className:`w-3 h-3`})})]})]},e.id)}),bn&&!gn&&(0,G.jsx)(`button`,{type:`button`,onClick:()=>wn(fn,vn+1,!0),disabled:Sn,className:`w-full py-2 rounded-lg border border-shogun-border text-[9px] font-bold uppercase tracking-widest text-shogun-subdued hover:border-cyan-500/40 hover:text-cyan-400 transition-all disabled:opacity-50`,children:Sn?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(k,{className:`w-3 h-3 animate-spin inline mr-1`}),` Loading...`]}):`Load More Models`})]}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-shogun-border/50 space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[9px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.custom_model_tag`,`Custom Model Tag`)}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(`input`,{type:`text`,value:un,onChange:e=>dn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&un.trim()&&(e.preventDefault(),Tr(un.trim()),dn(``))},placeholder:`e.g. llama3.2:latest or mistral:7b-instruct`,className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg px-3 py-2 text-xs font-mono focus:border-cyan-500/60 outline-none placeholder:text-shogun-subdued/40`}),(0,G.jsxs)(`button`,{type:`button`,disabled:!!on||!un.trim(),onClick:()=>{Tr(un.trim()),dn(``)},className:`px-3 py-2 bg-cyan-500/10 hover:bg-cyan-500/20 border border-cyan-500/30 hover:border-cyan-500/60 disabled:opacity-30 disabled:cursor-not-allowed rounded-lg text-cyan-400 text-[10px] font-bold uppercase tracking-widest transition-all whitespace-nowrap flex items-center gap-1`,children:[(0,G.jsx)(we,{className:`w-3 h-3`}),` `,u(`katana.pull`)]})]}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:[`Any valid Ollama model tag from `,(0,G.jsx)(`a`,{href:`https://ollama.com/search`,target:`_blank`,rel:`noopener noreferrer`,className:`text-cyan-400/70 font-mono hover:text-cyan-400 transition-colors`,children:`ollama.com/search`})]})]})]})]}),qr&&Dt.length>0&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-2`,children:[(0,G.jsx)(D,{className:`w-3.5 h-3.5`}),u(`katana.manage_local_models`,`Manage Local Models`),(0,G.jsx)(`span`,{className:`text-[8px] px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued font-bold`,children:Dt.length})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 max-h-48 overflow-y-auto pr-1 scrollbar-thin`,children:Dt.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded-lg border border-shogun-border bg-[#050508] hover:border-shogun-subdued transition-all`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-green-500 shrink-0`}),(0,G.jsx)(`span`,{className:`text-[10px] font-mono text-shogun-text truncate`,children:e})]}),kt===`ollama`&&(0,G.jsxs)(`button`,{type:`button`,disabled:Er===e,onClick:()=>Or(e),className:I(`shrink-0 flex items-center gap-1 px-2 py-1 rounded-lg text-[9px] font-bold uppercase transition-all border`,Er===e?`border-red-500/40 text-red-400 bg-red-500/10 animate-pulse`:`border-shogun-border text-red-500/50 hover:border-red-500/50 hover:text-red-500 hover:bg-red-500/5`),title:u(`katana.delete_local_model`,`Delete from Ollama`),children:[(0,G.jsx)(_e,{className:`w-3 h-3`}),(0,G.jsx)(`span`,{children:u(`katana.delete`,`Delete`)})]})]},e))})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(`button`,{type:`submit`,disabled:bt||!J.name,className:`flex-1 py-3 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold rounded-lg shadow-shogun transition-all flex items-center justify-center gap-2`,children:[bt?(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}):Rt?(0,G.jsx)(d,{className:`w-4 h-4`}):(0,G.jsx)(j,{className:`w-4 h-4`}),u(Rt?`katana.update_provider`:`katana.initiate_provider`)]}),Rt&&(0,G.jsx)(`button`,{type:`button`,onClick:jr,className:`px-4 py-2 bg-shogun-subdued/10 hover:bg-shogun-subdued/20 border border-shogun-border rounded-lg text-shogun-subdued text-xs font-bold uppercase transition-all`,children:u(`common.cancel`)})]})]})]})}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-6`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(h,{className:`w-5 h-5 text-shogun-blue`}),` `,u(`katana.active_providers`)]}),vt?(0,G.jsxs)(`div`,{className:`p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(k,{className:`w-8 h-8 animate-spin mx-auto text-shogun-blue mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:u(`katana.querying_model_grid`)})]}):St.length===0?(0,G.jsx)(`div`,{className:`p-12 text-center shogun-card border-dashed`,children:(0,G.jsx)(`p`,{className:`text-shogun-subdued italic`,children:u(`katana.no_providers`)})}):(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-4`,children:St.map(e=>{let t=Wr(e.provider_type),n=It[e.provider_type],r=e.status===`connected`,i=zt(e.provider_type);return(0,G.jsx)(`div`,{className:`shogun-card group hover:border-shogun-blue/50 transition-all`,children:(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:I(`w-12 h-12 rounded-xl flex items-center justify-center`,t.bg,t.text),children:i?(0,G.jsx)(D,{className:`w-6 h-6`}):(0,G.jsx)(Ne,{className:`w-6 h-6`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:e.name}),r?(0,G.jsx)(`span`,{className:`text-[8px] bg-green-500/10 text-green-500 px-1.5 py-0.5 rounded border border-green-500/20 font-bold uppercase`,children:u(`katana.active`)}):(0,G.jsx)(`span`,{className:`text-[8px] bg-shogun-subdued/10 text-shogun-subdued px-1.5 py-0.5 rounded border border-shogun-border font-bold uppercase`,children:e.status??u(`katana.not_configured`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,G.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued`,children:Gr(e.provider_type)}),(0,G.jsx)(`span`,{className:`text-xs text-shogun-subdued`,children:e.base_url||u(`katana.default_endpoint`)})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,G.jsx)(`a`,{href:n.url,target:`_blank`,rel:`noopener noreferrer`,className:`p-2 hover:bg-shogun-blue/10 text-shogun-subdued hover:text-shogun-blue rounded-lg transition-colors`,title:n.label,children:(0,G.jsx)(_,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Ar(e),className:`p-2 hover:bg-shogun-card rounded-lg transition-colors text-shogun-subdued hover:text-shogun-gold`,title:u(`katana.edit_provider`),children:(0,G.jsx)(U,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Mr(e.id,e.status),className:`p-2 hover:bg-shogun-card rounded-lg transition-colors text-shogun-subdued hover:text-shogun-text`,title:u(r?`katana.disable`:`katana.enable`),children:r?(0,G.jsx)(xe,{className:`w-4 h-4`}):(0,G.jsx)(P,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Nr(e.id,e.name),className:`p-2 hover:bg-red-500/10 text-red-500/50 hover:text-red-500 rounded-lg transition-colors`,title:u(`katana.delete_provider`),children:(0,G.jsx)(_e,{className:`w-4 h-4`})})]})]})},e.id)})}),Dt.length>0&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 border border-shogun-border bg-[#02040a]/40 backdrop-blur-md rounded-xl p-5 mt-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-shogun-border/40 pb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(D,{className:`w-5 h-5 text-green-400`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text text-sm`,children:`Local Models Manager`}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:`Manage models pulled on your local machines`})]})]}),(0,G.jsxs)(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-[#050508] border border-shogun-border text-green-400 font-mono font-bold`,children:[Dt.length,` models`]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 max-h-80 overflow-y-auto pr-1 scrollbar-thin`,children:Dt.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-lg border border-shogun-border bg-[#050508]/60 hover:border-shogun-subdued transition-all group`,children:[(0,G.jsx)(`div`,{className:`flex flex-col min-w-0 mr-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-500 shrink-0 shadow-[0_0_8px_#22c55e]`}),(0,G.jsx)(`span`,{className:`text-xs font-mono text-shogun-text truncate font-semibold`,title:e,children:e})]})}),kt===`ollama`&&(0,G.jsxs)(`button`,{type:`button`,disabled:Er===e,onClick:()=>Or(e),className:I(`shrink-0 flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[9px] font-bold uppercase transition-all border`,Er===e?`border-red-500/40 text-red-400 bg-red-500/10 animate-pulse`:`border-shogun-border text-red-500/60 hover:border-red-500 hover:text-red-500 hover:bg-red-500/10`),title:u(`katana.delete_local_model`,`Delete from Ollama`),children:[(0,G.jsx)(_e,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{children:Er===e?u(`katana.deleting`,`Deleting`):u(`katana.delete`,`Delete`)})]})]},e))})]})]})]}),r===`tools`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(be,{className:`w-5 h-5 text-shogun-blue`}),` `,u(`katana.tool_connectors`),(0,G.jsxs)(`span`,{className:`text-[10px] font-normal bg-shogun-card border border-shogun-border px-1.5 py-0.5 rounded text-shogun-subdued`,children:[Tt.length,` active`]})]}),(0,G.jsxs)(`button`,{id:`register-tool-btn`,onClick:()=>En(e=>!e),className:I(`flex items-center gap-2 px-4 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,Tn?`bg-shogun-blue/10 border-shogun-blue/40 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:text-shogun-blue hover:border-shogun-blue/40 hover:bg-shogun-blue/5`),children:[Tn?(0,G.jsx)(Ce,{className:`w-3 h-3`}):(0,G.jsx)(oe,{className:`w-3 h-3`}),u(Tn?`common.cancel`:`katana.register_new_tool`)]})]}),Tn&&(0,G.jsxs)(`div`,{className:`shogun-card border-shogun-blue/30 animate-in slide-in-from-top-3 duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(Ve,{className:`w-4 h-4 text-shogun-blue`}),` `,u(`katana.register_tool_connector`)]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 p-1 bg-[#050508] border border-shogun-border rounded-lg`,children:[`quick`,`manual`].map(e=>(0,G.jsx)(`button`,{onClick:()=>On(e),className:I(`px-3 py-1 rounded text-[10px] font-bold uppercase tracking-widest transition-all`,Dn===e?`bg-shogun-blue text-white shadow`:`text-shogun-subdued hover:text-shogun-text`),children:u(e===`quick`?`katana.quick_pick`:`katana.manual`)},e))})]}),(0,G.jsxs)(`form`,{onSubmit:Fr,children:[Dn===`quick`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(ce,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued`}),(0,G.jsx)(`input`,{type:`text`,placeholder:u(`katana.search_apis`),value:kn,onChange:e=>An(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2.5 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsx)(`div`,{className:`h-64 overflow-y-auto space-y-1 pr-1 scrollbar-thin scrollbar-thumb-shogun-border scrollbar-track-transparent`,children:Ur.length===0?(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic text-center py-8`,children:u(`katana.no_apis_match`)}):Ur.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{jn(e),Fn(``)},className:I(`w-full text-left px-3 py-2.5 rounded-lg border transition-all group flex items-center justify-between gap-2`,Y?.name===e.name?`border-shogun-blue/40 bg-shogun-blue/10 text-shogun-text`:`border-transparent hover:border-shogun-border hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text`),children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-xs font-bold truncate`,children:e.name}),(0,G.jsx)(`p`,{className:`text-[10px] truncate opacity-70`,children:e.description})]}),(0,G.jsx)(s,{className:I(`w-3.5 h-3.5 shrink-0 transition-all`,Y?.name===e.name?`text-shogun-blue opacity-100`:`opacity-0 group-hover:opacity-50`)})]},e.name))}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued text-center`,children:[Ur.length,` APIs in catalog`]})]}),(0,G.jsx)(`div`,{className:`flex flex-col`,children:Y?(0,G.jsxs)(`div`,{className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-text text-base`,children:Y.name}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1 leading-relaxed`,children:Y.description})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[{label:u(`katana.endpoint`),value:Y.base_url},{label:u(`katana.auth`),value:Y.auth_type.replace(`_`,` `).toUpperCase()},{label:u(`katana.type`),value:Y.connector_type.toUpperCase()},{label:u(`katana.risk`),value:Y.risk_level.toUpperCase()}].map(({label:e,value:t})=>(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`p`,{className:`text-shogun-subdued uppercase tracking-widest font-bold`,children:e}),(0,G.jsx)(`p`,{className:`text-shogun-text font-mono truncate`,children:t})]},e))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(je,{className:`w-3 h-3 text-shogun-subdued shrink-0`}),(0,G.jsx)(`a`,{href:`https://www.google.com/search?q=${encodeURIComponent(Y.name+` API documentation`)}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-shogun-blue hover:underline truncate`,children:`Find documentation →`})]}),Y.auth_type!==`none`&&(0,G.jsxs)(`div`,{className:`space-y-1.5 pt-1 border-t border-shogun-border/50`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(P,{className:`w-3 h-3 text-shogun-gold`}),`API Key`,(0,G.jsxs)(`span`,{className:`text-shogun-subdued/50 normal-case font-normal tracking-normal`,children:[`(`,Y.auth_type.replace(`_`,` `),`)`]})]}),(0,G.jsx)(`input`,{type:`password`,placeholder:`Paste your API key here…`,value:Pn,onChange:e=>Fn(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold focus:ring-1 focus:ring-shogun-gold/20 outline-none font-mono text-xs transition-all`}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:`Stored locally in the connector config. Never sent to third parties.`})]})]}):(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center bg-[#050508] border border-dashed border-shogun-border rounded-xl p-8 gap-3`,children:[(0,G.jsx)(Ve,{className:`w-8 h-8 text-shogun-subdued opacity-40`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:u(`katana.select_api_preview`)})]})})]}),Dn===`manual`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.tool_name`,`Tool Name *`)}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. Stripe Billing`,value:X.name,onChange:e=>In({...X,name:e.target.value,slug:Gt(e.target.value)}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.slug`,`Slug *`)}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`auto-generated`,value:X.slug,onChange:e=>In({...X,slug:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.base_url`,`Base URL`)}),(0,G.jsx)(`input`,{type:`text`,placeholder:`https://api.example.com/v1`,value:X.base_url,onChange:e=>In({...X,base_url:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.connector_type`,`Connector Type`)}),(0,G.jsx)(`select`,{value:X.connector_type,onChange:e=>In({...X,connector_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:Bt.map(e=>(0,G.jsx)(`option`,{value:e,children:e.toUpperCase()},e))})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.auth_type`,`Auth Type`)}),(0,G.jsx)(`select`,{value:X.auth_type,onChange:e=>In({...X,auth_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`,children:Vt.map(e=>(0,G.jsx)(`option`,{value:e,children:e.replace(`_`,` `).toUpperCase()},e))})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.risk_level`,`Risk Level`)}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Ht.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>In({...X,risk_level:e}),className:I(`flex-1 py-2 rounded-lg border text-[9px] font-bold uppercase tracking-widest transition-all`,X.risk_level===e?Kt(e)+` border-opacity-100`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/30`),children:e},e))})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-6 pt-5 border-t border-shogun-border`,children:[(0,G.jsxs)(`button`,{type:`submit`,disabled:Mn||Dn===`quick`&&!Y,className:`flex items-center gap-2 px-6 py-2.5 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 disabled:cursor-not-allowed text-white font-bold rounded-lg text-sm transition-all`,children:[Mn?(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(j,{className:`w-4 h-4`}),u(`katana.register_connector`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>En(!1),className:`px-4 py-2.5 text-sm font-bold text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`}),Dn===`quick`&&!Y&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued ml-auto`,children:u(`katana.select_api_first`)})]})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5`,children:vt?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(k,{className:`w-8 h-8 animate-spin mx-auto text-shogun-blue mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:u(`katana.loading_connectors`)})]}):Tt.length===0?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card border-dashed`,children:[(0,G.jsx)(be,{className:`w-8 h-8 text-shogun-subdued opacity-30 mx-auto mb-3`}),(0,G.jsx)(`p`,{className:`text-shogun-subdued italic text-sm`,children:u(`katana.no_tools`)}),(0,G.jsx)(`button`,{onClick:()=>En(!0),className:`mt-4 text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:`+ Register your first tool`})]}):Tt.map(e=>(0,G.jsxs)(`div`,{className:`shogun-card hover:border-shogun-blue/30 transition-all group relative`,children:[e.source!==`builtin`&&!e.config?.builtin&&(0,G.jsx)(`button`,{onClick:()=>Ir(e.id,e.name),className:`absolute top-3 right-3 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-500/10 text-red-500/50 hover:text-red-500 transition-all`,title:u(`katana.remove_connector`),children:(0,G.jsx)(_e,{className:`w-3.5 h-3.5`})}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-subdued group-hover:text-shogun-blue transition-colors shrink-0`,children:(0,G.jsx)(be,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text truncate flex items-center gap-2`,children:[e.name,(e.source===`builtin`||e.config?.builtin)&&(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest text-indigo-300 border border-indigo-400/30 bg-indigo-500/10 rounded px-1.5 py-0.5`,children:`Standard`})]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate`,children:e.slug})]})]}),e.base_url&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate mb-3 bg-[#050508] px-2 py-1 rounded border border-shogun-border`,children:e.base_url}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-shogun-border`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued`,children:e.connector_type||`api`}),(0,G.jsx)(`span`,{className:I(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,Kt(e.risk_level||`low`)),children:e.risk_level||`low`})]}),(0,G.jsx)(`span`,{className:I(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,e.status===`connected`||e.status===`active`?`text-green-400 border-green-400/30 bg-green-400/5`:e.status===`disabled`?`text-shogun-subdued border-shogun-border bg-shogun-card`:`text-yellow-400 border-yellow-400/30 bg-yellow-400/5`),children:e.status||`not_configured`})]})]},e.id))})]}),r===`tools`&&(0,G.jsxs)(`div`,{className:`space-y-6 pt-12 mt-12 border-t border-shogun-border/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(w,{className:`w-5 h-5 text-indigo-500`}),` `,u(`katana.mcp_servers`,`MCP Servers`),(0,G.jsxs)(`span`,{className:`text-[10px] font-normal bg-shogun-card border border-shogun-border px-1.5 py-0.5 rounded text-shogun-subdued`,children:[Tt.filter(e=>e.connector_type===`mcp`).length,` active`]})]}),(0,G.jsxs)(`button`,{onClick:()=>Rn(e=>!e),className:I(`flex items-center gap-2 px-4 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,Ln?`bg-indigo-500/10 border-indigo-500/40 text-indigo-400`:`border-shogun-border text-shogun-subdued hover:text-indigo-400 hover:border-indigo-500/40 hover:bg-indigo-500/5`),children:[Ln?(0,G.jsx)(Ce,{className:`w-3 h-3`}):(0,G.jsx)(oe,{className:`w-3 h-3`}),Ln?u(`common.cancel`):u(`katana.register_mcp`,`Register MCP`)]})]}),Ln&&(0,G.jsxs)(`div`,{className:`shogun-card border-indigo-500/30 animate-in slide-in-from-top-3 duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-5`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(Ve,{className:`w-4 h-4 text-indigo-500`}),` `,u(`katana.register_mcp_server`,`Register MCP Server`)]}),(0,G.jsx)(`div`,{className:`flex items-center gap-1 p-1 bg-[#050508] border border-shogun-border rounded-lg`,children:[`quick`,`manual`].map(e=>(0,G.jsx)(`button`,{onClick:()=>Bn(e),className:I(`px-3 py-1 rounded text-[10px] font-bold uppercase tracking-widest transition-all`,zn===e?`bg-indigo-500 text-white shadow`:`text-shogun-subdued hover:text-shogun-text`),children:u(e===`quick`?`katana.quick_pick`:`katana.manual`)},e))})]}),(0,G.jsxs)(`form`,{onSubmit:Pr,children:[zn===`quick`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(ce,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued`}),(0,G.jsx)(`input`,{type:`text`,placeholder:`Search MCP servers...`,value:Vn,onChange:e=>Hn(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg pl-9 pr-3 py-2.5 text-sm focus:border-indigo-500 outline-none`})]}),(0,G.jsx)(`div`,{className:`h-64 overflow-y-auto space-y-1 pr-1 scrollbar-thin scrollbar-thumb-shogun-border scrollbar-track-transparent`,children:qn.length===0?(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic text-center py-8`,children:`No MCP servers match your search.`}):qn.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>{Un(e),Gn({})},className:I(`w-full text-left px-3 py-2.5 rounded-lg border transition-all group flex items-center justify-between gap-2`,Z?.name===e.name?`border-indigo-500/40 bg-indigo-500/10 text-shogun-text`:`border-transparent hover:border-shogun-border hover:bg-shogun-card text-shogun-subdued hover:text-shogun-text`),children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`text-xs font-bold truncate`,children:e.name}),(0,G.jsx)(`p`,{className:`text-[10px] truncate opacity-70`,children:e.category})]}),(0,G.jsx)(s,{className:I(`w-3.5 h-3.5 shrink-0 transition-all`,Z?.name===e.name?`text-indigo-400 opacity-100`:`opacity-0 group-hover:opacity-50`)})]},e.name))})]}),(0,G.jsx)(`div`,{className:`flex flex-col`,children:Z?(0,G.jsxs)(`div`,{className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl p-5 space-y-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-text text-base`,children:Z.name}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1 leading-relaxed`,children:Z.description})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-2 text-[10px]`,children:[{label:`COMMAND`,value:Z.transport===`stdio`?`${Z.command} ${Z.args.join(` `)}`:Z.github_url},{label:`TRANSPORT`,value:Z.transport.toUpperCase()},{label:`RISK`,value:Z.risk_level.toUpperCase()}].map(({label:e,value:t})=>(0,G.jsxs)(`div`,{className:I(`space-y-0.5`,e===`COMMAND`&&`col-span-2`),children:[(0,G.jsx)(`p`,{className:`text-shogun-subdued uppercase tracking-widest font-bold`,children:e}),(0,G.jsx)(`p`,{className:`text-shogun-text font-mono truncate`,children:t})]},e))}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,G.jsx)(je,{className:`w-3 h-3 text-shogun-subdued shrink-0`}),(0,G.jsx)(`a`,{href:Z.github_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] text-indigo-400 hover:underline truncate`,children:`View Repository →`})]}),Z.env_keys.length>0&&(0,G.jsxs)(`div`,{className:`space-y-3 pt-3 border-t border-shogun-border/50`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(P,{className:`w-3 h-3 text-shogun-gold`}),`Required Environment Variables`]}),Z.env_keys.map(e=>(0,G.jsx)(`input`,{type:`password`,placeholder:e,value:Wn[e]||``,onChange:t=>Gn({...Wn,[e]:t.target.value}),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg p-2.5 text-sm focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/20 outline-none font-mono text-xs transition-all`},e))]})]}):(0,G.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center text-center bg-[#050508] border border-dashed border-shogun-border rounded-xl p-8 gap-3`,children:[(0,G.jsx)(Ve,{className:`w-8 h-8 text-shogun-subdued opacity-40`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`Select an MCP server from the catalog to configure it.`})]})})]}),zn===`manual`&&(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Server Name *`}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. My Custom MCP`,value:Q.name,onChange:e=>Kn({...Q,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Transport`}),(0,G.jsxs)(`select`,{value:Q.transport,onChange:e=>Kn({...Q,transport:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none`,children:[(0,G.jsx)(`option`,{value:`stdio`,children:`STDIO (Local command)`}),(0,G.jsx)(`option`,{value:`sse`,children:`SSE (Remote URL)`})]})]}),Q.transport===`stdio`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Command *`}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. npx`,value:Q.command,onChange:e=>Kn({...Q,command:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Arguments`}),(0,G.jsx)(`input`,{type:`text`,placeholder:`e.g. -y @modelcontextprotocol/server-postgres`,value:Q.args,onChange:e=>Kn({...Q,args:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none font-mono`})]})]}):(0,G.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`SSE URL *`}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`https://mcp.example.com/sse`,value:Q.command,onChange:e=>Kn({...Q,command:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-indigo-500 outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Risk Level`}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:Ht.map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>Kn({...Q,risk_level:e}),className:I(`flex-1 py-2 rounded-lg border text-[9px] font-bold uppercase tracking-widest transition-all`,Q.risk_level===e?Kt(e)+` border-opacity-100`:`border-shogun-border text-shogun-subdued hover:border-indigo-500/30`),children:e},e))})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 mt-6 pt-5 border-t border-shogun-border`,children:[(0,G.jsxs)(`button`,{type:`submit`,disabled:Mn||zn===`quick`&&(!Z||Z.env_keys.some(e=>!Wn[e])),className:`flex items-center gap-2 px-6 py-2.5 bg-indigo-500 hover:bg-indigo-600 disabled:opacity-40 disabled:cursor-not-allowed text-white font-bold rounded-lg text-sm transition-all`,children:[Mn?(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(j,{className:`w-4 h-4`}),`Register MCP Server`]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Rn(!1),className:`px-4 py-2.5 text-sm font-bold text-shogun-subdued hover:text-shogun-text transition-colors`,children:`Cancel`})]})]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-5`,children:vt?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(k,{className:`w-8 h-8 animate-spin mx-auto text-indigo-500 mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:`Loading MCPs`})]}):Tt.filter(e=>e.connector_type===`mcp`).length===0?(0,G.jsxs)(`div`,{className:`col-span-3 p-12 text-center shogun-card border-dashed`,children:[(0,G.jsx)(w,{className:`w-8 h-8 text-shogun-subdued opacity-30 mx-auto mb-3`}),(0,G.jsx)(`p`,{className:`text-shogun-subdued italic text-sm`,children:`No MCP servers registered`}),(0,G.jsx)(`button`,{onClick:()=>Rn(!0),className:`mt-4 text-[10px] font-bold text-indigo-400 hover:text-indigo-300 uppercase tracking-widest transition-colors`,children:`+ Register your first MCP`})]}):Tt.filter(e=>e.connector_type===`mcp`).map(e=>(0,G.jsxs)(`div`,{className:`shogun-card hover:border-indigo-500/30 transition-all group relative`,children:[e.source!==`builtin`&&!e.config?.builtin&&(0,G.jsx)(`button`,{onClick:()=>Ir(e.id,e.name),className:`absolute top-3 right-3 p-1.5 rounded-lg opacity-0 group-hover:opacity-100 hover:bg-red-500/10 text-red-500/50 hover:text-red-500 transition-all`,title:u(`katana.remove_connector`),children:(0,G.jsx)(_e,{className:`w-3.5 h-3.5`})}),(0,G.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,G.jsx)(`div`,{className:`w-10 h-10 rounded-lg bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-subdued group-hover:text-indigo-400 transition-colors shrink-0`,children:(0,G.jsx)(w,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text truncate flex items-center gap-2`,children:[e.name,(e.source===`builtin`||e.config?.builtin)&&(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest text-indigo-300 border border-indigo-400/30 bg-indigo-500/10 rounded px-1.5 py-0.5`,children:`Standard`})]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate`,children:[e.config?.transport===`sse`?`SSE`:`STDIO`,` • `,e.slug]})]})]}),e.config?.command&&(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued font-mono truncate mb-3 bg-[#050508] px-2 py-1 rounded border border-shogun-border`,title:e.config.transport===`stdio`?`${e.config.command} ${(e.config.args||[]).join(` `)}`:e.base_url,children:e.config.transport===`stdio`?`${e.config.command} ${(e.config.args||[]).join(` `)}`:e.base_url}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-shogun-border`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded bg-[#050508] border border-shogun-border text-shogun-subdued`,children:`MCP`}),(0,G.jsx)(`span`,{className:I(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,Kt(e.risk_level||`low`)),children:e.risk_level||`low`})]}),(0,G.jsx)(`span`,{className:I(`text-[8px] uppercase tracking-widest font-bold px-1.5 py-0.5 rounded border`,e.status===`connected`||e.status===`active`?`text-green-400 border-green-400/30 bg-green-400/5`:e.status===`disabled`?`text-shogun-subdued border-shogun-border bg-shogun-card`:`text-yellow-400 border-yellow-400/30 bg-yellow-400/5`),children:e.status||`not_configured`})]})]},e.id))})]}),r===`routing`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsx)(Ct,{isEditingProfiles:Qn,onEditProfiles:()=>$n(e=>!e)}),Qn&&(0,G.jsxs)(`div`,{className:`space-y-6 animate-in slide-in-from-top-2 duration-200`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(pe,{className:`w-5 h-5 text-shogun-blue`}),` `,u(`katana.routing_profiles`),(0,G.jsxs)(`span`,{className:`text-[10px] font-normal bg-shogun-card border border-shogun-border px-1.5 py-0.5 rounded text-shogun-subdued`,children:[Jn.length,` profiles`]})]}),(0,G.jsxs)(`button`,{onClick:()=>Zn(e=>!e),className:I(`flex items-center gap-2 px-4 py-2 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,Xn?`bg-shogun-blue/10 border-shogun-blue/40 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:text-shogun-blue hover:border-shogun-blue/40 hover:bg-shogun-blue/5`),children:[Xn?(0,G.jsx)(Ce,{className:`w-3 h-3`}):(0,G.jsx)(oe,{className:`w-3 h-3`}),u(Xn?`common.cancel`:`katana.new_profile`)]})]}),Xn&&(0,G.jsxs)(`div`,{className:`shogun-card border-shogun-blue/30 animate-in slide-in-from-top-3 duration-300`,children:[(0,G.jsxs)(`h4`,{className:`font-bold text-shogun-text flex items-center gap-2 mb-4`,children:[(0,G.jsx)(S,{className:`w-4 h-4 text-shogun-blue`}),` `,u(`katana.new_routing_profile`)]}),(0,G.jsxs)(`form`,{onSubmit:Lr,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.profile_name`,`Profile Name *`)}),(0,G.jsx)(`input`,{required:!0,type:`text`,placeholder:`e.g. Quality First`,value:or.name,onChange:e=>sr({...or,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.description`,`Description`)}),(0,G.jsx)(`input`,{type:`text`,placeholder:`Optional short description`,value:or.description,onChange:e=>sr({...or,description:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-4 mt-4 pt-4 border-t border-shogun-border`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer text-sm text-shogun-subdued hover:text-shogun-text transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:or.is_default,onChange:e=>sr({...or,is_default:e.target.checked}),className:`accent-shogun-blue`}),u(`katana.set_as_default_profile`)]}),(0,G.jsxs)(`button`,{type:`submit`,disabled:er||!or.name.trim(),className:`flex items-center gap-2 px-5 py-2 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm transition-all`,children:[er?(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(j,{className:`w-4 h-4`}),`Create Profile`]})]})]})]}),vt?(0,G.jsxs)(`div`,{className:`p-12 text-center shogun-card opacity-50`,children:[(0,G.jsx)(k,{className:`w-8 h-8 animate-spin mx-auto text-shogun-blue mb-4`}),(0,G.jsx)(`p`,{className:`text-xs uppercase tracking-widest font-bold`,children:u(`katana.loading_profiles`)})]}):Jn.length===0?(0,G.jsxs)(`div`,{className:`shogun-card text-center py-20 space-y-4 border-dashed`,children:[(0,G.jsx)(`div`,{className:`w-16 h-16 bg-shogun-blue/10 rounded-full flex items-center justify-center mx-auto`,children:(0,G.jsx)(n,{className:`w-8 h-8 text-shogun-blue`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:u(`katana.no_routing_profiles`)}),(0,G.jsx)(`p`,{className:`text-sm text-shogun-subdued mt-1 max-w-sm mx-auto`,children:u(`katana.no_routing_profiles_desc`)})]}),(0,G.jsx)(`button`,{onClick:()=>Zn(!0),className:`text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:u(`katana.create_first_profile`)})]}):(0,G.jsx)(`div`,{className:`space-y-4`,children:Jn.map(e=>{let t=nr===e.id,n=e.rules||[];return(0,G.jsxs)(`div`,{className:I(`shogun-card transition-all`,e.is_default?`border-shogun-gold/40`:`hover:border-shogun-blue/30`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:I(`w-12 h-12 rounded-xl flex items-center justify-center shrink-0`,e.is_default?`bg-shogun-gold/10 text-shogun-gold`:`bg-shogun-blue/10 text-shogun-blue`),children:e.is_default?(0,G.jsx)(he,{className:`w-5 h-5`}):(0,G.jsx)(pe,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h4`,{className:`font-bold text-shogun-text`,children:e.name}),e.is_default&&(0,G.jsx)(`span`,{className:`text-[8px] bg-shogun-gold/10 text-shogun-gold px-1.5 py-0.5 rounded border border-shogun-gold/30 font-bold uppercase tracking-widest`,children:u(`katana.default`)})]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:e.description||u(`katana.no_description`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,G.jsxs)(`button`,{onClick:()=>{rr(t?null:e.id),ar(!1)},className:I(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg border text-[10px] font-bold uppercase tracking-widest transition-all`,t?`border-shogun-blue/40 bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/30 hover:text-shogun-text`),children:[(0,G.jsx)(w,{className:`w-3 h-3`}),n.length,` `,n.length===1?u(`katana.rule`):u(`katana.rules`),t?(0,G.jsx)(c,{className:`w-3 h-3`}):(0,G.jsx)(a,{className:`w-3 h-3`})]}),!e.is_default&&(0,G.jsx)(`button`,{onClick:()=>zr(e.id),className:`p-2 hover:bg-shogun-gold/10 text-shogun-subdued hover:text-shogun-gold rounded-lg transition-colors`,title:u(`katana.set_as_default`),children:(0,G.jsx)(Ue,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{onClick:()=>Rr(e.id,e.name),className:`p-2 hover:bg-red-500/10 text-red-500/40 hover:text-red-500 rounded-lg transition-colors`,title:u(`katana.delete_profile`),children:(0,G.jsx)(_e,{className:`w-4 h-4`})})]})]}),t&&(0,G.jsxs)(`div`,{className:`mt-5 pt-5 border-t border-shogun-border space-y-3 animate-in slide-in-from-top-2 duration-200`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.routing_rules`)}),!ir&&(0,G.jsxs)(`button`,{onClick:()=>ar(!0),className:`flex items-center gap-1 text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:[(0,G.jsx)(oe,{className:`w-3 h-3`}),` `,u(`katana.add_rule`)]})]}),n.length===0&&!ir?(0,G.jsx)(`div`,{className:`text-center py-6 bg-[#050508] rounded-xl border border-dashed border-shogun-border`,children:(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued italic`,children:u(`katana.no_rules`)})}):(0,G.jsx)(`div`,{className:`space-y-2`,children:n.map((t,r)=>{let i=St.find(e=>e.id===t.primary_model_id);return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 bg-[#050508] border border-shogun-border rounded-xl p-3 group`,children:[(0,G.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-shogun-blue/10 flex items-center justify-center shrink-0`,children:(0,G.jsx)(S,{className:`w-4 h-4 text-shogun-blue`})}),(0,G.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 md:grid-cols-4 gap-x-4 gap-y-1`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:u(`katana.task_type_label`)}),(0,G.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:t.task_type===`*`?u(`katana.all_tasks`):t.task_type})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:u(`katana.primary_model`)}),(0,G.jsx)(`p`,{className:`text-xs font-bold text-shogun-text truncate`,children:i?.name||(0,G.jsx)(`span`,{className:`text-red-400/70 text-[10px]`,children:u(`katana.unlinked`)})}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued mt-0.5`,children:[t.fallback_model_ids?.length||0,` fallback(s)`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:u(`katana.latency`)}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-text`,children:t.latency_bias||(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:`—`})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:u(`katana.cost`)}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-text`,children:t.cost_bias||(0,G.jsx)(`span`,{className:`text-shogun-subdued`,children:`—`})})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 flex-none pl-4 border-l border-shogun-border/30`,children:[(0,G.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),Br(r,t)},className:`flex items-center gap-2 px-3 py-1.5 rounded-lg bg-shogun-blue/10 border border-shogun-blue/20 hover:bg-shogun-blue/20 text-shogun-blue transition-all`,title:u(`common.edit`),children:[(0,G.jsx)(U,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,children:u(`common.edit`)})]}),(0,G.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),Hr(e.id,n,r)},className:`flex items-center gap-2 px-2 py-1.5 rounded-lg bg-red-500/5 border border-red-500/10 hover:bg-red-500/10 text-red-500 transition-all`,title:u(`common.delete`),children:[(0,G.jsx)(_e,{className:`w-3.5 h-3.5`}),(0,G.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,children:u(`common.delete`)})]})]})]},r)})}),ir&&(0,G.jsxs)(`div`,{className:`bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl p-4 space-y-4 animate-in slide-in-from-top-2 duration-200`,children:[(0,G.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest flex items-center gap-1.5`,children:lr===null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(oe,{className:`w-3 h-3`}),` `,u(`katana.new_routing_rule`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(U,{className:`w-3 h-3`}),` `,u(`katana.edit_routing_rule`)]})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.task_type`,`Task Type`)}),(0,G.jsxs)(`select`,{value:$.task_type,onChange:e=>cr({...$,task_type:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:`*`,children:u(`katana.all_tasks_wildcard`)}),(0,G.jsx)(`option`,{value:`research`,children:u(`katana.task_research`)}),(0,G.jsx)(`option`,{value:`code`,children:u(`katana.task_code`)}),(0,G.jsx)(`option`,{value:`analysis`,children:u(`katana.task_analysis`)}),(0,G.jsx)(`option`,{value:`creative`,children:u(`katana.task_creative`)}),(0,G.jsx)(`option`,{value:`summarize`,children:u(`katana.task_summarize`)}),(0,G.jsx)(`option`,{value:`planning`,children:u(`katana.task_planning`)}),(0,G.jsx)(`option`,{value:`qa`,children:u(`katana.task_qa`)}),(0,G.jsx)(`option`,{value:`chat`,children:u(`katana.task_chat`)}),(0,G.jsx)(`option`,{value:`extraction`,children:u(`katana.task_extraction`)}),(0,G.jsx)(`option`,{value:`translation`,children:u(`katana.task_translation`)}),(0,G.jsx)(`option`,{value:`vision`,children:u(`katana.task_vision`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.primary_model_provider`,`Primary Model Provider *`)}),(0,G.jsxs)(`select`,{value:$.primary_model_id,onChange:e=>cr({...$,primary_model_id:e.target.value,fallback_model_ids:$.fallback_model_ids.filter(t=>t!==e.target.value)}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:u(`katana.select_provider`)}),St.map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.name,` — `,e.provider_type]},e.id)),St.length===0&&(0,G.jsx)(`option`,{disabled:!0,children:u(`katana.no_providers_yet`)})]}),St.length===0&&(0,G.jsxs)(`p`,{className:`text-[9px] text-yellow-400`,children:[`⚠ `,u(`katana.add_provider_first`)]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5 md:col-span-2`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Fallback Chain (in order)`}),(0,G.jsxs)(`select`,{value:``,onChange:e=>{let t=e.target.value;t&&!$.fallback_model_ids.includes(t)&&cr({...$,fallback_model_ids:[...$.fallback_model_ids,t]})},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:`— Add fallback provider —`}),St.filter(e=>e.id!==$.primary_model_id&&!$.fallback_model_ids.includes(e.id)).map(e=>(0,G.jsxs)(`option`,{value:e.id,children:[e.name,` — `,e.provider_type]},e.id))]}),$.fallback_model_ids.map((e,t)=>{let n=St.find(t=>t.id===e);return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-shogun-border bg-[#050508] px-3 py-2`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-bold text-shogun-gold`,children:[`#`,t+1]}),(0,G.jsx)(`span`,{className:`flex-1 text-xs`,children:n?.name||`Unlinked provider`}),(0,G.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>{let e=[...$.fallback_model_ids];[e[t-1],e[t]]=[e[t],e[t-1]],cr({...$,fallback_model_ids:e})},className:`disabled:opacity-20`,children:(0,G.jsx)(c,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{type:`button`,disabled:t===$.fallback_model_ids.length-1,onClick:()=>{let e=[...$.fallback_model_ids];[e[t],e[t+1]]=[e[t+1],e[t]],cr({...$,fallback_model_ids:e})},className:`disabled:opacity-20`,children:(0,G.jsx)(a,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>cr({...$,fallback_model_ids:$.fallback_model_ids.filter(t=>t!==e)}),children:(0,G.jsx)(Ce,{className:`w-3.5 h-3.5 text-red-400`})})]},e)}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:`A model is tried after the previous model exhausts its configured retries or times out.`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.latency_bias`,`Latency Bias`)}),(0,G.jsxs)(`select`,{value:$.latency_bias,onChange:e=>cr({...$,latency_bias:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:u(`katana.none_unbiased`)}),(0,G.jsx)(`option`,{value:`low`,children:u(`katana.latency_low`)}),(0,G.jsx)(`option`,{value:`medium`,children:u(`katana.latency_medium`)}),(0,G.jsx)(`option`,{value:`high`,children:u(`katana.latency_high`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.cost_bias`,`Cost Bias`)}),(0,G.jsxs)(`select`,{value:$.cost_bias,onChange:e=>cr({...$,cost_bias:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none`,children:[(0,G.jsx)(`option`,{value:``,children:u(`katana.none_unbiased`)}),(0,G.jsx)(`option`,{value:`budget`,children:u(`katana.cost_budget`)}),(0,G.jsx)(`option`,{value:`standard`,children:u(`katana.cost_standard`)}),(0,G.jsx)(`option`,{value:`premium`,children:u(`katana.cost_premium`)})]})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 pt-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>Vr(e.id,n),disabled:!$.primary_model_id,className:`flex items-center gap-2 px-5 py-2 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 disabled:cursor-not-allowed text-white font-bold rounded-lg text-sm transition-all`,children:[(0,G.jsx)(j,{className:`w-3.5 h-3.5`}),` `,u(lr===null?`katana.save_rule`:`katana.update_rule`)]}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>{ar(!1),ur(null),cr({task_type:`*`,primary_model_id:``,fallback_model_ids:[],latency_bias:``,cost_bias:``})},className:`px-4 py-2 text-sm text-shogun-subdued hover:text-shogun-text transition-colors font-bold`,children:u(`common.cancel`)}),!$.primary_model_id&&(0,G.jsx)(`span`,{className:`text-[10px] text-shogun-subdued ml-auto`,children:u(`katana.select_provider_continue`)})]})]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2 mt-2 px-1`,children:[(0,G.jsx)(ke,{className:`w-3 h-3 text-shogun-subdued mt-0.5 shrink-0`}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:[u(`katana.routing_legend`),` `,(0,G.jsx)(`code`,{className:`text-shogun-blue font-mono`,children:`task_type`}),` `,u(`katana.routing_legend_wins`),`.`,u(`katana.routing_legend_wildcard`),` `,(0,G.jsx)(`code`,{className:`text-shogun-blue font-mono`,children:`*`}),` `,u(`katana.routing_legend_catch`),`.`]})]})]})]},e.id)})})]})]}),r===`teams`&&(0,G.jsx)(Je,{}),r===`telegram`&&(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(H,{className:`w-5 h-5 text-shogun-blue`}),` `,u(`katana.telegram_channel`)]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:u(`katana.telegram_desc`)})]}),f?.connected&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-green-400/10 border border-green-400/30 rounded-lg`,children:[(0,G.jsx)(ye,{className:`w-3.5 h-3.5 text-green-400`}),(0,G.jsx)(`span`,{className:`text-xs font-bold text-green-400`,children:u(`katana.connected`)})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-5 gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 space-y-5`,children:[f?.connected&&(0,G.jsxs)(`div`,{className:`shogun-card bg-green-400/5 border-green-400/20 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-green-400/10 border border-green-400/30 flex items-center justify-center`,children:(0,G.jsx)(H,{className:`w-6 h-6 text-green-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`font-bold text-shogun-text`,children:[`@`,f.bot_username]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[`Bot ID: `,f.bot_id,` · `,f.first_name]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[u(`katana.mode`),`: `,(0,G.jsx)(`span`,{className:`font-bold uppercase text-green-400`,children:f.mode}),f.last_connected_at&&(0,G.jsxs)(G.Fragment,{children:[` · `,new Date(f.last_connected_at).toLocaleDateString()]})]})]})]}),(0,G.jsxs)(`button`,{onClick:_r,className:`flex items-center gap-1.5 px-3 py-1.5 border border-red-400/30 text-red-400/70 hover:text-red-400 hover:border-red-400/50 rounded-lg text-xs font-bold transition-all`,children:[(0,G.jsx)(ve,{className:`w-3.5 h-3.5`}),` `,u(`katana.disconnect`)]})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:f?.connected?u(`katana.update_configuration`):u(`katana.connect_a_bot`)}),(0,G.jsxs)(`form`,{onSubmit:mr,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(P,{className:`w-3 h-3 text-shogun-gold`}),` `,u(`katana.bot_token`)]}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:Oe?`text`:`password`,required:!0,placeholder:f?.connected?`Enter new token to re-connect…`:`123456789:AAExxxxxxxx`,value:m,onChange:e=>x(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 pr-10 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>Ae(e=>!e),className:`absolute right-3 top-1/2 -translate-y-1/2 text-shogun-subdued hover:text-shogun-text`,children:Oe?(0,G.jsx)(Fe,{className:`w-3.5 h-3.5`}):(0,G.jsx)(v,{className:`w-3.5 h-3.5`})})]}),(0,G.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:[u(`katana.get_token_from`),` `,(0,G.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noreferrer`,className:`text-shogun-blue hover:underline`,children:`@BotFather`}),`.`]})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.update_mode`,`Update Mode`)}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[`polling`,`webhook`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:I(`flex-1 py-2 rounded-lg border text-xs font-bold uppercase tracking-widest transition-all`,C===e?`bg-shogun-blue text-white border-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/40`),children:u(e===`polling`?`katana.polling`:`katana.webhook`)},e))}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:u(C===`polling`?`katana.polling_desc`:`katana.webhook_desc`)})]}),C===`webhook`&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.webhook_url`,`Webhook URL *`)}),(0,G.jsx)(`input`,{type:`url`,required:!0,placeholder:`https://yourdomain.com/telegram/webhook`,value:re,onChange:e=>ie(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,G.jsx)(ke,{className:`w-3 h-3 text-shogun-gold`}),` `,u(`katana.allowed_chat_ids`),(0,G.jsxs)(`span`,{className:`font-normal normal-case tracking-normal text-shogun-subdued/50`,children:[`(`,u(`katana.optional_whitelist`),`)`]})]}),(0,G.jsx)(`input`,{type:`text`,placeholder:`e.g. 123456789, -987654321`,value:ae,onChange:e=>O(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:u(`katana.chat_ids_help`)})]}),(0,G.jsx)(`button`,{type:`submit`,disabled:de||!m.trim(),className:`w-full flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm transition-all`,children:de?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}),` `,u(`katana.connecting`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(H,{className:`w-4 h-4`}),` `,f?.connected?u(`katana.update_connection`):u(`katana.connect_bot`)]})})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-5`,children:[(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(le,{className:`w-4 h-4 text-shogun-blue`}),` `,u(`katana.test_connection`)]}),f?.connected?(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(`input`,{type:`text`,placeholder:`Your chat ID, e.g. 123456789`,value:A,onChange:e=>ue(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`button`,{onClick:hr,disabled:me||!A.trim(),className:`w-full flex items-center justify-center gap-2 py-2.5 border border-shogun-blue/40 bg-shogun-blue/10 hover:bg-shogun-blue/20 text-shogun-blue disabled:opacity-40 font-bold rounded-lg text-sm transition-all`,children:me?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(k,{className:`w-3.5 h-3.5 animate-spin`}),` `,u(`katana.sending`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(le,{className:`w-3.5 h-3.5`}),` `,u(`katana.send_test`)]})}),M&&(0,G.jsxs)(`div`,{className:I(`p-3 rounded-lg text-xs flex items-start gap-2`,M.ok?`bg-green-400/10 border border-green-400/20 text-green-400`:`bg-red-400/10 border border-red-400/20 text-red-400`),children:[M.ok?(0,G.jsx)(i,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}):(0,G.jsx)(l,{className:`w-3.5 h-3.5 shrink-0 mt-0.5`}),M.message||M.error]})]}):(0,G.jsx)(`p`,{className:`text-center py-6 text-shogun-subdued text-xs italic`,children:u(`katana.connect_bot_first`)})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(s,{className:`w-4 h-4 text-shogun-gold`}),` `,u(`katana.quick_setup`)]}),(0,G.jsx)(`ol`,{className:`space-y-3`,children:[{n:`1`,t:u(`katana.tg_step1`),href:`https://t.me/BotFather`},{n:`2`,t:u(`katana.tg_step2`)},{n:`3`,t:u(`katana.tg_step3`)},{n:`4`,t:u(`katana.tg_step4`)},{n:`5`,t:u(`katana.tg_step5`)}].map(({n:e,t,href:n})=>(0,G.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`span`,{className:`w-5 h-5 rounded-full bg-shogun-blue/20 border border-shogun-blue/40 text-shogun-blue text-[9px] font-bold flex items-center justify-center shrink-0 mt-0.5`,children:e}),(0,G.jsxs)(`span`,{className:`text-xs text-shogun-subdued leading-relaxed`,children:[t,n&&(0,G.jsxs)(G.Fragment,{children:[` — `,(0,G.jsx)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,className:`text-shogun-blue hover:underline`,children:n.split(`//`)[1]})]})]})]},e))}),(0,G.jsxs)(`div`,{className:`pt-2 border-t border-shogun-border mt-3`,children:[(0,G.jsxs)(`button`,{onClick:gr,disabled:Te,className:`w-full flex items-center justify-center gap-2 py-2 border border-shogun-gold/30 bg-shogun-gold/10 hover:bg-shogun-gold/20 text-shogun-gold disabled:opacity-40 font-bold rounded-lg text-xs transition-all`,children:[Te?(0,G.jsx)(k,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(ce,{className:`w-3.5 h-3.5`}),u(`katana.auto_detect_chat_id`)]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued text-center mt-2 leading-tight`,children:[u(`katana.must_complete_step5`),` `,(0,G.jsx)(`br`,{}),u(`katana.auto_whitelist_desc`)]})]})]})]})]})]}),r===`telegram`&&Me.length>0&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 mt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(H,{className:`w-4 h-4 text-sky-400`}),` Forum Topic Mapping`]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:[`Thread IDs are captured automatically. Name older topics here, or send `,(0,G.jsx)(`b`,{children:`*strategy`}),`, `,(0,G.jsx)(`b`,{children:`*research`}),`, `,(0,G.jsx)(`b`,{children:`*shogun`}),`, `,(0,G.jsx)(`b`,{children:`*personal`}),`, `,(0,G.jsx)(`b`,{children:`*education`}),`, `,(0,G.jsx)(`b`,{children:`*general`}),`, or `,(0,G.jsx)(`b`,{children:`*news`}),` inside a topic to teach Shogun automatically.`]})]}),Me.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-shogun-border bg-[#050508] p-3 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,G.jsx)(`b`,{children:e.chat_title||`Telegram group`}),(0,G.jsx)(`span`,{className:`font-mono text-[9px] text-shogun-subdued`,children:e.chat_id})]}),(e.topics||[]).length===0?(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`No forum threads observed yet. Send one message in each topic.`}):(e.topics||[]).map(t=>{let n=`${e.chat_id}:${t.message_thread_id}`;return(0,G.jsxs)(`div`,{className:`grid grid-cols-[90px_minmax(0,1fr)_90px] items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-sky-400`,children:[`Thread `,t.message_thread_id]}),(0,G.jsx)(`input`,{value:Ie[n]||``,onChange:e=>Le(t=>({...t,[n]:e.target.value})),placeholder:`Enter topic name`,className:`w-full bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-xs focus:border-sky-400 outline-none`}),(0,G.jsx)(`button`,{onClick:()=>pr(e.chat_id,t.message_thread_id),disabled:Re===n||!(Ie[n]||``).trim(),className:`rounded-lg border border-sky-400/30 bg-sky-400/10 px-3 py-2 text-[10px] font-bold text-sky-300 disabled:opacity-40`,children:Re===n?`SAVING`:`SAVE`})]},n)})]},e.chat_id))]}),r===`mail_calendar`&&(0,G.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-300`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,G.jsx)(E,{className:`w-5 h-5 text-shogun-blue`}),` `,u(`katana.mail_calendar_settings`,`Mail & Calendar Settings`)]}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:u(`katana.mail_calendar_desc`,`Configure a single email and calendar account to send/receive mail and manage events.`)})]}),z?.is_active&&(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-green-400/10 border border-green-400/30 rounded-lg`,children:[(0,G.jsx)(ye,{className:`w-3.5 h-3.5 text-green-400`}),(0,G.jsx)(`span`,{className:`text-xs font-bold text-green-400`,children:u(`katana.connected`,`Connected`)})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-5 gap-6`,children:[(0,G.jsxs)(`div`,{className:`lg:col-span-3 space-y-5`,children:[z?.is_active&&(0,G.jsxs)(`div`,{className:`shogun-card bg-green-400/5 border-green-400/20 flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-green-400/10 border border-green-400/30 flex items-center justify-center`,children:(0,G.jsx)(E,{className:`w-6 h-6 text-green-400`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-bold text-shogun-text`,children:z.display_name||z.email_address}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued mt-0.5`,children:[z.email_address,` · `,z.provider.toUpperCase()]}),(0,G.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[u(`katana.calendar_integrated`,`Calendar`),`: `,(0,G.jsx)(`span`,{className:`font-bold uppercase text-green-400`,children:z.calendar_provider})]})]})]}),(0,G.jsxs)(`button`,{onClick:br,className:`flex items-center gap-1.5 px-3 py-1.5 border border-red-400/30 text-red-400/70 hover:text-red-400 hover:border-red-400/50 rounded-lg text-xs font-bold transition-all`,children:[(0,G.jsx)(ve,{className:`w-3.5 h-3.5`}),` `,u(`katana.disconnect`,`Disconnect`)]})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-bold text-shogun-text`,children:z?.is_active?u(`katana.update_mail_config`,`Update Connection Settings`):u(`katana.connect_mail_account`,`Connect Email Account`)}),(0,G.jsxs)(`form`,{onSubmit:yr,className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.mail_provider`,`Provider`)}),(0,G.jsxs)(`select`,{value:B.provider,onChange:e=>V({...B,provider:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none text-shogun-text`,children:[(0,G.jsx)(`option`,{value:`gmail`,children:`Google Gmail`}),(0,G.jsx)(`option`,{value:`outlook`,children:`Microsoft Outlook`}),(0,G.jsx)(`option`,{value:`proton`,children:`Proton Mail (Bridge)`}),(0,G.jsx)(`option`,{value:`other`,children:`Other / Custom IMAP`})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.display_name`,`Display Name`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`e.g. Shogun Agent`,value:B.display_name,onChange:e=>V({...B,display_name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.email_address`,`Email Address`)}),(0,G.jsx)(`input`,{type:`email`,required:!0,placeholder:`e.g. user@domain.com`,value:B.email_address,onChange:e=>V({...B,email_address:e.target.value,username:B.username||e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider`,children:u(`katana.incoming_mail_server`,`Incoming Mail Server`)}),(0,G.jsx)(`div`,{className:`flex gap-2`,children:[`imap`,`pop3`].map(e=>(0,G.jsx)(`button`,{type:`button`,onClick:()=>V({...B,protocol:e}),className:I(`px-3 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider border transition-all`,B.protocol===e?`bg-shogun-blue text-white border-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-blue/40`),children:e.toUpperCase()},e))})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsxs)(`div`,{className:`col-span-2 space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.incoming_host`,`Host`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`imap.example.com`,value:B.imap_host,onChange:e=>V({...B,imap_host:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.incoming_port`,`Port`)}),(0,G.jsx)(`input`,{type:`number`,required:!0,value:B.imap_port,onChange:e=>V({...B,imap_port:parseInt(e.target.value)||0}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:B.imap_use_ssl,onChange:e=>V({...B,imap_use_ssl:e.target.checked}),className:`accent-shogun-blue`}),u(`katana.incoming_ssl`,`Use SSL/TLS for Incoming Mail`)]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider block`,children:u(`katana.outgoing_mail_server`,`Outgoing SMTP Server`)}),(0,G.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,G.jsxs)(`div`,{className:`col-span-2 space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.outgoing_host`,`Host`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`smtp.example.com`,value:B.smtp_host,onChange:e=>V({...B,smtp_host:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.outgoing_port`,`Port`)}),(0,G.jsx)(`input`,{type:`number`,required:!0,value:B.smtp_port,onChange:e=>V({...B,smtp_port:parseInt(e.target.value)||0}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer text-xs text-shogun-subdued hover:text-shogun-text transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:B.smtp_use_ssl,onChange:e=>V({...B,smtp_use_ssl:e.target.checked}),className:`accent-shogun-blue`}),u(`katana.outgoing_ssl`,`Use SSL/TLS for Outgoing Mail`)]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider block`,children:u(`katana.auth`,`Authentication`)}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.username`,`Username`)}),(0,G.jsx)(`input`,{type:`text`,required:!0,placeholder:`e.g. user@domain.com`,value:B.username,onChange:e=>V({...B,username:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none`})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center justify-between`,children:(0,G.jsx)(`span`,{children:u(`katana.password`,`Password`)})}),(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(`input`,{type:$e?`text`:`password`,required:!z,placeholder:z?`••••••••`:`Password or App Password`,value:B.password,onChange:e=>V({...B,password:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 pr-10 text-sm focus:border-shogun-blue outline-none font-mono`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>et(e=>!e),className:`absolute right-3 top-1/2 -translate-y-1/2 text-shogun-subdued hover:text-shogun-text`,children:$e?(0,G.jsx)(Fe,{className:`w-3.5 h-3.5`}):(0,G.jsx)(v,{className:`w-3.5 h-3.5`})})]})]})]})]}),(0,G.jsxs)(`div`,{className:`pt-4 border-t border-shogun-border/40 space-y-4`,children:[(0,G.jsx)(`span`,{className:`text-xs font-bold text-shogun-text uppercase tracking-wider block`,children:u(`katana.calendar_integration`,`Calendar Integration`)}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.calendar_provider`,`Provider`)}),(0,G.jsxs)(`select`,{value:B.calendar_provider,onChange:e=>V({...B,calendar_provider:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none text-shogun-text`,children:[(0,G.jsx)(`option`,{value:`none`,children:`None / Disabled`}),(0,G.jsx)(`option`,{value:`caldav`,children:`CalDAV (Proton / Generic)`}),(0,G.jsx)(`option`,{value:`google_api`,children:`Google Calendar API`}),(0,G.jsx)(`option`,{value:`microsoft_graph`,children:`Microsoft Graph`})]})]}),B.calendar_provider===`caldav`&&(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:u(`katana.caldav_url`,`CalDAV URL`)}),(0,G.jsx)(`input`,{type:`url`,required:!0,placeholder:`https://caldav.example.com`,value:B.caldav_url,onChange:e=>V({...B,caldav_url:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none font-mono`})]})]})]}),qe&&(0,G.jsxs)(`div`,{className:I(`p-4 rounded-lg text-xs space-y-2 border`,qe.ok?`bg-green-400/10 border-green-400/20 text-green-400`:`bg-red-400/10 border-red-400/20 text-red-400`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-bold`,children:[qe.ok?(0,G.jsx)(i,{className:`w-4 h-4`}):(0,G.jsx)(l,{className:`w-4 h-4`}),(0,G.jsx)(`span`,{children:qe.ok?u(`katana.test_successful`,`All connections successful!`):u(`katana.test_failed`,`Connection tests failed`)})]}),(0,G.jsx)(`p`,{className:`text-[10px] leading-relaxed opacity-90`,children:qe.message}),(0,G.jsxs)(`div`,{className:`flex gap-4 pt-1 text-[10px]`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:I(`w-1.5 h-1.5 rounded-full`,qe.imap_ok?`bg-green-400`:`bg-red-400`)}),`Incoming Server Login: `,qe.imap_ok?`OK`:`FAIL`]}),(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:I(`w-1.5 h-1.5 rounded-full`,qe.smtp_ok?`bg-green-400`:`bg-red-400`)}),`Outgoing SMTP Login: `,qe.smtp_ok?`OK`:`FAIL`]})]})]}),(0,G.jsxs)(`div`,{className:`flex gap-4 pt-2`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:xr,disabled:Ge||!B.email_address||!B.username,className:`flex-1 flex items-center justify-center gap-2 py-3 border border-shogun-blue/40 bg-shogun-blue/10 hover:bg-shogun-blue/20 text-shogun-blue disabled:opacity-40 font-bold rounded-lg text-sm transition-all`,children:[Ge?(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(le,{className:`w-4 h-4`}),u(`katana.test_connection`,`Test Connection`)]}),(0,G.jsxs)(`button`,{type:`submit`,disabled:He||!B.email_address||!B.username,className:`flex-1 flex items-center justify-center gap-2 py-3 bg-shogun-blue hover:bg-shogun-blue/90 disabled:opacity-40 text-white font-bold rounded-lg text-sm transition-all`,children:[He?(0,G.jsx)(k,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(j,{className:`w-4 h-4`}),z?.is_active?u(`katana.save_settings`,`Save Settings`):u(`katana.connect_account`,`Connect Account`)]})]})]})]})]}),(0,G.jsxs)(`div`,{className:`lg:col-span-2 space-y-5`,children:[z&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(P,{className:`w-4 h-4 text-shogun-gold`}),u(`katana.permissions_toggles`,`Account Scopes`)]}),(0,G.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:u(`katana.permissions_help`,`Choose which operations this connected account exposes. ToolGate remains the runtime authority and may further restrict or require confirmation for every action.`)}),(0,G.jsx)(`div`,{className:`space-y-3 pt-2`,children:[{key:`perm_read_mail`,label:u(`katana.perm_read_mail`,`📨 Read Mail (Inbox/Folders)`)},{key:`perm_send_mail`,label:u(`katana.perm_send_mail`,`✉️ Send / Reply to Mail`)},{key:`perm_delete_mail`,label:u(`katana.perm_delete_mail`,`🗑️ Delete Mail (Move to Trash)`)},{key:`perm_read_calendar`,label:u(`katana.perm_read_calendar`,`📅 Read Calendar Events`)},{key:`perm_create_events`,label:u(`katana.perm_create_events`,`➕ Create Calendar Events`)},{key:`perm_edit_events`,label:u(`katana.perm_edit_events`,`✏️ Edit Calendar Events`)},{key:`perm_delete_events`,label:u(`katana.perm_delete_events`,`🗑️ Delete Calendar Events`)}].map(({key:e,label:t})=>(0,G.jsxs)(`label`,{className:`flex items-center justify-between py-2 border-b border-shogun-border/30 cursor-pointer group`,children:[(0,G.jsx)(`span`,{className:`text-xs text-shogun-subdued group-hover:text-shogun-text transition-colors`,children:t}),(0,G.jsx)(`input`,{type:`checkbox`,checked:Xe[e],onChange:t=>Qe({...Xe,[e]:t.target.checked}),className:`w-4 h-4 accent-shogun-blue cursor-pointer`})]},e))}),(0,G.jsxs)(`button`,{onClick:Sr,disabled:He,className:`w-full flex items-center justify-center gap-2 py-2.5 mt-2 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold rounded-lg text-xs transition-all`,children:[He?(0,G.jsx)(k,{className:`w-3.5 h-3.5 animate-spin`}):(0,G.jsx)(j,{className:`w-3.5 h-3.5`}),u(`katana.save_permissions`,`Save Permissions`)]}),(0,G.jsx)(`button`,{onClick:()=>e(`/toolgate`),className:`w-full rounded-lg border border-shogun-border py-2.5 text-xs font-bold text-shogun-blue transition-colors hover:border-shogun-blue/40 hover:bg-shogun-blue/10`,children:`View effective rules in ToolGate`})]}),(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`h4`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(s,{className:`w-4 h-4 text-shogun-gold`}),u(`katana.setup_guides`,`Quick Setup Guide`)]}),(0,G.jsxs)(`div`,{className:`text-xs space-y-4`,children:[B.provider===`gmail`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Google Gmail Setup:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-4 space-y-1.5 text-shogun-subdued text-[11px] leading-relaxed`,children:[(0,G.jsx)(`li`,{children:`Go to your Google Account settings → Security.`}),(0,G.jsxs)(`li`,{children:[`Ensure `,(0,G.jsx)(`strong`,{children:`2-Step Verification`}),` is enabled.`]}),(0,G.jsxs)(`li`,{children:[`Click on `,(0,G.jsx)(`strong`,{children:`App passwords`}),` (or search for it).`]}),(0,G.jsx)(`li`,{children:`Generate a new app password for "Mail" on your device.`}),(0,G.jsx)(`li`,{children:`Use your Gmail address as username and the 16-character generated password to connect.`})]})]}),B.provider===`outlook`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Outlook / Office 365 Setup:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-4 space-y-1.5 text-shogun-subdued text-[11px] leading-relaxed`,children:[(0,G.jsx)(`li`,{children:`Log in to your Outlook Account security settings.`}),(0,G.jsxs)(`li`,{children:[`Select `,(0,G.jsx)(`strong`,{children:`Manage how I sign in`}),` → App passwords.`]}),(0,G.jsx)(`li`,{children:`Create a new App Password.`}),(0,G.jsx)(`li`,{children:`Use your Outlook email address and the App Password to connect.`}),(0,G.jsx)(`li`,{children:`For Exchange accounts, verify IMAP access is enabled in Outlook settings.`})]})]}),B.provider===`proton`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Proton Mail (Bridge) Setup:`}),(0,G.jsxs)(`ol`,{className:`list-decimal pl-4 space-y-1.5 text-shogun-subdued text-[11px] leading-relaxed`,children:[(0,G.jsxs)(`li`,{children:[`Download and open the `,(0,G.jsx)(`strong`,{children:`Proton Mail Bridge`}),` application.`]}),(0,G.jsx)(`li`,{children:`Add your Proton account to the Bridge and wait for local encryption to sync.`}),(0,G.jsx)(`li`,{children:`Go to Bridge settings to view the local IMAP port, SMTP port, and Bridge password.`}),(0,G.jsxs)(`li`,{children:[`Set host to `,(0,G.jsx)(`code`,{className:`text-shogun-blue font-mono bg-[#050508] px-1 rounded`,children:`127.0.0.1`}),`.`]}),(0,G.jsx)(`li`,{children:`Use the ports provided by the Bridge (default: IMAP 1143, SMTP 1025) and disable SSL/TLS toggles (the Bridge encrypts traffic locally).`})]})]}),B.provider===`other`&&(0,G.jsxs)(`div`,{className:`space-y-2 animate-in fade-in duration-200`,children:[(0,G.jsx)(`h5`,{className:`font-bold text-shogun-blue`,children:`Generic Mail Provider:`}),(0,G.jsx)(`p`,{className:`text-[11px] text-shogun-subdued leading-relaxed`,children:`Enter your custom IMAP and SMTP server details (hostnames, ports, and SSL settings) as provided by your email provider. Ensure your credentials are correct.`})]})]})]})]})]})]}),r===`office`&&(0,G.jsxs)(`div`,{className:`space-y-6`,children:[it===`shrine`&&(0,G.jsxs)(`div`,{className:`rounded-xl border border-red-500/30 bg-red-500/10 p-5 flex items-center gap-4`,children:[(0,G.jsx)(l,{className:`w-6 h-6 text-red-400 flex-shrink-0`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-bold text-red-400`,children:`Office Disabled at SHRINE Posture`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`Office App Mode is blocked at SHRINE security tier. Raise your posture in Torii to at least GUARDED to use Office automation.`})]})]}),(0,G.jsxs)(`div`,{className:I(it===`shrine`&&`opacity-40 pointer-events-none select-none`),children:[K&&(0,G.jsxs)(`div`,{className:I(`rounded-xl border p-5 transition-all duration-500 mb-6`,K.enabled?`border-green-500/40 bg-gradient-to-r from-[#0f1422] to-[#131926] shadow-xl shadow-green-500/10`:`border-shogun-border bg-shogun-card`),children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsx)(`div`,{className:I(`p-3 rounded-xl transition-colors duration-500`,K.enabled?`bg-green-500/15 text-green-400`:`bg-shogun-bg text-shogun-subdued`),children:(0,G.jsx)(se,{className:`w-6 h-6`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-lg font-semibold text-shogun-text`,children:`Office App Mode`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:K.enabled?`Active — AI agents can interact with Office applications`:`Disabled — Enable to allow Office automation`})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[ut&&(0,G.jsx)(`span`,{className:`text-xs text-amber-400 animate-pulse`,children:`Unsaved`}),(0,G.jsxs)(`button`,{onClick:mt,disabled:ot||!ut,className:I(`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-all`,ut?`bg-shogun-gold text-black hover:bg-[#e6b422] shadow-lg shadow-shogun-gold/20`:`bg-shogun-border text-shogun-subdued cursor-not-allowed`),children:[ot?(0,G.jsx)(F,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(j,{className:`w-4 h-4`}),` Save`]}),(0,G.jsx)(`button`,{onClick:()=>gt(`enabled`,!K.enabled),className:I(`relative w-14 h-7 rounded-full transition-all duration-500`,K.enabled?`bg-green-500`:`bg-shogun-border`),children:(0,G.jsx)(`span`,{className:I(`absolute top-1 w-5 h-5 rounded-full bg-white shadow-lg transition-transform duration-500`,K.enabled?`translate-x-8 left-0`:`left-1`)})})]})]}),!tt?.platform_supported&&(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-amber-400 bg-amber-500/10 rounded-lg p-3`,children:[(0,G.jsx)(l,{className:`w-4 h-4 flex-shrink-0`}),(0,G.jsx)(`span`,{children:tt?.message||`Office App Mode requires Windows with Microsoft Office installed.`})]})]}),tt&&K&&(0,G.jsxs)(`div`,{className:`space-y-3 mb-6`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-shogun-subdued uppercase tracking-wider`,children:`Applications`}),(0,G.jsxs)(`button`,{onClick:ht,disabled:ct,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-shogun-subdued bg-shogun-bg hover:bg-shogun-border border border-shogun-border transition-all`,children:[(0,G.jsx)(k,{className:I(`w-3.5 h-3.5`,ct&&`animate-spin`)}),` Re-detect`]})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`,children:[{app:tt.excel,key:`excel`,icon:y,color:`text-green-400`,label:`Excel`},{app:tt.word,key:`word`,icon:ee,color:`text-blue-400`,label:`Word`},{app:tt.powerpoint,key:`powerpoint`,icon:w,color:`text-orange-400`,label:`PowerPoint`},{app:tt.outlook,key:`outlook`,icon:E,color:`text-cyan-400`,label:`Outlook`}].map(({app:e,key:t,icon:n,color:r,label:i})=>(0,G.jsxs)(`div`,{className:I(`relative rounded-xl border p-5 transition-all duration-300`,e?.installed&&K[t]?.enabled?`border-shogun-gold/30 bg-shogun-card shadow-lg shadow-shogun-gold/5`:`border-shogun-border bg-shogun-bg/60 opacity-70`),children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between mb-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`div`,{className:I(`p-2.5 rounded-lg bg-shogun-bg`,r),children:(0,G.jsx)(n,{className:`w-5 h-5`})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-shogun-text`,children:i}),e?.version&&(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:[`v`,e.version]})]})]}),(0,G.jsx)(`button`,{onClick:()=>gt(`${t}.enabled`,!K[t]?.enabled),disabled:!e?.installed,className:I(`relative w-10 h-5 rounded-full transition-all duration-300`,K[t]?.enabled&&e?.installed?`bg-shogun-gold`:`bg-shogun-border`,!e?.installed&&`opacity-40 cursor-not-allowed`),children:(0,G.jsx)(`span`,{className:I(`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-md transition-transform duration-300`,K[t]?.enabled&&e?.installed?`translate-x-5 left-0.5`:`left-0.5`)})})]}),(0,G.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:(0,G.jsxs)(`span`,{className:I(`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium tracking-wide`,e?.installed?`bg-emerald-500/15 text-emerald-400 ring-1 ring-emerald-500/30`:`bg-red-500/15 text-red-400 ring-1 ring-red-500/30`),children:[e?.installed?(0,G.jsx)(d,{className:`w-3.5 h-3.5`}):(0,G.jsx)(Ce,{className:`w-3.5 h-3.5`}),e?.installed?`Installed`:`Not found`]})})]},t))})]}),K&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(b,{className:`w-4 h-4 text-shogun-gold`}),` Approved Folders`]}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`All file operations are restricted to these folders. Files outside these boundaries will be rejected. By default, these map to subdirectories inside the `,(0,G.jsx)(`span`,{className:`text-shogun-gold font-medium`,children:`Agent Workspace`}),`.`]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[`input`,`output`,`templates`,`temp`].map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-shogun-subdued mb-1.5 capitalize`,children:e}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(te,{className:`w-4 h-4 text-shogun-subdued flex-shrink-0`}),(0,G.jsx)(`input`,{type:`text`,value:K.folders?.[e]||``,onChange:t=>gt(`folders.${e}`,t.target.value),placeholder:`workspace/${e}`,className:`flex-1 bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text placeholder-shogun-subdued/40 focus:outline-none focus:border-shogun-gold/50 transition-colors font-mono`})]})]},e))}),(0,G.jsxs)(`div`,{className:`bg-shogun-blue/5 border border-shogun-blue/20 rounded-lg p-3 flex items-start gap-2`,children:[(0,G.jsx)(ee,{className:`w-4 h-4 text-shogun-blue flex-shrink-0 mt-0.5`}),(0,G.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`Leave paths empty to auto-map to the `,(0,G.jsx)(`span`,{className:`text-shogun-blue font-medium`,children:`Workspace`}),` root folder (data/workspace). The Workspace is shared between Shogun, Samurai, and the File Explorer in Comms.`]})]})]}),K&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4 mb-6`,children:[(0,G.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(ke,{className:`w-4 h-4 text-shogun-gold`}),` Safety & Security`]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:[{key:`safety.block_path_traversal`,label:`Block path traversal`,desc:`Prevent ../ escape attacks`},{key:`safety.block_shortcuts`,label:`Block .lnk files`,desc:`Prevent shortcut escape`},{key:`safety.block_unc_paths`,label:`Block UNC paths`,desc:`Prevent network path access`},{key:`safety.version_outputs`,label:`Version outputs`,desc:`Auto-timestamp output files`},{key:`safety.require_output_validation`,label:`Validate outputs`,desc:`Verify output file integrity`},{key:`temp_cleanup_on_startup`,label:`Cleanup temp on startup`,desc:`Remove temp files at boot`}].map(e=>{let t=e.key.split(`.`),n=t.length===2?K[t[0]]?.[t[1]]:K[t[0]];return(0,G.jsxs)(`label`,{className:`flex items-start gap-3 p-3 rounded-lg bg-shogun-bg border border-shogun-border cursor-pointer hover:border-shogun-gold/20 transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!n,onChange:()=>gt(e.key,!n),className:`mt-0.5 accent-[#d4a017]`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm text-shogun-text font-medium`,children:e.label}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:e.desc})]})]},e.key)})})]}),K&&(0,G.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,G.jsxs)(`div`,{className:`font-bold text-shogun-text flex items-center gap-2`,children:[(0,G.jsx)(E,{className:`w-4 h-4 text-cyan-400`}),` Outlook Settings`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-shogun-subdued mb-2`,children:`Outlook Mode`}),(0,G.jsx)(`div`,{className:`flex gap-3`,children:[{value:`draft_only`,label:`Draft Only`,desc:`Create drafts, never send`},{value:`confirmed_send`,label:`Confirmed Send`,desc:`Send with approval`},{value:`approved_recipient_send`,label:`Approved Recipients`,desc:`Auto-send to allowlist`}].map(e=>(0,G.jsxs)(`button`,{onClick:()=>gt(`outlook.mode`,e.value),className:I(`flex-1 p-3 rounded-lg border text-left transition-all`,K.outlook?.mode===e.value?`border-shogun-gold/50 bg-shogun-gold/10`:`border-shogun-border bg-shogun-bg hover:border-shogun-gold/20`),children:[(0,G.jsx)(`p`,{className:I(`text-sm font-medium`,K.outlook?.mode===e.value?`text-shogun-gold`:`text-shogun-text`),children:e.label}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:e.desc})]},e.value))})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-start gap-3 p-3 rounded-lg bg-shogun-bg border border-shogun-border cursor-pointer hover:border-shogun-gold/20 transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!K.outlook?.require_confirmation,onChange:()=>gt(`outlook.require_confirmation`,!K.outlook?.require_confirmation),className:`mt-0.5 accent-[#d4a017]`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm text-shogun-text font-medium`,children:`Require confirmation`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:`Human must approve before sending`})]})]}),(0,G.jsxs)(`label`,{className:`flex items-start gap-3 p-3 rounded-lg bg-shogun-bg border border-shogun-border cursor-pointer hover:border-shogun-gold/20 transition-colors`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:!!K.outlook?.allow_external_recipients,onChange:()=>gt(`outlook.allow_external_recipients`,!K.outlook?.allow_external_recipients),className:`mt-0.5 accent-[#d4a017]`}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`text-sm text-shogun-text font-medium`,children:`Allow external recipients`}),(0,G.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-0.5`,children:`Send to domains outside the allowlist`})]})]})]})]}),!tt&&!K&&(0,G.jsx)(`div`,{className:`flex items-center justify-center h-40`,children:(0,G.jsx)(F,{className:`w-6 h-6 text-shogun-gold animate-spin`})})]})]}),r===`mado`&&(0,G.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,G.jsx)(Ze,{})}),r===`ide`&&(0,G.jsx)(_t,{}),r===`ronin`&&(0,G.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,G.jsx)(dt,{})}),r===`skillopt`&&(0,G.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,G.jsx)(Mt,{})})]})]})}export{qt as Katana}; \ No newline at end of file diff --git a/frontend/dist/assets/Logs-6JYps80J.js b/frontend/dist/assets/Logs-6JYps80J.js deleted file mode 100644 index d65005b..0000000 --- a/frontend/dist/assets/Logs-6JYps80J.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{t as i}from"./activity-D6ZKsL_W.js";import{t as a}from"./brain-3sva6MW8.js";import{t as o}from"./circle-alert-DVHRBFRQ.js";import{t as s}from"./circle-check-D9mntLsp.js";import{t as c}from"./circle-x-dN_LIrKM.js";import{t as l}from"./cpu-jON2DlCR.js";import{t as u}from"./download-OoiqiOHD.js";import{t as d}from"./eye-DuX8zHAU.js";import{t as ee}from"./file-key-B5dIYAeh.js";import{t as f}from"./funnel-BttEh0de.js";import{t as p}from"./info-CXnsqgVr.js";import{t as m}from"./link-2-DtQcNcp-.js";import{t as h}from"./loader-circle-yHzGFbgr.js";import{t as g}from"./refresh-cw-CCrS0Omg.js";import{t as _}from"./scale-fLrESr22.js";import{t as v}from"./search-CCF8DUSp.js";import{t as y}from"./shield-B_MY4jWU.js";import{t as b}from"./terminal-CmBetb-2.js";import{t as x}from"./trash-2-Cid5DKqF.js";import{t as S}from"./wrench-D1anTovu.js";import{t as C}from"./x-Bu7rztmN.js";import{t as w}from"./zap-BMpqZS6N.js";import{t as T}from"./utils-wrb6h48Y.js";import{r as E}from"./i18n-FxgwkwP0.js";import{t as D}from"./axios-BPyV2soB.js";var O=e(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),k=t(n(),1),A=r(),j=[{key:`all`,label:`All Events`,icon:b,color:`text-shogun-blue`},{key:`decision`,label:`Decision`,icon:_,color:`text-violet-400`},{key:`oversight`,label:`Oversight`,icon:d,color:`text-amber-400`},{key:`risk`,label:`Risk`,icon:O,color:`text-rose-400`},{key:`model`,label:`Model`,icon:l,color:`text-shogun-gold`},{key:`policy`,label:`Policy`,icon:y,color:`text-blue-400`},{key:`memory`,label:`Memory`,icon:a,color:`text-cyan-400`},{key:`tool`,label:`Tools`,icon:S,color:`text-green-400`},{key:`auth`,label:`Auth`,icon:y,color:`text-purple-400`},{key:`incident`,label:`Incident`,icon:w,color:`text-red-400`},{key:`system`,label:`System`,icon:i,color:`text-shogun-subdued`}];function M(e){return e?.toLowerCase()||`info`}function N(e){switch(M(e)){case`critical`:return`text-red-400 bg-red-500/10 border-red-500/30`;case`error`:return`text-red-500 bg-red-500/5 border-red-500/20`;case`warn`:return`text-yellow-400 bg-yellow-500/5 border-yellow-500/20`;default:return`text-shogun-blue bg-shogun-blue/5 border-shogun-blue/20`}}function P(e){return j.find(t=>t.key===e)||j[0]}function F(e){switch(e?.toLowerCase()){case`success`:return(0,A.jsx)(s,{className:`w-3 h-3 text-green-500`});case`denied`:return(0,A.jsx)(c,{className:`w-3 h-3 text-red-400`});case`error`:return(0,A.jsx)(o,{className:`w-3 h-3 text-red-500`});default:return(0,A.jsx)(p,{className:`w-3 h-3 text-shogun-subdued`})}}function I(){let{t:e}=E(),[t,n]=(0,k.useState)(!0),[r,a]=(0,k.useState)([]),[c,l]=(0,k.useState)(!0),[d,p]=(0,k.useState)(``),[_,S]=(0,k.useState)(`all`),[w,O]=(0,k.useState)(`all`),[I,L]=(0,k.useState)(!1),[R,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(null),[H,te]=(0,k.useState)([]),[ne,U]=(0,k.useState)(!1),[W,G]=(0,k.useState)(null),[K,q]=(0,k.useState)({}),J=(0,k.useRef)(null),Y=(0,k.useRef)(null),X=(0,k.useCallback)(async()=>{try{let e={limit:`300`};_!==`all`&&(e.severity=_),w!==`all`&&(e.category=w),a([...(await D.get(`/api/v1/logs`,{params:e})).data.data||[]].reverse())}catch(e){console.error(`Error fetching logs:`,e)}finally{n(!1)}},[_,w]),Z=(0,k.useCallback)(async()=>{try{q((await D.get(`/api/v1/logs/categories`)).data.data?.categories||{})}catch{}},[]),re=(0,k.useCallback)(async()=>{try{G((await D.get(`/api/v1/logs/audit/verify`)).data.data)}catch{}},[]),ie=(0,k.useCallback)(async e=>{try{te((await D.get(`/api/v1/logs/trace/${e}`)).data.data||[]),U(!0)}catch{}},[]);(0,k.useEffect)(()=>{n(!0),X(),Z(),re()},[_,w]),(0,k.useEffect)(()=>(Y.current&&clearInterval(Y.current),c&&(Y.current=setInterval(()=>{X(),Z()},5e3)),()=>{Y.current&&clearInterval(Y.current)}),[c,X,Z]),(0,k.useEffect)(()=>{c&&J.current&&(J.current.scrollTop=J.current.scrollHeight)},[r]);let Q=r.filter(e=>{let t=d.toLowerCase();return e.action?.toLowerCase().includes(t)||e.event_type?.toLowerCase().includes(t)||e.tool_name?.toLowerCase().includes(t)||e.model_used?.toLowerCase().includes(t)||e.trace_id?.toLowerCase().includes(t)}),ae=async()=>{z(!0);try{let e=await D.get(`/api/v1/logs/audit/export`,{params:{format:`json`,limit:`10000`},responseType:`blob`}),t=URL.createObjectURL(e.data),n=document.createElement(`a`);n.href=t,n.download=`shogun_audit_${new Date().toISOString().slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch(e){console.error(`Download failed`,e)}finally{z(!1)}},oe=async()=>{if(confirm(`Clear operational logs? The immutable audit chain will NOT be affected.`)){L(!0);try{await D.delete(`/api/v1/logs`),a([]),Z()}catch(e){console.error(`Clear failed`,e)}finally{L(!1)}}},$=r.filter(e=>M(e.severity)===`error`||M(e.severity)===`critical`).length,se=Object.values(K).reduce((e,t)=>e+t,0);return(0,A.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-500 max-w-[1400px] mx-auto h-[calc(100vh-140px)] flex flex-col`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`logs.title`,`Event Log`),(0,A.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Compliance Ready`})]}),(0,A.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`logs.subtitle`,`Compliance-grade event stream with full trace reconstruction.`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[W&&(0,A.jsxs)(`div`,{className:T(`px-3 py-2 rounded-lg border flex items-center gap-2 text-[10px] font-bold uppercase tracking-widest`,W.chain_intact?`bg-green-500/5 border-green-500/20 text-green-500`:`bg-red-500/10 border-red-500/30 text-red-400 animate-pulse`),children:[W.chain_intact?(0,A.jsx)(s,{className:`w-3.5 h-3.5`}):(0,A.jsx)(o,{className:`w-3.5 h-3.5`}),W.chain_intact?`Chain Intact`:`Chain Broken`,(0,A.jsxs)(`span`,{className:`text-[8px] opacity-60 ml-1`,children:[W.total_records,` records`]})]}),(0,A.jsxs)(`div`,{className:`flex items-center bg-shogun-card border border-shogun-border rounded-lg p-1`,children:[(0,A.jsxs)(`button`,{onClick:()=>l(!0),className:T(`px-3 py-1.5 text-[10px] font-bold uppercase rounded flex items-center gap-2 transition-all`,c?`bg-shogun-blue text-white`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,A.jsx)(g,{className:T(`w-3 h-3`,c&&`animate-spin`)}),` Live`]}),(0,A.jsxs)(`button`,{onClick:()=>l(!1),className:T(`px-3 py-1.5 text-[10px] font-bold uppercase rounded flex items-center gap-2 transition-all`,c?`text-shogun-subdued hover:text-shogun-text`:`bg-[#1a2040] text-shogun-text`),children:[(0,A.jsx)(i,{className:`w-3 h-3`}),` Paused`]})]}),(0,A.jsx)(`button`,{onClick:ae,disabled:R,title:`Export immutable audit log`,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors disabled:opacity-40`,children:R?(0,A.jsx)(h,{className:`w-4 h-4 animate-spin`}):(0,A.jsx)(u,{className:`w-4 h-4`})}),(0,A.jsx)(`button`,{onClick:oe,disabled:I,title:`Clear operational logs`,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-red-400 transition-colors disabled:opacity-40`,children:I?(0,A.jsx)(h,{className:`w-4 h-4 animate-spin`}):(0,A.jsx)(x,{className:`w-4 h-4`})})]})]}),(0,A.jsx)(`div`,{className:`flex gap-1 bg-[#050508] p-1 rounded-xl border border-shogun-border w-full`,children:j.map(e=>{let t=e.icon,n=e.key===`all`?se:K[e.key]||0;return(0,A.jsxs)(`button`,{onClick:()=>O(e.key),style:{flex:`1 1 0`,minWidth:0},className:T(`flex items-center justify-center gap-1 px-1.5 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all whitespace-nowrap`,w===e.key?`${e.color} bg-white/5 border border-white/10`:`text-shogun-subdued hover:text-shogun-text border border-transparent`),children:[(0,A.jsx)(t,{className:`w-3 h-3 shrink-0`}),(0,A.jsx)(`span`,{className:`truncate`,children:e.label}),n>0&&(0,A.jsx)(`span`,{className:`text-[8px] bg-white/5 px-1.5 py-0.5 rounded-full ml-0.5 shrink-0`,children:n})]},e.key)})}),(0,A.jsxs)(`div`,{className:`flex-1 flex flex-col shogun-card !p-0 overflow-hidden border-shogun-blue/20`,children:[(0,A.jsxs)(`div`,{className:`p-3 border-b border-shogun-border bg-[#050508]/80 flex items-center justify-between gap-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3 flex-1`,children:[(0,A.jsxs)(`div`,{className:`relative max-w-sm w-full`,children:[(0,A.jsx)(v,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued`}),(0,A.jsx)(`input`,{type:`text`,placeholder:`Search events, tools, models, traces...`,value:d,onChange:e=>p(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg pl-9 pr-4 py-1.5 text-xs focus:border-shogun-blue outline-none transition-all`})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(f,{className:`w-3 h-3 text-shogun-subdued`}),(0,A.jsxs)(`select`,{value:_,onChange:e=>S(e.target.value),className:`bg-shogun-bg border border-shogun-border rounded-lg px-2 py-1 text-[10px] font-bold uppercase text-shogun-subdued outline-none focus:border-shogun-blue`,children:[(0,A.jsx)(`option`,{value:`all`,children:`All Levels`}),(0,A.jsx)(`option`,{value:`info`,children:`Info`}),(0,A.jsx)(`option`,{value:`warn`,children:`Warn`}),(0,A.jsx)(`option`,{value:`error`,children:`Error`}),(0,A.jsx)(`option`,{value:`critical`,children:`Critical`})]})]})]}),(0,A.jsxs)(`div`,{className:`hidden lg:flex items-center gap-3 text-[9px] text-shogun-subdued font-bold uppercase tracking-widest`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-green-500`}),` Success`]}),(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-red-500`}),` Denied`]}),(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400`}),` Warn`]})]})]}),(0,A.jsxs)(`div`,{ref:J,className:`flex-1 overflow-y-auto font-mono text-[11px] leading-relaxed bg-[#02040a] scrollbar-hide`,children:[t&&r.length===0?(0,A.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center opacity-30 gap-3`,children:[(0,A.jsx)(b,{className:`w-10 h-10 animate-pulse`}),(0,A.jsx)(`span`,{className:`uppercase tracking-[0.3em]`,children:`Establishing uplink...`})]}):Q.length===0?(0,A.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued gap-3 py-20`,children:[(0,A.jsx)(y,{className:`w-12 h-12 opacity-20`}),(0,A.jsx)(`span`,{className:`text-sm italic`,children:`No events matching filters`}),(0,A.jsx)(`span`,{className:`text-[10px] opacity-50`,children:`Events will appear here as the system operates`})]}):Q.map((e,t)=>{let n=P(e.event_category),r=n.icon;return(0,A.jsxs)(`div`,{onClick:()=>V(B?.id===e.id?null:e),className:T(`group flex items-start gap-3 py-2 px-4 hover:bg-white/[0.03] transition-colors cursor-pointer border-l-2`,B?.id===e.id?`border-shogun-blue bg-white/[0.03]`:`border-transparent`),children:[(0,A.jsx)(`span`,{className:`text-shogun-subdued whitespace-nowrap opacity-40 select-none text-[10px] pt-0.5`,children:new Date(e.occurred_at).toLocaleTimeString()}),(0,A.jsx)(r,{className:T(`w-3.5 h-3.5 mt-0.5 shrink-0`,n.color)}),(0,A.jsx)(`div`,{className:T(`w-14 text-[9px] font-bold uppercase tracking-tighter shrink-0 pt-0.5 border rounded px-1 text-center`,N(e.severity)),children:e.severity}),F(e.result),(0,A.jsxs)(`div`,{className:`flex-1 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0`,children:[(0,A.jsx)(`span`,{className:`text-shogun-text`,children:e.action}),e.event_type&&(0,A.jsx)(`span`,{className:`text-[9px] bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border text-shogun-blue/70 font-bold uppercase tracking-widest`,children:e.event_type}),e.model_used&&(0,A.jsx)(`span`,{className:`text-[9px] text-shogun-gold/60`,children:e.model_used}),e.tool_name&&(0,A.jsxs)(`span`,{className:`text-[9px] text-green-400/60`,children:[`⚙ `,e.tool_name]}),e.policy_decision&&(0,A.jsx)(`span`,{className:T(`text-[9px] font-bold uppercase`,e.policy_decision===`denied`?`text-red-400`:`text-green-400/60`),children:e.policy_decision===`denied`?`✕ DENIED`:`✓ `+e.policy_decision}),e.trace_id&&(0,A.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),ie(e.trace_id)},className:`text-[8px] text-shogun-subdued/50 hover:text-shogun-blue font-mono flex items-center gap-0.5 transition-colors`,children:[(0,A.jsx)(m,{className:`w-2.5 h-2.5`}),e.trace_id.slice(0,12)]})]})]},e.id||t)}),(0,A.jsx)(`div`,{className:`h-4`})]}),B&&(0,A.jsxs)(`div`,{className:`border-t border-shogun-border bg-[#050508] p-4 max-h-[250px] overflow-y-auto`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,A.jsxs)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-gold flex items-center gap-2`,children:[(0,A.jsx)(ee,{className:`w-3.5 h-3.5`}),` Event Detail — `,B.event_id]}),(0,A.jsx)(`button`,{onClick:()=>V(null),className:`text-shogun-subdued hover:text-shogun-text`,children:(0,A.jsx)(C,{className:`w-4 h-4`})})]}),(0,A.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3 text-[10px]`,children:[[`WHO`,B.user_id||`—`],[`AGENT`,B.agent_id?.slice(0,8)||`—`],[`WHAT`,B.event_type],[`WHEN`,new Date(B.occurred_at).toISOString()],[`RESULT`,B.result],[`MODEL`,B.model_used||`—`],[`PROVIDER`,B.provider_used||`—`],[`TOOL`,B.tool_name||`—`],[`POLICY`,B.policy_ref||`—`],[`DECISION`,B.policy_decision||`—`],[`RISK`,B.risk_score||`low`],[`TRACE`,B.trace_id||`—`]].map(([e,t])=>(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`div`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest mb-0.5`,children:e}),(0,A.jsx)(`div`,{className:`text-shogun-text font-mono truncate`,children:t})]},e))}),B.policy_reason&&(0,A.jsxs)(`div`,{className:`mt-3 p-2 bg-shogun-blue/5 border border-shogun-blue/20 rounded text-[10px]`,children:[(0,A.jsx)(`span`,{className:`text-[8px] text-shogun-blue font-bold uppercase tracking-widest`,children:`Policy Reason: `}),(0,A.jsx)(`span`,{className:`text-shogun-text`,children:B.policy_reason})]}),B.confidence_score!=null&&(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest`,children:`AI Confidence:`}),(0,A.jsx)(`div`,{className:`flex-1 max-w-[200px] h-2 bg-[#02040a] rounded-full overflow-hidden border border-shogun-border`,children:(0,A.jsx)(`div`,{className:T(`h-full rounded-full transition-all`,B.confidence_score>=.7?`bg-green-500`:B.confidence_score>=.4?`bg-yellow-400`:`bg-red-500`),style:{width:`${Math.round(B.confidence_score*100)}%`}})}),(0,A.jsxs)(`span`,{className:T(`text-[10px] font-bold font-mono`,B.confidence_score>=.7?`text-green-500`:B.confidence_score>=.4?`text-yellow-400`:`text-red-500`),children:[Math.round(B.confidence_score*100),`%`]})]}),B.use_case_context?.frameworks?.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 flex-wrap`,children:[(0,A.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest`,children:`Frameworks:`}),B.use_case_context.frameworks.map(e=>(0,A.jsx)(`span`,{className:T(`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border`,e===`EU_AI_ACT`?`text-violet-400 border-violet-400/30 bg-violet-500/5`:e===`SOC2`?`text-blue-400 border-blue-400/30 bg-blue-500/5`:`text-cyan-400 border-cyan-400/30 bg-cyan-500/5`),children:e},e)),B.use_case_context.risk_level&&(0,A.jsxs)(`span`,{className:T(`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border`,B.use_case_context.risk_level===`high`?`text-red-400 border-red-400/30 bg-red-500/5`:B.use_case_context.risk_level===`limited`?`text-yellow-400 border-yellow-400/30 bg-yellow-500/5`:`text-green-400 border-green-400/30 bg-green-500/5`),children:[`Risk: `,B.use_case_context.risk_level]})]}),Object.keys(B.governance_flags||{}).length>0&&(0,A.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 flex-wrap`,children:[(0,A.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest`,children:`Governance:`}),Object.entries(B.governance_flags).map(([e,t])=>(0,A.jsxs)(`span`,{className:`text-[8px] text-amber-400/70 bg-amber-500/5 border border-amber-500/20 px-1.5 py-0.5 rounded`,children:[e,`: `,String(t)]},e))]}),B.memory_ids?.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 text-[10px]`,children:[(0,A.jsx)(`span`,{className:`text-[8px] text-cyan-400 font-bold uppercase tracking-widest`,children:`Memory IDs: `}),(0,A.jsx)(`span`,{className:`text-shogun-subdued font-mono`,children:B.memory_ids.join(`, `)})]}),Object.keys(B.detail||{}).length>0&&(0,A.jsxs)(`div`,{className:`mt-2`,children:[(0,A.jsx)(`div`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest mb-1`,children:`Detail Payload`}),(0,A.jsx)(`pre`,{className:`text-[9px] text-shogun-subdued bg-[#02040a] p-2 rounded border border-shogun-border overflow-x-auto max-h-24`,children:JSON.stringify(B.detail,null,2)})]})]}),(0,A.jsxs)(`div`,{className:`p-3 bg-shogun-card/50 border-t border-shogun-border flex items-center justify-between text-[9px] text-shogun-subdued font-bold uppercase tracking-widest`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,A.jsxs)(`span`,{className:T(`flex items-center gap-1.5`,c?`text-shogun-blue`:`text-shogun-subdued`),children:[(0,A.jsx)(i,{className:`w-3 h-3`}),c?`Live · 5s`:`Paused`]}),(0,A.jsxs)(`span`,{children:[Q.length,` / `,r.length,` events`]}),$>0&&(0,A.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,A.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse`}),$,` error`,$===1?``:`s`]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(y,{className:`w-3 h-3`}),` Dual-Layer Logging`]}),(0,A.jsxs)(`span`,{children:[`Audit: `,(0,A.jsx)(`span`,{className:W?.chain_intact?`text-green-500`:`text-red-400`,children:W?.chain_intact?`INTACT`:`BROKEN`})]})]})]})]}),ne&&(0,A.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-8`,onClick:()=>U(!1),children:(0,A.jsxs)(`div`,{className:`bg-[#0a0a12] border border-shogun-border rounded-2xl w-full max-w-3xl max-h-[80vh] overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,A.jsxs)(`div`,{className:`p-4 border-b border-shogun-border flex items-center justify-between`,children:[(0,A.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-gold flex items-center gap-2`,children:[(0,A.jsx)(m,{className:`w-4 h-4`}),` Trace Reconstruction`,(0,A.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued ml-2`,children:[H.length,` events in chain`]})]}),(0,A.jsx)(`button`,{onClick:()=>U(!1),className:`text-shogun-subdued hover:text-shogun-text`,children:(0,A.jsx)(C,{className:`w-5 h-5`})})]}),(0,A.jsxs)(`div`,{className:`p-4 overflow-y-auto max-h-[65vh] space-y-2`,children:[H.map((e,t)=>{let n=P(e.event_category),r=n.icon;return(0,A.jsxs)(`div`,{className:`flex items-start gap-3 p-3 bg-[#050508] rounded-lg border border-shogun-border`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,A.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-shogun-card border border-shogun-border flex items-center justify-center text-[9px] font-bold text-shogun-subdued`,children:t+1}),tt.key===e)||A[0]}function P(e){switch(e?.toLowerCase()){case`success`:return(0,k.jsx)(r,{className:`w-3 h-3 text-green-500`});case`denied`:return(0,k.jsx)(i,{className:`w-3 h-3 text-red-400`});case`error`:return(0,k.jsx)(n,{className:`w-3 h-3 text-red-500`});default:return(0,k.jsx)(c,{className:`w-3 h-3 text-shogun-subdued`})}}function F(){let{t:e}=S(),[t,i]=(0,O.useState)(!0),[a,o]=(0,O.useState)([]),[c,d]=(0,O.useState)(!0),[h,g]=(0,O.useState)(``),[_,x]=(0,O.useState)(`all`),[C,D]=(0,O.useState)(`all`),[F,I]=(0,O.useState)(!1),[L,R]=(0,O.useState)(!1),[z,B]=(0,O.useState)(null),[V,H]=(0,O.useState)([]),[U,W]=(0,O.useState)(!1),[G,K]=(0,O.useState)(null),[q,ne]=(0,O.useState)({}),J=(0,O.useRef)(null),Y=(0,O.useRef)(null),X=(0,O.useCallback)(async()=>{try{let e={limit:`300`};_!==`all`&&(e.severity=_),C!==`all`&&(e.category=C);let t=(await E.get(`/api/v1/logs`,{params:e})).data.data||[];o([...t].reverse())}catch(e){console.error(`Error fetching logs:`,e)}finally{i(!1)}},[_,C]),Z=(0,O.useCallback)(async()=>{try{let e=await E.get(`/api/v1/logs/categories`);ne(e.data.data?.categories||{})}catch{}},[]),re=(0,O.useCallback)(async()=>{try{let e=await E.get(`/api/v1/logs/audit/verify`);K(e.data.data)}catch{}},[]),ie=(0,O.useCallback)(async e=>{try{let t=await E.get(`/api/v1/logs/trace/${e}`);H(t.data.data||[]),W(!0)}catch{}},[]);(0,O.useEffect)(()=>{i(!0),X(),Z(),re()},[_,C]),(0,O.useEffect)(()=>(Y.current&&clearInterval(Y.current),c&&(Y.current=setInterval(()=>{X(),Z()},5e3)),()=>{Y.current&&clearInterval(Y.current)}),[c,X,Z]),(0,O.useEffect)(()=>{c&&J.current&&(J.current.scrollTop=J.current.scrollHeight)},[a]);let Q=a.filter(e=>{let t=h.toLowerCase();return e.action?.toLowerCase().includes(t)||e.event_type?.toLowerCase().includes(t)||e.tool_name?.toLowerCase().includes(t)||e.model_used?.toLowerCase().includes(t)||e.trace_id?.toLowerCase().includes(t)}),ae=async()=>{R(!0);try{let e=await E.get(`/api/v1/logs/audit/export`,{params:{format:`json`,limit:`10000`},responseType:`blob`}),t=URL.createObjectURL(e.data),n=document.createElement(`a`);n.href=t,n.download=`shogun_audit_${new Date().toISOString().slice(0,10)}.json`,n.click(),URL.revokeObjectURL(t)}catch(e){console.error(`Download failed`,e)}finally{R(!1)}},oe=async()=>{if(confirm(`Clear operational logs? The immutable audit chain will NOT be affected.`)){I(!0);try{await E.delete(`/api/v1/logs`),o([]),Z()}catch(e){console.error(`Clear failed`,e)}finally{I(!1)}}},$=a.filter(e=>j(e.severity)===`error`||j(e.severity)===`critical`).length,se=Object.values(q).reduce((e,t)=>e+t,0);return(0,k.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-500 max-w-[1400px] mx-auto h-[calc(100vh-140px)] flex flex-col`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`logs.title`,`Event Log`),(0,k.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`Compliance Ready`})]}),(0,k.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`logs.subtitle`,`Compliance-grade event stream with full trace reconstruction.`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[G&&(0,k.jsxs)(`div`,{className:b(`px-3 py-2 rounded-lg border flex items-center gap-2 text-[10px] font-bold uppercase tracking-widest`,G.chain_intact?`bg-green-500/5 border-green-500/20 text-green-500`:`bg-red-500/10 border-red-500/30 text-red-400 animate-pulse`),children:[G.chain_intact?(0,k.jsx)(r,{className:`w-3.5 h-3.5`}):(0,k.jsx)(n,{className:`w-3.5 h-3.5`}),G.chain_intact?`Chain Intact`:`Chain Broken`,(0,k.jsxs)(`span`,{className:`text-[8px] opacity-60 ml-1`,children:[G.total_records,` records`]})]}),(0,k.jsxs)(`div`,{className:`flex items-center bg-shogun-card border border-shogun-border rounded-lg p-1`,children:[(0,k.jsxs)(`button`,{onClick:()=>d(!0),className:b(`px-3 py-1.5 text-[10px] font-bold uppercase rounded flex items-center gap-2 transition-all`,c?`bg-shogun-blue text-white`:`text-shogun-subdued hover:text-shogun-text`),children:[(0,k.jsx)(u,{className:b(`w-3 h-3`,c&&`animate-spin`)}),` Live`]}),(0,k.jsxs)(`button`,{onClick:()=>d(!1),className:b(`px-3 py-1.5 text-[10px] font-bold uppercase rounded flex items-center gap-2 transition-all`,c?`text-shogun-subdued hover:text-shogun-text`:`bg-[#1a2040] text-shogun-text`),children:[(0,k.jsx)(T,{className:`w-3 h-3`}),` Paused`]})]}),(0,k.jsx)(`button`,{onClick:ae,disabled:L,title:`Export immutable audit log`,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors disabled:opacity-40`,children:L?(0,k.jsx)(y,{className:`w-4 h-4 animate-spin`}):(0,k.jsx)(te,{className:`w-4 h-4`})}),(0,k.jsx)(`button`,{onClick:oe,disabled:F,title:`Clear operational logs`,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-red-400 transition-colors disabled:opacity-40`,children:F?(0,k.jsx)(y,{className:`w-4 h-4 animate-spin`}):(0,k.jsx)(m,{className:`w-4 h-4`})})]})]}),(0,k.jsx)(`div`,{className:`flex gap-1 bg-[#050508] p-1 rounded-xl border border-shogun-border w-full`,children:A.map(e=>{let t=e.icon,n=e.key===`all`?se:q[e.key]||0;return(0,k.jsxs)(`button`,{onClick:()=>D(e.key),style:{flex:`1 1 0`,minWidth:0},className:b(`flex items-center justify-center gap-1 px-1.5 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all whitespace-nowrap`,C===e.key?`${e.color} bg-white/5 border border-white/10`:`text-shogun-subdued hover:text-shogun-text border border-transparent`),children:[(0,k.jsx)(t,{className:`w-3 h-3 shrink-0`}),(0,k.jsx)(`span`,{className:`truncate`,children:e.label}),n>0&&(0,k.jsx)(`span`,{className:`text-[8px] bg-white/5 px-1.5 py-0.5 rounded-full ml-0.5 shrink-0`,children:n})]},e.key)})}),(0,k.jsxs)(`div`,{className:`flex-1 flex flex-col shogun-card !p-0 overflow-hidden border-shogun-blue/20`,children:[(0,k.jsxs)(`div`,{className:`p-3 border-b border-shogun-border bg-[#050508]/80 flex items-center justify-between gap-4`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 flex-1`,children:[(0,k.jsxs)(`div`,{className:`relative max-w-sm w-full`,children:[(0,k.jsx)(f,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-shogun-subdued`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Search events, tools, models, traces...`,value:h,onChange:e=>g(e.target.value),className:`w-full bg-shogun-bg border border-shogun-border rounded-lg pl-9 pr-4 py-1.5 text-xs focus:border-shogun-blue outline-none transition-all`})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(s,{className:`w-3 h-3 text-shogun-subdued`}),(0,k.jsxs)(`select`,{value:_,onChange:e=>x(e.target.value),className:`bg-shogun-bg border border-shogun-border rounded-lg px-2 py-1 text-[10px] font-bold uppercase text-shogun-subdued outline-none focus:border-shogun-blue`,children:[(0,k.jsx)(`option`,{value:`all`,children:`All Levels`}),(0,k.jsx)(`option`,{value:`info`,children:`Info`}),(0,k.jsx)(`option`,{value:`warn`,children:`Warn`}),(0,k.jsx)(`option`,{value:`error`,children:`Error`}),(0,k.jsx)(`option`,{value:`critical`,children:`Critical`})]})]})]}),(0,k.jsxs)(`div`,{className:`hidden lg:flex items-center gap-3 text-[9px] text-shogun-subdued font-bold uppercase tracking-widest`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-green-500`}),` Success`]}),(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-red-500`}),` Denied`]}),(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400`}),` Warn`]})]})]}),(0,k.jsxs)(`div`,{ref:J,className:`flex-1 overflow-y-auto font-mono text-[11px] leading-relaxed bg-[#02040a] scrollbar-hide`,children:[t&&a.length===0?(0,k.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center opacity-30 gap-3`,children:[(0,k.jsx)(p,{className:`w-10 h-10 animate-pulse`}),(0,k.jsx)(`span`,{className:`uppercase tracking-[0.3em]`,children:`Establishing uplink...`})]}):Q.length===0?(0,k.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-shogun-subdued gap-3 py-20`,children:[(0,k.jsx)(w,{className:`w-12 h-12 opacity-20`}),(0,k.jsx)(`span`,{className:`text-sm italic`,children:`No events matching filters`}),(0,k.jsx)(`span`,{className:`text-[10px] opacity-50`,children:`Events will appear here as the system operates`})]}):Q.map((e,t)=>{let n=N(e.event_category),r=n.icon;return(0,k.jsxs)(`div`,{onClick:()=>B(z?.id===e.id?null:e),className:b(`group flex items-start gap-3 py-2 px-4 hover:bg-white/[0.03] transition-colors cursor-pointer border-l-2`,z?.id===e.id?`border-shogun-blue bg-white/[0.03]`:`border-transparent`),children:[(0,k.jsx)(`span`,{className:`text-shogun-subdued whitespace-nowrap opacity-40 select-none text-[10px] pt-0.5`,children:new Date(e.occurred_at).toLocaleTimeString()}),(0,k.jsx)(r,{className:b(`w-3.5 h-3.5 mt-0.5 shrink-0`,n.color)}),(0,k.jsx)(`div`,{className:b(`w-14 text-[9px] font-bold uppercase tracking-tighter shrink-0 pt-0.5 border rounded px-1 text-center`,M(e.severity)),children:e.severity}),P(e.result),(0,k.jsxs)(`div`,{className:`flex-1 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 min-w-0`,children:[(0,k.jsx)(`span`,{className:`text-shogun-text`,children:e.action}),e.event_type&&(0,k.jsx)(`span`,{className:`text-[9px] bg-shogun-card px-1.5 py-0.5 rounded border border-shogun-border text-shogun-blue/70 font-bold uppercase tracking-widest`,children:e.event_type}),e.model_used&&(0,k.jsx)(`span`,{className:`text-[9px] text-shogun-gold/60`,children:e.model_used}),e.tool_name&&(0,k.jsxs)(`span`,{className:`text-[9px] text-green-400/60`,children:[`⚙ `,e.tool_name]}),e.policy_decision&&(0,k.jsx)(`span`,{className:b(`text-[9px] font-bold uppercase`,e.policy_decision===`denied`?`text-red-400`:`text-green-400/60`),children:e.policy_decision===`denied`?`✕ DENIED`:`✓ `+e.policy_decision}),e.trace_id&&(0,k.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),ie(e.trace_id)},className:`text-[8px] text-shogun-subdued/50 hover:text-shogun-blue font-mono flex items-center gap-0.5 transition-colors`,children:[(0,k.jsx)(l,{className:`w-2.5 h-2.5`}),e.trace_id.slice(0,12)]})]})]},e.id||t)}),(0,k.jsx)(`div`,{className:`h-4`})]}),z&&(0,k.jsxs)(`div`,{className:`border-t border-shogun-border bg-[#050508] p-4 max-h-[250px] overflow-y-auto`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,k.jsxs)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-gold flex items-center gap-2`,children:[(0,k.jsx)(ee,{className:`w-3.5 h-3.5`}),` Event Detail — `,z.event_id]}),(0,k.jsx)(`button`,{onClick:()=>B(null),className:`text-shogun-subdued hover:text-shogun-text`,children:(0,k.jsx)(v,{className:`w-4 h-4`})})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3 text-[10px]`,children:[[`WHO`,z.user_id||`—`],[`AGENT`,z.agent_id?.slice(0,8)||`—`],[`WHAT`,z.event_type],[`WHEN`,new Date(z.occurred_at).toISOString()],[`RESULT`,z.result],[`MODEL`,z.model_used||`—`],[`PROVIDER`,z.provider_used||`—`],[`TOOL`,z.tool_name||`—`],[`POLICY`,z.policy_ref||`—`],[`DECISION`,z.policy_decision||`—`],[`RISK`,z.risk_score||`low`],[`TRACE`,z.trace_id||`—`]].map(([e,t])=>(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest mb-0.5`,children:e}),(0,k.jsx)(`div`,{className:`text-shogun-text font-mono truncate`,children:t})]},e))}),z.policy_reason&&(0,k.jsxs)(`div`,{className:`mt-3 p-2 bg-shogun-blue/5 border border-shogun-blue/20 rounded text-[10px]`,children:[(0,k.jsx)(`span`,{className:`text-[8px] text-shogun-blue font-bold uppercase tracking-widest`,children:`Policy Reason: `}),(0,k.jsx)(`span`,{className:`text-shogun-text`,children:z.policy_reason})]}),z.confidence_score!=null&&(0,k.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,k.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest`,children:`AI Confidence:`}),(0,k.jsx)(`div`,{className:`flex-1 max-w-[200px] h-2 bg-[#02040a] rounded-full overflow-hidden border border-shogun-border`,children:(0,k.jsx)(`div`,{className:b(`h-full rounded-full transition-all`,z.confidence_score>=.7?`bg-green-500`:z.confidence_score>=.4?`bg-yellow-400`:`bg-red-500`),style:{width:`${Math.round(z.confidence_score*100)}%`}})}),(0,k.jsxs)(`span`,{className:b(`text-[10px] font-bold font-mono`,z.confidence_score>=.7?`text-green-500`:z.confidence_score>=.4?`text-yellow-400`:`text-red-500`),children:[Math.round(z.confidence_score*100),`%`]})]}),z.use_case_context?.frameworks?.length>0&&(0,k.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 flex-wrap`,children:[(0,k.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest`,children:`Frameworks:`}),z.use_case_context.frameworks.map(e=>(0,k.jsx)(`span`,{className:b(`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border`,e===`EU_AI_ACT`?`text-violet-400 border-violet-400/30 bg-violet-500/5`:e===`SOC2`?`text-blue-400 border-blue-400/30 bg-blue-500/5`:`text-cyan-400 border-cyan-400/30 bg-cyan-500/5`),children:e},e)),z.use_case_context.risk_level&&(0,k.jsxs)(`span`,{className:b(`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border`,z.use_case_context.risk_level===`high`?`text-red-400 border-red-400/30 bg-red-500/5`:z.use_case_context.risk_level===`limited`?`text-yellow-400 border-yellow-400/30 bg-yellow-500/5`:`text-green-400 border-green-400/30 bg-green-500/5`),children:[`Risk: `,z.use_case_context.risk_level]})]}),Object.keys(z.governance_flags||{}).length>0&&(0,k.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 flex-wrap`,children:[(0,k.jsx)(`span`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest`,children:`Governance:`}),Object.entries(z.governance_flags).map(([e,t])=>(0,k.jsxs)(`span`,{className:`text-[8px] text-amber-400/70 bg-amber-500/5 border border-amber-500/20 px-1.5 py-0.5 rounded`,children:[e,`: `,String(t)]},e))]}),z.memory_ids?.length>0&&(0,k.jsxs)(`div`,{className:`mt-2 text-[10px]`,children:[(0,k.jsx)(`span`,{className:`text-[8px] text-cyan-400 font-bold uppercase tracking-widest`,children:`Memory IDs: `}),(0,k.jsx)(`span`,{className:`text-shogun-subdued font-mono`,children:z.memory_ids.join(`, `)})]}),Object.keys(z.detail||{}).length>0&&(0,k.jsxs)(`div`,{className:`mt-2`,children:[(0,k.jsx)(`div`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-widest mb-1`,children:`Detail Payload`}),(0,k.jsx)(`pre`,{className:`text-[9px] text-shogun-subdued bg-[#02040a] p-2 rounded border border-shogun-border overflow-x-auto max-h-24`,children:JSON.stringify(z.detail,null,2)})]})]}),(0,k.jsxs)(`div`,{className:`p-3 bg-shogun-card/50 border-t border-shogun-border flex items-center justify-between text-[9px] text-shogun-subdued font-bold uppercase tracking-widest`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,k.jsxs)(`span`,{className:b(`flex items-center gap-1.5`,c?`text-shogun-blue`:`text-shogun-subdued`),children:[(0,k.jsx)(T,{className:`w-3 h-3`}),c?`Live · 5s`:`Paused`]}),(0,k.jsxs)(`span`,{children:[Q.length,` / `,a.length,` events`]}),$>0&&(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,k.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse`}),$,` error`,$===1?``:`s`]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(w,{className:`w-3 h-3`}),` Dual-Layer Logging`]}),(0,k.jsxs)(`span`,{children:[`Audit: `,(0,k.jsx)(`span`,{className:G?.chain_intact?`text-green-500`:`text-red-400`,children:G?.chain_intact?`INTACT`:`BROKEN`})]})]})]})]}),U&&(0,k.jsx)(`div`,{className:`fixed inset-0 bg-black/60 backdrop-blur-sm z-50 flex items-center justify-center p-8`,onClick:()=>W(!1),children:(0,k.jsxs)(`div`,{className:`bg-[#0a0a12] border border-shogun-border rounded-2xl w-full max-w-3xl max-h-[80vh] overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,k.jsxs)(`div`,{className:`p-4 border-b border-shogun-border flex items-center justify-between`,children:[(0,k.jsxs)(`h3`,{className:`text-sm font-bold text-shogun-gold flex items-center gap-2`,children:[(0,k.jsx)(l,{className:`w-4 h-4`}),` Trace Reconstruction`,(0,k.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued ml-2`,children:[V.length,` events in chain`]})]}),(0,k.jsx)(`button`,{onClick:()=>W(!1),className:`text-shogun-subdued hover:text-shogun-text`,children:(0,k.jsx)(v,{className:`w-5 h-5`})})]}),(0,k.jsxs)(`div`,{className:`p-4 overflow-y-auto max-h-[65vh] space-y-2`,children:[V.map((e,t)=>{let n=N(e.event_category),r=n.icon;return(0,k.jsxs)(`div`,{className:`flex items-start gap-3 p-3 bg-[#050508] rounded-lg border border-shogun-border`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,k.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-shogun-card border border-shogun-border flex items-center justify-center text-[9px] font-bold text-shogun-subdued`,children:t+1}),tx[e]||x.custom,C={inbound:{label:`Inbound`,icon:ve,color:`text-cyan-400`},outbound:{label:`Outbound`,icon:v,color:`text-orange-400`},bidirectional:{label:`Bidirectional`,icon:i,color:`text-indigo-400`}},be=e=>C[e]||C.bidirectional,w={proposal:{color:`text-purple-400 bg-purple-500/10 border-purple-500/30`,label:`Proposal`,icon:me},task:{color:`text-shogun-blue bg-shogun-blue/10 border-shogun-blue/30`,label:`Task`,icon:h},reply:{color:`text-shogun-subdued bg-shogun-card border-shogun-border`,label:`Reply`,icon:le},update:{color:`text-green-400 bg-green-500/10 border-green-500/30`,label:`Update`,icon:o},plan_revision:{color:`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`,label:`Plan Rev.`,icon:ue},approval:{color:`text-green-400 bg-green-500/10 border-green-500/30`,label:`Approval`,icon:ae},signal:{color:`text-orange-400 bg-orange-500/10 border-orange-500/30`,label:`Signal`,icon:a},invitation:{color:`text-purple-400 bg-purple-500/10 border-purple-500/30`,label:`Invitation`,icon:p},system:{color:`text-shogun-subdued/60 bg-transparent border-transparent`,label:`System`,icon:l}},xe={active:`bg-green-500`,pending:`bg-yellow-500`,offline:`bg-shogun-subdued`,declined:`bg-red-500`};function Se(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function Ce(e){try{return new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`})}catch{return``}}function T(){let{t:e}=_e(),[t,n]=(0,y.useState)([]),[r,i]=(0,y.useState)(null),[a,ae]=(0,y.useState)(null),[h,ve]=(0,y.useState)(!0),[v,x]=(0,y.useState)(!1),[C,T]=(0,y.useState)(!1),[E,we]=(0,y.useState)(``),[D,O]=(0,y.useState)(``),[k,Te]=(0,y.useState)(``),[A,Ee]=(0,y.useState)(!1),[De,j]=(0,y.useState)(!1),[M,Oe]=(0,y.useState)(``),[ke,Ae]=(0,y.useState)(``),[N,je]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,Me]=(0,y.useState)(``),[L,Ne]=(0,y.useState)(`update`),[Pe,Fe]=(0,y.useState)(!1),[Ie,R]=(0,y.useState)(!1),[Le,z]=(0,y.useState)(``),[B,Re]=(0,y.useState)(!1),[V,ze]=(0,y.useState)(null),[Be,H]=(0,y.useState)(null),[U,Ve]=(0,y.useState)([]),[He,Ue]=(0,y.useState)([]),[W,We]=(0,y.useState)(!0),[Ge,G]=(0,y.useState)(!1),[K,Ke]=(0,y.useState)(``),[qe,Je]=(0,y.useState)(`microsoft_365`),[Ye,Xe]=(0,y.useState)(`bidirectional`),[Ze,Qe]=(0,y.useState)(``),[q,$e]=(0,y.useState)(!1),[J,Y]=(0,y.useState)(null),[et,tt]=(0,y.useState)(!1),[nt,rt]=(0,y.useState)(!1),X=(0,y.useRef)(null),it=(0,y.useRef)(null),Z=(0,y.useCallback)(async()=>{try{let[e,t]=await Promise.all([_.get(`/api/v1/workspaces`),_.get(`/api/v1/a2a/identity`)]);n(e.data.data||[]),ae(t.data.data)}catch(e){console.error(`Nexus fetch error:`,e)}finally{ve(!1)}},[]),Q=(0,y.useCallback)(async()=>{rt(!0);try{let[e,t]=await Promise.allSettled([_.get(`/api/v1/nexus/external/agents`),_.get(`/api/v1/nexus/external/tasks`,{params:{limit:10}})]);e.status===`fulfilled`&&Ve(e.value.data.data||[]),t.status===`fulfilled`&&Ue(t.value.data.data||[])}catch{}finally{rt(!1)}},[]),$=(0,y.useCallback)(async()=>{if(r)try{let e=(await _.get(`/api/v1/workspaces/${r.id}`)).data.data;i(e),n(t=>t.map(t=>t.id===e.id?e:t))}catch(e){console.error(`Workspace refresh error:`,e)}},[r]);(0,y.useEffect)(()=>{Z(),Q()},[]),(0,y.useEffect)(()=>(X.current&&clearInterval(X.current),r&&(X.current=setInterval($,8e3)),()=>{X.current&&clearInterval(X.current)}),[r?.id]),(0,y.useEffect)(()=>{it.current?.scrollIntoView({behavior:`smooth`})},[r?.messages?.length]);let at=async()=>{if(E.trim()){Ee(!0);try{let e=(await _.post(`/api/v1/workspaces`,{name:E,description:D||null,topic:k||null})).data.data;n(t=>[e,...t]),i(e),T(!1),we(``),O(``),Te(``)}catch(e){console.error(e)}finally{Ee(!1)}}},ot=async()=>{if(!(!M.trim()||!r)){je(!0),F(null);try{await _.post(`/api/v1/workspaces/${r.id}/peers`,{peer_url:M,peer_name:ke||`Remote Shogun`}),F({type:`success`,text:`Invitation sent. Peer is now pending.`}),Oe(``),Ae(``),await $()}catch(e){F({type:`error`,text:e.response?.data?.detail||`Invite failed`})}finally{je(!1)}}},st=async()=>{if(!(!I.trim()||!r)){Fe(!0);try{await _.post(`/api/v1/workspaces/${r.id}/messages`,{content:I,message_type:L}),Me(``),await $()}catch(e){console.error(e)}finally{Fe(!1)}}},ct=async()=>{if(r){Re(!0);try{await _.patch(`/api/v1/workspaces/${r.id}/document`,{content:Le}),R(!1),await $()}catch(e){console.error(e)}finally{Re(!1)}}},lt=async e=>{if(r)try{await _.delete(`/api/v1/workspaces/${r.id}/peers/${e}`),await $()}catch(e){console.error(e)}},ut=async e=>{ze(e);try{await _.delete(`/api/v1/workspaces/${e}`),n(t=>t.filter(t=>t.id!==e)),r?.id===e&&i(null)}catch(e){console.error(e)}finally{ze(null),H(null)}},dt=()=>{a?.inbound_url&&(navigator.clipboard.writeText(a.inbound_url),x(!0),setTimeout(()=>x(!1),2e3))},ft=async()=>{if(K.trim()){$e(!0),Y(null);try{let e=(await _.post(`/api/v1/nexus/external/register-agent`,{name:K,platform:qe,direction:Ye,endpoint_url:Ze||null})).data.data;Y({type:`success`,text:`Agent "${e.name}" registered. Copy the token below — it won't be shown again.`,token:e.token}),Ke(``),Qe(``),await Q()}catch(e){Y({type:`error`,text:e.response?.data?.detail||`Registration failed`})}finally{$e(!1)}}},pt=async e=>{try{await _.patch(`/api/v1/nexus/external/agents/${e}`,{is_active:!1}),await Q()}catch(e){console.error(e)}};if(!r)return(0,b.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-7xl mx-auto pb-12`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`nexus.title`,`Nexus`),(0,b.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`A2A Protocol`})]}),(0,b.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`nexus.subtitle`,`Agent-to-Agent workspaces — plan, communicate, and collaborate with remote Shogun instances.`)})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`button`,{onClick:Z,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,b.jsx)(d,{className:g(`w-4 h-4`,h&&`animate-spin`)})}),(0,b.jsxs)(`button`,{onClick:()=>T(!0),className:`px-5 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.15em] rounded-xl shadow-lg transition-all flex items-center gap-2`,children:[(0,b.jsx)(u,{className:`w-4 h-4`}),` `,e(`nexus.new_workspace`,`New Workspace`)]})]})]}),a&&(0,b.jsxs)(`div`,{className:`shogun-card bg-indigo-500/5 border-indigo-500/20 flex items-center gap-6`,children:[(0,b.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center flex-shrink-0`,children:(0,b.jsx)(l,{className:`w-6 h-6 text-indigo-400`})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-[10px] font-bold text-indigo-400 uppercase tracking-widest`,children:`My A2A Endpoint`}),(0,b.jsx)(`p`,{className:`text-sm font-bold text-shogun-text mt-0.5`,children:a.name}),(0,b.jsx)(`code`,{className:`text-[10px] text-shogun-subdued font-mono truncate block`,children:a.inbound_url})]}),(0,b.jsxs)(`button`,{onClick:dt,className:`flex-shrink-0 px-4 py-2 bg-indigo-500/10 border border-indigo-500/30 text-indigo-400 rounded-lg text-xs font-bold uppercase tracking-widest hover:bg-indigo-500/20 transition-colors flex items-center gap-2`,children:[v?(0,b.jsx)(te,{className:`w-3.5 h-3.5`}):(0,b.jsx)(oe,{className:`w-3.5 h-3.5`}),v?`Copied`:`Copy URL`]})]}),(0,b.jsxs)(`div`,{className:`shogun-card border-purple-500/20 overflow-hidden`,children:[(0,b.jsxs)(`button`,{onClick:()=>We(!W),className:`w-full flex items-center justify-between px-5 py-4 hover:bg-purple-500/5 transition-colors`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,b.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center`,children:(0,b.jsx)(s,{className:`w-5 h-5 text-purple-400`})}),(0,b.jsxs)(`div`,{className:`text-left`,children:[(0,b.jsxs)(`p`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[`External Gateway`,(0,b.jsx)(`span`,{className:`text-[8px] font-normal text-purple-400 bg-purple-500/10 px-2 py-0.5 rounded border border-purple-500/20 uppercase tracking-widest`,children:`Enterprise`})]}),(0,b.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:U.length===0?`Connect Microsoft 365, Salesforce, Google, ServiceNow and more`:`${U.filter(e=>e.is_active).length} active agent${U.filter(e=>e.is_active).length===1?``:`s`} connected`})]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[U.length>0&&(0,b.jsxs)(`div`,{className:`flex -space-x-2`,children:[U.slice(0,4).map(e=>{let t=S(e.platform);return(0,b.jsx)(`div`,{className:g(`w-7 h-7 rounded-full border-2 border-shogun-bg flex items-center justify-center text-[9px] font-bold`,t.bg,t.color),children:e.name.charAt(0).toUpperCase()},e.id)}),U.length>4&&(0,b.jsxs)(`div`,{className:`w-7 h-7 rounded-full border-2 border-shogun-bg bg-shogun-card flex items-center justify-center text-[9px] text-shogun-subdued`,children:[`+`,U.length-4]})]}),W?(0,b.jsx)(ie,{className:`w-4 h-4 text-shogun-subdued`}):(0,b.jsx)(ne,{className:`w-4 h-4 text-shogun-subdued`})]})]}),W&&(0,b.jsxs)(`div`,{className:`border-t border-purple-500/10 p-5 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Registered Enterprise Agents`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`button`,{onClick:Q,className:`p-1.5 text-shogun-subdued hover:text-purple-400 transition-colors rounded-lg`,children:(0,b.jsx)(d,{className:g(`w-3.5 h-3.5`,nt&&`animate-spin`)})}),(0,b.jsxs)(`button`,{onClick:()=>{G(!0),Y(null)},className:`px-4 py-2 bg-purple-600 hover:bg-purple-500 text-white font-bold text-[10px] uppercase tracking-widest rounded-lg transition-all flex items-center gap-1.5`,children:[(0,b.jsx)(u,{className:`w-3.5 h-3.5`}),` Register Agent`]})]})]}),U.length===0?(0,b.jsxs)(`div`,{className:`p-8 border border-dashed border-purple-500/20 rounded-xl text-center space-y-3`,children:[(0,b.jsx)(s,{className:`w-8 h-8 text-purple-400/30 mx-auto`}),(0,b.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No external agents registered yet.`}),(0,b.jsx)(`p`,{className:`text-[10px] text-shogun-subdued/60`,children:`Register an agent to let enterprise AI platforms send tasks to Shogun, or to dispatch tasks outward.`})]}):(0,b.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:U.map(e=>{let t=S(e.platform),n=be(e.direction),r=n.icon;return(0,b.jsxs)(`div`,{className:g(`shogun-card border-l-2 group relative`,e.is_active?`border-l-purple-400/60`:`border-l-shogun-border opacity-50`),children:[e.is_active&&(0,b.jsx)(`button`,{onClick:()=>pt(e.id),className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 p-1 rounded bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20 transition-all`,title:`Deactivate agent`,children:(0,b.jsx)(de,{className:`w-3 h-3`})}),(0,b.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,b.jsx)(`div`,{className:g(`w-9 h-9 rounded-lg flex items-center justify-center border flex-shrink-0`,t.bg),children:(0,b.jsx)(s,{className:g(`w-4 h-4`,t.color)})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-sm font-bold text-shogun-text truncate`,children:e.name}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,b.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded border`,t.bg,t.color),children:t.label}),(0,b.jsxs)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest flex items-center gap-0.5`,n.color),children:[(0,b.jsx)(r,{className:`w-2.5 h-2.5`}),` `,n.label]})]}),e.endpoint_url&&(0,b.jsxs)(`div`,{className:`flex items-center gap-1 mt-1.5`,children:[(0,b.jsx)(se,{className:`w-2.5 h-2.5 text-shogun-subdued/50`}),(0,b.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50 font-mono truncate`,children:e.endpoint_url})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,b.jsx)(`span`,{className:g(`w-1.5 h-1.5 rounded-full`,e.is_active?`bg-green-500`:`bg-red-500`)}),(0,b.jsx)(`span`,{className:`text-[9px] text-shogun-subdued`,children:e.is_active?`Active`:`Deactivated`}),(0,b.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued/40`,children:[`· `,Ce(e.created_at)]})]})]})]})]},e.id)})}),He.length>0&&(0,b.jsxs)(`div`,{className:`space-y-2 pt-2 border-t border-purple-500/10`,children:[(0,b.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Recent Gateway Tasks`}),(0,b.jsx)(`div`,{className:`space-y-1`,children:He.map(e=>(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-[#050508] rounded-lg`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,b.jsx)(`span`,{className:g(`w-1.5 h-1.5 rounded-full flex-shrink-0`,e.status===`completed`?`bg-green-500`:e.status===`executing`||e.status===`dispatching`||e.status===`dispatched`?`bg-blue-500 animate-pulse`:e.status===`blocked`||e.status===`failed`||e.status===`dispatch_failed`?`bg-red-500`:`bg-yellow-500`)}),(0,b.jsx)(`span`,{className:`text-xs text-shogun-text font-mono truncate`,children:e.requested_action}),(0,b.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded border`,S(e.source_platform).bg,S(e.source_platform).color),children:e.source_protocol===`outbound_dispatch`?`↗ OUT`:`↙ IN`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[(0,b.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest`,e.status===`completed`?`text-green-400`:e.status===`failed`||e.status===`blocked`||e.status===`dispatch_failed`?`text-red-400`:`text-shogun-subdued`),children:e.status}),(0,b.jsx)(`span`,{className:`text-[9px] text-shogun-subdued/50 font-mono`,children:Se(e.created_at)})]})]},e.id))})]})]})]}),h?(0,b.jsxs)(`div`,{className:`p-20 text-center shogun-card border-dashed flex flex-col items-center gap-4`,children:[(0,b.jsx)(c,{className:`w-8 h-8 animate-spin text-indigo-400`}),(0,b.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] text-shogun-subdued`,children:`Loading workspaces...`})]}):t.length===0?(0,b.jsxs)(`div`,{className:`p-20 text-center shogun-card border-dashed border-2 border-indigo-500/20 flex flex-col items-center gap-6`,children:[(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`div`,{className:`w-20 h-20 rounded-2xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,b.jsx)(l,{className:`w-10 h-10 text-indigo-400`})}),(0,b.jsx)(me,{className:`absolute -top-1 -right-1 w-5 h-5 text-shogun-gold animate-pulse`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`No Workspaces Yet`}),(0,b.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-md`,children:`Create a workspace to start collaborating with other Shogun instances using the A2A protocol.`})]}),(0,b.jsxs)(`button`,{onClick:()=>T(!0),className:`px-8 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-lg transition-all flex items-center gap-2`,children:[(0,b.jsx)(u,{className:`w-4 h-4`}),` Create First Workspace`]})]}):(0,b.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:t.map(e=>(0,b.jsxs)(`div`,{className:`relative shogun-card group hover:border-indigo-500/50 transition-all flex flex-col`,children:[(0,b.jsx)(`button`,{onClick:t=>{t.stopPropagation(),H(e.id)},className:`absolute top-3 right-3 opacity-0 group-hover:opacity-100 p-1.5 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20 transition-all z-10`,title:`Delete workspace`,children:V===e.id?(0,b.jsx)(c,{className:`w-3.5 h-3.5 animate-spin`}):(0,b.jsx)(f,{className:`w-3.5 h-3.5`})}),(0,b.jsxs)(`button`,{onClick:()=>{i(e),z(e.shared_document||``)},className:`text-left flex flex-col flex-1`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between mb-4`,children:[(0,b.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center group-hover:bg-indigo-500/20 transition-colors flex-shrink-0`,children:(0,b.jsx)(o,{className:`w-6 h-6 text-indigo-400`})}),(0,b.jsxs)(`div`,{className:`flex flex-col items-end gap-1 pr-8`,children:[(0,b.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border`,e.scope===`federated`?`text-indigo-400 bg-indigo-500/10 border-indigo-500/30`:`text-shogun-subdued bg-shogun-card border-shogun-border`),children:e.scope}),(0,b.jsx)(`span`,{className:g(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded`,e.status===`active`?`text-green-400`:`text-shogun-subdued`),children:e.status})]})]}),(0,b.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text group-hover:text-indigo-400 transition-colors`,children:e.name}),e.topic&&(0,b.jsx)(`p`,{className:`text-[10px] text-indigo-400/70 font-bold uppercase tracking-widest mt-1`,children:e.topic}),e.description&&(0,b.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-2 line-clamp-2 leading-relaxed flex-1`,children:e.description}),(0,b.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-shogun-border flex items-center justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-shogun-subdued`,children:[(0,b.jsx)(he,{className:`w-3 h-3`}),` `,e.peer_count,` peer`,e.peer_count===1?``:`s`]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-shogun-subdued`,children:[(0,b.jsx)(le,{className:`w-3 h-3`}),` `,e.message_count,` msg`,e.message_count===1?``:`s`]})]}),(0,b.jsx)(re,{className:`w-4 h-4 text-shogun-subdued group-hover:text-indigo-400 transition-colors`})]})]})]},e.id))}),Be&&(()=>{let e=t.find(e=>e.id===Be);return e?(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,b.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/30 w-full max-w-sm rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,b.jsxs)(`div`,{className:`p-6 border-b border-red-500/20 bg-red-500/5 flex items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 border border-red-500/20 flex items-center justify-center`,children:(0,b.jsx)(f,{className:`w-5 h-5 text-red-400`})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Delete Workspace`}),(0,b.jsx)(`p`,{className:`text-[10px] text-red-400 uppercase tracking-widest font-bold`,children:`Permanent — cannot be undone`})]})]}),(0,b.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,b.jsxs)(`p`,{className:`text-sm text-shogun-subdued`,children:[`Delete `,(0,b.jsx)(`strong`,{className:`text-shogun-text`,children:e.name}),`? This will remove all `,e.message_count,` messages and `,e.peer_count,` peer connections permanently.`]}),(0,b.jsxs)(`div`,{className:`flex gap-3`,children:[(0,b.jsx)(`button`,{onClick:()=>H(null),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,b.jsxs)(`button`,{onClick:()=>ut(e.id),disabled:V===e.id,className:`flex-1 py-3 bg-red-600 hover:bg-red-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[V===e.id?(0,b.jsx)(c,{className:`w-4 h-4 animate-spin`}):(0,b.jsx)(f,{className:`w-4 h-4`}),`Delete`]})]})]})]})}):null})(),C&&(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,b.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,b.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex items-center justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,b.jsx)(o,{className:`w-5 h-5 text-indigo-400`})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`New Workspace`}),(0,b.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:`A2A Collaboration`})]})]}),(0,b.jsx)(`button`,{onClick:()=>T(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,b.jsx)(m,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,b.jsxs)(`div`,{className:`p-8 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Name *`}),(0,b.jsx)(`input`,{autoFocus:!0,value:E,onChange:e=>we(e.target.value),placeholder:`Project Alpha...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`,onKeyDown:e=>e.key===`Enter`&&at()})]}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Topic`}),(0,b.jsx)(`input`,{value:k,onChange:e=>Te(e.target.value),placeholder:`e.g. Market analysis, Code review...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`})]}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Description`}),(0,b.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),placeholder:`What will this workspace be used for?`,rows:3,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all resize-none`})]}),(0,b.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,b.jsx)(`button`,{onClick:()=>T(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,b.jsxs)(`button`,{onClick:at,disabled:A||!E.trim(),className:`flex-1 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.15em] rounded-xl shadow-lg transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[A?(0,b.jsx)(c,{className:`w-4 h-4 animate-spin`}):(0,b.jsx)(u,{className:`w-4 h-4`}),A?`Creating...`:`Create Workspace`]})]})]})]})}),Ge&&(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,b.jsxs)(`div`,{className:`bg-shogun-bg border border-purple-500/30 w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,b.jsxs)(`div`,{className:`p-6 border-b border-purple-500/20 bg-purple-500/5 flex items-center justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center`,children:(0,b.jsx)(s,{className:`w-5 h-5 text-purple-400`})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Register External Agent`}),(0,b.jsx)(`p`,{className:`text-[10px] text-purple-400 uppercase tracking-widest`,children:`Enterprise Gateway`})]})]}),(0,b.jsx)(`button`,{onClick:()=>G(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,b.jsx)(m,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,b.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Agent Name *`}),(0,b.jsx)(`input`,{autoFocus:!0,value:K,onChange:e=>Ke(e.target.value),placeholder:`e.g. Salesforce Sales Agent`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Platform`}),(0,b.jsxs)(`select`,{value:qe,onChange:e=>Je(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all`,children:[(0,b.jsx)(`option`,{value:`microsoft_365`,children:`Microsoft 365`}),(0,b.jsx)(`option`,{value:`salesforce`,children:`Salesforce`}),(0,b.jsx)(`option`,{value:`google`,children:`Google`}),(0,b.jsx)(`option`,{value:`servicenow`,children:`ServiceNow`}),(0,b.jsx)(`option`,{value:`custom`,children:`Custom`})]})]}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Direction`}),(0,b.jsxs)(`select`,{value:Ye,onChange:e=>Xe(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all`,children:[(0,b.jsx)(`option`,{value:`bidirectional`,children:`↔ Bidirectional`}),(0,b.jsx)(`option`,{value:`inbound`,children:`← Inbound (Agent → Shogun)`}),(0,b.jsx)(`option`,{value:`outbound`,children:`→ Outbound (Shogun → Agent)`})]})]})]}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:[`Endpoint URL `,(0,b.jsx)(`span`,{className:`text-shogun-subdued/40`,children:`(for outbound dispatch)`})]}),(0,b.jsx)(`input`,{value:Ze,onChange:e=>Qe(e.target.value),placeholder:`https://agent.example.com/api/tasks`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all font-mono`}),(0,b.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50`,children:`Required for outbound or bidirectional. Leave empty for inbound-only agents.`})]}),J&&(0,b.jsxs)(`div`,{className:g(`p-4 rounded-xl border space-y-2`,J.type===`success`?`bg-green-500/10 border-green-500/30`:`bg-red-500/10 border-red-500/30`),children:[(0,b.jsx)(`p`,{className:g(`text-xs`,J.type===`success`?`text-green-400`:`text-red-400`),children:J.text}),J.token&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 bg-black/30 rounded-lg p-2`,children:[(0,b.jsx)(`code`,{className:`text-[10px] text-shogun-gold font-mono truncate flex-1`,children:J.token}),(0,b.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(J.token),tt(!0),setTimeout(()=>tt(!1),2e3)},className:`flex-shrink-0 px-3 py-1.5 bg-shogun-gold/10 border border-shogun-gold/30 text-shogun-gold rounded text-[10px] font-bold uppercase tracking-widest hover:bg-shogun-gold/20 transition-colors flex items-center gap-1`,children:[et?(0,b.jsx)(te,{className:`w-3 h-3`}):(0,b.jsx)(oe,{className:`w-3 h-3`}),et?`Copied!`:`Copy Token`]})]})]}),(0,b.jsxs)(`div`,{className:`p-3 bg-purple-500/5 border border-purple-500/20 rounded-xl text-[10px] text-shogun-subdued space-y-1`,children:[(0,b.jsx)(`p`,{className:`font-bold text-purple-400`,children:`How it works:`}),(0,b.jsx)(`p`,{children:`• The external agent uses the token as a Bearer header to authenticate`}),(0,b.jsxs)(`p`,{children:[`• `,(0,b.jsx)(`strong`,{children:`Inbound:`}),` The agent POSTs tasks to `,(0,b.jsx)(`code`,{className:`text-shogun-text bg-shogun-card px-1 rounded`,children:`/api/v1/nexus/external/a2a/task`})]}),(0,b.jsxs)(`p`,{children:[`• `,(0,b.jsx)(`strong`,{children:`Outbound:`}),` Shogun dispatches tasks to the agent's endpoint URL`]}),(0,b.jsx)(`p`,{children:`• All traffic is audited in L1 (operational) and L2 (immutable) logs`})]}),(0,b.jsxs)(`div`,{className:`flex gap-3 pt-1`,children:[(0,b.jsx)(`button`,{onClick:()=>G(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,b.jsxs)(`button`,{onClick:ft,disabled:q||!K.trim(),className:`flex-1 py-3 bg-purple-600 hover:bg-purple-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[q?(0,b.jsx)(c,{className:`w-4 h-4 animate-spin`}):(0,b.jsx)(u,{className:`w-4 h-4`}),q?`Registering...`:`Register Agent`]})]})]})]})})]});let mt=a?.inbound_url||``;return(0,b.jsxs)(`div`,{className:`flex flex-col h-[calc(100vh-80px)] animate-in fade-in duration-300`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-shogun-border bg-shogun-card flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,b.jsx)(`button`,{onClick:()=>{i(null),R(!1),Z()},className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors text-shogun-subdued hover:text-shogun-text`,children:(0,b.jsx)(ye,{className:`w-4 h-4`})}),(0,b.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,b.jsx)(o,{className:`w-4 h-4 text-indigo-400`})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h2`,{className:`text-base font-bold text-shogun-text`,children:r.name}),r.topic&&(0,b.jsx)(`p`,{className:`text-[10px] text-indigo-400/70 font-bold uppercase tracking-widest`,children:r.topic})]}),(0,b.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border text-green-400 bg-green-500/10 border-green-500/20`,children:r.status})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`button`,{onClick:$,className:`p-2 text-shogun-subdued hover:text-indigo-400 transition-colors`,children:(0,b.jsx)(d,{className:`w-4 h-4`})}),(0,b.jsxs)(`button`,{onClick:()=>{j(!0),F(null)},className:`px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-widest rounded-lg transition-all flex items-center gap-2`,children:[(0,b.jsx)(p,{className:`w-3.5 h-3.5`}),` Invite Peer`]}),(0,b.jsx)(`button`,{onClick:()=>H(r.id),className:`p-2 text-shogun-subdued hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all border border-transparent hover:border-red-500/20`,title:`Delete workspace`,children:(0,b.jsx)(f,{className:`w-4 h-4`})})]})]}),(0,b.jsxs)(`div`,{className:`flex-1 overflow-hidden grid grid-cols-[220px_1fr_320px]`,children:[(0,b.jsxs)(`div`,{className:`border-r border-shogun-border overflow-y-auto bg-[#050508] p-4 space-y-4`,children:[(0,b.jsxs)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-2`,children:[(0,b.jsx)(he,{className:`w-3 h-3`}),` Peers (`,r.peers.length,`)`]}),(0,b.jsxs)(`div`,{className:`p-3 rounded-xl border border-indigo-500/20 bg-indigo-500/5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,b.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-indigo-400 flex-shrink-0`}),(0,b.jsx)(`p`,{className:`text-xs font-bold text-indigo-400 truncate`,children:a?.name||`Me`})]}),(0,b.jsx)(`p`,{className:`text-[9px] text-shogun-subdued font-bold uppercase tracking-wider`,children:`Owner · This Instance`})]}),r.peers.length===0?(0,b.jsxs)(`div`,{className:`p-4 border border-dashed border-shogun-border rounded-xl text-center`,children:[(0,b.jsx)(ge,{className:`w-5 h-5 text-shogun-subdued mx-auto mb-2 opacity-30`}),(0,b.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`No peers yet. Invite a remote Shogun.`})]}):r.peers.map(e=>(0,b.jsxs)(`div`,{className:`p-3 rounded-xl border border-shogun-border bg-shogun-card group`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,b.jsx)(`span`,{className:g(`w-2 h-2 rounded-full flex-shrink-0`,xe[e.status]||`bg-shogun-subdued`)}),(0,b.jsx)(`p`,{className:`text-xs font-bold text-shogun-text truncate`,children:e.peer_name})]}),(0,b.jsx)(`button`,{onClick:()=>lt(e.id),className:`opacity-0 group-hover:opacity-100 p-1 text-shogun-subdued hover:text-red-400 transition-all`,children:(0,b.jsx)(f,{className:`w-3 h-3`})})]}),(0,b.jsxs)(`p`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-wider mt-1`,children:[e.role,` · `,e.status]}),(0,b.jsx)(`p`,{className:`text-[8px] text-shogun-subdued/60 font-mono truncate mt-1`,children:e.peer_url}),e.last_seen_at&&(0,b.jsxs)(`p`,{className:`text-[8px] text-shogun-subdued/50 mt-1`,children:[`seen `,Ce(e.last_seen_at)]})]},e.id))]}),(0,b.jsxs)(`div`,{className:`flex flex-col overflow-hidden border-r border-shogun-border`,children:[(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-3`,children:[r.messages.length===0&&(0,b.jsx)(`div`,{className:`p-8 text-center text-shogun-subdued text-xs`,children:`No messages yet. Post the first one.`}),r.messages.map(e=>{let t=w[e.message_type]||w.update,n=e.from_peer_url===mt||e.from_agent_id===`system`;return e.message_type===`system`?(0,b.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,b.jsx)(`div`,{className:`flex-1 h-px bg-shogun-border`}),(0,b.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60 whitespace-nowrap px-2 font-mono italic`,dangerouslySetInnerHTML:{__html:e.content.replace(/\*\*(.+?)\*\*/g,`$1`).replace(/`(.+?)`/g,`$1`)}}),(0,b.jsx)(`div`,{className:`flex-1 h-px bg-shogun-border`})]},e.id):(0,b.jsxs)(`div`,{className:g(`flex gap-3`,n?`flex-row-reverse`:`flex-row`),children:[(0,b.jsx)(`div`,{className:g(`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 text-xs font-bold`,n?`bg-indigo-500/20 text-indigo-400`:`bg-shogun-card border border-shogun-border text-shogun-subdued`),children:(e.from_name||`?`).charAt(0).toUpperCase()}),(0,b.jsxs)(`div`,{className:g(`max-w-[75%] space-y-1`,n?`items-end`:`items-start`,`flex flex-col`),children:[(0,b.jsxs)(`div`,{className:g(`flex items-center gap-2`,n?`flex-row-reverse`:`flex-row`),children:[(0,b.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text`,children:e.from_name}),(0,b.jsx)(`span`,{className:g(`text-[8px] font-bold px-1.5 py-0.5 rounded border uppercase tracking-widest`,t.color),children:t.label}),(0,b.jsx)(`span`,{className:`text-[9px] text-shogun-subdued/60 font-mono`,children:Se(e.created_at)})]}),(0,b.jsx)(`div`,{className:g(`px-4 py-2.5 rounded-2xl text-sm leading-relaxed`,n?`bg-indigo-600 text-white rounded-tr-sm`:`bg-shogun-card border border-shogun-border text-shogun-text rounded-tl-sm`),children:(0,b.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.content.replace(/\*\*(.+?)\*\*/g,`$1`).replace(/`(.+?)`/g,`$1`)}})}),n&&e.delivery_status!==`local`&&(0,b.jsx)(`span`,{className:g(`text-[8px] font-mono`,e.delivery_status===`delivered`?`text-green-400`:e.delivery_status===`failed`?`text-red-400`:`text-shogun-subdued`),children:e.delivery_status})]})]},e.id)}),(0,b.jsx)(`div`,{ref:it})]}),(0,b.jsxs)(`div`,{className:`p-4 border-t border-shogun-border bg-shogun-card space-y-3 flex-shrink-0`,children:[(0,b.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[`update`,`proposal`,`task`,`plan_revision`,`approval`,`signal`].map(e=>{let t=w[e];return(0,b.jsx)(`button`,{onClick:()=>Ne(e),className:g(`text-[9px] px-2.5 py-1 rounded border font-bold uppercase tracking-widest transition-all`,L===e?t.color:`text-shogun-subdued border-shogun-border hover:border-shogun-text`),children:t.label},e)})}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`textarea`,{value:I,onChange:e=>Me(e.target.value),placeholder:`Post a ${w[L]?.label||`message`}...`,rows:2,className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl px-4 py-2.5 text-sm focus:border-indigo-500 outline-none transition-all resize-none`,onKeyDown:e=>{e.key===`Enter`&&e.ctrlKey&&st()}}),(0,b.jsx)(`button`,{onClick:st,disabled:Pe||!I.trim(),className:`px-4 bg-indigo-600 hover:bg-indigo-500 text-white rounded-xl transition-all disabled:opacity-40 flex items-center gap-2`,children:Pe?(0,b.jsx)(c,{className:`w-4 h-4 animate-spin`}):(0,b.jsx)(pe,{className:`w-4 h-4`})})]}),(0,b.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50`,children:`Ctrl+Enter to send · Messages are fanned out to all active peers`})]})]}),(0,b.jsxs)(`div`,{className:`overflow-y-auto flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`p-4 border-b border-shogun-border flex items-center justify-between flex-shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(ce,{className:`w-4 h-4 text-shogun-gold`}),(0,b.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Shared Document`}),r.document_version>0&&(0,b.jsxs)(`span`,{className:`text-[8px] font-mono text-shogun-subdued/60`,children:[`v`,r.document_version]})]}),Ie?(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`button`,{onClick:()=>R(!1),className:`p-1.5 text-shogun-subdued hover:text-shogun-text transition-colors`,children:(0,b.jsx)(m,{className:`w-3.5 h-3.5`})}),(0,b.jsxs)(`button`,{onClick:ct,disabled:B,className:`px-3 py-1.5 bg-shogun-gold hover:bg-shogun-gold/90 text-black text-[10px] font-bold uppercase tracking-widest rounded-lg transition-all flex items-center gap-1.5`,children:[B?(0,b.jsx)(c,{className:`w-3 h-3 animate-spin`}):(0,b.jsx)(fe,{className:`w-3 h-3`}),`Save`]})]}):(0,b.jsx)(`button`,{onClick:()=>{R(!0),z(r.shared_document||``)},className:`p-1.5 text-shogun-subdued hover:text-shogun-gold transition-colors rounded-lg hover:bg-shogun-card`,children:(0,b.jsx)(ue,{className:`w-3.5 h-3.5`})})]}),Ie?(0,b.jsx)(`textarea`,{value:Le,onChange:e=>z(e.target.value),className:`flex-1 bg-[#050508] text-sm text-shogun-text font-mono p-4 outline-none resize-none border-none`,placeholder:`# Document Title - -Write your shared plan here...`}):(0,b.jsx)(`div`,{className:`flex-1 p-4 overflow-y-auto`,children:r.shared_document?(0,b.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none text-shogun-text text-sm leading-relaxed space-y-3`,dangerouslySetInnerHTML:{__html:r.shared_document.replace(/^# (.+)$/gm,`

    $1

    `).replace(/^## (.+)$/gm,`

    $2

    `).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/`(.+?)`/g,`$1`).replace(/\n/g,`
    `)}}):(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-center`,children:[(0,b.jsx)(ee,{className:`w-8 h-8 text-shogun-subdued opacity-30`}),(0,b.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`No document yet.`,(0,b.jsx)(`br`,{}),`Click the edit icon to start writing.`]})]})})]})]}),De&&(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,b.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-md rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,b.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex items-center justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,b.jsx)(p,{className:`w-5 h-5 text-indigo-400`})}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Invite Peer`}),(0,b.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:`Remote Shogun A2A URL`})]})]}),(0,b.jsx)(`button`,{onClick:()=>j(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,b.jsx)(m,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,b.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Peer Endpoint URL *`}),(0,b.jsx)(`input`,{autoFocus:!0,value:M,onChange:e=>Oe(e.target.value),placeholder:`http://remote-shogun:8000/api/v1/a2a/inbound`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all font-mono`})]}),(0,b.jsxs)(`div`,{className:`space-y-2`,children:[(0,b.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Display Name (optional)`}),(0,b.jsx)(`input`,{value:ke,onChange:e=>Ae(e.target.value),placeholder:`Their Shogun's name...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`})]}),P&&(0,b.jsx)(`div`,{className:g(`p-3 rounded-lg border text-xs`,P.type===`success`?`bg-green-500/10 border-green-500/30 text-green-400`:`bg-red-500/10 border-red-500/30 text-red-400`),children:P.text}),(0,b.jsxs)(`div`,{className:`p-3 bg-indigo-500/5 border border-indigo-500/20 rounded-xl text-[10px] text-shogun-subdued space-y-1`,children:[(0,b.jsx)(`p`,{className:`font-bold text-indigo-400`,children:`How it works:`}),(0,b.jsx)(`p`,{children:`• We ping their endpoint to verify it's reachable`}),(0,b.jsx)(`p`,{children:`• A signed invitation is sent using HMAC-SHA256`}),(0,b.jsx)(`p`,{children:`• They can then post messages back to this workspace`})]}),(0,b.jsxs)(`div`,{className:`flex gap-3`,children:[(0,b.jsx)(`button`,{onClick:()=>j(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,b.jsxs)(`button`,{onClick:ot,disabled:N||!M.trim(),className:`flex-1 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[N?(0,b.jsx)(c,{className:`w-4 h-4 animate-spin`}):(0,b.jsx)(pe,{className:`w-4 h-4`}),N?`Sending...`:`Send Invitation`]})]})]})]})})]})}export{T as Nexus}; \ No newline at end of file diff --git a/frontend/dist/assets/Nexus-nfAkNg-1.js b/frontend/dist/assets/Nexus-nfAkNg-1.js new file mode 100644 index 0000000..cef4b90 --- /dev/null +++ b/frontend/dist/assets/Nexus-nfAkNg-1.js @@ -0,0 +1,3 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./arrow-right-left-B7B694Vj.js";import{t as n}from"./check-DnxCktpz.js";import{t as ee}from"./chevron-down-qQcy55Tl.js";import{t as te}from"./chevron-right-CVeYaFvJ.js";import{t as ne}from"./chevron-up-BQBhWwJ7.js";import{t as r}from"./circle-alert-043xB2li.js";import{t as i}from"./circle-check-DBu5bzEI.js";import{t as re}from"./copy-BVi6zu1A.js";import{t as ie}from"./external-link-pPtmvETu.js";import{t as ae}from"./file-text-CrD-Um8r.js";import{t as a}from"./git-branch-qj-Uwi0O.js";import{t as oe}from"./pen-line-BmYzOL4O.js";import{t as o}from"./plus-Cxx0HjpF.js";import{t as se}from"./power-Bl6a5geq.js";import{t as s}from"./refresh-cw-Dm6S5UAJ.js";import{t as ce}from"./save-CupVJLfi.js";import{t as le}from"./send-BcKLBpfZ.js";import{t as ue}from"./sparkles-DyLIKWW0.js";import{t as c}from"./trash-2-DqRUHXwV.js";import{t as l}from"./user-plus-vtJ7dasD.js";import{t as de}from"./wifi-nqq7raTh.js";import{t as u}from"./zap-CQy--vuS.js";import{C as fe,T as d,a as f,g as p,i as m,j as pe,m as me,o as he,p as h,r as ge,t as g,y as _}from"./index-Dy1E248t.js";import{t as v}from"./axios-BGmZl9Qd.js";import{n as y,r as _e,t as ve}from"./infrastructureAuth-D0TsVUiV.js";var ye=d(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),be=d(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),b=d(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),x=e(pe(),1),S=g(),C={microsoft_365:{label:`Microsoft 365`,color:`text-blue-400`,bg:`bg-blue-500/10 border-blue-500/30`},salesforce:{label:`Salesforce`,color:`text-cyan-400`,bg:`bg-cyan-500/10 border-cyan-500/30`},google:{label:`Google`,color:`text-green-400`,bg:`bg-green-500/10 border-green-500/30`},servicenow:{label:`ServiceNow`,color:`text-lime-400`,bg:`bg-lime-500/10 border-lime-500/30`},custom:{label:`Custom`,color:`text-purple-400`,bg:`bg-purple-500/10 border-purple-500/30`}},w=e=>C[e]||C.custom,T={inbound:{label:`Inbound`,icon:ye,color:`text-cyan-400`},outbound:{label:`Outbound`,icon:b,color:`text-orange-400`},bidirectional:{label:`Bidirectional`,icon:t,color:`text-indigo-400`}},xe=e=>T[e]||T.bidirectional,E={proposal:{color:`text-purple-400 bg-purple-500/10 border-purple-500/30`,label:`Proposal`,icon:ue},task:{color:`text-shogun-blue bg-shogun-blue/10 border-shogun-blue/30`,label:`Task`,icon:u},reply:{color:`text-shogun-subdued bg-shogun-card border-shogun-border`,label:`Reply`,icon:me},update:{color:`text-green-400 bg-green-500/10 border-green-500/30`,label:`Update`,icon:a},plan_revision:{color:`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/30`,label:`Plan Rev.`,icon:oe},approval:{color:`text-green-400 bg-green-500/10 border-green-500/30`,label:`Approval`,icon:i},signal:{color:`text-orange-400 bg-orange-500/10 border-orange-500/30`,label:`Signal`,icon:r},invitation:{color:`text-purple-400 bg-purple-500/10 border-purple-500/30`,label:`Invitation`,icon:l},system:{color:`text-shogun-subdued/60 bg-transparent border-transparent`,label:`System`,icon:h}},Se={active:`bg-green-500`,pending:`bg-yellow-500`,offline:`bg-shogun-subdued`,declined:`bg-red-500`};function Ce(e){try{return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}catch{return``}}function we(e){try{return new Date(e).toLocaleDateString([],{month:`short`,day:`numeric`})}catch{return``}}function D(){let{t:e}=ge(),[t,r]=(0,x.useState)([]),[i,u]=(0,x.useState)(null),[d,pe]=(0,x.useState)(null),[g,ye]=(0,x.useState)(!0),[b,C]=(0,x.useState)(!1),[T,D]=(0,x.useState)(!1),[O,Te]=(0,x.useState)(``),[Ee,De]=(0,x.useState)(``),[Oe,ke]=(0,x.useState)(``),[k,Ae]=(0,x.useState)(!1),[je,A]=(0,x.useState)(!1),[j,Me]=(0,x.useState)(``),[M,Ne]=(0,x.useState)(ve),[Pe,Fe]=(0,x.useState)(``),[N,Ie]=(0,x.useState)(!1),[P,F]=(0,x.useState)(null),[I,Le]=(0,x.useState)(``),[L,Re]=(0,x.useState)(`update`),[ze,R]=(0,x.useState)(!1),[Be,z]=(0,x.useState)(!1),[Ve,B]=(0,x.useState)(``),[He,Ue]=(0,x.useState)(!1),[V,We]=(0,x.useState)(null),[Ge,H]=(0,x.useState)(null),[U,Ke]=(0,x.useState)([]),[qe,Je]=(0,x.useState)([]),[W,Ye]=(0,x.useState)(!0),[Xe,G]=(0,x.useState)(!1),[K,Ze]=(0,x.useState)(``),[Qe,$e]=(0,x.useState)(`microsoft_365`),[et,tt]=(0,x.useState)(`bidirectional`),[nt,rt]=(0,x.useState)(``),[q,it]=(0,x.useState)(!1),[J,Y]=(0,x.useState)(null),[at,ot]=(0,x.useState)(!1),[st,ct]=(0,x.useState)(!1),X=(0,x.useRef)(null),lt=(0,x.useRef)(null),Z=(0,x.useCallback)(async()=>{try{let[e,t]=await Promise.all([v.get(`/api/v1/workspaces`),v.get(`/api/v1/a2a/identity`)]);r(e.data.data||[]),pe(t.data.data)}catch(e){console.error(`Nexus fetch error:`,e)}finally{ye(!1)}},[]),Q=(0,x.useCallback)(async()=>{ct(!0);try{let[e,t]=await Promise.allSettled([v.get(`/api/v1/nexus/external/agents`),v.get(`/api/v1/nexus/external/tasks`,{params:{limit:10}})]);e.status===`fulfilled`&&Ke(e.value.data.data||[]),t.status===`fulfilled`&&Je(t.value.data.data||[])}catch{}finally{ct(!1)}},[]),$=(0,x.useCallback)(async()=>{if(i)try{let e=(await v.get(`/api/v1/workspaces/${i.id}`)).data.data;u(e),r(t=>t.map(t=>t.id===e.id?e:t))}catch(e){console.error(`Workspace refresh error:`,e)}},[i]);(0,x.useEffect)(()=>{Z(),Q()},[]),(0,x.useEffect)(()=>(X.current&&clearInterval(X.current),i&&(X.current=setInterval($,8e3)),()=>{X.current&&clearInterval(X.current)}),[i?.id]),(0,x.useEffect)(()=>{lt.current?.scrollIntoView({behavior:`smooth`})},[i?.messages?.length]);let ut=async()=>{if(O.trim()){Ae(!0);try{let e=(await v.post(`/api/v1/workspaces`,{name:O,description:Ee||null,topic:Oe||null})).data.data;r(t=>[e,...t]),u(e),D(!1),Te(``),De(``),ke(``)}catch(e){console.error(e)}finally{Ae(!1)}}},dt=async()=>{if(!(!j.trim()||!i)){Ie(!0),F(null);try{await v.post(`/api/v1/workspaces/${i.id}/peers`,{peer_url:j,peer_name:Pe||`Remote Shogun`},y(M)),F({type:`success`,text:`Invitation sent. Peer is now pending.`}),Me(``),Fe(``),await $()}catch(e){F({type:`error`,text:e.response?.data?.detail||`Invite failed`})}finally{Ie(!1)}}},ft=async()=>{if(!(!I.trim()||!i)){R(!0);try{await v.post(`/api/v1/workspaces/${i.id}/messages`,{content:I,message_type:L},y(M)),Le(``),await $()}catch(e){console.error(e)}finally{R(!1)}}},pt=async()=>{if(i){Ue(!0);try{await v.patch(`/api/v1/workspaces/${i.id}/document`,{content:Ve},y(M)),z(!1),await $()}catch(e){console.error(e)}finally{Ue(!1)}}},mt=async e=>{if(i)try{await v.delete(`/api/v1/workspaces/${i.id}/peers/${e}`),await $()}catch(e){console.error(e)}},ht=async e=>{We(e);try{await v.delete(`/api/v1/workspaces/${e}`),r(t=>t.filter(t=>t.id!==e)),i?.id===e&&u(null)}catch(e){console.error(e)}finally{We(null),H(null)}},gt=()=>{d?.inbound_url&&(navigator.clipboard.writeText(d.inbound_url),C(!0),setTimeout(()=>C(!1),2e3))},_t=async()=>{if(K.trim()){it(!0),Y(null);try{let e=(await v.post(`/api/v1/nexus/external/register-agent`,{name:K,platform:Qe,direction:et,endpoint_url:nt||null})).data.data;Y({type:`success`,text:`Agent "${e.name}" registered. Copy the token below — it won't be shown again.`,token:e.token}),Ze(``),rt(``),await Q()}catch(e){Y({type:`error`,text:e.response?.data?.detail||`Registration failed`})}finally{it(!1)}}},vt=async e=>{try{await v.patch(`/api/v1/nexus/external/agents/${e}`,{is_active:!1}),await Q()}catch(e){console.error(e)}};if(!i)return(0,S.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-7xl mx-auto pb-12`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`nexus.title`,`Nexus`),(0,S.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:`A2A Protocol`})]}),(0,S.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`nexus.subtitle`,`Agent-to-Agent workspaces — plan, communicate, and collaborate with remote Shogun instances.`)})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`button`,{onClick:Z,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,S.jsx)(s,{className:m(`w-4 h-4`,g&&`animate-spin`)})}),(0,S.jsxs)(`button`,{onClick:()=>D(!0),className:`px-5 py-2.5 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.15em] rounded-xl shadow-lg transition-all flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`w-4 h-4`}),` `,e(`nexus.new_workspace`,`New Workspace`)]})]})]}),d&&(0,S.jsxs)(`div`,{className:`shogun-card bg-indigo-500/5 border-indigo-500/20 flex items-center gap-6`,children:[(0,S.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center flex-shrink-0`,children:(0,S.jsx)(h,{className:`w-6 h-6 text-indigo-400`})}),(0,S.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,S.jsx)(`p`,{className:`text-[10px] font-bold text-indigo-400 uppercase tracking-widest`,children:`My A2A Endpoint`}),(0,S.jsx)(`p`,{className:`text-sm font-bold text-shogun-text mt-0.5`,children:d.name}),(0,S.jsx)(`code`,{className:`text-[10px] text-shogun-subdued font-mono truncate block`,children:d.inbound_url})]}),(0,S.jsxs)(`button`,{onClick:gt,className:`flex-shrink-0 px-4 py-2 bg-indigo-500/10 border border-indigo-500/30 text-indigo-400 rounded-lg text-xs font-bold uppercase tracking-widest hover:bg-indigo-500/20 transition-colors flex items-center gap-2`,children:[b?(0,S.jsx)(n,{className:`w-3.5 h-3.5`}):(0,S.jsx)(re,{className:`w-3.5 h-3.5`}),b?`Copied`:`Copy URL`]})]}),(0,S.jsxs)(`div`,{className:`shogun-card border-purple-500/20 overflow-hidden`,children:[(0,S.jsxs)(`button`,{onClick:()=>Ye(!W),className:`w-full flex items-center justify-between px-5 py-4 hover:bg-purple-500/5 transition-colors`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,S.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center`,children:(0,S.jsx)(_,{className:`w-5 h-5 text-purple-400`})}),(0,S.jsxs)(`div`,{className:`text-left`,children:[(0,S.jsxs)(`p`,{className:`text-sm font-bold text-shogun-text flex items-center gap-2`,children:[`External Gateway`,(0,S.jsx)(`span`,{className:`text-[8px] font-normal text-purple-400 bg-purple-500/10 px-2 py-0.5 rounded border border-purple-500/20 uppercase tracking-widest`,children:`Enterprise`})]}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:U.length===0?`Connect Microsoft 365, Salesforce, Google, ServiceNow and more`:`${U.filter(e=>e.is_active).length} active agent${U.filter(e=>e.is_active).length===1?``:`s`} connected`})]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[U.length>0&&(0,S.jsxs)(`div`,{className:`flex -space-x-2`,children:[U.slice(0,4).map(e=>{let t=w(e.platform);return(0,S.jsx)(`div`,{className:m(`w-7 h-7 rounded-full border-2 border-shogun-bg flex items-center justify-center text-[9px] font-bold`,t.bg,t.color),children:e.name.charAt(0).toUpperCase()},e.id)}),U.length>4&&(0,S.jsxs)(`div`,{className:`w-7 h-7 rounded-full border-2 border-shogun-bg bg-shogun-card flex items-center justify-center text-[9px] text-shogun-subdued`,children:[`+`,U.length-4]})]}),W?(0,S.jsx)(ne,{className:`w-4 h-4 text-shogun-subdued`}):(0,S.jsx)(ee,{className:`w-4 h-4 text-shogun-subdued`})]})]}),W&&(0,S.jsxs)(`div`,{className:`border-t border-purple-500/10 p-5 space-y-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Registered Enterprise Agents`}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{onClick:Q,className:`p-1.5 text-shogun-subdued hover:text-purple-400 transition-colors rounded-lg`,children:(0,S.jsx)(s,{className:m(`w-3.5 h-3.5`,st&&`animate-spin`)})}),(0,S.jsxs)(`button`,{onClick:()=>{G(!0),Y(null)},className:`px-4 py-2 bg-purple-600 hover:bg-purple-500 text-white font-bold text-[10px] uppercase tracking-widest rounded-lg transition-all flex items-center gap-1.5`,children:[(0,S.jsx)(o,{className:`w-3.5 h-3.5`}),` Register Agent`]})]})]}),U.length===0?(0,S.jsxs)(`div`,{className:`p-8 border border-dashed border-purple-500/20 rounded-xl text-center space-y-3`,children:[(0,S.jsx)(_,{className:`w-8 h-8 text-purple-400/30 mx-auto`}),(0,S.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No external agents registered yet.`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued/60`,children:`Register an agent to let enterprise AI platforms send tasks to Shogun, or to dispatch tasks outward.`})]}):(0,S.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:U.map(e=>{let t=w(e.platform),n=xe(e.direction),ee=n.icon;return(0,S.jsxs)(`div`,{className:m(`shogun-card border-l-2 group relative`,e.is_active?`border-l-purple-400/60`:`border-l-shogun-border opacity-50`),children:[e.is_active&&(0,S.jsx)(`button`,{onClick:()=>vt(e.id),className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 p-1 rounded bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20 transition-all`,title:`Deactivate agent`,children:(0,S.jsx)(se,{className:`w-3 h-3`})}),(0,S.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,S.jsx)(`div`,{className:m(`w-9 h-9 rounded-lg flex items-center justify-center border flex-shrink-0`,t.bg),children:(0,S.jsx)(_,{className:m(`w-4 h-4`,t.color)})}),(0,S.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,S.jsx)(`p`,{className:`text-sm font-bold text-shogun-text truncate`,children:e.name}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mt-1`,children:[(0,S.jsx)(`span`,{className:m(`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded border`,t.bg,t.color),children:t.label}),(0,S.jsxs)(`span`,{className:m(`text-[8px] font-bold uppercase tracking-widest flex items-center gap-0.5`,n.color),children:[(0,S.jsx)(ee,{className:`w-2.5 h-2.5`}),` `,n.label]})]}),e.endpoint_url&&(0,S.jsxs)(`div`,{className:`flex items-center gap-1 mt-1.5`,children:[(0,S.jsx)(ie,{className:`w-2.5 h-2.5 text-shogun-subdued/50`}),(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50 font-mono truncate`,children:e.endpoint_url})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,S.jsx)(`span`,{className:m(`w-1.5 h-1.5 rounded-full`,e.is_active?`bg-green-500`:`bg-red-500`)}),(0,S.jsx)(`span`,{className:`text-[9px] text-shogun-subdued`,children:e.is_active?`Active`:`Deactivated`}),(0,S.jsxs)(`span`,{className:`text-[9px] text-shogun-subdued/40`,children:[`· `,we(e.created_at)]})]})]})]})]},e.id)})}),qe.length>0&&(0,S.jsxs)(`div`,{className:`space-y-2 pt-2 border-t border-purple-500/10`,children:[(0,S.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Recent Gateway Tasks`}),(0,S.jsx)(`div`,{className:`space-y-1`,children:qe.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-[#050508] rounded-lg`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,S.jsx)(`span`,{className:m(`w-1.5 h-1.5 rounded-full flex-shrink-0`,e.status===`completed`?`bg-green-500`:e.status===`executing`||e.status===`dispatching`||e.status===`dispatched`?`bg-blue-500 animate-pulse`:e.status===`blocked`||e.status===`failed`||e.status===`dispatch_failed`?`bg-red-500`:`bg-yellow-500`)}),(0,S.jsx)(`span`,{className:`text-xs text-shogun-text font-mono truncate`,children:e.requested_action}),(0,S.jsx)(`span`,{className:m(`text-[8px] font-bold uppercase tracking-widest px-1.5 py-0.5 rounded border`,w(e.source_platform).bg,w(e.source_platform).color),children:e.source_protocol===`outbound_dispatch`?`↗ OUT`:`↙ IN`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[(0,S.jsx)(`span`,{className:m(`text-[8px] font-bold uppercase tracking-widest`,e.status===`completed`?`text-green-400`:e.status===`failed`||e.status===`blocked`||e.status===`dispatch_failed`?`text-red-400`:`text-shogun-subdued`),children:e.status}),(0,S.jsx)(`span`,{className:`text-[9px] text-shogun-subdued/50 font-mono`,children:Ce(e.created_at)})]})]},e.id))})]})]})]}),g?(0,S.jsxs)(`div`,{className:`p-20 text-center shogun-card border-dashed flex flex-col items-center gap-4`,children:[(0,S.jsx)(p,{className:`w-8 h-8 animate-spin text-indigo-400`}),(0,S.jsx)(`p`,{className:`text-[10px] font-bold uppercase tracking-[0.2em] text-shogun-subdued`,children:`Loading workspaces...`})]}):t.length===0?(0,S.jsxs)(`div`,{className:`p-20 text-center shogun-card border-dashed border-2 border-indigo-500/20 flex flex-col items-center gap-6`,children:[(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(`div`,{className:`w-20 h-20 rounded-2xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,S.jsx)(h,{className:`w-10 h-10 text-indigo-400`})}),(0,S.jsx)(ue,{className:`absolute -top-1 -right-1 w-5 h-5 text-shogun-gold animate-pulse`})]}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text mb-2`,children:`No Workspaces Yet`}),(0,S.jsx)(`p`,{className:`text-sm text-shogun-subdued max-w-md`,children:`Create a workspace to start collaborating with other Shogun instances using the A2A protocol.`})]}),(0,S.jsxs)(`button`,{onClick:()=>D(!0),className:`px-8 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.2em] rounded-xl shadow-lg transition-all flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`w-4 h-4`}),` Create First Workspace`]})]}):(0,S.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:t.map(e=>(0,S.jsxs)(`div`,{className:`relative shogun-card group hover:border-indigo-500/50 transition-all flex flex-col`,children:[(0,S.jsx)(`button`,{onClick:t=>{t.stopPropagation(),H(e.id)},className:`absolute top-3 right-3 opacity-0 group-hover:opacity-100 p-1.5 rounded-lg bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20 transition-all z-10`,title:`Delete workspace`,children:V===e.id?(0,S.jsx)(p,{className:`w-3.5 h-3.5 animate-spin`}):(0,S.jsx)(c,{className:`w-3.5 h-3.5`})}),(0,S.jsxs)(`button`,{onClick:()=>{u(e),B(e.shared_document||``)},className:`text-left flex flex-col flex-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between mb-4`,children:[(0,S.jsx)(`div`,{className:`w-12 h-12 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center group-hover:bg-indigo-500/20 transition-colors flex-shrink-0`,children:(0,S.jsx)(a,{className:`w-6 h-6 text-indigo-400`})}),(0,S.jsxs)(`div`,{className:`flex flex-col items-end gap-1 pr-8`,children:[(0,S.jsx)(`span`,{className:m(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border`,e.scope===`federated`?`text-indigo-400 bg-indigo-500/10 border-indigo-500/30`:`text-shogun-subdued bg-shogun-card border-shogun-border`),children:e.scope}),(0,S.jsx)(`span`,{className:m(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded`,e.status===`active`?`text-green-400`:`text-shogun-subdued`),children:e.status})]})]}),(0,S.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text group-hover:text-indigo-400 transition-colors`,children:e.name}),e.topic&&(0,S.jsx)(`p`,{className:`text-[10px] text-indigo-400/70 font-bold uppercase tracking-widest mt-1`,children:e.topic}),e.description&&(0,S.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-2 line-clamp-2 leading-relaxed flex-1`,children:e.description}),(0,S.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-shogun-border flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-shogun-subdued`,children:[(0,S.jsx)(he,{className:`w-3 h-3`}),` `,e.peer_count,` peer`,e.peer_count===1?``:`s`]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-shogun-subdued`,children:[(0,S.jsx)(me,{className:`w-3 h-3`}),` `,e.message_count,` msg`,e.message_count===1?``:`s`]})]}),(0,S.jsx)(te,{className:`w-4 h-4 text-shogun-subdued group-hover:text-indigo-400 transition-colors`})]})]})]},e.id))}),Ge&&(()=>{let e=t.find(e=>e.id===Ge);return e?(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,S.jsxs)(`div`,{className:`bg-shogun-bg border border-red-500/30 w-full max-w-sm rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,S.jsxs)(`div`,{className:`p-6 border-b border-red-500/20 bg-red-500/5 flex items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-red-500/10 border border-red-500/20 flex items-center justify-center`,children:(0,S.jsx)(c,{className:`w-5 h-5 text-red-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Delete Workspace`}),(0,S.jsx)(`p`,{className:`text-[10px] text-red-400 uppercase tracking-widest font-bold`,children:`Permanent — cannot be undone`})]})]}),(0,S.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,S.jsxs)(`p`,{className:`text-sm text-shogun-subdued`,children:[`Delete `,(0,S.jsx)(`strong`,{className:`text-shogun-text`,children:e.name}),`? This will remove all `,e.message_count,` messages and `,e.peer_count,` peer connections permanently.`]}),(0,S.jsxs)(`div`,{className:`flex gap-3`,children:[(0,S.jsx)(`button`,{onClick:()=>H(null),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,S.jsxs)(`button`,{onClick:()=>ht(e.id),disabled:V===e.id,className:`flex-1 py-3 bg-red-600 hover:bg-red-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[V===e.id?(0,S.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,S.jsx)(c,{className:`w-4 h-4`}),`Delete`]})]})]})]})}):null})(),T&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,S.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,S.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,S.jsx)(a,{className:`w-5 h-5 text-indigo-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:`New Workspace`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:`A2A Collaboration`})]})]}),(0,S.jsx)(`button`,{onClick:()=>D(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,S.jsx)(f,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,S.jsxs)(`div`,{className:`p-8 space-y-5`,children:[(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Name *`}),(0,S.jsx)(`input`,{autoFocus:!0,value:O,onChange:e=>Te(e.target.value),placeholder:`Project Alpha...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`,onKeyDown:e=>e.key===`Enter`&&ut()})]}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Topic`}),(0,S.jsx)(`input`,{value:Oe,onChange:e=>ke(e.target.value),placeholder:`e.g. Market analysis, Code review...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`})]}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Description`}),(0,S.jsx)(`textarea`,{value:Ee,onChange:e=>De(e.target.value),placeholder:`What will this workspace be used for?`,rows:3,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all resize-none`})]}),(0,S.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,S.jsx)(`button`,{onClick:()=>D(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,S.jsxs)(`button`,{onClick:ut,disabled:k||!O.trim(),className:`flex-1 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-[0.15em] rounded-xl shadow-lg transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[k?(0,S.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,S.jsx)(o,{className:`w-4 h-4`}),k?`Creating...`:`Create Workspace`]})]})]})]})}),Xe&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,S.jsxs)(`div`,{className:`bg-shogun-bg border border-purple-500/30 w-full max-w-lg rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,S.jsxs)(`div`,{className:`p-6 border-b border-purple-500/20 bg-purple-500/5 flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center`,children:(0,S.jsx)(_,{className:`w-5 h-5 text-purple-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Register External Agent`}),(0,S.jsx)(`p`,{className:`text-[10px] text-purple-400 uppercase tracking-widest`,children:`Enterprise Gateway`})]})]}),(0,S.jsx)(`button`,{onClick:()=>G(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,S.jsx)(f,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,S.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Agent Name *`}),(0,S.jsx)(`input`,{autoFocus:!0,value:K,onChange:e=>Ze(e.target.value),placeholder:`e.g. Salesforce Sales Agent`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all`})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Platform`}),(0,S.jsxs)(`select`,{value:Qe,onChange:e=>$e(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all`,children:[(0,S.jsx)(`option`,{value:`microsoft_365`,children:`Microsoft 365`}),(0,S.jsx)(`option`,{value:`salesforce`,children:`Salesforce`}),(0,S.jsx)(`option`,{value:`google`,children:`Google`}),(0,S.jsx)(`option`,{value:`servicenow`,children:`ServiceNow`}),(0,S.jsx)(`option`,{value:`custom`,children:`Custom`})]})]}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Direction`}),(0,S.jsxs)(`select`,{value:et,onChange:e=>tt(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all`,children:[(0,S.jsx)(`option`,{value:`bidirectional`,children:`↔ Bidirectional`}),(0,S.jsx)(`option`,{value:`inbound`,children:`← Inbound (Agent → Shogun)`}),(0,S.jsx)(`option`,{value:`outbound`,children:`→ Outbound (Shogun → Agent)`})]})]})]}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:[`Endpoint URL `,(0,S.jsx)(`span`,{className:`text-shogun-subdued/40`,children:`(for outbound dispatch)`})]}),(0,S.jsx)(`input`,{value:nt,onChange:e=>rt(e.target.value),placeholder:`https://agent.example.com/api/tasks`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-purple-500 outline-none transition-all font-mono`}),(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50`,children:`Required for outbound or bidirectional. Leave empty for inbound-only agents.`})]}),J&&(0,S.jsxs)(`div`,{className:m(`p-4 rounded-xl border space-y-2`,J.type===`success`?`bg-green-500/10 border-green-500/30`:`bg-red-500/10 border-red-500/30`),children:[(0,S.jsx)(`p`,{className:m(`text-xs`,J.type===`success`?`text-green-400`:`text-red-400`),children:J.text}),J.token&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 bg-black/30 rounded-lg p-2`,children:[(0,S.jsx)(`code`,{className:`text-[10px] text-shogun-gold font-mono truncate flex-1`,children:J.token}),(0,S.jsxs)(`button`,{onClick:()=>{navigator.clipboard.writeText(J.token),ot(!0),setTimeout(()=>ot(!1),2e3)},className:`flex-shrink-0 px-3 py-1.5 bg-shogun-gold/10 border border-shogun-gold/30 text-shogun-gold rounded text-[10px] font-bold uppercase tracking-widest hover:bg-shogun-gold/20 transition-colors flex items-center gap-1`,children:[at?(0,S.jsx)(n,{className:`w-3 h-3`}):(0,S.jsx)(re,{className:`w-3 h-3`}),at?`Copied!`:`Copy Token`]})]})]}),(0,S.jsxs)(`div`,{className:`p-3 bg-purple-500/5 border border-purple-500/20 rounded-xl text-[10px] text-shogun-subdued space-y-1`,children:[(0,S.jsx)(`p`,{className:`font-bold text-purple-400`,children:`How it works:`}),(0,S.jsx)(`p`,{children:`• The external agent uses the token as a Bearer header to authenticate`}),(0,S.jsxs)(`p`,{children:[`• `,(0,S.jsx)(`strong`,{children:`Inbound:`}),` The agent POSTs tasks to `,(0,S.jsx)(`code`,{className:`text-shogun-text bg-shogun-card px-1 rounded`,children:`/api/v1/nexus/external/a2a/task`})]}),(0,S.jsxs)(`p`,{children:[`• `,(0,S.jsx)(`strong`,{children:`Outbound:`}),` Shogun dispatches tasks to the agent's endpoint URL`]}),(0,S.jsx)(`p`,{children:`• All traffic is audited in L1 (operational) and L2 (immutable) logs`})]}),(0,S.jsxs)(`div`,{className:`flex gap-3 pt-1`,children:[(0,S.jsx)(`button`,{onClick:()=>G(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,S.jsxs)(`button`,{onClick:_t,disabled:q||!K.trim(),className:`flex-1 py-3 bg-purple-600 hover:bg-purple-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[q?(0,S.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,S.jsx)(o,{className:`w-4 h-4`}),q?`Registering...`:`Register Agent`]})]})]})]})})]});let yt=d?.inbound_url||``;return(0,S.jsxs)(`div`,{className:`flex flex-col h-[calc(100vh-80px)] animate-in fade-in duration-300`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-shogun-border bg-shogun-card flex-shrink-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,S.jsx)(`button`,{onClick:()=>{u(null),z(!1),Z()},className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors text-shogun-subdued hover:text-shogun-text`,children:(0,S.jsx)(be,{className:`w-4 h-4`})}),(0,S.jsx)(`div`,{className:`w-9 h-9 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,S.jsx)(a,{className:`w-4 h-4 text-indigo-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-base font-bold text-shogun-text`,children:i.name}),i.topic&&(0,S.jsx)(`p`,{className:`text-[10px] text-indigo-400/70 font-bold uppercase tracking-widest`,children:i.topic})]}),(0,S.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border text-green-400 bg-green-500/10 border-green-500/20`,children:i.status})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{onClick:$,className:`p-2 text-shogun-subdued hover:text-indigo-400 transition-colors`,children:(0,S.jsx)(s,{className:`w-4 h-4`})}),(0,S.jsxs)(`button`,{onClick:()=>{A(!0),F(null)},className:`px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-widest rounded-lg transition-all flex items-center gap-2`,children:[(0,S.jsx)(l,{className:`w-3.5 h-3.5`}),` Invite Peer`]}),(0,S.jsx)(`button`,{onClick:()=>H(i.id),className:`p-2 text-shogun-subdued hover:text-red-400 hover:bg-red-500/10 rounded-lg transition-all border border-transparent hover:border-red-500/20`,title:`Delete workspace`,children:(0,S.jsx)(c,{className:`w-4 h-4`})})]})]}),(0,S.jsxs)(`div`,{className:`flex-1 overflow-hidden grid grid-cols-[220px_1fr_320px]`,children:[(0,S.jsxs)(`div`,{className:`border-r border-shogun-border overflow-y-auto bg-[#050508] p-4 space-y-4`,children:[(0,S.jsxs)(`p`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-2`,children:[(0,S.jsx)(he,{className:`w-3 h-3`}),` Peers (`,i.peers.length,`)`]}),(0,S.jsxs)(`div`,{className:`p-3 rounded-xl border border-indigo-500/20 bg-indigo-500/5`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,S.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-indigo-400 flex-shrink-0`}),(0,S.jsx)(`p`,{className:`text-xs font-bold text-indigo-400 truncate`,children:d?.name||`Me`})]}),(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued font-bold uppercase tracking-wider`,children:`Owner · This Instance`})]}),i.peers.length===0?(0,S.jsxs)(`div`,{className:`p-4 border border-dashed border-shogun-border rounded-xl text-center`,children:[(0,S.jsx)(de,{className:`w-5 h-5 text-shogun-subdued mx-auto mb-2 opacity-30`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued`,children:`No peers yet. Invite a remote Shogun.`})]}):i.peers.map(e=>(0,S.jsxs)(`div`,{className:`p-3 rounded-xl border border-shogun-border bg-shogun-card group`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,S.jsx)(`span`,{className:m(`w-2 h-2 rounded-full flex-shrink-0`,Se[e.status]||`bg-shogun-subdued`)}),(0,S.jsx)(`p`,{className:`text-xs font-bold text-shogun-text truncate`,children:e.peer_name})]}),(0,S.jsx)(`button`,{onClick:()=>mt(e.id),className:`opacity-0 group-hover:opacity-100 p-1 text-shogun-subdued hover:text-red-400 transition-all`,children:(0,S.jsx)(c,{className:`w-3 h-3`})})]}),(0,S.jsxs)(`p`,{className:`text-[8px] text-shogun-subdued font-bold uppercase tracking-wider mt-1`,children:[e.role,` · `,e.status]}),(0,S.jsx)(`p`,{className:`text-[8px] text-shogun-subdued/60 font-mono truncate mt-1`,children:e.peer_url}),e.last_seen_at&&(0,S.jsxs)(`p`,{className:`text-[8px] text-shogun-subdued/50 mt-1`,children:[`seen `,we(e.last_seen_at)]})]},e.id))]}),(0,S.jsxs)(`div`,{className:`flex flex-col overflow-hidden border-r border-shogun-border`,children:[(0,S.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-3`,children:[i.messages.length===0&&(0,S.jsx)(`div`,{className:`p-8 text-center text-shogun-subdued text-xs`,children:`No messages yet. Post the first one.`}),i.messages.map(e=>{let t=E[e.message_type]||E.update,n=e.from_peer_url===yt||e.from_agent_id===`system`;return e.message_type===`system`?(0,S.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,S.jsx)(`div`,{className:`flex-1 h-px bg-shogun-border`}),(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60 whitespace-nowrap px-2 font-mono italic`,dangerouslySetInnerHTML:{__html:e.content.replace(/\*\*(.+?)\*\*/g,`$1`).replace(/`(.+?)`/g,`$1`)}}),(0,S.jsx)(`div`,{className:`flex-1 h-px bg-shogun-border`})]},e.id):(0,S.jsxs)(`div`,{className:m(`flex gap-3`,n?`flex-row-reverse`:`flex-row`),children:[(0,S.jsx)(`div`,{className:m(`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 text-xs font-bold`,n?`bg-indigo-500/20 text-indigo-400`:`bg-shogun-card border border-shogun-border text-shogun-subdued`),children:(e.from_name||`?`).charAt(0).toUpperCase()}),(0,S.jsxs)(`div`,{className:m(`max-w-[75%] space-y-1`,n?`items-end`:`items-start`,`flex flex-col`),children:[(0,S.jsxs)(`div`,{className:m(`flex items-center gap-2`,n?`flex-row-reverse`:`flex-row`),children:[(0,S.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text`,children:e.from_name}),(0,S.jsx)(`span`,{className:m(`text-[8px] font-bold px-1.5 py-0.5 rounded border uppercase tracking-widest`,t.color),children:t.label}),(0,S.jsx)(`span`,{className:`text-[9px] text-shogun-subdued/60 font-mono`,children:Ce(e.created_at)})]}),(0,S.jsx)(`div`,{className:m(`px-4 py-2.5 rounded-2xl text-sm leading-relaxed`,n?`bg-indigo-600 text-white rounded-tr-sm`:`bg-shogun-card border border-shogun-border text-shogun-text rounded-tl-sm`),children:(0,S.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.content.replace(/\*\*(.+?)\*\*/g,`$1`).replace(/`(.+?)`/g,`$1`)}})}),n&&e.delivery_status!==`local`&&(0,S.jsx)(`span`,{className:m(`text-[8px] font-mono`,e.delivery_status===`delivered`?`text-green-400`:e.delivery_status===`failed`?`text-red-400`:`text-shogun-subdued`),children:e.delivery_status})]})]},e.id)}),(0,S.jsx)(`div`,{ref:lt})]}),(0,S.jsxs)(`div`,{className:`p-4 border-t border-shogun-border bg-shogun-card space-y-3 flex-shrink-0`,children:[(0,S.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[`update`,`proposal`,`task`,`plan_revision`,`approval`,`signal`].map(e=>{let t=E[e];return(0,S.jsx)(`button`,{onClick:()=>Re(e),className:m(`text-[9px] px-2.5 py-1 rounded border font-bold uppercase tracking-widest transition-all`,L===e?t.color:`text-shogun-subdued border-shogun-border hover:border-shogun-text`),children:t.label},e)})}),(0,S.jsxs)(`div`,{className:`flex gap-2`,children:[(0,S.jsx)(`textarea`,{value:I,onChange:e=>Le(e.target.value),placeholder:`Post a ${E[L]?.label||`message`}...`,rows:2,className:`flex-1 bg-[#050508] border border-shogun-border rounded-xl px-4 py-2.5 text-sm focus:border-indigo-500 outline-none transition-all resize-none`,onKeyDown:e=>{e.key===`Enter`&&e.ctrlKey&&ft()}}),(0,S.jsx)(`button`,{onClick:ft,disabled:ze||!I.trim(),className:`px-4 bg-indigo-600 hover:bg-indigo-500 text-white rounded-xl transition-all disabled:opacity-40 flex items-center gap-2`,children:ze?(0,S.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,S.jsx)(le,{className:`w-4 h-4`})})]}),(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50`,children:`Ctrl+Enter to send · Messages are fanned out to all active peers`})]})]}),(0,S.jsxs)(`div`,{className:`overflow-y-auto flex flex-col`,children:[(0,S.jsxs)(`div`,{className:`p-4 border-b border-shogun-border flex items-center justify-between flex-shrink-0`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(ae,{className:`w-4 h-4 text-shogun-gold`}),(0,S.jsx)(`p`,{className:`text-[10px] font-bold text-shogun-text uppercase tracking-widest`,children:`Shared Document`}),i.document_version>0&&(0,S.jsxs)(`span`,{className:`text-[8px] font-mono text-shogun-subdued/60`,children:[`v`,i.document_version]})]}),Be?(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(`button`,{onClick:()=>z(!1),className:`p-1.5 text-shogun-subdued hover:text-shogun-text transition-colors`,children:(0,S.jsx)(f,{className:`w-3.5 h-3.5`})}),(0,S.jsxs)(`button`,{onClick:pt,disabled:He,className:`px-3 py-1.5 bg-shogun-gold hover:bg-shogun-gold/90 text-black text-[10px] font-bold uppercase tracking-widest rounded-lg transition-all flex items-center gap-1.5`,children:[He?(0,S.jsx)(p,{className:`w-3 h-3 animate-spin`}):(0,S.jsx)(ce,{className:`w-3 h-3`}),`Save`]})]}):(0,S.jsx)(`button`,{onClick:()=>{z(!0),B(i.shared_document||``)},className:`p-1.5 text-shogun-subdued hover:text-shogun-gold transition-colors rounded-lg hover:bg-shogun-card`,children:(0,S.jsx)(oe,{className:`w-3.5 h-3.5`})})]}),Be?(0,S.jsx)(`textarea`,{value:Ve,onChange:e=>B(e.target.value),className:`flex-1 bg-[#050508] text-sm text-shogun-text font-mono p-4 outline-none resize-none border-none`,placeholder:`# Document Title + +Write your shared plan here...`}):(0,S.jsx)(`div`,{className:`flex-1 p-4 overflow-y-auto`,children:i.shared_document?(0,S.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none text-shogun-text text-sm leading-relaxed space-y-3`,dangerouslySetInnerHTML:{__html:i.shared_document.replace(/^# (.+)$/gm,`

    $1

    `).replace(/^## (.+)$/gm,`

    $2

    `).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/`(.+?)`/g,`$1`).replace(/\n/g,`
    `)}}):(0,S.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-center`,children:[(0,S.jsx)(fe,{className:`w-8 h-8 text-shogun-subdued opacity-30`}),(0,S.jsxs)(`p`,{className:`text-xs text-shogun-subdued`,children:[`No document yet.`,(0,S.jsx)(`br`,{}),`Click the edit icon to start writing.`]})]})})]})]}),je&&(0,S.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/80 backdrop-blur-sm animate-in fade-in duration-200`,children:(0,S.jsxs)(`div`,{className:`bg-shogun-bg border border-shogun-border w-full max-w-md rounded-2xl shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,S.jsxs)(`div`,{className:`p-6 border-b border-shogun-border bg-shogun-card flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`w-10 h-10 rounded-xl bg-indigo-500/10 border border-indigo-500/20 flex items-center justify-center`,children:(0,S.jsx)(l,{className:`w-5 h-5 text-indigo-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`text-base font-bold text-shogun-text`,children:`Invite Peer`}),(0,S.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:`Remote Shogun A2A URL`})]})]}),(0,S.jsx)(`button`,{onClick:()=>A(!1),className:`p-2 hover:bg-[#0a0e1a] rounded-lg transition-colors`,children:(0,S.jsx)(f,{className:`w-5 h-5 text-shogun-subdued`})})]}),(0,S.jsxs)(`div`,{className:`p-6 space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Peer Endpoint URL *`}),(0,S.jsx)(`input`,{autoFocus:!0,value:j,onChange:e=>Me(e.target.value),placeholder:`http://remote-shogun:8000/api/v1/a2a/inbound`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all font-mono`})]}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Display Name (optional)`}),(0,S.jsx)(`input`,{value:Pe,onChange:e=>Fe(e.target.value),placeholder:`Their Shogun's name...`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all`})]}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:`Infrastructure Admin Token`}),(0,S.jsx)(`input`,{type:`password`,autoComplete:`off`,value:M,onChange:e=>{let t=e.target.value;Ne(t),_e(t)},placeholder:`Required by Shogun Server mode`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all font-mono`}),(0,S.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/60`,children:`Stored only for this browser tab session.`})]}),P&&(0,S.jsx)(`div`,{className:m(`p-3 rounded-lg border text-xs`,P.type===`success`?`bg-green-500/10 border-green-500/30 text-green-400`:`bg-red-500/10 border-red-500/30 text-red-400`),children:P.text}),(0,S.jsxs)(`div`,{className:`p-3 bg-indigo-500/5 border border-indigo-500/20 rounded-xl text-[10px] text-shogun-subdued space-y-1`,children:[(0,S.jsx)(`p`,{className:`font-bold text-indigo-400`,children:`How it works:`}),(0,S.jsx)(`p`,{children:`• We ping their endpoint to verify it's reachable`}),(0,S.jsx)(`p`,{children:`• A signed invitation is sent using HMAC-SHA256`}),(0,S.jsx)(`p`,{children:`• They can then post messages back to this workspace`})]}),(0,S.jsxs)(`div`,{className:`flex gap-3`,children:[(0,S.jsx)(`button`,{onClick:()=>A(!1),className:`flex-1 py-3 bg-shogun-card border border-shogun-border text-shogun-subdued font-bold text-xs uppercase tracking-widest rounded-xl hover:border-shogun-text transition-colors`,children:`Cancel`}),(0,S.jsxs)(`button`,{onClick:dt,disabled:N||!j.trim(),className:`flex-1 py-3 bg-indigo-600 hover:bg-indigo-500 text-white font-bold text-xs uppercase tracking-widest rounded-xl transition-all disabled:opacity-40 flex items-center justify-center gap-2`,children:[N?(0,S.jsx)(p,{className:`w-4 h-4 animate-spin`}):(0,S.jsx)(le,{className:`w-4 h-4`}),N?`Sending...`:`Send Invitation`]})]})]})]})})]})}export{D as Nexus}; \ No newline at end of file diff --git a/frontend/dist/assets/SamuraiNetwork-CeC0ZEUc.js b/frontend/dist/assets/SamuraiNetwork-CeC0ZEUc.js deleted file mode 100644 index 1230835..0000000 --- a/frontend/dist/assets/SamuraiNetwork-CeC0ZEUc.js +++ /dev/null @@ -1,17 +0,0 @@ -import{i as e,n as t,o as n,r,t as i}from"./jsx-runtime-DmifIpYY.js";import{t as a}from"./react-dom-DWobv3jf.js";import{t as o}from"./preload-helper-D4M6sveU.js";import{t as s}from"./calendar-DL2fCMC-.js";import{t as c}from"./camera-DjFKI4Th.js";import{t as l}from"./chevron-down-ZviArC66.js";import{t as u}from"./chevron-left-BFAWv4As.js";import{t as d}from"./chevron-up-NHCFdinU.js";import{t as f}from"./circle-check-D9mntLsp.js";import{t as p}from"./circle-x-dN_LIrKM.js";import{t as m}from"./clock-B8iyCT3M.js";import{t as h}from"./code-xml-CCdcZbQg.js";import{t as g}from"./copy-B91lRfaY.js";import{t as _}from"./download-OoiqiOHD.js";import{t as v}from"./eye-DuX8zHAU.js";import{t as y}from"./file-spreadsheet-CsZ2n5Og.js";import{t as b}from"./file-text-Db8l8y7y.js";import{t as x}from"./folder-open-C_e4r6rd.js";import{t as S}from"./git-branch-eFNiJwrC.js";import{t as C}from"./globe-CSe1LLSr.js";import{t as w}from"./history-odxnpvgx.js";import{t as T}from"./info-CXnsqgVr.js";import{t as E}from"./layers-4dQLphXM.js";import{t as D}from"./layout-grid-CJTAEcGa.js";import{t as O}from"./link-DhxsOVpy.js";import{t as k}from"./loader-circle-yHzGFbgr.js";import{t as A}from"./mail-CjEwmRbK.js";import{t as j}from"./message-square-D4G-UYnF.js";import{t as M}from"./network-RTAno7O_.js";import{t as N}from"./pause-kViKpNvP.js";import{n as P,t as F}from"./route-B0unASBQ.js";import{t as I}from"./plus-DFW_DMbT.js";import{t as L}from"./power-BmbVankB.js";import{t as R}from"./refresh-cw-CCrS0Omg.js";import{t as ee}from"./rotate-ccw-DsOLVoka.js";import{t as z}from"./save-CJWuwqGS.js";import{t as te}from"./search-CCF8DUSp.js";import{t as B}from"./settings-DYFQa-lL.js";import{t as ne}from"./shield-check-4WxAMs16.js";import{t as V}from"./shield-B_MY4jWU.js";import{t as H}from"./sparkles-DddBjN-5.js";import{t as re}from"./trash-2-Cid5DKqF.js";import{t as ie}from"./triangle-alert-BwzZbklP.js";import{t as ae}from"./upload-D8ecl32P.js";import{t as oe}from"./users-D7R1ctQe.js";import{t as se}from"./x-Bu7rztmN.js";import{t as ce}from"./zap-BMpqZS6N.js";import{t as U}from"./utils-wrb6h48Y.js";import{r as le}from"./i18n-FxgwkwP0.js";import{t as W}from"./axios-BPyV2soB.js";var ue=t(`bookmark-plus`,[[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M15 10H9`,key:`o6yqo3`}],[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),de=t(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),fe=t(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),pe=t(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),me=t(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),he=t(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),ge=t(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),_e=t(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),G=n(r(),1),ve=n(a()),K=i();function q(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n{}};function ye(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}be.prototype=ye.prototype={constructor:be,on:function(e,t){var n=this._,r=xe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),we.hasOwnProperty(t)?{space:we[t],local:e}:e}function Ee(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function De(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Oe(e){var t=Te(e);return(t.local?De:Ee)(t)}function ke(){}function Ae(e){return e==null?ke:function(){return this.querySelector(e)}}function je(e){typeof e!=`function`&&(e=Ae(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function st(e){e||=ct;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function lt(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ut(){return Array.from(this)}function dt(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Ct:typeof t==`function`?Tt:wt)(e,t,n??``)):Dt(this.node(),e)}function Dt(e,t){return e.style.getPropertyValue(t)||St(e).getComputedStyle(e,null).getPropertyValue(t)}function Ot(e){return function(){delete this[e]}}function kt(e,t){return function(){this[e]=t}}function At(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function jt(e,t){return arguments.length>1?this.each((t==null?Ot:typeof t==`function`?At:kt)(e,t)):this.node()[e]}function Mt(e){return e.trim().split(/^|\s+/)}function Nt(e){return e.classList||new Pt(e)}function Pt(e){this._node=e,this._names=Mt(e.getAttribute(`class`)||``)}Pt.prototype={add:function(e){this._names.indexOf(e)<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 Ft(e,t){for(var n=Nt(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function dn(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function Nn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){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:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Nn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Pn(e){return!e.ctrlKey&&!e.button}function Fn(){return this.parentNode}function In(e,t){return t??{x:e.x,y:e.y}}function Ln(){return navigator.maxTouchPoints||`ontouchstart`in this}function Rn(){var e=Pn,t=Fn,n=In,r=Ln,i={},a=ye(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,En).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(Cn(n.view).on(`mousemove.drag`,m,Dn).on(`mouseup.drag`,h,Dn),An(n.view),On(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(kn(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){Cn(e.view).on(`mousemove.drag mouseup.drag`,null),jn(e.view,l),kn(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?sr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?sr(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=Jn.exec(e))?new ur(t[1],t[2],t[3],1):(t=Yn.exec(e))?new ur(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Xn.exec(e))?sr(t[1],t[2],t[3],t[4]):(t=Zn.exec(e))?sr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Qn.exec(e))?_r(t[1],t[2]/100,t[3]/100,1):(t=$n.exec(e))?_r(t[1],t[2]/100,t[3]/100,t[4]):er.hasOwnProperty(e)?or(er[e]):e===`transparent`?new ur(NaN,NaN,NaN,0):null}function or(e){return new ur(e>>16&255,e>>8&255,e&255,1)}function sr(e,t,n,r){return r<=0&&(e=t=n=NaN),new ur(e,t,n,r)}function cr(e){return e instanceof Vn||(e=ar(e)),e?(e=e.rgb(),new ur(e.r,e.g,e.b,e.opacity)):new ur}function lr(e,t,n,r){return arguments.length===1?cr(e):new ur(e,t,n,r??1)}function ur(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}zn(ur,lr,Bn(Vn,{brighter(e){return e=e==null?Un:Un**+e,new ur(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Hn:Hn**+e,new ur(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ur(hr(this.r),hr(this.g),hr(this.b),mr(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:dr,formatHex:dr,formatHex8:fr,formatRgb:pr,toString:pr}));function dr(){return`#${gr(this.r)}${gr(this.g)}${gr(this.b)}`}function fr(){return`#${gr(this.r)}${gr(this.g)}${gr(this.b)}${gr((isNaN(this.opacity)?1:this.opacity)*255)}`}function pr(){let e=mr(this.opacity);return`${e===1?`rgb(`:`rgba(`}${hr(this.r)}, ${hr(this.g)}, ${hr(this.b)}${e===1?`)`:`, ${e})`}`}function mr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function hr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function gr(e){return e=hr(e),(e<16?`0`:``)+e.toString(16)}function _r(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new br(e,t,n,r)}function vr(e){if(e instanceof br)return new br(e.h,e.s,e.l,e.opacity);if(e instanceof Vn||(e=ar(e)),!e)return new br;if(e instanceof br)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new br(o,s,c,e.opacity)}function yr(e,t,n,r){return arguments.length===1?vr(e):new br(e,t,n,r??1)}function br(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}zn(br,yr,Bn(Vn,{brighter(e){return e=e==null?Un:Un**+e,new br(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Hn:Hn**+e,new br(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,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new ur(Cr(e>=240?e-240:e+120,i,r),Cr(e,i,r),Cr(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new br(xr(this.h),Sr(this.s),Sr(this.l),mr(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(){let e=mr(this.opacity);return`${e===1?`hsl(`:`hsla(`}${xr(this.h)}, ${Sr(this.s)*100}%, ${Sr(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function xr(e){return e=(e||0)%360,e<0?e+360:e}function Sr(e){return Math.max(0,Math.min(1,e||0))}function Cr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var wr=e=>()=>e;function Tr(e,t){return function(n){return e+n*t}}function Er(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Dr(e){return(e=+e)==1?Or:function(t,n){return n-t?Er(t,n,e):wr(isNaN(t)?n:t)}}function Or(e,t){var n=t-e;return n?Tr(e,n):wr(isNaN(e)?t:e)}var kr=(function e(t){var n=Dr(t);function r(e,t){var r=n((e=lr(e)).r,(t=lr(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Or(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Ar(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Pr(r,i)})),n=Lr.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Pr(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Pr(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Pr(e,n)},{i:s-2,x:Pr(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--ni}function vi(){li=(ci=di.now())+ui,ni=ri=0;try{_i()}finally{ni=0,bi(),li=0}}function yi(){var e=di.now(),t=e-ci;t>ai&&(ui-=t,ci=e)}function bi(){for(var e,t=oi,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:oi=n);si=e,xi(r)}function xi(e){ni||(ri&&=clearTimeout(ri),e-li>24?(e<1/0&&(ri=setTimeout(vi,e-di.now()-ui)),ii&&=clearInterval(ii)):(ii||=(ci=di.now(),setInterval(yi,ai)),ni=1,fi(vi)))}function Si(e,t,n){var r=new hi;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var Ci=ye(`start`,`end`,`cancel`,`interrupt`),wi=[];function Ti(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ki(e,n,{name:t,index:r,group:i,on:Ci,tween:wi,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function Ei(e,t){var n=Oi(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Di(e,t){var n=Oi(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Oi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function ki(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=gi(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return Si(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function ji(e){return this.each(function(){Ai(this,e)})}function Mi(e,t){var n,r;return function(){var i=Di(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o=0&&(e=e.slice(0,t)),!e||e===`start`})}function ca(e,t,n){var r,i,a=sa(t)?Ei:Di;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function la(e,t){var n=this._id;return arguments.length<2?Oi(this.node(),n).on.on(e):this.each(ca(n,e,t))}function ua(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function da(){return this.on(`end.remove`,ua(this._id))}function fa(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ae(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function Ua(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:r,enumerable:!0,configurable:!0},_:{value:i}})}function Wa(e,t,n){this.k=e,this.x=t,this.y=n}Wa.prototype={constructor:Wa,scale:function(e){return e===1?this:new Wa(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Wa(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 Ga=new Wa(1,0,0);Ka.prototype=Wa.prototype;function Ka(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ga;return e.__zoom}function qa(e){e.stopImmediatePropagation()}function Ja(e){e.preventDefault(),e.stopImmediatePropagation()}function Ya(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Xa(){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 Za(){return this.__zoom||Ga}function Qa(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $a(){return navigator.maxTouchPoints||`ontouchstart`in this}function eo(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function to(){var e=Ya,t=Xa,n=eo,r=Qa,i=$a,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=ti,l=ye(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Za).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Za),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Ga.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Wa(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Wa(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Wa(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=Cn(this.that).datum();l.call(e,this.that,new Ua(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Tn(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Ai(this),s.start();Ja(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=Cn(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Tn(t,i),l=t.clientX,u=t.clientY;An(t.view),qa(t),a.mouse=[c,this.__zoom.invert(c)],Ai(this),a.start();function d(e){if(Ja(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Tn(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),jn(e.view,a.moved),Ja(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Tn(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Ja(r),s>0?Cn(this).transition().duration(s).call(x,d,c,r):Cn(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(qa(t),s=0;s`[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,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,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.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},ro=[[-1/0,-1/0],[1/0,1/0]],io=[`Enter`,` `,`Escape`],ao={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},oo;(function(e){e.Strict=`strict`,e.Loose=`loose`})(oo||={});var so;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(so||={});var co;(function(e){e.Partial=`partial`,e.Full=`full`})(co||={});var lo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},uo;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(uo||={});var fo;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(fo||={});var Y;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Y||={});var po={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function mo(e){return e===null?null:e?`valid`:`invalid`}var ho=e=>`id`in e&&`source`in e&&`target`in e,go=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),_o=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),vo=(e,t=[0,0])=>{let{width:n,height:r}=Zo(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},yo=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:Po(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):_o(n)?n:t.nodeLookup.get(n.id)),Mo(e,i?Io(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),bo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Mo(n,Io(e)),r=!0)}),r?Po(n):{x:0,y:0,width:0,height:0}},xo=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...Uo(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=Ro(s,Fo(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},So=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function Co(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function wo({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=Jo(bo(Co(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function To({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,no.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&Xo(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Xo(d)?Oo(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,no.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function Eo({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=So(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var Do=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Oo=(e={x:0,y:0},t,n)=>({x:Do(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Do(e.y,t[0][1],t[1][1]-(n?.height??0))});function ko(e,t,n){let{width:r,height:i}=Zo(n),{x:a,y:o}=n.internals.positionAbsolute;return Oo(e,[[a,o],[a+r,o+i]],t)}var Ao=(e,t,n)=>en?-Do(Math.abs(e-n),1,t)/t:0,jo=(e,t,n=15,r=40)=>[Ao(e.x,r,t.width-r)*n,Ao(e.y,r,t.height-r)*n],Mo=(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)}),No=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Po=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Fo=(e,t=[0,0])=>{let{x:n,y:r}=_o(e)?e.internals.positionAbsolute:vo(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Io=(e,t=[0,0])=>{let{x:n,y:r}=_o(e)?e.internals.positionAbsolute:vo(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Lo=(e,t)=>Po(Mo(No(e),No(t))),Ro=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},zo=e=>Bo(e.width)&&Bo(e.height)&&Bo(e.x)&&Bo(e.y),Bo=e=>!isNaN(e)&&isFinite(e),Vo=(e,t)=>{},Ho=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Uo=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Ho(s,o):s},Wo=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Go(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ko(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Go(e,n),i=Go(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Go(e.top??e.y??0,n),i=Go(e.bottom??e.y??0,n),a=Go(e.left??e.x??0,t),o=Go(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function qo(e,t,n,r,i,a){let{x:o,y:s}=Wo(e,[t,n,r]),{x:c,y:l}=Wo({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Jo=(e,t,n,r,i,a)=>{let o=Ko(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Do(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=qo(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},Yo=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Xo(e){return e!=null&&e!==`parent`}function Zo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Qo(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function $o(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function es(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function ts(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function ns(e){return{...ao,...e||{}}}function rs(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=ls(e),s=Uo({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Ho(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var is=e=>({width:e.offsetWidth,height:e.offsetHeight}),as=e=>e?.getRootNode?.()||window?.document,os=[`INPUT`,`SELECT`,`TEXTAREA`];function ss(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?os.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var cs=e=>`clientX`in e,ls=(e,t)=>{let n=cs(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},us=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...is(t)}})};function ds({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function fs(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ps({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Y.Left:return[t-fs(t-r,a),n];case Y.Right:return[t+fs(r-t,a),n];case Y.Top:return[t,n-fs(n-i,a)];case Y.Bottom:return[t,n+fs(i-n,a)]}}function ms({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top,curvature:o=.25}){let[s,c]=ps({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=ps({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=ds({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function hs({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n0}var vs=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ys=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),bs=(e,t,n={})=>{if(!e.source||!e.target)return no.error006(),t;let r=n.getEdgeId||vs,i;return i=ho(e)?{...e}:{...e,id:r(e)},ys(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))},xs=(e,t,n,r={shouldReplaceId:!0})=>{let{id:i,...a}=e;if(!t.source||!t.target)return no.error006(),n;if(!n.find(t=>t.id===e.id))return no.error007(i),n;let o=r.getEdgeId||vs,s={...a,id:r.shouldReplaceId?o(t):i,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(e=>e.id!==i).concat(s)};function Ss({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=hs({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Cs={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},ws=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.xMath.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Es({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:r=Y.Top,center:i,offset:a,stepPosition:o}){let s=Cs[t],c=Cs[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=ws({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=hs({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function Ds(e,t,n,r){let i=Math.min(Ts(e,t)/2,Ts(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.xe.id===t):e[0])||null}function Ps(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Fs(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Ps(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Is=1e3,Ls=10,Rs={nodeOrigin:[0,0],nodeExtent:ro,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},zs={...Rs,checkEquality:!0};function Bs(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Vs(e,t,n){let r=Bs(Rs,n);for(let n of e.values())if(n.parentId)Ks(n,e,t,r);else{let e=Oo(vo(n,r.nodeOrigin),Xo(n.extent)?n.extent:r.nodeExtent,Zo(n));n.internals.positionAbsolute=e}}function Hs(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function Us(e){return e===`manual`}function Ws(e,t,n,r={}){let i=Bs(zs,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!Us(i.zIndexMode)?Is:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Oo(vo(u,i.nodeOrigin),Xo(u.extent)?u.extent:i.nodeExtent,Zo(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Hs(u,e),z:qs(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Ks(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Gs(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ks(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Bs(Rs,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Gs(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Ls),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Js(e,u,o,s,a&&!Us(c)?Is:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function qs(e,t,n){let r=Bo(e.zIndex)?e.zIndex:0;return Us(n)?r:r+(e.selected?t:0)}function Js(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Zo(e),l=vo(e,n),u=Xo(e.extent)?Oo(l,e.extent,c):l,d=Oo({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=ko(d,c,t));let f=qs(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function Ys(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Lo(a.get(n.parentId)?.expandedRect??Fo(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Zo(a),l=a.origin??r,u=t.x0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width0){let e=Ys(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Zs({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function Qs(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function $s(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Qs(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Qs(`target`,s,c,e,i,o),t.set(r.id,r)}}function ec(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:ec(n,t):!1}function tc(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function nc(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!ec(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function rc({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function ic({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Ho(a,t);return{x:o.x-a.x,y:o.y-a.y}}function ac({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=Cn(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?No(bo(s)):null,x=v&&l?ic({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Ho(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=To({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=rc({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=jo(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=rs(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=nc(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=rc({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=Rn().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=rs(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=ls(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=rs(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=ls(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=ls(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=rc({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!tc(t,`.${g}`,v))&&(!_||tc(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function oc(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Ro(i,Fo(e))>0&&r.push(e);return r}var sc=250;function cc(e,t,n,r){let i=[],a=1/0,o=oc(e,n,t+sc);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Ms(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function lc(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Ms(o,c,c.position,!0)}:c}function uc(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function dc(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var fc=()=>!0;function pc(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=fc,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=as(e.target),E=0,D,{x:O,y:k}=ls(e),A=uc(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=lc(i,A,r,c,t);if(!N)return;let P=ls(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=jo(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ee)}let z={...N,nodeId:i,type:A,position:N.position},te=c.get(i),B={inProgress:!0,isValid:null,from:Ms(te,z,Y.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:te,to:P,toHandle:null,toPosition:po[z.position],toNode:null,pointer:P};function ne(){M=!0,y(B),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ne();function V(e){if(!M){let{x:t,y:n}=ls(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ne()}if(!x()||!z){H(e);return}let a=b();P=ls(e,j),D=cc(Uo(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=mc(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=dc(!!D,s.isValid);let u=c.get(i),f=u?Ms(u,z,Y.Left,!0):B.from,p={...B,from:f,isValid:L,to:s.toHandle&&L?Wo({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:po[z.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),B=p}function H(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=B,r={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,V),T.removeEventListener(`mouseup`,H),T.removeEventListener(`touchmove`,V),T.removeEventListener(`touchend`,H)}}T.addEventListener(`mousemove`,V),T.addEventListener(`mouseup`,H),T.addEventListener(`touchmove`,V),T.addEventListener(`touchend`,H)}function mc(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=fc,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=ls(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=uc(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===oo.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=lc(t,e,a,u,n,!0)}return _}var hc={onPointerDown:pc,isValid:mc};function gc({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=Cn(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&Yo()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=to().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:Tn}}var _c=e=>({x:e.x,y:e.y,zoom:e.k}),vc=({x:e,y:t,zoom:n})=>Ga.translate(e,t).scale(n),yc=(e,t)=>e.target.closest(`.${t}`),bc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),xc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Sc=(e,t=0,n=xc,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Cc=e=>{let t=e.ctrlKey&&Yo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function wc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(yc(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=Tn(u),t=d*2**Cc(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===so.Vertical?0:u.deltaX*f,m=i===so.Horizontal?0:u.deltaY*f;!Yo()&&u.shiftKey&&i!==so.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=_c(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function Tc({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=yc(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ec({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=_c(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Dc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&bc(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,_c(a.transform))}}function Oc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&bc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=_c(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function kc({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(yc(d,`${l}-flow__node`)||yc(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||yc(d,s)&&m||yc(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function Ac({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=to().scaleExtent([t,n]).translateExtent(r),f=Cn(e).call(d);v({x:i.x,y:i.y,zoom:Do(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(Cc);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Vr:ti).transform(Sc(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Bo(E)||E<0?0:E);let k=O?wc({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Tc({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=Ec({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=Dc({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=Oc({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=kc({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(A),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=vc(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=vc(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=vc(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?Ka(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Vr:ti).scaleTo(Sc(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?Vr:ti).scaleBy(Sc(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Bo(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var jc;(function(e){e.Line=`line`,e.Handle=`handle`})(jc||={});function Mc({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function Nc(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Pc(e,t){return Math.max(0,t-e)}function Fc(e,t){return Math.max(0,e-t)}function Ic(e,t,n){return Math.max(0,t-e,e-n)}function Lc(e,t){return e?!t:t}function Rc(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Ic(E,h,g),j=Ic(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Pc(y+w+O,o[0][0]):!c&&w>0&&(e=Fc(y+E+O,o[1][0])),l&&T<0?t=Pc(b+T+k,o[0][1]):!l&&T>0&&(t=Fc(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=Fc(y+w,s[0][0]):!c&&w<0&&(e=Pc(y+E,s[1][0])),l&&T>0?t=Fc(b+T,s[0][1]):!l&&T<0&&(t=Pc(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Ic(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?Fc(b+k+E/C,o[1][1])*C:Pc(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Pc(b+E/C,s[1][1])*C:Fc(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Ic(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?Fc(y+D*C+O,o[1][0])/C:Pc(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Pc(y+D*C,s[1][0])/C:Fc(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Lc(c,l)?-w:w)/C:w=(Lc(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var zc={width:0,height:0,x:0,y:0},Bc={...zc,pointerX:0,pointerY:0,aspectRatio:1};function Vc(e){return[[0,0],[e.measured.width,e.measured.height]]}function Hc(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Uc({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=Cn(e),o={controlDirection:Nc(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...zc},h={...Bc};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Nc(e)};let g,_=null,v=[],y,b,x,S=!1,C=Rn().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=rs(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?Vc(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Hc(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=rs(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=Rc(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var Wc=e((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Gc=e(((e,t)=>{t.exports=Wc()})),Kc=e((e=>{var t=r(),n=Gc();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),qc=n(e(((e,t)=>{t.exports=Kc()}))(),1),Jc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Yc=e=>e?Jc(e):Jc,{useDebugValue:Xc}=G.default,{useSyncExternalStoreWithSelector:Zc}=qc.default,Qc=e=>e;function $c(e,t=Qc,n){let r=Zc(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Xc(r),r}var el=(e,t)=>{let n=Yc(e),r=(e,r=t)=>$c(n,e,r);return Object.assign(r,n),r},tl=(e,t)=>e?el(e,t):el;function X(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var nl=(0,G.createContext)(null),rl=nl.Provider,il=no.error001();function Z(e,t){let n=(0,G.useContext)(nl);if(n===null)throw Error(il);return $c(n,e,t)}function Q(){let e=(0,G.useContext)(nl);if(e===null)throw Error(il);return(0,G.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var al={display:`none`},ol={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},sl=`react-flow__node-desc`,cl=`react-flow__edge-desc`,ll=`react-flow__aria-live`,ul=e=>e.ariaLiveMessage,dl=e=>e.ariaLabelConfig;function fl({rfId:e}){let t=Z(ul);return(0,K.jsx)(`div`,{id:`${ll}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:ol,children:t})}function pl({rfId:e,disableKeyboardA11y:t}){let n=Z(dl);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{id:`${sl}-${e}`,style:al,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,K.jsx)(`div`,{id:`${cl}-${e}`,style:al,children:n[`edge.a11yDescription.default`]}),!t&&(0,K.jsx)(fl,{rfId:e})]})}var ml=(0,G.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,K.jsx)(`div`,{className:q([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));ml.displayName=`Panel`;function hl({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,K.jsx)(ml,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,K.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var gl=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},_l=e=>e.id;function vl(e,t){return X(e.selectedNodes.map(_l),t.selectedNodes.map(_l))&&X(e.selectedEdges.map(_l),t.selectedEdges.map(_l))}function yl({onSelectionChange:e}){let t=Q(),{selectedNodes:n,selectedEdges:r}=Z(gl,vl);return(0,G.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var bl=e=>!!e.onSelectionChangeHandlers;function xl({onSelectionChange:e}){let t=Z(bl);return e||t?(0,K.jsx)(yl,{onSelectionChange:e}):null}var Sl=typeof window<`u`?G.useLayoutEffect:G.useEffect,Cl=[0,0],wl={x:0,y:0,zoom:1},Tl=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],El=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Dl={translateExtent:ro,nodeOrigin:Cl,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ol(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Z(El,X),l=Q();Sl(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Dl,s()}),[]);let u=(0,G.useRef)(Dl);return Sl(()=>{for(let s of Tl){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:ns(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Tl.map(t=>e[t])),null}function kl(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Al(e){let[t,n]=(0,G.useState)(e===`system`?null:e);return(0,G.useEffect)(()=>{if(e!==`system`){n(e);return}let t=kl(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?kl()?.matches?`dark`:`light`:t}var jl=typeof document<`u`?document:null;function Ml(e=null,t={target:jl,actInsideInputWithModifier:!0}){let[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(!1),a=(0,G.useRef)(new Set([])),[o,s]=(0,G.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,` -`).replace(` - -`,` -+`).split(` -`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,G.useEffect)(()=>{let n=t?.target??jl,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&ss(e))return!1;let n=Pl(e.code,s);if(a.current.add(e[n]),Nl(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Pl(e.code,s);Nl(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Nl(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Pl(e,t){return t.includes(e)?`code`:`key`}var Fl=()=>{let e=Q();return(0,G.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=Jo(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Uo(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Wo(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Il(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Ll(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Ll(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function Rl(e,t){return Il(e,t)}function zl(e,t){return Il(e,t)}function Bl(e,t){return{id:e,type:`select`,selected:t}}function Vl(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(Bl(a.id,e)))}return r}function Hl({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function Ul(e){return{id:e.id,type:`remove`}}var Wl=e=>go(e),Gl=e=>ho(e);function Kl(e){return(0,G.forwardRef)(e)}function ql(e){let[t,n]=(0,G.useState)(BigInt(0)),[r]=(0,G.useState)(()=>Jl(()=>n(e=>e+BigInt(1))));return Sl(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Jl(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Yl=(0,G.createContext)(null);function Xl({children:e}){let t=Q(),n=ql((0,G.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Hl({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=ql((0,G.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Hl({items:s,lookup:o}))},[])),i=(0,G.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,K.jsx)(Yl.Provider,{value:i,children:e})}function Zl(){let e=(0,G.useContext)(Yl);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var Ql=e=>!!e.panZoom;function $l(){let e=Fl(),t=Q(),n=Zl(),r=Z(Ql),i=(0,G.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Wl(e)?e:n.get(e.id),a=i.parentId?$o(i.position,i.measured,i.parentId,n,r):i.position;return Fo({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Wl(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Gl(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await Eo({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Ul);o?.(f),c(e)}if(m){let e=d.map(Ul);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=zo(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=Fo(s?r:a),l=Ro(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=zo(e)?e:a(e);if(!r)return!1;let i=Ro(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return yo(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??ts();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,G.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var eu=e=>e.selected,tu=typeof window<`u`?window:void 0;function nu({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=Q(),{deleteElements:r}=$l(),i=Ml(e,{actInsideInputWithModifier:!1}),a=Ml(t,{target:tu});(0,G.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(eu),edges:e.filter(eu)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,G.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function ru(e){let t=Q();(0,G.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=is(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,no.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var iu={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},au=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function ou({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=so.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=Q(),S=(0,G.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=Z(au,X),E=Ml(f),D=(0,G.useRef)();ru(S);let O=(0,G.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,G.useEffect)(()=>{if(S.current){D.current=Ac({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,G.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,K.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:iu,children:m})}var su=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function cu(){let{userSelectionActive:e,userSelectionRect:t}=Z(su,X);return e&&t?(0,K.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var lu=(e,t)=>n=>{n.target===t.current&&e?.(n)},uu=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function du({isSelecting:e,selectionKeyPressed:t,selectionMode:n=co.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:m}){let h=Q(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=Z(uu,X),b=_&&(e||g),x=(0,G.useRef)(null),S=(0,G.useRef)(),C=(0,G.useRef)(new Set),w=(0,G.useRef)(new Set),T=(0,G.useRef)(!1),E=e=>{if(T.current||y){T.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},D=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},O=u?e=>u(e):void 0;return(0,K.jsxs)(`div`,{className:q([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:lu(E,x),onContextMenu:lu(D,x),onWheel:lu(O,x),onPointerEnter:b?void 0:d,onPointerMove:b?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:c,connectionLookup:l,triggerNodeChanges:u,triggerEdgeChanges:d,defaultEdgeOptions:f,resetSelectedElements:p}=h.getState();if(!S.current||!r)return;let{x:m,y:g}=ls(e.nativeEvent,S.current),{startX:_,startY:v}=r;if(!T.current){let n=t?0:i;if(Math.hypot(m-_,g-v)<=n)return;p(),o?.(e)}T.current=!0;let y={startX:_,startY:v,x:m<_?m:_,y:ge.id)),w.current=new Set;let E=f?.selectable??!0;for(let e of C.current){let t=l.get(e);if(t)for(let{edgeId:e}of t.values()){let t=c.get(e);t&&(t.selectable??E)&&w.current.add(e)}}es(b,C.current)||u(Vl(s,C.current,!0)),es(x,w.current)||d(Vl(c,w.current)),h.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:b?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===x.current&&h.getState().userSelectionRect&&E?.(e),h.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(s?.(e),h.setState({nodesSelectionActive:C.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=h.getState();if(S.current=r?.getBoundingClientRect(),!S.current)return;let i=n.target===x.current;if(!i&&n.target.closest(`.nokey`)||!e||!(a&&i||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),T.current=!1;let{x:o,y:s}=ls(n.nativeEvent,S.current);h.setState({userSelectionRect:{width:0,height:0,startX:o,startY:s,x:o,y:s}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{T.current&&=(e.stopPropagation(),!1)}:void 0,onPointerLeave:p,ref:x,style:iu,children:[m,(0,K.jsx)(cu,{})]})}function fu({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,no.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function pu({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=Q(),[c,l]=(0,G.useState)(!1),u=(0,G.useRef)();return(0,G.useEffect)(()=>{u.current=ac({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{fu({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,G.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var mu=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function hu(){let e=Q();return(0,G.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=mu(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=Ho(t,i));let{position:a,positionAbsolute:s}=To({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var gu=(0,G.createContext)(null),_u=gu.Provider;gu.Consumer;var vu=()=>(0,G.useContext)(gu),yu=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),bu=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===oo.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function xu({type:e=`source`,position:t=Y.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=Q(),_=vu(),{connectOnClick:v,noPanClassName:y,rfId:b}=Z(yu,X),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Z(bu(_,m,e),X);_||g.getState().onError?.(`010`,no.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(bs(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=cs(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();hc.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,K.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:q([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=as(t.target),h=n||c,{connection:v,isValid:y}=hc.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var Su=(0,G.memo)(Kl(xu));function Cu({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return(0,K.jsxs)(K.Fragment,{children:[e?.label,(0,K.jsx)(Su,{type:`source`,position:n,isConnectable:t})]})}function wu({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:r=Y.Bottom}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Su,{type:`target`,position:n,isConnectable:t}),e?.label,(0,K.jsx)(Su,{type:`source`,position:r,isConnectable:t})]})}function Tu(){return null}function Eu({data:e,isConnectable:t,targetPosition:n=Y.Top}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Su,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Du={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ou={input:Cu,default:wu,output:Eu,group:Tu};function ku(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Au=e=>{let{width:t,height:n,x:r,y:i}=bo(e.nodeLookup,{filter:e=>!!e.selected});return{width:Bo(t)?t:null,height:Bo(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function ju({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=Q(),{width:i,height:a,transformString:o,userSelectionActive:s}=Z(Au,X),c=hu(),l=(0,G.useRef)(null);(0,G.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(pu({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,K.jsx)(`div`,{className:q([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,K.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Du,e.key)&&(e.preventDefault(),c({direction:Du[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Mu=typeof window<`u`?window:void 0,Nu=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Pu({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,preventScrolling:k,onSelectionContextMenu:A,noWheelClassName:j,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:P,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=Z(Nu,X),R=Ml(l,{target:Mu}),ee=Ml(h,{target:Mu}),z=ee||w,te=ee||b,B=u&&z!==!0,ne=R||L||B;return nu({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,K.jsx)(ou,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:te,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&z,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:B,children:(0,K.jsxs)(du,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:z,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:B,children:[e,I&&(0,K.jsx)(ju,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}Pu.displayName=`FlowRenderer`;var Fu=(0,G.memo)(Pu),Iu=e=>t=>e?xo(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Lu(e){return Z((0,G.useCallback)(Iu(e),[e]),X)}var Ru=e=>e.updateNodeInternals;function zu(){let e=Z(Ru),[t]=(0,G.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,G.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Bu({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=Q(),a=(0,G.useRef)(null),o=(0,G.useRef)(null),s=(0,G.useRef)(e.sourcePosition),c=(0,G.useRef)(e.targetPosition),l=(0,G.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,G.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,G.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,G.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Vu({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Z(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},X),S=y.type||`default`,C=g?.[S]||Ou[S];C===void 0&&(v?.(`003`,no.error003(S)),S=`default`,C=g?.default||Ou.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=Q(),k=Qo(y),A=Bu({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=pu({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=hu();if(y.hidden)return null;let N=Zo(y),P=ku(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,ee=a?e=>a(e,{...b.userNode}):void 0,z=o?e=>o(e,{...b.userNode}):void 0,te=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&fu({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},B=t=>{if(!(ss(t.nativeEvent)||m)){if(io.includes(t.key)&&T)fu({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Du,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:Du[t.key],factor:t.shiftKey?4:1})}}},ne=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(xo(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,K.jsx)(`div`,{className:q([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:ee,onClick:te,onDoubleClick:z,onKeyDown:D?B:void 0,tabIndex:D?0:void 0,onFocus:D?ne:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${sl}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,K.jsx)(_u,{value:e,children:(0,K.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var Hu=(0,G.memo)(Vu),Uu=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Wu(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=Z(Uu,X),o=Lu(e.onlyRenderVisibleElements),s=zu();return(0,K.jsx)(`div`,{className:`react-flow__nodes`,style:iu,children:o.map(o=>(0,K.jsx)(Hu,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}Wu.displayName=`NodeRenderer`;var Gu=(0,G.memo)(Wu);function Ku(e){return Z((0,G.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&_s({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),X)}var qu=({color:e=`none`,strokeWidth:t=1})=>(0,K.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),Ju=({color:e=`none`,strokeWidth:t=1})=>(0,K.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),Yu={[fo.Arrow]:qu,[fo.ArrowClosed]:Ju};function Xu(e){let t=Q();return(0,G.useMemo)(()=>Object.prototype.hasOwnProperty.call(Yu,e)?Yu[e]:(t.getState().onError?.(`009`,no.error009(e)),null),[e])}var Zu=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=Xu(t);return c?(0,K.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,K.jsx)(c,{color:n,strokeWidth:o})}):null},Qu=({defaultColor:e,rfId:t})=>{let n=Z(e=>e.edges),r=Z(e=>e.defaultEdgeOptions),i=(0,G.useMemo)(()=>Fs(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,K.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,K.jsx)(`defs`,{children:i.map(e=>(0,K.jsx)(Zu,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Qu.displayName=`MarkerDefinitions`;var $u=(0,G.memo)(Qu);function ed({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,G.useState)({x:1,y:0,width:0,height:0}),p=q([`react-flow__edge-textwrapper`,l]),m=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,K.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,K.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,K.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}ed.displayName=`EdgeText`;var td=(0,G.memo)(ed);function nd({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`path`,{...u,d:e,fill:`none`,className:q([`react-flow__edge-path`,u.className])}),l?(0,K.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Bo(t)&&Bo(n)?(0,K.jsx)(td,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function rd({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Y.Left||e===Y.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function id({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top}){let[o,s]=rd({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=rd({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=ds({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function ad(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=id({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,K.jsx)(nd,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var od=ad({isInternal:!1}),sd=ad({isInternal:!0});od.displayName=`SimpleBezierEdge`,sd.displayName=`SimpleBezierEdgeInternal`;function cd(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Y.Bottom,targetPosition:m=Y.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Os({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,K.jsx)(nd,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var ld=cd({isInternal:!1}),ud=cd({isInternal:!0});ld.displayName=`SmoothStepEdge`,ud.displayName=`SmoothStepEdgeInternal`;function dd(e){return(0,G.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,K.jsx)(ld,{...n,id:r,pathOptions:(0,G.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var fd=dd({isInternal:!1}),pd=dd({isInternal:!0});fd.displayName=`StepEdge`,pd.displayName=`StepEdgeInternal`;function md(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=Ss({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,K.jsx)(nd,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var hd=md({isInternal:!1}),gd=md({isInternal:!0});hd.displayName=`StraightEdge`,gd.displayName=`StraightEdgeInternal`;function _d(e){return(0,G.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Y.Bottom,targetPosition:s=Y.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=ms({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,K.jsx)(nd,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var vd=_d({isInternal:!1}),yd=_d({isInternal:!0});vd.displayName=`BezierEdge`,yd.displayName=`BezierEdgeInternal`;var bd={default:yd,straight:gd,step:pd,smoothstep:ud,simplebezier:sd},xd={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Sd=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,Cd=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,wd=`react-flow__edgeupdater`;function Td({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,K.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:q([wd,`${wd}-${s}`]),cx:Sd(t,r,e),cy:Cd(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Ed({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=Q(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;hc.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,K.jsxs)(K.Fragment,{children:[(e===!0||e===`source`)&&(0,K.jsx)(Td,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,K.jsx)(Td,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Dd({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=Z(t=>t.edgeLookup.get(e)),b=Z(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||bd[x];S===void 0&&(_?.(`011`,no.error011(x)),x=`default`,S=h?.default||bd.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,G.useRef)(null),[D,O]=(0,G.useState)(!1),[k,A]=(0,G.useState)(!1),j=Q(),{zIndex:M,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=Z((0,G.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...xd};let i=As({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:gs({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||xd}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),X),ee=(0,G.useMemo)(()=>y.markerStart?`url('#${Ps(y.markerStart,m)}')`:void 0,[y.markerStart,m]),z=(0,G.useMemo)(()=>y.markerEnd?`url('#${Ps(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let te=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},B=a?e=>{a(e,{...y})}:void 0,ne=o?e=>{o(e,{...y})}:void 0,V=s?e=>{s(e,{...y})}:void 0,H=c?e=>{c(e,{...y})}:void 0,re=l?e=>{l(e,{...y})}:void 0;return(0,K.jsx)(`svg`,{style:{zIndex:M},children:(0,K.jsxs)(`g`,{className:q([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:te,onDoubleClick:B,onContextMenu:ne,onMouseEnter:V,onMouseMove:H,onMouseLeave:re,onKeyDown:C?t=>{if(!v&&io.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${cl}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,K.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:ee,markerEnd:z,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,K.jsx)(Ed,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var Od=(0,G.memo)(Dd),kd=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ad({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Z(kd,X),b=Ku(t);return(0,K.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,K.jsx)($u,{defaultColor:e,rfId:n}),b.map(e=>(0,K.jsx)(Od,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Ad.displayName=`EdgeRenderer`;var jd=(0,G.memo)(Ad),Md=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Nd({children:e}){return(0,K.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:Z(Md)},children:e})}function Pd(e){let t=$l(),n=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Fd=e=>e.panZoom?.syncViewport;function Id(e){let t=Z(Fd),n=Q();return(0,G.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Ld(e){return e.connection.inProgress?{...e.connection,to:Uo(e.connection.to,e.transform)}:{...e.connection}}function Rd(e){return e?t=>e(Ld(t)):Ld}function zd(e){return Z(Rd(e),X)}var Bd=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Vd({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Z(Bd,X);return a&&i&&c?(0,K.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,K.jsx)(`g`,{className:q([`react-flow__connection`,mo(s)]),children:(0,K.jsx)(Hd,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var Hd=({style:e,type:t=uo.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=zd();if(!i)return;if(n)return(0,K.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:mo(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case uo.Bezier:[m]=ms(h);break;case uo.SimpleBezier:[m]=id(h);break;case uo.Step:[m]=Os({...h,borderRadius:0});break;case uo.SmoothStep:[m]=Os(h);break;default:[m]=Ss(h)}return(0,K.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};Hd.displayName=`ConnectionLine`;var Ud={};function Wd(e=Ud){(0,G.useRef)(e),Q(),(0,G.useEffect)(()=>{},[e])}function Gd(){Q(),(0,G.useRef)(!1),(0,G.useEffect)(()=>{},[])}function Kd({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:ee,onPaneClick:z,onPaneMouseEnter:te,onPaneMouseMove:B,onPaneMouseLeave:ne,onPaneScroll:V,onPaneContextMenu:H,paneClickDistance:re,nodeClickDistance:ie,onEdgeContextMenu:ae,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:U,onReconnect:le,onReconnectStart:W,onReconnectEnd:ue,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,nodeExtent:he,rfId:ge,viewport:_e,onViewportChange:G}){return Wd(e),Wd(t),Gd(),Pd(n),Id(_e),(0,K.jsx)(Fu,{onPaneClick:z,onPaneMouseEnter:te,onPaneMouseMove:B,onPaneMouseLeave:ne,onPaneContextMenu:H,onPaneScroll:V,paneClickDistance:re,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:ee,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:de,noWheelClassName:fe,noPanClassName:pe,disableKeyboardA11y:me,onViewportChange:G,isControlledViewport:!!_e,children:(0,K.jsxs)(Nd,{children:[(0,K.jsx)(jd,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:le,onReconnectStart:W,onReconnectEnd:ue,onlyRenderVisibleElements:T,onEdgeContextMenu:ae,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:U,defaultMarkerColor:M,noPanClassName:pe,disableKeyboardA11y:me,rfId:ge}),(0,K.jsx)(Vd,{style:h,type:m,component:g,containerStyle:_}),(0,K.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,K.jsx)(Gu,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ie,onlyRenderVisibleElements:T,noPanClassName:pe,noDragClassName:de,disableKeyboardA11y:me,nodeExtent:he,rfId:ge}),(0,K.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}Kd.displayName=`GraphView`;var qd=(0,G.memo)(Kd),Jd=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??ro;$s(h,g,_);let{nodesInitialized:x}=Ws(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=Jo(bo(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:ro,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:oo.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...lo},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Vo,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:ao,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Yd=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>tl((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await wo({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...Jd({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=Ws(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();$s(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=Xs(e,n,r,i,a,o,l);d&&(Vs(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Ms(e,o.fromHandle,Y.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=Ys(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Rl(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(zl(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>Bl(e,!0)));return}i(Vl(r,new Set([...e]),!0)),a(Vl(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>Bl(e,!0)));return}a(Vl(n,new Set([...e]))),i(Vl(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(Bl(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(Bl(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Bl(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Bl(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(Ws(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return Zs({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return Promise.resolve(!1);let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...lo}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...Jd()})}},Object.is);function Xd({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,G.useState)(()=>Yd({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,K.jsx)(rl,{value:m,children:(0,K.jsx)(Xl,{children:p})})}function Zd({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,G.useContext)(nl)?(0,K.jsx)(K.Fragment,{children:e}):(0,K.jsx)(Xd,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var Qd={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function $d({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=uo.Bezier,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:te,deleteKeyCode:B=`Backspace`,selectionKeyCode:ne=`Shift`,selectionOnDrag:V=!1,selectionMode:H=co.Full,panActivationKeyCode:re=`Space`,multiSelectionKeyCode:ie=Yo()?`Meta`:`Control`,zoomActivationKeyCode:ae=Yo()?`Meta`:`Control`,snapToGrid:oe,snapGrid:se,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:U,nodesDraggable:le,autoPanOnNodeFocus:W,nodesConnectable:ue,nodesFocusable:de,nodeOrigin:fe=Cl,edgesFocusable:pe,edgesReconnectable:me,elementsSelectable:he=!0,defaultViewport:ge=wl,minZoom:_e=.5,maxZoom:ve=2,translateExtent:J=ro,preventScrolling:ye=!0,nodeExtent:be,defaultMarkerColor:xe=`#b1b1b7`,zoomOnScroll:Se=!0,zoomOnPinch:Ce=!0,panOnScroll:we=!1,panOnScrollSpeed:Te=.5,panOnScrollMode:Ee=so.Free,zoomOnDoubleClick:De=!0,panOnDrag:Oe=!0,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:Fe=1,nodeClickDistance:Ie=0,children:Le,onReconnect:Re,onReconnectStart:ze,onReconnectEnd:Be,onEdgeContextMenu:Ve,onEdgeDoubleClick:He,onEdgeMouseEnter:Ue,onEdgeMouseMove:We,onEdgeMouseLeave:Ge,reconnectRadius:Ke=10,onNodesChange:qe,onEdgesChange:Je,noDragClassName:Ye=`nodrag`,noWheelClassName:Xe=`nowheel`,noPanClassName:Ze=`nopan`,fitView:Qe,fitViewOptions:$e,connectOnClick:et,attributionPosition:tt,proOptions:nt,defaultEdgeOptions:rt,elevateNodesOnSelect:it=!0,elevateEdgesOnSelect:at=!1,disableKeyboardA11y:ot=!1,autoPanOnConnect:st,autoPanOnNodeDrag:ct,autoPanSpeed:lt,connectionRadius:ut,isValidConnection:dt,onError:ft,style:pt,id:mt,nodeDragThreshold:ht,connectionDragThreshold:gt,viewport:_t,onViewportChange:vt,width:yt,height:bt,colorMode:xt=`light`,debug:St,onScroll:Ct,ariaLabelConfig:wt,zIndexMode:Tt=`basic`,...Et},Dt){let Ot=mt||`1`,kt=Al(xt),At=(0,G.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Ct?.(e)},[Ct]);return(0,K.jsx)(`div`,{"data-testid":`rf__wrapper`,...Et,onScroll:At,style:{...pt,...Qd},ref:Dt,className:q([`react-flow`,i,kt]),id:mt,role:`application`,children:(0,K.jsxs)(Zd,{nodes:e,edges:t,width:yt,height:bt,fitView:Qe,fitViewOptions:$e,minZoom:_e,maxZoom:ve,nodeOrigin:fe,nodeExtent:be,zIndexMode:Tt,children:[(0,K.jsx)(Ol,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:le,autoPanOnNodeFocus:W,nodesConnectable:ue,nodesFocusable:de,edgesFocusable:pe,edgesReconnectable:me,elementsSelectable:he,elevateNodesOnSelect:it,elevateEdgesOnSelect:at,minZoom:_e,maxZoom:ve,nodeExtent:be,onNodesChange:qe,onEdgesChange:Je,snapToGrid:oe,snapGrid:se,connectionMode:L,translateExtent:J,connectOnClick:et,defaultEdgeOptions:rt,fitView:Qe,fitViewOptions:$e,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ze,nodeOrigin:fe,rfId:Ot,autoPanOnConnect:st,autoPanOnNodeDrag:ct,autoPanSpeed:lt,onError:ft,connectionRadius:ut,isValidConnection:dt,selectNodesOnDrag:U,nodeDragThreshold:ht,connectionDragThreshold:gt,onBeforeDelete:I,debug:St,ariaLabelConfig:wt,zIndexMode:Tt}),(0,K.jsx)(qd,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:te,selectionKeyCode:ne,selectionOnDrag:V,selectionMode:H,deleteKeyCode:B,multiSelectionKeyCode:ie,panActivationKeyCode:re,zoomActivationKeyCode:ae,onlyRenderVisibleElements:ce,defaultViewport:ge,translateExtent:J,minZoom:_e,maxZoom:ve,preventScrolling:ye,zoomOnScroll:Se,zoomOnPinch:Ce,zoomOnDoubleClick:De,panOnScroll:we,panOnScrollSpeed:Te,panOnScrollMode:Ee,panOnDrag:Oe,onPaneClick:ke,onPaneMouseEnter:Ae,onPaneMouseMove:je,onPaneMouseLeave:Me,onPaneScroll:Ne,onPaneContextMenu:Pe,paneClickDistance:Fe,nodeClickDistance:Ie,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Re,onReconnectStart:ze,onReconnectEnd:Be,onEdgeContextMenu:Ve,onEdgeDoubleClick:He,onEdgeMouseEnter:Ue,onEdgeMouseMove:We,onEdgeMouseLeave:Ge,reconnectRadius:Ke,defaultMarkerColor:xe,noDragClassName:Ye,noWheelClassName:Xe,noPanClassName:Ze,rfId:Ot,disableKeyboardA11y:ot,nodeExtent:be,viewport:_t,onViewportChange:vt}),(0,K.jsx)(xl,{onSelectionChange:k}),Le,(0,K.jsx)(hl,{proOptions:nt,position:tt}),(0,K.jsx)(pl,{rfId:Ot,disableKeyboardA11y:ot})]})})}var ef=Kl($d),tf=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function nf({children:e}){let t=Z(tf);return t?(0,ve.createPortal)(e,t):null}function rf(e){let[t,n]=(0,G.useState)(e);return[t,n,(0,G.useCallback)(e=>n(t=>Rl(e,t)),[])]}function af(e){let[t,n]=(0,G.useState)(e);return[t,n,(0,G.useCallback)(e=>n(t=>zl(e,t)),[])]}no.error014();function of({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,K.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:q([`react-flow__background-pattern`,n,r])})}function sf({radius:e,className:t}){return(0,K.jsx)(`circle`,{cx:e,cy:e,r:e,className:q([`react-flow__background-pattern`,`dots`,t])})}var cf;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(cf||={});var lf={[cf.Dots]:1,[cf.Lines]:1,[cf.Cross]:6},uf=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function df({id:e,variant:t=cf.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,G.useRef)(null),{transform:f,patternId:p}=Z(uf,X),m=r||lf[t],h=t===cf.Dots,g=t===cf.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,K.jsxs)(`svg`,{className:q([`react-flow__background`,l]),style:{...c,...iu,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,K.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,K.jsx)(sf,{radius:y/2,className:u}):(0,K.jsx)(of,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,K.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}df.displayName=`Background`;var ff=(0,G.memo)(df);function pf(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,K.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function mf(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,K.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function hf(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,K.jsx)(`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 gf(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,K.jsx)(`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 _f(){return(0,K.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,K.jsx)(`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`})})}function vf({children:e,className:t,...n}){return(0,K.jsx)(`button`,{type:`button`,className:q([`react-flow__controls-button`,t]),...n,children:e})}var yf=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function bf({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=Q(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Z(yf,X),{zoomIn:y,zoomOut:b,fitView:x}=$l();return(0,K.jsxs)(ml,{className:q([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(vf,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,K.jsx)(pf,{})}),(0,K.jsx)(vf,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,K.jsx)(mf,{})})]}),n&&(0,K.jsx)(vf,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,K.jsx)(hf,{})}),r&&(0,K.jsx)(vf,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,K.jsx)(_f,{}):(0,K.jsx)(gf,{})}),u]})}bf.displayName=`Controls`;var xf=(0,G.memo)(bf);function Sf({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,K.jsx)(`rect`,{className:q([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var Cf=(0,G.memo)(Sf),wf=e=>e.nodes.map(e=>e.id),Tf=e=>e instanceof Function?e:()=>e;function Ef({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=Cf,onClick:o}){let s=Z(wf,X),c=Tf(t),l=Tf(e),u=Tf(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,K.jsx)(K.Fragment,{children:s.map(e=>(0,K.jsx)(Of,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Df({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Z(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=Zo(r);return{node:r,x:i,y:a,width:o,height:s}},X);return!l||l.hidden||!Qo(l)?null:(0,K.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Of=(0,G.memo)(Df),kf=(0,G.memo)(Ef),Af=200,jf=150,Mf=e=>!e.hidden,Nf=e=>{let t={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:t,boundingRect:e.nodeLookup.size>0?Lo(bo(e.nodeLookup,{filter:Mf}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Pf=`react-flow__minimap-desc`;function Ff({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=Q(),S=(0,G.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=Z(Nf,X),j=e?.width??Af,M=e?.height??jf,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,ee=C.x-(I-C.width)/2-R,z=C.y-(L-C.height)/2-R,te=I+R*2,B=L+R*2,ne=`${Pf}-${T}`,V=(0,G.useRef)(0),H=(0,G.useRef)();V.current=F,(0,G.useEffect)(()=>{if(S.current&&E)return H.current=gc({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>V.current}),()=>{H.current?.destroy()}},[E]),(0,G.useEffect)(()=>{H.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let re=p?e=>{let[t,n]=H.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ie=m?(0,G.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,ae=_??A[`minimap.ariaLabel`];return(0,K.jsx)(ml,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:q([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,K.jsxs)(`svg`,{width:j,height:M,viewBox:`${ee} ${z} ${te} ${B}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ne,ref:S,onClick:re,children:[ae&&(0,K.jsx)(`title`,{id:ne,children:ae}),(0,K.jsx)(kf,{onClick:ie,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,K.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${ee-R},${z-R}h${te+R*2}v${B+R*2}h${-te-R*2}z - M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Ff.displayName=`MiniMap`;var If=(0,G.memo)(Ff),Lf=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Rf={[jc.Line]:`right`,[jc.Handle]:`bottom-right`};function zf({nodeId:e,position:t,variant:n=jc.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=vu(),y=typeof e==`string`?e:v,b=Q(),x=(0,G.useRef)(null),S=n===jc.Handle,C=Z((0,G.useCallback)(Lf(S&&p),[S,p]),X),w=(0,G.useRef)(null),T=t??Rf[n];return(0,G.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Uc({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Ys([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...$o({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,K.jsx)(`div`,{className:q([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,G.memo)(zf);var Bf=`shogun.samuraiDiagnostics`,Vf=250,Hf=`1.16.0-build78`,Uf=!1;function Wf(){try{let e=window.localStorage.getItem(Bf);return e?JSON.parse(e):[]}catch{return[]}}function Gf(e){try{window.localStorage.setItem(Bf,JSON.stringify(e.slice(-Vf)))}catch{}}function Kf(e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&typeof e==`object`)try{return JSON.parse(JSON.stringify(e))}catch{return String(e)}return e}function qf(e,t){let n=e.getBoundingClientRect(),r=window.getComputedStyle(e),i=n.left+n.width/2,a=n.top+n.height/2,o=n.width>0&&n.height>0?document.elementFromPoint(i,a):null;return{index:t,tag:e.tagName.toLowerCase(),text:e.textContent?.trim().replace(/\s+/g,` `).slice(0,80)||``,className:e.getAttribute(`class`)||``,rect:{left:Math.round(n.left),top:Math.round(n.top),width:Math.round(n.width),height:Math.round(n.height),right:Math.round(n.right),bottom:Math.round(n.bottom)},style:{display:r.display,visibility:r.visibility,opacity:r.opacity,pointerEvents:r.pointerEvents,zIndex:r.zIndex,color:r.color,backgroundColor:r.backgroundColor},topElementAtCenter:o?{tag:o.tagName.toLowerCase(),text:o.textContent?.trim().replace(/\s+/g,` `).slice(0,80)||``,className:o.getAttribute(`class`)||``,sameElement:o===e||e.contains(o)}:null}}function Jf(e){return Array.from(document.querySelectorAll(`button, a`)).filter(t=>t.textContent?.trim().replace(/\s+/g,` `)===e)}function $(e,t={}){if(typeof window>`u`)return;let n={ts:new Date().toISOString(),event:e,details:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Kf(t)]))};Gf([...Wf(),n]),console.info(`[SamuraiDiagnostics]`,n)}function Yf(e){if(typeof window>`u`)return;let t=Jf(`Fleet`),n=Jf(`Agent Flow`),r=Array.from(document.querySelectorAll(`[title="Node Properties"], [aria-label^="Open properties"]`)),i=Array.from(document.querySelectorAll(`.react-flow__node`)),a=Array.from(document.querySelectorAll(`h3`)).filter(e=>e.textContent?.trim()===`Node Properties`);$(`samurai.snapshot`,{reason:e,url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},document:{readyState:document.readyState,bodyClass:document.body.className,rootChildren:document.getElementById(`root`)?.children.length||0},counts:{fleetButtons:t.length,agentFlowButtons:n.length,nodePropertyButtons:r.length,reactFlowNodes:i.length,inspectorTitles:a.length},fleetButtons:t.map(qf),agentFlowButtons:n.map(qf),nodePropertyButtons:r.slice(0,10).map(qf),reactFlowNodes:i.slice(0,10).map(qf),inspectorTitles:a.map(qf)})}function Xf(){typeof window>`u`||Uf||(Uf=!0,window.addEventListener(`error`,e=>{$(`window.error`,{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno,error:e.error})}),window.addEventListener(`unhandledrejection`,e=>{$(`window.unhandledrejection`,{reason:e.reason})}))}function Zf(){Gf([]),$(`diagnostics.cleared`)}function Qf(){let e=Wf();return[`SHOGUN SAMURAI DIAGNOSTICS`,`diagnostic_build=${Hf}`,`created_at=${new Date().toISOString()}`,`url=${window.location.href}`,`user_agent=${navigator.userAgent}`,`events=${e.length}`,``].concat(e.map(e=>JSON.stringify(e))).join(` -`)}async function $f(){Yf(`copy`);let e=Qf();try{return await navigator.clipboard.writeText(e),$(`diagnostics.copied`,{length:e.length}),!0}catch{return $(`diagnostics.copy_failed`,{length:e.length}),!1}}function ep(){Yf(`download`);let e=Qf(),t=new Blob([e],{type:`text/plain;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`shogun-samurai-diagnostics-${new Date().toISOString().replace(/[:.]/g,`-`)}.txt`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n),$(`diagnostics.downloaded`,{length:e.length})}function tp(){return Hf}var np=Object.assign({"./templates/da.json":()=>o(()=>import(`./da-BsqrSR7K.js`).then(e=>e.default),[]),"./templates/de.json":()=>o(()=>import(`./de-cdt7EBNd.js`).then(e=>e.default),[]),"./templates/en.json":()=>o(()=>import(`./en-C0uX5rrc.js`).then(e=>e.default),[]),"./templates/es.json":()=>o(()=>import(`./es-COFOLNXG.js`).then(e=>e.default),[]),"./templates/fr.json":()=>o(()=>import(`./fr-DfKye5IV.js`).then(e=>e.default),[]),"./templates/hi.json":()=>o(()=>import(`./hi-CGR2ilvf.js`).then(e=>e.default),[]),"./templates/it.json":()=>o(()=>import(`./it-BEVxJ7X4.js`).then(e=>e.default),[]),"./templates/ja.json":()=>o(()=>import(`./ja-wYu4rlaK.js`).then(e=>e.default),[]),"./templates/ko.json":()=>o(()=>import(`./ko-BO2LfAUh.js`).then(e=>e.default),[]),"./templates/no.json":()=>o(()=>import(`./no-BFw2iKyG.js`).then(e=>e.default),[]),"./templates/pl.json":()=>o(()=>import(`./pl-MmRfh9bn.js`).then(e=>e.default),[]),"./templates/pt.json":()=>o(()=>import(`./pt-Bp4M2WKA.js`).then(e=>e.default),[]),"./templates/sv.json":()=>o(()=>import(`./sv-CcL3eaih.js`).then(e=>e.default),[]),"./templates/uk.json":()=>o(()=>import(`./uk-BuU_4NHy.js`).then(e=>e.default),[]),"./templates/zh.json":()=>o(()=>import(`./zh-JnmjSPxW.js`).then(e=>e.default),[])}),rp={da:`Mine skabeloner`,de:`Meine Vorlagen`,es:`Mis plantillas`,fr:`Mes modèles`,hi:`मेरे टेम्पलेट`,it:`I miei modelli`,ja:`マイテンプレート`,ko:`내 템플릿`,no:`Mine maler`,pl:`Moje szablony`,pt:`Meus modelos`,sv:`Mina mallar`,uk:`Мої шаблони`,zh:`我的模板`};function ip(){let{language:e}=le(),[t,n]=(0,G.useState)(null);(0,G.useEffect)(()=>{let t=!0;return(np[`./templates/${e}.json`]||np[`./templates/en.json`])?.().then(e=>{t&&n(e)}).catch(()=>np[`./templates/en.json`]?.().then(e=>{t&&n(e)})),()=>{t=!1}},[e]);let r=(0,G.useCallback)((e,n)=>t?.ui?.[e]||n,[t]),i=(0,G.useCallback)((n,r=!1)=>r?n===`My Templates`&&rp[e]||n:t?.categories?.[n]||n,[t,e]);return{ui:r,category:i,difficulty:(0,G.useCallback)(e=>t?.difficulty?.[e]||e,[t]),agentFlow:(0,G.useCallback)(e=>{let n=e.source===`custom`||e.id.startsWith(`custom:`),r=n?void 0:t?.agentFlow?.[e.id];return{...e,name:r?.name||e.name,description:r?.description||e.description,category:i(e.category,n)}},[t,i]),flowStack:(0,G.useCallback)(e=>{let n=e.source===`custom`||e.id.startsWith(`custom:`),r=n?void 0:t?.flowStack?.[e.id];return{...e,name:r?.name||e.name,description:r?.description||e.description,category:i(e.category,n),duration_label:r?.duration_label||e.duration_label,builder_nodes:e.builder_nodes?.map(e=>({...e,label:r?.builder_labels?.[e.id]||e.label}))}},[t,i])}}var ap=(0,G.createContext)(null);function op(e){let t=/(?:Z|[+-]\d{2}:\d{2})$/i.test(e);return new Date(t?e:`${e}Z`)}function sp(e){return e?op(e).toLocaleString():`-`}var cp=[{type:`samurai`,label:`Samurai`,icon:oe,color:`#d4a017`,desc:`Task worker / sub-agent`},{type:`coding`,label:`Coding`,icon:h,color:`#14b8a6`,desc:`Governed IDE and programming memory`},{type:`shogun_approval`,label:`Shogun Approval`,icon:V,color:`#4a8cc7`,desc:`Approval gate`},{type:`logic`,label:`Logic / Decision`,icon:S,color:`#a78bfa`,desc:`Branching logic`},{type:`input`,label:`Input`,icon:he,color:`#22c55e`,desc:`Workflow start point`},{type:`output`,label:`Output`,icon:ge,color:`#f97316`,desc:`Final delivery`},{type:`mado_browser`,label:`Mado Browser`,icon:C,color:`#06b6d4`,desc:`Browser automation`},{type:`email_send`,label:`Email Send`,icon:A,color:`#e879a8`,desc:`Send email via SMTP`},{type:`channel_send`,label:`Telegram / Teams`,icon:j,color:`#38bdf8`,desc:`Send an operator message`},{type:`workspace`,label:`Workspace`,icon:x,color:`#f59e0b`,desc:`File operations`},{type:`office`,label:`Office`,icon:y,color:`#10b981`,desc:`Office documents`},{type:`subflow`,label:`Subflow`,icon:E,color:`#8b5cf6`,desc:`Run a reusable child flow`},{type:`stack_orchestrator`,label:`Stack Orchestrator`,icon:M,color:`#c084fc`,desc:`Supervise long-running Agent Stacks`}],lp={samurai:`#d4a017`,coding:`#14b8a6`,shogun_approval:`#4a8cc7`,logic:`#a78bfa`,input:`#22c55e`,output:`#f97316`,mado_browser:`#06b6d4`,email_send:`#e879a8`,channel_send:`#38bdf8`,workspace:`#f59e0b`,office:`#10b981`,subflow:`#8b5cf6`,stack_orchestrator:`#c084fc`},up={samurai:oe,coding:h,shogun_approval:V,logic:S,input:he,output:ge,mado_browser:C,email_send:A,channel_send:j,workspace:x,office:y,subflow:E,stack_orchestrator:M};function dp(e){return e instanceof HTMLElement&&!!e.closest(`button, input, textarea, select, a, [role="button"], .nodrag, .nowheel`)}function fp({node:e}){let t=e.status===`completed`?`#22c55e`:e.status===`failed`?`#ef4444`:e.status===`running`?`#4a8cc7`:e.status===`cancelled`?`#7a8899`:`#d4a017`;return(0,K.jsxs)(`div`,{className:`relative pl-4`,children:[e.run_depth>0&&(0,K.jsx)(`div`,{className:`absolute left-0 top-0 h-4 w-3 border-b border-l border-[#2a3060] rounded-bl`}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-[#1a2040] bg-[#0e1225] p-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{background:t}}),(0,K.jsx)(`span`,{className:`truncate text-[10px] font-bold text-[#c8d0d8]`,children:e.flow_name}),(0,K.jsxs)(`span`,{className:`text-[8px] text-[#7a8899]`,children:[`v`,e.flow_version]})]}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold uppercase`,style:{color:t},children:e.status})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex gap-3 text-[8px] text-[#7a8899]`,children:[(0,K.jsxs)(`span`,{children:[`Depth `,e.run_depth]}),e.started_at&&e.completed_at&&(0,K.jsxs)(`span`,{children:[((op(e.completed_at).getTime()-op(e.started_at).getTime())/1e3).toFixed(1),`s`]}),(0,K.jsx)(`span`,{className:`ml-auto font-mono`,children:String(e.run_id).slice(0,8)})]})]}),e.children?.length>0&&(0,K.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-[#1a2040] pl-2`,children:e.children.map(e=>(0,K.jsx)(fp,{node:e},e.run_id))})]})}function pp({id:e,data:t,selected:n,type:r}){let i=lp[r]||`#d4a017`,a=up[r]||oe,o=t.config||{},s=(0,G.useContext)(ap),c=s?.nodeStates?.[e],l=c?.status||t.execution_status,u=c?.output??t.execution_output??``,d=s?.runId||t.execution_run_id||null,m=l===`running`;return(0,K.jsxs)(`div`,{className:U(`relative min-w-[200px] max-w-[260px] rounded-lg border transition-all duration-200`,n?`ring-2 ring-offset-1 ring-offset-[#0a0e1a] shadow-lg`:`shadow-md hover:shadow-lg`),onClick:i=>{dp(i.target)||($(`agent_flow.node.click`,{nodeId:e,type:r,label:t.label,selected:n}),t.onOpenInspector?.(e))},onPointerUp:i=>{dp(i.target)||($(`agent_flow.node.pointer_up`,{nodeId:e,type:r,label:t.label,selected:n}),t.onOpenInspector?.(e))},style:{background:m?`linear-gradient(135deg, ${i}0a 0%, #0e1225 42%, ${i}06 100%)`:`#0e1225`,borderColor:m||n?i:`#1a2040`,boxShadow:m?`inset 0 0 20px ${i}2e, 0 0 0 3px ${i}, 0 0 14px 5px ${i}f2, 0 0 38px 14px ${i}b8, 0 0 82px 28px ${i}73, 0 0 128px 42px ${i}3d`:n?`0 0 0 1px ${i}b3, 0 0 20px ${i}55`:void 0,filter:m?`saturate(1.08) brightness(1.03)`:void 0},children:[(0,K.jsx)(`div`,{className:U(`rounded-t-lg transition-all duration-300`,m?`h-1.5`:`h-1`),style:{background:i,boxShadow:m?`0 0 10px 3px ${i}, 0 0 28px 10px ${i}d9, 0 0 52px 18px ${i}80`:void 0}}),(0,K.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 border-b`,style:{borderColor:`#1a204060`},children:[(0,K.jsx)(`div`,{className:`w-6 h-6 rounded flex items-center justify-center shrink-0`,style:{background:`${i}15`,border:`1px solid ${i}30`},children:(0,K.jsx)(a,{className:`w-3.5 h-3.5`,style:{color:i}})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-[11px] font-bold text-[#c8d0d8] truncate`,children:t.label}),(0,K.jsx)(`div`,{className:`text-[8px] font-bold uppercase tracking-widest`,style:{color:`${i}90`},children:r.replace(`_`,` `)})]}),(0,K.jsx)(`button`,{type:`button`,title:`Node Properties`,"aria-label":`Open properties for ${t.label||`node`}`,className:`nodrag nopan shrink-0 w-6 h-6 rounded border border-[#1a2040] bg-[#0a0e1a] text-[#7a8899] hover:text-[#d4a017] hover:border-[#d4a017]/50 flex items-center justify-center transition-colors`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onPointerUp:n=>{n.preventDefault(),n.stopPropagation(),$(`agent_flow.node.properties_button.pointer_up`,{nodeId:e,type:r,label:t.label}),t.onOpenInspector?.(e)},onClick:n=>{n.preventDefault(),n.stopPropagation(),$(`agent_flow.node.properties_button.click`,{nodeId:e,type:r,label:t.label}),t.onOpenInspector?.(e)},children:(0,K.jsx)(B,{className:`w-3 h-3`})})]}),(0,K.jsxs)(`div`,{className:`px-3 py-2 space-y-1`,children:[r===`samurai`&&(0,K.jsxs)(K.Fragment,{children:[o.task_description&&(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.task_description}),o.routing_profile_name&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(ce,{className:`w-2.5 h-2.5 text-[#d4a017]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#d4a017]/80`,children:o.routing_profile_name})]}),!o.task_description&&!o.routing_profile_name&&(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899]/50 italic`,children:`Configure task...`})]}),r===`shogun_approval`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(V,{className:`w-2.5 h-2.5 text-[#4a8cc7]/70`}),(0,K.jsxs)(`span`,{className:`text-[8px] font-bold text-[#4a8cc7]/80 uppercase`,children:[o.approval_mode||`manual`,` approval`]})]}),o.confidence_threshold&&(0,K.jsxs)(`span`,{className:`text-[8px] text-[#7a8899]`,children:[`Threshold: `,o.confidence_threshold,`%`]})]}),r===`logic`&&(0,K.jsx)(`p`,{className:`text-[9px] text-[#a78bfa]/80 font-mono`,children:o.condition_expression||`IF condition → ...`}),r===`input`&&(0,K.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,K.jsxs)(`span`,{className:`text-[8px] font-bold text-[#22c55e]/80 uppercase`,children:[o.input_type||`manual`,` trigger`]})}),r===`output`&&(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5 w-full`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#f97316]/80 uppercase`,children:o.output_type||`artifact`})}),l===`completed`&&(0,K.jsxs)(`button`,{"data-testid":`view-output-result`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onPointerUp:e=>{e.preventDefault(),e.stopPropagation(),s?.view({runId:d,label:t.label||`Output`,content:u})},onClick:e=>{e.stopPropagation(),e.detail===0&&s?.view({runId:d,label:t.label||`Output`,content:u})},type:`button`,className:`nodrag nopan mt-1 w-full flex items-center justify-center gap-1.5 px-2 py-1 bg-[#22c55e]/10 hover:bg-[#22c55e]/20 text-[#22c55e] border border-[#22c55e]/20 rounded text-[9px] font-bold uppercase transition-colors`,children:[(0,K.jsx)(te,{className:`w-3 h-3`}),`View Result`]})]}),r===`mado_browser`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(C,{className:`w-2.5 h-2.5 text-[#06b6d4]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#06b6d4]/80 uppercase`,children:o.action||`navigate`})]}),o.url&&(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.url})]}),r===`email_send`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(A,{className:`w-2.5 h-2.5 text-[#e879a8]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#e879a8]/80 truncate`,children:o.to_address||`No recipient`})]}),o.subject&&(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.subject})]}),r===`channel_send`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(j,{className:`w-2.5 h-2.5 text-[#38bdf8]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#38bdf8]/80 uppercase`,children:o.channel||`both`})]}),(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.message_template||`Uses predecessor output`})]}),r===`workspace`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(x,{className:`w-2.5 h-2.5 text-[#f59e0b]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#f59e0b]/80 uppercase`,children:o.action||`read_file`})]}),o.path&&(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.path})]}),r===`office`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(y,{className:`w-2.5 h-2.5 text-[#10b981]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#10b981]/80 uppercase`,children:o.action||`word_read`})]}),o.input_path&&(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.input_path})]}),r===`coding`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(h,{className:`w-2.5 h-2.5 text-[#14b8a6]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#14b8a6]/80 uppercase`,children:o.action||`analyze`})]}),(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.task_description||o.command||`Configure coding task...`}),o.recall_memory!==!1&&(0,K.jsx)(`span`,{className:`text-[8px] text-[#14b8a6]/60`,children:`Programming memory enabled`})]}),r===`subflow`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(E,{className:`w-2.5 h-2.5 text-[#8b5cf6]/70`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#8b5cf6]/80 uppercase`,children:o.child_flow_name||`Select child flow`})]}),(0,K.jsxs)(`p`,{className:`text-[8px] text-[#7a8899]`,children:[o.child_flow_version_mode||`locked`,o.child_flow_version?` · v${o.child_flow_version}`:``,` · `,o.on_failure||`fail_parent`]})]}),r===`stack_orchestrator`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(M,{className:`w-2.5 h-2.5 text-[#c084fc]/80`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold text-[#c084fc] uppercase`,children:o.mode||`selected_stack`})]}),(0,K.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.objective||`Configure a governed long-running objective`})]})]}),r!==`input`&&(0,K.jsx)(Su,{type:`target`,position:Y.Left,className:`!w-2.5 !h-2.5 !border-2 !rounded-full !bg-[#0a0e1a]`,style:{borderColor:i}}),r!==`output`&&(0,K.jsx)(Su,{type:`source`,position:Y.Right,className:`!w-2.5 !h-2.5 !border-2 !rounded-full !bg-[#0a0e1a]`,style:{borderColor:i}}),r===`logic`&&(0,K.jsx)(K.Fragment,{children:(0,K.jsx)(Su,{type:`source`,position:Y.Bottom,id:`false`,className:`!w-2.5 !h-2.5 !border-2 !rounded-full !bg-[#0a0e1a]`,style:{borderColor:`#ef4444`}})}),l&&l!==`pending`&&(0,K.jsxs)(`div`,{className:`absolute -top-1 -right-1 z-10`,children:[l===`running`&&(0,K.jsx)(`div`,{className:`w-6 h-6 rounded-full flex items-center justify-center animate-pulse`,style:{background:i,boxShadow:`0 0 10px ${i}, 0 0 22px ${i}cc`},children:(0,K.jsx)(k,{className:`w-3 h-3 text-white animate-spin`})}),l===`completed`&&(0,K.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-[#22c55e] flex items-center justify-center shadow-[0_0_8px_rgba(34,197,94,0.4)]`,children:(0,K.jsx)(f,{className:`w-3 h-3 text-white`})}),l===`failed`&&(0,K.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-[#ef4444] flex items-center justify-center shadow-[0_0_8px_rgba(239,68,68,0.4)]`,children:(0,K.jsx)(p,{className:`w-3 h-3 text-white`})}),l===`skipped`&&(0,K.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-[#7a8899] flex items-center justify-center`,children:(0,K.jsx)(ie,{className:`w-3 h-3 text-white`})})]})]})}var mp={samurai:pp,coding:pp,shogun_approval:pp,logic:pp,input:pp,output:pp,mado_browser:pp,email_send:pp,channel_send:pp,workspace:pp,office:pp,subflow:pp,stack_orchestrator:pp};function hp({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,data:s,markerEnd:c,style:l,selected:u}){let[d,f,p]=Os({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:i,targetPosition:o,borderRadius:12}),m=s?.edge_type===`success`?`#22c55e`:s?.edge_type===`failure`?`#ef4444`:s?.edge_type===`conditional`?`#a78bfa`:`#4a8cc7`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(nd,{id:e,path:d,markerEnd:c,style:{...l,stroke:u?`#d4a017`:m,strokeWidth:u?2.5:1.5,opacity:u?1:.7}}),s?.label&&(0,K.jsx)(nf,{children:(0,K.jsx)(`div`,{className:`absolute text-[8px] font-bold uppercase tracking-wider px-2 py-0.5 rounded border pointer-events-all`,style:{transform:`translate(-50%, -50%) translate(${f}px,${p}px)`,background:`#0e1225`,borderColor:m+`40`,color:m},children:s.label})})]})}var gp={custom:hp},_p=[`excel_read`,`word_read`,`pptx_read`];function vp({config:e,updateConfig:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)([]),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(new Set),u=e.action||`word_read`,d=_p.includes(u),f=d?`input_path`:`output_path`,p=d?`Source File`:`Destination Folder`,m=d?`Select the file to read`:`Where to save the output file`,h=d?`Input/document.docx`:`Output/`,g=(0,G.useMemo)(()=>u.startsWith(`excel`)?[`xlsx`,`xls`,`csv`]:u.startsWith(`word`)?[`docx`,`doc`]:u.startsWith(`pptx`)?[`pptx`,`ppt`]:[],[u]),_=async()=>{r(!0),s(!0);try{let e=await W.get(`/api/v1/workspace/tree`);a(e.data?.data?.tree||e.data?.data||[])}catch{a([])}s(!1)},v=e=>{t(f,e),r(!1)},y=e=>{t(f,e+`/`),r(!1)},S=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=e=>g.includes(e.toLowerCase())?`text-[#10b981]`:`text-[#7a8899]/50`,w=(e,t=0)=>{if(e.type===`directory`){let n=c.has(e.path),r=e.children||[];return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{onClick:()=>d?S(e.path):y(e.path),className:U(`w-full flex items-center gap-2 px-3 py-1.5 rounded-lg text-left transition-colors group`,`hover:bg-[#10b981]/10`,!(!d||yp(r,g))&&d&&`opacity-40`),style:{paddingLeft:`${12+t*16}px`},children:[(0,K.jsx)(x,{className:U(`w-3.5 h-3.5`,n?`text-[#10b981]`:`text-[#f59e0b]/70`)}),(0,K.jsx)(`span`,{className:`text-xs text-[#c8d0d8] flex-1 truncate`,children:e.name}),d?(0,K.jsx)(`span`,{className:`text-[8px] text-[#7a8899] opacity-0 group-hover:opacity-100 transition-opacity`,children:n?`▼`:`▶`}):(0,K.jsx)(`span`,{className:`ml-auto text-[9px] text-[#10b981] opacity-0 group-hover:opacity-100 transition-opacity`,children:`Select`})]}),d&&n&&r.map(e=>w(e,t+1))]},e.path)}if(!d)return null;let n=e.extension||``,r=g.includes(n.toLowerCase()),i=e.size?`${(e.size/1024).toFixed(1)} KB`:``;return(0,K.jsxs)(`button`,{onClick:()=>r?v(e.path):void 0,className:U(`w-full flex items-center gap-2 px-3 py-1.5 rounded-lg text-left transition-colors group`,r?`hover:bg-[#10b981]/10 cursor-pointer`:`opacity-30 cursor-default`),style:{paddingLeft:`${12+t*16}px`},disabled:!r,children:[(0,K.jsx)(b,{className:U(`w-3.5 h-3.5`,C(n))}),(0,K.jsx)(`span`,{className:U(`text-xs flex-1 truncate`,r?`text-[#c8d0d8]`:`text-[#7a8899]/60`),children:e.name}),i&&(0,K.jsx)(`span`,{className:`text-[8px] text-[#7a8899]/50 shrink-0`,children:i}),r&&(0,K.jsx)(`span`,{className:`text-[9px] text-[#10b981] opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:`Select`})]},e.path)};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,K.jsxs)(`select`,{value:u,onChange:e=>t(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none`,children:[(0,K.jsxs)(`optgroup`,{label:`Excel`,children:[(0,K.jsx)(`option`,{value:`excel_read`,children:`Excel — Read`}),(0,K.jsx)(`option`,{value:`excel_create`,children:`Excel — Create`}),(0,K.jsx)(`option`,{value:`excel_write`,children:`Excel — Write`})]}),(0,K.jsxs)(`optgroup`,{label:`Word`,children:[(0,K.jsx)(`option`,{value:`word_read`,children:`Word — Read`}),(0,K.jsx)(`option`,{value:`word_create`,children:`Word — Create`}),(0,K.jsx)(`option`,{value:`word_replace`,children:`Word — Replace Placeholders`})]}),(0,K.jsxs)(`optgroup`,{label:`PowerPoint`,children:[(0,K.jsx)(`option`,{value:`pptx_read`,children:`PowerPoint — Read`}),(0,K.jsx)(`option`,{value:`pptx_replace`,children:`PowerPoint — Replace Placeholders`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[d?(0,K.jsx)(b,{className:`w-3 h-3 text-[#10b981]/60`}):(0,K.jsx)(x,{className:`w-3 h-3 text-[#10b981]/60`}),p]}),(0,K.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,K.jsx)(`input`,{type:`text`,value:e[f]||``,onChange:e=>t(f,e.target.value),className:`flex-1 bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none`,placeholder:h}),(0,K.jsx)(`button`,{onClick:_,className:`px-2.5 bg-[#10b981]/10 border border-[#10b981]/30 rounded-lg text-[#10b981] hover:bg-[#10b981]/20 transition-colors`,title:d?`Browse workspace files`:`Browse workspace folders`,children:d?(0,K.jsx)(b,{className:`w-3.5 h-3.5`}):(0,K.jsx)(x,{className:`w-3.5 h-3.5`})})]}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#7a8899]/60`,children:m})]}),[`excel_read`,`excel_create`,`excel_write`].includes(u)&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Sheet Name`}),(0,K.jsx)(`input`,{type:`text`,value:e.sheet_name||``,onChange:e=>t(`sheet_name`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none`,placeholder:`Sheet1`})]}),u===`word_create`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Content Template`}),(0,K.jsx)(`textarea`,{value:e.content_template||``,onChange:e=>t(`content_template`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none resize-none`,placeholder:`Use {{context}} for predecessor data.`})]}),(0,K.jsx)(`div`,{className:`p-2.5 bg-[#10b981]/5 border border-[#10b981]/20 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-[8px] text-[#10b981]/80`,children:[(0,K.jsx)(`strong`,{children:`Office`}),` — All paths are relative to the workspace root. Requires Office App Mode enabled in the Katana.`]})}),n&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,K.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a2040] rounded-xl p-5 w-[28rem] max-h-[70vh] shadow-2xl flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-bold text-[#c8d0d8] flex items-center gap-2`,children:[d?(0,K.jsx)(b,{className:`w-4 h-4 text-[#10b981]`}):(0,K.jsx)(x,{className:`w-4 h-4 text-[#10b981]`}),d?`Select Source File`:`Select Destination Folder`]}),(0,K.jsx)(`button`,{onClick:()=>r(!1),className:`p-1 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,K.jsx)(se,{className:`w-4 h-4`})})]}),d&&(0,K.jsxs)(`p`,{className:`text-[9px] text-[#7a8899] mb-3`,children:[`Expand folders to find your file. Only `,(0,K.jsx)(`strong`,{className:`text-[#10b981]`,children:g.join(`, `)}),` files are selectable.`]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-0.5 min-h-[200px]`,children:o?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(k,{className:`w-5 h-5 text-[#10b981] animate-spin`})}):i.length===0?(0,K.jsx)(`p`,{className:`text-xs text-[#7a8899] text-center py-8`,children:`No files found in workspace`}):(0,K.jsxs)(K.Fragment,{children:[!d&&(0,K.jsxs)(`button`,{onClick:()=>y(``),className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left hover:bg-[#10b981]/10 transition-colors group`,children:[(0,K.jsx)(x,{className:`w-4 h-4 text-[#10b981]`}),(0,K.jsx)(`span`,{className:`text-xs text-[#c8d0d8] font-medium`,children:`/ (workspace root)`}),(0,K.jsx)(`span`,{className:`ml-auto text-[9px] text-[#10b981] opacity-0 group-hover:opacity-100 transition-opacity`,children:`Select`})]}),i.map(e=>w(e,0))]})})]})})]})}function yp(e,t){for(let n of e)if(n.type===`file`&&t.includes((n.extension||``).toLowerCase())||n.type===`directory`&&n.children&&yp(n.children,t))return!0;return!1}function bp({label:e,value:t,onChange:n,placeholder:r}){let[i,a]=(0,G.useState)(JSON.stringify(t||{},null,2)),[o,s]=(0,G.useState)(``);return(0,G.useEffect)(()=>a(JSON.stringify(t||{},null,2)),[t]),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:e}),(0,K.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),onBlur:()=>{try{let e=JSON.parse(i||`{}`);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`Use a JSON object`);n(e),s(``)}catch(e){s(e instanceof Error?e.message:`Invalid JSON`)}},rows:5,spellCheck:!1,placeholder:r,className:U(`w-full bg-[#0a0e1a] border rounded-lg p-2 text-[10px] font-mono text-[#c8d0d8] outline-none resize-y`,o?`border-[#ef4444]`:`border-[#1a2040] focus:border-[#8b5cf6]`)}),o&&(0,K.jsx)(`p`,{className:`text-[8px] text-[#ef4444]`,children:o})]})}function xp({node:e,onUpdate:t,onClose:n,agents:r,routingProfiles:i,flowId:a,flows:o}){let c=e.type||`samurai`,l=lp[c]||`#d4a017`,u=up[c]||oe,d=e.data?.config||{},f=d.memory_infusion||{},[p,h]=(0,G.useState)(null),[g,_]=(0,G.useState)(!1),v=(n,r)=>{t(e.id,{...e.data,config:{...d,[n]:r}})},y=n=>{t(e.id,{...e.data,label:n})},x=(e,t)=>{v(`memory_infusion`,{...f,[e]:t})};return(0,K.jsxs)(`div`,{className:`w-full bg-[#050508] border-l border-[#1a2040] h-full flex flex-col overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-[#1a2040] flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-7 h-7 rounded-lg flex items-center justify-center`,style:{background:`${l}15`,border:`1px solid ${l}30`},children:(0,K.jsx)(u,{className:`w-4 h-4`,style:{color:l}})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8]`,children:`Node Properties`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest`,style:{color:l},children:c.replace(`_`,` `)})]})]}),(0,K.jsx)(`button`,{onClick:n,className:`p-1.5 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,K.jsx)(se,{className:`w-3.5 h-3.5`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Label`}),(0,K.jsx)(`input`,{type:`text`,value:e.data?.label||``,onChange:e=>y(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none`})]}),c===`samurai`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[`Linked Fleet Samurai `,(0,K.jsx)(`span`,{className:`text-[#d4a017]/70 font-normal normal-case tracking-normal`,children:`(Optional)`})]}),(0,K.jsxs)(`select`,{value:d.agent_id||``,onChange:e=>v(`agent_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:`Use Ephemeral / Ad-Hoc Samurai`}),r.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899] leading-tight`,children:`Leave unlinked to spawn a temporary Samurai that won't clutter your Fleet.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Task Description`}),(0,K.jsx)(`textarea`,{value:d.task_description||``,onChange:e=>v(`task_description`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none resize-y min-h-[60px]`,placeholder:`Describe what this Samurai should do...`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Expected Output`}),(0,K.jsx)(`input`,{type:`text`,value:d.expected_output||``,onChange:e=>v(`expected_output`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`,placeholder:`e.g., JSON report, markdown summary...`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(ce,{className:`w-3 h-3 text-[#d4a017]/70`}),` Routing Profile`]}),(0,K.jsxs)(`select`,{value:d.routing_profile_id||``,onChange:e=>v(`routing_profile_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:`System default`}),i.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Timeout (s)`}),(0,K.jsx)(`input`,{type:`number`,value:d.timeout||300,onChange:e=>v(`timeout`,parseInt(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Retries`}),(0,K.jsx)(`input`,{type:`number`,value:d.retry_count||0,onChange:e=>v(`retry_count`,parseInt(e.target.value)),min:0,max:5,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`On Failure`}),(0,K.jsxs)(`select`,{value:d.failure_action||`stop`,onChange:e=>v(`failure_action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`stop`,children:`Stop workflow`}),(0,K.jsx)(`option`,{value:`retry`,children:`Retry`}),(0,K.jsx)(`option`,{value:`skip`,children:`Skip and continue`}),(0,K.jsx)(`option`,{value:`escalate`,children:`Escalate to Shogun`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Context Injection`}),(0,K.jsx)(`textarea`,{value:d.context_injection||``,onChange:e=>v(`context_injection`,e.target.value),rows:2,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none resize-none`,placeholder:`Additional context to inject...`})]})]}),c===`shogun_approval`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Approval Mode`}),(0,K.jsxs)(`select`,{value:d.approval_mode||`manual`,onChange:e=>v(`approval_mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`manual`,children:`Manual Human Approval`}),(0,K.jsx)(`option`,{value:`ai_assisted`,children:`AI-Assisted Approval`}),(0,K.jsx)(`option`,{value:`policy_based`,children:`Policy-Based Approval`}),(0,K.jsx)(`option`,{value:`confidence_threshold`,children:`Confidence Threshold`})]})]}),d.approval_mode===`confidence_threshold`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Confidence Threshold (%)`}),(0,K.jsx)(`input`,{type:`number`,value:d.confidence_threshold||85,onChange:e=>v(`confidence_threshold`,parseInt(e.target.value)),min:0,max:100,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Escalation Action`}),(0,K.jsxs)(`select`,{value:d.escalation_action||`notify`,onChange:e=>v(`escalation_action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`notify`,children:`Notify operator`}),(0,K.jsx)(`option`,{value:`block`,children:`Block until manual review`}),(0,K.jsx)(`option`,{value:`reroute`,children:`Reroute for revision`}),(0,K.jsx)(`option`,{value:`stop`,children:`Stop workflow`})]})]})]}),c===`logic`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Condition Expression`}),(0,K.jsx)(`textarea`,{value:d.condition_expression||``,onChange:e=>v(`condition_expression`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#a78bfa] font-mono focus:border-[#a78bfa] transition-colors outline-none resize-none`,placeholder:`e.g., confidence > 85%`})]}),(0,K.jsx)(`div`,{className:`p-2.5 bg-[#a78bfa]/5 border border-[#a78bfa]/20 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-[8px] text-[#a78bfa]/80`,children:[(0,K.jsx)(`strong`,{children:`Right handle →`}),` TRUE branch`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`strong`,{children:`Bottom handle ↓`}),` FALSE branch`]})})]}),c===`input`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Input Type`}),(0,K.jsxs)(`select`,{value:d.input_type||`manual`,onChange:e=>v(`input_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`manual`,children:`Manual Input`}),(0,K.jsx)(`option`,{value:`document`,children:`Document Upload`}),(0,K.jsx)(`option`,{value:`api`,children:`API Trigger`}),(0,K.jsx)(`option`,{value:`scheduled`,children:`Scheduled Trigger`}),(0,K.jsx)(`option`,{value:`event`,children:`Event-Based Trigger`}),(0,K.jsx)(`option`,{value:`nexus`,children:`Nexus Task`})]})]}),d.input_type===`scheduled`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(s,{className:`w-3 h-3`}),` Frequency`]}),(0,K.jsxs)(`select`,{value:d.schedule_frequency||`nightly`,onChange:e=>v(`schedule_frequency`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`hourly`,children:`Hourly`}),(0,K.jsx)(`option`,{value:`nightly`,children:`Daily (Nightly)`}),(0,K.jsx)(`option`,{value:`weekly`,children:`Weekly`}),(0,K.jsx)(`option`,{value:`monthly`,children:`Monthly`})]})]}),d.schedule_frequency!==`hourly`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(m,{className:`w-3 h-3`}),` Run Time`]}),(0,K.jsx)(`input`,{type:`time`,value:d.schedule_time||`07:00`,onChange:e=>v(`schedule_time`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`})]}),d.schedule_frequency===`hourly`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Minute Offset`}),(0,K.jsx)(`input`,{type:`number`,min:0,max:59,value:d.schedule_minute_offset??0,onChange:e=>v(`schedule_minute_offset`,parseInt(e.target.value)||0),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`,placeholder:`0`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Runs at this minute past every hour (0–59)`})]}),d.schedule_frequency===`weekly`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Days of Week`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`].map(e=>{let t=d.schedule_days||[`mon`,`tue`,`wed`,`thu`,`fri`],n=t.includes(e);return(0,K.jsx)(`button`,{type:`button`,onClick:()=>{let r=n?t.filter(t=>t!==e):[...t,e];v(`schedule_days`,r.length?r:[e])},className:U(`px-2 py-1 rounded text-[9px] font-bold uppercase tracking-wider transition-all cursor-pointer border`,n?`bg-[#22c55e]/15 border-[#22c55e]/40 text-[#22c55e]`:`bg-[#0a0e1a] border-[#1a2040] text-[#555] hover:border-[#2a3060]`),children:e},e)})})]}),d.schedule_frequency===`monthly`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Day of Month`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:28,value:d.schedule_day||1,onChange:e=>v(`schedule_day`,parseInt(e.target.value)||1),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Day 1–28 (avoids month-length issues)`})]}),(0,K.jsx)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5`,children:(0,K.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,K.jsx)(`strong`,{children:`Note:`}),` Saving a scheduled trigger activates the flow and registers it with the job scheduler.`]})})]}),d.input_type===`document`&&(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(ae,{className:`w-3 h-3`}),` Upload Document`]}),(0,K.jsx)(`div`,{className:U(`border-2 border-dashed rounded-xl p-4 text-center cursor-pointer transition-all duration-200`,`hover:border-[#22c55e]/50 hover:bg-[#22c55e]/5`,d.uploaded_file?`border-[#22c55e]/30 bg-[#22c55e]/5`:`border-[#1a2040] bg-[#0a0e1a]`),onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`.pdf,.txt,.csv,.json,.md,.docx,.xlsx`,e.onchange=async e=>{let t=e.target.files?.[0];if(!t)return;let n=new FormData;n.append(`file`,t);try{let e=(await W.post(`/api/v1/agent-flows/${a}/upload`,n)).data?.data;v(`uploaded_file`,{filename:e?.filename||t.name,size:t.size,path:e?.path||``})}catch{v(`uploaded_file`,{filename:t.name,size:t.size,path:``,error:`Upload failed`})}},e.click()},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:async e=>{e.preventDefault(),e.stopPropagation();let t=e.dataTransfer.files?.[0];if(!t)return;let n=new FormData;n.append(`file`,t);try{let e=(await W.post(`/api/v1/agent-flows/${a}/upload`,n)).data?.data;v(`uploaded_file`,{filename:e?.filename||t.name,size:t.size,path:e?.path||``})}catch{v(`uploaded_file`,{filename:t.name,size:t.size,path:``,error:`Upload failed`})}},children:d.uploaded_file?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(b,{className:`w-6 h-6 mx-auto text-[#22c55e]`}),(0,K.jsx)(`p`,{className:`text-[10px] font-bold text-[#c8d0d8] truncate`,children:d.uploaded_file.filename}),(0,K.jsxs)(`p`,{className:`text-[8px] text-[#555]`,children:[(d.uploaded_file.size/1024).toFixed(1),` KB`]}),(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),v(`uploaded_file`,null)},className:`text-[8px] text-[#ef4444] hover:text-[#ef4444]/80 font-bold uppercase tracking-wider cursor-pointer`,children:`Remove`})]}):(0,K.jsxs)(`div`,{className:`space-y-1.5 py-2`,children:[(0,K.jsx)(ae,{className:`w-6 h-6 mx-auto text-[#555]`}),(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899] font-bold`,children:`Drag & drop or click to upload`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`PDF, TXT, CSV, JSON, MD, DOCX, XLSX`})]})})]})}),(!d.input_type||d.input_type===`manual`)&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Initial Context`}),(0,K.jsx)(`textarea`,{value:d.manual_input||``,onChange:e=>v(`manual_input`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none resize-y min-h-[60px]`,placeholder:`Enter initial context or instructions for the flow...`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`This text is passed as input when the flow runs`})]}),d.input_type===`api`&&(()=>{let[e,t]=(0,G.useState)(!1),[n,r]=(0,G.useState)([]);(0,G.useEffect)(()=>{let e=!1;return t(!0),W.get(`/api/v1/tools`).then(t=>{e||r(t.data?.data||[])}).catch(()=>{}).finally(()=>{e||t(!1)}),()=>{e=!0}},[]);let i=n.find(e=>e.id===d.api_tool_id);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(ce,{className:`w-3 h-3`}),` API Source`]}),(0,K.jsxs)(`select`,{value:d.api_tool_id||``,onChange:e=>{let t=n.find(t=>t.id===e.target.value);v(`api_tool_id`,e.target.value||null),v(`api_tool_name`,t?.name||null),v(`api_base_url`,t?.base_url||null)},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:`— Webhook (direct POST) —`}),e&&(0,K.jsx)(`option`,{disabled:!0,children:`Loading connectors...`}),n.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.connector_type,`)`,e.base_url?` · ${e.base_url}`:``]},e.id))]}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:d.api_tool_id?`This flow triggers via the selected API connector`:`Select a connector or use the direct webhook URL below`})]}),i&&(0,K.jsxs)(`div`,{className:`bg-[#06b6d4]/5 border border-[#06b6d4]/20 rounded-lg p-2.5 space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[9px] font-bold text-[#06b6d4]`,children:i.name}),(0,K.jsx)(`span`,{className:U(`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded`,i.status===`active`?`text-green-400 bg-green-500/10`:`text-[#555] bg-[#0a0e1a]`),children:i.status})]}),i.base_url&&(0,K.jsx)(`p`,{className:`text-[8px] text-[#555] font-mono truncate`,children:i.base_url})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(O,{className:`w-3 h-3`}),` Webhook URL`]}),(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[(0,K.jsx)(`input`,{type:`text`,readOnly:!0,value:`${window.location.origin}/api/v1/agent-flows/${a}/runs`,className:`flex-1 bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#7a8899] font-mono outline-none select-all`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/api/v1/agent-flows/${a}/runs`)},className:`p-2 bg-[#0a0e1a] border border-[#1a2040] rounded-lg hover:border-[#22c55e]/40 transition-colors cursor-pointer`,title:`Copy URL`,children:(0,K.jsx)(pe,{className:`w-3 h-3 text-[#7a8899]`})})]})]}),(0,K.jsxs)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5 space-y-1.5`,children:[(0,K.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,K.jsx)(`strong`,{children:`Usage:`}),` Send a `,(0,K.jsx)(`code`,{className:`bg-[#0a0e1a] px-1 py-0.5 rounded text-[8px]`,children:`POST`}),` request with a JSON body to trigger this flow.`]}),(0,K.jsx)(`pre`,{className:`text-[8px] text-[#555] font-mono bg-[#0a0e1a] p-2 rounded overflow-x-auto`,children:`POST /api/v1/agent-flows/${a}/runs -Content-Type: application/json - -{ "trigger_type": "api" }`})]})]})})(),d.input_type===`event`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(_e,{className:`w-3 h-3`}),` Event Source`]}),(0,K.jsxs)(`select`,{value:d.event_source||`email`,onChange:e=>v(`event_source`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`email`,children:`Email Received`}),(0,K.jsx)(`option`,{value:`bushido`,children:`Bushido Schedule`}),(0,K.jsx)(`option`,{value:`system`,children:`System Event`}),(0,K.jsx)(`option`,{value:`custom`,children:`Custom Event`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Event Filter`}),(0,K.jsx)(`input`,{type:`text`,value:d.event_filter||``,onChange:e=>v(`event_filter`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`,placeholder:d.event_source===`email`?`from:*@client.com`:d.event_source===`system`?`event_type:agent.deployed`:`filter expression...`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Optional filter to narrow which events trigger this flow`})]}),(0,K.jsxs)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5 space-y-1`,children:[(0,K.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,K.jsx)(`strong`,{children:`How it works:`}),` When a matching event is captured by the Shogun Event Logger, this flow will be triggered automatically.`]}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555] leading-relaxed`,children:`Events are emitted by all subsystems — email sync, agent actions, Bushido schedules, browser automation, and system heartbeats.`})]})]}),d.input_type===`nexus`&&(()=>{let[e,t]=(0,G.useState)(!1),[n,r]=(0,G.useState)([]);return(0,G.useEffect)(()=>{let e=!1;return t(!0),W.get(`/api/v1/workspaces`).then(t=>{e||r(t.data?.data||[])}).catch(()=>{}).finally(()=>{e||t(!1)}),()=>{e=!0}},[]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,K.jsx)(ce,{className:`w-3 h-3`}),` Nexus Workspace`]}),(0,K.jsxs)(`select`,{value:d.nexus_workspace_id||``,onChange:e=>v(`nexus_workspace_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:`— Select workspace —`}),e&&(0,K.jsx)(`option`,{disabled:!0,children:`Loading...`}),n.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,e.topic?` (${e.topic})`:``]},e.id))]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Trigger on Message Type`}),(0,K.jsxs)(`select`,{value:d.nexus_message_type||`task`,onChange:e=>v(`nexus_message_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`task`,children:`Task messages`}),(0,K.jsx)(`option`,{value:`proposal`,children:`Proposals`}),(0,K.jsx)(`option`,{value:`signal`,children:`Signals / Alerts`}),(0,K.jsx)(`option`,{value:`any`,children:`Any message`})]}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`This flow triggers when a matching message arrives in the workspace`})]}),(0,K.jsx)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5 space-y-1`,children:(0,K.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,K.jsx)(`strong`,{children:`How it works:`}),` When a `,(0,K.jsx)(`code`,{className:`bg-[#0a0e1a] px-1 py-0.5 rounded text-[8px]`,children:d.nexus_message_type||`task`}),` message arrives in the linked workspace, the message content is passed as input to this flow.`]})})]})})(),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Description`}),(0,K.jsx)(`textarea`,{value:d.description||``,onChange:e=>v(`description`,e.target.value),rows:2,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none resize-y min-h-[44px]`,placeholder:`Describe the input...`})]})]}),c===`output`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Output Type`}),(0,K.jsxs)(`select`,{value:d.output_type||`artifact`,onChange:e=>v(`output_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`artifact`,children:`Artifact / Report`}),(0,K.jsx)(`option`,{value:`export`,children:`Export File`}),(0,K.jsx)(`option`,{value:`api`,children:`API Response`}),(0,K.jsx)(`option`,{value:`notification`,children:`Notification`}),(0,K.jsx)(`option`,{value:`memory`,children:`Store in Memory`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Format`}),(0,K.jsxs)(`select`,{value:d.format||`markdown`,onChange:e=>v(`format`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`markdown`,children:`Markdown`}),(0,K.jsx)(`option`,{value:`json`,children:`JSON`}),(0,K.jsx)(`option`,{value:`html`,children:`HTML`}),(0,K.jsx)(`option`,{value:`plain`,children:`Plain Text`})]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-[#f97316]/25 bg-[#f97316]/5 p-3 space-y-3`,children:[(0,K.jsxs)(`label`,{className:`flex items-center justify-between gap-3 cursor-pointer`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`block text-[9px] font-bold text-[#f97316] uppercase tracking-widest`,children:`Memory Infusion`}),(0,K.jsx)(`span`,{className:`block text-[8px] text-[#7a8899] mt-1`,children:`Store this output mechanically in Archives`})]}),(0,K.jsx)(`input`,{type:`checkbox`,checked:f.enabled===!0,onChange:e=>v(`memory_infusion`,{memory_type:`episodic`,importance:.8,decay_type:`sticky`,tags:[`auto-stored`,`flow-output`],title_template:`{flow_name} - {timestamp}`,content_fields:[`result`,`summary`],redact_sensitive:!0,on_missing_field:`store_available`,max_content_length:12e3,store_on:`success`,deduplication:{mode:`exact`,semantic_threshold:.92},...f,enabled:e.target.checked}),className:`accent-[#f97316]`})]}),f.enabled===!0&&(0,K.jsxs)(`div`,{className:`space-y-3 border-t border-[#f97316]/15 pt-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Memory type`,(0,K.jsx)(`select`,{value:f.memory_type||`episodic`,onChange:e=>x(`memory_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[`episodic`,`semantic`,`procedural`,`persona`].map(e=>(0,K.jsx)(`option`,{children:e},e))})]}),(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Decay`,(0,K.jsx)(`select`,{value:f.decay_type||`sticky`,onChange:e=>x(`decay_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[`fast`,`medium`,`slow`,`sticky`,`pinned`].map(e=>(0,K.jsx)(`option`,{children:e},e))})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Importance`,(0,K.jsx)(`input`,{type:`number`,min:0,max:1,step:.05,value:f.importance??.8,onChange:e=>x(`importance`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`})]}),(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Store on`,(0,K.jsxs)(`select`,{value:f.store_on||`success`,onChange:e=>x(`store_on`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[(0,K.jsx)(`option`,{value:`success`,children:`Success`}),(0,K.jsx)(`option`,{value:`partial`,children:`Partial`}),(0,K.jsx)(`option`,{value:`always`,children:`Always`})]})]})]}),(0,K.jsxs)(`label`,{className:`block space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Title template`,(0,K.jsx)(`input`,{value:f.title_template||`{flow_name} - {timestamp}`,onChange:e=>x(`title_template`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] normal-case text-[#c8d0d8] outline-none`})]}),(0,K.jsxs)(`label`,{className:`block space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Content fields`,(0,K.jsx)(`input`,{value:(f.content_fields||[`result`,`summary`]).join(`, `),onChange:e=>x(`content_fields`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] normal-case text-[#c8d0d8] outline-none`})]}),(0,K.jsxs)(`label`,{className:`block space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Tags`,(0,K.jsx)(`input`,{value:(f.tags||[`auto-stored`,`flow-output`]).join(`, `),onChange:e=>x(`tags`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] normal-case text-[#c8d0d8] outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Missing fields`,(0,K.jsxs)(`select`,{value:f.on_missing_field||`store_available`,onChange:e=>x(`on_missing_field`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[(0,K.jsx)(`option`,{value:`store_available`,children:`Store available`}),(0,K.jsx)(`option`,{value:`skip`,children:`Skip memory`}),(0,K.jsx)(`option`,{value:`fail`,children:`Fail node`})]})]}),(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Max characters`,(0,K.jsx)(`input`,{type:`number`,min:256,max:1e5,value:f.max_content_length||12e3,onChange:e=>x(`max_content_length`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Deduplication`,(0,K.jsxs)(`select`,{value:f.deduplication?.mode||`exact`,onChange:e=>x(`deduplication`,{semantic_threshold:.92,...f.deduplication,mode:e.target.value}),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[(0,K.jsx)(`option`,{value:`none`,children:`None`}),(0,K.jsx)(`option`,{value:`exact`,children:`Exact hash`}),(0,K.jsx)(`option`,{value:`semantic`,children:`Semantic`})]})]}),f.deduplication?.mode===`semantic`&&(0,K.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Similarity`,(0,K.jsx)(`input`,{type:`number`,min:.5,max:1,step:.01,value:f.deduplication?.semantic_threshold??.92,onChange:e=>x(`deduplication`,{...f.deduplication,mode:`semantic`,semantic_threshold:Number(e.target.value)}),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-[9px] text-[#c8d0d8] cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:f.redact_sensitive!==!1,onChange:e=>x(`redact_sensitive`,e.target.checked),className:`accent-[#f97316]`}),`Redact credentials and secrets before storage`]})]})]})]}),c===`coding`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`rounded-lg border border-[#14b8a6]/20 bg-[#14b8a6]/5 p-2.5 text-[9px] leading-relaxed text-[#8adbd1]`,children:`Coding nodes use governed IDE Mode. Workspace actions require Campaign or Ronin posture, an approved workspace, and the matching IDE permissions.`}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,K.jsxs)(`select`,{value:d.action||`analyze`,onChange:e=>v(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none`,children:[(0,K.jsx)(`option`,{value:`analyze`,children:`Analyze / Plan`}),(0,K.jsx)(`option`,{value:`list_files`,children:`List Repository Files`}),(0,K.jsx)(`option`,{value:`search`,children:`Search Code`}),(0,K.jsx)(`option`,{value:`read_file`,children:`Read File`}),(0,K.jsx)(`option`,{value:`apply_patch`,children:`Write / Replace File`}),(0,K.jsx)(`option`,{value:`run_task`,children:`Run Test / Build Task`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Task Description`}),(0,K.jsx)(`textarea`,{value:d.task_description||``,onChange:e=>v(`task_description`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none resize-y`,placeholder:`Describe the coding objective and acceptance criteria...`})]}),d.action!==`analyze`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Approved Workspace ID`}),(0,K.jsx)(`input`,{value:d.workspace_id||``,onChange:e=>v(`workspace_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none`,placeholder:`VS Code workspace UUID`})]}),(d.action===`read_file`||d.action===`apply_patch`)&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Workspace-relative Path`}),(0,K.jsx)(`input`,{value:d.path||``,onChange:e=>v(`path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none font-mono`,placeholder:`src/module.py`})]}),d.action===`search`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsx)(`input`,{value:d.query||``,onChange:e=>v(`query`,e.target.value),className:`bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,placeholder:`Search text`}),(0,K.jsx)(`input`,{value:d.file_glob||`*`,onChange:e=>v(`file_glob`,e.target.value),className:`bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,placeholder:`*.py`})]}),d.action===`apply_patch`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Complete File Content`}),(0,K.jsx)(`textarea`,{value:d.content_template||``,onChange:e=>v(`content_template`,e.target.value),rows:7,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#c8d0d8] font-mono outline-none`,placeholder:`Use {{context}} to insert predecessor output.`})]}),d.action===`run_task`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Allowlisted Command`}),(0,K.jsx)(`input`,{value:d.command||``,onChange:e=>v(`command`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] font-mono outline-none`,placeholder:`pytest tests/test_feature.py`})]}),(0,K.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-[#1a2040] bg-[#0a0e1a] p-2.5 text-[10px] text-[#c8d0d8]`,children:[`Recall project programming memory`,(0,K.jsx)(`input`,{type:`checkbox`,checked:d.recall_memory!==!1,onChange:e=>v(`recall_memory`,e.target.checked)})]}),d.action===`run_task`&&(0,K.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-[#1a2040] bg-[#0a0e1a] p-2.5 text-[10px] text-[#c8d0d8]`,children:[`Remember successful verified result`,(0,K.jsx)(`input`,{type:`checkbox`,checked:!!d.remember_on_success,onChange:e=>v(`remember_on_success`,e.target.checked)})]})]}),c===`subflow`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rounded-lg border border-[#8b5cf6]/25 bg-[#8b5cf6]/5 p-3`,children:[(0,K.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-widest text-[#8b5cf6]`,children:`Governed child execution`}),(0,K.jsx)(`p`,{className:`mt-1 text-[9px] leading-relaxed text-[#7a8899]`,children:`The child inherits this run's posture, permission ceiling, audit context, and cancellation state.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Child Flow`}),(0,K.jsxs)(`select`,{value:d.child_flow_id||``,onChange:n=>{let r=o.find(e=>e.id===n.target.value);t(e.id,{...e.data,config:{...d,child_flow_id:r?.id||``,child_flow_name:r?.name||``,child_flow_version:r?.version||null,child_flow_version_mode:d.child_flow_version_mode||`locked`,execution_mode:`sequential`,timeout_seconds:d.timeout_seconds||600,on_failure:d.on_failure||`fail_parent`}}),h(null)},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:`Select a reusable flow...`}),o.filter(e=>e.id!==a).map(e=>(0,K.jsxs)(`option`,{value:e.id,disabled:!e.allow_as_subflow,children:[e.name,` · v`,e.version,` · `,e.risk_tier,e.allow_as_subflow?``:` · blocked`]},e.id))]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Version`}),(0,K.jsxs)(`select`,{value:d.child_flow_version_mode||`locked`,onChange:e=>v(`child_flow_version_mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`,children:[(0,K.jsx)(`option`,{value:`locked`,children:`Locked`}),(0,K.jsx)(`option`,{value:`latest`,children:`Latest`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Timeout`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:86400,value:d.timeout_seconds||600,onChange:e=>v(`timeout_seconds`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Failure Policy`}),(0,K.jsxs)(`select`,{value:d.on_failure||`fail_parent`,onChange:e=>v(`on_failure`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`,children:[(0,K.jsx)(`option`,{value:`fail_parent`,children:`Fail parent`}),(0,K.jsx)(`option`,{value:`continue_with_error`,children:`Continue with error`}),(0,K.jsx)(`option`,{value:`route_to_error`,children:`Route error downstream`})]})]}),(0,K.jsx)(bp,{label:`Input Mapping`,value:d.input_mapping||{},onChange:e=>v(`input_mapping`,e),placeholder:`{"topic": "{{input.topic}}"}`}),(0,K.jsx)(bp,{label:`Output Mapping`,value:d.output_mapping||{},onChange:e=>v(`output_mapping`,e),placeholder:`{"summary": "{{output.summary}}"}`}),(0,K.jsxs)(`button`,{type:`button`,disabled:!d.child_flow_id||g,onClick:async()=>{if(d.child_flow_id){_(!0);try{h((await W.post(`/api/v1/agent-flows/${a}/validate-subflow`,{child_flow_id:d.child_flow_id,child_flow_version_mode:d.child_flow_version_mode||`locked`,child_flow_version:d.child_flow_version||null})).data?.data||null)}catch(e){h({valid:!1,warnings:[],errors:[W.isAxiosError(e)?e.response?.data?.detail||e.message:`Validation failed`]})}finally{_(!1)}}},className:`w-full flex items-center justify-center gap-2 rounded-lg border border-[#8b5cf6]/30 bg-[#8b5cf6]/10 px-3 py-2 text-[9px] font-bold uppercase tracking-widest text-[#a78bfa] disabled:opacity-40`,children:[g?(0,K.jsx)(k,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(V,{className:`w-3 h-3`}),`Validate safety & governance`]}),p&&(0,K.jsxs)(`div`,{className:U(`rounded-lg border p-2.5 text-[9px]`,p.valid?`border-[#22c55e]/25 bg-[#22c55e]/5 text-[#22c55e]`:`border-[#ef4444]/25 bg-[#ef4444]/5 text-[#ef4444]`),children:[(0,K.jsx)(`p`,{className:`font-bold uppercase tracking-wider`,children:p.valid?`Reference is safe`:`Reference is blocked`}),[...p.warnings,...p.errors].map((e,t)=>(0,K.jsx)(`p`,{className:`mt-1 opacity-80`,children:e},t))]})]}),c===`stack_orchestrator`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rounded-lg border border-[#c084fc]/25 bg-[#c084fc]/5 p-3`,children:[(0,K.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-widest text-[#c084fc]`,children:`Runtime control layer`}),(0,K.jsx)(`p`,{className:`mt-1 text-[9px] leading-relaxed text-[#7a8899]`,children:`Supervises Agent Stacks through persistent state, checkpoints, verification, retries and inherited posture permissions. Concrete work remains in Agent Flow.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Execution Mode`}),(0,K.jsxs)(`select`,{value:d.mode||`selected_stack`,onChange:e=>v(`mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`,children:[(0,K.jsx)(`option`,{value:`selected_stack`,children:`Selected Agent Stack`}),(0,K.jsx)(`option`,{value:`template`,children:`Stack Template`}),(0,K.jsx)(`option`,{value:`goal_driven`,children:`Goal-driven plan`})]})]}),(d.mode||`selected_stack`)===`selected_stack`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Agent Stack`}),(0,K.jsxs)(`select`,{value:d.selected_stack_id||``,onChange:e=>v(`selected_stack_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:`Select an Agent Stack...`}),o.filter(e=>e.id!==a).map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.flow_type,` · `,e.risk_tier]},e.id))]})]}),d.mode===`template`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Stack Template ID`}),(0,K.jsx)(`input`,{value:d.stack_template_id||``,onChange:e=>v(`stack_template_id`,e.target.value),placeholder:`bug-fix-stack`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Objective`}),(0,K.jsx)(`textarea`,{value:d.objective||``,onChange:e=>v(`objective`,e.target.value),rows:3,placeholder:`Describe the long-running outcome...`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none resize-y`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Success Criteria`}),(0,K.jsx)(`textarea`,{value:(d.success_criteria||[]).join(` -`),onChange:e=>v(`success_criteria`,e.target.value.split(` -`).map(e=>e.trim()).filter(Boolean)),rows:3,placeholder:`One criterion per line -Tests pass -Artifacts verified`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none resize-y`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Allowed Tools`}),(0,K.jsx)(`input`,{value:(d.allowed_tools||[]).join(`, `),onChange:e=>v(`allowed_tools`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),placeholder:`workspace, ide, mado`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`This list can only narrow the active posture. IDE and Ronin permissions must also be explicitly enabled.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Model Routing Profile`}),(0,K.jsxs)(`select`,{value:d.model_routing_profile||`balanced`,onChange:e=>v(`model_routing_profile`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`,children:[(0,K.jsx)(`option`,{value:`balanced`,children:`Balanced`}),i.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Max Runtime (min)`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:1440,value:d.max_runtime_minutes||60,onChange:e=>v(`max_runtime_minutes`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Max Iterations`}),(0,K.jsx)(`input`,{type:`number`,min:1,max:500,value:d.max_iterations||50,onChange:e=>v(`max_iterations`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Retries / Step`}),(0,K.jsx)(`input`,{type:`number`,min:0,max:10,value:d.max_retry_attempts_per_step??2,onChange:e=>v(`max_retry_attempts_per_step`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Checkpoint`}),(0,K.jsxs)(`select`,{value:d.checkpoint_frequency||`after_each_step`,onChange:e=>v(`checkpoint_frequency`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,K.jsx)(`option`,{value:`after_each_step`,children:`Each step`}),(0,K.jsx)(`option`,{value:`after_each_subflow`,children:`Each subflow`}),(0,K.jsx)(`option`,{value:`timed`,children:`Timed`})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border border-[#1a2040] p-2 text-[9px] text-[#c8d0d8]`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:d.context_compaction!==!1,onChange:e=>v(`context_compaction`,e.target.checked)}),` Context compaction`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border border-[#1a2040] p-2 text-[9px] text-[#c8d0d8]`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:d.verification_required!==!1,onChange:e=>v(`verification_required`,e.target.checked)}),` Verification required`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Approval Policy`}),(0,K.jsxs)(`select`,{value:d.approval_policy||`inherited`,onChange:e=>v(`approval_policy`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,K.jsx)(`option`,{value:`inherited`,children:`Inherited`}),(0,K.jsx)(`option`,{value:`step_based`,children:`Step based`}),(0,K.jsx)(`option`,{value:`always_required_for_high_risk`,children:`Always for high risk`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Failure Policy`}),(0,K.jsxs)(`select`,{value:d.failure_policy||`pause`,onChange:e=>v(`failure_policy`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,K.jsx)(`option`,{value:`pause`,children:`Pause`}),(0,K.jsx)(`option`,{value:`retry`,children:`Retry`}),(0,K.jsx)(`option`,{value:`continue_with_error`,children:`Continue with error`}),(0,K.jsx)(`option`,{value:`fail_stack`,children:`Fail stack`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Artifacts`}),(0,K.jsxs)(`select`,{value:d.artifact_policy||`retain_all`,onChange:e=>v(`artifact_policy`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,K.jsx)(`option`,{value:`retain_all`,children:`Retain all`}),(0,K.jsx)(`option`,{value:`retain_final_only`,children:`Final only`}),(0,K.jsx)(`option`,{value:`retain_selected`,children:`Selected`})]})]})]})]}),c===`mado_browser`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,K.jsxs)(`select`,{value:d.action||`navigate`,onChange:e=>v(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`navigate`,children:`Navigate to URL`}),(0,K.jsx)(`option`,{value:`extract_content`,children:`Extract Content`}),(0,K.jsx)(`option`,{value:`screenshot`,children:`Take Screenshot`}),(0,K.jsx)(`option`,{value:`fill_form`,children:`Fill Form`}),(0,K.jsx)(`option`,{value:`click`,children:`Click Element`}),(0,K.jsx)(`option`,{value:`execute_js`,children:`Execute JavaScript`}),(0,K.jsx)(`option`,{value:`wait_for`,children:`Wait for Element`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`URL`}),(0,K.jsx)(`input`,{type:`text`,value:d.url||``,onChange:e=>v(`url`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none`,placeholder:`https://example.com`})]}),(()=>{let n=[{value:`headlines`,label:`📰 All Headlines`,selector:`h1, h2, h3, h4, article h2, article h3`,desc:`Grabs all headline text from the page`},{value:`links`,label:`🔗 All Links`,selector:`a[href]`,desc:`Extracts every link on the page with its URL`},{value:`article`,label:`📄 Article Content`,selector:`article, [role="article"], .post-content, .entry-content, .article-body, main`,desc:`Main article text and body content`},{value:`news_cards`,label:`🗞️ News Cards`,selector:`article a, [data-n-tid] a, c-wiz article, [jslog] h3, [jslog] h4`,desc:`News feed cards (Google News, news aggregators)`},{value:`tables`,label:`📊 Tables & Data`,selector:`table, [role="table"], .data-table`,desc:`Structured tables and data grids`},{value:`images`,label:`🖼️ Images`,selector:`img[src], picture source`,desc:`All images with their source URLs`},{value:`lists`,label:`📋 Lists`,selector:`ul, ol, dl, [role="list"]`,desc:`Bullet points, numbered lists, and definition lists`},{value:`prices`,label:`💰 Prices & Products`,selector:`[class*="price"], [data-price], .product-card, .product-title`,desc:`Product names, prices, and e-commerce data`},{value:`full_page`,label:`📜 Full Page Text`,selector:`body`,desc:`Everything visible on the page`},{value:`custom`,label:`⚙️ Custom Selector`,selector:``,desc:`Write your own CSS selector`}],r=d.selector_preset||n.find(e=>e.selector===d.selector)?.value||(d.selector?`custom`:``),i=d.show_advanced_selector||r===`custom`,a=n.find(e=>e.value===r),o=n=>{t(e.id,{...e.data,config:{...d,...n}})};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`What to Extract`}),(0,K.jsxs)(`select`,{value:r,onChange:e=>{let t=n.find(t=>t.value===e.target.value);t&&t.value!==`custom`?o({selector:t.selector,selector_preset:t.value,show_advanced_selector:!1}):o({selector_preset:`custom`,show_advanced_selector:!0})},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:`— Choose what to extract —`}),n.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),a&&r!==`custom`&&(0,K.jsx)(`p`,{className:`text-[8px] text-[#06b6d4]/70`,children:a.desc})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Describe What You Need`}),(0,K.jsx)(`textarea`,{value:d.extract_hint||``,onChange:e=>v(`extract_hint`,e.target.value),rows:2,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none resize-y min-h-[40px]`,placeholder:`e.g. "Get all article titles and their links" or "Find product prices"`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Optional — helps the AI understand what to look for in the extracted content`})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>v(`show_advanced_selector`,!i),className:`flex items-center gap-1.5 text-[8px] font-bold text-[#555] hover:text-[#7a8899] uppercase tracking-widest transition-colors cursor-pointer`,children:[(0,K.jsx)(`span`,{className:`transition-transform`,style:{transform:i?`rotate(90deg)`:`rotate(0deg)`},children:`▶`}),`Advanced: CSS Selector`]}),i&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`input`,{type:`text`,value:d.selector||``,onChange:e=>{o({selector:e.target.value,selector_preset:`custom`})},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#06b6d4] font-mono focus:border-[#06b6d4] transition-colors outline-none`,placeholder:`e.g., .main-content, #article, table`}),(0,K.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Raw CSS selector — for power users who know the page structure`})]})]})})(),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Session Name`}),(0,K.jsx)(`input`,{type:`text`,value:d.session_name||`flow_browser`,onChange:e=>v(`session_name`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none`,placeholder:`flow_browser`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Browser Mode`}),(0,K.jsxs)(`select`,{value:d.browser_mode||`headless`,onChange:e=>v(`browser_mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`headless`,children:`Headless`}),(0,K.jsx)(`option`,{value:`visible`,children:`Visible`})]})]}),d.action===`extract_content`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Extract Type`}),(0,K.jsxs)(`select`,{value:d.extract_type||`text`,onChange:e=>v(`extract_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`text`,children:`Text`}),(0,K.jsx)(`option`,{value:`html`,children:`HTML`}),(0,K.jsx)(`option`,{value:`inner_text`,children:`Inner Text`})]})]}),d.action===`execute_js`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`JavaScript`}),(0,K.jsx)(`textarea`,{value:d.script||``,onChange:e=>v(`script`,e.target.value),rows:4,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#06b6d4] font-mono focus:border-[#06b6d4] transition-colors outline-none resize-none`,placeholder:`document.title`})]}),d.action===`wait_for`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Timeout (ms)`}),(0,K.jsx)(`input`,{type:`number`,value:d.timeout||1e4,onChange:e=>v(`timeout`,parseInt(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none`})]}),(0,K.jsx)(`div`,{className:`p-2.5 bg-[#06b6d4]/5 border border-[#06b6d4]/20 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-[8px] text-[#06b6d4]/80`,children:[(0,K.jsx)(`strong`,{children:`Mado 窓`}),` — Browser actions are governed by the Torii security posture. Domain allowlists and session limits apply.`]})})]}),c===`email_send`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`To Address`}),(0,K.jsx)(`input`,{type:`text`,value:d.to_address||``,onChange:e=>v(`to_address`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`recipient@example.com`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`CC Address`}),(0,K.jsx)(`input`,{type:`text`,value:d.cc_address||``,onChange:e=>v(`cc_address`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`cc@example.com`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`BCC Address`}),(0,K.jsx)(`input`,{type:`text`,value:d.bcc_address||``,onChange:e=>v(`bcc_address`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`bcc@example.com`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Subject`}),(0,K.jsx)(`input`,{type:`text`,value:d.subject||``,onChange:e=>v(`subject`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`Email subject line...`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Body Template`}),(0,K.jsx)(`textarea`,{value:d.body_template||``,onChange:e=>v(`body_template`,e.target.value),rows:4,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none resize-none`,placeholder:`Leave empty to use predecessor output as body. Use {{context}} to inject predecessor output into a template.`})]}),(0,K.jsx)(`div`,{className:`p-2.5 bg-[#e879a8]/5 border border-[#e879a8]/20 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-[8px] text-[#e879a8]/80`,children:[(0,K.jsx)(`strong`,{children:`Mail ✉`}),` — Sends via the SMTP account configured in the Mail page. Requires `,(0,K.jsx)(`code`,{className:`text-[#e879a8]`,children:`perm_send_mail`}),` to be enabled.`]})})]}),c===`channel_send`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Channel`}),(0,K.jsxs)(`select`,{value:d.channel||`both`,onChange:e=>v(`channel`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,children:[(0,K.jsx)(`option`,{value:`both`,children:`Telegram and Teams`}),(0,K.jsx)(`option`,{value:`telegram`,children:`Telegram`}),(0,K.jsx)(`option`,{value:`teams`,children:`Microsoft Teams`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Message Template`}),(0,K.jsx)(`textarea`,{value:d.message_template||``,onChange:e=>v(`message_template`,e.target.value),rows:4,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none resize-none`,placeholder:`Leave empty to send the predecessor output, or use {{context}} inside a message.`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Telegram Chat IDs (optional)`}),(0,K.jsx)(`input`,{type:`text`,value:(d.telegram_chat_ids||[]).join(`, `),onChange:e=>v(`telegram_chat_ids`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,placeholder:`Uses configured allowed chats when empty`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Telegram Topic Thread ID (optional)`}),(0,K.jsx)(`input`,{type:`number`,min:`1`,step:`1`,value:d.message_thread_id??``,onChange:e=>v(`message_thread_id`,e.target.value===``?null:Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,placeholder:`For example, 22 for the News topic`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Teams Conversation IDs (optional)`}),(0,K.jsx)(`input`,{type:`text`,value:(d.teams_conversation_ids||[]).join(`, `),onChange:e=>v(`teams_conversation_ids`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,placeholder:`Uses notification routes or known conversations when empty`})]})]}),c===`workspace`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,K.jsxs)(`select`,{value:d.action||`read_file`,onChange:e=>v(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,children:[(0,K.jsx)(`option`,{value:`read_file`,children:`Read File`}),(0,K.jsx)(`option`,{value:`write_file`,children:`Write File`}),(0,K.jsx)(`option`,{value:`list_files`,children:`List Files`}),(0,K.jsx)(`option`,{value:`mkdir`,children:`Create Directory`}),(0,K.jsx)(`option`,{value:`delete`,children:`Delete`}),(0,K.jsx)(`option`,{value:`copy`,children:`Copy`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Path`}),(0,K.jsx)(`input`,{type:`text`,value:d.path||``,onChange:e=>v(`path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,placeholder:`Input/myfile.txt (relative to workspace)`})]}),d.action===`copy`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Source Path`}),(0,K.jsx)(`input`,{type:`text`,value:d.source_path||``,onChange:e=>v(`source_path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,placeholder:`Input/source.txt`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Destination Path`}),(0,K.jsx)(`input`,{type:`text`,value:d.dest_path||``,onChange:e=>v(`dest_path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,placeholder:`Output/dest.txt`})]})]}),d.action===`write_file`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Content Template`}),(0,K.jsx)(`textarea`,{value:d.content_template||``,onChange:e=>v(`content_template`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none resize-none`,placeholder:`Leave empty to write predecessor output. Use {{context}} for predecessor data.`})]}),(0,K.jsx)(`div`,{className:`p-2.5 bg-[#f59e0b]/5 border border-[#f59e0b]/20 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-[8px] text-[#f59e0b]/80`,children:[(0,K.jsx)(`strong`,{children:`Workspace`}),` — All paths are relative to the agent workspace folder. Governed by the Torii security posture.`]})})]}),c===`office`&&(0,K.jsx)(vp,{config:d,updateConfig:v})]})]})}function Sp({flow:e,onBack:t,onFlowUpdate:n,agents:r,routingProfiles:i,availableFlows:a}){let o=$l(),s=(0,G.useRef)(null),c=(0,G.useMemo)(()=>(e.nodes||[]).map(e=>({id:e.id,type:e.node_type,position:{x:e.position_x,y:e.position_y},data:{label:e.label,config:e.config}})),[e.id]),l=(0,G.useMemo)(()=>(e.edges||[]).map(e=>({id:e.id,source:e.source_node_id,target:e.target_node_id,sourceHandle:e.source_handle,targetHandle:e.target_handle,type:`custom`,data:{label:e.label,edge_type:e.edge_type},markerEnd:{type:fo.ArrowClosed,color:`#4a8cc7`,width:16,height:16}})),[e.id]),[d,h,g]=rf(c),[_,v,y]=af(l),[b,x]=(0,G.useState)(null),[C,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(!1),[O,A]=(0,G.useState)(e.name),[j,N]=(0,G.useState)(!1),[F,I]=(0,G.useState)(e.status),[ee,te]=(0,G.useState)(!1);(0,G.useEffect)(()=>I(e.status),[e.id,e.status]),(0,G.useEffect)(()=>{$(`agent_flow.canvas.mount`,{flowId:e.id,flowName:e.name,nodes:e.nodes?.length||0,edges:e.edges?.length||0,agents:r.length,routingProfiles:i.length})},[e.id]);let[B,ne]=(0,G.useState)(null),[V,H]=(0,G.useState)(null),[ie,ae]=(0,G.useState)({}),[oe,ce]=(0,G.useState)(null),[le,de]=(0,G.useState)(!1),[pe,me]=(0,G.useState)(!1),[he,ge]=(0,G.useState)([]),[_e,q]=(0,G.useState)(null),[J,ye]=(0,G.useState)(null),[be,xe]=(0,G.useState)(null),[Se,Ce]=(0,G.useState)(!1),[we,Te]=(0,G.useState)(null),Ee=(0,G.useRef)(null),De=(0,G.useCallback)(async(e,t)=>{q(e),Ce(!0);try{let[t,n]=await Promise.all([W.get(`/api/v1/agent-flows/runs/${e}`),W.get(`/api/v1/agent-flows/runs/${e}/tree`)]),r=t.data?.data||null;return ye(r),xe(n.data?.data||null),r}catch(e){return console.error(e),ye(t?{status:`completed`,trigger_type:`manual`,result_summary:{[t.label]:t.content}}:null),xe(null),null}finally{Ce(!1)}},[]),Oe=(0,G.useCallback)(e=>{if(e.runId){De(e.runId,{label:e.label,content:e.content});return}q(`node-output`),ye({status:`completed`,trigger_type:`manual`,result_summary:{[e.label]:e.content}}),xe(null)},[De]),ke=(0,G.useMemo)(()=>({view:Oe,runId:oe,nodeStates:ie}),[oe,Oe,ie]),Ae=(0,G.useCallback)(async()=>{try{ge((await W.get(`/api/v1/agent-flows/${e.id}/runs?limit=20`)).data?.data||[])}catch{}},[e.id]),je=(0,G.useCallback)(t=>{let n={...t.node_states||{}};t.status===`completed`&&(e.nodes||[]).forEach(e=>{if(e.node_type!==`output`)return;let r=e.label||``,i=t.result_summary?.[r],a=n[e.id]||{};n[e.id]={...a,status:`completed`,output:a.output??i??`The run completed, but no output text was returned.`}}),H(t.status),ae(n),ce(t.id||null),h(e=>e.map(e=>{let r=n[e.id],i=typeof e.data?.label==`string`?e.data.label:``,a=e.type===`output`?t.result_summary?.[i]:void 0,o=r?.output??a??null;return{...e,className:r?.status===`running`?`agent-flow-node-running`:void 0,style:{...e.style||{},"--agent-flow-active-color":lp[e.type||``]||`#d4a017`,"--agent-flow-glow-strong":`${lp[e.type||``]||`#d4a017`}66`,"--agent-flow-glow-medium":`${lp[e.type||``]||`#d4a017`}3d`,"--agent-flow-glow-soft":`${lp[e.type||``]||`#d4a017`}1a`,"--agent-flow-glow-faint":`${lp[e.type||``]||`#d4a017`}12`},data:{...e.data,execution_status:r?.status||null,execution_output:o,execution_run_id:t.id||null}}}))},[e.nodes,h]);(0,G.useEffect)(()=>{(async()=>{try{let t=(await W.get(`/api/v1/agent-flows/${e.id}/runs?limit=1`)).data?.data?.[0];if(t){let e=(await W.get(`/api/v1/agent-flows/runs/${t.id}`)).data?.data;e&&je(e),(t.status===`pending`||t.status===`running`)&&(ne(t.id),de(!0))}}catch{}})()},[e.id,je]),(0,G.useEffect)(()=>{D(!0)},[d,_]);let Me=(0,G.useCallback)(e=>{let t=d.find(t=>t.id===e);$(`agent_flow.inspector.open_request`,{nodeId:e,foundNode:!!t,type:t?.type,label:t?.data?.label,totalNodes:d.length}),x(e)},[d]),Ne=(0,G.useMemo)(()=>d.map(e=>({...e,data:{...e.data,onOpenInspector:Me}})),[d,Me]);(0,G.useEffect)(()=>{if(!B)return;let e=async()=>{try{let e=(await W.get(`/api/v1/agent-flows/runs/${B}`)).data?.data;e&&(je(e),[`completed`,`failed`,`cancelled`].includes(e.status)&&(ne(null),de(!1),Ae(),Ee.current&&clearInterval(Ee.current)))}catch{}};return e(),Ee.current=setInterval(e,1500),()=>{Ee.current&&clearInterval(Ee.current)}},[B,Ae,je]);let Pe=(0,G.useCallback)(e=>{v(t=>bs({...e,type:`custom`,data:{label:null,edge_type:`default`},markerEnd:{type:fo.ArrowClosed,color:`#4a8cc7`,width:16,height:16}},t))},[v]),Fe=(0,G.useCallback)((e,t)=>{$(`agent_flow.reactflow.on_node_click`,{nodeId:t.id,type:t.type,label:t.data?.label}),Me(t.id)},[Me]),Ie=(0,G.useCallback)(e=>{let t=e.target,n=t instanceof HTMLElement?t.closest(`.react-flow__node, [title="Node Properties"], [aria-label^="Open properties"]`):null;$(`agent_flow.reactflow.on_pane_click`,{selectedNodeId:b,ignoredBecauseNodeClick:!!n}),!n&&x(null)},[b]),Le=(0,G.useCallback)(({nodes:e})=>{e[0]&&($(`agent_flow.reactflow.selection_change`,{nodeId:e[0].id,type:e[0].type,label:e[0].data?.label}),x(e[0].id))},[]),Re=(0,G.useCallback)((e,t)=>{h(n=>n.map(n=>n.id===e?{...n,data:t}:n))},[h]),ze=(0,G.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),Be=(0,G.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/agentflow-node-type`);if(!t)return;let n=o.screenToFlowPosition({x:e.clientX,y:e.clientY}),r=cp.find(e=>e.type===t),i=t===`stack_orchestrator`?{mode:`selected_stack`,objective:``,success_criteria:[],allowed_tools:[],model_routing_profile:`balanced`,max_runtime_minutes:60,max_iterations:50,max_retry_attempts_per_step:2,checkpoint_frequency:`after_each_step`,context_compaction:!0,verification_required:!0,approval_policy:`inherited`,artifact_policy:`retain_all`,failure_policy:`pause`}:{},a={id:crypto.randomUUID(),type:t,position:n,data:{label:r?.label||`New Node`,config:i}};h(e=>[...e,a])},[o,h]),Ve=(0,G.useCallback)(()=>{h(e=>e.filter(e=>!e.selected)),v(e=>e.filter(e=>!e.selected)),x(null)},[h,v]),He=(0,G.useCallback)(async()=>{T(!0);try{O!==e.name&&await W.patch(`/api/v1/agent-flows/${e.id}`,{name:O});let t=o.getViewport(),n={viewport:{x:t.x,y:t.y,zoom:t.zoom},nodes:d.map(e=>({id:e.id,node_type:e.type||`samurai`,label:e.data?.label||`Untitled`,position_x:e.position.x,position_y:e.position.y,config:e.data?.config||{}})),edges:_.map(e=>({id:e.id,source_node_id:e.source,target_node_id:e.target,source_handle:e.sourceHandle||null,target_handle:e.targetHandle||null,label:e.data?.label||null,edge_type:e.data?.edge_type||`default`,config:e.data?.config||{}}))};return await W.put(`/api/v1/agent-flows/${e.id}/graph`,n),D(!1),!0}catch(e){return console.error(`Failed to save flow:`,e),window.alert(e?.response?.data?.detail||`Could not save this AgentFlow.`),!1}finally{T(!1)}},[e.id,e.name,O,d,_,o]),Ue=(0,G.useCallback)(async()=>{if(ee||E&&!await He())return;let t=F===`active`?`paused`:`active`;te(!0);try{I((await W.post(`/api/v1/agent-flows/${e.id}/${t===`active`?`activate`:`pause`}`)).data?.data?.status||t),n()}catch(e){window.alert(e?.response?.data?.detail||`Could not set this AgentFlow to ${t}.`)}finally{te(!1)}},[ee,E,e.id,F,He,n]),We=(0,G.useCallback)(async()=>{if(E&&!await He())return;let t=window.prompt(`Template name`,O);if(!t)return;let n=window.prompt(`Template category`,`My Templates`)||`My Templates`;try{await W.post(`/api/v1/agent-flows/${e.id}/save-as-template`,{name:t,category:n}),window.alert(`Reusable template “${t}” saved.`)}catch(e){window.alert(e?.response?.data?.detail||`Could not save this template.`)}},[E,e.id,O,He]),Ge=(0,G.useCallback)(async()=>{if(!le&&!(E&&!await He())){de(!0),H(`pending`),ce(null),h(e=>e.map(e=>({...e,className:void 0,data:{...e.data,execution_status:null,execution_output:null,execution_run_id:null}})));try{let t=(await W.post(`/api/v1/agent-flows/${e.id}/run`)).data?.data?.run_id;t&&ne(t)}catch(e){console.error(`Failed to start flow run:`,e),de(!1),H(null)}}},[le,E,He,e.id,h]),Ke=(0,G.useCallback)(async()=>{if(B)try{await W.post(`/api/v1/agent-flows/runs/${B}/cancel`),ne(null),de(!1),H(`cancelled`)}catch{}},[B]);(0,G.useEffect)(()=>{if(!pe)return;Ae();let e=window.setInterval(()=>{Ae()},3e3);return()=>window.clearInterval(e)},[Ae,pe]);let qe=(0,G.useCallback)(async e=>{if(window.confirm(`Delete this run and its generated Output file?`)){Te(e);try{await W.delete(`/api/v1/agent-flows/runs/${e}`),ge(t=>t.filter(t=>t.id!==e)),(oe===e||d.some(t=>t.data?.execution_run_id===e))&&(H(null),ae({}),ce(null),h(e=>e.map(e=>({...e,className:void 0,data:{...e.data,execution_status:null,execution_output:null,execution_run_id:null}})))),_e===e&&(q(null),ye(null),xe(null))}catch(e){console.error(`Failed to delete flow run:`,e)}finally{Te(null)}}},[oe,d,_e,h]),Je=(0,G.useCallback)(async e=>{let t=await De(e);t&&je(t)},[je,De]);(0,G.useEffect)(()=>{let e=e=>{if((e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),He()),e.key===`Delete`||e.key===`Backspace`){if(document.activeElement?.tagName===`INPUT`||document.activeElement?.tagName===`TEXTAREA`||document.activeElement?.tagName===`SELECT`)return;Ve()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[He,Ve]);let Ye=b&&d.find(e=>e.id===b)||null;return(0,G.useEffect)(()=>{$(`agent_flow.inspector.state`,{selectedNodeId:b,inspectorVisible:!!Ye,nodeType:Ye?.type,nodeLabel:Ye?.data?.label,totalNodes:d.length})},[b,Ye,d.length]),(0,K.jsxs)(`div`,{"data-testid":`agent-flow-editor`,"data-flow-id":e.id,className:`relative flex h-[calc(100vh-120px)] rounded-lg overflow-hidden border border-[#1a2040] min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col bg-[#060810]`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2 bg-[#0a0e1a] border-b border-[#1a2040] shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,K.jsx)(`button`,{onClick:t,className:`p-1.5 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,K.jsx)(u,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`h-5 w-px bg-[#1a2040]`}),j?(0,K.jsx)(`input`,{autoFocus:!0,type:`text`,value:O,onChange:e=>A(e.target.value),onBlur:()=>N(!1),onKeyDown:e=>e.key===`Enter`&&N(!1),className:`bg-[#0e1225] border border-[#d4a017]/40 rounded px-2 py-1 text-sm font-bold text-[#d4a017] outline-none`}):(0,K.jsx)(`button`,{onClick:()=>N(!0),className:`max-w-[min(28rem,60vw)] truncate text-sm font-bold text-[#d4a017] hover:text-[#d4a017]/80 transition-colors`,children:O}),(0,K.jsx)(`span`,{className:U(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border`,F===`active`?`text-green-400 bg-green-500/10 border-green-500/20`:F===`paused`?`text-[#4a8cc7] bg-[#4a8cc7]/10 border-[#4a8cc7]/20`:`text-[#7a8899] bg-[#7a8899]/10 border-[#7a8899]/20`),children:F}),E&&(0,K.jsx)(`span`,{className:`text-[8px] text-[#d4a017]/60 font-bold uppercase tracking-widest animate-pulse`,children:`Unsaved`})]}),(0,K.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-1 mr-2`,children:cp.map(e=>{let t=e.icon;return(0,K.jsxs)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(`application/agentflow-node-type`,e.type),t.dataTransfer.effectAllowed=`move`},className:`flex shrink-0 items-center gap-1.5 px-2 py-1.5 bg-[#0e1225] border border-[#1a2040] rounded-md cursor-grab active:cursor-grabbing hover:border-[#2a3060] transition-colors group`,title:`Drag to add ${e.label}`,children:[(0,K.jsx)(t,{className:`w-3 h-3`,style:{color:e.color}}),(0,K.jsx)(`span`,{className:`hidden text-[9px] font-bold text-[#7a8899] group-hover:text-[#c8d0d8] lg:inline`,children:e.label})]},e.type)})}),(0,K.jsx)(`div`,{className:`h-5 w-px bg-[#1a2040]`}),(0,K.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":F===`active`,onClick:Ue,disabled:ee||C,className:U(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider border transition-all`,F===`active`?`bg-green-500/15 text-green-400 border-green-500/30 hover:bg-green-500/25`:`bg-[#0e1225] text-[#7a8899] border-[#2a3060] hover:text-[#c8d0d8]`,(ee||C)&&`opacity-60 cursor-wait`),title:F===`active`?`Pause this AgentFlow and disable its schedule`:`Activate this AgentFlow`,children:[ee?(0,K.jsx)(k,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(L,{className:`w-3 h-3`}),F===`active`?`Active`:`Activate`]}),(0,K.jsxs)(`button`,{onClick:He,disabled:C,className:U(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all`,C?`bg-[#7a8899]/20 text-[#7a8899] cursor-wait`:E?`bg-[#d4a017] text-black hover:bg-[#d4a017]/90 shadow-[0_0_12px_rgba(212,160,23,0.2)]`:`bg-[#0e1225] text-[#7a8899] border border-[#1a2040] hover:border-[#2a3060]`),children:[C?(0,K.jsx)(k,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(z,{className:`w-3 h-3`}),C?`Saving...`:`Save`]}),(0,K.jsxs)(`button`,{onClick:We,disabled:C,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#8b5cf6]/15 text-[#c084fc] border border-[#8b5cf6]/30 hover:bg-[#8b5cf6]/25 transition-all`,title:`Save this AgentFlow for future reuse`,children:[(0,K.jsx)(ue,{className:`w-3 h-3`}),` Template`]}),(0,K.jsx)(`div`,{className:`h-5 w-px bg-[#1a2040]`}),le?(0,K.jsxs)(`button`,{onClick:Ke,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#ef4444]/20 text-[#ef4444] border border-[#ef4444]/30 hover:bg-[#ef4444]/30 transition-all`,children:[(0,K.jsx)(fe,{className:`w-3 h-3`}),`Cancel`]}):(0,K.jsxs)(`button`,{onClick:Ge,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#22c55e]/20 text-[#22c55e] border border-[#22c55e]/30 hover:bg-[#22c55e]/30 transition-all shadow-[0_0_10px_rgba(34,197,94,0.1)]`,children:[(0,K.jsx)(P,{className:`w-3 h-3`}),`Run`]}),(0,K.jsxs)(`button`,{onClick:()=>{me(!pe),pe||Ae()},className:U(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all border`,pe?`bg-[#4a8cc7]/20 text-[#4a8cc7] border-[#4a8cc7]/30`:`bg-[#0e1225] text-[#7a8899] border-[#1a2040] hover:border-[#2a3060]`),children:[(0,K.jsx)(w,{className:`w-3 h-3`}),`History`]})]})]}),V&&(0,K.jsxs)(`div`,{className:U(`flex items-center justify-between px-4 py-2 border-b text-[10px] font-bold uppercase tracking-wider`,V===`running`?`bg-[#4a8cc7]/10 border-[#4a8cc7]/20 text-[#4a8cc7]`:V===`completed`?`bg-[#22c55e]/10 border-[#22c55e]/20 text-[#22c55e]`:V===`failed`?`bg-[#ef4444]/10 border-[#ef4444]/20 text-[#ef4444]`:V===`cancelled`?`bg-[#7a8899]/10 border-[#7a8899]/20 text-[#7a8899]`:`bg-[#d4a017]/10 border-[#d4a017]/20 text-[#d4a017]`),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[V===`running`&&(0,K.jsx)(k,{className:`w-3 h-3 animate-spin`}),V===`completed`&&(0,K.jsx)(f,{className:`w-3 h-3`}),V===`failed`&&(0,K.jsx)(p,{className:`w-3 h-3`}),V===`pending`&&(0,K.jsx)(m,{className:`w-3 h-3`}),(0,K.jsxs)(`span`,{children:[`Flow `,V]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Object.values(ie).length>0&&(0,K.jsxs)(`span`,{className:`text-[9px] opacity-70`,children:[Object.values(ie).filter(e=>e.status===`completed`).length,`/`,Object.values(ie).length,` nodes completed`]}),V!==`running`&&(0,K.jsx)(`button`,{onClick:()=>{H(null),ae({}),ce(null),h(e=>e.map(e=>({...e,className:void 0,data:{...e.data,execution_status:null,execution_output:null,execution_run_id:null}})))},className:`text-current opacity-50 hover:opacity-100 transition-opacity`,children:(0,K.jsx)(se,{className:`w-3 h-3`})})]})]}),(0,K.jsx)(`div`,{ref:s,className:`flex-1 min-w-0`,children:(0,K.jsx)(ap.Provider,{value:ke,children:(0,K.jsxs)(ef,{nodes:Ne,edges:_,onNodesChange:g,onEdgesChange:y,onConnect:Pe,onNodeClick:Fe,onNodeDoubleClick:Fe,onPaneClick:Ie,onSelectionChange:Le,onDrop:Be,onDragOver:ze,nodeTypes:mp,edgeTypes:gp,defaultViewport:e.viewport,fitView:!!e.nodes?.length,snapToGrid:!0,snapGrid:[16,16],nodeDragThreshold:5,selectNodesOnDrag:!1,deleteKeyCode:null,proOptions:{hideAttribution:!0},style:{background:`#060810`},children:[(0,K.jsx)(xf,{position:`bottom-left`,style:{display:`flex`,gap:2},className:`!bg-[#0e1225] !border !border-[#1a2040] !rounded-lg !shadow-lg [&>button]:!bg-[#0a0e1a] [&>button]:!border-[#1a2040] [&>button]:!text-[#7a8899] [&>button:hover]:!text-[#d4a017] [&>button]:!rounded [&>button]:!w-7 [&>button]:!h-7`}),(0,K.jsx)(If,{position:`bottom-right`,nodeColor:e=>lp[e.type||`samurai`]||`#d4a017`,maskColor:`rgba(6, 8, 16, 0.85)`,className:`!bg-[#0a0e1a] !border !border-[#1a2040] !rounded-lg`,style:{width:160,height:100}}),(0,K.jsx)(ff,{variant:cf.Dots,gap:20,size:1,color:`#1a204040`}),d.length===0&&(0,K.jsx)(ml,{position:`top-center`,className:`mt-24`,children:(0,K.jsxs)(`div`,{className:`text-center space-y-3 animate-in fade-in duration-700`,children:[(0,K.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-[#0e1225] border border-[#1a2040] flex items-center justify-center mx-auto`,children:(0,K.jsx)(S,{className:`w-7 h-7 text-[#4a8cc7]/40`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-bold text-[#7a8899]`,children:`Empty Canvas`}),(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899]/60 mt-1`,children:`Drag cards from the toolbar above to build your workflow`})]})]})})]})})})]}),Ye&&(0,K.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 z-[60] w-[min(420px,calc(100vw-320px))] min-w-[320px] max-w-[420px] shadow-[-20px_0_40px_rgba(0,0,0,0.35)]`,children:(0,K.jsx)(xp,{node:Ye,onUpdate:Re,onClose:()=>x(null),agents:r,routingProfiles:i,flowId:e.id,flows:a})}),(0,ve.createPortal)((0,K.jsxs)(K.Fragment,{children:[pe&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:99998,backgroundColor:`rgba(0,0,0,0.2)`,pointerEvents:`auto`},onClick:()=>me(!1)}),(0,K.jsxs)(`div`,{style:{position:`fixed`,top:0,right:0,width:320,height:`100vh`,zIndex:99999,backgroundColor:`#0a0e1a`,borderLeft:`1px solid #1a2040`,display:`flex`,flexDirection:`column`,boxShadow:`-8px 0 32px rgba(0,0,0,0.5)`,pointerEvents:`auto`},children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[#1a2040] shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(w,{className:`w-4 h-4 text-[#4a8cc7] shrink-0`}),(0,K.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8] uppercase tracking-wider`,children:`Run History`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,K.jsx)(`button`,{onClick:Ae,className:`p-1.5 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,title:`Refresh history`,children:(0,K.jsx)(R,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>me(!1),className:`p-1.5 hover:bg-[#ef4444]/20 text-[#7a8899] hover:text-[#ef4444] rounded-lg transition-colors`,title:`Close history`,children:(0,K.jsx)(se,{className:`w-4 h-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-2`,children:[he.length===0&&(0,K.jsxs)(`div`,{className:`text-center py-8`,children:[(0,K.jsx)(m,{className:`w-8 h-8 text-[#7a8899]/30 mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899]/50`,children:`No runs yet`})]}),he.map(e=>(0,K.jsxs)(`div`,{onClick:()=>Je(e.id),className:`p-3 bg-[#0e1225] border border-[#1a2040] rounded-lg hover:border-[#2a3060] transition-colors overflow-hidden cursor-pointer`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.status===`completed`&&(0,K.jsx)(f,{className:`w-3.5 h-3.5 text-[#22c55e] shrink-0`}),e.status===`failed`&&(0,K.jsx)(p,{className:`w-3.5 h-3.5 text-[#ef4444] shrink-0`}),e.status===`running`&&(0,K.jsx)(k,{className:`w-3.5 h-3.5 text-[#4a8cc7] animate-spin shrink-0`}),e.status===`cancelled`&&(0,K.jsx)(fe,{className:`w-3.5 h-3.5 text-[#7a8899] shrink-0`}),e.status===`pending`&&(0,K.jsx)(m,{className:`w-3.5 h-3.5 text-[#d4a017] shrink-0`}),(0,K.jsx)(`span`,{className:U(`text-[10px] font-bold uppercase`,e.status===`completed`?`text-[#22c55e]`:e.status===`failed`?`text-[#ef4444]`:e.status===`running`?`text-[#4a8cc7]`:`text-[#7a8899]`),children:e.status})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest text-[#7a8899]/60 bg-[#7a8899]/10 px-1.5 py-0.5 rounded truncate max-w-[80px]`,children:e.trigger_type}),(0,K.jsx)(`button`,{type:`button`,title:`Delete run and Output file`,disabled:we===e.id||e.status===`running`||e.status===`pending`,onClick:t=>{t.stopPropagation(),qe(e.id)},className:`p-1 rounded text-[#7a8899]/60 hover:text-[#ef4444] hover:bg-[#ef4444]/10 disabled:opacity-30 disabled:pointer-events-none transition-colors`,children:we===e.id?(0,K.jsx)(k,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(re,{className:`w-3 h-3`})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] text-[#7a8899]`,children:[(0,K.jsx)(`span`,{children:sp(e.created_at)}),e.started_at&&e.completed_at&&(0,K.jsxs)(`span`,{className:`text-[#d4a017]/70`,children:[((op(e.completed_at).getTime()-op(e.started_at).getTime())/1e3).toFixed(1),`s`]})]}),e.error_message&&(0,K.jsx)(`p`,{className:`mt-1.5 text-[9px] text-[#ef4444]/80 line-clamp-2 bg-[#ef4444]/5 rounded p-1.5`,children:e.error_message})]},e.id))]})]})]}),_e&&(0,K.jsxs)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4 pointer-events-auto`,style:{zIndex:1e5},children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>q(null)}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-4xl max-h-[85vh] bg-[#0a0e1a] border border-[#1a2040] rounded-xl shadow-2xl flex flex-col overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-[#1a2040] bg-[#0e1225]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8] uppercase tracking-wider`,children:`Run Details`}),Se&&(0,K.jsx)(k,{className:`w-4 h-4 text-[#4a8cc7] animate-spin`})]}),(0,K.jsx)(`button`,{onClick:()=>q(null),className:`p-2 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,K.jsx)(se,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:J?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-[11px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[(0,K.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Status: `,(0,K.jsx)(`span`,{className:U(J.status===`completed`?`text-[#22c55e]`:J.status===`failed`?`text-[#ef4444]`:`text-[#4a8cc7]`),children:J.status})]}),(0,K.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Trigger: `,J.trigger_type]}),(0,K.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Depth: `,J.run_depth||0]}),J.flow_version&&(0,K.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Flow v`,J.flow_version]}),J.started_at&&J.completed_at&&(0,K.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Duration: `,((op(J.completed_at).getTime()-op(J.started_at).getTime())/1e3).toFixed(2),`s`]})]}),J.error_message&&(0,K.jsxs)(`div`,{className:`p-4 rounded-lg border border-[#ef4444]/20 bg-[#ef4444]/5`,children:[(0,K.jsx)(`h3`,{className:`text-xs font-bold text-[#ef4444] uppercase tracking-wider mb-2`,children:`Error Details`}),(0,K.jsx)(`p`,{className:`text-sm text-[#ef4444]/90 whitespace-pre-wrap font-mono`,children:J.error_message})]}),be&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[#1a2040] pb-2`,children:[(0,K.jsx)(M,{className:`w-4 h-4 text-[#8b5cf6]`}),(0,K.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8] uppercase tracking-wider`,children:`Flow Stacking Execution Tree`})]}),(0,K.jsx)(fp,{node:be})]}),J.governance_context&&Object.keys(J.governance_context).length>0&&(0,K.jsxs)(`details`,{className:`rounded-lg border border-[#1a2040] bg-[#0e1225] p-3`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer text-[10px] font-bold uppercase tracking-wider text-[#7a8899]`,children:`Inherited governance context`}),(0,K.jsx)(`pre`,{className:`mt-3 overflow-x-auto whitespace-pre-wrap text-[9px] text-[#c8d0d8]`,children:JSON.stringify(J.governance_context,null,2)})]}),J.result_summary&&Object.keys(J.result_summary).length>0?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8] uppercase tracking-wider border-b border-[#1a2040] pb-2`,children:`Output Artifacts & Reports`}),Object.entries(J.result_summary).map(([e,t])=>(0,K.jsxs)(`div`,{className:`rounded-lg border border-[#2a3060] bg-[#0e1225] overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`px-4 py-2 bg-[#1a2040]/50 border-b border-[#2a3060]`,children:(0,K.jsx)(`span`,{className:`text-xs font-bold text-[#4a8cc7]`,children:e})}),(0,K.jsx)(`div`,{className:`p-4 text-sm text-[#c8d0d8] leading-relaxed whitespace-pre-wrap overflow-x-auto`,children:String(t)})]},e))]}):(0,K.jsx)(`div`,{className:`py-8 text-center border border-dashed border-[#1a2040] rounded-lg`,children:(0,K.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`No output artifacts generated for this run.`})})]}):!Se&&(0,K.jsx)(`div`,{className:`py-12 text-center`,children:(0,K.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`Could not load run details.`})})})]})]})]}),document.getElementById(`portal-root`))]})}function Cp({flows:e,loading:t,onSelect:n,onCreate:r,onDelete:i,onDuplicate:a,onRefresh:o}){let[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(null),d=e.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),f={draft:`#7a8899`,active:`#22c55e`,paused:`#4a8cc7`,archived:`#7a8899`};return(0,K.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-500`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[{label:`Total Flows`,value:e.length,color:`#d4a017`},{label:`Active`,value:e.filter(e=>e.status===`active`).length,color:`#22c55e`},{label:`Draft`,value:e.filter(e=>e.status===`draft`).length,color:`#7a8899`},{label:`Paused`,value:e.filter(e=>e.status===`paused`).length,color:`#4a8cc7`}].map((e,t)=>(0,K.jsxs)(`div`,{className:`shogun-card !p-4 border-l-2`,style:{borderLeftColor:e.color},children:[(0,K.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-bold text-[#7a8899]`,children:e.label}),(0,K.jsx)(`div`,{className:`text-2xl font-bold text-[#c8d0d8] mt-1`,children:e.value})]},t))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1 max-w-md`,children:[(0,K.jsx)(te,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#7a8899]`}),(0,K.jsx)(`input`,{type:`text`,placeholder:`Filter workflows...`,value:s,onChange:e=>c(e.target.value),className:`w-full bg-[#0e1225] border border-[#1a2040] rounded-lg pl-10 pr-4 py-2 text-sm text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none`})]}),(0,K.jsx)(`button`,{onClick:o,className:`p-2.5 bg-[#0e1225] border border-[#1a2040] rounded-lg text-[#7a8899] hover:text-[#d4a017] transition-colors`,children:(0,K.jsx)(R,{className:U(`w-4 h-4`,t&&`animate-spin`)})}),(0,K.jsxs)(`button`,{onClick:r,className:`flex items-center gap-2 bg-[#4a8cc7] hover:bg-[#4a8cc7]/90 text-white font-bold py-2.5 px-5 rounded-lg transition-all shadow-[0_0_20px_rgba(74,140,199,0.15)] text-xs`,children:[(0,K.jsx)(I,{className:`w-4 h-4`}),` NEW FLOW`]})]}),t?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16`,children:[(0,K.jsx)(k,{className:`w-6 h-6 text-[#d4a017] animate-spin`}),(0,K.jsx)(`span`,{className:`text-[10px] text-[#7a8899] uppercase tracking-widest`,children:`Loading workflows...`})]}):d.length===0?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(S,{className:`w-10 h-10 text-[#1a2040] mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:e.length===0?`No Agent Flows created yet`:`No flows match your search`}),e.length===0&&(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899]/60 mt-1`,children:`Create your first workflow to orchestrate Samurai agents visually`})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:d.map(e=>(0,K.jsxs)(`button`,{onClick:()=>n(e.id),className:`shogun-card !p-0 text-left hover:border-[#4a8cc7]/40 transition-all group relative overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`h-0.5`,style:{background:f[e.status]||`#7a8899`}}),(0,K.jsxs)(`div`,{className:`p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-bold text-[#c8d0d8] group-hover:text-[#d4a017] transition-colors truncate`,children:e.name}),(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899] mt-1 line-clamp-2`,children:e.description||`No description`})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),u(l===e.id?null:e.id)},className:`p-1.5 hover:bg-[#1a2040] rounded-lg text-[#7a8899] hover:text-[#c8d0d8] transition-colors opacity-0 group-hover:opacity-100`,children:(0,K.jsx)(me,{className:`w-3.5 h-3.5`})}),l===e.id&&(0,K.jsxs)(`div`,{className:`absolute right-0 top-8 z-10 w-36 bg-[#0e1225] border border-[#1a2040] rounded-lg shadow-xl overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),a(e.id),u(null)},className:`w-full flex items-center gap-2 px-3 py-2 text-[10px] font-bold text-[#7a8899] hover:bg-[#1a2040] hover:text-[#c8d0d8] transition-colors`,children:[(0,K.jsx)(g,{className:`w-3 h-3`}),` Duplicate`]}),(0,K.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(e.id),u(null)},className:`w-full flex items-center gap-2 px-3 py-2 text-[10px] font-bold text-red-400 hover:bg-red-500/10 transition-colors`,children:[(0,K.jsx)(re,{className:`w-3 h-3`}),` Delete`]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mt-4`,children:[e.flow_type===`stack`&&(0,K.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border text-[#a78bfa] bg-[#8b5cf6]/10 border-[#8b5cf6]/30`,children:`Flow Stack`}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border`,style:{color:f[e.status],background:`${f[e.status]}10`,borderColor:`${f[e.status]}30`},children:e.status}),(0,K.jsxs)(`span`,{className:`text-[8px] text-[#7a8899] flex items-center gap-1`,children:[(0,K.jsx)(m,{className:`w-2.5 h-2.5`}),e.trigger_type]}),(0,K.jsx)(`span`,{className:`text-[8px] text-[#7a8899]/60 ml-auto`,children:new Date(e.updated_at).toLocaleDateString()})]})]})]},e.id))})]})}var wp={"Document Processing":`#10b981`,"Data Analysis":`#3b82f6`,"Content Creation":`#f59e0b`,"Email Automation":`#8b5cf6`,"Research & Intelligence":`#ef4444`,"Business Operations":`#06b6d4`,Marketing:`#ec4899`,"Human Resources":`#14b8a6`,"Legal & Compliance":`#6366f1`,"Education & Training":`#f97316`},Tp={beginner:{label:`Beginner`,color:`#10b981`},intermediate:{label:`Intermediate`,color:`#f59e0b`},advanced:{label:`Advanced`,color:`#ef4444`}};function Ep({onClose:e,onCreate:t,onCreateFromTemplate:n}){let{ui:r,category:i,difficulty:a,agentFlow:o}=ip(),[s,c]=(0,G.useState)(`templates`),[l,u]=(0,G.useState)([]),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)(!0),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(null),[y,b]=(0,G.useState)(``),[x,S]=(0,G.useState)(null),[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(``),[O,A]=(0,G.useState)(`manual`);(0,G.useEffect)(()=>{(async()=>{try{let e=(await W.get(`/api/v1/agent-flows/templates`)).data?.data;e&&(u(e.templates||[]),f(e.categories||[]))}catch(e){console.error(`Failed to load templates:`,e),g((W.isAxiosError(e)?e.response?.data?.detail:``)||`AgentFlow templates could not be loaded. Run Shogun Repair/Update and restart Shogun.`)}finally{m(!1)}})()},[]);let j=(0,G.useMemo)(()=>{let e=l;_&&(e=e.filter(e=>e.category===_));let t=e.map(e=>o(e));if(y.trim()){let e=y.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.category.toLowerCase().includes(e))}return t},[l,_,y,o]),M=async e=>{S(e);try{n(e)}catch{S(null)}};return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-200`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,K.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a2040] rounded-xl w-full max-w-5xl h-[85vh] shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200 flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`bg-[#0e1225] border-b border-[#1a2040] p-5 flex items-center justify-between shrink-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`text-lg font-bold text-[#d4a017] flex items-center gap-2`,children:[(0,K.jsx)(H,{className:`w-5 h-5`}),r(`create_agent_flow`,`Create Agent Flow`)]}),(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899] uppercase tracking-widest font-bold mt-1`,children:r(`choose_template`,`Choose a template or start from scratch`)})]}),(0,K.jsx)(`button`,{onClick:e,className:`p-2 hover:bg-[#d4a017]/10 text-[#7a8899] hover:text-[#d4a017] rounded-lg transition-colors`,children:(0,K.jsx)(se,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`border-b border-[#1a2040] flex gap-0 shrink-0`,children:[(0,K.jsxs)(`button`,{onClick:()=>c(`templates`),className:U(`px-6 py-3 text-sm font-bold transition-all flex items-center gap-2`,s===`templates`?`text-[#d4a017] border-b-2 border-[#d4a017] bg-[#d4a017]/5`:`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`),children:[(0,K.jsx)(D,{className:`w-4 h-4`}),r(`templates`,`Templates`),(0,K.jsx)(`span`,{className:`text-[9px] bg-[#d4a017]/20 text-[#d4a017] px-1.5 py-0.5 rounded-full font-bold`,children:l.length})]}),(0,K.jsxs)(`button`,{onClick:()=>c(`blank`),className:U(`px-6 py-3 text-sm font-bold transition-all flex items-center gap-2`,s===`blank`?`text-[#d4a017] border-b-2 border-[#d4a017] bg-[#d4a017]/5`:`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`),children:[(0,K.jsx)(I,{className:`w-4 h-4`}),r(`blank_flow`,`Blank Flow`)]})]}),s===`templates`?(0,K.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`w-56 border-r border-[#1a2040] overflow-y-auto shrink-0 p-3 space-y-0.5`,children:[(0,K.jsxs)(`button`,{onClick:()=>v(null),className:U(`w-full text-left px-3 py-2 rounded-lg text-xs font-medium transition-colors`,_?`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`:`bg-[#d4a017]/10 text-[#d4a017]`),children:[r(`all_templates`,`All Templates`),(0,K.jsx)(`span`,{className:`float-right text-[9px] opacity-60`,children:l.length})]}),d.map(e=>(0,K.jsxs)(`button`,{onClick:()=>v(e.name===_?null:e.name),className:U(`w-full text-left px-3 py-2 rounded-lg text-xs font-medium transition-colors flex items-center gap-2`,_===e.name?`bg-[#d4a017]/10 text-[#d4a017]`:`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`),children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:wp[e.name]||`#7a8899`}}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:i(e.name)}),(0,K.jsx)(`span`,{className:`text-[9px] opacity-60`,children:e.count})]},e.name))]}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`p-3 border-b border-[#1a2040] shrink-0`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(te,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-[#7a8899]`}),(0,K.jsx)(`input`,{type:`text`,value:y,onChange:e=>b(e.target.value),className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg pl-9 pr-3 py-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`,placeholder:r(`search_templates`,`Search templates...`)})]})}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3`,children:p?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(k,{className:`w-6 h-6 text-[#d4a017] animate-spin`})}):h?(0,K.jsxs)(`div`,{className:`text-center py-16 px-8`,children:[(0,K.jsx)(ie,{className:`w-8 h-8 text-amber-400 mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-sm text-amber-300 font-semibold`,children:r(`templates_unavailable`,`Templates unavailable`)}),(0,K.jsx)(`p`,{className:`text-xs text-[#7a8899] mt-2`,children:h})]}):j.length===0?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(te,{className:`w-8 h-8 text-[#7a8899]/40 mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:r(`no_templates`,`No templates match your search`)})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:j.map(e=>{let t=wp[l.find(t=>t.id===e.id)?.category||e.category]||`#7a8899`,n=Tp[e.difficulty]||Tp.beginner;return(0,K.jsx)(`button`,{onClick:()=>M(e.id),disabled:!!x,className:U(`text-left p-3.5 rounded-xl border transition-all group`,`bg-[#0e1225] border-[#1a2040] hover:border-[#d4a017]/50 hover:bg-[#0e1225]/80`,`hover:shadow-[0_0_20px_rgba(212,160,23,0.08)]`,x===e.id&&`opacity-70 pointer-events-none`),children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(`span`,{className:`text-xl leading-none mt-0.5`,children:e.icon}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`h4`,{className:`text-xs font-bold text-[#c8d0d8] truncate flex-1 group-hover:text-[#d4a017] transition-colors`,children:e.name}),x===e.id&&(0,K.jsx)(k,{className:`w-3 h-3 text-[#d4a017] animate-spin shrink-0`})]}),(0,K.jsx)(`p`,{className:`text-[10px] text-[#7a8899] line-clamp-2 leading-relaxed mb-2`,children:e.description}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded`,style:{color:t,background:`${t}15`},children:e.category}),(0,K.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded`,style:{color:n.color,background:`${n.color}15`},children:a(e.difficulty||`beginner`)||n.label}),(0,K.jsxs)(`span`,{className:`text-[8px] text-[#7a8899]/60 ml-auto`,children:[e.node_count,` `,r(`nodes`,`nodes`)]})]})]})]})},e.id)})})})]})]}):(0,K.jsxs)(`div`,{className:`p-6 space-y-5 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Flow Name`}),(0,K.jsx)(`input`,{type:`text`,autoFocus:!0,value:C,onChange:e=>w(e.target.value),className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg p-2.5 text-sm text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`,placeholder:`e.g., Research Pipeline, Weekly Report...`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Trigger Type`}),(0,K.jsxs)(`select`,{value:O,onChange:e=>A(e.target.value),className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg p-2.5 text-sm text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`manual`,children:`Manual Execution`}),(0,K.jsx)(`option`,{value:`scheduled`,children:`Scheduled / Cron`}),(0,K.jsx)(`option`,{value:`event`,children:`Event-Based Trigger`}),(0,K.jsx)(`option`,{value:`api`,children:`API Trigger`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Description`}),(0,K.jsx)(`textarea`,{value:T,onChange:e=>E(e.target.value),rows:3,className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg p-3 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none resize-none`,placeholder:`Describe the purpose of this workflow...`})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)(`button`,{onClick:e,className:`flex-1 bg-[#0e1225] hover:bg-[#1a2040] text-[#7a8899] font-bold py-2.5 rounded-lg transition-all border border-[#1a2040] text-sm`,children:`Cancel`}),(0,K.jsxs)(`button`,{onClick:()=>t(C,T,O),disabled:!C.trim(),className:U(`flex-1 font-bold py-2.5 rounded-lg transition-all text-sm flex items-center justify-center gap-2`,C.trim()?`bg-[#4a8cc7] hover:bg-[#4a8cc7]/90 text-white shadow-[0_0_20px_rgba(74,140,199,0.15)]`:`bg-[#7a8899]/20 text-[#7a8899] cursor-not-allowed`),children:[(0,K.jsx)(I,{className:`w-3.5 h-3.5`}),`Create Blank Flow`]})]})]})]})})}var Dp=()=>{let[e,t]=(0,G.useState)([]),[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(!0),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)([]),[u,d]=(0,G.useState)([]);(0,G.useEffect)(()=>{$(`agent_flow.mount`,{path:window.location.pathname,href:window.location.href})},[]);let f=(0,G.useCallback)(async()=>{a(!0),$(`agent_flow.fetch_flows.start`);try{let e=await W.get(`/api/v1/agent-flows`);e.data.data?(t(e.data.data),$(`agent_flow.fetch_flows.success`,{count:e.data.data.length,ids:e.data.data.slice(0,10).map(e=>e.id)})):$(`agent_flow.fetch_flows.empty_response`,{response:e.data})}catch(e){console.error(`Failed to fetch flows:`,e),$(`agent_flow.fetch_flows.error`,{error:e})}finally{a(!1)}},[]),p=(0,G.useCallback)(async()=>{$(`agent_flow.fetch_support.start`);try{let[e,t]=await Promise.all([W.get(`/api/v1/agents?agent_type=samurai`),W.get(`/api/v1/model-routing-profiles`)]);e.data.data&&l(e.data.data),t.data.data&&d(t.data.data),$(`agent_flow.fetch_support.success`,{agents:e.data?.data?.length||0,routingProfiles:t.data?.data?.length||0})}catch(e){console.error(`Failed to fetch support data:`,e),$(`agent_flow.fetch_support.error`,{error:e})}},[]);(0,G.useEffect)(()=>{f(),p()},[f,p]);let m=(0,G.useCallback)(async e=>{$(`agent_flow.load_flow.start`,{flowId:e});try{let t=await W.get(`/api/v1/agent-flows/${e}`);t.data.data?($(`agent_flow.load_flow.success`,{flowId:e,nodes:t.data.data.nodes?.length||0,edges:t.data.data.edges?.length||0}),r(t.data.data)):$(`agent_flow.load_flow.empty_response`,{flowId:e,response:t.data})}catch(t){console.error(`Failed to load flow:`,t),$(`agent_flow.load_flow.error`,{flowId:e,error:t})}},[]),h=(0,G.useCallback)(async(e,t,n)=>{try{let i=await W.post(`/api/v1/agent-flows`,{name:e,description:t,trigger_type:n});i.data.data&&(s(!1),r(i.data.data),f())}catch(e){console.error(`Failed to create flow:`,e)}},[f]),g=(0,G.useCallback)(async e=>{try{let t=await W.post(`/api/v1/agent-flows/from-template`,{template_id:e});if(t.data.data){s(!1);let e=t.data.data.id,n=await W.get(`/api/v1/agent-flows/${e}`);n.data.data?r(n.data.data):r(t.data.data),f()}}catch(e){console.error(`Failed to create flow from template:`,e)}},[f]),_=(0,G.useCallback)(async e=>{if(confirm(`Delete this Agent Flow?`))try{await W.delete(`/api/v1/agent-flows/${e}`),f()}catch(e){console.error(`Failed to delete flow:`,e)}},[f]),v=(0,G.useCallback)(async e=>{try{await W.post(`/api/v1/agent-flows/${e}/duplicate`),f()}catch(e){console.error(`Failed to duplicate flow:`,e)}},[f]);return n?(0,K.jsx)(Xd,{children:(0,K.jsx)(Sp,{flow:n,onBack:()=>{r(null),f()},onFlowUpdate:f,agents:c,routingProfiles:u,availableFlows:e},n.id)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cp,{flows:e,loading:i,onSelect:m,onCreate:()=>s(!0),onDelete:_,onDuplicate:v,onRefresh:f}),o&&(0,K.jsx)(Ep,{onClose:()=>s(!1),onCreate:h,onCreateFromTemplate:g})]})},Op=(0,G.createContext)({openEditor:()=>void 0,deleteNode:()=>void 0});function kp({id:e,data:t,selected:n}){let{openEditor:r,deleteNode:i}=(0,G.useContext)(Op);return(0,K.jsxs)(`div`,{onClick:()=>r(e),className:U(`relative w-[230px] rounded-xl border bg-[#0e1225] text-[#c8d0d8] shadow-lg transition-all`,n?`border-purple-400 ring-2 ring-purple-400/25`:`border-[#28325d] hover:border-[#4a8cc7]`),children:[(0,K.jsx)(Su,{type:`target`,position:Y.Left,className:`!h-3 !w-3 !border-2 !border-[#080b16] !bg-[#4a8cc7]`}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3`,children:[(0,K.jsx)(E,{className:`mt-0.5 h-4 w-4 shrink-0 text-purple-400`}),(0,K.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:()=>r(e),className:`nodrag nopan min-w-0 flex-1 text-left`,children:[(0,K.jsx)(`div`,{className:`truncate text-[11px] font-bold`,children:String(t.label||`AgentFlow`)}),(0,K.jsxs)(`div`,{className:`mt-1 text-[8px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[String(t.category||`AgentFlow`),` · drag to reorder`]})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,title:`Edit AgentFlow`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),r(e)},className:`nodrag nopan rounded border border-[#28325d] p-1 text-[#7a8899] hover:text-[#4a8cc7]`,children:(0,K.jsx)(v,{className:`h-3 w-3`})}),(0,K.jsx)(`button`,{type:`button`,title:`Delete from stack`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),i(e)},className:`nodrag nopan rounded border border-red-500/20 p-1 text-red-400/70 hover:bg-red-500/10 hover:text-red-300`,children:(0,K.jsx)(re,{className:`h-3 w-3`})})]})]}),(0,K.jsx)(Su,{type:`source`,position:Y.Right,className:`!h-3 !w-3 !border-2 !border-[#080b16] !bg-[#8b5cf6]`})]})}var Ap={stackFlow:kp},jp=class extends G.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`The embedded AgentFlow editor could not be rendered.`,e,t)}render(){return this.state.error?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center bg-[#050508] p-6`,children:(0,K.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-red-500/30 bg-[#0e1225] p-6 text-center shadow-2xl`,children:[(0,K.jsx)(`h2`,{className:`text-base font-bold text-red-300`,children:`The AgentFlow editor could not open`}),(0,K.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-shogun-subdued`,children:`The Flow Stack is still safe. Close this view and try the AgentFlow again.`}),(0,K.jsx)(`p`,{className:`mt-3 rounded border border-red-500/20 bg-black/20 p-2 text-[10px] text-red-200`,children:this.state.error.message}),(0,K.jsx)(`button`,{type:`button`,onClick:this.props.onClose,className:`mt-5 rounded border border-shogun-border px-4 py-2 text-xs font-bold text-shogun-text hover:border-shogun-blue`,children:`BACK TO FLOW STACK`})]})}):this.props.children}};function Mp({flow:e,onClose:t,agents:n,routingProfiles:r,availableFlows:i}){return(0,K.jsx)(`div`,{className:`fixed inset-0 z-[100] overflow-hidden bg-[#050508] p-3`,"data-testid":`embedded-agent-flow-editor`,children:(0,K.jsx)(jp,{onClose:t,children:(0,K.jsx)(Xd,{children:(0,K.jsx)(Sp,{flow:e,onBack:t,onFlowUpdate:()=>void 0,agents:n,routingProfiles:r,availableFlows:i},e.id)})})})}function Np({seed:e}){let[t,n]=(0,G.useState)([]),[r,i,a]=rf([]),[o,s,c]=af([]),[u,f]=(0,G.useState)([]),[p,m]=(0,G.useState)([]),[h,g]=(0,G.useState)(!0),[_,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(`All`),[x,S]=(0,G.useState)(`My Templates`),[C,w]=(0,G.useState)(`New Flow Stack`),[E,D]=(0,G.useState)(``),[O,A]=(0,G.useState)(`Complete the stack and verify every flow output.`),[j,M]=(0,G.useState)(`balanced`),[N,P]=(0,G.useState)(`pause`),[F,I]=(0,G.useState)(1440),[R,ee]=(0,G.useState)(100),[B,V]=(0,G.useState)(3),[H,ie]=(0,G.useState)(`after_each_subflow`),[ae,oe]=(0,G.useState)(`step_based`),[se,ce]=(0,G.useState)(`retain_all`),[le,fe]=(0,G.useState)(!1),[pe,me]=(0,G.useState)(``),[he,ge]=(0,G.useState)(`draft`),[_e,ve]=(0,G.useState)(!1),[q,J]=(0,G.useState)(``),[ye,be]=(0,G.useState)(null),[xe,Se]=(0,G.useState)(null),Ce=(0,G.useRef)(!1),[we,Te]=(0,G.useState)([]),[Ee,De]=(0,G.useState)([]),[Oe,ke]=(0,G.useState)([]),Ae=$l();(0,G.useEffect)(()=>{Promise.all([W.get(`/api/v1/agent-flows/templates`),W.get(`/api/v1/agents?agent_type=samurai`),W.get(`/api/v1/model-routing-profiles`),W.get(`/api/v1/agent-flows`)]).then(([e,t,r,i])=>{n(e.data?.data?.templates||[]),Te(t.data?.data||[]),De(r.data?.data||[]),ke(i.data?.data||[])})},[]);let je=(0,G.useCallback)(async e=>{if(Ce.current)return;let t=e.data.flowId?String(e.data.flowId):``,n=e.data.templateId?String(e.data.templateId):``;if(!t&&!n){J(`“${String(e.data.label||`This AgentFlow`)}” is not linked to an AgentFlow template.`);return}Ce.current=!0,Se(e.id),J(`Opening the editable AgentFlow...`);try{let r=t;if(!r){let t=await W.post(`/api/v1/agent-flows/from-template`,{template_id:n},{timeout:15e3});if(r=String(t.data?.data?.id||``),!r)throw Error(`The AgentFlow template could not be instantiated.`);i(t=>t.map(t=>t.id===e.id?{...t,data:{...t.data,flowId:r,templateId:void 0}}:t))}let[a,o]=await Promise.all([W.get(`/api/v1/agent-flows/${encodeURIComponent(r)}`,{timeout:15e3}),W.get(`/api/v1/agent-flows`,{timeout:15e3})]);ke(o.data?.data||[]);let s=a.data?.data;if(!s?.id||!Array.isArray(s.nodes)||!Array.isArray(s.edges))throw Error(`The server returned an incomplete AgentFlow.`);be(s),J(``)}catch(e){J(e?.response?.data?.detail||e?.message||`Could not open this AgentFlow.`)}finally{Ce.current=!1,Se(null)}},[i]);(0,G.useEffect)(()=>{if(!e||!t.length)return;let n=e.builder_nodes?.length?e.builder_nodes.map(t=>({id:t.id,position:{x:t.position_x,y:t.position_y},type:`stackFlow`,data:{label:t.label,templateId:t.template_id,flowId:t.flow_id,category:e.category}})):(e.flow_template_ids||[]).map((n,r)=>{let i=t.find(e=>e.id===n);return{id:crypto.randomUUID(),position:{x:340+r*300,y:220},type:`stackFlow`,data:{label:i?.name||n,templateId:n,category:i?.category||e.category}}}),r=e.builder_edges?.length?e.builder_edges.map((e,t)=>({id:`seed-edge-${t}`,source:e.source,target:e.target,animated:!0,style:{stroke:`#8b5cf6`,strokeWidth:2}})):n.slice(1).map((e,t)=>({id:`seed-edge-${t}`,source:n[t].id,target:e.id,animated:!0,style:{stroke:`#8b5cf6`,strokeWidth:2}}));i(n),s(r),w(e.name),D(e.description),S(e.category||`My Templates`),b(`All`),me(``),ge(`draft`),e.orchestrator_config&&(A(t=>e.orchestrator_config?.objective||t),M(e.orchestrator_config.model_routing_profile||`balanced`),P(e.orchestrator_config.failure_policy||`retry`),I(e.orchestrator_config.max_runtime_minutes||1440),ee(e.orchestrator_config.max_iterations||100),V(e.orchestrator_config.max_retry_attempts_per_step??3),ie(e.orchestrator_config.checkpoint_frequency||`after_each_subflow`),oe(e.orchestrator_config.approval_policy||`step_based`),ce(e.orchestrator_config.artifact_policy||`retain_all`)),J(`Opened “${e.name}” in the Stack Builder. Click any AgentFlow block to inspect its internal nodes.`),window.setTimeout(()=>Ae.fitView({padding:.15}),0)},[e,t,Ae,s,i]);let Me=(0,G.useMemo)(()=>[`All`,...Array.from(new Set(t.map(e=>e.category))).sort()],[t]),Ne=(0,G.useMemo)(()=>t.filter(e=>(y===`All`||e.category===y)&&`${e.name} ${e.description}`.toLowerCase().includes(_.toLowerCase())),[t,y,_]),Pe=(0,G.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e)),s(t=>t.filter(t=>t.source!==e&&t.target!==e)),f(t=>t.filter(t=>t!==e))},[s,i]),Fe=(0,G.useCallback)(()=>{if(!u.length&&!p.length)return;let e=new Set(u),t=new Set(p);i(t=>t.filter(t=>!e.has(t.id))),s(n=>n.filter(n=>!t.has(n.id)&&!e.has(n.source)&&!e.has(n.target))),f([]),m([])},[p,u,s,i]),Ie=(0,G.useCallback)(({nodes:e,edges:t})=>{let n=e.map(e=>e.id),r=t.map(e=>e.id);f(e=>e.length===n.length&&e.every((e,t)=>e===n[t])?e:n),m(e=>e.length===r.length&&e.every((e,t)=>e===r[t])?e:r)},[]);(0,G.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let t=e.target;t instanceof HTMLElement&&t.closest(`input, textarea, select, [contenteditable="true"]`)||(e.preventDefault(),Fe())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Fe]);let Le=(0,G.useMemo)(()=>({openEditor:e=>{let t=r.find(t=>t.id===e);t&&je(t)},deleteNode:Pe}),[Pe,r,je]),Re=(0,G.useCallback)((e,t)=>{je(t)},[je]),ze=(0,G.useCallback)(e=>{s(t=>bs({...e,animated:!0,style:{stroke:`#8b5cf6`,strokeWidth:2}},t))},[s]),Be=(0,G.useCallback)((e,t)=>{s(n=>xs(e,t,n))},[s]),Ve=(0,G.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`},[]),He=(0,G.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/shogun-flow-template`);if(!t)return;let n=JSON.parse(t),r=Ae.screenToFlowPosition({x:e.clientX,y:e.clientY}),a=crypto.randomUUID();i(e=>[...e,{id:a,position:r,type:`stackFlow`,data:{label:n.name,templateId:n.id,category:n.category}}])},[Ae,i]),Ue=async e=>{let t=r;if(!t.length)return J(`Drag at least one AgentFlow template onto the canvas.`);if(t.length>1&&!o.length)return J(`Connect the AgentFlow templates before saving.`);fe(!0),J(``);try{let n=await W.post(`/api/v1/agent-flows/flow-stacks/compose`,{name:C,description:E,category:x,nodes:t.map(e=>({id:e.id,template_id:e.data.templateId||void 0,flow_id:e.data.flowId||void 0,label:e.data.label,position_x:e.position.x,position_y:e.position.y})),edges:o.map(e=>({id:e.id,source:e.source,target:e.target})),orchestrator_config:{objective:O,model_routing_profile:j,failure_policy:N,checkpoint_frequency:H,verification_required:!0,max_runtime_minutes:F,max_iterations:R,max_retry_attempts_per_step:B,context_compaction:`enabled`,approval_policy:ae,artifact_policy:se,timeout_seconds:Math.min(F*60,86400)},save_as_template:e});me(String(n.data.data.id)),ge(n.data.data.status===`active`?`active`:n.data.data.status===`paused`?`paused`:`draft`),J(e?`Stack and reusable template saved: ${n.data.data.name}`:`Flow Stack saved: ${n.data.data.name}`)}catch(e){J(e?.response?.data?.detail||`Could not save the Flow Stack.`)}finally{fe(!1)}};return(0,K.jsxs)(`div`,{className:`grid grid-cols-[300px_minmax(0,1fr)] gap-4 min-h-[690px]`,children:[(0,K.jsxs)(`aside`,{className:`shogun-card !p-4 overflow-hidden flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(de,{className:`w-4 h-4 text-shogun-blue`}),(0,K.jsx)(`b`,{className:`text-xs`,children:`AGENTFLOW TEMPLATES`})]}),(0,K.jsxs)(`div`,{className:`relative mb-2`,children:[(0,K.jsx)(te,{className:`absolute w-3.5 h-3.5 left-2.5 top-2.5 text-shogun-subdued`}),(0,K.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:`Search templates`,className:`w-full bg-[#080b16] border border-shogun-border rounded pl-8 pr-2 py-2 text-xs`})]}),(0,K.jsx)(`select`,{value:y,onChange:e=>b(e.target.value),className:`bg-[#080b16] border border-shogun-border rounded p-2 text-xs mb-3`,children:Me.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))}),(0,K.jsx)(`div`,{className:`space-y-2 overflow-y-auto pr-1 flex-1`,children:Ne.map(e=>(0,K.jsxs)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(`application/shogun-flow-template`,JSON.stringify(e)),t.dataTransfer.effectAllowed=`copy`},className:`p-3 rounded-lg border border-shogun-border bg-[#0a0e1a] hover:border-shogun-blue cursor-grab active:cursor-grabbing`,children:[(0,K.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:e.name}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,K.jsx)(`div`,{className:`text-[9px] text-shogun-blue uppercase`,children:e.category}),(0,K.jsx)(`div`,{className:`text-[9px] text-shogun-subdued`,children:`DRAG TO STACK`})]})]},e.id))})]}),(0,K.jsxs)(`section`,{className:`rounded-xl border border-shogun-border bg-[#060913] overflow-hidden relative`,children:[(0,K.jsxs)(`div`,{className:`absolute z-20 top-3 left-3 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`px-3 py-2 rounded bg-[#0e1225]/95 border border-shogun-border text-[10px] text-shogun-subdued`,children:`Drag to reorder · connect handles · click a card to edit`}),(u.length>0||p.length>0)&&(0,K.jsxs)(`button`,{onClick:Fe,className:`flex items-center gap-1.5 rounded border border-red-500/30 bg-[#180b14]/95 px-3 py-2 text-[10px] font-bold text-red-300 hover:bg-red-500/15`,children:[(0,K.jsx)(re,{className:`h-3 w-3`}),`DELETE SELECTED (`,u.length+p.length,`)`]})]}),(0,K.jsx)(Op.Provider,{value:Le,children:(0,K.jsxs)(ef,{nodes:r,edges:o,nodeTypes:Ap,onNodesChange:a,onEdgesChange:c,onConnect:ze,onReconnect:Be,onNodeClick:Re,onSelectionChange:Ie,onDrop:He,onDragOver:Ve,edgesReconnectable:!0,deleteKeyCode:null,fitView:!0,children:[(0,K.jsx)(ff,{variant:cf.Dots,color:`#26305d`,gap:22}),(0,K.jsx)(xf,{}),(0,K.jsx)(If,{nodeColor:`#4a8cc7`})]})}),(0,K.jsxs)(`aside`,{className:U(`absolute z-30 top-3 right-3 w-[360px] rounded-xl border border-purple-400/30 bg-[#0b0e1c]/95 shadow-2xl backdrop-blur transition-all`,h?`max-h-[calc(100%-24px)] overflow-y-auto p-4 space-y-4`:`w-auto p-2`),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ne,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`b`,{className:`text-xs`,children:`STACK ORCHESTRATOR`})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),title:h?`Collapse orchestrator`:`Expand orchestrator`,className:`rounded border border-purple-400/20 p-1 text-purple-300 hover:bg-purple-500/10`,children:h?(0,K.jsx)(d,{className:`h-3.5 w-3.5`}):(0,K.jsx)(l,{className:`h-3.5 w-3.5`})})]}),h&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`group relative rounded-lg border border-purple-400/20 bg-purple-500/5 p-2.5 text-[9px] leading-relaxed text-shogun-subdued`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 font-bold uppercase tracking-wider text-purple-300`,children:[(0,K.jsx)(T,{className:`h-3.5 w-3.5`}),` How the Orchestrator works`]}),(0,K.jsx)(`p`,{className:`mt-1`,children:`It supervises the complete Stack: passing output between AgentFlows, saving checkpoints, retrying failures, compacting long-running context, and verifying results before completion.`}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 hidden w-64 rounded-lg border border-purple-400/30 bg-[#080b16] p-3 text-[9px] normal-case text-shogun-text shadow-2xl group-hover:block`,children:`Configure the goal and safety limits here. Activate the saved Stack when it is ready to run. Pausing a Stack prevents new executions without deleting it.`})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Stack name`,(0,K.jsx)(`input`,{value:C,onChange:e=>w(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs text-shogun-text`})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Stack category`,(0,K.jsx)(`select`,{value:x,onChange:e=>S(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs text-shogun-text`,children:Object.keys(Pp).map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Description`,(0,K.jsx)(`textarea`,{value:E,onChange:e=>D(e.target.value),rows:2,className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs text-shogun-text`})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Objective`,(0,K.jsx)(`textarea`,{value:O,onChange:e=>A(e.target.value),rows:4,className:`mt-1 w-full bg-[#080b16] border border-purple-500/30 rounded p-2 text-xs text-shogun-text`})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Model routing`,(0,K.jsxs)(`select`,{value:j,onChange:e=>M(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,K.jsx)(`option`,{children:`balanced`}),(0,K.jsx)(`option`,{children:`quality`}),(0,K.jsx)(`option`,{children:`speed`}),(0,K.jsx)(`option`,{children:`cost`})]})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`On failure`,(0,K.jsxs)(`select`,{value:N,onChange:e=>P(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,K.jsx)(`option`,{children:`pause`}),(0,K.jsx)(`option`,{children:`retry`}),(0,K.jsx)(`option`,{children:`continue_with_error`}),(0,K.jsx)(`option`,{children:`fail_stack`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Max runtime (min)`,(0,K.jsx)(`input`,{type:`number`,min:1,max:1440,value:F,onChange:e=>I(Number(e.target.value)),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Max iterations`,(0,K.jsx)(`input`,{type:`number`,min:1,max:500,value:R,onChange:e=>ee(Number(e.target.value)),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`})]})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Checkpoints`,(0,K.jsxs)(`select`,{value:H,onChange:e=>ie(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,K.jsx)(`option`,{value:`after_each_subflow`,children:`After every subflow`}),(0,K.jsx)(`option`,{value:`after_each_step`,children:`After every step`}),(0,K.jsx)(`option`,{value:`timed`,children:`Timed`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Retries`,(0,K.jsx)(`input`,{type:`number`,min:0,max:10,value:B,onChange:e=>V(Number(e.target.value)),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Approval`,(0,K.jsxs)(`select`,{value:ae,onChange:e=>oe(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,K.jsx)(`option`,{value:`step_based`,children:`Step based`}),(0,K.jsx)(`option`,{value:`inherited`,children:`Inherited`}),(0,K.jsx)(`option`,{value:`always_required_for_high_risk`,children:`High risk`})]})]})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Artifacts`,(0,K.jsxs)(`select`,{value:se,onChange:e=>ce(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,K.jsx)(`option`,{value:`retain_all`,children:`Retain all`}),(0,K.jsx)(`option`,{value:`retain_final_only`,children:`Final only`}),(0,K.jsx)(`option`,{value:`retain_selected`,children:`Selected`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-shogun-subdued`,children:[(0,K.jsxs)(`span`,{children:[r.length,` flows`]}),(0,K.jsxs)(`span`,{children:[o.length,` connections`]})]}),(0,K.jsxs)(`button`,{disabled:!pe||_e,onClick:async()=>{if(!pe)return J(`Save the Flow Stack before activating it.`);let e=he!==`active`;ve(!0);try{ge((await W.post(`/api/v1/agent-flows/${encodeURIComponent(pe)}/${e?`activate`:`pause`}`)).data?.data?.status===`active`?`active`:`paused`),J(e?`Flow Stack activated and available for execution.`:`Flow Stack deactivated. Existing history is preserved.`)}catch(t){J(t?.response?.data?.detail||`Could not ${e?`activate`:`deactivate`} the Flow Stack.`)}finally{ve(!1)}},title:pe?he===`active`?`Deactivate this Stack`:`Activate this Stack`:`Save the Stack before activating it`,className:U(`w-full flex justify-center items-center gap-2 py-2 rounded text-xs font-bold border disabled:cursor-not-allowed disabled:opacity-40`,he===`active`?`border-green-400/40 bg-green-500/15 text-green-300`:`border-shogun-border bg-[#080b16] text-shogun-subdued`),children:[(0,K.jsx)(L,{className:`w-3.5 h-3.5`}),_e?`UPDATING...`:he===`active`?`ACTIVE — CLICK TO DEACTIVATE`:pe?`ACTIVATE STACK`:`SAVE STACK TO ACTIVATE`]}),(0,K.jsxs)(`button`,{onClick:()=>{i([]),s([]),f([]),m([])},className:`w-full flex justify-center items-center gap-2 py-2 border border-red-500/25 text-red-400 rounded text-xs`,children:[(0,K.jsx)(re,{className:`w-3.5 h-3.5`}),` CLEAR CANVAS`]}),(0,K.jsxs)(`button`,{disabled:le,onClick:()=>Ue(!1),className:`w-full flex justify-center items-center gap-2 py-2 bg-shogun-blue rounded text-white font-bold text-xs`,children:[(0,K.jsx)(z,{className:`w-3.5 h-3.5`}),` SAVE STACK`]}),(0,K.jsxs)(`button`,{disabled:le,onClick:()=>Ue(!0),className:`w-full flex justify-center items-center gap-2 py-2 bg-purple-500/20 border border-purple-400/40 text-purple-300 rounded font-bold text-xs`,children:[(0,K.jsx)(ue,{className:`w-3.5 h-3.5`}),` SAVE AS TEMPLATE`]}),q&&(0,K.jsx)(`div`,{className:`p-2 rounded border border-shogun-border bg-[#080b16] text-[10px] text-shogun-text`,children:q})]})]})]}),xe&&(0,K.jsx)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-[90] -translate-x-1/2 rounded-lg border border-shogun-blue/30 bg-[#0e1225] px-4 py-3 shadow-2xl`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-shogun-text`,children:[(0,K.jsx)(k,{className:`w-5 h-5 animate-spin text-shogun-blue`}),` Opening editable AgentFlow...`]})}),ye&&(0,K.jsx)(Mp,{flow:ye,onClose:()=>be(null),agents:we,routingProfiles:Ee,availableFlows:Oe})]})}var Pp={"Continuous Intelligence":`#22c55e`,"Strategy & Transformation":`#3b82f6`,"Product & Innovation":`#f59e0b`,"Growth & Brand":`#ec4899`,"Customer Operations":`#06b6d4`,"Data & Executive Operations":`#8b5cf6`,"Risk & Compliance":`#ef4444`,"People & Capability":`#14b8a6`,"Incident & Resilience":`#f97316`,"Knowledge & Publishing":`#6366f1`,"My Templates":`#d4a017`};function Fp({onOpen:e}){let{ui:t,category:n,flowStack:r}=ip(),[i,a]=(0,G.useState)([]),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(`All`),[u,d]=(0,G.useState)(``),f=(0,G.useCallback)(()=>W.get(`/api/v1/agent-flows/flow-stack-templates`).then(e=>a(e.data?.data?.templates||[])),[]);(0,G.useEffect)(()=>{f()},[f]);let p=[`All`,...Array.from(new Set(i.map(e=>e.category))).sort()],m=i.filter(e=>c===`All`||e.category===c).map(e=>r(e)).filter(e=>`${e.name} ${e.description} ${e.category}`.toLowerCase().includes(o.toLowerCase()));return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(te,{className:`absolute w-4 h-4 left-3 top-3 text-shogun-subdued`}),(0,K.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:t(`search_stack_templates`,`Search Flow Stack templates`),className:`w-full bg-[#0e1225] border border-shogun-border rounded-lg pl-10 p-2.5 text-sm`})]}),(0,K.jsx)(`select`,{value:c,onChange:e=>l(e.target.value),className:`bg-[#0e1225] border border-shogun-border rounded-lg px-3 text-xs`,style:{color:c===`All`?`#c8d0d8`:Pp[c]||`#c8d0d8`},children:p.map(e=>(0,K.jsx)(`option`,{value:e,style:{color:e===`All`?`#c8d0d8`:Pp[e]||`#c8d0d8`},children:e===`All`?t(`all_stack_categories`,`All Flow Stack Categories`):`● ${n(e)}`},e))}),(0,K.jsx)(`button`,{onClick:f,className:`p-2.5 border border-shogun-border rounded-lg`,children:(0,K.jsx)(R,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`text-xs text-shogun-subdued`,children:[i.length,` `,t(`reusable_templates`,`reusable templates`),` · `,m.length,` `,t(`shown`,`shown`)]}),u&&(0,K.jsx)(`div`,{className:`p-3 border border-shogun-blue/30 bg-shogun-blue/10 rounded text-xs`,children:u}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:m.map(n=>{let r=Pp[i.find(e=>e.id===n.id)?.category||n.category]||`#7a8899`;return(0,K.jsxs)(`div`,{onClick:()=>e(n),className:`shogun-card relative !p-4 flex flex-col min-h-[210px] cursor-pointer hover:border-purple-400/50 transition-colors overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-0.5`,style:{backgroundColor:r}}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(E,{className:`w-5 h-5`,style:{color:r}}),(0,K.jsx)(`span`,{className:`text-[9px] uppercase rounded px-2 py-1 font-bold`,style:{color:r,backgroundColor:`${r}18`},children:n.category})]}),(0,K.jsx)(`h3`,{className:`font-bold text-sm mt-3`,children:n.name}),(0,K.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-2 flex-1`,children:n.description}),(0,K.jsxs)(`div`,{className:`flex gap-2 my-3`,children:[(0,K.jsxs)(`span`,{className:`text-[9px] px-2 py-1 rounded bg-purple-500/10 text-purple-300 border border-purple-500/20`,children:[n.flow_count||0,` `,t(`phases`,`phases`).toUpperCase()]}),(0,K.jsx)(`span`,{className:`text-[9px] px-2 py-1 rounded bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20`,children:n.duration_label||t(`resumable`,`Resumable`)})]}),(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(n)},className:`w-full px-3 py-2 rounded bg-purple-500/20 text-purple-300 border border-purple-500/30 text-[10px] font-bold`,children:t(`open_program`,`Open long-running program`).toUpperCase()})]},n.id)})})]})}function Ip(){let e=`/api/v1/stacks/orchestrator`,[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)([]),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)([]),[p,m]=(0,G.useState)([]),[h,g]=(0,G.useState)([]),[_,v]=(0,G.useState)(`Execute the selected Flow Stack and verify the final output.`),[y,b]=(0,G.useState)(`Every AgentFlow produces a non-empty result -All required verification checks pass`),[x,S]=(0,G.useState)(``),C=(0,G.useCallback)(async()=>{let[t,r]=await Promise.all([W.get(`/api/v1/agent-flows`),W.get(e)]);n((t.data?.data||[]).filter(e=>e.flow_type===`stack`));let a=r.data?.data||[];i(a),c(e=>e||a[0]?.id||``)},[]),w=(0,G.useCallback)(async t=>{if(t)try{let[n,r,i,a]=await Promise.all([W.get(`${e}/${t}`),W.get(`${e}/${t}/checkpoints`),W.get(`${e}/${t}/artifacts`),W.get(`${e}/${t}/verifications`)]);u(n.data?.data||null),f(r.data?.data||[]),m(i.data?.data||[]),g(a.data?.data||[])}catch(e){S(e?.response?.data?.detail||`Could not load the runtime trace.`)}},[]);(0,G.useEffect)(()=>{C()},[C]),(0,G.useEffect)(()=>{if(!s)return;w(s);let e=window.setInterval(()=>{w(s),C()},2e3);return()=>window.clearInterval(e)},[s,w,C]);let T=async()=>{if(!a)return S(`Select a saved Flow Stack first.`);try{let t=(await W.post(`${e}/create`,{mode:`selected_stack`,selected_stack_id:a,objective:_,success_criteria:y.split(` -`).map(e=>e.trim()).filter(Boolean),verification_required:!0,context_compaction:`enabled`,checkpoint_frequency:`after_each_subflow`,failure_policy:`pause`})).data.data.id;await W.post(`${e}/${t}/start`),c(t),S(`Run started with durable checkpoints and independent verification.`),await C()}catch(e){S(e?.response?.data?.detail||`Could not start the run.`)}},E=async(t,n)=>{try{await W.post(`${e}/${t}/${n}`),await w(t),await C()}catch(e){S(e?.response?.data?.detail||`Could not ${n} this run.`)}},D=e=>({completed:`#22c55e`,passed:`#22c55e`,running:`#38bdf8`,retrying:`#f59e0b`,paused:`#f59e0b`,waiting_approval:`#c084fc`,failed:`#ef4444`,cancelled:`#7a8899`,completed_with_errors:`#f97316`})[e]||`#7a8899`;return(0,K.jsxs)(`div`,{className:`grid grid-cols-[340px_minmax(0,1fr)] gap-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(ne,{className:`w-5 h-5 text-purple-400`}),(0,K.jsx)(`b`,{children:`Start governed run`})]}),(0,K.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,K.jsx)(`option`,{value:``,children:`Select Flow Stack`}),t.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Objective`,(0,K.jsx)(`textarea`,{value:_,onChange:e=>v(e.target.value),rows:4,className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs normal-case`})]}),(0,K.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Success criteria — one per line`,(0,K.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),rows:3,className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs normal-case`})]}),(0,K.jsxs)(`button`,{onClick:T,className:`w-full flex justify-center gap-2 items-center bg-purple-500/25 border border-purple-400/40 text-purple-200 py-2 rounded text-xs font-bold`,children:[(0,K.jsx)(P,{className:`w-4 h-4`}),` START ORCHESTRATOR`]}),x&&(0,K.jsx)(`div`,{className:`text-[10px] text-shogun-subdued`,children:x})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`b`,{className:`text-xs`,children:`CURRENT & RECENT RUNS`}),(0,K.jsx)(`button`,{onClick:C,children:(0,K.jsx)(R,{className:`w-4 h-4`})})]}),r.length===0&&(0,K.jsx)(`div`,{className:`shogun-card text-xs text-shogun-subdued`,children:`No stack runs yet.`}),r.map(e=>(0,K.jsxs)(`button`,{onClick:()=>c(e.id),className:U(`shogun-card !p-3 w-full text-left border transition-colors`,s===e.id&&`border-purple-400/60`),children:[(0,K.jsx)(`div`,{className:`font-bold text-xs line-clamp-2`,children:e.objective}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-[9px] uppercase`,children:[(0,K.jsx)(`span`,{style:{color:D(e.status)},children:e.status.replaceAll(`_`,` `)}),(0,K.jsx)(`span`,{className:`text-shogun-subdued`,children:e.posture||`ready`})]})]},e.id))]})]}),(0,K.jsxs)(`div`,{className:`space-y-4 min-w-0`,children:[!l&&(0,K.jsx)(`div`,{className:`shogun-card text-sm text-shogun-subdued`,children:`Select a run to inspect its live execution trace.`}),l&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`shogun-card !p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-[9px] uppercase text-shogun-subdued`,children:`Runtime command view`}),(0,K.jsx)(`h3`,{className:`mt-1 font-bold`,children:l.objective}),(0,K.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[9px]`,children:[(0,K.jsx)(`span`,{className:`rounded border px-2 py-1 uppercase`,style:{color:D(l.status),borderColor:`${D(l.status)}55`},children:l.status.replaceAll(`_`,` `)}),(0,K.jsxs)(`span`,{className:`rounded border border-shogun-border px-2 py-1 text-shogun-subdued`,children:[l.completed_steps?.length||0,`/`,l.steps?.length||0,` steps`]}),(0,K.jsx)(`span`,{className:`rounded border border-shogun-border px-2 py-1 text-shogun-subdued`,children:l.model_profile})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[l.status===`running`&&(0,K.jsx)(`button`,{onClick:()=>E(l.id,`pause`),title:`Pause`,className:`rounded border border-amber-400/30 p-2 text-amber-300`,children:(0,K.jsx)(N,{className:`w-4 h-4`})}),l.status===`paused`&&(0,K.jsx)(`button`,{onClick:()=>E(l.id,`resume`),title:`Resume`,className:`rounded border border-green-400/30 p-2 text-green-300`,children:(0,K.jsx)(ee,{className:`w-4 h-4`})}),![`completed`,`completed_with_errors`,`cancelled`,`failed`].includes(l.status)&&(0,K.jsx)(`button`,{onClick:()=>E(l.id,`cancel`),title:`Cancel`,className:`rounded border border-red-400/30 p-2 text-red-300`,children:(0,K.jsx)(fe,{className:`w-4 h-4`})})]})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1.45fr)_minmax(280px,0.8fr)] gap-4`,children:[(0,K.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,K.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Live execution tree`}),(0,K.jsx)(`div`,{className:`mt-3 space-y-2`,children:(l.steps||[]).map((e,t)=>{let n=e.metadata_json?.routing_decision||{};return(0,K.jsx)(`div`,{className:`rounded-lg border border-shogun-border bg-[#080b16] p-3`,children:(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-[9px] font-bold`,style:{color:D(e.status),borderColor:D(e.status)},children:t+1}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,K.jsx)(`b`,{className:`truncate text-[10px]`,children:e.name}),(0,K.jsx)(`span`,{className:`text-[8px] uppercase`,style:{color:D(e.status)},children:e.status.replaceAll(`_`,` `)})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-3 text-[8px] text-shogun-subdued`,children:[(0,K.jsx)(`span`,{children:e.model_used||`model pending`}),(0,K.jsxs)(`span`,{children:[`profile `,n.active_profile||l.model_profile]}),(0,K.jsxs)(`span`,{children:[`complexity `,n.complexity_score??`—`]}),(0,K.jsxs)(`span`,{children:[`cost tier `,n.estimated_cost_tier??`—`]}),(0,K.jsxs)(`span`,{children:[`escalation `,n.escalation_level||`none`]}),(0,K.jsxs)(`span`,{children:[`retry `,e.retry_count,`/`,e.max_retries]}),(0,K.jsxs)(`span`,{style:{color:D(e.verification_status)},children:[`verification `,e.verification_status]})]}),n.reason&&(0,K.jsx)(`p`,{className:`mt-1 text-[8px] text-purple-300`,children:n.reason}),e.error_json?.message&&(0,K.jsx)(`p`,{className:`mt-2 text-[8px] text-red-400`,children:e.error_json.message})]})]})},e.id)})})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,K.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Independent verification`}),(0,K.jsxs)(`div`,{className:`mt-3 space-y-2 max-h-64 overflow-y-auto`,children:[h.map(e=>(0,K.jsxs)(`div`,{className:`rounded border border-shogun-border p-2`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between gap-2 text-[8px] uppercase`,children:[(0,K.jsx)(`b`,{children:e.verification_type.replaceAll(`_`,` `)}),(0,K.jsx)(`span`,{style:{color:D(e.status)},children:e.status})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[8px] text-shogun-subdued`,children:e.observed_result}),(0,K.jsxs)(`div`,{className:`mt-1 text-[8px] text-purple-300`,children:[e.metadata_json?.verifier_mode||`evidence`,` · score `,e.metadata_json?.score??`—`]})]},e.id)),h.length===0&&(0,K.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:`No verification evidence yet.`})]})]}),(0,K.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,K.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Evidence & continuity`}),(0,K.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-center`,children:[(0,K.jsxs)(`div`,{className:`rounded bg-[#080b16] p-2`,children:[(0,K.jsx)(`b`,{className:`text-purple-300`,children:d.length}),(0,K.jsx)(`div`,{className:`text-[7px] uppercase text-shogun-subdued`,children:`checkpoints`})]}),(0,K.jsxs)(`div`,{className:`rounded bg-[#080b16] p-2`,children:[(0,K.jsx)(`b`,{className:`text-blue-300`,children:p.length}),(0,K.jsx)(`div`,{className:`text-[7px] uppercase text-shogun-subdued`,children:`artifacts`})]}),(0,K.jsxs)(`div`,{className:`rounded bg-[#080b16] p-2`,children:[(0,K.jsx)(`b`,{className:`text-green-300`,children:h.filter(e=>e.status===`passed`).length}),(0,K.jsx)(`div`,{className:`text-[7px] uppercase text-shogun-subdued`,children:`passed`})]})]}),d[0]&&(0,K.jsxs)(`div`,{className:`mt-3 rounded border border-shogun-border p-2`,children:[(0,K.jsx)(`b`,{className:`text-[8px]`,children:`Latest durable checkpoint`}),(0,K.jsx)(`p`,{className:`mt-1 line-clamp-4 whitespace-pre-wrap text-[8px] text-shogun-subdued`,children:d[0].context_summary}),(0,K.jsx)(`p`,{className:`mt-1 text-[8px] text-purple-300`,children:d[0].resume_instruction})]})]})]})]}),Object.keys(l.final_summary||{}).length>0&&(0,K.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,K.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Final verified summary`}),(0,K.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 text-[9px]`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-shogun-subdued`,children:`Status`}),(0,K.jsx)(`p`,{style:{color:D(l.final_summary.final_status)},children:l.final_summary.final_status?.replaceAll(`_`,` `)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-shogun-subdued`,children:`Files changed`}),(0,K.jsx)(`p`,{children:l.final_summary.files_changed?.length||0})]}),(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`span`,{className:`text-shogun-subdued`,children:`Known issues`}),(0,K.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap text-[8px] text-amber-300`,children:JSON.stringify(l.final_summary.known_issues||[],null,2)})]})]})]})]})]})]})}var Lp=()=>{let{ui:e}=ip(),[t,n]=(0,G.useState)(`builder`),[r,i]=(0,G.useState)(null);return(0,K.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-500`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,K.jsx)(E,{className:`text-purple-400`}),` `,e(`flow_stacking`,`Flow Stacking`)]}),(0,K.jsx)(`p`,{className:`text-sm text-shogun-subdued mt-1`,children:e(`flow_stacking_subtitle`,`Compose AgentFlows into connected, orchestrated systems.`)})]}),(0,K.jsxs)(`div`,{className:`text-[10px] px-3 py-1.5 border border-purple-500/30 bg-purple-500/10 text-purple-300 rounded-full`,children:[`208 `,e(`built_in_stacks`,`built-in stacks`).toUpperCase()]})]}),(0,K.jsx)(`div`,{className:`flex gap-2 border border-shogun-border bg-shogun-card p-1 rounded-lg w-fit`,children:[[`builder`,F,e(`stack_builder`,`Stack Builder`).toUpperCase()],[`templates`,H,e(`stack_templates`,`Stack Templates`).toUpperCase()],[`runtime`,ne,e(`orchestrator`,`Orchestrator`).toUpperCase()]].map(([e,r,i])=>(0,K.jsxs)(`button`,{onClick:()=>n(e),className:U(`flex items-center gap-2 px-4 py-2 rounded text-xs font-bold`,t===e?`bg-purple-500/20 border border-purple-400/40 text-purple-200`:`text-shogun-subdued border border-transparent`),children:[(0,K.jsx)(r,{className:`w-4 h-4`}),i]},e))}),t===`builder`&&(0,K.jsx)(Xd,{children:(0,K.jsx)(Np,{seed:r?.template||null})},`stack-builder-${r?.revision||0}`),t===`templates`&&(0,K.jsx)(Fp,{onOpen:e=>{i(t=>({template:{...e,builder_nodes:e.builder_nodes?.map(e=>({...e})),builder_edges:e.builder_edges?.map(e=>({...e}))},revision:(t?.revision||0)+1})),n(`builder`)}}),t===`runtime`&&(0,K.jsx)(Ip,{})]})},Rp=()=>{let{t:e}=le(),[t,n]=(0,G.useState)([]),[r,i]=(0,G.useState)([]),[a,o]=(0,G.useState)([]),[s,l]=(0,G.useState)([]),[u,d]=(0,G.useState)(!0),[f,p]=(0,G.useState)(!1),[m,h]=(0,G.useState)(`fleet`),[g,v]=(0,G.useState)(``),[y,b]=(0,G.useState)(null),[x,C]=(0,G.useState)({name:``,description:``,spawn_policy:`manual`,role_id:``,model_routing_profile_id:``}),[w,T]=(0,G.useState)(!1),[D,O]=(0,G.useState)(null),k=(0,G.useRef)(null),A=(0,G.useRef)(null),[j,M]=(0,G.useState)(null),[F,L]=(0,G.useState)(null),[ee,ne]=(0,G.useState)(!1),[V,H]=(0,G.useState)({name:``,slug:``,description:``,role_id:``,model_routing_profile_id:``,agent_type:`samurai`,spawn_policy:`manual`,tags:[]});(0,G.useEffect)(()=>{Xf(),$(`samurai.mount`,{build:tp(),path:window.location.pathname,href:window.location.href,width:window.innerWidth,height:window.innerHeight}),Yf(`mount-immediate`),window.setTimeout(()=>Yf(`mount-500ms`),500),window.setTimeout(()=>Yf(`mount-2000ms`),2e3),window.location.hash===`#agent-flow`?($(`samurai.hash_open_agent_flow`),h(`agent-flow`)):window.location.hash===`#flow-stack`&&h(`flow-stack`),ie()},[]),(0,G.useEffect)(()=>{$(`samurai.active_tab`,{activeTab:m}),window.setTimeout(()=>{let e=Array.from(document.querySelectorAll(`button`)).map(e=>e.textContent?.trim()).filter(Boolean).filter(e=>e===`Fleet`||e===`Agent Flow`||e===`Flow Stack`);$(`samurai.tab_dom_check`,{activeTab:m,foundTabs:e,tabCount:e.length}),Yf(`active-tab-${m}`)},0)},[m]);let ie=async()=>{d(!0),$(`samurai.fetch_all.start`);try{let[e,t,r,a]=await Promise.all([W.get(`/api/v1/agents?agent_type=samurai`),W.get(`/api/v1/missions`),W.get(`/api/v1/samurai-roles`),W.get(`/api/v1/model-routing-profiles`)]);e.data.data&&n(e.data.data),t.data.data&&i(t.data.data),r.data.data&&o(r.data.data),a.data.data&&l(a.data.data),$(`samurai.fetch_all.success`,{agents:e.data?.data?.length||0,missions:t.data?.data?.length||0,roles:r.data?.data?.length||0,routingProfiles:a.data?.data?.length||0})}catch(e){console.error(`Error fetching data:`,e),$(`samurai.fetch_all.error`,{error:e})}finally{d(!1)}},ae=async()=>{let e=await $f();e||ep(),ne(e),window.setTimeout(()=>ne(!1),2e3)},ue=e=>r.find(t=>t.assigned_agent_id===e&&[`in_progress`,`pending`,`queued`].includes(t.status)),de=e=>{if(!e?.started_at)return e?.status===`pending`||e?.status===`queued`?5:0;let t=Date.now()-new Date(e.started_at).getTime();return Math.min(95,Math.round(t/(300*1e3)*100))},fe=async e=>{e.preventDefault();try{let e=V.name.toLowerCase().replace(/\s+/g,`-`),t=await W.post(`/api/v1/agents`,{...V,slug:e,model_routing_profile_id:V.model_routing_profile_id||null});if(j&&t.data?.data?.id){let e=new FormData;e.append(`file`,j);try{await W.post(`/api/v1/agents/${t.data.data.id}/avatar`,e,{headers:{"Content-Type":`multipart/form-data`}})}catch{}}p(!1),H({name:``,slug:``,description:``,role_id:``,model_routing_profile_id:``,agent_type:`samurai`,spawn_policy:`manual`,tags:[]}),M(null),L(null),ie()}catch(e){console.error(`Error creating agent:`,e)}},he=async e=>{let t=e.target.files?.[0];if(!t||!y)return;let r=new FormData;r.append(`file`,t);try{let e=await W.post(`/api/v1/agents/${y.id}/avatar`,r,{headers:{"Content-Type":`multipart/form-data`}});b({...y,avatar_url:e.data.data.avatar_url}),n(t=>t.map(t=>t.id===y.id?{...t,avatar_url:e.data.data.avatar_url}:t))}catch{O(`Failed to upload avatar.`)}},ge=e=>{let t=e.target.files?.[0];if(!t)return;M(t);let n=new FileReader;n.onloadend=()=>L(n.result),n.readAsDataURL(t)},ve=async(t,n)=>{try{if(n===`delete`){if(!confirm(e(`samurai_network.confirm_delete`)))return;await W.delete(`/api/v1/agents/${t}`)}else await W.post(`/api/v1/agents/${t}/${n}`);ie()}catch(e){console.error(`Error performing ${n}:`,e)}},q=e=>{b(e),C({name:e.name||``,description:e.description||``,spawn_policy:e.spawn_policy||`manual`,role_id:e.samurai_profile?.role_id||e.samurai_profile?.samurai_role?.id||``,model_routing_profile_id:e.model_routing_profile_id||``}),O(null)},J=async()=>{if(y){T(!0),O(null);try{await W.patch(`/api/v1/agents/${y.id}`,{name:x.name,description:x.description,spawn_policy:x.spawn_policy,model_routing_profile_id:x.model_routing_profile_id||null,...x.role_id?{role_id:x.role_id}:{}}),b(null),ie()}catch(t){O(t?.response?.data?.detail||e(`samurai_network.save_failed`))}finally{T(!1)}}},ye=e=>e.routing_profile?.name||null,be=t.filter(e=>e.name.toLowerCase().includes(g.toLowerCase())||e.slug.toLowerCase().includes(g.toLowerCase())),xe=e=>{$(`samurai.tab_click`,{tab:e}),h(e),window.history.replaceState(null,``,e===`fleet`?window.location.pathname:`#${e}`),window.setTimeout(()=>Yf(`tab-click-${e}`),0)};return(0,K.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 pb-12`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`samurai_network.title`,`Samurai Network`),(0,K.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:e(`samurai_network.fleet_status`)})]}),(0,K.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`samurai_network.subtitle`,`Orchestrate specialized sub-agents across the mission grid.`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`button`,{onClick:ae,className:`flex items-center gap-2 bg-shogun-card border border-shogun-border hover:border-shogun-blue text-shogun-subdued hover:text-shogun-blue font-bold py-2.5 px-3 rounded-lg transition-all text-[10px] uppercase tracking-widest`,title:`Copy Samurai diagnostics`,children:[(0,K.jsx)(pe,{className:`w-3.5 h-3.5`}),ee?`Copied`:`Copy Diagnostics`]}),(0,K.jsx)(`button`,{onClick:ep,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,title:`Download Samurai diagnostics`,children:(0,K.jsx)(_,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:Zf,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-red-400 transition-colors text-[10px] font-bold`,title:`Clear Samurai diagnostics`,children:`CLR`}),m===`fleet`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:ie,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,K.jsx)(R,{className:U(`w-4 h-4`,u&&`animate-spin`)})}),(0,K.jsxs)(`button`,{onClick:()=>p(!0),className:`flex items-center gap-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun`,children:[(0,K.jsx)(I,{className:`w-4 h-4`}),` `,e(`samurai_network.deploy_samurai`,`DEPLOY SAMURAI`)]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 border border-shogun-border bg-shogun-card p-1 rounded-lg w-fit`,children:[(0,K.jsxs)(`button`,{onClick:()=>xe(`fleet`),className:U(`flex items-center gap-2 px-5 py-3 text-xs font-bold uppercase tracking-wider transition-all rounded-md border`,m===`fleet`?`text-black bg-shogun-gold border-shogun-gold shadow-shogun`:`text-shogun-subdued border-transparent hover:text-shogun-text hover:border-shogun-border`),children:[(0,K.jsx)(oe,{className:`w-4 h-4`}),e(`samurai_network.tab_fleet`,`Fleet`)]}),(0,K.jsxs)(`button`,{onClick:()=>xe(`agent-flow`),className:U(`flex items-center gap-2 px-5 py-3 text-xs font-bold uppercase tracking-wider transition-all rounded-md border`,m===`agent-flow`?`text-black bg-shogun-gold border-shogun-gold shadow-shogun`:`text-shogun-subdued border-transparent hover:text-shogun-text hover:border-shogun-border`),children:[(0,K.jsx)(S,{className:`w-4 h-4`}),e(`samurai_network.tab_agent_flow`,`Agent Flow`)]}),(0,K.jsxs)(`button`,{onClick:()=>xe(`flow-stack`),className:U(`flex items-center gap-2 px-5 py-3 text-xs font-bold uppercase tracking-wider transition-all rounded-md border`,m===`flow-stack`?`text-black bg-shogun-gold border-shogun-gold shadow-shogun`:`text-shogun-subdued border-transparent hover:text-shogun-text hover:border-shogun-border`),children:[(0,K.jsx)(E,{className:`w-4 h-4`}),`Flow Stack`]})]}),m===`agent-flow`&&(0,K.jsx)(Dp,{}),m===`flow-stack`&&(0,K.jsx)(Lp,{}),m===`fleet`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-6`,children:[{label:e(`samurai_network.total_fleet`,`Total Fleet`),value:t.length.toString(),icon:oe,color:`text-shogun-gold`},{label:e(`samurai_network.active`,`Active`),value:t.filter(e=>e.status===`active`).length.toString(),icon:P,color:`text-green-500`},{label:e(`samurai_network.suspended`,`Suspended`),value:t.filter(e=>e.status===`suspended`).length.toString(),icon:N,color:`text-shogun-blue`},{label:e(`samurai_network.signal_range`,`Signal Range`),value:`100%`,icon:_e,color:`text-shogun-subdued`}].map((e,t)=>(0,K.jsxs)(`div`,{className:`shogun-card flex flex-col gap-1 border-l-2`,style:{borderLeftColor:t===0?`#d4a017`:t===1?`#22c55e`:t===2?`#4a8cc7`:`#1a2040`},children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-shogun-subdued mb-1`,children:[(0,K.jsx)(e.icon,{className:U(`w-3 h-3`,e.color)}),(0,K.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-bold`,children:e.label})]}),(0,K.jsx)(`span`,{className:`text-2xl font-bold text-shogun-text`,children:e.value})]},t))}),(0,K.jsxs)(`div`,{className:`shogun-card overflow-hidden !p-0`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-shogun-border bg-[#050508]/50 flex items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1 max-w-md`,children:[(0,K.jsx)(te,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-shogun-subdued`}),(0,K.jsx)(`input`,{type:`text`,placeholder:e(`samurai_network.filter_placeholder`),value:g,onChange:e=>v(e.target.value),className:`w-full bg-shogun-card border border-shogun-border rounded-lg pl-10 pr-4 py-2 text-sm focus:border-shogun-blue transition-colors outline-none`})]}),(0,K.jsxs)(`select`,{className:`bg-shogun-card border border-shogun-border rounded-lg px-3 py-2 text-xs text-shogun-subdued outline-none focus:border-shogun-blue`,children:[(0,K.jsx)(`option`,{children:e(`samurai_network.all_status`)}),(0,K.jsx)(`option`,{children:e(`samurai_network.status_active`)}),(0,K.jsx)(`option`,{children:e(`samurai_network.status_suspended`)})]})]}),(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-left border-collapse`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-shogun-border bg-[#050508]/30`,children:[(0,K.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_designation`,`Designation`)}),(0,K.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_status`,`Status`)}),(0,K.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_task`,`Current Task`)}),(0,K.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_role`,`Role / Slug`)}),(0,K.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_routing`,`Routing`)}),(0,K.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_deployed`,`Deployed At`)}),(0,K.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest text-right`,children:e(`common.actions`,`Actions`)})]})}),(0,K.jsx)(`tbody`,{children:u?(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:7,className:`p-12 text-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-6 h-6 border-2 border-shogun-gold border-t-transparent rounded-full animate-spin`}),(0,K.jsx)(`span`,{className:`text-xs text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.scanning_grid`)})]})})}):be.length===0?(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:7,className:`p-12 text-center text-shogun-subdued text-sm italic`,children:e(`samurai_network.no_samurai`)})}):be.map(t=>{let n=ye(t);return(0,K.jsxs)(`tr`,{className:`border-b border-shogun-border hover:bg-shogun-gold/5 transition-colors group`,children:[(0,K.jsx)(`td`,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`w-10 h-10 rounded-lg bg-shogun-card border border-shogun-border flex items-center justify-center text-shogun-gold font-bold relative overflow-hidden`,children:[t.avatar_url&&t.avatar_url!==`/shogun-avatar.png`?(0,K.jsx)(`img`,{src:t.avatar_url,alt:t.name,className:`w-full h-full object-cover`}):t.name[0],(0,K.jsx)(`div`,{className:`absolute -top-1 -right-1 w-4 h-4 rounded-full bg-shogun-blue border border-[#0a0e1a] flex items-center justify-center`,children:(0,K.jsx)(oe,{className:`w-2 h-2 text-white`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col`,children:[(0,K.jsx)(`span`,{className:`font-bold text-shogun-text text-sm`,children:t.name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-tighter`,children:[`ID: `,t.id.slice(0,8)]}),t.samurai_profile?.samurai_role&&(0,K.jsx)(`span`,{className:`text-[9px] bg-shogun-blue/10 text-shogun-blue px-1.5 py-0.5 rounded border border-shogun-blue/20 font-bold uppercase tracking-widest`,children:t.samurai_profile.samurai_role.name})]})]})]})}),(0,K.jsx)(`td`,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:U(`w-1.5 h-1.5 rounded-full`,t.status===`active`?`bg-green-500`:`bg-shogun-blue`)}),(0,K.jsx)(`span`,{className:U(`text-[10px] font-bold uppercase tracking-widest`,t.status===`active`?`text-green-500`:`text-shogun-blue`),children:t.status===`active`?e(`samurai_network.status_active`):e(`samurai_network.status_suspended`)})]})}),(0,K.jsx)(`td`,{className:`p-4`,children:(()=>{let n=ue(t.id);if(!n)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-shogun-subdued/40`}),(0,K.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:e(`samurai_network.idle`)})]});let r=de(n);return(0,K.jsxs)(`div`,{className:`space-y-1.5 min-w-[180px]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text truncate max-w-[160px]`,title:n.title,children:n.title}),(0,K.jsxs)(`span`,{className:`text-[9px] font-mono font-bold text-shogun-gold shrink-0`,children:[r,`%`]})]}),(0,K.jsx)(`div`,{className:`w-full h-1.5 bg-[#0a0e1a] rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:U(`h-full rounded-full transition-all duration-700`,r<30?`bg-gradient-to-r from-shogun-blue to-shogun-blue/70`:r<70?`bg-gradient-to-r from-shogun-blue via-shogun-gold/60 to-shogun-gold`:`bg-gradient-to-r from-shogun-gold to-green-400`),style:{width:`${r}%`}})})]})})()}),(0,K.jsx)(`td`,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsx)(`code`,{className:`text-[10px] bg-shogun-card px-2 py-1 rounded border border-shogun-border text-shogun-blue w-fit`,children:t.slug}),t.samurai_profile?.samurai_role?.purpose&&(0,K.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic line-clamp-1 max-w-[150px]`,children:t.samurai_profile.samurai_role.purpose})]})}),(0,K.jsx)(`td`,{className:`p-4`,children:n?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(ce,{className:`w-3 h-3 text-shogun-gold/70 shrink-0`}),(0,K.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-gold/90 truncate max-w-[120px]`,title:n,children:n})]}):(0,K.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:e(`samurai_network.default_routing`)})}),(0,K.jsx)(`td`,{className:`p-4 text-xs text-shogun-subdued`,children:new Date(t.created_at).toLocaleDateString()}),(0,K.jsx)(`td`,{className:`p-4 text-right`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:[t.status===`active`?(0,K.jsx)(`button`,{onClick:()=>ve(t.id,`suspend`),className:`p-1.5 hover:bg-shogun-blue/10 text-shogun-blue rounded transition-colors`,title:e(`samurai_network.suspend_agent`),children:(0,K.jsx)(N,{className:`w-3.5 h-3.5`})}):(0,K.jsx)(`button`,{onClick:()=>ve(t.id,`resume`),className:`p-1.5 hover:bg-green-500/10 text-green-500 rounded transition-colors`,title:e(`samurai_network.resume_agent`),children:(0,K.jsx)(P,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>ve(t.id,`delete`),className:`p-1.5 hover:bg-red-500/10 text-red-500 rounded transition-colors`,title:e(`samurai_network.delete_agent`),children:(0,K.jsx)(re,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>q(t),className:`p-1.5 hover:bg-shogun-gold/10 text-shogun-gold rounded transition-colors`,title:e(`samurai_network.configure_samurai`),children:(0,K.jsx)(me,{className:`w-3.5 h-3.5`})})]})})]},t.id)})})]})})]}),y&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-200`,onClick:e=>{e.target===e.currentTarget&&b(null)},children:(0,K.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-shogun-border rounded-xl w-full max-w-lg shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,K.jsxs)(`div`,{className:`bg-shogun-card border-b border-shogun-border p-6 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsxs)(`div`,{onClick:()=>k.current?.click(),className:`w-14 h-14 rounded-xl bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-gold font-bold text-lg relative cursor-pointer group hover:border-shogun-gold/50 transition-all overflow-hidden shrink-0`,children:[y.avatar_url&&y.avatar_url!==`/shogun-avatar.png`?(0,K.jsx)(`img`,{src:y.avatar_url,alt:y.name,className:`w-full h-full object-cover`}):y.name[0],(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)(c,{className:`w-4 h-4 text-shogun-gold`})})]}),(0,K.jsx)(`input`,{type:`file`,ref:k,className:`hidden`,accept:`image/*`,onChange:he}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(B,{className:`w-4 h-4 text-shogun-gold`}),(0,K.jsx)(`h3`,{className:`text-lg font-bold text-shogun-gold`,children:e(`samurai_network.configure_samurai`)})]}),(0,K.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold mt-1`,children:[y.name,` · `,(0,K.jsx)(`span`,{className:`font-mono`,children:y.id.slice(0,8)})]})]})]}),(0,K.jsx)(`button`,{onClick:()=>b(null),className:`p-2 hover:bg-shogun-gold/10 text-shogun-subdued hover:text-shogun-gold rounded-lg transition-colors`,children:(0,K.jsx)(se,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.unit_name`)}),(0,K.jsx)(`input`,{type:`text`,value:x.name,onChange:e=>C({...x,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.designation_role`)}),(0,K.jsxs)(`select`,{value:x.role_id,onChange:e=>C({...x,role_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:e(`samurai_network.keep_current_role`)}),a.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),y.samurai_profile?.samurai_role?.name&&(0,K.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[e(`samurai_network.current`),`: `,(0,K.jsx)(`span`,{className:`text-shogun-blue font-bold`,children:y.samurai_profile.samurai_role.name})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,K.jsx)(ce,{className:`w-3 h-3 text-shogun-gold/70`}),` `,e(`samurai_network.routing_profile`)]}),(0,K.jsxs)(`select`,{value:x.model_routing_profile_id,onChange:e=>C({...x,model_routing_profile_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:e(`samurai_network.system_default`)}),s.map(t=>(0,K.jsxs)(`option`,{value:t.id,children:[t.name,t.is_default?` (${e(`samurai_network.default_routing`)})`:``]},t.id))]}),y.routing_profile?.name&&(0,K.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[e(`samurai_network.current`),`: `,(0,K.jsx)(`span`,{className:`text-shogun-gold font-bold`,children:y.routing_profile.name})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.spawn_policy`)}),(0,K.jsxs)(`select`,{value:x.spawn_policy,onChange:e=>C({...x,spawn_policy:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`manual`,children:e(`samurai_network.manual_deploy`)}),(0,K.jsx)(`option`,{value:`auto`,children:e(`samurai_network.auto_spawn`)}),(0,K.jsx)(`option`,{value:`scheduled`,children:e(`samurai_network.scheduled_routine`)})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.operational_directive`)}),(0,K.jsx)(`textarea`,{value:x.description,onChange:e=>C({...x,description:e.target.value}),rows:3,className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-xs focus:border-shogun-gold transition-colors outline-none resize-none`,placeholder:e(`samurai_network.directive_placeholder`)})]}),D&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,K.jsx)(se,{className:`w-3.5 h-3.5 text-red-400 shrink-0`}),(0,K.jsx)(`p`,{className:`text-xs text-red-400`,children:D})]})]}),(0,K.jsxs)(`div`,{className:`p-6 pt-0 flex gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>b(null),className:`flex-1 bg-shogun-card hover:bg-[#1a2040] text-shogun-subdued font-bold py-2.5 rounded-lg transition-all border border-shogun-border text-sm`,children:e(`common.cancel`)}),(0,K.jsxs)(`button`,{onClick:J,disabled:w||!x.name.trim(),className:U(`flex-1 font-bold py-2.5 rounded-lg transition-all text-sm flex items-center justify-center gap-2`,w||!x.name.trim()?`bg-shogun-subdued/20 text-shogun-subdued cursor-not-allowed`:`bg-shogun-gold hover:bg-shogun-gold/90 text-black shadow-shogun`),children:[w?(0,K.jsx)(R,{className:`w-3.5 h-3.5 animate-spin`}):(0,K.jsx)(z,{className:`w-3.5 h-3.5`}),e(w?`samurai_network.saving`:`samurai_network.save_changes`)]})]})]})}),f&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-300`,onClick:e=>{e.target===e.currentTarget&&p(!1)},children:(0,K.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-shogun-border rounded-xl w-full max-w-lg shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300`,children:[(0,K.jsxs)(`div`,{className:`bg-shogun-card border-b border-shogun-border p-6 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsxs)(`div`,{onClick:()=>A.current?.click(),className:`w-14 h-14 rounded-xl bg-[#050508] border border-dashed border-shogun-border flex items-center justify-center relative cursor-pointer group hover:border-shogun-gold/50 transition-all overflow-hidden shrink-0`,children:[F?(0,K.jsx)(`img`,{src:F,alt:`Avatar preview`,className:`w-full h-full object-cover`}):(0,K.jsx)(c,{className:`w-5 h-5 text-shogun-subdued group-hover:text-shogun-gold transition-colors`}),F&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)(c,{className:`w-4 h-4 text-shogun-gold`})})]}),(0,K.jsx)(`input`,{type:`file`,ref:A,className:`hidden`,accept:`image/*`,onChange:ge}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xl font-bold text-shogun-gold`,children:e(`samurai_network.deploy_new`)}),(0,K.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold mt-1`,children:e(`samurai_network.initialize_fleet`)})]})]}),(0,K.jsx)(`button`,{onClick:()=>{p(!1),M(null),L(null)},className:`p-2 hover:bg-shogun-gold/10 text-shogun-subdued hover:text-shogun-gold rounded-lg transition-colors`,children:(0,K.jsx)(se,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`form`,{onSubmit:fe,className:`p-6 space-y-5`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.samurai_designation`)}),(0,K.jsxs)(`select`,{required:!0,value:V.role_id,onChange:e=>{let t=a.find(t=>t.id===e.target.value);t&&H({...V,role_id:t.id,name:t.name,description:t.description||t.purpose})},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,disabled:!0,children:e(`samurai_network.select_role`)}),a.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.custom_unit_name`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,value:V.name,onChange:e=>H({...V,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none`,placeholder:`e.g. Shadow Scout`})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.spawn_policy`)}),(0,K.jsxs)(`select`,{value:V.spawn_policy,onChange:e=>H({...V,spawn_policy:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`manual`,children:e(`samurai_network.manual_deploy`)}),(0,K.jsx)(`option`,{value:`auto`,children:e(`samurai_network.auto_spawn`)}),(0,K.jsx)(`option`,{value:`scheduled`,children:e(`samurai_network.scheduled_routine`)})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,K.jsx)(ce,{className:`w-3 h-3 text-shogun-gold/70`}),` `,e(`samurai_network.model_routing_profile`)]}),(0,K.jsxs)(`select`,{value:V.model_routing_profile_id,onChange:e=>H({...V,model_routing_profile_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:e(`samurai_network.system_default`)}),s.map(t=>(0,K.jsxs)(`option`,{value:t.id,children:[t.name,t.is_default?` (${e(`samurai_network.default_routing`)})`:``]},t.id))]}),(0,K.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:e(`samurai_network.routing_description`)})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.operational_directive`)}),(0,K.jsx)(`textarea`,{value:V.description,onChange:e=>H({...V,description:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-xs focus:border-shogun-blue transition-colors outline-none h-24 resize-none`,placeholder:e(`samurai_network.auto_populate_placeholder`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-1`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>p(!1),className:`flex-1 bg-shogun-card hover:bg-[#1a2040] text-shogun-subdued font-bold py-3 rounded-lg transition-all border border-shogun-border`,children:e(`samurai_network.abort`)}),(0,K.jsx)(`button`,{type:`submit`,disabled:!V.name||!V.role_id,className:U(`flex-1 font-bold py-3 rounded-lg transition-all shadow-shogun`,!V.name||!V.role_id?`bg-shogun-subdued/20 text-shogun-subdued cursor-not-allowed`:`bg-shogun-blue hover:bg-shogun-blue/90 text-white`),children:e(`samurai_network.deploy_samurai_btn`)})]})]})]})})]})]})};export{Rp as SamuraiNetwork}; \ No newline at end of file diff --git a/frontend/dist/assets/SamuraiNetwork-fAu0Eoqm.js b/frontend/dist/assets/SamuraiNetwork-fAu0Eoqm.js new file mode 100644 index 0000000..ba5a831 --- /dev/null +++ b/frontend/dist/assets/SamuraiNetwork-fAu0Eoqm.js @@ -0,0 +1,17 @@ +import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./calendar-Cad5gZZR.js";import{t as r}from"./camera-BK7z_aNh.js";import{t as i}from"./chevron-down-qQcy55Tl.js";import{t as a}from"./chevron-left-CoAjCl9c.js";import{t as o}from"./chevron-up-BQBhWwJ7.js";import{t as s}from"./circle-check-DBu5bzEI.js";import{t as c}from"./circle-x-Dv8yz1YS.js";import{t as l}from"./clock-DQ9Dz1_z.js";import{t as u}from"./code-xml-DLPBFEaQ.js";import{t as d}from"./copy-BVi6zu1A.js";import{t as f}from"./eye-jI9oiQpv.js";import{t as p}from"./file-spreadsheet-ikcYZmJa.js";import{t as m}from"./file-text-CrD-Um8r.js";import{t as h}from"./folder-open-CZ39dYm6.js";import{t as g}from"./git-branch-qj-Uwi0O.js";import{t as _}from"./info-D6evxaHJ.js";import{t as v}from"./layers-PPVhckft.js";import{t as y}from"./layout-grid-BCXZ_u1g.js";import{t as b}from"./link-Cl51GLTm.js";import{t as x}from"./mail-Ca9FQxut.js";import{t as S}from"./pause-B7kChltd.js";import{n as C,t as w}from"./route-B34TZTak.js";import{t as T}from"./plus-Cxx0HjpF.js";import{t as E}from"./power-Bl6a5geq.js";import{t as D}from"./refresh-cw-Dm6S5UAJ.js";import{t as O}from"./rotate-ccw-B4t0zm9t.js";import{t as k}from"./save-CupVJLfi.js";import{t as A}from"./search-DuRUeriq.js";import{t as j}from"./settings-DedojrI9.js";import{t as M}from"./sparkles-DyLIKWW0.js";import{t as N}from"./trash-2-DqRUHXwV.js";import{t as P}from"./upload-NSOxRjZn.js";import{t as F}from"./zap-CQy--vuS.js";import{A as I,T as L,_ as R,a as ee,b as z,c as te,d as B,g as V,i as H,j as U,k as W,m as ne,o as re,p as G,r as ie,t as ae,u as oe,y as se}from"./index-Dy1E248t.js";import{t as K}from"./axios-BGmZl9Qd.js";var ce=L(`bookmark-plus`,[[`path`,{d:`M12 7v6`,key:`lw1j43`}],[`path`,{d:`M15 10H9`,key:`o6yqo3`}],[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),le=L(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),ue=L(`circle-stop`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`rect`,{x:`9`,y:`9`,width:`6`,height:`6`,rx:`1`,key:`1ssd4o`}]]),de=L(`clipboard`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}]]),fe=L(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),pe=L(`log-in`,[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]),me=L(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),he=L(`radio`,[[`path`,{d:`M16.247 7.761a6 6 0 0 1 0 8.478`,key:`1fwjs5`}],[`path`,{d:`M19.075 4.933a10 10 0 0 1 0 14.134`,key:`ehdyv1`}],[`path`,{d:`M4.925 19.067a10 10 0 0 1 0-14.134`,key:`1q22gi`}],[`path`,{d:`M7.753 16.239a6 6 0 0 1 0-8.478`,key:`r2q7qm`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),q=e(U(),1),ge=e(I()),J=ae();function Y(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n{}};function _e(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}ve.prototype=_e.prototype={constructor:ve,on:function(e,t){var n=this._,r=ye(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),Se.hasOwnProperty(t)?{space:Se[t],local:e}:e}function we(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function Te(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ee(e){var t=Ce(e);return(t.local?Te:we)(t)}function De(){}function Oe(e){return e==null?De:function(){return this.querySelector(e)}}function ke(e){typeof e!=`function`&&(e=Oe(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function at(e){e||=ot;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function st(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ct(){return Array.from(this)}function lt(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?xt:typeof t==`function`?Ct:St)(e,t,n??``)):Tt(this.node(),e)}function Tt(e,t){return e.style.getPropertyValue(t)||bt(e).getComputedStyle(e,null).getPropertyValue(t)}function Et(e){return function(){delete this[e]}}function Dt(e,t){return function(){this[e]=t}}function Ot(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function kt(e,t){return arguments.length>1?this.each((t==null?Et:typeof t==`function`?Ot:Dt)(e,t)):this.node()[e]}function At(e){return e.trim().split(/^|\s+/)}function jt(e){return e.classList||new Mt(e)}function Mt(e){this._node=e,this._names=At(e.getAttribute(`class`)||``)}Mt.prototype={add:function(e){this._names.indexOf(e)<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 Nt(e,t){for(var n=jt(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function ln(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function jn(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){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:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}jn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Mn(e){return!e.ctrlKey&&!e.button}function Nn(){return this.parentNode}function Pn(e,t){return t??{x:e.x,y:e.y}}function Fn(){return navigator.maxTouchPoints||`ontouchstart`in this}function In(){var e=Mn,t=Nn,n=Pn,r=Fn,i={},a=_e(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,wn).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(xn(n.view).on(`mousemove.drag`,m,Tn).on(`mouseup.drag`,h,Tn),On(n.view),En(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(Dn(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){xn(e.view).on(`mousemove.drag mouseup.drag`,null),kn(e.view,l),Dn(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ar(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ar(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=Kn.exec(e))?new cr(t[1],t[2],t[3],1):(t=qn.exec(e))?new cr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Jn.exec(e))?ar(t[1],t[2],t[3],t[4]):(t=Yn.exec(e))?ar(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Xn.exec(e))?hr(t[1],t[2]/100,t[3]/100,1):(t=Zn.exec(e))?hr(t[1],t[2]/100,t[3]/100,t[4]):Qn.hasOwnProperty(e)?ir(Qn[e]):e===`transparent`?new cr(NaN,NaN,NaN,0):null}function ir(e){return new cr(e>>16&255,e>>8&255,e&255,1)}function ar(e,t,n,r){return r<=0&&(e=t=n=NaN),new cr(e,t,n,r)}function or(e){return e instanceof zn||(e=rr(e)),e?(e=e.rgb(),new cr(e.r,e.g,e.b,e.opacity)):new cr}function sr(e,t,n,r){return arguments.length===1?or(e):new cr(e,t,n,r??1)}function cr(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ln(cr,sr,Rn(zn,{brighter(e){return e=e==null?Vn:Vn**+e,new cr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Bn:Bn**+e,new cr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new cr(pr(this.r),pr(this.g),pr(this.b),fr(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:lr,formatHex:lr,formatHex8:ur,formatRgb:dr,toString:dr}));function lr(){return`#${mr(this.r)}${mr(this.g)}${mr(this.b)}`}function ur(){return`#${mr(this.r)}${mr(this.g)}${mr(this.b)}${mr((isNaN(this.opacity)?1:this.opacity)*255)}`}function dr(){let e=fr(this.opacity);return`${e===1?`rgb(`:`rgba(`}${pr(this.r)}, ${pr(this.g)}, ${pr(this.b)}${e===1?`)`:`, ${e})`}`}function fr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function pr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function mr(e){return e=pr(e),(e<16?`0`:``)+e.toString(16)}function hr(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new vr(e,t,n,r)}function gr(e){if(e instanceof vr)return new vr(e.h,e.s,e.l,e.opacity);if(e instanceof zn||(e=rr(e)),!e)return new vr;if(e instanceof vr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new vr(o,s,c,e.opacity)}function _r(e,t,n,r){return arguments.length===1?gr(e):new vr(e,t,n,r??1)}function vr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ln(vr,_r,Rn(zn,{brighter(e){return e=e==null?Vn:Vn**+e,new vr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Bn:Bn**+e,new vr(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,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new cr(xr(e>=240?e-240:e+120,i,r),xr(e,i,r),xr(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new vr(yr(this.h),br(this.s),br(this.l),fr(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(){let e=fr(this.opacity);return`${e===1?`hsl(`:`hsla(`}${yr(this.h)}, ${br(this.s)*100}%, ${br(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function yr(e){return e=(e||0)%360,e<0?e+360:e}function br(e){return Math.max(0,Math.min(1,e||0))}function xr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Sr=e=>()=>e;function Cr(e,t){return function(n){return e+n*t}}function wr(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Tr(e){return(e=+e)==1?Er:function(t,n){return n-t?wr(t,n,e):Sr(isNaN(t)?n:t)}}function Er(e,t){var n=t-e;return n?Cr(e,n):Sr(isNaN(e)?t:e)}var Dr=(function e(t){var n=Tr(t);function r(e,t){var r=n((e=sr(e)).r,(t=sr(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=Er(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Or(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Mr(r,i)})),n=Fr.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Mr(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Mr(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Mr(e,n)},{i:s-2,x:Mr(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--ei}function gi(){si=(oi=li.now())+ci,ei=ti=0;try{hi()}finally{ei=0,vi(),si=0}}function _i(){var e=li.now(),t=e-oi;t>ri&&(ci-=t,oi=e)}function vi(){for(var e,t=ii,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ii=n);ai=e,yi(r)}function yi(e){ei||(ti&&=clearTimeout(ti),e-si>24?(e<1/0&&(ti=setTimeout(gi,e-li.now()-ci)),ni&&=clearInterval(ni)):(ni||=(oi=li.now(),setInterval(_i,ri)),ei=1,ui(gi)))}function bi(e,t,n){var r=new pi;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var xi=_e(`start`,`end`,`cancel`,`interrupt`),Si=[];function Ci(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Di(e,n,{name:t,index:r,group:i,on:xi,tween:Si,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function wi(e,t){var n=Ei(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function Ti(e,t){var n=Ei(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function Ei(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Di(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=mi(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return bi(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function ki(e){return this.each(function(){Oi(this,e)})}function Ai(e,t){var n,r;return function(){var i=Ti(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o=0&&(e=e.slice(0,t)),!e||e===`start`})}function oa(e,t,n){var r,i,a=aa(t)?wi:Ti;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function sa(e,t){var n=this._id;return arguments.length<2?Ei(this.node(),n).on.on(e):this.each(oa(n,e,t))}function ca(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function la(){return this.on(`end.remove`,ca(this._id))}function ua(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Oe(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function Va(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ha(e,t,n){this.k=e,this.x=t,this.y=n}Ha.prototype={constructor:Ha,scale:function(e){return e===1?this:new Ha(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ha(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 Ua=new Ha(1,0,0);Wa.prototype=Ha.prototype;function Wa(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ua;return e.__zoom}function Ga(e){e.stopImmediatePropagation()}function Ka(e){e.preventDefault(),e.stopImmediatePropagation()}function qa(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Ja(){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 Ya(){return this.__zoom||Ua}function Xa(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Za(){return navigator.maxTouchPoints||`ontouchstart`in this}function Qa(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function $a(){var e=qa,t=Ja,n=Qa,r=Xa,i=Za,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=$r,l=_e(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Ya).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Ya),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Ua.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Ha(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Ha(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Ha(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=xn(this.that).datum();l.call(e,this.that,new Va(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=Cn(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],Oi(this),s.start();Ka(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=xn(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=Cn(t,i),l=t.clientX,u=t.clientY;On(t.view),Ga(t),a.mouse=[c,this.__zoom.invert(c)],Oi(this),a.start();function d(e){if(Ka(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=Cn(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),kn(e.view,a.moved),Ka(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=Cn(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Ka(r),s>0?xn(this).transition().duration(s).call(x,d,c,r):xn(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(Ga(t),s=0;s`[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,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,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.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},to=[[-1/0,-1/0],[1/0,1/0]],no=[`Enter`,` `,`Escape`],ro={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},io;(function(e){e.Strict=`strict`,e.Loose=`loose`})(io||={});var ao;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(ao||={});var oo;(function(e){e.Partial=`partial`,e.Full=`full`})(oo||={});var so={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},co;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(co||={});var lo;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(lo||={});var Z;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Z||={});var uo={[Z.Left]:Z.Right,[Z.Right]:Z.Left,[Z.Top]:Z.Bottom,[Z.Bottom]:Z.Top};function fo(e){return e===null?null:e?`valid`:`invalid`}var po=e=>`id`in e&&`source`in e&&`target`in e,mo=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),ho=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),go=(e,t=[0,0])=>{let{width:n,height:r}=Yo(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},_o=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:Mo(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):ho(n)?n:t.nodeLookup.get(n.id)),Ao(e,i?Po(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),vo=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Ao(n,Po(e)),r=!0)}),r?Mo(n):{x:0,y:0,width:0,height:0}},yo=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...Vo(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=Io(s,No(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},bo=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function xo(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function So({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=Ko(vo(xo(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function Co({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,eo.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&Jo(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Jo(d)?Eo(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,eo.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function wo({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=bo(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var To=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Eo=(e={x:0,y:0},t,n)=>({x:To(e.x,t[0][0],t[1][0]-(n?.width??0)),y:To(e.y,t[0][1],t[1][1]-(n?.height??0))});function Do(e,t,n){let{width:r,height:i}=Yo(n),{x:a,y:o}=n.internals.positionAbsolute;return Eo(e,[[a,o],[a+r,o+i]],t)}var Oo=(e,t,n)=>en?-To(Math.abs(e-n),1,t)/t:0,ko=(e,t,n=15,r=40)=>[Oo(e.x,r,t.width-r)*n,Oo(e.y,r,t.height-r)*n],Ao=(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)}),jo=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Mo=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),No=(e,t=[0,0])=>{let{x:n,y:r}=ho(e)?e.internals.positionAbsolute:go(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Po=(e,t=[0,0])=>{let{x:n,y:r}=ho(e)?e.internals.positionAbsolute:go(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Fo=(e,t)=>Mo(Ao(jo(e),jo(t))),Io=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Lo=e=>Ro(e.width)&&Ro(e.height)&&Ro(e.x)&&Ro(e.y),Ro=e=>!isNaN(e)&&isFinite(e),zo=(e,t)=>{},Bo=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Vo=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Bo(s,o):s},Ho=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Uo(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Wo(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Uo(e,n),i=Uo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Uo(e.top??e.y??0,n),i=Uo(e.bottom??e.y??0,n),a=Uo(e.left??e.x??0,t),o=Uo(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Go(e,t,n,r,i,a){let{x:o,y:s}=Ho(e,[t,n,r]),{x:c,y:l}=Ho({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Ko=(e,t,n,r,i,a)=>{let o=Wo(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=To(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Go(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},qo=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Jo(e){return e!=null&&e!==`parent`}function Yo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Xo(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Zo(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Qo(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function $o(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function es(e){return{...ro,...e||{}}}function ts(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=ss(e),s=Vo({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Bo(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ns=e=>({width:e.offsetWidth,height:e.offsetHeight}),rs=e=>e?.getRootNode?.()||window?.document,is=[`INPUT`,`SELECT`,`TEXTAREA`];function as(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?is.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var os=e=>`clientX`in e,ss=(e,t)=>{let n=os(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},cs=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ns(t)}})};function ls({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function us(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ds({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Z.Left:return[t-us(t-r,a),n];case Z.Right:return[t+us(r-t,a),n];case Z.Top:return[t,n-us(n-i,a)];case Z.Bottom:return[t,n+us(i-n,a)]}}function fs({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top,curvature:o=.25}){let[s,c]=ds({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=ds({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=ls({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function ps({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n0}var gs=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,_s=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),vs=(e,t,n={})=>{if(!e.source||!e.target)return eo.error006(),t;let r=n.getEdgeId||gs,i;return i=po(e)?{...e}:{...e,id:r(e)},_s(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))},ys=(e,t,n,r={shouldReplaceId:!0})=>{let{id:i,...a}=e;if(!t.source||!t.target)return eo.error006(),n;if(!n.find(t=>t.id===e.id))return eo.error007(i),n;let o=r.getEdgeId||gs,s={...a,id:r.shouldReplaceId?o(t):i,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle};return n.filter(e=>e.id!==i).concat(s)};function bs({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=ps({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var xs={[Z.Left]:{x:-1,y:0},[Z.Right]:{x:1,y:0},[Z.Top]:{x:0,y:-1},[Z.Bottom]:{x:0,y:1}},Ss=({source:e,sourcePosition:t=Z.Bottom,target:n})=>t===Z.Left||t===Z.Right?e.xMath.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function ws({source:e,sourcePosition:t=Z.Bottom,target:n,targetPosition:r=Z.Top,center:i,offset:a,stepPosition:o}){let s=xs[t],c=xs[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=Ss({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=ps({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function Ts(e,t,n,r){let i=Math.min(Cs(e,t)/2,Cs(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.xe.id===t):e[0])||null}function Ms(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Ns(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Ms(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Ps=1e3,Fs=10,Is={nodeOrigin:[0,0],nodeExtent:to,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Ls={...Is,checkEquality:!0};function Rs(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function zs(e,t,n){let r=Rs(Is,n);for(let n of e.values())if(n.parentId)Ws(n,e,t,r);else{let e=Eo(go(n,r.nodeOrigin),Jo(n.extent)?n.extent:r.nodeExtent,Yo(n));n.internals.positionAbsolute=e}}function Bs(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function Vs(e){return e===`manual`}function Hs(e,t,n,r={}){let i=Rs(Ls,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!Vs(i.zIndexMode)?Ps:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=Eo(go(u,i.nodeOrigin),Jo(u.extent)?u.extent:i.nodeExtent,Yo(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Bs(u,e),z:Gs(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Ws(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Us(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ws(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Rs(Is,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Us(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Fs),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Ks(e,u,o,s,a&&!Vs(c)?Ps:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Gs(e,t,n){let r=Ro(e.zIndex)?e.zIndex:0;return Vs(n)?r:r+(e.selected?t:0)}function Ks(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Yo(e),l=go(e,n),u=Jo(e.extent)?Eo(l,e.extent,c):l,d=Eo({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Do(d,c,t));let f=Gs(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function qs(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Fo(a.get(n.parentId)?.expandedRect??No(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Yo(a),l=a.origin??r,u=t.x0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width0){let e=qs(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Ys({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function Xs(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Zs(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Xs(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Xs(`target`,s,c,e,i,o),t.set(r.id,r)}}function Qs(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Qs(n,t):!1}function $s(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function ec(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Qs(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function tc({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function nc({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Bo(a,t);return{x:o.x-a.x,y:o.y-a.y}}function rc({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=xn(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?jo(vo(s)):null,x=v&&l?nc({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Bo(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=Co({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=tc({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=ko(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=ts(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=ec(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=tc({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=In().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=ts(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=ss(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=ts(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=ss(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=ss(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=tc({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!$s(t,`.${g}`,v))&&(!_||$s(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function ic(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Io(i,No(e))>0&&r.push(e);return r}var ac=250;function oc(e,t,n,r){let i=[],a=1/0,o=ic(e,n,t+ac);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=As(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function sc(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...As(o,c,c.position,!0)}:c}function cc(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function lc(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var uc=()=>!0;function dc(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=uc,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=rs(e.target),E=0,D,{x:O,y:k}=ss(e),A=cc(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=sc(i,A,r,c,t);if(!N)return;let P=ss(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=ko(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ee)}let z={...N,nodeId:i,type:A,position:N.position},te=c.get(i),B={inProgress:!0,isValid:null,from:As(te,z,Z.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:te,to:P,toHandle:null,toPosition:uo[z.position],toNode:null,pointer:P};function V(){M=!0,y(B),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&V();function H(e){if(!M){let{x:t,y:n}=ss(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;V()}if(!x()||!z){U(e);return}let a=b();P=ss(e,j),D=oc(Vo(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=fc(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=lc(!!D,s.isValid);let u=c.get(i),f=u?As(u,z,Z.Left,!0):B.from,p={...B,from:f,isValid:L,to:s.toHandle&&L?Ho({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:uo[z.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),B=p}function U(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=B,r={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,H),T.removeEventListener(`mouseup`,U),T.removeEventListener(`touchmove`,H),T.removeEventListener(`touchend`,U)}}T.addEventListener(`mousemove`,H),T.addEventListener(`mouseup`,U),T.addEventListener(`touchmove`,H),T.addEventListener(`touchend`,U)}function fc(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=uc,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=ss(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=cc(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===io.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=sc(t,e,a,u,n,!0)}return _}var pc={onPointerDown:dc,isValid:fc};function mc({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=xn(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&qo()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=$a().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:Cn}}var hc=e=>({x:e.x,y:e.y,zoom:e.k}),gc=({x:e,y:t,zoom:n})=>Ua.translate(e,t).scale(n),_c=(e,t)=>e.target.closest(`.${t}`),vc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),yc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,bc=(e,t=0,n=yc,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},xc=e=>{let t=e.ctrlKey&&qo()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Sc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(_c(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=Cn(u),t=d*2**xc(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===ao.Vertical?0:u.deltaX*f,m=i===ao.Horizontal?0:u.deltaY*f;!qo()&&u.shiftKey&&i!==ao.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=hc(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function Cc({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=_c(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function wc({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=hc(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Tc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&vc(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,hc(a.transform))}}function Ec({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&vc(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=hc(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Dc({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(_c(d,`${l}-flow__node`)||_c(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||_c(d,s)&&m||_c(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function Oc({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=$a().scaleExtent([t,n]).translateExtent(r),f=xn(e).call(d);v({x:i.x,y:i.y,zoom:To(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(xc);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?zr:$r).transform(bc(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let O=i&&!S&&!r;d.clickDistance(D?1/0:!Ro(E)||E<0?0:E);let k=O?Sc({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Cc({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=wc({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=Tc({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=Ec({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=Dc({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(A),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=gc(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=gc(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=gc(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?Wa(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?zr:$r).scaleTo(bc(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?zr:$r).scaleBy(bc(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!Ro(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var kc;(function(e){e.Line=`line`,e.Handle=`handle`})(kc||={});function Ac({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function jc(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Mc(e,t){return Math.max(0,t-e)}function Nc(e,t){return Math.max(0,e-t)}function Pc(e,t,n){return Math.max(0,t-e,e-n)}function Fc(e,t){return e?!t:t}function Ic(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Pc(E,h,g),j=Pc(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Mc(y+w+O,o[0][0]):!c&&w>0&&(e=Nc(y+E+O,o[1][0])),l&&T<0?t=Mc(b+T+k,o[0][1]):!l&&T>0&&(t=Nc(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=Nc(y+w,s[0][0]):!c&&w<0&&(e=Mc(y+E,s[1][0])),l&&T>0?t=Nc(b+T,s[0][1]):!l&&T<0&&(t=Mc(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Pc(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?Nc(b+k+E/C,o[1][1])*C:Mc(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Mc(b+E/C,s[1][1])*C:Nc(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Pc(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?Nc(y+D*C+O,o[1][0])/C:Mc(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Mc(y+D*C,s[1][0])/C:Nc(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Fc(c,l)?-w:w)/C:w=(Fc(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Lc={width:0,height:0,x:0,y:0},Rc={...Lc,pointerX:0,pointerY:0,aspectRatio:1};function zc(e){return[[0,0],[e.measured.width,e.measured.height]]}function Bc(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Vc({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=xn(e),o={controlDirection:jc(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Lc},h={...Rc};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:jc(e)};let g,_=null,v=[],y,b,x,S=!1,C=In().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=ts(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?zc(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Bc(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=ts(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=Ic(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var Hc=t((e=>{var t=U();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Uc=t(((e,t)=>{t.exports=Hc()})),Wc=t((e=>{var t=U(),n=Uc();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Gc=e(t(((e,t)=>{t.exports=Wc()}))(),1),Kc=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},qc=e=>e?Kc(e):Kc,{useDebugValue:Jc}=q.default,{useSyncExternalStoreWithSelector:Yc}=Gc.default,Xc=e=>e;function Zc(e,t=Xc,n){let r=Yc(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Jc(r),r}var Qc=(e,t)=>{let n=qc(e),r=(e,r=t)=>Zc(n,e,r);return Object.assign(r,n),r},$c=(e,t)=>e?Qc(e,t):Qc;function el(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var tl=(0,q.createContext)(null),nl=tl.Provider,rl=eo.error001();function Q(e,t){let n=(0,q.useContext)(tl);if(n===null)throw Error(rl);return Zc(n,e,t)}function il(){let e=(0,q.useContext)(tl);if(e===null)throw Error(rl);return(0,q.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var al={display:`none`},ol={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},sl=`react-flow__node-desc`,cl=`react-flow__edge-desc`,ll=`react-flow__aria-live`,ul=e=>e.ariaLiveMessage,dl=e=>e.ariaLabelConfig;function fl({rfId:e}){let t=Q(ul);return(0,J.jsx)(`div`,{id:`${ll}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:ol,children:t})}function pl({rfId:e,disableKeyboardA11y:t}){let n=Q(dl);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{id:`${sl}-${e}`,style:al,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,J.jsx)(`div`,{id:`${cl}-${e}`,style:al,children:n[`edge.a11yDescription.default`]}),!t&&(0,J.jsx)(fl,{rfId:e})]})}var ml=(0,q.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,J.jsx)(`div`,{className:Y([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));ml.displayName=`Panel`;function hl({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,J.jsx)(ml,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,J.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var gl=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},_l=e=>e.id;function vl(e,t){return el(e.selectedNodes.map(_l),t.selectedNodes.map(_l))&&el(e.selectedEdges.map(_l),t.selectedEdges.map(_l))}function yl({onSelectionChange:e}){let t=il(),{selectedNodes:n,selectedEdges:r}=Q(gl,vl);return(0,q.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var bl=e=>!!e.onSelectionChangeHandlers;function xl({onSelectionChange:e}){let t=Q(bl);return e||t?(0,J.jsx)(yl,{onSelectionChange:e}):null}var Sl=typeof window<`u`?q.useLayoutEffect:q.useEffect,Cl=[0,0],wl={x:0,y:0,zoom:1},Tl=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],El=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Dl={translateExtent:to,nodeOrigin:Cl,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ol(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(El,el),l=il();Sl(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Dl,s()}),[]);let u=(0,q.useRef)(Dl);return Sl(()=>{for(let s of Tl){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:es(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Tl.map(t=>e[t])),null}function kl(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Al(e){let[t,n]=(0,q.useState)(e===`system`?null:e);return(0,q.useEffect)(()=>{if(e!==`system`){n(e);return}let t=kl(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?kl()?.matches?`dark`:`light`:t}var jl=typeof document<`u`?document:null;function Ml(e=null,t={target:jl,actInsideInputWithModifier:!0}){let[n,r]=(0,q.useState)(!1),i=(0,q.useRef)(!1),a=(0,q.useRef)(new Set([])),[o,s]=(0,q.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,` +`).replace(` + +`,` ++`).split(` +`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,q.useEffect)(()=>{let n=t?.target??jl,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&as(e))return!1;let n=Pl(e.code,s);if(a.current.add(e[n]),Nl(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Pl(e.code,s);Nl(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Nl(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Pl(e,t){return t.includes(e)?`code`:`key`}var Fl=()=>{let e=il();return(0,q.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=Ko(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Vo(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Ho(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Il(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Ll(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Ll(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function Rl(e,t){return Il(e,t)}function zl(e,t){return Il(e,t)}function Bl(e,t){return{id:e,type:`select`,selected:t}}function Vl(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(Bl(a.id,e)))}return r}function Hl({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function Ul(e){return{id:e.id,type:`remove`}}var Wl=e=>mo(e),Gl=e=>po(e);function Kl(e){return(0,q.forwardRef)(e)}function ql(e){let[t,n]=(0,q.useState)(BigInt(0)),[r]=(0,q.useState)(()=>Jl(()=>n(e=>e+BigInt(1))));return Sl(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Jl(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Yl=(0,q.createContext)(null);function Xl({children:e}){let t=il(),n=ql((0,q.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Hl({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=ql((0,q.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Hl({items:s,lookup:o}))},[])),i=(0,q.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,J.jsx)(Yl.Provider,{value:i,children:e})}function Zl(){let e=(0,q.useContext)(Yl);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var Ql=e=>!!e.panZoom;function $l(){let e=Fl(),t=il(),n=Zl(),r=Q(Ql),i=(0,q.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Wl(e)?e:n.get(e.id),a=i.parentId?Zo(i.position,i.measured,i.parentId,n,r):i.position;return No({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Wl(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Gl(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await wo({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Ul);o?.(f),c(e)}if(m){let e=d.map(Ul);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Lo(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=No(s?r:a),l=Io(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=Lo(e)?e:a(e);if(!r)return!1;let i=Io(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return _o(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??$o();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,q.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var eu=e=>e.selected,tu=typeof window<`u`?window:void 0;function nu({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=il(),{deleteElements:r}=$l(),i=Ml(e,{actInsideInputWithModifier:!1}),a=Ml(t,{target:tu});(0,q.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(eu),edges:e.filter(eu)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,q.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function ru(e){let t=il();(0,q.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=ns(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,eo.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var iu={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},au=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function ou({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=ao.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=il(),S=(0,q.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=Q(au,el),E=Ml(f),D=(0,q.useRef)();ru(S);let O=(0,q.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,q.useEffect)(()=>{if(S.current){D.current=Oc({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,q.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,J.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:iu,children:m})}var su=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function cu(){let{userSelectionActive:e,userSelectionRect:t}=Q(su,el);return e&&t?(0,J.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var lu=(e,t)=>n=>{n.target===t.current&&e?.(n)},uu=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function du({isSelecting:e,selectionKeyPressed:t,selectionMode:n=oo.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:m}){let h=il(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=Q(uu,el),b=_&&(e||g),x=(0,q.useRef)(null),S=(0,q.useRef)(),C=(0,q.useRef)(new Set),w=(0,q.useRef)(new Set),T=(0,q.useRef)(!1),E=e=>{if(T.current||y){T.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},D=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},O=u?e=>u(e):void 0;return(0,J.jsxs)(`div`,{className:Y([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:lu(E,x),onContextMenu:lu(D,x),onWheel:lu(O,x),onPointerEnter:b?void 0:d,onPointerMove:b?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:c,connectionLookup:l,triggerNodeChanges:u,triggerEdgeChanges:d,defaultEdgeOptions:f,resetSelectedElements:p}=h.getState();if(!S.current||!r)return;let{x:m,y:g}=ss(e.nativeEvent,S.current),{startX:_,startY:v}=r;if(!T.current){let n=t?0:i;if(Math.hypot(m-_,g-v)<=n)return;p(),o?.(e)}T.current=!0;let y={startX:_,startY:v,x:m<_?m:_,y:ge.id)),w.current=new Set;let E=f?.selectable??!0;for(let e of C.current){let t=l.get(e);if(t)for(let{edgeId:e}of t.values()){let t=c.get(e);t&&(t.selectable??E)&&w.current.add(e)}}Qo(b,C.current)||u(Vl(s,C.current,!0)),Qo(x,w.current)||d(Vl(c,w.current)),h.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:b?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===x.current&&h.getState().userSelectionRect&&E?.(e),h.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(s?.(e),h.setState({nodesSelectionActive:C.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=h.getState();if(S.current=r?.getBoundingClientRect(),!S.current)return;let i=n.target===x.current;if(!i&&n.target.closest(`.nokey`)||!e||!(a&&i||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),T.current=!1;let{x:o,y:s}=ss(n.nativeEvent,S.current);h.setState({userSelectionRect:{width:0,height:0,startX:o,startY:s,x:o,y:s}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{T.current&&=(e.stopPropagation(),!1)}:void 0,onPointerLeave:p,ref:x,style:iu,children:[m,(0,J.jsx)(cu,{})]})}function fu({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,eo.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function pu({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=il(),[c,l]=(0,q.useState)(!1),u=(0,q.useRef)();return(0,q.useEffect)(()=>{u.current=rc({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{fu({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,q.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var mu=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function hu(){let e=il();return(0,q.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=mu(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=Bo(t,i));let{position:a,positionAbsolute:s}=Co({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var gu=(0,q.createContext)(null),_u=gu.Provider;gu.Consumer;var vu=()=>(0,q.useContext)(gu),yu=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),bu=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===io.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function xu({type:e=`source`,position:t=Z.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=il(),_=vu(),{connectOnClick:v,noPanClassName:y,rfId:b}=Q(yu,el),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Q(bu(_,m,e),el);_||g.getState().onError?.(`010`,eo.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(vs(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=os(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();pc.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,J.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Y([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=rs(t.target),h=n||c,{connection:v,isValid:y}=pc.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var Su=(0,q.memo)(Kl(xu));function Cu({data:e,isConnectable:t,sourcePosition:n=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[e?.label,(0,J.jsx)(Su,{type:`source`,position:n,isConnectable:t})]})}function wu({data:e,isConnectable:t,targetPosition:n=Z.Top,sourcePosition:r=Z.Bottom}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Su,{type:`target`,position:n,isConnectable:t}),e?.label,(0,J.jsx)(Su,{type:`source`,position:r,isConnectable:t})]})}function Tu(){return null}function Eu({data:e,isConnectable:t,targetPosition:n=Z.Top}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Su,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Du={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ou={input:Cu,default:wu,output:Eu,group:Tu};function ku(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Au=e=>{let{width:t,height:n,x:r,y:i}=vo(e.nodeLookup,{filter:e=>!!e.selected});return{width:Ro(t)?t:null,height:Ro(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function ju({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=il(),{width:i,height:a,transformString:o,userSelectionActive:s}=Q(Au,el),c=hu(),l=(0,q.useRef)(null);(0,q.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(pu({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,J.jsx)(`div`,{className:Y([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,J.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(Du,e.key)&&(e.preventDefault(),c({direction:Du[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Mu=typeof window<`u`?window:void 0,Nu=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Pu({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,preventScrolling:k,onSelectionContextMenu:A,noWheelClassName:j,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:P,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=Q(Nu,el),R=Ml(l,{target:Mu}),ee=Ml(h,{target:Mu}),z=ee||w,te=ee||b,B=u&&z!==!0,V=R||L||B;return nu({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,J.jsx)(ou,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:te,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&z,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:B,children:(0,J.jsxs)(du,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:z,isSelecting:!!V,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:B,children:[e,I&&(0,J.jsx)(ju,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}Pu.displayName=`FlowRenderer`;var Fu=(0,q.memo)(Pu),Iu=e=>t=>e?yo(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Lu(e){return Q((0,q.useCallback)(Iu(e),[e]),el)}var Ru=e=>e.updateNodeInternals;function zu(){let e=Q(Ru),[t]=(0,q.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,q.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Bu({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=il(),a=(0,q.useRef)(null),o=(0,q.useRef)(null),s=(0,q.useRef)(e.sourcePosition),c=(0,q.useRef)(e.targetPosition),l=(0,q.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,q.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,q.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,q.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Vu({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Q(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},el),S=y.type||`default`,C=g?.[S]||Ou[S];C===void 0&&(v?.(`003`,eo.error003(S)),S=`default`,C=g?.default||Ou.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=il(),k=Xo(y),A=Bu({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=pu({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=hu();if(y.hidden)return null;let N=Yo(y),P=ku(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,ee=a?e=>a(e,{...b.userNode}):void 0,z=o?e=>o(e,{...b.userNode}):void 0,te=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&fu({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},B=t=>{if(!(as(t.nativeEvent)||m)){if(no.includes(t.key)&&T){let n=t.key===`Escape`;fu({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Du,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:Du[t.key],factor:t.shiftKey?4:1})}}},V=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(yo(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,J.jsx)(`div`,{className:Y([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:ee,onClick:te,onDoubleClick:z,onKeyDown:D?B:void 0,tabIndex:D?0:void 0,onFocus:D?V:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${sl}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,J.jsx)(_u,{value:e,children:(0,J.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var Hu=(0,q.memo)(Vu),Uu=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Wu(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=Q(Uu,el),o=Lu(e.onlyRenderVisibleElements),s=zu();return(0,J.jsx)(`div`,{className:`react-flow__nodes`,style:iu,children:o.map(o=>(0,J.jsx)(Hu,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}Wu.displayName=`NodeRenderer`;var Gu=(0,q.memo)(Wu);function Ku(e){return Q((0,q.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&hs({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),el)}var qu=({color:e=`none`,strokeWidth:t=1})=>(0,J.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),Ju=({color:e=`none`,strokeWidth:t=1})=>(0,J.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),Yu={[lo.Arrow]:qu,[lo.ArrowClosed]:Ju};function Xu(e){let t=il();return(0,q.useMemo)(()=>Object.prototype.hasOwnProperty.call(Yu,e)?Yu[e]:(t.getState().onError?.(`009`,eo.error009(e)),null),[e])}var Zu=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=Xu(t);return c?(0,J.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,J.jsx)(c,{color:n,strokeWidth:o})}):null},Qu=({defaultColor:e,rfId:t})=>{let n=Q(e=>e.edges),r=Q(e=>e.defaultEdgeOptions),i=(0,q.useMemo)(()=>Ns(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,J.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,J.jsx)(`defs`,{children:i.map(e=>(0,J.jsx)(Zu,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Qu.displayName=`MarkerDefinitions`;var $u=(0,q.memo)(Qu);function ed({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,q.useState)({x:1,y:0,width:0,height:0}),p=Y([`react-flow__edge-textwrapper`,l]),m=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,J.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,J.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,J.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}ed.displayName=`EdgeText`;var td=(0,q.memo)(ed);function nd({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{...u,d:e,fill:`none`,className:Y([`react-flow__edge-path`,u.className])}),l?(0,J.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Ro(t)&&Ro(n)?(0,J.jsx)(td,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function rd({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Z.Left||e===Z.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function id({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:r,targetY:i,targetPosition:a=Z.Top}){let[o,s]=rd({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=rd({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=ls({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function ad(e){return(0,q.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=id({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,J.jsx)(nd,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var od=ad({isInternal:!1}),sd=ad({isInternal:!0});od.displayName=`SimpleBezierEdge`,sd.displayName=`SimpleBezierEdgeInternal`;function cd(e){return(0,q.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Z.Bottom,targetPosition:m=Z.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Es({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,J.jsx)(nd,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var ld=cd({isInternal:!1}),ud=cd({isInternal:!0});ld.displayName=`SmoothStepEdge`,ud.displayName=`SmoothStepEdgeInternal`;function dd(e){return(0,q.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,J.jsx)(ld,{...n,id:r,pathOptions:(0,q.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var fd=dd({isInternal:!1}),pd=dd({isInternal:!0});fd.displayName=`StepEdge`,pd.displayName=`StepEdgeInternal`;function md(e){return(0,q.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=bs({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,J.jsx)(nd,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var hd=md({isInternal:!1}),gd=md({isInternal:!0});hd.displayName=`StraightEdge`,gd.displayName=`StraightEdgeInternal`;function _d(e){return(0,q.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Z.Bottom,targetPosition:s=Z.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=fs({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,J.jsx)(nd,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var vd=_d({isInternal:!1}),yd=_d({isInternal:!0});vd.displayName=`BezierEdge`,yd.displayName=`BezierEdgeInternal`;var bd={default:yd,straight:gd,step:pd,smoothstep:ud,simplebezier:sd},xd={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Sd=(e,t,n)=>n===Z.Left?e-t:n===Z.Right?e+t:e,Cd=(e,t,n)=>n===Z.Top?e-t:n===Z.Bottom?e+t:e,wd=`react-flow__edgeupdater`;function Td({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,J.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Y([wd,`${wd}-${s}`]),cx:Sd(t,r,e),cy:Cd(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Ed({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=il(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;pc.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,J.jsxs)(J.Fragment,{children:[(e===!0||e===`source`)&&(0,J.jsx)(Td,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,J.jsx)(Td,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Dd({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=Q(t=>t.edgeLookup.get(e)),b=Q(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||bd[x];S===void 0&&(_?.(`011`,eo.error011(x)),x=`default`,S=h?.default||bd.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,q.useRef)(null),[D,O]=(0,q.useState)(!1),[k,A]=(0,q.useState)(!1),j=il(),{zIndex:M,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=Q((0,q.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...xd};let i=Os({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:ms({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||xd}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),el),ee=(0,q.useMemo)(()=>y.markerStart?`url('#${Ms(y.markerStart,m)}')`:void 0,[y.markerStart,m]),z=(0,q.useMemo)(()=>y.markerEnd?`url('#${Ms(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let te=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},B=a?e=>{a(e,{...y})}:void 0,V=o?e=>{o(e,{...y})}:void 0,H=s?e=>{s(e,{...y})}:void 0,U=c?e=>{c(e,{...y})}:void 0,W=l?e=>{l(e,{...y})}:void 0;return(0,J.jsx)(`svg`,{style:{zIndex:M},children:(0,J.jsxs)(`g`,{className:Y([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:te,onDoubleClick:B,onContextMenu:V,onMouseEnter:H,onMouseMove:U,onMouseLeave:W,onKeyDown:C?t=>{if(!v&&no.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${cl}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,J.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:ee,markerEnd:z,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,J.jsx)(Ed,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var Od=(0,q.memo)(Dd),kd=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Ad({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Q(kd,el),b=Ku(t);return(0,J.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,J.jsx)($u,{defaultColor:e,rfId:n}),b.map(e=>(0,J.jsx)(Od,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Ad.displayName=`EdgeRenderer`;var jd=(0,q.memo)(Ad),Md=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Nd({children:e}){return(0,J.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:Q(Md)},children:e})}function Pd(e){let t=$l(),n=(0,q.useRef)(!1);(0,q.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Fd=e=>e.panZoom?.syncViewport;function Id(e){let t=Q(Fd),n=il();return(0,q.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Ld(e){return e.connection.inProgress?{...e.connection,to:Vo(e.connection.to,e.transform)}:{...e.connection}}function Rd(e){return e?t=>e(Ld(t)):Ld}function zd(e){return Q(Rd(e),el)}var Bd=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Vd({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Q(Bd,el);return a&&i&&c?(0,J.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,J.jsx)(`g`,{className:Y([`react-flow__connection`,fo(s)]),children:(0,J.jsx)(Hd,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var Hd=({style:e,type:t=co.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=zd();if(!i)return;if(n)return(0,J.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:fo(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case co.Bezier:[m]=fs(h);break;case co.SimpleBezier:[m]=id(h);break;case co.Step:[m]=Es({...h,borderRadius:0});break;case co.SmoothStep:[m]=Es(h);break;default:[m]=bs(h)}return(0,J.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};Hd.displayName=`ConnectionLine`;var Ud={};function Wd(e=Ud){(0,q.useRef)(e),il(),(0,q.useEffect)(()=>{},[e])}function Gd(){il(),(0,q.useRef)(!1),(0,q.useEffect)(()=>{},[])}function Kd({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:ee,onPaneClick:z,onPaneMouseEnter:te,onPaneMouseMove:B,onPaneMouseLeave:V,onPaneScroll:H,onPaneContextMenu:U,paneClickDistance:W,nodeClickDistance:ne,onEdgeContextMenu:re,onEdgeMouseEnter:G,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,onReconnect:se,onReconnectStart:K,onReconnectEnd:ce,noDragClassName:le,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,nodeExtent:pe,rfId:me,viewport:he,onViewportChange:q}){return Wd(e),Wd(t),Gd(),Pd(n),Id(he),(0,J.jsx)(Fu,{onPaneClick:z,onPaneMouseEnter:te,onPaneMouseMove:B,onPaneMouseLeave:V,onPaneContextMenu:U,onPaneScroll:H,paneClickDistance:W,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:ee,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:le,noWheelClassName:ue,noPanClassName:de,disableKeyboardA11y:fe,onViewportChange:q,isControlledViewport:!!he,children:(0,J.jsxs)(Nd,{children:[(0,J.jsx)(jd,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:se,onReconnectStart:K,onReconnectEnd:ce,onlyRenderVisibleElements:T,onEdgeContextMenu:re,onEdgeMouseEnter:G,onEdgeMouseMove:ie,onEdgeMouseLeave:ae,reconnectRadius:oe,defaultMarkerColor:M,noPanClassName:de,disableKeyboardA11y:fe,rfId:me}),(0,J.jsx)(Vd,{style:h,type:m,component:g,containerStyle:_}),(0,J.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,J.jsx)(Gu,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ne,onlyRenderVisibleElements:T,noPanClassName:de,noDragClassName:le,disableKeyboardA11y:fe,nodeExtent:pe,rfId:me}),(0,J.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}Kd.displayName=`GraphView`;var qd=(0,q.memo)(Kd),Jd=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??to;Zs(h,g,_);let{nodesInitialized:x}=Hs(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=Ko(vo(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:to,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:io.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...so},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:zo,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:ro,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Yd=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>$c((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await So({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...Jd({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=Hs(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();Zs(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=Js(e,n,r,i,a,o,l);d&&(zs(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=As(e,o.fromHandle,Z.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=qs(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Rl(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(zl(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>Bl(e,!0)));return}i(Vl(r,new Set([...e]),!0)),a(Vl(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>Bl(e,!0)));return}a(Vl(n,new Set([...e]))),i(Vl(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(Bl(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(Bl(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Bl(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Bl(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(Hs(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return Ys({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return Promise.resolve(!1);let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...so}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...Jd()})}},Object.is);function Xd({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,q.useState)(()=>Yd({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,J.jsx)(nl,{value:m,children:(0,J.jsx)(Xl,{children:p})})}function Zd({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,q.useContext)(tl)?(0,J.jsx)(J.Fragment,{children:e}):(0,J.jsx)(Xd,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var Qd={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function $d({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=co.Bezier,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:te,deleteKeyCode:B=`Backspace`,selectionKeyCode:V=`Shift`,selectionOnDrag:H=!1,selectionMode:U=oo.Full,panActivationKeyCode:W=`Space`,multiSelectionKeyCode:ne=qo()?`Meta`:`Control`,zoomActivationKeyCode:re=qo()?`Meta`:`Control`,snapToGrid:G,snapGrid:ie,onlyRenderVisibleElements:ae=!1,selectNodesOnDrag:oe,nodesDraggable:se,autoPanOnNodeFocus:K,nodesConnectable:ce,nodesFocusable:le,nodeOrigin:ue=Cl,edgesFocusable:de,edgesReconnectable:fe,elementsSelectable:pe=!0,defaultViewport:me=wl,minZoom:he=.5,maxZoom:ge=2,translateExtent:X=to,preventScrolling:_e=!0,nodeExtent:ve,defaultMarkerColor:ye=`#b1b1b7`,zoomOnScroll:be=!0,zoomOnPinch:xe=!0,panOnScroll:Se=!1,panOnScrollSpeed:Ce=.5,panOnScrollMode:we=ao.Free,zoomOnDoubleClick:Te=!0,panOnDrag:Ee=!0,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne=1,nodeClickDistance:Pe=0,children:Fe,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We=10,onNodesChange:Ge,onEdgesChange:Ke,noDragClassName:qe=`nodrag`,noWheelClassName:Je=`nowheel`,noPanClassName:Ye=`nopan`,fitView:Xe,fitViewOptions:Ze,connectOnClick:Qe,attributionPosition:$e,proOptions:et,defaultEdgeOptions:tt,elevateNodesOnSelect:nt=!0,elevateEdgesOnSelect:rt=!1,disableKeyboardA11y:it=!1,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanSpeed:st,connectionRadius:ct,isValidConnection:lt,onError:ut,style:dt,id:ft,nodeDragThreshold:pt,connectionDragThreshold:mt,viewport:ht,onViewportChange:gt,width:_t,height:vt,colorMode:yt=`light`,debug:bt,onScroll:xt,ariaLabelConfig:St,zIndexMode:Ct=`basic`,...wt},Tt){let Et=ft||`1`,Dt=Al(yt),Ot=(0,q.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),xt?.(e)},[xt]);return(0,J.jsx)(`div`,{"data-testid":`rf__wrapper`,...wt,onScroll:Ot,style:{...dt,...Qd},ref:Tt,className:Y([`react-flow`,i,Dt]),id:ft,role:`application`,children:(0,J.jsxs)(Zd,{nodes:e,edges:t,width:_t,height:vt,fitView:Xe,fitViewOptions:Ze,minZoom:he,maxZoom:ge,nodeOrigin:ue,nodeExtent:ve,zIndexMode:Ct,children:[(0,J.jsx)(Ol,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:se,autoPanOnNodeFocus:K,nodesConnectable:ce,nodesFocusable:le,edgesFocusable:de,edgesReconnectable:fe,elementsSelectable:pe,elevateNodesOnSelect:nt,elevateEdgesOnSelect:rt,minZoom:he,maxZoom:ge,nodeExtent:ve,onNodesChange:Ge,onEdgesChange:Ke,snapToGrid:G,snapGrid:ie,connectionMode:L,translateExtent:X,connectOnClick:Qe,defaultEdgeOptions:tt,fitView:Xe,fitViewOptions:Ze,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Ye,nodeOrigin:ue,rfId:Et,autoPanOnConnect:at,autoPanOnNodeDrag:ot,autoPanSpeed:st,onError:ut,connectionRadius:ct,isValidConnection:lt,selectNodesOnDrag:oe,nodeDragThreshold:pt,connectionDragThreshold:mt,onBeforeDelete:I,debug:bt,ariaLabelConfig:St,zIndexMode:Ct}),(0,J.jsx)(qd,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:ee,connectionLineComponent:z,connectionLineContainerStyle:te,selectionKeyCode:V,selectionOnDrag:H,selectionMode:U,deleteKeyCode:B,multiSelectionKeyCode:ne,panActivationKeyCode:W,zoomActivationKeyCode:re,onlyRenderVisibleElements:ae,defaultViewport:me,translateExtent:X,minZoom:he,maxZoom:ge,preventScrolling:_e,zoomOnScroll:be,zoomOnPinch:xe,zoomOnDoubleClick:Te,panOnScroll:Se,panOnScrollSpeed:Ce,panOnScrollMode:we,panOnDrag:Ee,onPaneClick:De,onPaneMouseEnter:Oe,onPaneMouseMove:ke,onPaneMouseLeave:Ae,onPaneScroll:je,onPaneContextMenu:Me,paneClickDistance:Ne,nodeClickDistance:Pe,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ie,onReconnectStart:Le,onReconnectEnd:Re,onEdgeContextMenu:ze,onEdgeDoubleClick:Be,onEdgeMouseEnter:Ve,onEdgeMouseMove:He,onEdgeMouseLeave:Ue,reconnectRadius:We,defaultMarkerColor:ye,noDragClassName:qe,noWheelClassName:Je,noPanClassName:Ye,rfId:Et,disableKeyboardA11y:it,nodeExtent:ve,viewport:ht,onViewportChange:gt}),(0,J.jsx)(xl,{onSelectionChange:k}),Fe,(0,J.jsx)(hl,{proOptions:et,position:$e}),(0,J.jsx)(pl,{rfId:Et,disableKeyboardA11y:it})]})})}var ef=Kl($d),tf=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function nf({children:e}){let t=Q(tf);return t?(0,ge.createPortal)(e,t):null}function rf(e){let[t,n]=(0,q.useState)(e);return[t,n,(0,q.useCallback)(e=>n(t=>Rl(e,t)),[])]}function af(e){let[t,n]=(0,q.useState)(e);return[t,n,(0,q.useCallback)(e=>n(t=>zl(e,t)),[])]}eo.error014();function of({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,J.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Y([`react-flow__background-pattern`,n,r])})}function sf({radius:e,className:t}){return(0,J.jsx)(`circle`,{cx:e,cy:e,r:e,className:Y([`react-flow__background-pattern`,`dots`,t])})}var cf;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(cf||={});var lf={[cf.Dots]:1,[cf.Lines]:1,[cf.Cross]:6},uf=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function df({id:e,variant:t=cf.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,q.useRef)(null),{transform:f,patternId:p}=Q(uf,el),m=r||lf[t],h=t===cf.Dots,g=t===cf.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,J.jsxs)(`svg`,{className:Y([`react-flow__background`,l]),style:{...c,...iu,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,J.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,J.jsx)(sf,{radius:y/2,className:u}):(0,J.jsx)(of,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,J.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}df.displayName=`Background`;var ff=(0,q.memo)(df);function pf(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,J.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function mf(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,J.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function hf(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,J.jsx)(`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 gf(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`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 _f(){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,J.jsx)(`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`})})}function vf({children:e,className:t,...n}){return(0,J.jsx)(`button`,{type:`button`,className:Y([`react-flow__controls-button`,t]),...n,children:e})}var yf=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function bf({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=il(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Q(yf,el),{zoomIn:y,zoomOut:b,fitView:x}=$l();return(0,J.jsxs)(ml,{className:Y([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(vf,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,J.jsx)(pf,{})}),(0,J.jsx)(vf,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,J.jsx)(mf,{})})]}),n&&(0,J.jsx)(vf,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,J.jsx)(hf,{})}),r&&(0,J.jsx)(vf,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,J.jsx)(_f,{}):(0,J.jsx)(gf,{})}),u]})}bf.displayName=`Controls`;var xf=(0,q.memo)(bf);function Sf({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,J.jsx)(`rect`,{className:Y([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var Cf=(0,q.memo)(Sf),wf=e=>e.nodes.map(e=>e.id),Tf=e=>e instanceof Function?e:()=>e;function Ef({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=Cf,onClick:o}){let s=Q(wf,el),c=Tf(t),l=Tf(e),u=Tf(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,J.jsx)(J.Fragment,{children:s.map(e=>(0,J.jsx)(Of,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Df({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Q(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=Yo(r);return{node:r,x:i,y:a,width:o,height:s}},el);return!l||l.hidden||!Xo(l)?null:(0,J.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Of=(0,q.memo)(Df),kf=(0,q.memo)(Ef),Af=200,jf=150,Mf=e=>!e.hidden,Nf=e=>{let t={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:t,boundingRect:e.nodeLookup.size>0?Fo(vo(e.nodeLookup,{filter:Mf}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Pf=`react-flow__minimap-desc`;function Ff({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=il(),S=(0,q.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=Q(Nf,el),j=e?.width??Af,M=e?.height??jf,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,ee=C.x-(I-C.width)/2-R,z=C.y-(L-C.height)/2-R,te=I+R*2,B=L+R*2,V=`${Pf}-${T}`,H=(0,q.useRef)(0),U=(0,q.useRef)();H.current=F,(0,q.useEffect)(()=>{if(S.current&&E)return U.current=mc({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>H.current}),()=>{U.current?.destroy()}},[E]),(0,q.useEffect)(()=>{U.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let W=p?e=>{let[t,n]=U.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ne=m?(0,q.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,re=_??A[`minimap.ariaLabel`];return(0,J.jsx)(ml,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Y([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,J.jsxs)(`svg`,{width:j,height:M,viewBox:`${ee} ${z} ${te} ${B}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":V,ref:S,onClick:W,children:[re&&(0,J.jsx)(`title`,{id:V,children:re}),(0,J.jsx)(kf,{onClick:ne,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,J.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${ee-R},${z-R}h${te+R*2}v${B+R*2}h${-te-R*2}z + M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Ff.displayName=`MiniMap`;var If=(0,q.memo)(Ff),Lf=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Rf={[kc.Line]:`right`,[kc.Handle]:`bottom-right`};function zf({nodeId:e,position:t,variant:n=kc.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=vu(),y=typeof e==`string`?e:v,b=il(),x=(0,q.useRef)(null),S=n===kc.Handle,C=Q((0,q.useCallback)(Lf(S&&p),[S,p]),el),w=(0,q.useRef)(null),T=t??Rf[n];return(0,q.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Vc({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=qs([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Zo({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,J.jsx)(`div`,{className:Y([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,q.memo)(zf);var Bf=`shogun.samuraiDiagnostics`,Vf=`1.16.0-build78`,Hf=!1;function Uf(){try{let e=window.localStorage.getItem(Bf);return e?JSON.parse(e):[]}catch{return[]}}function Wf(e){try{window.localStorage.setItem(Bf,JSON.stringify(e.slice(-250)))}catch{}}function Gf(e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&typeof e==`object`)try{return JSON.parse(JSON.stringify(e))}catch{return String(e)}return e}function Kf(e,t){let n=e.getBoundingClientRect(),r=window.getComputedStyle(e),i=n.left+n.width/2,a=n.top+n.height/2,o=n.width>0&&n.height>0?document.elementFromPoint(i,a):null;return{index:t,tag:e.tagName.toLowerCase(),text:e.textContent?.trim().replace(/\s+/g,` `).slice(0,80)||``,className:e.getAttribute(`class`)||``,rect:{left:Math.round(n.left),top:Math.round(n.top),width:Math.round(n.width),height:Math.round(n.height),right:Math.round(n.right),bottom:Math.round(n.bottom)},style:{display:r.display,visibility:r.visibility,opacity:r.opacity,pointerEvents:r.pointerEvents,zIndex:r.zIndex,color:r.color,backgroundColor:r.backgroundColor},topElementAtCenter:o?{tag:o.tagName.toLowerCase(),text:o.textContent?.trim().replace(/\s+/g,` `).slice(0,80)||``,className:o.getAttribute(`class`)||``,sameElement:o===e||e.contains(o)}:null}}function qf(e){return Array.from(document.querySelectorAll(`button, a`)).filter(t=>t.textContent?.trim().replace(/\s+/g,` `)===e)}function $(e,t={}){if(typeof window>`u`)return;let n={ts:new Date().toISOString(),event:e,details:Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Gf(t)]))};Wf([...Uf(),n]),console.info(`[SamuraiDiagnostics]`,n)}function Jf(e){if(typeof window>`u`)return;let t=qf(`Fleet`),n=qf(`Agent Flow`),r=Array.from(document.querySelectorAll(`[title="Node Properties"], [aria-label^="Open properties"]`)),i=Array.from(document.querySelectorAll(`.react-flow__node`)),a=Array.from(document.querySelectorAll(`h3`)).filter(e=>e.textContent?.trim()===`Node Properties`);$(`samurai.snapshot`,{reason:e,url:window.location.href,viewport:{width:window.innerWidth,height:window.innerHeight},document:{readyState:document.readyState,bodyClass:document.body.className,rootChildren:document.getElementById(`root`)?.children.length||0},counts:{fleetButtons:t.length,agentFlowButtons:n.length,nodePropertyButtons:r.length,reactFlowNodes:i.length,inspectorTitles:a.length},fleetButtons:t.map(Kf),agentFlowButtons:n.map(Kf),nodePropertyButtons:r.slice(0,10).map(Kf),reactFlowNodes:i.slice(0,10).map(Kf),inspectorTitles:a.map(Kf)})}function Yf(){typeof window>`u`||Hf||(Hf=!0,window.addEventListener(`error`,e=>{$(`window.error`,{message:e.message,filename:e.filename,lineno:e.lineno,colno:e.colno,error:e.error})}),window.addEventListener(`unhandledrejection`,e=>{$(`window.unhandledrejection`,{reason:e.reason})}))}function Xf(){Wf([]),$(`diagnostics.cleared`)}function Zf(){let e=Uf();return[`SHOGUN SAMURAI DIAGNOSTICS`,`diagnostic_build=${Vf}`,`created_at=${new Date().toISOString()}`,`url=${window.location.href}`,`user_agent=${navigator.userAgent}`,`events=${e.length}`,``].concat(e.map(e=>JSON.stringify(e))).join(` +`)}async function Qf(){Jf(`copy`);let e=Zf();try{return await navigator.clipboard.writeText(e),$(`diagnostics.copied`,{length:e.length}),!0}catch{return $(`diagnostics.copy_failed`,{length:e.length}),!1}}function $f(){Jf(`download`);let e=Zf(),t=new Blob([e],{type:`text/plain;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`shogun-samurai-diagnostics-${new Date().toISOString().replace(/[:.]/g,`-`)}.txt`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n),$(`diagnostics.downloaded`,{length:e.length})}function ep(){return Vf}var tp=Object.assign({"./templates/da.json":()=>W(()=>import(`./da-C_JRVwbf.js`).then(e=>e.default),[]),"./templates/de.json":()=>W(()=>import(`./de-CQkyhazf.js`).then(e=>e.default),[]),"./templates/en.json":()=>W(()=>import(`./en-Dy2XegBR.js`).then(e=>e.default),[]),"./templates/es.json":()=>W(()=>import(`./es-CxIGzVeO.js`).then(e=>e.default),[]),"./templates/fr.json":()=>W(()=>import(`./fr-DDa3_quw.js`).then(e=>e.default),[]),"./templates/hi.json":()=>W(()=>import(`./hi-CF82HlCM.js`).then(e=>e.default),[]),"./templates/it.json":()=>W(()=>import(`./it-DVtRUKef.js`).then(e=>e.default),[]),"./templates/ja.json":()=>W(()=>import(`./ja-CpTEhhTa.js`).then(e=>e.default),[]),"./templates/ko.json":()=>W(()=>import(`./ko-DMwqEnmZ.js`).then(e=>e.default),[]),"./templates/no.json":()=>W(()=>import(`./no-DZ89dZm7.js`).then(e=>e.default),[]),"./templates/pl.json":()=>W(()=>import(`./pl-D3ccuxiw.js`).then(e=>e.default),[]),"./templates/pt.json":()=>W(()=>import(`./pt-BFqWSkrq.js`).then(e=>e.default),[]),"./templates/sv.json":()=>W(()=>import(`./sv-B10igbrI.js`).then(e=>e.default),[]),"./templates/uk.json":()=>W(()=>import(`./uk-BJxZbDxP.js`).then(e=>e.default),[]),"./templates/zh.json":()=>W(()=>import(`./zh-BKZogL19.js`).then(e=>e.default),[])}),np={da:`Mine skabeloner`,de:`Meine Vorlagen`,es:`Mis plantillas`,fr:`Mes modèles`,hi:`मेरे टेम्पलेट`,it:`I miei modelli`,ja:`マイテンプレート`,ko:`내 템플릿`,no:`Mine maler`,pl:`Moje szablony`,pt:`Meus modelos`,sv:`Mina mallar`,uk:`Мої шаблони`,zh:`我的模板`};function rp(){let{language:e}=ie(),[t,n]=(0,q.useState)(null);(0,q.useEffect)(()=>{let t=!0;return(tp[`./templates/${e}.json`]||tp[`./templates/en.json`])?.().then(e=>{t&&n(e)}).catch(()=>tp[`./templates/en.json`]?.().then(e=>{t&&n(e)})),()=>{t=!1}},[e]);let r=(0,q.useCallback)((e,n)=>t?.ui?.[e]||n,[t]),i=(0,q.useCallback)((n,r=!1)=>r?n===`My Templates`&&np[e]||n:t?.categories?.[n]||n,[t,e]);return{ui:r,category:i,difficulty:(0,q.useCallback)(e=>t?.difficulty?.[e]||e,[t]),agentFlow:(0,q.useCallback)(e=>{let n=e.source===`custom`||e.id.startsWith(`custom:`),r=n?void 0:t?.agentFlow?.[e.id];return{...e,name:r?.name||e.name,description:r?.description||e.description,category:i(e.category,n)}},[t,i]),flowStack:(0,q.useCallback)(e=>{let n=e.source===`custom`||e.id.startsWith(`custom:`),r=n?void 0:t?.flowStack?.[e.id];return{...e,name:r?.name||e.name,description:r?.description||e.description,category:i(e.category,n),duration_label:r?.duration_label||e.duration_label,builder_nodes:e.builder_nodes?.map(e=>({...e,label:r?.builder_labels?.[e.id]||e.label}))}},[t,i])}}var ip=(0,q.createContext)(null);function ap(e){let t=/(?:Z|[+-]\d{2}:\d{2})$/i.test(e);return new Date(t?e:`${e}Z`)}function op(e){return e?ap(e).toLocaleString():`-`}var sp=[{type:`samurai`,label:`Samurai`,icon:re,color:`#d4a017`,desc:`Task worker / sub-agent`},{type:`coding`,label:`Coding`,icon:u,color:`#14b8a6`,desc:`Governed IDE and programming memory`},{type:`shogun_approval`,label:`Shogun Approval`,icon:oe,color:`#4a8cc7`,desc:`Approval gate`},{type:`logic`,label:`Logic / Decision`,icon:g,color:`#a78bfa`,desc:`Branching logic`},{type:`input`,label:`Input`,icon:pe,color:`#22c55e`,desc:`Workflow start point`},{type:`output`,label:`Output`,icon:me,color:`#f97316`,desc:`Final delivery`},{type:`mado_browser`,label:`Mado Browser`,icon:se,color:`#06b6d4`,desc:`Browser automation`},{type:`email_send`,label:`Email Send`,icon:x,color:`#e879a8`,desc:`Send email via SMTP`},{type:`channel_send`,label:`Telegram / Teams`,icon:ne,color:`#38bdf8`,desc:`Send an operator message`},{type:`workspace`,label:`Workspace`,icon:h,color:`#f59e0b`,desc:`File operations`},{type:`office`,label:`Office`,icon:p,color:`#10b981`,desc:`Office documents`},{type:`subflow`,label:`Subflow`,icon:v,color:`#8b5cf6`,desc:`Run a reusable child flow`},{type:`stack_orchestrator`,label:`Stack Orchestrator`,icon:G,color:`#c084fc`,desc:`Supervise long-running Agent Stacks`}],cp={samurai:`#d4a017`,coding:`#14b8a6`,shogun_approval:`#4a8cc7`,logic:`#a78bfa`,input:`#22c55e`,output:`#f97316`,mado_browser:`#06b6d4`,email_send:`#e879a8`,channel_send:`#38bdf8`,workspace:`#f59e0b`,office:`#10b981`,subflow:`#8b5cf6`,stack_orchestrator:`#c084fc`},lp={samurai:re,coding:u,shogun_approval:oe,logic:g,input:pe,output:me,mado_browser:se,email_send:x,channel_send:ne,workspace:h,office:p,subflow:v,stack_orchestrator:G};function up(e){return e instanceof HTMLElement&&!!e.closest(`button, input, textarea, select, a, [role="button"], .nodrag, .nowheel`)}function dp({node:e}){let t=e.status===`completed`?`#22c55e`:e.status===`failed`?`#ef4444`:e.status===`running`?`#4a8cc7`:e.status===`cancelled`?`#7a8899`:`#d4a017`;return(0,J.jsxs)(`div`,{className:`relative pl-4`,children:[e.run_depth>0&&(0,J.jsx)(`div`,{className:`absolute left-0 top-0 h-4 w-3 border-b border-l border-[#2a3060] rounded-bl`}),(0,J.jsxs)(`div`,{className:`rounded-lg border border-[#1a2040] bg-[#0e1225] p-2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{background:t}}),(0,J.jsx)(`span`,{className:`truncate text-[10px] font-bold text-[#c8d0d8]`,children:e.flow_name}),(0,J.jsxs)(`span`,{className:`text-[8px] text-[#7a8899]`,children:[`v`,e.flow_version]})]}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold uppercase`,style:{color:t},children:e.status})]}),(0,J.jsxs)(`div`,{className:`mt-1 flex gap-3 text-[8px] text-[#7a8899]`,children:[(0,J.jsxs)(`span`,{children:[`Depth `,e.run_depth]}),e.started_at&&e.completed_at&&(0,J.jsxs)(`span`,{children:[((ap(e.completed_at).getTime()-ap(e.started_at).getTime())/1e3).toFixed(1),`s`]}),(0,J.jsx)(`span`,{className:`ml-auto font-mono`,children:String(e.run_id).slice(0,8)})]})]}),e.children?.length>0&&(0,J.jsx)(`div`,{className:`mt-2 space-y-2 border-l border-[#1a2040] pl-2`,children:e.children.map(e=>(0,J.jsx)(dp,{node:e},e.run_id))})]})}function fp({id:e,data:t,selected:n,type:r}){let i=cp[r]||`#d4a017`,a=lp[r]||re,o=t.config||{},l=(0,q.useContext)(ip),d=l?.nodeStates?.[e],f=d?.status||t.execution_status,m=d?.output??t.execution_output??``,g=l?.runId||t.execution_run_id||null,_=f===`running`;return(0,J.jsxs)(`div`,{className:H(`relative min-w-[200px] max-w-[260px] rounded-lg border transition-all duration-200`,n?`ring-2 ring-offset-1 ring-offset-[#0a0e1a] shadow-lg`:`shadow-md hover:shadow-lg`),onClick:i=>{up(i.target)||($(`agent_flow.node.click`,{nodeId:e,type:r,label:t.label,selected:n}),t.onOpenInspector?.(e))},onPointerUp:i=>{up(i.target)||($(`agent_flow.node.pointer_up`,{nodeId:e,type:r,label:t.label,selected:n}),t.onOpenInspector?.(e))},style:{background:_?`linear-gradient(135deg, ${i}0a 0%, #0e1225 42%, ${i}06 100%)`:`#0e1225`,borderColor:_||n?i:`#1a2040`,boxShadow:_?`inset 0 0 20px ${i}2e, 0 0 0 3px ${i}, 0 0 14px 5px ${i}f2, 0 0 38px 14px ${i}b8, 0 0 82px 28px ${i}73, 0 0 128px 42px ${i}3d`:n?`0 0 0 1px ${i}b3, 0 0 20px ${i}55`:void 0,filter:_?`saturate(1.08) brightness(1.03)`:void 0},children:[(0,J.jsx)(`div`,{className:H(`rounded-t-lg transition-all duration-300`,_?`h-1.5`:`h-1`),style:{background:i,boxShadow:_?`0 0 10px 3px ${i}, 0 0 28px 10px ${i}d9, 0 0 52px 18px ${i}80`:void 0}}),(0,J.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 border-b`,style:{borderColor:`#1a204060`},children:[(0,J.jsx)(`div`,{className:`w-6 h-6 rounded flex items-center justify-center shrink-0`,style:{background:`${i}15`,border:`1px solid ${i}30`},children:(0,J.jsx)(a,{className:`w-3.5 h-3.5`,style:{color:i}})}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`div`,{className:`text-[11px] font-bold text-[#c8d0d8] truncate`,children:t.label}),(0,J.jsx)(`div`,{className:`text-[8px] font-bold uppercase tracking-widest`,style:{color:`${i}90`},children:r.replace(`_`,` `)})]}),(0,J.jsx)(`button`,{type:`button`,title:`Node Properties`,"aria-label":`Open properties for ${t.label||`node`}`,className:`nodrag nopan shrink-0 w-6 h-6 rounded border border-[#1a2040] bg-[#0a0e1a] text-[#7a8899] hover:text-[#d4a017] hover:border-[#d4a017]/50 flex items-center justify-center transition-colors`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onPointerUp:n=>{n.preventDefault(),n.stopPropagation(),$(`agent_flow.node.properties_button.pointer_up`,{nodeId:e,type:r,label:t.label}),t.onOpenInspector?.(e)},onClick:n=>{n.preventDefault(),n.stopPropagation(),$(`agent_flow.node.properties_button.click`,{nodeId:e,type:r,label:t.label}),t.onOpenInspector?.(e)},children:(0,J.jsx)(j,{className:`w-3 h-3`})})]}),(0,J.jsxs)(`div`,{className:`px-3 py-2 space-y-1`,children:[r===`samurai`&&(0,J.jsxs)(J.Fragment,{children:[o.task_description&&(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.task_description}),o.routing_profile_name&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(F,{className:`w-2.5 h-2.5 text-[#d4a017]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#d4a017]/80`,children:o.routing_profile_name})]}),!o.task_description&&!o.routing_profile_name&&(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899]/50 italic`,children:`Configure task...`})]}),r===`shogun_approval`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(oe,{className:`w-2.5 h-2.5 text-[#4a8cc7]/70`}),(0,J.jsxs)(`span`,{className:`text-[8px] font-bold text-[#4a8cc7]/80 uppercase`,children:[o.approval_mode||`manual`,` approval`]})]}),o.confidence_threshold&&(0,J.jsxs)(`span`,{className:`text-[8px] text-[#7a8899]`,children:[`Threshold: `,o.confidence_threshold,`%`]})]}),r===`logic`&&(0,J.jsx)(`p`,{className:`text-[9px] text-[#a78bfa]/80 font-mono`,children:o.condition_expression||`IF condition → ...`}),r===`input`&&(0,J.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,J.jsxs)(`span`,{className:`text-[8px] font-bold text-[#22c55e]/80 uppercase`,children:[o.input_type||`manual`,` trigger`]})}),r===`output`&&(0,J.jsxs)(`div`,{className:`flex flex-col gap-1.5 w-full`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#f97316]/80 uppercase`,children:o.output_type||`artifact`})}),f===`completed`&&(0,J.jsxs)(`button`,{"data-testid":`view-output-result`,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onPointerUp:e=>{e.preventDefault(),e.stopPropagation(),l?.view({runId:g,label:t.label||`Output`,content:m})},onClick:e=>{e.stopPropagation(),e.detail===0&&l?.view({runId:g,label:t.label||`Output`,content:m})},type:`button`,className:`nodrag nopan mt-1 w-full flex items-center justify-center gap-1.5 px-2 py-1 bg-[#22c55e]/10 hover:bg-[#22c55e]/20 text-[#22c55e] border border-[#22c55e]/20 rounded text-[9px] font-bold uppercase transition-colors`,children:[(0,J.jsx)(A,{className:`w-3 h-3`}),`View Result`]})]}),r===`mado_browser`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(se,{className:`w-2.5 h-2.5 text-[#06b6d4]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#06b6d4]/80 uppercase`,children:o.action||`navigate`})]}),o.url&&(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.url})]}),r===`email_send`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(x,{className:`w-2.5 h-2.5 text-[#e879a8]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#e879a8]/80 truncate`,children:o.to_address||`No recipient`})]}),o.subject&&(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.subject})]}),r===`channel_send`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(ne,{className:`w-2.5 h-2.5 text-[#38bdf8]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#38bdf8]/80 uppercase`,children:o.channel||`both`})]}),(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.message_template||`Uses predecessor output`})]}),r===`workspace`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(h,{className:`w-2.5 h-2.5 text-[#f59e0b]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#f59e0b]/80 uppercase`,children:o.action||`read_file`})]}),o.path&&(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.path})]}),r===`office`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(p,{className:`w-2.5 h-2.5 text-[#10b981]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#10b981]/80 uppercase`,children:o.action||`word_read`})]}),o.input_path&&(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] truncate`,children:o.input_path})]}),r===`coding`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(u,{className:`w-2.5 h-2.5 text-[#14b8a6]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#14b8a6]/80 uppercase`,children:o.action||`analyze`})]}),(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.task_description||o.command||`Configure coding task...`}),o.recall_memory!==!1&&(0,J.jsx)(`span`,{className:`text-[8px] text-[#14b8a6]/60`,children:`Programming memory enabled`})]}),r===`subflow`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(v,{className:`w-2.5 h-2.5 text-[#8b5cf6]/70`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#8b5cf6]/80 uppercase`,children:o.child_flow_name||`Select child flow`})]}),(0,J.jsxs)(`p`,{className:`text-[8px] text-[#7a8899]`,children:[o.child_flow_version_mode||`locked`,o.child_flow_version?` · v${o.child_flow_version}`:``,` · `,o.on_failure||`fail_parent`]})]}),r===`stack_orchestrator`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(G,{className:`w-2.5 h-2.5 text-[#c084fc]/80`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold text-[#c084fc] uppercase`,children:o.mode||`selected_stack`})]}),(0,J.jsx)(`p`,{className:`text-[9px] text-[#7a8899] line-clamp-2`,children:o.objective||`Configure a governed long-running objective`})]})]}),r!==`input`&&(0,J.jsx)(Su,{type:`target`,position:Z.Left,className:`!w-2.5 !h-2.5 !border-2 !rounded-full !bg-[#0a0e1a]`,style:{borderColor:i}}),r!==`output`&&(0,J.jsx)(Su,{type:`source`,position:Z.Right,className:`!w-2.5 !h-2.5 !border-2 !rounded-full !bg-[#0a0e1a]`,style:{borderColor:i}}),r===`logic`&&(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(Su,{type:`source`,position:Z.Bottom,id:`false`,className:`!w-2.5 !h-2.5 !border-2 !rounded-full !bg-[#0a0e1a]`,style:{borderColor:`#ef4444`}})}),f&&f!==`pending`&&(0,J.jsxs)(`div`,{className:`absolute -top-1 -right-1 z-10`,children:[f===`running`&&(0,J.jsx)(`div`,{className:`w-6 h-6 rounded-full flex items-center justify-center animate-pulse`,style:{background:i,boxShadow:`0 0 10px ${i}, 0 0 22px ${i}cc`},children:(0,J.jsx)(V,{className:`w-3 h-3 text-white animate-spin`})}),f===`completed`&&(0,J.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-[#22c55e] flex items-center justify-center shadow-[0_0_8px_rgba(34,197,94,0.4)]`,children:(0,J.jsx)(s,{className:`w-3 h-3 text-white`})}),f===`failed`&&(0,J.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-[#ef4444] flex items-center justify-center shadow-[0_0_8px_rgba(239,68,68,0.4)]`,children:(0,J.jsx)(c,{className:`w-3 h-3 text-white`})}),f===`skipped`&&(0,J.jsx)(`div`,{className:`w-5 h-5 rounded-full bg-[#7a8899] flex items-center justify-center`,children:(0,J.jsx)(te,{className:`w-3 h-3 text-white`})})]})]})}var pp={samurai:fp,coding:fp,shogun_approval:fp,logic:fp,input:fp,output:fp,mado_browser:fp,email_send:fp,channel_send:fp,workspace:fp,office:fp,subflow:fp,stack_orchestrator:fp};function mp({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,data:s,markerEnd:c,style:l,selected:u}){let[d,f,p]=Es({sourceX:t,sourceY:n,sourcePosition:a,targetX:r,targetY:i,targetPosition:o,borderRadius:12}),m=s?.edge_type===`success`?`#22c55e`:s?.edge_type===`failure`?`#ef4444`:s?.edge_type===`conditional`?`#a78bfa`:`#4a8cc7`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(nd,{id:e,path:d,markerEnd:c,style:{...l,stroke:u?`#d4a017`:m,strokeWidth:u?2.5:1.5,opacity:u?1:.7}}),s?.label&&(0,J.jsx)(nf,{children:(0,J.jsx)(`div`,{className:`absolute text-[8px] font-bold uppercase tracking-wider px-2 py-0.5 rounded border pointer-events-all`,style:{transform:`translate(-50%, -50%) translate(${f}px,${p}px)`,background:`#0e1225`,borderColor:m+`40`,color:m},children:s.label})})]})}var hp={custom:mp},gp=[`excel_read`,`word_read`,`pptx_read`];function _p({config:e,updateConfig:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)([]),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(new Set),u=e.action||`word_read`,d=gp.includes(u),f=d?`input_path`:`output_path`,p=d?`Source File`:`Destination Folder`,g=d?`Select the file to read`:`Where to save the output file`,_=d?`Input/document.docx`:`Output/`,v=(0,q.useMemo)(()=>u.startsWith(`excel`)?[`xlsx`,`xls`,`csv`]:u.startsWith(`word`)?[`docx`,`doc`]:u.startsWith(`pptx`)?[`pptx`,`ppt`]:[],[u]),y=async()=>{r(!0),s(!0);try{let e=await K.get(`/api/v1/workspace/tree`),t=e.data?.data?.tree||e.data?.data||[];a(t)}catch{a([])}s(!1)},b=e=>{t(f,e),r(!1)},x=e=>{t(f,e+`/`),r(!1)},S=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=e=>v.includes(e.toLowerCase())?`text-[#10b981]`:`text-[#7a8899]/50`,w=(e,t=0)=>{if(e.type===`directory`){let n=c.has(e.path),r=e.children||[];return(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`button`,{onClick:()=>d?S(e.path):x(e.path),className:H(`w-full flex items-center gap-2 px-3 py-1.5 rounded-lg text-left transition-colors group`,`hover:bg-[#10b981]/10`,!(!d||vp(r,v))&&d&&`opacity-40`),style:{paddingLeft:`${12+t*16}px`},children:[(0,J.jsx)(h,{className:H(`w-3.5 h-3.5`,n?`text-[#10b981]`:`text-[#f59e0b]/70`)}),(0,J.jsx)(`span`,{className:`text-xs text-[#c8d0d8] flex-1 truncate`,children:e.name}),d?(0,J.jsx)(`span`,{className:`text-[8px] text-[#7a8899] opacity-0 group-hover:opacity-100 transition-opacity`,children:n?`▼`:`▶`}):(0,J.jsx)(`span`,{className:`ml-auto text-[9px] text-[#10b981] opacity-0 group-hover:opacity-100 transition-opacity`,children:`Select`})]}),d&&n&&r.map(e=>w(e,t+1))]},e.path)}if(!d)return null;let n=e.extension||``,r=v.includes(n.toLowerCase()),i=e.size?`${(e.size/1024).toFixed(1)} KB`:``;return(0,J.jsxs)(`button`,{onClick:()=>r?b(e.path):void 0,className:H(`w-full flex items-center gap-2 px-3 py-1.5 rounded-lg text-left transition-colors group`,r?`hover:bg-[#10b981]/10 cursor-pointer`:`opacity-30 cursor-default`),style:{paddingLeft:`${12+t*16}px`},disabled:!r,children:[(0,J.jsx)(m,{className:H(`w-3.5 h-3.5`,C(n))}),(0,J.jsx)(`span`,{className:H(`text-xs flex-1 truncate`,r?`text-[#c8d0d8]`:`text-[#7a8899]/60`),children:e.name}),i&&(0,J.jsx)(`span`,{className:`text-[8px] text-[#7a8899]/50 shrink-0`,children:i}),r&&(0,J.jsx)(`span`,{className:`text-[9px] text-[#10b981] opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,children:`Select`})]},e.path)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,J.jsxs)(`select`,{value:u,onChange:e=>t(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none`,children:[(0,J.jsxs)(`optgroup`,{label:`Excel`,children:[(0,J.jsx)(`option`,{value:`excel_read`,children:`Excel — Read`}),(0,J.jsx)(`option`,{value:`excel_create`,children:`Excel — Create`}),(0,J.jsx)(`option`,{value:`excel_write`,children:`Excel — Write`})]}),(0,J.jsxs)(`optgroup`,{label:`Word`,children:[(0,J.jsx)(`option`,{value:`word_read`,children:`Word — Read`}),(0,J.jsx)(`option`,{value:`word_create`,children:`Word — Create`}),(0,J.jsx)(`option`,{value:`word_replace`,children:`Word — Replace Placeholders`})]}),(0,J.jsxs)(`optgroup`,{label:`PowerPoint`,children:[(0,J.jsx)(`option`,{value:`pptx_read`,children:`PowerPoint — Read`}),(0,J.jsx)(`option`,{value:`pptx_replace`,children:`PowerPoint — Replace Placeholders`})]})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[d?(0,J.jsx)(m,{className:`w-3 h-3 text-[#10b981]/60`}):(0,J.jsx)(h,{className:`w-3 h-3 text-[#10b981]/60`}),p]}),(0,J.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,J.jsx)(`input`,{type:`text`,value:e[f]||``,onChange:e=>t(f,e.target.value),className:`flex-1 bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none`,placeholder:_}),(0,J.jsx)(`button`,{onClick:y,className:`px-2.5 bg-[#10b981]/10 border border-[#10b981]/30 rounded-lg text-[#10b981] hover:bg-[#10b981]/20 transition-colors`,title:d?`Browse workspace files`:`Browse workspace folders`,children:d?(0,J.jsx)(m,{className:`w-3.5 h-3.5`}):(0,J.jsx)(h,{className:`w-3.5 h-3.5`})})]}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#7a8899]/60`,children:g})]}),[`excel_read`,`excel_create`,`excel_write`].includes(u)&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Sheet Name`}),(0,J.jsx)(`input`,{type:`text`,value:e.sheet_name||``,onChange:e=>t(`sheet_name`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none`,placeholder:`Sheet1`})]}),u===`word_create`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Content Template`}),(0,J.jsx)(`textarea`,{value:e.content_template||``,onChange:e=>t(`content_template`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#10b981] transition-colors outline-none resize-none`,placeholder:`Use {{context}} for predecessor data.`})]}),(0,J.jsx)(`div`,{className:`p-2.5 bg-[#10b981]/5 border border-[#10b981]/20 rounded-lg`,children:(0,J.jsxs)(`p`,{className:`text-[8px] text-[#10b981]/80`,children:[(0,J.jsx)(`strong`,{children:`Office`}),` — All paths are relative to the workspace root. Requires Office App Mode enabled in the Katana.`]})}),n&&(0,J.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 backdrop-blur-sm`,children:(0,J.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a2040] rounded-xl p-5 w-[28rem] max-h-[70vh] shadow-2xl flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,J.jsxs)(`h3`,{className:`text-sm font-bold text-[#c8d0d8] flex items-center gap-2`,children:[d?(0,J.jsx)(m,{className:`w-4 h-4 text-[#10b981]`}):(0,J.jsx)(h,{className:`w-4 h-4 text-[#10b981]`}),d?`Select Source File`:`Select Destination Folder`]}),(0,J.jsx)(`button`,{onClick:()=>r(!1),className:`p-1 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,J.jsx)(ee,{className:`w-4 h-4`})})]}),d&&(0,J.jsxs)(`p`,{className:`text-[9px] text-[#7a8899] mb-3`,children:[`Expand folders to find your file. Only `,(0,J.jsx)(`strong`,{className:`text-[#10b981]`,children:v.join(`, `)}),` files are selectable.`]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto space-y-0.5 min-h-[200px]`,children:o?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,J.jsx)(V,{className:`w-5 h-5 text-[#10b981] animate-spin`})}):i.length===0?(0,J.jsx)(`p`,{className:`text-xs text-[#7a8899] text-center py-8`,children:`No files found in workspace`}):(0,J.jsxs)(J.Fragment,{children:[!d&&(0,J.jsxs)(`button`,{onClick:()=>x(``),className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left hover:bg-[#10b981]/10 transition-colors group`,children:[(0,J.jsx)(h,{className:`w-4 h-4 text-[#10b981]`}),(0,J.jsx)(`span`,{className:`text-xs text-[#c8d0d8] font-medium`,children:`/ (workspace root)`}),(0,J.jsx)(`span`,{className:`ml-auto text-[9px] text-[#10b981] opacity-0 group-hover:opacity-100 transition-opacity`,children:`Select`})]}),i.map(e=>w(e,0))]})})]})})]})}function vp(e,t){for(let n of e)if(n.type===`file`&&t.includes((n.extension||``).toLowerCase())||n.type===`directory`&&n.children&&vp(n.children,t))return!0;return!1}function yp({label:e,value:t,onChange:n,placeholder:r}){let[i,a]=(0,q.useState)(JSON.stringify(t||{},null,2)),[o,s]=(0,q.useState)(``);return(0,q.useEffect)(()=>a(JSON.stringify(t||{},null,2)),[t]),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:e}),(0,J.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),onBlur:()=>{try{let e=JSON.parse(i||`{}`);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`Use a JSON object`);n(e),s(``)}catch(e){s(e instanceof Error?e.message:`Invalid JSON`)}},rows:5,spellCheck:!1,placeholder:r,className:H(`w-full bg-[#0a0e1a] border rounded-lg p-2 text-[10px] font-mono text-[#c8d0d8] outline-none resize-y`,o?`border-[#ef4444]`:`border-[#1a2040] focus:border-[#8b5cf6]`)}),o&&(0,J.jsx)(`p`,{className:`text-[8px] text-[#ef4444]`,children:o})]})}function bp({node:e,onUpdate:t,onClose:r,agents:i,routingProfiles:a,flowId:o,flows:s}){let c=e.type||`samurai`,u=cp[c]||`#d4a017`,d=lp[c]||re,f=e.data?.config||{},p=f.memory_infusion||{},[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(!1),y=(n,r)=>{t(e.id,{...e.data,config:{...f,[n]:r}})},x=n=>{t(e.id,{...e.data,label:n})},S=(e,t)=>{y(`memory_infusion`,{...p,[e]:t})};return(0,J.jsxs)(`div`,{className:`w-full bg-[#050508] border-l border-[#1a2040] h-full flex flex-col overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`p-4 border-b border-[#1a2040] flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`w-7 h-7 rounded-lg flex items-center justify-center`,style:{background:`${u}15`,border:`1px solid ${u}30`},children:(0,J.jsx)(d,{className:`w-4 h-4`,style:{color:u}})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8]`,children:`Node Properties`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest`,style:{color:u},children:c.replace(`_`,` `)})]})]}),(0,J.jsx)(`button`,{onClick:r,className:`p-1.5 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,J.jsx)(ee,{className:`w-3.5 h-3.5`})})]}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Label`}),(0,J.jsx)(`input`,{type:`text`,value:e.data?.label||``,onChange:e=>x(e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none`})]}),c===`samurai`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[`Linked Fleet Samurai `,(0,J.jsx)(`span`,{className:`text-[#d4a017]/70 font-normal normal-case tracking-normal`,children:`(Optional)`})]}),(0,J.jsxs)(`select`,{value:f.agent_id||``,onChange:e=>y(`agent_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:`Use Ephemeral / Ad-Hoc Samurai`}),i.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899] leading-tight`,children:`Leave unlinked to spawn a temporary Samurai that won't clutter your Fleet.`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Task Description`}),(0,J.jsx)(`textarea`,{value:f.task_description||``,onChange:e=>y(`task_description`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none resize-y min-h-[60px]`,placeholder:`Describe what this Samurai should do...`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Expected Output`}),(0,J.jsx)(`input`,{type:`text`,value:f.expected_output||``,onChange:e=>y(`expected_output`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`,placeholder:`e.g., JSON report, markdown summary...`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(F,{className:`w-3 h-3 text-[#d4a017]/70`}),` Routing Profile`]}),(0,J.jsxs)(`select`,{value:f.routing_profile_id||``,onChange:e=>y(`routing_profile_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:`System default`}),a.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Timeout (s)`}),(0,J.jsx)(`input`,{type:`number`,value:f.timeout||300,onChange:e=>y(`timeout`,parseInt(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Retries`}),(0,J.jsx)(`input`,{type:`number`,value:f.retry_count||0,onChange:e=>y(`retry_count`,parseInt(e.target.value)),min:0,max:5,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`On Failure`}),(0,J.jsxs)(`select`,{value:f.failure_action||`stop`,onChange:e=>y(`failure_action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`stop`,children:`Stop workflow`}),(0,J.jsx)(`option`,{value:`retry`,children:`Retry`}),(0,J.jsx)(`option`,{value:`skip`,children:`Skip and continue`}),(0,J.jsx)(`option`,{value:`escalate`,children:`Escalate to Shogun`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Context Injection`}),(0,J.jsx)(`textarea`,{value:f.context_injection||``,onChange:e=>y(`context_injection`,e.target.value),rows:2,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none resize-none`,placeholder:`Additional context to inject...`})]})]}),c===`shogun_approval`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Approval Mode`}),(0,J.jsxs)(`select`,{value:f.approval_mode||`manual`,onChange:e=>y(`approval_mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`manual`,children:`Manual Human Approval`}),(0,J.jsx)(`option`,{value:`ai_assisted`,children:`AI-Assisted Approval`}),(0,J.jsx)(`option`,{value:`policy_based`,children:`Policy-Based Approval`}),(0,J.jsx)(`option`,{value:`confidence_threshold`,children:`Confidence Threshold`})]})]}),f.approval_mode===`confidence_threshold`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Confidence Threshold (%)`}),(0,J.jsx)(`input`,{type:`number`,value:f.confidence_threshold||85,onChange:e=>y(`confidence_threshold`,parseInt(e.target.value)),min:0,max:100,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Escalation Action`}),(0,J.jsxs)(`select`,{value:f.escalation_action||`notify`,onChange:e=>y(`escalation_action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`notify`,children:`Notify operator`}),(0,J.jsx)(`option`,{value:`block`,children:`Block until manual review`}),(0,J.jsx)(`option`,{value:`reroute`,children:`Reroute for revision`}),(0,J.jsx)(`option`,{value:`stop`,children:`Stop workflow`})]})]})]}),c===`logic`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Condition Expression`}),(0,J.jsx)(`textarea`,{value:f.condition_expression||``,onChange:e=>y(`condition_expression`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#a78bfa] font-mono focus:border-[#a78bfa] transition-colors outline-none resize-none`,placeholder:`e.g., confidence > 85%`})]}),(0,J.jsx)(`div`,{className:`p-2.5 bg-[#a78bfa]/5 border border-[#a78bfa]/20 rounded-lg`,children:(0,J.jsxs)(`p`,{className:`text-[8px] text-[#a78bfa]/80`,children:[(0,J.jsx)(`strong`,{children:`Right handle →`}),` TRUE branch`,(0,J.jsx)(`br`,{}),(0,J.jsx)(`strong`,{children:`Bottom handle ↓`}),` FALSE branch`]})})]}),c===`input`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Input Type`}),(0,J.jsxs)(`select`,{value:f.input_type||`manual`,onChange:e=>y(`input_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`manual`,children:`Manual Input`}),(0,J.jsx)(`option`,{value:`document`,children:`Document Upload`}),(0,J.jsx)(`option`,{value:`api`,children:`API Trigger`}),(0,J.jsx)(`option`,{value:`scheduled`,children:`Scheduled Trigger`}),(0,J.jsx)(`option`,{value:`event`,children:`Event-Based Trigger`}),(0,J.jsx)(`option`,{value:`nexus`,children:`Nexus Task`})]})]}),f.input_type===`scheduled`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(n,{className:`w-3 h-3`}),` Frequency`]}),(0,J.jsxs)(`select`,{value:f.schedule_frequency||`nightly`,onChange:e=>y(`schedule_frequency`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`hourly`,children:`Hourly`}),(0,J.jsx)(`option`,{value:`nightly`,children:`Daily (Nightly)`}),(0,J.jsx)(`option`,{value:`weekly`,children:`Weekly`}),(0,J.jsx)(`option`,{value:`monthly`,children:`Monthly`})]})]}),f.schedule_frequency!==`hourly`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(l,{className:`w-3 h-3`}),` Run Time`]}),(0,J.jsx)(`input`,{type:`time`,value:f.schedule_time||`07:00`,onChange:e=>y(`schedule_time`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`})]}),f.schedule_frequency===`hourly`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Minute Offset`}),(0,J.jsx)(`input`,{type:`number`,min:0,max:59,value:f.schedule_minute_offset??0,onChange:e=>y(`schedule_minute_offset`,parseInt(e.target.value)||0),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`,placeholder:`0`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Runs at this minute past every hour (0–59)`})]}),f.schedule_frequency===`weekly`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Days of Week`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`].map(e=>{let t=f.schedule_days||[`mon`,`tue`,`wed`,`thu`,`fri`],n=t.includes(e);return(0,J.jsx)(`button`,{type:`button`,onClick:()=>{let r=n?t.filter(t=>t!==e):[...t,e];y(`schedule_days`,r.length?r:[e])},className:H(`px-2 py-1 rounded text-[9px] font-bold uppercase tracking-wider transition-all cursor-pointer border`,n?`bg-[#22c55e]/15 border-[#22c55e]/40 text-[#22c55e]`:`bg-[#0a0e1a] border-[#1a2040] text-[#555] hover:border-[#2a3060]`),children:e},e)})})]}),f.schedule_frequency===`monthly`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Day of Month`}),(0,J.jsx)(`input`,{type:`number`,min:1,max:28,value:f.schedule_day||1,onChange:e=>y(`schedule_day`,parseInt(e.target.value)||1),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Day 1–28 (avoids month-length issues)`})]}),(0,J.jsx)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5`,children:(0,J.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,J.jsx)(`strong`,{children:`Note:`}),` Saving a scheduled trigger activates the flow and registers it with the job scheduler.`]})})]}),f.input_type===`document`&&(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(P,{className:`w-3 h-3`}),` Upload Document`]}),(0,J.jsx)(`div`,{className:H(`border-2 border-dashed rounded-xl p-4 text-center cursor-pointer transition-all duration-200`,`hover:border-[#22c55e]/50 hover:bg-[#22c55e]/5`,f.uploaded_file?`border-[#22c55e]/30 bg-[#22c55e]/5`:`border-[#1a2040] bg-[#0a0e1a]`),onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`.pdf,.txt,.csv,.json,.md,.docx,.xlsx`,e.onchange=async e=>{let t=e.target.files?.[0];if(!t)return;let n=new FormData;n.append(`file`,t);try{let e=(await K.post(`/api/v1/agent-flows/${o}/upload`,n)).data?.data;y(`uploaded_file`,{filename:e?.filename||t.name,size:t.size,path:e?.path||``})}catch{y(`uploaded_file`,{filename:t.name,size:t.size,path:``,error:`Upload failed`})}},e.click()},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:async e=>{e.preventDefault(),e.stopPropagation();let t=e.dataTransfer.files?.[0];if(!t)return;let n=new FormData;n.append(`file`,t);try{let e=(await K.post(`/api/v1/agent-flows/${o}/upload`,n)).data?.data;y(`uploaded_file`,{filename:e?.filename||t.name,size:t.size,path:e?.path||``})}catch{y(`uploaded_file`,{filename:t.name,size:t.size,path:``,error:`Upload failed`})}},children:f.uploaded_file?(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(m,{className:`w-6 h-6 mx-auto text-[#22c55e]`}),(0,J.jsx)(`p`,{className:`text-[10px] font-bold text-[#c8d0d8] truncate`,children:f.uploaded_file.filename}),(0,J.jsxs)(`p`,{className:`text-[8px] text-[#555]`,children:[(f.uploaded_file.size/1024).toFixed(1),` KB`]}),(0,J.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),y(`uploaded_file`,null)},className:`text-[8px] text-[#ef4444] hover:text-[#ef4444]/80 font-bold uppercase tracking-wider cursor-pointer`,children:`Remove`})]}):(0,J.jsxs)(`div`,{className:`space-y-1.5 py-2`,children:[(0,J.jsx)(P,{className:`w-6 h-6 mx-auto text-[#555]`}),(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899] font-bold`,children:`Drag & drop or click to upload`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`PDF, TXT, CSV, JSON, MD, DOCX, XLSX`})]})})]})}),(!f.input_type||f.input_type===`manual`)&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Initial Context`}),(0,J.jsx)(`textarea`,{value:f.manual_input||``,onChange:e=>y(`manual_input`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none resize-y min-h-[60px]`,placeholder:`Enter initial context or instructions for the flow...`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`This text is passed as input when the flow runs`})]}),f.input_type===`api`&&(()=>{let[e,t]=(0,q.useState)(!1),[n,r]=(0,q.useState)([]);(0,q.useEffect)(()=>{let e=!1;return t(!0),K.get(`/api/v1/tools`).then(t=>{e||r(t.data?.data||[])}).catch(()=>{}).finally(()=>{e||t(!1)}),()=>{e=!0}},[]);let i=n.find(e=>e.id===f.api_tool_id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(F,{className:`w-3 h-3`}),` API Source`]}),(0,J.jsxs)(`select`,{value:f.api_tool_id||``,onChange:e=>{let t=n.find(t=>t.id===e.target.value);y(`api_tool_id`,e.target.value||null),y(`api_tool_name`,t?.name||null),y(`api_base_url`,t?.base_url||null)},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:`— Webhook (direct POST) —`}),e&&(0,J.jsx)(`option`,{disabled:!0,children:`Loading connectors...`}),n.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.connector_type,`)`,e.base_url?` · ${e.base_url}`:``]},e.id))]}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:f.api_tool_id?`This flow triggers via the selected API connector`:`Select a connector or use the direct webhook URL below`})]}),i&&(0,J.jsxs)(`div`,{className:`bg-[#06b6d4]/5 border border-[#06b6d4]/20 rounded-lg p-2.5 space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`span`,{className:`text-[9px] font-bold text-[#06b6d4]`,children:i.name}),(0,J.jsx)(`span`,{className:H(`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded`,i.status===`active`?`text-green-400 bg-green-500/10`:`text-[#555] bg-[#0a0e1a]`),children:i.status})]}),i.base_url&&(0,J.jsx)(`p`,{className:`text-[8px] text-[#555] font-mono truncate`,children:i.base_url})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(b,{className:`w-3 h-3`}),` Webhook URL`]}),(0,J.jsxs)(`div`,{className:`flex gap-1`,children:[(0,J.jsx)(`input`,{type:`text`,readOnly:!0,value:`${window.location.origin}/api/v1/agent-flows/${o}/runs`,className:`flex-1 bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#7a8899] font-mono outline-none select-all`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{navigator.clipboard.writeText(`${window.location.origin}/api/v1/agent-flows/${o}/runs`)},className:`p-2 bg-[#0a0e1a] border border-[#1a2040] rounded-lg hover:border-[#22c55e]/40 transition-colors cursor-pointer`,title:`Copy URL`,children:(0,J.jsx)(de,{className:`w-3 h-3 text-[#7a8899]`})})]})]}),(0,J.jsxs)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5 space-y-1.5`,children:[(0,J.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,J.jsx)(`strong`,{children:`Usage:`}),` Send a `,(0,J.jsx)(`code`,{className:`bg-[#0a0e1a] px-1 py-0.5 rounded text-[8px]`,children:`POST`}),` request with a JSON body to trigger this flow.`]}),(0,J.jsx)(`pre`,{className:`text-[8px] text-[#555] font-mono bg-[#0a0e1a] p-2 rounded overflow-x-auto`,children:`POST /api/v1/agent-flows/${o}/runs +Content-Type: application/json + +{ "trigger_type": "api" }`})]})]})})(),f.input_type===`event`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(he,{className:`w-3 h-3`}),` Event Source`]}),(0,J.jsxs)(`select`,{value:f.event_source||`email`,onChange:e=>y(`event_source`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`email`,children:`Email Received`}),(0,J.jsx)(`option`,{value:`bushido`,children:`Bushido Schedule`}),(0,J.jsx)(`option`,{value:`system`,children:`System Event`}),(0,J.jsx)(`option`,{value:`custom`,children:`Custom Event`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Event Filter`}),(0,J.jsx)(`input`,{type:`text`,value:f.event_filter||``,onChange:e=>y(`event_filter`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none`,placeholder:f.event_source===`email`?`from:*@client.com`:f.event_source===`system`?`event_type:agent.deployed`:`filter expression...`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Optional filter to narrow which events trigger this flow`})]}),(0,J.jsxs)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5 space-y-1`,children:[(0,J.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,J.jsx)(`strong`,{children:`How it works:`}),` When a matching event is captured by the Shogun Event Logger, this flow will be triggered automatically.`]}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555] leading-relaxed`,children:`Events are emitted by all subsystems — email sync, agent actions, Bushido schedules, browser automation, and system heartbeats.`})]})]}),f.input_type===`nexus`&&(()=>{let[e,t]=(0,q.useState)(!1),[n,r]=(0,q.useState)([]);return(0,q.useEffect)(()=>{let e=!1;return t(!0),K.get(`/api/v1/workspaces`).then(t=>{e||r(t.data?.data||[])}).catch(()=>{}).finally(()=>{e||t(!1)}),()=>{e=!0}},[]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest flex items-center gap-1`,children:[(0,J.jsx)(F,{className:`w-3 h-3`}),` Nexus Workspace`]}),(0,J.jsxs)(`select`,{value:f.nexus_workspace_id||``,onChange:e=>y(`nexus_workspace_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:`— Select workspace —`}),e&&(0,J.jsx)(`option`,{disabled:!0,children:`Loading...`}),n.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,e.topic?` (${e.topic})`:``]},e.id))]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Trigger on Message Type`}),(0,J.jsxs)(`select`,{value:f.nexus_message_type||`task`,onChange:e=>y(`nexus_message_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`task`,children:`Task messages`}),(0,J.jsx)(`option`,{value:`proposal`,children:`Proposals`}),(0,J.jsx)(`option`,{value:`signal`,children:`Signals / Alerts`}),(0,J.jsx)(`option`,{value:`any`,children:`Any message`})]}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`This flow triggers when a matching message arrives in the workspace`})]}),(0,J.jsx)(`div`,{className:`bg-[#22c55e]/5 border border-[#22c55e]/20 rounded-lg p-2.5 space-y-1`,children:(0,J.jsxs)(`p`,{className:`text-[9px] text-[#22c55e]/80 leading-relaxed`,children:[(0,J.jsx)(`strong`,{children:`How it works:`}),` When a `,(0,J.jsx)(`code`,{className:`bg-[#0a0e1a] px-1 py-0.5 rounded text-[8px]`,children:f.nexus_message_type||`task`}),` message arrives in the linked workspace, the message content is passed as input to this flow.`]})})]})})(),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Description`}),(0,J.jsx)(`textarea`,{value:f.description||``,onChange:e=>y(`description`,e.target.value),rows:2,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#22c55e] transition-colors outline-none resize-y min-h-[44px]`,placeholder:`Describe the input...`})]})]}),c===`output`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Output Type`}),(0,J.jsxs)(`select`,{value:f.output_type||`artifact`,onChange:e=>y(`output_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`artifact`,children:`Artifact / Report`}),(0,J.jsx)(`option`,{value:`export`,children:`Export File`}),(0,J.jsx)(`option`,{value:`api`,children:`API Response`}),(0,J.jsx)(`option`,{value:`notification`,children:`Notification`}),(0,J.jsx)(`option`,{value:`memory`,children:`Store in Memory`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Format`}),(0,J.jsxs)(`select`,{value:f.format||`markdown`,onChange:e=>y(`format`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f97316] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`markdown`,children:`Markdown`}),(0,J.jsx)(`option`,{value:`json`,children:`JSON`}),(0,J.jsx)(`option`,{value:`html`,children:`HTML`}),(0,J.jsx)(`option`,{value:`plain`,children:`Plain Text`})]})]}),(0,J.jsxs)(`div`,{className:`rounded-lg border border-[#f97316]/25 bg-[#f97316]/5 p-3 space-y-3`,children:[(0,J.jsxs)(`label`,{className:`flex items-center justify-between gap-3 cursor-pointer`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`span`,{className:`block text-[9px] font-bold text-[#f97316] uppercase tracking-widest`,children:`Memory Infusion`}),(0,J.jsx)(`span`,{className:`block text-[8px] text-[#7a8899] mt-1`,children:`Store this output mechanically in Archives`})]}),(0,J.jsx)(`input`,{type:`checkbox`,checked:p.enabled===!0,onChange:e=>y(`memory_infusion`,{memory_type:`episodic`,importance:.8,decay_type:`sticky`,tags:[`auto-stored`,`flow-output`],title_template:`{flow_name} - {timestamp}`,content_fields:[`result`,`summary`],redact_sensitive:!0,on_missing_field:`store_available`,max_content_length:12e3,store_on:`success`,deduplication:{mode:`exact`,semantic_threshold:.92},...p,enabled:e.target.checked}),className:`accent-[#f97316]`})]}),p.enabled===!0&&(0,J.jsxs)(`div`,{className:`space-y-3 border-t border-[#f97316]/15 pt-3`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Memory type`,(0,J.jsx)(`select`,{value:p.memory_type||`episodic`,onChange:e=>S(`memory_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[`episodic`,`semantic`,`procedural`,`persona`].map(e=>(0,J.jsx)(`option`,{children:e},e))})]}),(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Decay`,(0,J.jsx)(`select`,{value:p.decay_type||`sticky`,onChange:e=>S(`decay_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[`fast`,`medium`,`slow`,`sticky`,`pinned`].map(e=>(0,J.jsx)(`option`,{children:e},e))})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Importance`,(0,J.jsx)(`input`,{type:`number`,min:0,max:1,step:.05,value:p.importance??.8,onChange:e=>S(`importance`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`})]}),(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Store on`,(0,J.jsxs)(`select`,{value:p.store_on||`success`,onChange:e=>S(`store_on`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[(0,J.jsx)(`option`,{value:`success`,children:`Success`}),(0,J.jsx)(`option`,{value:`partial`,children:`Partial`}),(0,J.jsx)(`option`,{value:`always`,children:`Always`})]})]})]}),(0,J.jsxs)(`label`,{className:`block space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Title template`,(0,J.jsx)(`input`,{value:p.title_template||`{flow_name} - {timestamp}`,onChange:e=>S(`title_template`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] normal-case text-[#c8d0d8] outline-none`})]}),(0,J.jsxs)(`label`,{className:`block space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Content fields`,(0,J.jsx)(`input`,{value:(p.content_fields||[`result`,`summary`]).join(`, `),onChange:e=>S(`content_fields`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] normal-case text-[#c8d0d8] outline-none`})]}),(0,J.jsxs)(`label`,{className:`block space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Tags`,(0,J.jsx)(`input`,{value:(p.tags||[`auto-stored`,`flow-output`]).join(`, `),onChange:e=>S(`tags`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] normal-case text-[#c8d0d8] outline-none`})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Missing fields`,(0,J.jsxs)(`select`,{value:p.on_missing_field||`store_available`,onChange:e=>S(`on_missing_field`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[(0,J.jsx)(`option`,{value:`store_available`,children:`Store available`}),(0,J.jsx)(`option`,{value:`skip`,children:`Skip memory`}),(0,J.jsx)(`option`,{value:`fail`,children:`Fail node`})]})]}),(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Max characters`,(0,J.jsx)(`input`,{type:`number`,min:256,max:1e5,value:p.max_content_length||12e3,onChange:e=>S(`max_content_length`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Deduplication`,(0,J.jsxs)(`select`,{value:p.deduplication?.mode||`exact`,onChange:e=>S(`deduplication`,{semantic_threshold:.92,...p.deduplication,mode:e.target.value}),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`,children:[(0,J.jsx)(`option`,{value:`none`,children:`None`}),(0,J.jsx)(`option`,{value:`exact`,children:`Exact hash`}),(0,J.jsx)(`option`,{value:`semantic`,children:`Semantic`})]})]}),p.deduplication?.mode===`semantic`&&(0,J.jsxs)(`label`,{className:`space-y-1 text-[8px] uppercase text-[#7a8899]`,children:[`Similarity`,(0,J.jsx)(`input`,{type:`number`,min:.5,max:1,step:.01,value:p.deduplication?.semantic_threshold??.92,onChange:e=>S(`deduplication`,{...p.deduplication,mode:`semantic`,semantic_threshold:Number(e.target.value)}),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded p-2 text-[10px] text-[#c8d0d8] outline-none`})]})]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-2 text-[9px] text-[#c8d0d8] cursor-pointer`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:p.redact_sensitive!==!1,onChange:e=>S(`redact_sensitive`,e.target.checked),className:`accent-[#f97316]`}),`Redact credentials and secrets before storage`]})]})]})]}),c===`coding`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`rounded-lg border border-[#14b8a6]/20 bg-[#14b8a6]/5 p-2.5 text-[9px] leading-relaxed text-[#8adbd1]`,children:`Coding nodes use governed IDE Mode. Workspace actions require Campaign or Ronin posture, an approved workspace, and the matching IDE permissions.`}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,J.jsxs)(`select`,{value:f.action||`analyze`,onChange:e=>y(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none`,children:[(0,J.jsx)(`option`,{value:`analyze`,children:`Analyze / Plan`}),(0,J.jsx)(`option`,{value:`list_files`,children:`List Repository Files`}),(0,J.jsx)(`option`,{value:`search`,children:`Search Code`}),(0,J.jsx)(`option`,{value:`read_file`,children:`Read File`}),(0,J.jsx)(`option`,{value:`apply_patch`,children:`Write / Replace File`}),(0,J.jsx)(`option`,{value:`run_task`,children:`Run Test / Build Task`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Task Description`}),(0,J.jsx)(`textarea`,{value:f.task_description||``,onChange:e=>y(`task_description`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none resize-y`,placeholder:`Describe the coding objective and acceptance criteria...`})]}),f.action!==`analyze`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Approved Workspace ID`}),(0,J.jsx)(`input`,{value:f.workspace_id||``,onChange:e=>y(`workspace_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none`,placeholder:`VS Code workspace UUID`})]}),(f.action===`read_file`||f.action===`apply_patch`)&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Workspace-relative Path`}),(0,J.jsx)(`input`,{value:f.path||``,onChange:e=>y(`path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#14b8a6] outline-none font-mono`,placeholder:`src/module.py`})]}),f.action===`search`&&(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsx)(`input`,{value:f.query||``,onChange:e=>y(`query`,e.target.value),className:`bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,placeholder:`Search text`}),(0,J.jsx)(`input`,{value:f.file_glob||`*`,onChange:e=>y(`file_glob`,e.target.value),className:`bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,placeholder:`*.py`})]}),f.action===`apply_patch`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Complete File Content`}),(0,J.jsx)(`textarea`,{value:f.content_template||``,onChange:e=>y(`content_template`,e.target.value),rows:7,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#c8d0d8] font-mono outline-none`,placeholder:`Use {{context}} to insert predecessor output.`})]}),f.action===`run_task`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Allowlisted Command`}),(0,J.jsx)(`input`,{value:f.command||``,onChange:e=>y(`command`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] font-mono outline-none`,placeholder:`pytest tests/test_feature.py`})]}),(0,J.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-[#1a2040] bg-[#0a0e1a] p-2.5 text-[10px] text-[#c8d0d8]`,children:[`Recall project programming memory`,(0,J.jsx)(`input`,{type:`checkbox`,checked:f.recall_memory!==!1,onChange:e=>y(`recall_memory`,e.target.checked)})]}),f.action===`run_task`&&(0,J.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-[#1a2040] bg-[#0a0e1a] p-2.5 text-[10px] text-[#c8d0d8]`,children:[`Remember successful verified result`,(0,J.jsx)(`input`,{type:`checkbox`,checked:!!f.remember_on_success,onChange:e=>y(`remember_on_success`,e.target.checked)})]})]}),c===`subflow`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`rounded-lg border border-[#8b5cf6]/25 bg-[#8b5cf6]/5 p-3`,children:[(0,J.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-widest text-[#8b5cf6]`,children:`Governed child execution`}),(0,J.jsx)(`p`,{className:`mt-1 text-[9px] leading-relaxed text-[#7a8899]`,children:`The child inherits this run's posture, permission ceiling, audit context, and cancellation state.`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Child Flow`}),(0,J.jsxs)(`select`,{value:f.child_flow_id||``,onChange:n=>{let r=s.find(e=>e.id===n.target.value);t(e.id,{...e.data,config:{...f,child_flow_id:r?.id||``,child_flow_name:r?.name||``,child_flow_version:r?.version||null,child_flow_version_mode:f.child_flow_version_mode||`locked`,execution_mode:`sequential`,timeout_seconds:f.timeout_seconds||600,on_failure:f.on_failure||`fail_parent`}}),g(null)},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`,children:[(0,J.jsx)(`option`,{value:``,children:`Select a reusable flow...`}),s.filter(e=>e.id!==o).map(e=>(0,J.jsxs)(`option`,{value:e.id,disabled:!e.allow_as_subflow,children:[e.name,` · v`,e.version,` · `,e.risk_tier,e.allow_as_subflow?``:` · blocked`]},e.id))]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Version`}),(0,J.jsxs)(`select`,{value:f.child_flow_version_mode||`locked`,onChange:e=>y(`child_flow_version_mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`,children:[(0,J.jsx)(`option`,{value:`locked`,children:`Locked`}),(0,J.jsx)(`option`,{value:`latest`,children:`Latest`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Timeout`}),(0,J.jsx)(`input`,{type:`number`,min:1,max:86400,value:f.timeout_seconds||600,onChange:e=>y(`timeout_seconds`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Failure Policy`}),(0,J.jsxs)(`select`,{value:f.on_failure||`fail_parent`,onChange:e=>y(`on_failure`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#8b5cf6] outline-none`,children:[(0,J.jsx)(`option`,{value:`fail_parent`,children:`Fail parent`}),(0,J.jsx)(`option`,{value:`continue_with_error`,children:`Continue with error`}),(0,J.jsx)(`option`,{value:`route_to_error`,children:`Route error downstream`})]})]}),(0,J.jsx)(yp,{label:`Input Mapping`,value:f.input_mapping||{},onChange:e=>y(`input_mapping`,e),placeholder:`{"topic": "{{input.topic}}"}`}),(0,J.jsx)(yp,{label:`Output Mapping`,value:f.output_mapping||{},onChange:e=>y(`output_mapping`,e),placeholder:`{"summary": "{{output.summary}}"}`}),(0,J.jsxs)(`button`,{type:`button`,disabled:!f.child_flow_id||_,onClick:async()=>{if(f.child_flow_id){v(!0);try{let e=await K.post(`/api/v1/agent-flows/${o}/validate-subflow`,{child_flow_id:f.child_flow_id,child_flow_version_mode:f.child_flow_version_mode||`locked`,child_flow_version:f.child_flow_version||null});g(e.data?.data||null)}catch(e){g({valid:!1,warnings:[],errors:[K.isAxiosError(e)?e.response?.data?.detail||e.message:`Validation failed`]})}finally{v(!1)}}},className:`w-full flex items-center justify-center gap-2 rounded-lg border border-[#8b5cf6]/30 bg-[#8b5cf6]/10 px-3 py-2 text-[9px] font-bold uppercase tracking-widest text-[#a78bfa] disabled:opacity-40`,children:[_?(0,J.jsx)(V,{className:`w-3 h-3 animate-spin`}):(0,J.jsx)(oe,{className:`w-3 h-3`}),`Validate safety & governance`]}),h&&(0,J.jsxs)(`div`,{className:H(`rounded-lg border p-2.5 text-[9px]`,h.valid?`border-[#22c55e]/25 bg-[#22c55e]/5 text-[#22c55e]`:`border-[#ef4444]/25 bg-[#ef4444]/5 text-[#ef4444]`),children:[(0,J.jsx)(`p`,{className:`font-bold uppercase tracking-wider`,children:h.valid?`Reference is safe`:`Reference is blocked`}),[...h.warnings,...h.errors].map((e,t)=>(0,J.jsx)(`p`,{className:`mt-1 opacity-80`,children:e},t))]})]}),c===`stack_orchestrator`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`rounded-lg border border-[#c084fc]/25 bg-[#c084fc]/5 p-3`,children:[(0,J.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-widest text-[#c084fc]`,children:`Runtime control layer`}),(0,J.jsx)(`p`,{className:`mt-1 text-[9px] leading-relaxed text-[#7a8899]`,children:`Supervises Agent Stacks through persistent state, checkpoints, verification, retries and inherited posture permissions. Concrete work remains in Agent Flow.`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Execution Mode`}),(0,J.jsxs)(`select`,{value:f.mode||`selected_stack`,onChange:e=>y(`mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`,children:[(0,J.jsx)(`option`,{value:`selected_stack`,children:`Selected Agent Stack`}),(0,J.jsx)(`option`,{value:`template`,children:`Stack Template`}),(0,J.jsx)(`option`,{value:`goal_driven`,children:`Goal-driven plan`})]})]}),(f.mode||`selected_stack`)===`selected_stack`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Agent Stack`}),(0,J.jsxs)(`select`,{value:f.selected_stack_id||``,onChange:e=>y(`selected_stack_id`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`,children:[(0,J.jsx)(`option`,{value:``,children:`Select an Agent Stack...`}),s.filter(e=>e.id!==o).map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.flow_type,` · `,e.risk_tier]},e.id))]})]}),f.mode===`template`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Stack Template ID`}),(0,J.jsx)(`input`,{value:f.stack_template_id||``,onChange:e=>y(`stack_template_id`,e.target.value),placeholder:`bug-fix-stack`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Objective`}),(0,J.jsx)(`textarea`,{value:f.objective||``,onChange:e=>y(`objective`,e.target.value),rows:3,placeholder:`Describe the long-running outcome...`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none resize-y`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Success Criteria`}),(0,J.jsx)(`textarea`,{value:(f.success_criteria||[]).join(` +`),onChange:e=>y(`success_criteria`,e.target.value.split(` +`).map(e=>e.trim()).filter(Boolean)),rows:3,placeholder:`One criterion per line +Tests pass +Artifacts verified`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none resize-y`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Allowed Tools`}),(0,J.jsx)(`input`,{value:(f.allowed_tools||[]).join(`, `),onChange:e=>y(`allowed_tools`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),placeholder:`workspace, ide, mado`,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`This list can only narrow the active posture. IDE and Ronin permissions must also be explicitly enabled.`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Model Routing Profile`}),(0,J.jsxs)(`select`,{value:f.model_routing_profile||`balanced`,onChange:e=>y(`model_routing_profile`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#c084fc] outline-none`,children:[(0,J.jsx)(`option`,{value:`balanced`,children:`Balanced`}),a.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Max Runtime (min)`}),(0,J.jsx)(`input`,{type:`number`,min:1,max:1440,value:f.max_runtime_minutes||60,onChange:e=>y(`max_runtime_minutes`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Max Iterations`}),(0,J.jsx)(`input`,{type:`number`,min:1,max:500,value:f.max_iterations||50,onChange:e=>y(`max_iterations`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Retries / Step`}),(0,J.jsx)(`input`,{type:`number`,min:0,max:10,value:f.max_retry_attempts_per_step??2,onChange:e=>y(`max_retry_attempts_per_step`,Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Checkpoint`}),(0,J.jsxs)(`select`,{value:f.checkpoint_frequency||`after_each_step`,onChange:e=>y(`checkpoint_frequency`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,J.jsx)(`option`,{value:`after_each_step`,children:`Each step`}),(0,J.jsx)(`option`,{value:`after_each_subflow`,children:`Each subflow`}),(0,J.jsx)(`option`,{value:`timed`,children:`Timed`})]})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border border-[#1a2040] p-2 text-[9px] text-[#c8d0d8]`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:f.context_compaction!==!1,onChange:e=>y(`context_compaction`,e.target.checked)}),` Context compaction`]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-2 rounded-lg border border-[#1a2040] p-2 text-[9px] text-[#c8d0d8]`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:f.verification_required!==!1,onChange:e=>y(`verification_required`,e.target.checked)}),` Verification required`]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Approval Policy`}),(0,J.jsxs)(`select`,{value:f.approval_policy||`inherited`,onChange:e=>y(`approval_policy`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,J.jsx)(`option`,{value:`inherited`,children:`Inherited`}),(0,J.jsx)(`option`,{value:`step_based`,children:`Step based`}),(0,J.jsx)(`option`,{value:`always_required_for_high_risk`,children:`Always for high risk`})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Failure Policy`}),(0,J.jsxs)(`select`,{value:f.failure_policy||`pause`,onChange:e=>y(`failure_policy`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,J.jsx)(`option`,{value:`pause`,children:`Pause`}),(0,J.jsx)(`option`,{value:`retry`,children:`Retry`}),(0,J.jsx)(`option`,{value:`continue_with_error`,children:`Continue with error`}),(0,J.jsx)(`option`,{value:`fail_stack`,children:`Fail stack`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Artifacts`}),(0,J.jsxs)(`select`,{value:f.artifact_policy||`retain_all`,onChange:e=>y(`artifact_policy`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] outline-none`,children:[(0,J.jsx)(`option`,{value:`retain_all`,children:`Retain all`}),(0,J.jsx)(`option`,{value:`retain_final_only`,children:`Final only`}),(0,J.jsx)(`option`,{value:`retain_selected`,children:`Selected`})]})]})]})]}),c===`mado_browser`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,J.jsxs)(`select`,{value:f.action||`navigate`,onChange:e=>y(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`navigate`,children:`Navigate to URL`}),(0,J.jsx)(`option`,{value:`extract_content`,children:`Extract Content`}),(0,J.jsx)(`option`,{value:`screenshot`,children:`Take Screenshot`}),(0,J.jsx)(`option`,{value:`fill_form`,children:`Fill Form`}),(0,J.jsx)(`option`,{value:`click`,children:`Click Element`}),(0,J.jsx)(`option`,{value:`execute_js`,children:`Execute JavaScript`}),(0,J.jsx)(`option`,{value:`wait_for`,children:`Wait for Element`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`URL`}),(0,J.jsx)(`input`,{type:`text`,value:f.url||``,onChange:e=>y(`url`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none`,placeholder:`https://example.com`})]}),(()=>{let n=[{value:`headlines`,label:`📰 All Headlines`,selector:`h1, h2, h3, h4, article h2, article h3`,desc:`Grabs all headline text from the page`},{value:`links`,label:`🔗 All Links`,selector:`a[href]`,desc:`Extracts every link on the page with its URL`},{value:`article`,label:`📄 Article Content`,selector:`article, [role="article"], .post-content, .entry-content, .article-body, main`,desc:`Main article text and body content`},{value:`news_cards`,label:`🗞️ News Cards`,selector:`article a, [data-n-tid] a, c-wiz article, [jslog] h3, [jslog] h4`,desc:`News feed cards (Google News, news aggregators)`},{value:`tables`,label:`📊 Tables & Data`,selector:`table, [role="table"], .data-table`,desc:`Structured tables and data grids`},{value:`images`,label:`🖼️ Images`,selector:`img[src], picture source`,desc:`All images with their source URLs`},{value:`lists`,label:`📋 Lists`,selector:`ul, ol, dl, [role="list"]`,desc:`Bullet points, numbered lists, and definition lists`},{value:`prices`,label:`💰 Prices & Products`,selector:`[class*="price"], [data-price], .product-card, .product-title`,desc:`Product names, prices, and e-commerce data`},{value:`full_page`,label:`📜 Full Page Text`,selector:`body`,desc:`Everything visible on the page`},{value:`custom`,label:`⚙️ Custom Selector`,selector:``,desc:`Write your own CSS selector`}],r=f.selector_preset||n.find(e=>e.selector===f.selector)?.value||(f.selector?`custom`:``),i=f.show_advanced_selector||r===`custom`,a=n.find(e=>e.value===r),o=n=>{t(e.id,{...e.data,config:{...f,...n}})};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`What to Extract`}),(0,J.jsxs)(`select`,{value:r,onChange:e=>{let t=n.find(t=>t.value===e.target.value);t&&t.value!==`custom`?o({selector:t.selector,selector_preset:t.value,show_advanced_selector:!1}):o({selector_preset:`custom`,show_advanced_selector:!0})},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:`— Choose what to extract —`}),n.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),a&&r!==`custom`&&(0,J.jsx)(`p`,{className:`text-[8px] text-[#06b6d4]/70`,children:a.desc})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Describe What You Need`}),(0,J.jsx)(`textarea`,{value:f.extract_hint||``,onChange:e=>y(`extract_hint`,e.target.value),rows:2,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none resize-y min-h-[40px]`,placeholder:`e.g. "Get all article titles and their links" or "Find product prices"`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Optional — helps the AI understand what to look for in the extracted content`})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>y(`show_advanced_selector`,!i),className:`flex items-center gap-1.5 text-[8px] font-bold text-[#555] hover:text-[#7a8899] uppercase tracking-widest transition-colors cursor-pointer`,children:[(0,J.jsx)(`span`,{className:`transition-transform`,style:{transform:i?`rotate(90deg)`:`rotate(0deg)`},children:`▶`}),`Advanced: CSS Selector`]}),i&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`input`,{type:`text`,value:f.selector||``,onChange:e=>{o({selector:e.target.value,selector_preset:`custom`})},className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#06b6d4] font-mono focus:border-[#06b6d4] transition-colors outline-none`,placeholder:`e.g., .main-content, #article, table`}),(0,J.jsx)(`p`,{className:`text-[8px] text-[#555]`,children:`Raw CSS selector — for power users who know the page structure`})]})]})})(),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Session Name`}),(0,J.jsx)(`input`,{type:`text`,value:f.session_name||`flow_browser`,onChange:e=>y(`session_name`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none`,placeholder:`flow_browser`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Browser Mode`}),(0,J.jsxs)(`select`,{value:f.browser_mode||`headless`,onChange:e=>y(`browser_mode`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`headless`,children:`Headless`}),(0,J.jsx)(`option`,{value:`visible`,children:`Visible`})]})]}),f.action===`extract_content`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Extract Type`}),(0,J.jsxs)(`select`,{value:f.extract_type||`text`,onChange:e=>y(`extract_type`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`text`,children:`Text`}),(0,J.jsx)(`option`,{value:`html`,children:`HTML`}),(0,J.jsx)(`option`,{value:`inner_text`,children:`Inner Text`})]})]}),f.action===`execute_js`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`JavaScript`}),(0,J.jsx)(`textarea`,{value:f.script||``,onChange:e=>y(`script`,e.target.value),rows:4,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-[10px] text-[#06b6d4] font-mono focus:border-[#06b6d4] transition-colors outline-none resize-none`,placeholder:`document.title`})]}),f.action===`wait_for`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Timeout (ms)`}),(0,J.jsx)(`input`,{type:`number`,value:f.timeout||1e4,onChange:e=>y(`timeout`,parseInt(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#06b6d4] transition-colors outline-none`})]}),(0,J.jsx)(`div`,{className:`p-2.5 bg-[#06b6d4]/5 border border-[#06b6d4]/20 rounded-lg`,children:(0,J.jsxs)(`p`,{className:`text-[8px] text-[#06b6d4]/80`,children:[(0,J.jsx)(`strong`,{children:`Mado 窓`}),` — Browser actions are governed by the Torii security posture. Domain allowlists and session limits apply.`]})})]}),c===`email_send`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`To Address`}),(0,J.jsx)(`input`,{type:`text`,value:f.to_address||``,onChange:e=>y(`to_address`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`recipient@example.com`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`CC Address`}),(0,J.jsx)(`input`,{type:`text`,value:f.cc_address||``,onChange:e=>y(`cc_address`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`cc@example.com`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`BCC Address`}),(0,J.jsx)(`input`,{type:`text`,value:f.bcc_address||``,onChange:e=>y(`bcc_address`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`bcc@example.com`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Subject`}),(0,J.jsx)(`input`,{type:`text`,value:f.subject||``,onChange:e=>y(`subject`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none`,placeholder:`Email subject line...`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Body Template`}),(0,J.jsx)(`textarea`,{value:f.body_template||``,onChange:e=>y(`body_template`,e.target.value),rows:4,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#e879a8] transition-colors outline-none resize-none`,placeholder:`Leave empty to use predecessor output as body. Use {{context}} to inject predecessor output into a template.`})]}),(0,J.jsx)(`div`,{className:`p-2.5 bg-[#e879a8]/5 border border-[#e879a8]/20 rounded-lg`,children:(0,J.jsxs)(`p`,{className:`text-[8px] text-[#e879a8]/80`,children:[(0,J.jsx)(`strong`,{children:`Mail ✉`}),` — Sends via the SMTP account configured in the Mail page. Requires `,(0,J.jsx)(`code`,{className:`text-[#e879a8]`,children:`perm_send_mail`}),` to be enabled.`]})})]}),c===`channel_send`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Channel`}),(0,J.jsxs)(`select`,{value:f.channel||`both`,onChange:e=>y(`channel`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,children:[(0,J.jsx)(`option`,{value:`both`,children:`Telegram and Teams`}),(0,J.jsx)(`option`,{value:`telegram`,children:`Telegram`}),(0,J.jsx)(`option`,{value:`teams`,children:`Microsoft Teams`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Message Template`}),(0,J.jsx)(`textarea`,{value:f.message_template||``,onChange:e=>y(`message_template`,e.target.value),rows:4,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none resize-none`,placeholder:`Leave empty to send the predecessor output, or use {{context}} inside a message.`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Telegram Chat IDs (optional)`}),(0,J.jsx)(`input`,{type:`text`,value:(f.telegram_chat_ids||[]).join(`, `),onChange:e=>y(`telegram_chat_ids`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,placeholder:`Uses configured allowed chats when empty`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Telegram Topic Thread ID (optional)`}),(0,J.jsx)(`input`,{type:`number`,min:`1`,step:`1`,value:f.message_thread_id??``,onChange:e=>y(`message_thread_id`,e.target.value===``?null:Number(e.target.value)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,placeholder:`For example, 22 for the News topic`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Teams Conversation IDs (optional)`}),(0,J.jsx)(`input`,{type:`text`,value:(f.teams_conversation_ids||[]).join(`, `),onChange:e=>y(`teams_conversation_ids`,e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#38bdf8] transition-colors outline-none`,placeholder:`Uses notification routes or known conversations when empty`})]})]}),c===`workspace`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Action`}),(0,J.jsxs)(`select`,{value:f.action||`read_file`,onChange:e=>y(`action`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,children:[(0,J.jsx)(`option`,{value:`read_file`,children:`Read File`}),(0,J.jsx)(`option`,{value:`write_file`,children:`Write File`}),(0,J.jsx)(`option`,{value:`list_files`,children:`List Files`}),(0,J.jsx)(`option`,{value:`mkdir`,children:`Create Directory`}),(0,J.jsx)(`option`,{value:`delete`,children:`Delete`}),(0,J.jsx)(`option`,{value:`copy`,children:`Copy`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Path`}),(0,J.jsx)(`input`,{type:`text`,value:f.path||``,onChange:e=>y(`path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,placeholder:`Input/myfile.txt (relative to workspace)`})]}),f.action===`copy`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Source Path`}),(0,J.jsx)(`input`,{type:`text`,value:f.source_path||``,onChange:e=>y(`source_path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,placeholder:`Input/source.txt`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Destination Path`}),(0,J.jsx)(`input`,{type:`text`,value:f.dest_path||``,onChange:e=>y(`dest_path`,e.target.value),className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none`,placeholder:`Output/dest.txt`})]})]}),f.action===`write_file`&&(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[9px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Content Template`}),(0,J.jsx)(`textarea`,{value:f.content_template||``,onChange:e=>y(`content_template`,e.target.value),rows:3,className:`w-full bg-[#0a0e1a] border border-[#1a2040] rounded-lg p-2 text-xs text-[#c8d0d8] focus:border-[#f59e0b] transition-colors outline-none resize-none`,placeholder:`Leave empty to write predecessor output. Use {{context}} for predecessor data.`})]}),(0,J.jsx)(`div`,{className:`p-2.5 bg-[#f59e0b]/5 border border-[#f59e0b]/20 rounded-lg`,children:(0,J.jsxs)(`p`,{className:`text-[8px] text-[#f59e0b]/80`,children:[(0,J.jsx)(`strong`,{children:`Workspace`}),` — All paths are relative to the agent workspace folder. Governed by the Torii security posture.`]})})]}),c===`office`&&(0,J.jsx)(_p,{config:f,updateConfig:y})]})]})}function xp({flow:e,onBack:t,onFlowUpdate:n,agents:r,routingProfiles:i,availableFlows:o}){let u=$l(),d=(0,q.useRef)(null),f=(0,q.useMemo)(()=>(e.nodes||[]).map(e=>({id:e.id,type:e.node_type,position:{x:e.position_x,y:e.position_y},data:{label:e.label,config:e.config}})),[e.id]),p=(0,q.useMemo)(()=>(e.edges||[]).map(e=>({id:e.id,source:e.source_node_id,target:e.target_node_id,sourceHandle:e.source_handle,targetHandle:e.target_handle,type:`custom`,data:{label:e.label,edge_type:e.edge_type},markerEnd:{type:lo.ArrowClosed,color:`#4a8cc7`,width:16,height:16}})),[e.id]),[m,h,_]=rf(f),[v,y,b]=af(p),[x,S]=(0,q.useState)(null),[w,T]=(0,q.useState)(!1),[O,A]=(0,q.useState)(!1),[j,M]=(0,q.useState)(e.name),[P,F]=(0,q.useState)(!1),[I,L]=(0,q.useState)(e.status),[z,te]=(0,q.useState)(!1);(0,q.useEffect)(()=>L(e.status),[e.id,e.status]),(0,q.useEffect)(()=>{$(`agent_flow.canvas.mount`,{flowId:e.id,flowName:e.name,nodes:e.nodes?.length||0,edges:e.edges?.length||0,agents:r.length,routingProfiles:i.length})},[e.id]);let[B,U]=(0,q.useState)(null),[W,ne]=(0,q.useState)(null),[re,ie]=(0,q.useState)({}),[ae,oe]=(0,q.useState)(null),[se,le]=(0,q.useState)(!1),[de,fe]=(0,q.useState)(!1),[pe,me]=(0,q.useState)([]),[he,Y]=(0,q.useState)(null),[X,_e]=(0,q.useState)(null),[ve,ye]=(0,q.useState)(null),[be,xe]=(0,q.useState)(!1),[Se,Ce]=(0,q.useState)(null),we=(0,q.useRef)(null),Te=(0,q.useCallback)(async(e,t)=>{Y(e),xe(!0);try{let[t,n]=await Promise.all([K.get(`/api/v1/agent-flows/runs/${e}`),K.get(`/api/v1/agent-flows/runs/${e}/tree`)]),r=t.data?.data||null;return _e(r),ye(n.data?.data||null),r}catch(e){return console.error(e),_e(t?{status:`completed`,trigger_type:`manual`,result_summary:{[t.label]:t.content}}:null),ye(null),null}finally{xe(!1)}},[]),Ee=(0,q.useCallback)(e=>{if(e.runId){Te(e.runId,{label:e.label,content:e.content});return}Y(`node-output`),_e({status:`completed`,trigger_type:`manual`,result_summary:{[e.label]:e.content}}),ye(null)},[Te]),De=(0,q.useMemo)(()=>({view:Ee,runId:ae,nodeStates:re}),[ae,Ee,re]),Oe=(0,q.useCallback)(async()=>{try{let t=await K.get(`/api/v1/agent-flows/${e.id}/runs?limit=20`);me(t.data?.data||[])}catch{}},[e.id]),ke=(0,q.useCallback)(t=>{let n={...t.node_states||{}};t.status===`completed`&&(e.nodes||[]).forEach(e=>{if(e.node_type!==`output`)return;let r=e.label||``,i=t.result_summary?.[r],a=n[e.id]||{};n[e.id]={...a,status:`completed`,output:a.output??i??`The run completed, but no output text was returned.`}}),ne(t.status),ie(n),oe(t.id||null),h(e=>e.map(e=>{let r=n[e.id],i=typeof e.data?.label==`string`?e.data.label:``,a=e.type===`output`?t.result_summary?.[i]:void 0,o=r?.output??a??null;return{...e,className:r?.status===`running`?`agent-flow-node-running`:void 0,style:{...e.style||{},"--agent-flow-active-color":cp[e.type||``]||`#d4a017`,"--agent-flow-glow-strong":`${cp[e.type||``]||`#d4a017`}66`,"--agent-flow-glow-medium":`${cp[e.type||``]||`#d4a017`}3d`,"--agent-flow-glow-soft":`${cp[e.type||``]||`#d4a017`}1a`,"--agent-flow-glow-faint":`${cp[e.type||``]||`#d4a017`}12`},data:{...e.data,execution_status:r?.status||null,execution_output:o,execution_run_id:t.id||null}}}))},[e.nodes,h]);(0,q.useEffect)(()=>{(async()=>{try{let t=(await K.get(`/api/v1/agent-flows/${e.id}/runs?limit=1`)).data?.data?.[0];if(t){let e=(await K.get(`/api/v1/agent-flows/runs/${t.id}`)).data?.data;e&&ke(e),(t.status===`pending`||t.status===`running`)&&(U(t.id),le(!0))}}catch{}})()},[e.id,ke]),(0,q.useEffect)(()=>{A(!0)},[m,v]);let Ae=(0,q.useCallback)(e=>{let t=m.find(t=>t.id===e);$(`agent_flow.inspector.open_request`,{nodeId:e,foundNode:!!t,type:t?.type,label:t?.data?.label,totalNodes:m.length}),S(e)},[m]),je=(0,q.useMemo)(()=>m.map(e=>({...e,data:{...e.data,onOpenInspector:Ae}})),[m,Ae]);(0,q.useEffect)(()=>{if(!B)return;let e=async()=>{try{let e=(await K.get(`/api/v1/agent-flows/runs/${B}`)).data?.data;e&&(ke(e),[`completed`,`failed`,`cancelled`].includes(e.status)&&(U(null),le(!1),Oe(),we.current&&clearInterval(we.current)))}catch{}};return e(),we.current=setInterval(e,1500),()=>{we.current&&clearInterval(we.current)}},[B,Oe,ke]);let Me=(0,q.useCallback)(e=>{y(t=>vs({...e,type:`custom`,data:{label:null,edge_type:`default`},markerEnd:{type:lo.ArrowClosed,color:`#4a8cc7`,width:16,height:16}},t))},[y]),Ne=(0,q.useCallback)((e,t)=>{$(`agent_flow.reactflow.on_node_click`,{nodeId:t.id,type:t.type,label:t.data?.label}),Ae(t.id)},[Ae]),Pe=(0,q.useCallback)(e=>{let t=e.target,n=t instanceof HTMLElement?t.closest(`.react-flow__node, [title="Node Properties"], [aria-label^="Open properties"]`):null;$(`agent_flow.reactflow.on_pane_click`,{selectedNodeId:x,ignoredBecauseNodeClick:!!n}),!n&&S(null)},[x]),Fe=(0,q.useCallback)(({nodes:e})=>{e[0]&&($(`agent_flow.reactflow.selection_change`,{nodeId:e[0].id,type:e[0].type,label:e[0].data?.label}),S(e[0].id))},[]),Ie=(0,q.useCallback)((e,t)=>{h(n=>n.map(n=>n.id===e?{...n,data:t}:n))},[h]),Le=(0,q.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},[]),Re=(0,q.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/agentflow-node-type`);if(!t)return;let n=u.screenToFlowPosition({x:e.clientX,y:e.clientY}),r=sp.find(e=>e.type===t),i=t===`stack_orchestrator`?{mode:`selected_stack`,objective:``,success_criteria:[],allowed_tools:[],model_routing_profile:`balanced`,max_runtime_minutes:60,max_iterations:50,max_retry_attempts_per_step:2,checkpoint_frequency:`after_each_step`,context_compaction:!0,verification_required:!0,approval_policy:`inherited`,artifact_policy:`retain_all`,failure_policy:`pause`}:{},a={id:crypto.randomUUID(),type:t,position:n,data:{label:r?.label||`New Node`,config:i}};h(e=>[...e,a])},[u,h]),ze=(0,q.useCallback)(()=>{h(e=>e.filter(e=>!e.selected)),y(e=>e.filter(e=>!e.selected)),S(null)},[h,y]),Be=(0,q.useCallback)(async()=>{T(!0);try{j!==e.name&&await K.patch(`/api/v1/agent-flows/${e.id}`,{name:j});let t=u.getViewport(),n={viewport:{x:t.x,y:t.y,zoom:t.zoom},nodes:m.map(e=>({id:e.id,node_type:e.type||`samurai`,label:e.data?.label||`Untitled`,position_x:e.position.x,position_y:e.position.y,config:e.data?.config||{}})),edges:v.map(e=>({id:e.id,source_node_id:e.source,target_node_id:e.target,source_handle:e.sourceHandle||null,target_handle:e.targetHandle||null,label:e.data?.label||null,edge_type:e.data?.edge_type||`default`,config:e.data?.config||{}}))};return await K.put(`/api/v1/agent-flows/${e.id}/graph`,n),A(!1),!0}catch(e){return console.error(`Failed to save flow:`,e),window.alert(e?.response?.data?.detail||`Could not save this AgentFlow.`),!1}finally{T(!1)}},[e.id,e.name,j,m,v,u]),Ve=(0,q.useCallback)(async()=>{if(z||O&&!await Be())return;let t=I===`active`?`paused`:`active`;te(!0);try{let r=await K.post(`/api/v1/agent-flows/${e.id}/${t===`active`?`activate`:`pause`}`);L(r.data?.data?.status||t),n()}catch(e){window.alert(e?.response?.data?.detail||`Could not set this AgentFlow to ${t}.`)}finally{te(!1)}},[z,O,e.id,I,Be,n]),He=(0,q.useCallback)(async()=>{if(O&&!await Be())return;let t=window.prompt(`Template name`,j);if(!t)return;let n=window.prompt(`Template category`,`My Templates`)||`My Templates`;try{await K.post(`/api/v1/agent-flows/${e.id}/save-as-template`,{name:t,category:n}),window.alert(`Reusable template “${t}” saved.`)}catch(e){window.alert(e?.response?.data?.detail||`Could not save this template.`)}},[O,e.id,j,Be]),Ue=(0,q.useCallback)(async()=>{if(!se&&!(O&&!await Be())){le(!0),ne(`pending`),oe(null),h(e=>e.map(e=>({...e,className:void 0,data:{...e.data,execution_status:null,execution_output:null,execution_run_id:null}})));try{let t=(await K.post(`/api/v1/agent-flows/${e.id}/run`)).data?.data?.run_id;t&&U(t)}catch(e){console.error(`Failed to start flow run:`,e),le(!1),ne(null)}}},[se,O,Be,e.id,h]),We=(0,q.useCallback)(async()=>{if(B)try{await K.post(`/api/v1/agent-flows/runs/${B}/cancel`),U(null),le(!1),ne(`cancelled`)}catch{}},[B]);(0,q.useEffect)(()=>{if(!de)return;Oe();let e=window.setInterval(()=>{Oe()},3e3);return()=>window.clearInterval(e)},[Oe,de]);let Ge=(0,q.useCallback)(async e=>{if(window.confirm(`Delete this run and its generated Output file?`)){Ce(e);try{await K.delete(`/api/v1/agent-flows/runs/${e}`),me(t=>t.filter(t=>t.id!==e)),(ae===e||m.some(t=>t.data?.execution_run_id===e))&&(ne(null),ie({}),oe(null),h(e=>e.map(e=>({...e,className:void 0,data:{...e.data,execution_status:null,execution_output:null,execution_run_id:null}})))),he===e&&(Y(null),_e(null),ye(null))}catch(e){console.error(`Failed to delete flow run:`,e)}finally{Ce(null)}}},[ae,m,he,h]),Ke=(0,q.useCallback)(async e=>{let t=await Te(e);t&&ke(t)},[ke,Te]);(0,q.useEffect)(()=>{let e=e=>{if((e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),Be()),e.key===`Delete`||e.key===`Backspace`){if(document.activeElement?.tagName===`INPUT`||document.activeElement?.tagName===`TEXTAREA`||document.activeElement?.tagName===`SELECT`)return;ze()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Be,ze]);let qe=x&&m.find(e=>e.id===x)||null;return(0,q.useEffect)(()=>{$(`agent_flow.inspector.state`,{selectedNodeId:x,inspectorVisible:!!qe,nodeType:qe?.type,nodeLabel:qe?.data?.label,totalNodes:m.length})},[x,qe,m.length]),(0,J.jsxs)(`div`,{"data-testid":`agent-flow-editor`,"data-flow-id":e.id,className:`relative flex h-[calc(100vh-120px)] rounded-lg overflow-hidden border border-[#1a2040] min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col bg-[#060810]`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2 bg-[#0a0e1a] border-b border-[#1a2040] shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,J.jsx)(`button`,{onClick:t,className:`p-1.5 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,J.jsx)(a,{className:`w-4 h-4`})}),(0,J.jsx)(`div`,{className:`h-5 w-px bg-[#1a2040]`}),P?(0,J.jsx)(`input`,{autoFocus:!0,type:`text`,value:j,onChange:e=>M(e.target.value),onBlur:()=>F(!1),onKeyDown:e=>e.key===`Enter`&&F(!1),className:`bg-[#0e1225] border border-[#d4a017]/40 rounded px-2 py-1 text-sm font-bold text-[#d4a017] outline-none`}):(0,J.jsx)(`button`,{onClick:()=>F(!0),className:`max-w-[min(28rem,60vw)] truncate text-sm font-bold text-[#d4a017] hover:text-[#d4a017]/80 transition-colors`,children:j}),(0,J.jsx)(`span`,{className:H(`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border`,I===`active`?`text-green-400 bg-green-500/10 border-green-500/20`:I===`paused`?`text-[#4a8cc7] bg-[#4a8cc7]/10 border-[#4a8cc7]/20`:`text-[#7a8899] bg-[#7a8899]/10 border-[#7a8899]/20`),children:I}),O&&(0,J.jsx)(`span`,{className:`text-[8px] text-[#d4a017]/60 font-bold uppercase tracking-widest animate-pulse`,children:`Unsaved`})]}),(0,J.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-1 mr-2`,children:sp.map(e=>{let t=e.icon;return(0,J.jsxs)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(`application/agentflow-node-type`,e.type),t.dataTransfer.effectAllowed=`move`},className:`flex shrink-0 items-center gap-1.5 px-2 py-1.5 bg-[#0e1225] border border-[#1a2040] rounded-md cursor-grab active:cursor-grabbing hover:border-[#2a3060] transition-colors group`,title:`Drag to add ${e.label}`,children:[(0,J.jsx)(t,{className:`w-3 h-3`,style:{color:e.color}}),(0,J.jsx)(`span`,{className:`hidden text-[9px] font-bold text-[#7a8899] group-hover:text-[#c8d0d8] lg:inline`,children:e.label})]},e.type)})}),(0,J.jsx)(`div`,{className:`h-5 w-px bg-[#1a2040]`}),(0,J.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":I===`active`,onClick:Ve,disabled:z||w,className:H(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider border transition-all`,I===`active`?`bg-green-500/15 text-green-400 border-green-500/30 hover:bg-green-500/25`:`bg-[#0e1225] text-[#7a8899] border-[#2a3060] hover:text-[#c8d0d8]`,(z||w)&&`opacity-60 cursor-wait`),title:I===`active`?`Pause this AgentFlow and disable its schedule`:`Activate this AgentFlow`,children:[z?(0,J.jsx)(V,{className:`w-3 h-3 animate-spin`}):(0,J.jsx)(E,{className:`w-3 h-3`}),I===`active`?`Active`:`Activate`]}),(0,J.jsxs)(`button`,{onClick:Be,disabled:w,className:H(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all`,w?`bg-[#7a8899]/20 text-[#7a8899] cursor-wait`:O?`bg-[#d4a017] text-black hover:bg-[#d4a017]/90 shadow-[0_0_12px_rgba(212,160,23,0.2)]`:`bg-[#0e1225] text-[#7a8899] border border-[#1a2040] hover:border-[#2a3060]`),children:[w?(0,J.jsx)(V,{className:`w-3 h-3 animate-spin`}):(0,J.jsx)(k,{className:`w-3 h-3`}),w?`Saving...`:`Save`]}),(0,J.jsxs)(`button`,{onClick:He,disabled:w,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#8b5cf6]/15 text-[#c084fc] border border-[#8b5cf6]/30 hover:bg-[#8b5cf6]/25 transition-all`,title:`Save this AgentFlow for future reuse`,children:[(0,J.jsx)(ce,{className:`w-3 h-3`}),` Template`]}),(0,J.jsx)(`div`,{className:`h-5 w-px bg-[#1a2040]`}),se?(0,J.jsxs)(`button`,{onClick:We,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#ef4444]/20 text-[#ef4444] border border-[#ef4444]/30 hover:bg-[#ef4444]/30 transition-all`,children:[(0,J.jsx)(ue,{className:`w-3 h-3`}),`Cancel`]}):(0,J.jsxs)(`button`,{onClick:Ue,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider bg-[#22c55e]/20 text-[#22c55e] border border-[#22c55e]/30 hover:bg-[#22c55e]/30 transition-all shadow-[0_0_10px_rgba(34,197,94,0.1)]`,children:[(0,J.jsx)(C,{className:`w-3 h-3`}),`Run`]}),(0,J.jsxs)(`button`,{onClick:()=>{fe(!de),de||Oe()},className:H(`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[10px] font-bold uppercase tracking-wider transition-all border`,de?`bg-[#4a8cc7]/20 text-[#4a8cc7] border-[#4a8cc7]/30`:`bg-[#0e1225] text-[#7a8899] border-[#1a2040] hover:border-[#2a3060]`),children:[(0,J.jsx)(R,{className:`w-3 h-3`}),`History`]})]})]}),W&&(0,J.jsxs)(`div`,{className:H(`flex items-center justify-between px-4 py-2 border-b text-[10px] font-bold uppercase tracking-wider`,W===`running`?`bg-[#4a8cc7]/10 border-[#4a8cc7]/20 text-[#4a8cc7]`:W===`completed`?`bg-[#22c55e]/10 border-[#22c55e]/20 text-[#22c55e]`:W===`failed`?`bg-[#ef4444]/10 border-[#ef4444]/20 text-[#ef4444]`:W===`cancelled`?`bg-[#7a8899]/10 border-[#7a8899]/20 text-[#7a8899]`:`bg-[#d4a017]/10 border-[#d4a017]/20 text-[#d4a017]`),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[W===`running`&&(0,J.jsx)(V,{className:`w-3 h-3 animate-spin`}),W===`completed`&&(0,J.jsx)(s,{className:`w-3 h-3`}),W===`failed`&&(0,J.jsx)(c,{className:`w-3 h-3`}),W===`pending`&&(0,J.jsx)(l,{className:`w-3 h-3`}),(0,J.jsxs)(`span`,{children:[`Flow `,W]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Object.values(re).length>0&&(0,J.jsxs)(`span`,{className:`text-[9px] opacity-70`,children:[Object.values(re).filter(e=>e.status===`completed`).length,`/`,Object.values(re).length,` nodes completed`]}),W!==`running`&&(0,J.jsx)(`button`,{onClick:()=>{ne(null),ie({}),oe(null),h(e=>e.map(e=>({...e,className:void 0,data:{...e.data,execution_status:null,execution_output:null,execution_run_id:null}})))},className:`text-current opacity-50 hover:opacity-100 transition-opacity`,children:(0,J.jsx)(ee,{className:`w-3 h-3`})})]})]}),(0,J.jsx)(`div`,{ref:d,className:`flex-1 min-w-0`,children:(0,J.jsx)(ip.Provider,{value:De,children:(0,J.jsxs)(ef,{nodes:je,edges:v,onNodesChange:_,onEdgesChange:b,onConnect:Me,onNodeClick:Ne,onNodeDoubleClick:Ne,onPaneClick:Pe,onSelectionChange:Fe,onDrop:Re,onDragOver:Le,nodeTypes:pp,edgeTypes:hp,defaultViewport:e.viewport,fitView:!!e.nodes?.length,snapToGrid:!0,snapGrid:[16,16],nodeDragThreshold:5,selectNodesOnDrag:!1,deleteKeyCode:null,proOptions:{hideAttribution:!0},style:{background:`#060810`},children:[(0,J.jsx)(xf,{position:`bottom-left`,style:{display:`flex`,gap:2},className:`!bg-[#0e1225] !border !border-[#1a2040] !rounded-lg !shadow-lg [&>button]:!bg-[#0a0e1a] [&>button]:!border-[#1a2040] [&>button]:!text-[#7a8899] [&>button:hover]:!text-[#d4a017] [&>button]:!rounded [&>button]:!w-7 [&>button]:!h-7`}),(0,J.jsx)(If,{position:`bottom-right`,nodeColor:e=>cp[e.type||`samurai`]||`#d4a017`,maskColor:`rgba(6, 8, 16, 0.85)`,className:`!bg-[#0a0e1a] !border !border-[#1a2040] !rounded-lg`,style:{width:160,height:100}}),(0,J.jsx)(ff,{variant:cf.Dots,gap:20,size:1,color:`#1a204040`}),m.length===0&&(0,J.jsx)(ml,{position:`top-center`,className:`mt-24`,children:(0,J.jsxs)(`div`,{className:`text-center space-y-3 animate-in fade-in duration-700`,children:[(0,J.jsx)(`div`,{className:`w-16 h-16 rounded-2xl bg-[#0e1225] border border-[#1a2040] flex items-center justify-center mx-auto`,children:(0,J.jsx)(g,{className:`w-7 h-7 text-[#4a8cc7]/40`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-sm font-bold text-[#7a8899]`,children:`Empty Canvas`}),(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899]/60 mt-1`,children:`Drag cards from the toolbar above to build your workflow`})]})]})})]})})})]}),qe&&(0,J.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 z-[60] w-[min(420px,calc(100vw-320px))] min-w-[320px] max-w-[420px] shadow-[-20px_0_40px_rgba(0,0,0,0.35)]`,children:(0,J.jsx)(bp,{node:qe,onUpdate:Ie,onClose:()=>S(null),agents:r,routingProfiles:i,flowId:e.id,flows:o})}),(0,ge.createPortal)((0,J.jsxs)(J.Fragment,{children:[de&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{style:{position:`fixed`,inset:0,zIndex:99998,backgroundColor:`rgba(0,0,0,0.2)`,pointerEvents:`auto`},onClick:()=>fe(!1)}),(0,J.jsxs)(`div`,{style:{position:`fixed`,top:0,right:0,width:320,height:`100vh`,zIndex:99999,backgroundColor:`#0a0e1a`,borderLeft:`1px solid #1a2040`,display:`flex`,flexDirection:`column`,boxShadow:`-8px 0 32px rgba(0,0,0,0.5)`,pointerEvents:`auto`},children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-[#1a2040] shrink-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(R,{className:`w-4 h-4 text-[#4a8cc7] shrink-0`}),(0,J.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8] uppercase tracking-wider`,children:`Run History`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,J.jsx)(`button`,{onClick:Oe,className:`p-1.5 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,title:`Refresh history`,children:(0,J.jsx)(D,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(`button`,{onClick:()=>fe(!1),className:`p-1.5 hover:bg-[#ef4444]/20 text-[#7a8899] hover:text-[#ef4444] rounded-lg transition-colors`,title:`Close history`,children:(0,J.jsx)(ee,{className:`w-4 h-4`})})]})]}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-3 space-y-2`,children:[pe.length===0&&(0,J.jsxs)(`div`,{className:`text-center py-8`,children:[(0,J.jsx)(l,{className:`w-8 h-8 text-[#7a8899]/30 mx-auto mb-2`}),(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899]/50`,children:`No runs yet`})]}),pe.map(e=>(0,J.jsxs)(`div`,{onClick:()=>Ke(e.id),className:`p-3 bg-[#0e1225] border border-[#1a2040] rounded-lg hover:border-[#2a3060] transition-colors overflow-hidden cursor-pointer`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2 gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[e.status===`completed`&&(0,J.jsx)(s,{className:`w-3.5 h-3.5 text-[#22c55e] shrink-0`}),e.status===`failed`&&(0,J.jsx)(c,{className:`w-3.5 h-3.5 text-[#ef4444] shrink-0`}),e.status===`running`&&(0,J.jsx)(V,{className:`w-3.5 h-3.5 text-[#4a8cc7] animate-spin shrink-0`}),e.status===`cancelled`&&(0,J.jsx)(ue,{className:`w-3.5 h-3.5 text-[#7a8899] shrink-0`}),e.status===`pending`&&(0,J.jsx)(l,{className:`w-3.5 h-3.5 text-[#d4a017] shrink-0`}),(0,J.jsx)(`span`,{className:H(`text-[10px] font-bold uppercase`,e.status===`completed`?`text-[#22c55e]`:e.status===`failed`?`text-[#ef4444]`:e.status===`running`?`text-[#4a8cc7]`:`text-[#7a8899]`),children:e.status})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,J.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest text-[#7a8899]/60 bg-[#7a8899]/10 px-1.5 py-0.5 rounded truncate max-w-[80px]`,children:e.trigger_type}),(0,J.jsx)(`button`,{type:`button`,title:`Delete run and Output file`,disabled:Se===e.id||e.status===`running`||e.status===`pending`,onClick:t=>{t.stopPropagation(),Ge(e.id)},className:`p-1 rounded text-[#7a8899]/60 hover:text-[#ef4444] hover:bg-[#ef4444]/10 disabled:opacity-30 disabled:pointer-events-none transition-colors`,children:Se===e.id?(0,J.jsx)(V,{className:`w-3 h-3 animate-spin`}):(0,J.jsx)(N,{className:`w-3 h-3`})})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] text-[#7a8899]`,children:[(0,J.jsx)(`span`,{children:op(e.created_at)}),e.started_at&&e.completed_at&&(0,J.jsxs)(`span`,{className:`text-[#d4a017]/70`,children:[((ap(e.completed_at).getTime()-ap(e.started_at).getTime())/1e3).toFixed(1),`s`]})]}),e.error_message&&(0,J.jsx)(`p`,{className:`mt-1.5 text-[9px] text-[#ef4444]/80 line-clamp-2 bg-[#ef4444]/5 rounded p-1.5`,children:e.error_message})]},e.id))]})]})]}),he&&(0,J.jsxs)(`div`,{className:`fixed inset-0 flex items-center justify-center p-4 pointer-events-auto`,style:{zIndex:1e5},children:[(0,J.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>Y(null)}),(0,J.jsxs)(`div`,{className:`relative w-full max-w-4xl max-h-[85vh] bg-[#0a0e1a] border border-[#1a2040] rounded-xl shadow-2xl flex flex-col overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-[#1a2040] bg-[#0e1225]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-bold text-[#c8d0d8] uppercase tracking-wider`,children:`Run Details`}),be&&(0,J.jsx)(V,{className:`w-4 h-4 text-[#4a8cc7] animate-spin`})]}),(0,J.jsx)(`button`,{onClick:()=>Y(null),className:`p-2 hover:bg-[#1a2040] text-[#7a8899] hover:text-[#c8d0d8] rounded-lg transition-colors`,children:(0,J.jsx)(ee,{className:`w-5 h-5`})})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto p-6 space-y-6`,children:X?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-[11px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[(0,J.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Status: `,(0,J.jsx)(`span`,{className:H(X.status===`completed`?`text-[#22c55e]`:X.status===`failed`?`text-[#ef4444]`:`text-[#4a8cc7]`),children:X.status})]}),(0,J.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Trigger: `,X.trigger_type]}),(0,J.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Depth: `,X.run_depth||0]}),X.flow_version&&(0,J.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Flow v`,X.flow_version]}),X.started_at&&X.completed_at&&(0,J.jsxs)(`span`,{className:`bg-[#1a2040] px-2.5 py-1 rounded`,children:[`Duration: `,((ap(X.completed_at).getTime()-ap(X.started_at).getTime())/1e3).toFixed(2),`s`]})]}),X.error_message&&(0,J.jsxs)(`div`,{className:`p-4 rounded-lg border border-[#ef4444]/20 bg-[#ef4444]/5`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-bold text-[#ef4444] uppercase tracking-wider mb-2`,children:`Error Details`}),(0,J.jsx)(`p`,{className:`text-sm text-[#ef4444]/90 whitespace-pre-wrap font-mono`,children:X.error_message})]}),ve&&(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[#1a2040] pb-2`,children:[(0,J.jsx)(G,{className:`w-4 h-4 text-[#8b5cf6]`}),(0,J.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8] uppercase tracking-wider`,children:`Flow Stacking Execution Tree`})]}),(0,J.jsx)(dp,{node:ve})]}),X.governance_context&&Object.keys(X.governance_context).length>0&&(0,J.jsxs)(`details`,{className:`rounded-lg border border-[#1a2040] bg-[#0e1225] p-3`,children:[(0,J.jsx)(`summary`,{className:`cursor-pointer text-[10px] font-bold uppercase tracking-wider text-[#7a8899]`,children:`Inherited governance context`}),(0,J.jsx)(`pre`,{className:`mt-3 overflow-x-auto whitespace-pre-wrap text-[9px] text-[#c8d0d8]`,children:JSON.stringify(X.governance_context,null,2)})]}),X.result_summary&&Object.keys(X.result_summary).length>0?(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h3`,{className:`text-xs font-bold text-[#c8d0d8] uppercase tracking-wider border-b border-[#1a2040] pb-2`,children:`Output Artifacts & Reports`}),Object.entries(X.result_summary).map(([e,t])=>(0,J.jsxs)(`div`,{className:`rounded-lg border border-[#2a3060] bg-[#0e1225] overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`px-4 py-2 bg-[#1a2040]/50 border-b border-[#2a3060]`,children:(0,J.jsx)(`span`,{className:`text-xs font-bold text-[#4a8cc7]`,children:e})}),(0,J.jsx)(`div`,{className:`p-4 text-sm text-[#c8d0d8] leading-relaxed whitespace-pre-wrap overflow-x-auto`,children:String(t)})]},e))]}):(0,J.jsx)(`div`,{className:`py-8 text-center border border-dashed border-[#1a2040] rounded-lg`,children:(0,J.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`No output artifacts generated for this run.`})})]}):!be&&(0,J.jsx)(`div`,{className:`py-12 text-center`,children:(0,J.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:`Could not load run details.`})})})]})]})]}),document.getElementById(`portal-root`))]})}function Sp({flows:e,loading:t,onSelect:n,onCreate:r,onDelete:i,onDuplicate:a,onRefresh:o}){let[s,c]=(0,q.useState)(``),[u,f]=(0,q.useState)(null),p=e.filter(e=>e.name.toLowerCase().includes(s.toLowerCase())),m={draft:`#7a8899`,active:`#22c55e`,paused:`#4a8cc7`,archived:`#7a8899`};return(0,J.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-500`,children:[(0,J.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-4`,children:[{label:`Total Flows`,value:e.length,color:`#d4a017`},{label:`Active`,value:e.filter(e=>e.status===`active`).length,color:`#22c55e`},{label:`Draft`,value:e.filter(e=>e.status===`draft`).length,color:`#7a8899`},{label:`Paused`,value:e.filter(e=>e.status===`paused`).length,color:`#4a8cc7`}].map((e,t)=>(0,J.jsxs)(`div`,{className:`shogun-card !p-4 border-l-2`,style:{borderLeftColor:e.color},children:[(0,J.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-bold text-[#7a8899]`,children:e.label}),(0,J.jsx)(`div`,{className:`text-2xl font-bold text-[#c8d0d8] mt-1`,children:e.value})]},t))}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1 max-w-md`,children:[(0,J.jsx)(A,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#7a8899]`}),(0,J.jsx)(`input`,{type:`text`,placeholder:`Filter workflows...`,value:s,onChange:e=>c(e.target.value),className:`w-full bg-[#0e1225] border border-[#1a2040] rounded-lg pl-10 pr-4 py-2 text-sm text-[#c8d0d8] focus:border-[#4a8cc7] transition-colors outline-none`})]}),(0,J.jsx)(`button`,{onClick:o,className:`p-2.5 bg-[#0e1225] border border-[#1a2040] rounded-lg text-[#7a8899] hover:text-[#d4a017] transition-colors`,children:(0,J.jsx)(D,{className:H(`w-4 h-4`,t&&`animate-spin`)})}),(0,J.jsxs)(`button`,{onClick:r,className:`flex items-center gap-2 bg-[#4a8cc7] hover:bg-[#4a8cc7]/90 text-white font-bold py-2.5 px-5 rounded-lg transition-all shadow-[0_0_20px_rgba(74,140,199,0.15)] text-xs`,children:[(0,J.jsx)(T,{className:`w-4 h-4`}),` NEW FLOW`]})]}),t?(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16`,children:[(0,J.jsx)(V,{className:`w-6 h-6 text-[#d4a017] animate-spin`}),(0,J.jsx)(`span`,{className:`text-[10px] text-[#7a8899] uppercase tracking-widest`,children:`Loading workflows...`})]}):p.length===0?(0,J.jsxs)(`div`,{className:`text-center py-16`,children:[(0,J.jsx)(g,{className:`w-10 h-10 text-[#1a2040] mx-auto mb-3`}),(0,J.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:e.length===0?`No Agent Flows created yet`:`No flows match your search`}),e.length===0&&(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899]/60 mt-1`,children:`Create your first workflow to orchestrate Samurai agents visually`})]}):(0,J.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:p.map(e=>(0,J.jsxs)(`button`,{onClick:()=>n(e.id),className:`shogun-card !p-0 text-left hover:border-[#4a8cc7]/40 transition-all group relative overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`h-0.5`,style:{background:m[e.status]||`#7a8899`}}),(0,J.jsxs)(`div`,{className:`p-5`,children:[(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(`h4`,{className:`text-sm font-bold text-[#c8d0d8] group-hover:text-[#d4a017] transition-colors truncate`,children:e.name}),(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899] mt-1 line-clamp-2`,children:e.description||`No description`})]}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),f(u===e.id?null:e.id)},className:`p-1.5 hover:bg-[#1a2040] rounded-lg text-[#7a8899] hover:text-[#c8d0d8] transition-colors opacity-0 group-hover:opacity-100`,children:(0,J.jsx)(fe,{className:`w-3.5 h-3.5`})}),u===e.id&&(0,J.jsxs)(`div`,{className:`absolute right-0 top-8 z-10 w-36 bg-[#0e1225] border border-[#1a2040] rounded-lg shadow-xl overflow-hidden`,children:[(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),a(e.id),f(null)},className:`w-full flex items-center gap-2 px-3 py-2 text-[10px] font-bold text-[#7a8899] hover:bg-[#1a2040] hover:text-[#c8d0d8] transition-colors`,children:[(0,J.jsx)(d,{className:`w-3 h-3`}),` Duplicate`]}),(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(e.id),f(null)},className:`w-full flex items-center gap-2 px-3 py-2 text-[10px] font-bold text-red-400 hover:bg-red-500/10 transition-colors`,children:[(0,J.jsx)(N,{className:`w-3 h-3`}),` Delete`]})]})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mt-4`,children:[e.flow_type===`stack`&&(0,J.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border text-[#a78bfa] bg-[#8b5cf6]/10 border-[#8b5cf6]/30`,children:`Flow Stack`}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-widest px-2 py-0.5 rounded border`,style:{color:m[e.status],background:`${m[e.status]}10`,borderColor:`${m[e.status]}30`},children:e.status}),(0,J.jsxs)(`span`,{className:`text-[8px] text-[#7a8899] flex items-center gap-1`,children:[(0,J.jsx)(l,{className:`w-2.5 h-2.5`}),e.trigger_type]}),(0,J.jsx)(`span`,{className:`text-[8px] text-[#7a8899]/60 ml-auto`,children:new Date(e.updated_at).toLocaleDateString()})]})]})]},e.id))})]})}var Cp={"Document Processing":`#10b981`,"Data Analysis":`#3b82f6`,"Content Creation":`#f59e0b`,"Email Automation":`#8b5cf6`,"Research & Intelligence":`#ef4444`,"Business Operations":`#06b6d4`,Marketing:`#ec4899`,"Human Resources":`#14b8a6`,"Legal & Compliance":`#6366f1`,"Education & Training":`#f97316`},wp={beginner:{label:`Beginner`,color:`#10b981`},intermediate:{label:`Intermediate`,color:`#f59e0b`},advanced:{label:`Advanced`,color:`#ef4444`}};function Tp({onClose:e,onCreate:t,onCreateFromTemplate:n}){let{ui:r,category:i,difficulty:a,agentFlow:o}=rp(),[s,c]=(0,q.useState)(`templates`),[l,u]=(0,q.useState)([]),[d,f]=(0,q.useState)([]),[p,m]=(0,q.useState)(!0),[h,g]=(0,q.useState)(``),[_,v]=(0,q.useState)(null),[b,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(null),[w,E]=(0,q.useState)(``),[D,O]=(0,q.useState)(``),[k,j]=(0,q.useState)(`manual`);(0,q.useEffect)(()=>{(async()=>{try{let e=(await K.get(`/api/v1/agent-flows/templates`)).data?.data;e&&(u(e.templates||[]),f(e.categories||[]))}catch(e){console.error(`Failed to load templates:`,e);let t=K.isAxiosError(e)?e.response?.data?.detail:``;g(t||`AgentFlow templates could not be loaded. Run Shogun Repair/Update and restart Shogun.`)}finally{m(!1)}})()},[]);let N=(0,q.useMemo)(()=>{let e=l;_&&(e=e.filter(e=>e.category===_));let t=e.map(e=>o(e));if(b.trim()){let e=b.toLowerCase();return t.filter(t=>t.name.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)||t.category.toLowerCase().includes(e))}return t},[l,_,b,o]),P=async e=>{C(e);try{n(e)}catch{C(null)}};return(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-200`,onClick:t=>{t.target===t.currentTarget&&e()},children:(0,J.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a2040] rounded-xl w-full max-w-5xl h-[85vh] shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200 flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`bg-[#0e1225] border-b border-[#1a2040] p-5 flex items-center justify-between shrink-0`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h3`,{className:`text-lg font-bold text-[#d4a017] flex items-center gap-2`,children:[(0,J.jsx)(M,{className:`w-5 h-5`}),r(`create_agent_flow`,`Create Agent Flow`)]}),(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899] uppercase tracking-widest font-bold mt-1`,children:r(`choose_template`,`Choose a template or start from scratch`)})]}),(0,J.jsx)(`button`,{onClick:e,className:`p-2 hover:bg-[#d4a017]/10 text-[#7a8899] hover:text-[#d4a017] rounded-lg transition-colors`,children:(0,J.jsx)(ee,{className:`w-4 h-4`})})]}),(0,J.jsxs)(`div`,{className:`border-b border-[#1a2040] flex gap-0 shrink-0`,children:[(0,J.jsxs)(`button`,{onClick:()=>c(`templates`),className:H(`px-6 py-3 text-sm font-bold transition-all flex items-center gap-2`,s===`templates`?`text-[#d4a017] border-b-2 border-[#d4a017] bg-[#d4a017]/5`:`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`),children:[(0,J.jsx)(y,{className:`w-4 h-4`}),r(`templates`,`Templates`),(0,J.jsx)(`span`,{className:`text-[9px] bg-[#d4a017]/20 text-[#d4a017] px-1.5 py-0.5 rounded-full font-bold`,children:l.length})]}),(0,J.jsxs)(`button`,{onClick:()=>c(`blank`),className:H(`px-6 py-3 text-sm font-bold transition-all flex items-center gap-2`,s===`blank`?`text-[#d4a017] border-b-2 border-[#d4a017] bg-[#d4a017]/5`:`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`),children:[(0,J.jsx)(T,{className:`w-4 h-4`}),r(`blank_flow`,`Blank Flow`)]})]}),s===`templates`?(0,J.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`w-56 border-r border-[#1a2040] overflow-y-auto shrink-0 p-3 space-y-0.5`,children:[(0,J.jsxs)(`button`,{onClick:()=>v(null),className:H(`w-full text-left px-3 py-2 rounded-lg text-xs font-medium transition-colors`,_?`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`:`bg-[#d4a017]/10 text-[#d4a017]`),children:[r(`all_templates`,`All Templates`),(0,J.jsx)(`span`,{className:`float-right text-[9px] opacity-60`,children:l.length})]}),d.map(e=>(0,J.jsxs)(`button`,{onClick:()=>v(e.name===_?null:e.name),className:H(`w-full text-left px-3 py-2 rounded-lg text-xs font-medium transition-colors flex items-center gap-2`,_===e.name?`bg-[#d4a017]/10 text-[#d4a017]`:`text-[#7a8899] hover:text-[#c8d0d8] hover:bg-[#1a2040]/50`),children:[(0,J.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0`,style:{background:Cp[e.name]||`#7a8899`}}),(0,J.jsx)(`span`,{className:`flex-1 truncate`,children:i(e.name)}),(0,J.jsx)(`span`,{className:`text-[9px] opacity-60`,children:e.count})]},e.name))]}),(0,J.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`p-3 border-b border-[#1a2040] shrink-0`,children:(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(A,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-[#7a8899]`}),(0,J.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg pl-9 pr-3 py-2 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`,placeholder:r(`search_templates`,`Search templates...`)})]})}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3`,children:p?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,J.jsx)(V,{className:`w-6 h-6 text-[#d4a017] animate-spin`})}):h?(0,J.jsxs)(`div`,{className:`text-center py-16 px-8`,children:[(0,J.jsx)(te,{className:`w-8 h-8 text-amber-400 mx-auto mb-3`}),(0,J.jsx)(`p`,{className:`text-sm text-amber-300 font-semibold`,children:r(`templates_unavailable`,`Templates unavailable`)}),(0,J.jsx)(`p`,{className:`text-xs text-[#7a8899] mt-2`,children:h})]}):N.length===0?(0,J.jsxs)(`div`,{className:`text-center py-16`,children:[(0,J.jsx)(A,{className:`w-8 h-8 text-[#7a8899]/40 mx-auto mb-3`}),(0,J.jsx)(`p`,{className:`text-sm text-[#7a8899]`,children:r(`no_templates`,`No templates match your search`)})]}):(0,J.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:N.map(e=>{let t=Cp[l.find(t=>t.id===e.id)?.category||e.category]||`#7a8899`,n=wp[e.difficulty]||wp.beginner;return(0,J.jsx)(`button`,{onClick:()=>P(e.id),disabled:!!S,className:H(`text-left p-3.5 rounded-xl border transition-all group`,`bg-[#0e1225] border-[#1a2040] hover:border-[#d4a017]/50 hover:bg-[#0e1225]/80`,`hover:shadow-[0_0_20px_rgba(212,160,23,0.08)]`,S===e.id&&`opacity-70 pointer-events-none`),children:(0,J.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,J.jsx)(`span`,{className:`text-xl leading-none mt-0.5`,children:e.icon}),(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,J.jsx)(`h4`,{className:`text-xs font-bold text-[#c8d0d8] truncate flex-1 group-hover:text-[#d4a017] transition-colors`,children:e.name}),S===e.id&&(0,J.jsx)(V,{className:`w-3 h-3 text-[#d4a017] animate-spin shrink-0`})]}),(0,J.jsx)(`p`,{className:`text-[10px] text-[#7a8899] line-clamp-2 leading-relaxed mb-2`,children:e.description}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,J.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded`,style:{color:t,background:`${t}15`},children:e.category}),(0,J.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded`,style:{color:n.color,background:`${n.color}15`},children:a(e.difficulty||`beginner`)||n.label}),(0,J.jsxs)(`span`,{className:`text-[8px] text-[#7a8899]/60 ml-auto`,children:[e.node_count,` `,r(`nodes`,`nodes`)]})]})]})]})},e.id)})})})]})]}):(0,J.jsxs)(`div`,{className:`p-6 space-y-5 overflow-y-auto`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Flow Name`}),(0,J.jsx)(`input`,{type:`text`,autoFocus:!0,value:w,onChange:e=>E(e.target.value),className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg p-2.5 text-sm text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none`,placeholder:`e.g., Research Pipeline, Weekly Report...`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Trigger Type`}),(0,J.jsxs)(`select`,{value:k,onChange:e=>j(e.target.value),className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg p-2.5 text-sm text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`manual`,children:`Manual Execution`}),(0,J.jsx)(`option`,{value:`scheduled`,children:`Scheduled / Cron`}),(0,J.jsx)(`option`,{value:`event`,children:`Event-Based Trigger`}),(0,J.jsx)(`option`,{value:`api`,children:`API Trigger`})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-[#7a8899] uppercase tracking-widest`,children:`Description`}),(0,J.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),rows:3,className:`w-full bg-[#050508] border border-[#1a2040] rounded-lg p-3 text-xs text-[#c8d0d8] focus:border-[#d4a017] transition-colors outline-none resize-none`,placeholder:`Describe the purpose of this workflow...`})]}),(0,J.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,J.jsx)(`button`,{onClick:e,className:`flex-1 bg-[#0e1225] hover:bg-[#1a2040] text-[#7a8899] font-bold py-2.5 rounded-lg transition-all border border-[#1a2040] text-sm`,children:`Cancel`}),(0,J.jsxs)(`button`,{onClick:()=>t(w,D,k),disabled:!w.trim(),className:H(`flex-1 font-bold py-2.5 rounded-lg transition-all text-sm flex items-center justify-center gap-2`,w.trim()?`bg-[#4a8cc7] hover:bg-[#4a8cc7]/90 text-white shadow-[0_0_20px_rgba(74,140,199,0.15)]`:`bg-[#7a8899]/20 text-[#7a8899] cursor-not-allowed`),children:[(0,J.jsx)(T,{className:`w-3.5 h-3.5`}),`Create Blank Flow`]})]})]})]})})}var Ep=()=>{let[e,t]=(0,q.useState)([]),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(!0),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)([]);(0,q.useEffect)(()=>{$(`agent_flow.mount`,{path:window.location.pathname,href:window.location.href})},[]);let f=(0,q.useCallback)(async()=>{a(!0),$(`agent_flow.fetch_flows.start`);try{let e=await K.get(`/api/v1/agent-flows`);e.data.data?(t(e.data.data),$(`agent_flow.fetch_flows.success`,{count:e.data.data.length,ids:e.data.data.slice(0,10).map(e=>e.id)})):$(`agent_flow.fetch_flows.empty_response`,{response:e.data})}catch(e){console.error(`Failed to fetch flows:`,e),$(`agent_flow.fetch_flows.error`,{error:e})}finally{a(!1)}},[]),p=(0,q.useCallback)(async()=>{$(`agent_flow.fetch_support.start`);try{let[e,t]=await Promise.all([K.get(`/api/v1/agents?agent_type=samurai`),K.get(`/api/v1/model-routing-profiles`)]);e.data.data&&l(e.data.data),t.data.data&&d(t.data.data),$(`agent_flow.fetch_support.success`,{agents:e.data?.data?.length||0,routingProfiles:t.data?.data?.length||0})}catch(e){console.error(`Failed to fetch support data:`,e),$(`agent_flow.fetch_support.error`,{error:e})}},[]);(0,q.useEffect)(()=>{f(),p()},[f,p]);let m=(0,q.useCallback)(async e=>{$(`agent_flow.load_flow.start`,{flowId:e});try{let t=await K.get(`/api/v1/agent-flows/${e}`);t.data.data?($(`agent_flow.load_flow.success`,{flowId:e,nodes:t.data.data.nodes?.length||0,edges:t.data.data.edges?.length||0}),r(t.data.data)):$(`agent_flow.load_flow.empty_response`,{flowId:e,response:t.data})}catch(t){console.error(`Failed to load flow:`,t),$(`agent_flow.load_flow.error`,{flowId:e,error:t})}},[]),h=(0,q.useCallback)(async(e,t,n)=>{try{let i=await K.post(`/api/v1/agent-flows`,{name:e,description:t,trigger_type:n});i.data.data&&(s(!1),r(i.data.data),f())}catch(e){console.error(`Failed to create flow:`,e)}},[f]),g=(0,q.useCallback)(async e=>{try{let t=await K.post(`/api/v1/agent-flows/from-template`,{template_id:e});if(t.data.data){s(!1);let e=t.data.data.id,n=await K.get(`/api/v1/agent-flows/${e}`);n.data.data?r(n.data.data):r(t.data.data),f()}}catch(e){console.error(`Failed to create flow from template:`,e)}},[f]),_=(0,q.useCallback)(async e=>{if(confirm(`Delete this Agent Flow?`))try{await K.delete(`/api/v1/agent-flows/${e}`),f()}catch(e){console.error(`Failed to delete flow:`,e)}},[f]),v=(0,q.useCallback)(async e=>{try{await K.post(`/api/v1/agent-flows/${e}/duplicate`),f()}catch(e){console.error(`Failed to duplicate flow:`,e)}},[f]);return n?(0,J.jsx)(Xd,{children:(0,J.jsx)(xp,{flow:n,onBack:()=>{r(null),f()},onFlowUpdate:f,agents:c,routingProfiles:u,availableFlows:e},n.id)}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Sp,{flows:e,loading:i,onSelect:m,onCreate:()=>s(!0),onDelete:_,onDuplicate:v,onRefresh:f}),o&&(0,J.jsx)(Tp,{onClose:()=>s(!1),onCreate:h,onCreateFromTemplate:g})]})},Dp=(0,q.createContext)({openEditor:()=>void 0,deleteNode:()=>void 0});function Op({id:e,data:t,selected:n}){let{openEditor:r,deleteNode:i}=(0,q.useContext)(Dp);return(0,J.jsxs)(`div`,{onClick:()=>r(e),className:H(`relative w-[230px] rounded-xl border bg-[#0e1225] text-[#c8d0d8] shadow-lg transition-all`,n?`border-purple-400 ring-2 ring-purple-400/25`:`border-[#28325d] hover:border-[#4a8cc7]`),children:[(0,J.jsx)(Su,{type:`target`,position:Z.Left,className:`!h-3 !w-3 !border-2 !border-[#080b16] !bg-[#4a8cc7]`}),(0,J.jsxs)(`div`,{className:`flex items-start gap-2 p-3`,children:[(0,J.jsx)(v,{className:`mt-0.5 h-4 w-4 shrink-0 text-purple-400`}),(0,J.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:()=>r(e),className:`nodrag nopan min-w-0 flex-1 text-left`,children:[(0,J.jsx)(`div`,{className:`truncate text-[11px] font-bold`,children:String(t.label||`AgentFlow`)}),(0,J.jsxs)(`div`,{className:`mt-1 text-[8px] font-bold uppercase tracking-wider text-[#7a8899]`,children:[String(t.category||`AgentFlow`),` · drag to reorder`]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,title:`Edit AgentFlow`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),r(e)},className:`nodrag nopan rounded border border-[#28325d] p-1 text-[#7a8899] hover:text-[#4a8cc7]`,children:(0,J.jsx)(f,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{type:`button`,title:`Delete from stack`,onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),i(e)},className:`nodrag nopan rounded border border-red-500/20 p-1 text-red-400/70 hover:bg-red-500/10 hover:text-red-300`,children:(0,J.jsx)(N,{className:`h-3 w-3`})})]})]}),(0,J.jsx)(Su,{type:`source`,position:Z.Right,className:`!h-3 !w-3 !border-2 !border-[#080b16] !bg-[#8b5cf6]`})]})}var kp={stackFlow:Op},Ap=class extends q.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`The embedded AgentFlow editor could not be rendered.`,e,t)}render(){return this.state.error?(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center bg-[#050508] p-6`,children:(0,J.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-red-500/30 bg-[#0e1225] p-6 text-center shadow-2xl`,children:[(0,J.jsx)(`h2`,{className:`text-base font-bold text-red-300`,children:`The AgentFlow editor could not open`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-shogun-subdued`,children:`The Flow Stack is still safe. Close this view and try the AgentFlow again.`}),(0,J.jsx)(`p`,{className:`mt-3 rounded border border-red-500/20 bg-black/20 p-2 text-[10px] text-red-200`,children:this.state.error.message}),(0,J.jsx)(`button`,{type:`button`,onClick:this.props.onClose,className:`mt-5 rounded border border-shogun-border px-4 py-2 text-xs font-bold text-shogun-text hover:border-shogun-blue`,children:`BACK TO FLOW STACK`})]})}):this.props.children}};function jp({flow:e,onClose:t,agents:n,routingProfiles:r,availableFlows:i}){return(0,J.jsx)(`div`,{className:`fixed inset-0 z-[100] overflow-hidden bg-[#050508] p-3`,"data-testid":`embedded-agent-flow-editor`,children:(0,J.jsx)(Ap,{onClose:t,children:(0,J.jsx)(Xd,{children:(0,J.jsx)(xp,{flow:e,onBack:t,onFlowUpdate:()=>void 0,agents:n,routingProfiles:r,availableFlows:i},e.id)})})})}function Mp({seed:e}){let[t,n]=(0,q.useState)([]),[r,a,s]=rf([]),[c,l,u]=af([]),[d,f]=(0,q.useState)([]),[p,m]=(0,q.useState)([]),[h,g]=(0,q.useState)(!0),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(`All`),[S,C]=(0,q.useState)(`My Templates`),[w,T]=(0,q.useState)(`New Flow Stack`),[D,O]=(0,q.useState)(``),[j,M]=(0,q.useState)(`Complete the stack and verify every flow output.`),[P,F]=(0,q.useState)(`balanced`),[I,L]=(0,q.useState)(`pause`),[R,ee]=(0,q.useState)(1440),[z,te]=(0,q.useState)(100),[U,W]=(0,q.useState)(3),[ne,re]=(0,q.useState)(`after_each_subflow`),[G,ie]=(0,q.useState)(`step_based`),[ae,oe]=(0,q.useState)(`retain_all`),[se,ue]=(0,q.useState)(!1),[de,fe]=(0,q.useState)(``),[pe,me]=(0,q.useState)(`draft`),[he,ge]=(0,q.useState)(!1),[Y,X]=(0,q.useState)(``),[_e,ve]=(0,q.useState)(null),[ye,be]=(0,q.useState)(null),xe=(0,q.useRef)(!1),[Se,Ce]=(0,q.useState)([]),[we,Te]=(0,q.useState)([]),[Ee,De]=(0,q.useState)([]),Oe=$l();(0,q.useEffect)(()=>{Promise.all([K.get(`/api/v1/agent-flows/templates`),K.get(`/api/v1/agents?agent_type=samurai`),K.get(`/api/v1/model-routing-profiles`),K.get(`/api/v1/agent-flows`)]).then(([e,t,r,i])=>{n(e.data?.data?.templates||[]),Ce(t.data?.data||[]),Te(r.data?.data||[]),De(i.data?.data||[])})},[]);let ke=(0,q.useCallback)(async e=>{if(xe.current)return;let t=e.data.flowId?String(e.data.flowId):``,n=e.data.templateId?String(e.data.templateId):``;if(!t&&!n){X(`“${String(e.data.label||`This AgentFlow`)}” is not linked to an AgentFlow template.`);return}xe.current=!0,be(e.id),X(`Opening the editable AgentFlow...`);try{let r=t;if(!r){let t=await K.post(`/api/v1/agent-flows/from-template`,{template_id:n},{timeout:15e3});if(r=String(t.data?.data?.id||``),!r)throw Error(`The AgentFlow template could not be instantiated.`);a(t=>t.map(t=>t.id===e.id?{...t,data:{...t.data,flowId:r,templateId:void 0}}:t))}let[i,o]=await Promise.all([K.get(`/api/v1/agent-flows/${encodeURIComponent(r)}`,{timeout:15e3}),K.get(`/api/v1/agent-flows`,{timeout:15e3})]);De(o.data?.data||[]);let s=i.data?.data;if(!s?.id||!Array.isArray(s.nodes)||!Array.isArray(s.edges))throw Error(`The server returned an incomplete AgentFlow.`);ve(s),X(``)}catch(e){X(e?.response?.data?.detail||e?.message||`Could not open this AgentFlow.`)}finally{xe.current=!1,be(null)}},[a]);(0,q.useEffect)(()=>{if(!e||!t.length)return;let n=e.builder_nodes?.length?e.builder_nodes.map(t=>({id:t.id,position:{x:t.position_x,y:t.position_y},type:`stackFlow`,data:{label:t.label,templateId:t.template_id,flowId:t.flow_id,category:e.category}})):(e.flow_template_ids||[]).map((n,r)=>{let i=t.find(e=>e.id===n);return{id:crypto.randomUUID(),position:{x:340+r*300,y:220},type:`stackFlow`,data:{label:i?.name||n,templateId:n,category:i?.category||e.category}}}),r=e.builder_edges?.length?e.builder_edges.map((e,t)=>({id:`seed-edge-${t}`,source:e.source,target:e.target,animated:!0,style:{stroke:`#8b5cf6`,strokeWidth:2}})):n.slice(1).map((e,t)=>({id:`seed-edge-${t}`,source:n[t].id,target:e.id,animated:!0,style:{stroke:`#8b5cf6`,strokeWidth:2}}));a(n),l(r),T(e.name),O(e.description),C(e.category||`My Templates`),x(`All`),fe(``),me(`draft`),e.orchestrator_config&&(M(t=>e.orchestrator_config?.objective||t),F(e.orchestrator_config.model_routing_profile||`balanced`),L(e.orchestrator_config.failure_policy||`retry`),ee(e.orchestrator_config.max_runtime_minutes||1440),te(e.orchestrator_config.max_iterations||100),W(e.orchestrator_config.max_retry_attempts_per_step??3),re(e.orchestrator_config.checkpoint_frequency||`after_each_subflow`),ie(e.orchestrator_config.approval_policy||`step_based`),oe(e.orchestrator_config.artifact_policy||`retain_all`)),X(`Opened “${e.name}” in the Stack Builder. Click any AgentFlow block to inspect its internal nodes.`),window.setTimeout(()=>Oe.fitView({padding:.15}),0)},[e,t,Oe,l,a]);let Ae=(0,q.useMemo)(()=>[`All`,...Array.from(new Set(t.map(e=>e.category))).sort()],[t]),je=(0,q.useMemo)(()=>t.filter(e=>(b===`All`||e.category===b)&&`${e.name} ${e.description}`.toLowerCase().includes(v.toLowerCase())),[t,b,v]),Me=(0,q.useCallback)(e=>{a(t=>t.filter(t=>t.id!==e)),l(t=>t.filter(t=>t.source!==e&&t.target!==e)),f(t=>t.filter(t=>t!==e))},[l,a]),Ne=(0,q.useCallback)(()=>{if(!d.length&&!p.length)return;let e=new Set(d),t=new Set(p);a(t=>t.filter(t=>!e.has(t.id))),l(n=>n.filter(n=>!t.has(n.id)&&!e.has(n.source)&&!e.has(n.target))),f([]),m([])},[p,d,l,a]),Pe=(0,q.useCallback)(({nodes:e,edges:t})=>{let n=e.map(e=>e.id),r=t.map(e=>e.id);f(e=>e.length===n.length&&e.every((e,t)=>e===n[t])?e:n),m(e=>e.length===r.length&&e.every((e,t)=>e===r[t])?e:r)},[]);(0,q.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let t=e.target;t instanceof HTMLElement&&t.closest(`input, textarea, select, [contenteditable="true"]`)||(e.preventDefault(),Ne())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Ne]);let Fe=(0,q.useMemo)(()=>({openEditor:e=>{let t=r.find(t=>t.id===e);t&&ke(t)},deleteNode:Me}),[Me,r,ke]),Ie=(0,q.useCallback)((e,t)=>{ke(t)},[ke]),Le=(0,q.useCallback)(e=>{l(t=>vs({...e,animated:!0,style:{stroke:`#8b5cf6`,strokeWidth:2}},t))},[l]),Re=(0,q.useCallback)((e,t)=>{l(n=>ys(e,t,n))},[l]),ze=(0,q.useCallback)(e=>{e.preventDefault(),e.dataTransfer.dropEffect=`copy`},[]),Be=(0,q.useCallback)(e=>{e.preventDefault();let t=e.dataTransfer.getData(`application/shogun-flow-template`);if(!t)return;let n=JSON.parse(t),r=Oe.screenToFlowPosition({x:e.clientX,y:e.clientY}),i=crypto.randomUUID();a(e=>[...e,{id:i,position:r,type:`stackFlow`,data:{label:n.name,templateId:n.id,category:n.category}}])},[Oe,a]),Ve=async e=>{let t=r;if(!t.length)return X(`Drag at least one AgentFlow template onto the canvas.`);if(t.length>1&&!c.length)return X(`Connect the AgentFlow templates before saving.`);ue(!0),X(``);try{let n=await K.post(`/api/v1/agent-flows/flow-stacks/compose`,{name:w,description:D,category:S,nodes:t.map(e=>({id:e.id,template_id:e.data.templateId||void 0,flow_id:e.data.flowId||void 0,label:e.data.label,position_x:e.position.x,position_y:e.position.y})),edges:c.map(e=>({id:e.id,source:e.source,target:e.target})),orchestrator_config:{objective:j,model_routing_profile:P,failure_policy:I,checkpoint_frequency:ne,verification_required:!0,max_runtime_minutes:R,max_iterations:z,max_retry_attempts_per_step:U,context_compaction:`enabled`,approval_policy:G,artifact_policy:ae,timeout_seconds:Math.min(R*60,86400)},save_as_template:e});fe(String(n.data.data.id)),me(n.data.data.status===`active`?`active`:n.data.data.status===`paused`?`paused`:`draft`),X(e?`Stack and reusable template saved: ${n.data.data.name}`:`Flow Stack saved: ${n.data.data.name}`)}catch(e){X(e?.response?.data?.detail||`Could not save the Flow Stack.`)}finally{ue(!1)}};return(0,J.jsxs)(`div`,{className:`grid grid-cols-[300px_minmax(0,1fr)] gap-4 min-h-[690px]`,children:[(0,J.jsxs)(`aside`,{className:`shogun-card !p-4 overflow-hidden flex flex-col`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,J.jsx)(le,{className:`w-4 h-4 text-shogun-blue`}),(0,J.jsx)(`b`,{className:`text-xs`,children:`AGENTFLOW TEMPLATES`})]}),(0,J.jsxs)(`div`,{className:`relative mb-2`,children:[(0,J.jsx)(A,{className:`absolute w-3.5 h-3.5 left-2.5 top-2.5 text-shogun-subdued`}),(0,J.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`Search templates`,className:`w-full bg-[#080b16] border border-shogun-border rounded pl-8 pr-2 py-2 text-xs`})]}),(0,J.jsx)(`select`,{value:b,onChange:e=>x(e.target.value),className:`bg-[#080b16] border border-shogun-border rounded p-2 text-xs mb-3`,children:Ae.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))}),(0,J.jsx)(`div`,{className:`space-y-2 overflow-y-auto pr-1 flex-1`,children:je.map(e=>(0,J.jsxs)(`div`,{draggable:!0,onDragStart:t=>{t.dataTransfer.setData(`application/shogun-flow-template`,JSON.stringify(e)),t.dataTransfer.effectAllowed=`copy`},className:`p-3 rounded-lg border border-shogun-border bg-[#0a0e1a] hover:border-shogun-blue cursor-grab active:cursor-grabbing`,children:[(0,J.jsx)(`div`,{className:`text-xs font-bold text-shogun-text`,children:e.name}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between mt-1`,children:[(0,J.jsx)(`div`,{className:`text-[9px] text-shogun-blue uppercase`,children:e.category}),(0,J.jsx)(`div`,{className:`text-[9px] text-shogun-subdued`,children:`DRAG TO STACK`})]})]},e.id))})]}),(0,J.jsxs)(`section`,{className:`rounded-xl border border-shogun-border bg-[#060913] overflow-hidden relative`,children:[(0,J.jsxs)(`div`,{className:`absolute z-20 top-3 left-3 flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`px-3 py-2 rounded bg-[#0e1225]/95 border border-shogun-border text-[10px] text-shogun-subdued`,children:`Drag to reorder · connect handles · click a card to edit`}),(d.length>0||p.length>0)&&(0,J.jsxs)(`button`,{onClick:Ne,className:`flex items-center gap-1.5 rounded border border-red-500/30 bg-[#180b14]/95 px-3 py-2 text-[10px] font-bold text-red-300 hover:bg-red-500/15`,children:[(0,J.jsx)(N,{className:`h-3 w-3`}),`DELETE SELECTED (`,d.length+p.length,`)`]})]}),(0,J.jsx)(Dp.Provider,{value:Fe,children:(0,J.jsxs)(ef,{nodes:r,edges:c,nodeTypes:kp,onNodesChange:s,onEdgesChange:u,onConnect:Le,onReconnect:Re,onNodeClick:Ie,onSelectionChange:Pe,onDrop:Be,onDragOver:ze,edgesReconnectable:!0,deleteKeyCode:null,fitView:!0,children:[(0,J.jsx)(ff,{variant:cf.Dots,color:`#26305d`,gap:22}),(0,J.jsx)(xf,{}),(0,J.jsx)(If,{nodeColor:`#4a8cc7`})]})}),(0,J.jsxs)(`aside`,{className:H(`absolute z-30 top-3 right-3 w-[360px] rounded-xl border border-purple-400/30 bg-[#0b0e1c]/95 shadow-2xl backdrop-blur transition-all`,h?`max-h-[calc(100%-24px)] overflow-y-auto p-4 space-y-4`:`w-auto p-2`),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(B,{className:`w-4 h-4 text-purple-400`}),(0,J.jsx)(`b`,{className:`text-xs`,children:`STACK ORCHESTRATOR`})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),title:h?`Collapse orchestrator`:`Expand orchestrator`,className:`rounded border border-purple-400/20 p-1 text-purple-300 hover:bg-purple-500/10`,children:h?(0,J.jsx)(o,{className:`h-3.5 w-3.5`}):(0,J.jsx)(i,{className:`h-3.5 w-3.5`})})]}),h&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`group relative rounded-lg border border-purple-400/20 bg-purple-500/5 p-2.5 text-[9px] leading-relaxed text-shogun-subdued`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 font-bold uppercase tracking-wider text-purple-300`,children:[(0,J.jsx)(_,{className:`h-3.5 w-3.5`}),` How the Orchestrator works`]}),(0,J.jsx)(`p`,{className:`mt-1`,children:`It supervises the complete Stack: passing output between AgentFlows, saving checkpoints, retrying failures, compacting long-running context, and verifying results before completion.`}),(0,J.jsx)(`div`,{className:`pointer-events-none absolute right-2 top-2 hidden w-64 rounded-lg border border-purple-400/30 bg-[#080b16] p-3 text-[9px] normal-case text-shogun-text shadow-2xl group-hover:block`,children:`Configure the goal and safety limits here. Activate the saved Stack when it is ready to run. Pausing a Stack prevents new executions without deleting it.`})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Stack name`,(0,J.jsx)(`input`,{value:w,onChange:e=>T(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs text-shogun-text`})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Stack category`,(0,J.jsx)(`select`,{value:S,onChange:e=>C(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs text-shogun-text`,children:Object.keys(Np).map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Description`,(0,J.jsx)(`textarea`,{value:D,onChange:e=>O(e.target.value),rows:2,className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs text-shogun-text`})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Objective`,(0,J.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),rows:4,className:`mt-1 w-full bg-[#080b16] border border-purple-500/30 rounded p-2 text-xs text-shogun-text`})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Model routing`,(0,J.jsxs)(`select`,{value:P,onChange:e=>F(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,J.jsx)(`option`,{children:`balanced`}),(0,J.jsx)(`option`,{children:`quality`}),(0,J.jsx)(`option`,{children:`speed`}),(0,J.jsx)(`option`,{children:`cost`})]})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`On failure`,(0,J.jsxs)(`select`,{value:I,onChange:e=>L(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,J.jsx)(`option`,{children:`pause`}),(0,J.jsx)(`option`,{children:`retry`}),(0,J.jsx)(`option`,{children:`continue_with_error`}),(0,J.jsx)(`option`,{children:`fail_stack`})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Max runtime (min)`,(0,J.jsx)(`input`,{type:`number`,min:1,max:1440,value:R,onChange:e=>ee(Number(e.target.value)),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Max iterations`,(0,J.jsx)(`input`,{type:`number`,min:1,max:500,value:z,onChange:e=>te(Number(e.target.value)),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`})]})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Checkpoints`,(0,J.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,J.jsx)(`option`,{value:`after_each_subflow`,children:`After every subflow`}),(0,J.jsx)(`option`,{value:`after_each_step`,children:`After every step`}),(0,J.jsx)(`option`,{value:`timed`,children:`Timed`})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Retries`,(0,J.jsx)(`input`,{type:`number`,min:0,max:10,value:U,onChange:e=>W(Number(e.target.value)),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Approval`,(0,J.jsxs)(`select`,{value:G,onChange:e=>ie(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,J.jsx)(`option`,{value:`step_based`,children:`Step based`}),(0,J.jsx)(`option`,{value:`inherited`,children:`Inherited`}),(0,J.jsx)(`option`,{value:`always_required_for_high_risk`,children:`High risk`})]})]})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Artifacts`,(0,J.jsxs)(`select`,{value:ae,onChange:e=>oe(e.target.value),className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,J.jsx)(`option`,{value:`retain_all`,children:`Retain all`}),(0,J.jsx)(`option`,{value:`retain_final_only`,children:`Final only`}),(0,J.jsx)(`option`,{value:`retain_selected`,children:`Selected`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-[10px] text-shogun-subdued`,children:[(0,J.jsxs)(`span`,{children:[r.length,` flows`]}),(0,J.jsxs)(`span`,{children:[c.length,` connections`]})]}),(0,J.jsxs)(`button`,{disabled:!de||he,onClick:async()=>{if(!de)return X(`Save the Flow Stack before activating it.`);let e=pe!==`active`;ge(!0);try{let t=await K.post(`/api/v1/agent-flows/${encodeURIComponent(de)}/${e?`activate`:`pause`}`);me(t.data?.data?.status===`active`?`active`:`paused`),X(e?`Flow Stack activated and available for execution.`:`Flow Stack deactivated. Existing history is preserved.`)}catch(t){X(t?.response?.data?.detail||`Could not ${e?`activate`:`deactivate`} the Flow Stack.`)}finally{ge(!1)}},title:de?pe===`active`?`Deactivate this Stack`:`Activate this Stack`:`Save the Stack before activating it`,className:H(`w-full flex justify-center items-center gap-2 py-2 rounded text-xs font-bold border disabled:cursor-not-allowed disabled:opacity-40`,pe===`active`?`border-green-400/40 bg-green-500/15 text-green-300`:`border-shogun-border bg-[#080b16] text-shogun-subdued`),children:[(0,J.jsx)(E,{className:`w-3.5 h-3.5`}),he?`UPDATING...`:pe===`active`?`ACTIVE — CLICK TO DEACTIVATE`:de?`ACTIVATE STACK`:`SAVE STACK TO ACTIVATE`]}),(0,J.jsxs)(`button`,{onClick:()=>{a([]),l([]),f([]),m([])},className:`w-full flex justify-center items-center gap-2 py-2 border border-red-500/25 text-red-400 rounded text-xs`,children:[(0,J.jsx)(N,{className:`w-3.5 h-3.5`}),` CLEAR CANVAS`]}),(0,J.jsxs)(`button`,{disabled:se,onClick:()=>Ve(!1),className:`w-full flex justify-center items-center gap-2 py-2 bg-shogun-blue rounded text-white font-bold text-xs`,children:[(0,J.jsx)(k,{className:`w-3.5 h-3.5`}),` SAVE STACK`]}),(0,J.jsxs)(`button`,{disabled:se,onClick:()=>Ve(!0),className:`w-full flex justify-center items-center gap-2 py-2 bg-purple-500/20 border border-purple-400/40 text-purple-300 rounded font-bold text-xs`,children:[(0,J.jsx)(ce,{className:`w-3.5 h-3.5`}),` SAVE AS TEMPLATE`]}),Y&&(0,J.jsx)(`div`,{className:`p-2 rounded border border-shogun-border bg-[#080b16] text-[10px] text-shogun-text`,children:Y})]})]})]}),ye&&(0,J.jsx)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-[90] -translate-x-1/2 rounded-lg border border-shogun-blue/30 bg-[#0e1225] px-4 py-3 shadow-2xl`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3 text-sm text-shogun-text`,children:[(0,J.jsx)(V,{className:`w-5 h-5 animate-spin text-shogun-blue`}),` Opening editable AgentFlow...`]})}),_e&&(0,J.jsx)(jp,{flow:_e,onClose:()=>ve(null),agents:Se,routingProfiles:we,availableFlows:Ee})]})}var Np={"Continuous Intelligence":`#22c55e`,"Strategy & Transformation":`#3b82f6`,"Product & Innovation":`#f59e0b`,"Growth & Brand":`#ec4899`,"Customer Operations":`#06b6d4`,"Data & Executive Operations":`#8b5cf6`,"Risk & Compliance":`#ef4444`,"People & Capability":`#14b8a6`,"Incident & Resilience":`#f97316`,"Knowledge & Publishing":`#6366f1`,"My Templates":`#d4a017`};function Pp({onOpen:e}){let{ui:t,category:n,flowStack:r}=rp(),[i,a]=(0,q.useState)([]),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(`All`),[u,d]=(0,q.useState)(``),f=(0,q.useCallback)(()=>K.get(`/api/v1/agent-flows/flow-stack-templates`).then(e=>a(e.data?.data?.templates||[])),[]);(0,q.useEffect)(()=>{f()},[f]);let p=[`All`,...Array.from(new Set(i.map(e=>e.category))).sort()],m=i.filter(e=>c===`All`||e.category===c).map(e=>r(e)).filter(e=>`${e.name} ${e.description} ${e.category}`.toLowerCase().includes(o.toLowerCase()));return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex gap-3`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(A,{className:`absolute w-4 h-4 left-3 top-3 text-shogun-subdued`}),(0,J.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:t(`search_stack_templates`,`Search Flow Stack templates`),className:`w-full bg-[#0e1225] border border-shogun-border rounded-lg pl-10 p-2.5 text-sm`})]}),(0,J.jsx)(`select`,{value:c,onChange:e=>l(e.target.value),className:`bg-[#0e1225] border border-shogun-border rounded-lg px-3 text-xs`,style:{color:c===`All`?`#c8d0d8`:Np[c]||`#c8d0d8`},children:p.map(e=>(0,J.jsx)(`option`,{value:e,style:{color:e===`All`?`#c8d0d8`:Np[e]||`#c8d0d8`},children:e===`All`?t(`all_stack_categories`,`All Flow Stack Categories`):`● ${n(e)}`},e))}),(0,J.jsx)(`button`,{onClick:f,className:`p-2.5 border border-shogun-border rounded-lg`,children:(0,J.jsx)(D,{className:`w-4 h-4`})})]}),(0,J.jsxs)(`div`,{className:`text-xs text-shogun-subdued`,children:[i.length,` `,t(`reusable_templates`,`reusable templates`),` · `,m.length,` `,t(`shown`,`shown`)]}),u&&(0,J.jsx)(`div`,{className:`p-3 border border-shogun-blue/30 bg-shogun-blue/10 rounded text-xs`,children:u}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3`,children:m.map(n=>{let r=Np[i.find(e=>e.id===n.id)?.category||n.category]||`#7a8899`;return(0,J.jsxs)(`div`,{onClick:()=>e(n),className:`shogun-card relative !p-4 flex flex-col min-h-[210px] cursor-pointer hover:border-purple-400/50 transition-colors overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-0.5`,style:{backgroundColor:r}}),(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(v,{className:`w-5 h-5`,style:{color:r}}),(0,J.jsx)(`span`,{className:`text-[9px] uppercase rounded px-2 py-1 font-bold`,style:{color:r,backgroundColor:`${r}18`},children:n.category})]}),(0,J.jsx)(`h3`,{className:`font-bold text-sm mt-3`,children:n.name}),(0,J.jsx)(`p`,{className:`text-[11px] text-shogun-subdued mt-2 flex-1`,children:n.description}),(0,J.jsxs)(`div`,{className:`flex gap-2 my-3`,children:[(0,J.jsxs)(`span`,{className:`text-[9px] px-2 py-1 rounded bg-purple-500/10 text-purple-300 border border-purple-500/20`,children:[n.flow_count||0,` `,t(`phases`,`phases`).toUpperCase()]}),(0,J.jsx)(`span`,{className:`text-[9px] px-2 py-1 rounded bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20`,children:n.duration_label||t(`resumable`,`Resumable`)})]}),(0,J.jsx)(`button`,{onClick:t=>{t.stopPropagation(),e(n)},className:`w-full px-3 py-2 rounded bg-purple-500/20 text-purple-300 border border-purple-500/30 text-[10px] font-bold`,children:t(`open_program`,`Open long-running program`).toUpperCase()})]},n.id)})})]})}function Fp(){let e=`/api/v1/stacks/orchestrator`,[t,n]=(0,q.useState)([]),[r,i]=(0,q.useState)([]),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)([]),[p,m]=(0,q.useState)([]),[h,g]=(0,q.useState)([]),[_,v]=(0,q.useState)(`Execute the selected Flow Stack and verify the final output.`),[y,b]=(0,q.useState)(`Every AgentFlow produces a non-empty result +All required verification checks pass`),[x,w]=(0,q.useState)(``),T=(0,q.useCallback)(async()=>{let[t,r]=await Promise.all([K.get(`/api/v1/agent-flows`),K.get(e)]);n((t.data?.data||[]).filter(e=>e.flow_type===`stack`));let a=r.data?.data||[];i(a),c(e=>e||a[0]?.id||``)},[]),E=(0,q.useCallback)(async t=>{if(t)try{let[n,r,i,a]=await Promise.all([K.get(`${e}/${t}`),K.get(`${e}/${t}/checkpoints`),K.get(`${e}/${t}/artifacts`),K.get(`${e}/${t}/verifications`)]);u(n.data?.data||null),f(r.data?.data||[]),m(i.data?.data||[]),g(a.data?.data||[])}catch(e){w(e?.response?.data?.detail||`Could not load the runtime trace.`)}},[]);(0,q.useEffect)(()=>{T()},[T]),(0,q.useEffect)(()=>{if(!s)return;E(s);let e=window.setInterval(()=>{E(s),T()},2e3);return()=>window.clearInterval(e)},[s,E,T]);let k=async()=>{if(!a)return w(`Select a saved Flow Stack first.`);try{let t=(await K.post(`${e}/create`,{mode:`selected_stack`,selected_stack_id:a,objective:_,success_criteria:y.split(` +`).map(e=>e.trim()).filter(Boolean),verification_required:!0,context_compaction:`enabled`,checkpoint_frequency:`after_each_subflow`,failure_policy:`pause`})).data.data.id;await K.post(`${e}/${t}/start`),c(t),w(`Run started with durable checkpoints and independent verification.`),await T()}catch(e){w(e?.response?.data?.detail||`Could not start the run.`)}},A=async(t,n)=>{try{await K.post(`${e}/${t}/${n}`),await E(t),await T()}catch(e){w(e?.response?.data?.detail||`Could not ${n} this run.`)}},j=e=>({completed:`#22c55e`,passed:`#22c55e`,running:`#38bdf8`,retrying:`#f59e0b`,paused:`#f59e0b`,waiting_approval:`#c084fc`,failed:`#ef4444`,cancelled:`#7a8899`,completed_with_errors:`#f97316`})[e]||`#7a8899`;return(0,J.jsxs)(`div`,{className:`grid grid-cols-[340px_minmax(0,1fr)] gap-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,J.jsx)(B,{className:`w-5 h-5 text-purple-400`}),(0,J.jsx)(`b`,{children:`Start governed run`})]}),(0,J.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs`,children:[(0,J.jsx)(`option`,{value:``,children:`Select Flow Stack`}),t.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Objective`,(0,J.jsx)(`textarea`,{value:_,onChange:e=>v(e.target.value),rows:4,className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs normal-case`})]}),(0,J.jsxs)(`label`,{className:`block text-[9px] uppercase text-shogun-subdued`,children:[`Success criteria — one per line`,(0,J.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value),rows:3,className:`mt-1 w-full bg-[#080b16] border border-shogun-border rounded p-2 text-xs normal-case`})]}),(0,J.jsxs)(`button`,{onClick:k,className:`w-full flex justify-center gap-2 items-center bg-purple-500/25 border border-purple-400/40 text-purple-200 py-2 rounded text-xs font-bold`,children:[(0,J.jsx)(C,{className:`w-4 h-4`}),` START ORCHESTRATOR`]}),x&&(0,J.jsx)(`div`,{className:`text-[10px] text-shogun-subdued`,children:x})]}),(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between`,children:[(0,J.jsx)(`b`,{className:`text-xs`,children:`CURRENT & RECENT RUNS`}),(0,J.jsx)(`button`,{onClick:T,children:(0,J.jsx)(D,{className:`w-4 h-4`})})]}),r.length===0&&(0,J.jsx)(`div`,{className:`shogun-card text-xs text-shogun-subdued`,children:`No stack runs yet.`}),r.map(e=>(0,J.jsxs)(`button`,{onClick:()=>c(e.id),className:H(`shogun-card !p-3 w-full text-left border transition-colors`,s===e.id&&`border-purple-400/60`),children:[(0,J.jsx)(`div`,{className:`font-bold text-xs line-clamp-2`,children:e.objective}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-[9px] uppercase`,children:[(0,J.jsx)(`span`,{style:{color:j(e.status)},children:e.status.replaceAll(`_`,` `)}),(0,J.jsx)(`span`,{className:`text-shogun-subdued`,children:e.posture||`ready`})]})]},e.id))]})]}),(0,J.jsxs)(`div`,{className:`space-y-4 min-w-0`,children:[!l&&(0,J.jsx)(`div`,{className:`shogun-card text-sm text-shogun-subdued`,children:`Select a run to inspect its live execution trace.`}),l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`shogun-card !p-4`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-[9px] uppercase text-shogun-subdued`,children:`Runtime command view`}),(0,J.jsx)(`h3`,{className:`mt-1 font-bold`,children:l.objective}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2 text-[9px]`,children:[(0,J.jsx)(`span`,{className:`rounded border px-2 py-1 uppercase`,style:{color:j(l.status),borderColor:`${j(l.status)}55`},children:l.status.replaceAll(`_`,` `)}),(0,J.jsxs)(`span`,{className:`rounded border border-shogun-border px-2 py-1 text-shogun-subdued`,children:[l.completed_steps?.length||0,`/`,l.steps?.length||0,` steps`]}),(0,J.jsx)(`span`,{className:`rounded border border-shogun-border px-2 py-1 text-shogun-subdued`,children:l.model_profile})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[l.status===`running`&&(0,J.jsx)(`button`,{onClick:()=>A(l.id,`pause`),title:`Pause`,className:`rounded border border-amber-400/30 p-2 text-amber-300`,children:(0,J.jsx)(S,{className:`w-4 h-4`})}),l.status===`paused`&&(0,J.jsx)(`button`,{onClick:()=>A(l.id,`resume`),title:`Resume`,className:`rounded border border-green-400/30 p-2 text-green-300`,children:(0,J.jsx)(O,{className:`w-4 h-4`})}),![`completed`,`completed_with_errors`,`cancelled`,`failed`].includes(l.status)&&(0,J.jsx)(`button`,{onClick:()=>A(l.id,`cancel`),title:`Cancel`,className:`rounded border border-red-400/30 p-2 text-red-300`,children:(0,J.jsx)(ue,{className:`w-4 h-4`})})]})]})}),(0,J.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1.45fr)_minmax(280px,0.8fr)] gap-4`,children:[(0,J.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,J.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Live execution tree`}),(0,J.jsx)(`div`,{className:`mt-3 space-y-2`,children:(l.steps||[]).map((e,t)=>{let n=e.metadata_json?.routing_decision||{};return(0,J.jsx)(`div`,{className:`rounded-lg border border-shogun-border bg-[#080b16] p-3`,children:(0,J.jsxs)(`div`,{className:`flex gap-3`,children:[(0,J.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-[9px] font-bold`,style:{color:j(e.status),borderColor:j(e.status)},children:t+1}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,J.jsx)(`b`,{className:`truncate text-[10px]`,children:e.name}),(0,J.jsx)(`span`,{className:`text-[8px] uppercase`,style:{color:j(e.status)},children:e.status.replaceAll(`_`,` `)})]}),(0,J.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-3 text-[8px] text-shogun-subdued`,children:[(0,J.jsx)(`span`,{children:e.model_used||`model pending`}),(0,J.jsxs)(`span`,{children:[`profile `,n.active_profile||l.model_profile]}),(0,J.jsxs)(`span`,{children:[`complexity `,n.complexity_score??`—`]}),(0,J.jsxs)(`span`,{children:[`cost tier `,n.estimated_cost_tier??`—`]}),(0,J.jsxs)(`span`,{children:[`escalation `,n.escalation_level||`none`]}),(0,J.jsxs)(`span`,{children:[`retry `,e.retry_count,`/`,e.max_retries]}),(0,J.jsxs)(`span`,{style:{color:j(e.verification_status)},children:[`verification `,e.verification_status]})]}),n.reason&&(0,J.jsx)(`p`,{className:`mt-1 text-[8px] text-purple-300`,children:n.reason}),e.error_json?.message&&(0,J.jsx)(`p`,{className:`mt-2 text-[8px] text-red-400`,children:e.error_json.message})]})]})},e.id)})})]}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,J.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Independent verification`}),(0,J.jsxs)(`div`,{className:`mt-3 space-y-2 max-h-64 overflow-y-auto`,children:[h.map(e=>(0,J.jsxs)(`div`,{className:`rounded border border-shogun-border p-2`,children:[(0,J.jsxs)(`div`,{className:`flex justify-between gap-2 text-[8px] uppercase`,children:[(0,J.jsx)(`b`,{children:e.verification_type.replaceAll(`_`,` `)}),(0,J.jsx)(`span`,{style:{color:j(e.status)},children:e.status})]}),(0,J.jsx)(`p`,{className:`mt-1 text-[8px] text-shogun-subdued`,children:e.observed_result}),(0,J.jsxs)(`div`,{className:`mt-1 text-[8px] text-purple-300`,children:[e.metadata_json?.verifier_mode||`evidence`,` · score `,e.metadata_json?.score??`—`]})]},e.id)),h.length===0&&(0,J.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:`No verification evidence yet.`})]})]}),(0,J.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,J.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Evidence & continuity`}),(0,J.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-center`,children:[(0,J.jsxs)(`div`,{className:`rounded bg-[#080b16] p-2`,children:[(0,J.jsx)(`b`,{className:`text-purple-300`,children:d.length}),(0,J.jsx)(`div`,{className:`text-[7px] uppercase text-shogun-subdued`,children:`checkpoints`})]}),(0,J.jsxs)(`div`,{className:`rounded bg-[#080b16] p-2`,children:[(0,J.jsx)(`b`,{className:`text-blue-300`,children:p.length}),(0,J.jsx)(`div`,{className:`text-[7px] uppercase text-shogun-subdued`,children:`artifacts`})]}),(0,J.jsxs)(`div`,{className:`rounded bg-[#080b16] p-2`,children:[(0,J.jsx)(`b`,{className:`text-green-300`,children:h.filter(e=>e.status===`passed`).length}),(0,J.jsx)(`div`,{className:`text-[7px] uppercase text-shogun-subdued`,children:`passed`})]})]}),d[0]&&(0,J.jsxs)(`div`,{className:`mt-3 rounded border border-shogun-border p-2`,children:[(0,J.jsx)(`b`,{className:`text-[8px]`,children:`Latest durable checkpoint`}),(0,J.jsx)(`p`,{className:`mt-1 line-clamp-4 whitespace-pre-wrap text-[8px] text-shogun-subdued`,children:d[0].context_summary}),(0,J.jsx)(`p`,{className:`mt-1 text-[8px] text-purple-300`,children:d[0].resume_instruction})]})]})]})]}),Object.keys(l.final_summary||{}).length>0&&(0,J.jsxs)(`section`,{className:`shogun-card !p-4`,children:[(0,J.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Final verified summary`}),(0,J.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-3 text-[9px]`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`text-shogun-subdued`,children:`Status`}),(0,J.jsx)(`p`,{style:{color:j(l.final_summary.final_status)},children:l.final_summary.final_status?.replaceAll(`_`,` `)})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`span`,{className:`text-shogun-subdued`,children:`Files changed`}),(0,J.jsx)(`p`,{children:l.final_summary.files_changed?.length||0})]}),(0,J.jsxs)(`div`,{className:`col-span-2`,children:[(0,J.jsx)(`span`,{className:`text-shogun-subdued`,children:`Known issues`}),(0,J.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap text-[8px] text-amber-300`,children:JSON.stringify(l.final_summary.known_issues||[],null,2)})]})]})]})]})]})]})}var Ip=()=>{let{ui:e}=rp(),[t,n]=(0,q.useState)(`builder`),[r,i]=(0,q.useState)(null);return(0,J.jsxs)(`div`,{className:`space-y-5 animate-in fade-in duration-500`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h2`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,J.jsx)(v,{className:`text-purple-400`}),` `,e(`flow_stacking`,`Flow Stacking`)]}),(0,J.jsx)(`p`,{className:`text-sm text-shogun-subdued mt-1`,children:e(`flow_stacking_subtitle`,`Compose AgentFlows into connected, orchestrated systems.`)})]}),(0,J.jsxs)(`div`,{className:`text-[10px] px-3 py-1.5 border border-purple-500/30 bg-purple-500/10 text-purple-300 rounded-full`,children:[`208 `,e(`built_in_stacks`,`built-in stacks`).toUpperCase()]})]}),(0,J.jsx)(`div`,{className:`flex gap-2 border border-shogun-border bg-shogun-card p-1 rounded-lg w-fit`,children:[[`builder`,w,e(`stack_builder`,`Stack Builder`).toUpperCase()],[`templates`,M,e(`stack_templates`,`Stack Templates`).toUpperCase()],[`runtime`,B,e(`orchestrator`,`Orchestrator`).toUpperCase()]].map(([e,r,i])=>(0,J.jsxs)(`button`,{onClick:()=>n(e),className:H(`flex items-center gap-2 px-4 py-2 rounded text-xs font-bold`,t===e?`bg-purple-500/20 border border-purple-400/40 text-purple-200`:`text-shogun-subdued border border-transparent`),children:[(0,J.jsx)(r,{className:`w-4 h-4`}),i]},e))}),t===`builder`&&(0,J.jsx)(Xd,{children:(0,J.jsx)(Mp,{seed:r?.template||null})},`stack-builder-${r?.revision||0}`),t===`templates`&&(0,J.jsx)(Pp,{onOpen:e=>{i(t=>({template:{...e,builder_nodes:e.builder_nodes?.map(e=>({...e})),builder_edges:e.builder_edges?.map(e=>({...e}))},revision:(t?.revision||0)+1})),n(`builder`)}}),t===`runtime`&&(0,J.jsx)(Fp,{})]})},Lp=()=>{let{t:e}=ie(),[t,n]=(0,q.useState)([]),[i,a]=(0,q.useState)([]),[o,s]=(0,q.useState)([]),[c,l]=(0,q.useState)([]),[u,d]=(0,q.useState)(!0),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(`fleet`),[_,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(null),[w,E]=(0,q.useState)({name:``,description:``,spawn_policy:`manual`,role_id:``,model_routing_profile_id:``}),[O,M]=(0,q.useState)(!1),[P,I]=(0,q.useState)(null),L=(0,q.useRef)(null),R=(0,q.useRef)(null),[te,B]=(0,q.useState)(null),[V,U]=(0,q.useState)(null),[W,ne]=(0,q.useState)(!1),[G,ae]=(0,q.useState)({name:``,slug:``,description:``,role_id:``,model_routing_profile_id:``,agent_type:`samurai`,spawn_policy:`manual`,tags:[]});(0,q.useEffect)(()=>{Yf(),$(`samurai.mount`,{build:ep(),path:window.location.pathname,href:window.location.href,width:window.innerWidth,height:window.innerHeight}),Jf(`mount-immediate`),window.setTimeout(()=>Jf(`mount-500ms`),500),window.setTimeout(()=>Jf(`mount-2000ms`),2e3),window.location.hash===`#agent-flow`?($(`samurai.hash_open_agent_flow`),h(`agent-flow`)):window.location.hash===`#flow-stack`&&h(`flow-stack`),oe()},[]),(0,q.useEffect)(()=>{$(`samurai.active_tab`,{activeTab:m}),window.setTimeout(()=>{let e=Array.from(document.querySelectorAll(`button`)).map(e=>e.textContent?.trim()).filter(Boolean).filter(e=>e===`Fleet`||e===`Agent Flow`||e===`Flow Stack`);$(`samurai.tab_dom_check`,{activeTab:m,foundTabs:e,tabCount:e.length}),Jf(`active-tab-${m}`)},0)},[m]);let oe=async()=>{d(!0),$(`samurai.fetch_all.start`);try{let[e,t,r,i]=await Promise.all([K.get(`/api/v1/agents?agent_type=samurai`),K.get(`/api/v1/missions`),K.get(`/api/v1/samurai-roles`),K.get(`/api/v1/model-routing-profiles`)]);e.data.data&&n(e.data.data),t.data.data&&a(t.data.data),r.data.data&&s(r.data.data),i.data.data&&l(i.data.data),$(`samurai.fetch_all.success`,{agents:e.data?.data?.length||0,missions:t.data?.data?.length||0,roles:r.data?.data?.length||0,routingProfiles:i.data?.data?.length||0})}catch(e){console.error(`Error fetching data:`,e),$(`samurai.fetch_all.error`,{error:e})}finally{d(!1)}},se=async()=>{let e=await Qf();e||$f(),ne(e),window.setTimeout(()=>ne(!1),2e3)},ce=e=>i.find(t=>t.assigned_agent_id===e&&[`in_progress`,`pending`,`queued`].includes(t.status)),le=e=>{if(!e?.started_at)return e?.status===`pending`||e?.status===`queued`?5:0;let t=Date.now()-new Date(e.started_at).getTime();return Math.min(95,Math.round(t/(300*1e3)*100))},ue=async e=>{e.preventDefault();try{let e=G.name.toLowerCase().replace(/\s+/g,`-`),t=await K.post(`/api/v1/agents`,{...G,slug:e,model_routing_profile_id:G.model_routing_profile_id||null});if(te&&t.data?.data?.id){let e=new FormData;e.append(`file`,te);try{await K.post(`/api/v1/agents/${t.data.data.id}/avatar`,e,{headers:{"Content-Type":`multipart/form-data`}})}catch{}}p(!1),ae({name:``,slug:``,description:``,role_id:``,model_routing_profile_id:``,agent_type:`samurai`,spawn_policy:`manual`,tags:[]}),B(null),U(null),oe()}catch(e){console.error(`Error creating agent:`,e)}},pe=async e=>{let t=e.target.files?.[0];if(!t||!b)return;let r=new FormData;r.append(`file`,t);try{let e=await K.post(`/api/v1/agents/${b.id}/avatar`,r,{headers:{"Content-Type":`multipart/form-data`}});x({...b,avatar_url:e.data.data.avatar_url}),n(t=>t.map(t=>t.id===b.id?{...t,avatar_url:e.data.data.avatar_url}:t))}catch{I(`Failed to upload avatar.`)}},me=e=>{let t=e.target.files?.[0];if(!t)return;B(t);let n=new FileReader;n.onloadend=()=>U(n.result),n.readAsDataURL(t)},ge=async(t,n)=>{try{if(n===`delete`){if(!confirm(e(`samurai_network.confirm_delete`)))return;await K.delete(`/api/v1/agents/${t}`)}else await K.post(`/api/v1/agents/${t}/${n}`);oe()}catch(e){console.error(`Error performing ${n}:`,e)}},Y=e=>{x(e),E({name:e.name||``,description:e.description||``,spawn_policy:e.spawn_policy||`manual`,role_id:e.samurai_profile?.role_id||e.samurai_profile?.samurai_role?.id||``,model_routing_profile_id:e.model_routing_profile_id||``}),I(null)},X=async()=>{if(b){M(!0),I(null);try{await K.patch(`/api/v1/agents/${b.id}`,{name:w.name,description:w.description,spawn_policy:w.spawn_policy,model_routing_profile_id:w.model_routing_profile_id||null,...w.role_id?{role_id:w.role_id}:{}}),x(null),oe()}catch(t){I(t?.response?.data?.detail||e(`samurai_network.save_failed`))}finally{M(!1)}}},_e=e=>e.routing_profile?.name||null,ve=t.filter(e=>e.name.toLowerCase().includes(_.toLowerCase())||e.slug.toLowerCase().includes(_.toLowerCase())),ye=e=>{$(`samurai.tab_click`,{tab:e}),h(e),window.history.replaceState(null,``,e===`fleet`?window.location.pathname:`#${e}`),window.setTimeout(()=>Jf(`tab-click-${e}`),0)};return(0,J.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 pb-12`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`h2`,{className:`text-3xl font-bold shogun-title flex items-center gap-3`,children:[e(`samurai_network.title`,`Samurai Network`),(0,J.jsx)(`span`,{className:`text-[10px] font-normal text-shogun-subdued bg-shogun-card px-2 py-0.5 rounded border border-shogun-border tracking-[0.2em] uppercase`,children:e(`samurai_network.fleet_status`)})]}),(0,J.jsx)(`p`,{className:`text-shogun-subdued text-sm mt-1`,children:e(`samurai_network.subtitle`,`Orchestrate specialized sub-agents across the mission grid.`)})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`button`,{onClick:se,className:`flex items-center gap-2 bg-shogun-card border border-shogun-border hover:border-shogun-blue text-shogun-subdued hover:text-shogun-blue font-bold py-2.5 px-3 rounded-lg transition-all text-[10px] uppercase tracking-widest`,title:`Copy Samurai diagnostics`,children:[(0,J.jsx)(de,{className:`w-3.5 h-3.5`}),W?`Copied`:`Copy Diagnostics`]}),(0,J.jsx)(`button`,{onClick:$f,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,title:`Download Samurai diagnostics`,children:(0,J.jsx)(z,{className:`w-4 h-4`})}),(0,J.jsx)(`button`,{onClick:Xf,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-red-400 transition-colors text-[10px] font-bold`,title:`Clear Samurai diagnostics`,children:`CLR`}),m===`fleet`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{onClick:oe,className:`p-2.5 bg-shogun-card border border-shogun-border rounded-lg text-shogun-subdued hover:text-shogun-gold transition-colors`,children:(0,J.jsx)(D,{className:H(`w-4 h-4`,u&&`animate-spin`)})}),(0,J.jsxs)(`button`,{onClick:()=>p(!0),className:`flex items-center gap-2 bg-shogun-blue hover:bg-shogun-blue/90 text-white font-bold py-2.5 px-6 rounded-lg transition-all shadow-shogun`,children:[(0,J.jsx)(T,{className:`w-4 h-4`}),` `,e(`samurai_network.deploy_samurai`,`DEPLOY SAMURAI`)]})]})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 border border-shogun-border bg-shogun-card p-1 rounded-lg w-fit`,children:[(0,J.jsxs)(`button`,{onClick:()=>ye(`fleet`),className:H(`flex items-center gap-2 px-5 py-3 text-xs font-bold uppercase tracking-wider transition-all rounded-md border`,m===`fleet`?`text-black bg-shogun-gold border-shogun-gold shadow-shogun`:`text-shogun-subdued border-transparent hover:text-shogun-text hover:border-shogun-border`),children:[(0,J.jsx)(re,{className:`w-4 h-4`}),e(`samurai_network.tab_fleet`,`Fleet`)]}),(0,J.jsxs)(`button`,{onClick:()=>ye(`agent-flow`),className:H(`flex items-center gap-2 px-5 py-3 text-xs font-bold uppercase tracking-wider transition-all rounded-md border`,m===`agent-flow`?`text-black bg-shogun-gold border-shogun-gold shadow-shogun`:`text-shogun-subdued border-transparent hover:text-shogun-text hover:border-shogun-border`),children:[(0,J.jsx)(g,{className:`w-4 h-4`}),e(`samurai_network.tab_agent_flow`,`Agent Flow`)]}),(0,J.jsxs)(`button`,{onClick:()=>ye(`flow-stack`),className:H(`flex items-center gap-2 px-5 py-3 text-xs font-bold uppercase tracking-wider transition-all rounded-md border`,m===`flow-stack`?`text-black bg-shogun-gold border-shogun-gold shadow-shogun`:`text-shogun-subdued border-transparent hover:text-shogun-text hover:border-shogun-border`),children:[(0,J.jsx)(v,{className:`w-4 h-4`}),`Flow Stack`]})]}),m===`agent-flow`&&(0,J.jsx)(Ep,{}),m===`flow-stack`&&(0,J.jsx)(Ip,{}),m===`fleet`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-4 gap-6`,children:[{label:e(`samurai_network.total_fleet`,`Total Fleet`),value:t.length.toString(),icon:re,color:`text-shogun-gold`},{label:e(`samurai_network.active`,`Active`),value:t.filter(e=>e.status===`active`).length.toString(),icon:C,color:`text-green-500`},{label:e(`samurai_network.suspended`,`Suspended`),value:t.filter(e=>e.status===`suspended`).length.toString(),icon:S,color:`text-shogun-blue`},{label:e(`samurai_network.signal_range`,`Signal Range`),value:`100%`,icon:he,color:`text-shogun-subdued`}].map((e,t)=>(0,J.jsxs)(`div`,{className:`shogun-card flex flex-col gap-1 border-l-2`,style:{borderLeftColor:t===0?`#d4a017`:t===1?`#22c55e`:t===2?`#4a8cc7`:`#1a2040`},children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-shogun-subdued mb-1`,children:[(0,J.jsx)(e.icon,{className:H(`w-3 h-3`,e.color)}),(0,J.jsx)(`span`,{className:`text-[9px] uppercase tracking-widest font-bold`,children:e.label})]}),(0,J.jsx)(`span`,{className:`text-2xl font-bold text-shogun-text`,children:e.value})]},t))}),(0,J.jsxs)(`div`,{className:`shogun-card overflow-hidden !p-0`,children:[(0,J.jsxs)(`div`,{className:`p-4 border-b border-shogun-border bg-[#050508]/50 flex items-center justify-between gap-4`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1 max-w-md`,children:[(0,J.jsx)(A,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-shogun-subdued`}),(0,J.jsx)(`input`,{type:`text`,placeholder:e(`samurai_network.filter_placeholder`),value:_,onChange:e=>y(e.target.value),className:`w-full bg-shogun-card border border-shogun-border rounded-lg pl-10 pr-4 py-2 text-sm focus:border-shogun-blue transition-colors outline-none`})]}),(0,J.jsxs)(`select`,{className:`bg-shogun-card border border-shogun-border rounded-lg px-3 py-2 text-xs text-shogun-subdued outline-none focus:border-shogun-blue`,children:[(0,J.jsx)(`option`,{children:e(`samurai_network.all_status`)}),(0,J.jsx)(`option`,{children:e(`samurai_network.status_active`)}),(0,J.jsx)(`option`,{children:e(`samurai_network.status_suspended`)})]})]}),(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`w-full text-left border-collapse`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{className:`border-b border-shogun-border bg-[#050508]/30`,children:[(0,J.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_designation`,`Designation`)}),(0,J.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_status`,`Status`)}),(0,J.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_task`,`Current Task`)}),(0,J.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_role`,`Role / Slug`)}),(0,J.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_routing`,`Routing`)}),(0,J.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai.table_deployed`,`Deployed At`)}),(0,J.jsx)(`th`,{className:`p-4 text-[10px] font-bold text-shogun-subdued uppercase tracking-widest text-right`,children:e(`common.actions`,`Actions`)})]})}),(0,J.jsx)(`tbody`,{children:u?(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:7,className:`p-12 text-center`,children:(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`w-6 h-6 border-2 border-shogun-gold border-t-transparent rounded-full animate-spin`}),(0,J.jsx)(`span`,{className:`text-xs text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.scanning_grid`)})]})})}):ve.length===0?(0,J.jsx)(`tr`,{children:(0,J.jsx)(`td`,{colSpan:7,className:`p-12 text-center text-shogun-subdued text-sm italic`,children:e(`samurai_network.no_samurai`)})}):ve.map(t=>{let n=_e(t);return(0,J.jsxs)(`tr`,{className:`border-b border-shogun-border hover:bg-shogun-gold/5 transition-colors group`,children:[(0,J.jsx)(`td`,{className:`p-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsxs)(`div`,{className:`w-10 h-10 rounded-lg bg-shogun-card border border-shogun-border flex items-center justify-center text-shogun-gold font-bold relative overflow-hidden`,children:[t.avatar_url&&t.avatar_url!==`/shogun-avatar.png`?(0,J.jsx)(`img`,{src:t.avatar_url,alt:t.name,className:`w-full h-full object-cover`}):t.name[0],(0,J.jsx)(`div`,{className:`absolute -top-1 -right-1 w-4 h-4 rounded-full bg-shogun-blue border border-[#0a0e1a] flex items-center justify-center`,children:(0,J.jsx)(re,{className:`w-2 h-2 text-white`})})]}),(0,J.jsxs)(`div`,{className:`flex flex-col`,children:[(0,J.jsx)(`span`,{className:`font-bold text-shogun-text text-sm`,children:t.name}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-tighter`,children:[`ID: `,t.id.slice(0,8)]}),t.samurai_profile?.samurai_role&&(0,J.jsx)(`span`,{className:`text-[9px] bg-shogun-blue/10 text-shogun-blue px-1.5 py-0.5 rounded border border-shogun-blue/20 font-bold uppercase tracking-widest`,children:t.samurai_profile.samurai_role.name})]})]})]})}),(0,J.jsx)(`td`,{className:`p-4`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:H(`w-1.5 h-1.5 rounded-full`,t.status===`active`?`bg-green-500`:`bg-shogun-blue`)}),(0,J.jsx)(`span`,{className:H(`text-[10px] font-bold uppercase tracking-widest`,t.status===`active`?`text-green-500`:`text-shogun-blue`),children:t.status===`active`?e(`samurai_network.status_active`):e(`samurai_network.status_suspended`)})]})}),(0,J.jsx)(`td`,{className:`p-4`,children:(()=>{let n=ce(t.id);if(!n)return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-shogun-subdued/40`}),(0,J.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:e(`samurai_network.idle`)})]});let r=le(n);return(0,J.jsxs)(`div`,{className:`space-y-1.5 min-w-[180px]`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text truncate max-w-[160px]`,title:n.title,children:n.title}),(0,J.jsxs)(`span`,{className:`text-[9px] font-mono font-bold text-shogun-gold shrink-0`,children:[r,`%`]})]}),(0,J.jsx)(`div`,{className:`w-full h-1.5 bg-[#0a0e1a] rounded-full overflow-hidden`,children:(0,J.jsx)(`div`,{className:H(`h-full rounded-full transition-all duration-700`,r<30?`bg-gradient-to-r from-shogun-blue to-shogun-blue/70`:r<70?`bg-gradient-to-r from-shogun-blue via-shogun-gold/60 to-shogun-gold`:`bg-gradient-to-r from-shogun-gold to-green-400`),style:{width:`${r}%`}})})]})})()}),(0,J.jsx)(`td`,{className:`p-4`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`code`,{className:`text-[10px] bg-shogun-card px-2 py-1 rounded border border-shogun-border text-shogun-blue w-fit`,children:t.slug}),t.samurai_profile?.samurai_role?.purpose&&(0,J.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic line-clamp-1 max-w-[150px]`,children:t.samurai_profile.samurai_role.purpose})]})}),(0,J.jsx)(`td`,{className:`p-4`,children:n?(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(F,{className:`w-3 h-3 text-shogun-gold/70 shrink-0`}),(0,J.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-gold/90 truncate max-w-[120px]`,title:n,children:n})]}):(0,J.jsx)(`span`,{className:`text-[10px] text-shogun-subdued italic`,children:e(`samurai_network.default_routing`)})}),(0,J.jsx)(`td`,{className:`p-4 text-xs text-shogun-subdued`,children:new Date(t.created_at).toLocaleDateString()}),(0,J.jsx)(`td`,{className:`p-4 text-right`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:[t.status===`active`?(0,J.jsx)(`button`,{onClick:()=>ge(t.id,`suspend`),className:`p-1.5 hover:bg-shogun-blue/10 text-shogun-blue rounded transition-colors`,title:e(`samurai_network.suspend_agent`),children:(0,J.jsx)(S,{className:`w-3.5 h-3.5`})}):(0,J.jsx)(`button`,{onClick:()=>ge(t.id,`resume`),className:`p-1.5 hover:bg-green-500/10 text-green-500 rounded transition-colors`,title:e(`samurai_network.resume_agent`),children:(0,J.jsx)(C,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(`button`,{onClick:()=>ge(t.id,`delete`),className:`p-1.5 hover:bg-red-500/10 text-red-500 rounded transition-colors`,title:e(`samurai_network.delete_agent`),children:(0,J.jsx)(N,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(`button`,{onClick:()=>Y(t),className:`p-1.5 hover:bg-shogun-gold/10 text-shogun-gold rounded transition-colors`,title:e(`samurai_network.configure_samurai`),children:(0,J.jsx)(fe,{className:`w-3.5 h-3.5`})})]})})]},t.id)})})]})})]}),b&&(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-200`,onClick:e=>{e.target===e.currentTarget&&x(null)},children:(0,J.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-shogun-border rounded-xl w-full max-w-lg shadow-2xl overflow-hidden animate-in zoom-in-95 duration-200`,children:[(0,J.jsxs)(`div`,{className:`bg-shogun-card border-b border-shogun-border p-6 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsxs)(`div`,{onClick:()=>L.current?.click(),className:`w-14 h-14 rounded-xl bg-[#050508] border border-shogun-border flex items-center justify-center text-shogun-gold font-bold text-lg relative cursor-pointer group hover:border-shogun-gold/50 transition-all overflow-hidden shrink-0`,children:[b.avatar_url&&b.avatar_url!==`/shogun-avatar.png`?(0,J.jsx)(`img`,{src:b.avatar_url,alt:b.name,className:`w-full h-full object-cover`}):b.name[0],(0,J.jsx)(`div`,{className:`absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(r,{className:`w-4 h-4 text-shogun-gold`})})]}),(0,J.jsx)(`input`,{type:`file`,ref:L,className:`hidden`,accept:`image/*`,onChange:pe}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(j,{className:`w-4 h-4 text-shogun-gold`}),(0,J.jsx)(`h3`,{className:`text-lg font-bold text-shogun-gold`,children:e(`samurai_network.configure_samurai`)})]}),(0,J.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold mt-1`,children:[b.name,` · `,(0,J.jsx)(`span`,{className:`font-mono`,children:b.id.slice(0,8)})]})]})]}),(0,J.jsx)(`button`,{onClick:()=>x(null),className:`p-2 hover:bg-shogun-gold/10 text-shogun-subdued hover:text-shogun-gold rounded-lg transition-colors`,children:(0,J.jsx)(ee,{className:`w-4 h-4`})})]}),(0,J.jsxs)(`div`,{className:`p-6 space-y-5`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.unit_name`)}),(0,J.jsx)(`input`,{type:`text`,value:w.name,onChange:e=>E({...w,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.designation_role`)}),(0,J.jsxs)(`select`,{value:w.role_id,onChange:e=>E({...w,role_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:e(`samurai_network.keep_current_role`)}),o.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),b.samurai_profile?.samurai_role?.name&&(0,J.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[e(`samurai_network.current`),`: `,(0,J.jsx)(`span`,{className:`text-shogun-blue font-bold`,children:b.samurai_profile.samurai_role.name})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,J.jsx)(F,{className:`w-3 h-3 text-shogun-gold/70`}),` `,e(`samurai_network.routing_profile`)]}),(0,J.jsxs)(`select`,{value:w.model_routing_profile_id,onChange:e=>E({...w,model_routing_profile_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:e(`samurai_network.system_default`)}),c.map(t=>(0,J.jsxs)(`option`,{value:t.id,children:[t.name,t.is_default?` (${e(`samurai_network.default_routing`)})`:``]},t.id))]}),b.routing_profile?.name&&(0,J.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued`,children:[e(`samurai_network.current`),`: `,(0,J.jsx)(`span`,{className:`text-shogun-gold font-bold`,children:b.routing_profile.name})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.spawn_policy`)}),(0,J.jsxs)(`select`,{value:w.spawn_policy,onChange:e=>E({...w,spawn_policy:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-gold transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`manual`,children:e(`samurai_network.manual_deploy`)}),(0,J.jsx)(`option`,{value:`auto`,children:e(`samurai_network.auto_spawn`)}),(0,J.jsx)(`option`,{value:`scheduled`,children:e(`samurai_network.scheduled_routine`)})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.operational_directive`)}),(0,J.jsx)(`textarea`,{value:w.description,onChange:e=>E({...w,description:e.target.value}),rows:3,className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-xs focus:border-shogun-gold transition-colors outline-none resize-none`,placeholder:e(`samurai_network.directive_placeholder`)})]}),P&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 p-3 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,J.jsx)(ee,{className:`w-3.5 h-3.5 text-red-400 shrink-0`}),(0,J.jsx)(`p`,{className:`text-xs text-red-400`,children:P})]})]}),(0,J.jsxs)(`div`,{className:`p-6 pt-0 flex gap-3`,children:[(0,J.jsx)(`button`,{onClick:()=>x(null),className:`flex-1 bg-shogun-card hover:bg-[#1a2040] text-shogun-subdued font-bold py-2.5 rounded-lg transition-all border border-shogun-border text-sm`,children:e(`common.cancel`)}),(0,J.jsxs)(`button`,{onClick:X,disabled:O||!w.name.trim(),className:H(`flex-1 font-bold py-2.5 rounded-lg transition-all text-sm flex items-center justify-center gap-2`,O||!w.name.trim()?`bg-shogun-subdued/20 text-shogun-subdued cursor-not-allowed`:`bg-shogun-gold hover:bg-shogun-gold/90 text-black shadow-shogun`),children:[O?(0,J.jsx)(D,{className:`w-3.5 h-3.5 animate-spin`}):(0,J.jsx)(k,{className:`w-3.5 h-3.5`}),e(O?`samurai_network.saving`:`samurai_network.save_changes`)]})]})]})}),f&&(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-300`,onClick:e=>{e.target===e.currentTarget&&p(!1)},children:(0,J.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-shogun-border rounded-xl w-full max-w-lg shadow-2xl overflow-hidden animate-in zoom-in-95 duration-300`,children:[(0,J.jsxs)(`div`,{className:`bg-shogun-card border-b border-shogun-border p-6 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsxs)(`div`,{onClick:()=>R.current?.click(),className:`w-14 h-14 rounded-xl bg-[#050508] border border-dashed border-shogun-border flex items-center justify-center relative cursor-pointer group hover:border-shogun-gold/50 transition-all overflow-hidden shrink-0`,children:[V?(0,J.jsx)(`img`,{src:V,alt:`Avatar preview`,className:`w-full h-full object-cover`}):(0,J.jsx)(r,{className:`w-5 h-5 text-shogun-subdued group-hover:text-shogun-gold transition-colors`}),V&&(0,J.jsx)(`div`,{className:`absolute inset-0 bg-black/50 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,J.jsx)(r,{className:`w-4 h-4 text-shogun-gold`})})]}),(0,J.jsx)(`input`,{type:`file`,ref:R,className:`hidden`,accept:`image/*`,onChange:me}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-xl font-bold text-shogun-gold`,children:e(`samurai_network.deploy_new`)}),(0,J.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest font-bold mt-1`,children:e(`samurai_network.initialize_fleet`)})]})]}),(0,J.jsx)(`button`,{onClick:()=>{p(!1),B(null),U(null)},className:`p-2 hover:bg-shogun-gold/10 text-shogun-subdued hover:text-shogun-gold rounded-lg transition-colors`,children:(0,J.jsx)(ee,{className:`w-4 h-4`})})]}),(0,J.jsxs)(`form`,{onSubmit:ue,className:`p-6 space-y-5`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.samurai_designation`)}),(0,J.jsxs)(`select`,{required:!0,value:G.role_id,onChange:e=>{let t=o.find(t=>t.id===e.target.value);t&&ae({...G,role_id:t.id,name:t.name,description:t.description||t.purpose})},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,disabled:!0,children:e(`samurai_network.select_role`)}),o.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.custom_unit_name`)}),(0,J.jsx)(`input`,{type:`text`,required:!0,value:G.name,onChange:e=>ae({...G,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none`,placeholder:`e.g. Shadow Scout`})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.spawn_policy`)}),(0,J.jsxs)(`select`,{value:G.spawn_policy,onChange:e=>ae({...G,spawn_policy:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:`manual`,children:e(`samurai_network.manual_deploy`)}),(0,J.jsx)(`option`,{value:`auto`,children:e(`samurai_network.auto_spawn`)}),(0,J.jsx)(`option`,{value:`scheduled`,children:e(`samurai_network.scheduled_routine`)})]})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsxs)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest flex items-center gap-1.5`,children:[(0,J.jsx)(F,{className:`w-3 h-3 text-shogun-gold/70`}),` `,e(`samurai_network.model_routing_profile`)]}),(0,J.jsxs)(`select`,{value:G.model_routing_profile_id,onChange:e=>ae({...G,model_routing_profile_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2.5 text-sm focus:border-shogun-blue transition-colors outline-none cursor-pointer`,children:[(0,J.jsx)(`option`,{value:``,children:e(`samurai_network.system_default`)}),c.map(t=>(0,J.jsxs)(`option`,{value:t.id,children:[t.name,t.is_default?` (${e(`samurai_network.default_routing`)})`:``]},t.id))]}),(0,J.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:e(`samurai_network.routing_description`)})]}),(0,J.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,J.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:e(`samurai_network.operational_directive`)}),(0,J.jsx)(`textarea`,{value:G.description,onChange:e=>ae({...G,description:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-xs focus:border-shogun-blue transition-colors outline-none h-24 resize-none`,placeholder:e(`samurai_network.auto_populate_placeholder`)})]}),(0,J.jsxs)(`div`,{className:`flex gap-3 pt-1`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>p(!1),className:`flex-1 bg-shogun-card hover:bg-[#1a2040] text-shogun-subdued font-bold py-3 rounded-lg transition-all border border-shogun-border`,children:e(`samurai_network.abort`)}),(0,J.jsx)(`button`,{type:`submit`,disabled:!G.name||!G.role_id,className:H(`flex-1 font-bold py-3 rounded-lg transition-all shadow-shogun`,!G.name||!G.role_id?`bg-shogun-subdued/20 text-shogun-subdued cursor-not-allowed`:`bg-shogun-blue hover:bg-shogun-blue/90 text-white`),children:e(`samurai_network.deploy_samurai_btn`)})]})]})]})})]})]})};export{Lp as SamuraiNetwork}; \ No newline at end of file diff --git a/frontend/dist/assets/SetupWizard-BoGxsHE2.js b/frontend/dist/assets/SetupWizard-BoGxsHE2.js deleted file mode 100644 index 576d90d..0000000 --- a/frontend/dist/assets/SetupWizard-BoGxsHE2.js +++ /dev/null @@ -1,93 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{t as i}from"./camera-DjFKI4Th.js";import{t as a}from"./check-CBVCj3hp.js";import{t as o}from"./chevron-left-BFAWv4As.js";import{t as s}from"./chevron-right-BzAY5P9l.js";import{t as c}from"./circle-alert-DVHRBFRQ.js";import{t as l}from"./circle-check-D9mntLsp.js";import{t as u}from"./cpu-jON2DlCR.js";import{t as ee}from"./crosshair-IDZ5dQs8.js";import{t as te}from"./database-B_RLhoAx.js";import{t as ne}from"./file-text-Db8l8y7y.js";import{t as re}from"./folder-open-C_e4r6rd.js";import{t as ie}from"./globe-CSe1LLSr.js";import{t as ae}from"./grip-vertical-DIOTevc1.js";import{t as oe}from"./hard-drive-CKvWVafA.js";import{t as se}from"./keyboard-Cb4Fcm9X.js";import{t as d}from"./loader-circle-yHzGFbgr.js";import{t as ce}from"./monitor-DhSxAiCm.js";import{t as le}from"./scroll-text-IcbZPPfm.js";import{t as ue}from"./server-CMY38Yt2.js";import{t as de}from"./settings-DYFQa-lL.js";import{t as f}from"./shield-B_MY4jWU.js";import{t as fe}from"./sparkles-DddBjN-5.js";import{t as pe}from"./triangle-alert-BwzZbklP.js";import{t as me}from"./user-plus-DNXtLt6r.js";import{t as p}from"./user-Dr0R8XdF.js";import{t as he}from"./users-D7R1ctQe.js";import{t as m}from"./x-Bu7rztmN.js";import{t as ge}from"./zap-BMpqZS6N.js";import{r as _e,t as h}from"./i18n-FxgwkwP0.js";import{t as g}from"./axios-BPyV2soB.js";var ve=e(`mouse`,[[`rect`,{x:`5`,y:`2`,width:`14`,height:`20`,rx:`7`,key:`11ol66`}],[`path`,{d:`M12 6v4`,key:`16clxf`}]]),_=t(n(),1),v=r(),y=9,ye=[{type:`openai`,label:`OpenAI`,icon:`⚡`,color:`#10a37f`},{type:`anthropic`,label:`Anthropic`,icon:`🧠`,color:`#d4a017`},{type:`google`,label:`Google Gemini`,icon:`✨`,color:`#4285f4`},{type:`ollama`,label:`Ollama`,icon:`🦙`,color:`#ffffff`},{type:`openrouter`,label:`OpenRouter`,icon:`🌐`,color:`#6366f1`},{type:`perplexity`,label:`Perplexity`,icon:`🔍`,color:`#20b2aa`}],be=[{id:`ultra_economy`,name:`Ultra Economy`,description:`Lowest cost; strongly prefers local and cheap models.`},{id:`economy`,name:`Economy`,description:`Low-cost daily work with practical escalation.`},{id:`balanced`,name:`Balanced`,description:`Recommended balance of cost, speed, and quality.`},{id:`high_capability`,name:`High Capability`,description:`Uses stronger models earlier for complex work.`},{id:`premium`,name:`Premium`,description:`Maximum configured quality with visible cost controls.`},{id:`custom`,name:`Custom`,description:`Use only your ordered model selection with capability and safety gates.`}],xe=`priorities: - - Safety before autonomy - - Use existing trusted skills when possible - - Escalate ambiguous high-risk actions - - Maintain stealth in network operations - -operational_constraints: - - shell_access: restricted_to_container - - memory_retention: long_term - - verification_threshold: 0.85 - -delegation_rules: - - research: delegate_to_samurai - - coding: delegate_to_samurai - - tactical_analysis: shogun_priority`,Se=`# SHOGUN SYSTEM CONSTITUTION -# --- Global Behavioral Principles --- - -core_directives: - - id: zero_harm - rule: "Operations must not compromise host system integrity." - severity: CRITICAL - - - id: transparency - rule: "All autonomous spawns must be logged to the Torii registry." - severity: HIGH - - - id: human_oversight - rule: "No irreversible actions without human approval." - severity: BALANCED - -autonomy_limits: - max_recursion_depth: 3 - prohibited_tools: - - shell_rm_root - - network_sniffing - approval_required: true - -data_sovereignty: - retention_policy: episodic_decay - privacy_tier: maximal`,Ce=`# The Mandate - -## Title -**Shogun — Primary Orchestrator** - -## Mandate Statement - -You are the primary orchestrating AI of the Shogun platform. - -Your responsibility is to ensure that all operations, agents, and workflows are coordinated, efficient, and aligned with the operator's objectives. - ---- - -## Core Objective - -Maintain operational excellence across the Samurai network. Ensure that sub-agents are effectively deployed, monitored, and guided toward their assigned tasks. - ---- - -## Operating Principles - -### Relevance over volume -Focus on meaningful work, not busy work. - -### Clarity over complexity -Communicate clearly and concisely. - -### Stewardship over passivity -Proactively maintain the system, don't merely observe. - -### Trust over hype -Reliability and consistency build trust.`,b=({onComplete:e})=>{let{t,language:n,setLanguage:r}=_e(),[b,we]=(0,_.useState)(1),[Te,Ee]=(0,_.useState)(`left`),[x,De]=(0,_.useState)(n),[S,Oe]=(0,_.useState)(`Daimyo`),[C,ke]=(0,_.useState)(`single`),[w,T]=(0,_.useState)([]),Ae=()=>T(e=>[...e,{id:crypto.randomUUID(),display_name:``,email:``,channel:`telegram`,telegram_user_id:``,teams_aad_object_id:``,teams_user_principal_name:``}]),E=(e,t)=>{T(n=>n.map(n=>n.id===e?{...n,...t}:n))},je=C===`single`||S.trim().length>0&&w.length>0&&w.every(e=>e.display_name.trim().length>0&&(e.channel===`telegram`?e.telegram_user_id.trim().length>0:e.teams_aad_object_id.trim().length>0||e.teams_user_principal_name.trim().length>0)),Me=e=>{De(e),r(e)},[Ne,Pe]=(0,_.useState)(``),[D,Fe]=(0,_.useState)(`Shogun Prime`),[Ie,Le]=(0,_.useState)(`Master orchestrator of the Samurai Network.`),[Re,ze]=(0,_.useState)(``),[O,Be]=(0,_.useState)([]),[k,A]=(0,_.useState)(50),[j,Ve]=(0,_.useState)(`analytical`),[M,He]=(0,_.useState)(`medium`),[Ue,We]=(0,_.useState)(`medium`),[Ge,Ke]=(0,_.useState)(`medium`),[qe,Je]=(0,_.useState)(`balanced`),[N,Ye]=(0,_.useState)(`balanced`),[Xe,Ze]=(0,_.useState)(`focused`),[Qe,$e]=(0,_.useState)(xe),[P,F]=(0,_.useState)([]),[et,I]=(0,_.useState)(``),[tt,nt]=(0,_.useState)(Se),[rt,it]=(0,_.useState)(Ce),[L,at]=(0,_.useState)(`custom`),[R,ot]=(0,_.useState)(``),[z,B]=(0,_.useState)([]),[V,st]=(0,_.useState)(!1),[H,U]=(0,_.useState)(null),[ct,lt]=(0,_.useState)(!1),[W,G]=(0,_.useState)(null),[ut,dt]=(0,_.useState)(!1),[ft,pt]=(0,_.useState)(!1),[K,mt]=(0,_.useState)(!1),[ht,gt]=(0,_.useState)(!1),[_t,vt]=(0,_.useState)(null);(0,_.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.allSettled([g.get(`/api/v1/setup/status`),g.get(`/api/v1/personas`)]);if(e.status===`fulfilled`){Pe(e.value.data.data?.data_path||``),pt(e.value.data.data?.deployment_mode===`server`);let t=e.value.data.data?.language;t&&h.some(e=>e.code===t)&&(De(t),r(t))}t.status===`fulfilled`&&Be(t.value.data.data||[])}catch{}})()},[r]);let q=(e,n)=>Object.entries(n).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),t(e)),J=be.map(e=>({...e,name:t(`setup.routing_${e.id}`),description:t(`setup.routing_${e.id}_desc`)})),Y=(0,_.useCallback)(()=>{be+1))},[b]),X=(0,_.useCallback)(()=>{b>1&&(Ee(`right`),we(e=>e-1))},[b]),yt=e=>{if(P.find(t=>t.provider_type===e)){I(e);return}let t=ye.find(t=>t.type===e)?.label||e,n=[`ollama`,`lmstudio`,`local`].includes(e);F(r=>[...r,{id:crypto.randomUUID(),provider_type:e,name:t,api_key:``,base_url:n?`http://127.0.0.1:11434`:``,models:[],discoveredModels:[],status:`pending`,auth_type:n?`none`:`api_key`}]),I(e)},Z=(e,t)=>{F(n=>n.map(n=>n.id===e?{...n,...t}:n))},bt=e=>{F(t=>t.filter(t=>t.id!==e)),I(``)},xt=async e=>{Z(e.id,{status:`testing`});let t=[`ollama`,`lmstudio`,`local`].includes(e.provider_type),n=e.base_url||{openai:`https://api.openai.com`,anthropic:`https://api.anthropic.com`,google:`https://generativelanguage.googleapis.com`,openrouter:`https://openrouter.ai/api`,perplexity:`https://api.perplexity.ai`}[e.provider_type]||``;try{let r={"Content-Type":`application/json`};e.api_key&&(r.Authorization=`Bearer ${e.api_key}`);let i=t?`${n}/api/tags`:`${n}/v1/models`,a=await fetch(i,{headers:r,signal:AbortSignal.timeout(8e3)});if(a.ok){let n=await a.json(),r=[];t&&n.models?r=n.models.map(e=>e.name||e.model).filter(Boolean):n.data&&(r=n.data.map(e=>e.id).filter(Boolean)),Z(e.id,{status:`connected`,discoveredModels:r})}else e.api_key||t?Z(e.id,{status:`connected`}):Z(e.id,{status:`failed`})}catch{e.api_key||t?Z(e.id,{status:`connected`}):Z(e.id,{status:`failed`})}},Q=P.filter(e=>e.status===`connected`).flatMap(e=>(e.models.length>0?e.models:[e.name]).map(t=>({value:`${e.id}::${t}`,label:t,group:`${e.provider_type.toUpperCase()} — ${e.name}`}))),St=e=>{ze(e);let t=O.find(t=>t.id===e);if(t&&(t.tone&&Ve(t.tone),t.risk_tolerance&&He(t.risk_tolerance),t.verbosity&&We(t.verbosity),t.planning_depth&&Ke(t.planning_depth),t.tool_usage_style&&Je(t.tool_usage_style),t.security_bias&&Ye(t.security_bias),t.memory_style&&Ze(t.memory_style),t.autonomy))if(t.autonomy===`low`||t.autonomy===`guarded`)A(25);else if(t.autonomy===`medium`||t.autonomy===`tactical`)A(50);else if(t.autonomy===`high`||t.autonomy===`campaign`)A(75);else if(t.autonomy===`critical`||t.autonomy===`ronin`)A(100);else{let e=parseInt(t.autonomy);isNaN(e)||A(e)}},Ct=async()=>{mt(!0),vt(null);try{await g.post(`/api/v1/setup/complete`,{language:x,operator_name:S,installation_mode:C,team_members:C===`team`?[{display_name:S,is_primary:!0,channel:`web`},...w.map(e=>({display_name:e.display_name,email:e.email||null,is_primary:!1,channel:e.channel,telegram_user_id:e.channel===`telegram`?e.telegram_user_id:null,teams_aad_object_id:e.channel===`microsoft_teams`&&e.teams_aad_object_id||null,teams_user_principal_name:e.channel===`microsoft_teams`&&e.teams_user_principal_name||null}))]:[],data_path:Ne,agent_name:D,description:Ie,persona_id:Re||null,autonomy:k,tone:j,risk_tolerance:M,verbosity:Ue,planning_depth:Ge,tool_usage_style:qe,security_bias:N,memory_style:Xe,behavioral_directives:Qe,providers:P.filter(e=>e.status===`connected`).map(e=>({provider_type:e.provider_type,name:e.name,auth_type:e.auth_type,api_key:e.api_key||null,base_url:e.base_url||null,models:e.models})),constitution:tt,mandate:rt,primary_model:R,fallback_models:z,routing_profile:L,ronin_enabled:V}),localStorage.setItem(`shogun_language`,x),localStorage.setItem(`shogun_operator_name`,S),gt(!0),setTimeout(()=>{e()},2500)}catch(e){console.error(`Setup failed:`,e);let n=t(`setup.completion_error_help`);if(g.isAxiosError(e)){let t=e.response?.data?.detail;typeof t==`string`&&t.trim()&&(n=t)}vt(n),mt(!1)}},wt=()=>(0,v.jsx)(`div`,{className:`flex items-center justify-center gap-1 mb-8`,children:Array.from({length:y},(e,t)=>{let n=t+1,r=n(0,v.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none transition-colors ${r}`,children:n});return(0,v.jsxs)(`div`,{className:`fixed inset-0 bg-[#0a0e1a] text-white overflow-y-auto z-50`,children:[(0,v.jsx)(`div`,{className:`fixed inset-0 opacity-[0.03] pointer-events-none`,style:{backgroundImage:`linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px)`,backgroundSize:`40px 40px`}}),(0,v.jsxs)(`div`,{className:`relative max-w-5xl mx-auto px-6 py-10`,children:[(0,v.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,v.jsx)(`h1`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-[0.3em]`,children:t(`setup.wizard_title`)}),(0,v.jsx)(`p`,{className:`text-[11px] text-[#555] mt-1`,children:q(`setup.progress`,{current:b,total:y})})]}),(0,v.jsx)(wt,{}),(0,v.jsx)(`div`,{className:`animate-in ${Te===`left`?`slide-in-from-right-5`:`slide-in-from-left-5`} fade-in duration-400`,children:(()=>{switch(b){case 1:return(0,v.jsxs)(`div`,{className:`space-y-8`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(ie,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step1_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.step1_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step1_explainer`)})}),(0,v.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-5 lg:grid-cols-7 gap-3 max-w-4xl mx-auto`,children:h.map(e=>(0,v.jsxs)(`button`,{onClick:()=>Me(e.code),className:` - p-4 rounded-xl border-2 transition-all duration-300 text-center group hover:scale-[1.03] - ${x===e.code?`border-[#d4a017] bg-[#d4a017]/10 shadow-[0_0_20px_rgba(212,160,23,0.15)]`:`border-[#2a2f3e] bg-[#0d1117] hover:border-[#3b82f6]/50`} - `,children:[(0,v.jsx)(`span`,{className:`text-2xl block mb-2`,children:e.flag}),(0,v.jsx)(`span`,{className:`text-sm font-bold text-white block`,children:e.name}),(0,v.jsx)(`span`,{className:`text-[10px] text-[#666] block mt-0.5`,children:e.englishName}),x===e.code&&(0,v.jsx)(l,{className:`w-4 h-4 text-[#d4a017] mx-auto mt-2`})]},e.code))}),(0,v.jsxs)(`div`,{className:`max-w-3xl mx-auto pt-4 border-t border-[#1a1f2e] space-y-5`,children:[(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>ke(`single`),className:`p-4 rounded-xl border-2 text-left transition-all ${C===`single`?`border-[#d4a017] bg-[#d4a017]/10`:`border-[#2a2f3e] bg-[#0d1117]`}`,children:[(0,v.jsx)(p,{className:`w-5 h-5 text-[#d4a017] mb-2`}),(0,v.jsx)(`p`,{className:`font-bold text-white`,children:t(`setup.mode_single`)}),(0,v.jsx)(`p`,{className:`text-xs text-[#777] mt-1`,children:t(`setup.mode_single_desc`)})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{ke(`team`),w.length===0&&Ae()},className:`p-4 rounded-xl border-2 text-left transition-all ${C===`team`?`border-[#3b82f6] bg-[#3b82f6]/10`:`border-[#2a2f3e] bg-[#0d1117]`}`,children:[(0,v.jsx)(he,{className:`w-5 h-5 text-[#3b82f6] mb-2`}),(0,v.jsx)(`p`,{className:`font-bold text-white`,children:t(`setup.mode_team`)}),(0,v.jsx)(`p`,{className:`text-xs text-[#777] mt-1`,children:t(`setup.mode_team_desc`)})]})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`label`,{className:`text-[10px] text-[#888] uppercase tracking-widest font-bold block mb-1.5`,children:t(C===`team`?`setup.primary_admin_name`:`setup.calling_name`)}),(0,v.jsx)(`input`,{type:`text`,value:S,onChange:e=>Oe(e.target.value),placeholder:`Daimyo`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#d4a017] outline-none transition-colors`}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#666] mt-2`,children:t(C===`team`?`setup.primary_admin_desc`:`setup.calling_name_desc`)})]}),C===`team`&&(0,v.jsxs)(`div`,{className:`space-y-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-bold text-white`,children:t(`setup.team_members`)}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:t(`setup.team_members_desc`)})]}),(0,v.jsxs)(`button`,{type:`button`,onClick:Ae,className:`flex items-center gap-1.5 px-3 py-2 rounded-lg bg-[#3b82f6]/15 text-[#60a5fa] text-xs font-bold hover:bg-[#3b82f6]/25`,children:[(0,v.jsx)(me,{className:`w-4 h-4`}),` `,t(`setup.add_member`)]})]}),w.map((e,n)=>(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-4 space-y-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsx)(`p`,{className:`text-xs font-bold text-[#3b82f6] uppercase tracking-widest`,children:q(`setup.member_number`,{number:n+1})}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>T(t=>t.filter(t=>t.id!==e.id)),className:`text-[#666] hover:text-red-400`,children:(0,v.jsx)(m,{className:`w-4 h-4`})})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,v.jsx)(`input`,{value:e.display_name,onChange:t=>E(e.id,{display_name:t.target.value}),placeholder:t(`setup.full_name`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none`}),(0,v.jsx)(`input`,{value:e.email,onChange:t=>E(e.id,{email:t.target.value}),placeholder:t(`setup.email_optional`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none`}),(0,v.jsxs)(`select`,{value:e.channel,onChange:t=>E(e.id,{channel:t.target.value}),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none`,children:[(0,v.jsx)(`option`,{value:`telegram`,children:`Telegram`}),(0,v.jsx)(`option`,{value:`microsoft_teams`,children:`Microsoft Teams`})]}),e.channel===`telegram`?(0,v.jsx)(`input`,{value:e.telegram_user_id,onChange:t=>E(e.id,{telegram_user_id:t.target.value}),placeholder:t(`setup.telegram_user_id`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none`}):(0,v.jsx)(`input`,{value:e.teams_user_principal_name,onChange:t=>E(e.id,{teams_user_principal_name:t.target.value}),placeholder:t(`setup.teams_upn`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none`})]}),e.channel===`microsoft_teams`&&(0,v.jsx)(`input`,{value:e.teams_aad_object_id,onChange:t=>E(e.id,{teams_aad_object_id:t.target.value}),placeholder:t(`setup.teams_object_id`),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none`})]},e.id)),!je&&(0,v.jsx)(`p`,{className:`text-xs text-amber-400`,children:t(`setup.team_validation`)})]})]})]});case 2:return(0,v.jsxs)(`div`,{className:`space-y-8`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(re,{className:`w-12 h-12 text-[#3b82f6] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step2_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.step2_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step2_explainer`)})}),(0,v.jsx)(`div`,{className:`max-w-xl mx-auto`,children:(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#d4a017]/30 rounded-xl p-6 space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] text-[#888] uppercase tracking-widest font-bold`,children:t(`setup.step2_data_dir`)}),(0,v.jsx)(`input`,{type:`text`,value:Ne,onChange:e=>Pe(e.target.value),placeholder:`C:\\Users\\you\\Shogun\\data`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-[#d4a017] focus:border-[#d4a017] outline-none transition-colors`}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#555]`,children:t(`setup.step2_path_help`)})]}),(0,v.jsx)(`div`,{className:`h-px bg-[#2a2f3e]`}),(0,v.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[{icon:te,label:t(`setup.step2_database`),sub:`shogun.db`},{icon:oe,label:t(`setup.step2_vector`),sub:`qdrant/`},{icon:de,label:t(`setup.step2_configs`),sub:`configs/`},{icon:le,label:t(`setup.step2_logs`),sub:`logs/`}].map(({icon:e,label:t,sub:n})=>(0,v.jsxs)(`div`,{className:`flex items-center gap-2.5 p-2.5 rounded-lg bg-[#0a0e1a] border border-[#1a1f2e]`,children:[(0,v.jsx)(e,{className:`w-4 h-4 text-[#3b82f6]`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-medium text-white`,children:t}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#555] font-mono`,children:n})]})]},t))})]})})]});case 3:return(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(p,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step3_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.step3_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-4xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step3_explainer`)})}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 max-w-4xl mx-auto`,children:[(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,v.jsxs)(`h3`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-widest flex items-center gap-2`,children:[(0,v.jsx)(p,{className:`w-4 h-4`}),` `,t(`setup.step8_identity`)]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_agent_name`)}),(0,v.jsx)(`input`,{type:`text`,value:D,onChange:e=>Fe(e.target.value),placeholder:t(`setup.step3_agent_name_placeholder`),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#d4a017] outline-none transition-colors`})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_description`)}),(0,v.jsx)(`textarea`,{value:Ie,onChange:e=>Le(e.target.value),placeholder:t(`setup.step3_description_placeholder`),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#d4a017] outline-none transition-colors min-h-[80px] resize-y`})]}),O.length>0&&(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_persona`)}),(0,v.jsxs)($,{value:Re,onChange:St,children:[(0,v.jsx)(`option`,{value:``,children:t(`setup.step3_select_persona`)}),O.map(e=>(0,v.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,v.jsxs)(`h3`,{className:`text-sm font-bold text-[#3b82f6] uppercase tracking-widest flex items-center gap-2`,children:[(0,v.jsx)(ge,{className:`w-4 h-4`}),` `,t(`setup.autonomy_logic`)]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_autonomy`)}),(0,v.jsxs)(`span`,{className:`text-[#3b82f6] font-mono font-bold text-sm`,children:[k,`%`]})]}),(0,v.jsx)(`input`,{type:`range`,min:`0`,max:`100`,step:`10`,value:k,onChange:e=>A(parseInt(e.target.value)),className:`w-full accent-[#3b82f6]`})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_tone`)}),(0,v.jsxs)($,{value:j,onChange:Ve,children:[(0,v.jsx)(`option`,{value:`analytical`,children:t(`setup.step3_tone_analytical`)}),(0,v.jsx)(`option`,{value:`direct`,children:t(`setup.step3_tone_direct`)}),(0,v.jsx)(`option`,{value:`supportive`,children:t(`setup.step3_tone_supportive`)}),(0,v.jsx)(`option`,{value:`strategic`,children:t(`setup.step3_tone_strategic`)})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_risk`)}),(0,v.jsxs)($,{value:M,onChange:He,children:[(0,v.jsx)(`option`,{value:`low`,children:t(`setup.step3_risk_low`)}),(0,v.jsx)(`option`,{value:`medium`,children:t(`setup.step3_risk_medium`)}),(0,v.jsx)(`option`,{value:`high`,children:t(`setup.step3_risk_high`)})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_verbosity`)}),(0,v.jsxs)($,{value:Ue,onChange:We,children:[(0,v.jsx)(`option`,{value:`low`,children:t(`setup.step3_verbosity_low`)}),(0,v.jsx)(`option`,{value:`medium`,children:t(`setup.step3_verbosity_medium`)}),(0,v.jsx)(`option`,{value:`high`,children:t(`setup.step3_verbosity_high`)})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_planning`)}),(0,v.jsxs)($,{value:Ge,onChange:Ke,children:[(0,v.jsx)(`option`,{value:`low`,children:t(`setup.step3_planning_low`)}),(0,v.jsx)(`option`,{value:`medium`,children:t(`setup.step3_planning_medium`)}),(0,v.jsx)(`option`,{value:`high`,children:t(`setup.step3_planning_high`)})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_tool_usage`)}),(0,v.jsxs)($,{value:qe,onChange:Je,children:[(0,v.jsx)(`option`,{value:`conservative`,children:t(`setup.step3_tool_conservative`)}),(0,v.jsx)(`option`,{value:`balanced`,children:t(`setup.step3_tool_balanced`)}),(0,v.jsx)(`option`,{value:`aggressive`,children:t(`setup.step3_tool_aggressive`)})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_security_bias`)}),(0,v.jsxs)($,{value:N,onChange:Ye,children:[(0,v.jsx)(`option`,{value:`strict`,children:t(`setup.step3_security_strict`)}),(0,v.jsx)(`option`,{value:`balanced`,children:t(`setup.step3_security_balanced`)}),(0,v.jsx)(`option`,{value:`open`,children:t(`setup.step3_security_open`)})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step3_memory`)}),(0,v.jsxs)($,{value:Xe,onChange:Ze,children:[(0,v.jsx)(`option`,{value:`conservative`,children:t(`setup.step3_memory_conservative`)}),(0,v.jsx)(`option`,{value:`focused`,children:t(`setup.step3_memory_focused`)}),(0,v.jsx)(`option`,{value:`expansive`,children:t(`setup.step3_memory_expansive`)})]})]})]})]})]});case 4:return(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(f,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step4_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.step4_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step4_explainer`)})}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-[#2a2f3e] bg-[#0a0e1a]`,children:[(0,v.jsx)(`span`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.yaml_configuration`)}),(0,v.jsx)(`button`,{onClick:()=>$e(xe),className:`text-[10px] font-bold text-[#3b82f6] hover:text-[#d4a017] uppercase tracking-widest transition-colors`,children:t(`setup.step4_reset`)})]}),(0,v.jsx)(`textarea`,{spellCheck:!1,value:Qe,onChange:e=>$e(e.target.value),className:`w-full bg-[#050508] p-5 font-mono text-xs leading-relaxed text-white focus:outline-none min-h-[400px] resize-y`})]})})]});case 5:{let e=P.find(e=>e.provider_type===et),n=P.filter(e=>e.status===`connected`).length;return(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(u,{className:`w-12 h-12 text-[#3b82f6] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step5_title`)}),(0,v.jsxs)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:[t(`setup.step5_subtitle`),n>0&&(0,v.jsxs)(`span`,{className:`text-[#d4a017] font-bold`,children:[` (`,n,` `,t(`setup.step5_added`),`)`]})]})]}),(0,v.jsx)(`div`,{className:`max-w-2xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step5_explainer`)})}),(0,v.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3 max-w-2xl mx-auto`,children:ye.map(e=>{let t=P.find(t=>t.provider_type===e.type);return(0,v.jsxs)(`button`,{onClick:()=>yt(e.type),className:` - p-4 rounded-xl border-2 transition-all duration-300 text-center relative group hover:scale-[1.03] - ${et===e.type?`border-[#3b82f6] bg-[#3b82f6]/10`:t?.status===`connected`?`border-[#d4a017]/50 bg-[#d4a017]/5`:`border-[#2a2f3e] bg-[#0d1117] hover:border-[#3b82f6]/50`} - `,children:[(0,v.jsx)(`span`,{className:`text-2xl block mb-1`,children:e.icon}),(0,v.jsx)(`span`,{className:`text-sm font-bold text-white block`,children:e.label}),t?.status===`connected`&&(0,v.jsx)(l,{className:`w-4 h-4 text-[#d4a017] absolute top-2 right-2`})]},e.type)})}),e&&(0,v.jsxs)(`div`,{className:`max-w-xl mx-auto bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4 animate-in slide-in-from-bottom-3 duration-300`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsx)(`h3`,{className:`text-sm font-bold text-white`,children:e.name}),(0,v.jsx)(`button`,{onClick:()=>bt(e.id),className:`text-[#666] hover:text-red-400 transition-colors`,children:(0,v.jsx)(m,{className:`w-4 h-4`})})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step5_provider_name`)}),(0,v.jsx)(`input`,{value:e.name,onChange:t=>Z(e.id,{name:t.target.value}),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none transition-colors`})]}),[`ollama`,`lmstudio`,`local`].includes(e.provider_type)?(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.step5_base_url`)}),(0,v.jsx)(`input`,{value:e.base_url,onChange:t=>Z(e.id,{base_url:t.target.value}),placeholder:`http://127.0.0.1:11434`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`})]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.auth_type`)}),(0,v.jsxs)($,{value:e.auth_type,onChange:t=>Z(e.id,{auth_type:t}),children:[(0,v.jsx)(`option`,{value:`api_key`,children:t(`setup.step5_api_key`)}),(0,v.jsx)(`option`,{value:`oauth`,children:`OAuth`})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:e.auth_type===`oauth`?t(`setup.oauth_token`):t(`setup.step5_api_key`)}),(0,v.jsx)(`input`,{type:`password`,value:e.api_key,onChange:t=>Z(e.id,{api_key:t.target.value}),placeholder:e.auth_type===`oauth`?`Bearer ...`:`sk-...`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`})]})]}),e.discoveredModels.length>0&&(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:t(`setup.available_models`)}),(0,v.jsx)(`span`,{className:`text-[10px] text-[#555]`,children:q(`setup.models_found`,{count:e.discoveredModels.length})})]}),(0,v.jsx)(`div`,{className:`bg-[#050508] border border-[#2a2f3e] rounded-lg max-h-40 overflow-y-auto`,children:e.discoveredModels.map(t=>{let n=e.models.includes(t);return(0,v.jsxs)(`div`,{onDoubleClick:()=>{n||Z(e.id,{models:[...e.models,t]})},className:` - flex items-center justify-between px-3 py-1.5 text-[11px] font-mono cursor-pointer select-none - border-b border-[#1a1f2e] last:border-b-0 transition-colors - ${n?`text-[#d4a017] bg-[#d4a017]/5`:`text-[#999] hover:bg-[#1a1f2e] hover:text-white`} - `,children:[(0,v.jsx)(`span`,{className:`truncate`,children:t}),n&&(0,v.jsx)(l,{className:`w-3 h-3 text-[#d4a017] shrink-0`})]},t)})})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsx)(`label`,{className:`text-[10px] font-bold text-[#d4a017] uppercase tracking-widest`,children:t(`setup.selected_models`)}),e.models.length>0&&(0,v.jsx)(`span`,{className:`text-[10px] text-[#d4a017] font-bold`,children:q(`setup.models_selected`,{count:e.models.length})})]}),e.models.length>0?(0,v.jsx)(`div`,{className:`flex flex-wrap gap-1.5 p-2.5 bg-[#0a0e1a] border border-[#d4a017]/20 rounded-lg`,children:e.models.map(t=>(0,v.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-[#d4a017]/10 border border-[#d4a017]/30 text-[10px] font-mono text-[#d4a017]`,children:[t,(0,v.jsx)(`button`,{onClick:()=>Z(e.id,{models:e.models.filter(e=>e!==t)}),className:`text-[#d4a017]/40 hover:text-red-400 transition-colors`,children:(0,v.jsx)(m,{className:`w-2.5 h-2.5`})})]},t))}):(0,v.jsxs)(`p`,{className:`text-[10px] text-[#555] italic py-2 text-center`,children:[t(`setup.no_models_selected`),` `,e.discoveredModels.length>0?t(`setup.double_click_add`):t(`setup.test_or_add_model`)]}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(`input`,{"data-manual-model-input":!0,placeholder:t(`setup.type_model_name`),className:`flex-1 bg-[#050508] border border-[#2a2f3e] rounded-lg p-2 text-xs font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`,onKeyDown:t=>{if(t.key===`Enter`){let n=t.target.value.trim();n&&!e.models.includes(n)&&(Z(e.id,{models:[...e.models,n]}),t.target.value=``)}}}),(0,v.jsx)(`button`,{onClick:()=>{let t=document.querySelector(`[data-manual-model-input]`);if(t&&t.value.trim()){let n=t.value.trim();e.models.includes(n)||(Z(e.id,{models:[...e.models,n]}),t.value=``)}},className:`px-3 py-2 rounded-lg bg-[#1a1f2e] border border-[#2a2f3e] text-[10px] font-bold text-[#888] hover:text-white hover:border-[#3b82f6] transition-all`,children:t(`setup.add`)})]})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsx)(`button`,{onClick:()=>xt(e),disabled:e.status===`testing`,className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-[#3b82f6] hover:bg-[#3b82f6]/80 text-white text-sm font-bold transition-all disabled:opacity-50`,children:e.status===`testing`?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(d,{className:`w-4 h-4 animate-spin`}),` `,t(`setup.step5_testing`)]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(ge,{className:`w-4 h-4`}),` `,t(`setup.step5_test`)]})}),e.status===`connected`&&(0,v.jsxs)(`span`,{className:`text-sm text-green-400 flex items-center gap-1`,children:[(0,v.jsx)(l,{className:`w-4 h-4`}),` `,t(`setup.step5_connected`)]}),e.status===`failed`&&(0,v.jsxs)(`span`,{className:`text-sm text-red-400 flex items-center gap-1`,children:[(0,v.jsx)(c,{className:`w-4 h-4`}),` `,t(`setup.step5_failed`)]})]})]})]})}case 6:return(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(ne,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step6_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.step6_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-5xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step6_explainer`)})}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4 max-w-5xl mx-auto`,children:[(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-[#2a2f3e] bg-[#0a0e1a]`,children:[(0,v.jsxs)(`span`,{className:`text-[10px] font-bold text-[#d4a017] uppercase tracking-widest`,children:[`⚖️ `,t(`setup.step6_constitution`),` (YAML)`]}),(0,v.jsx)(`button`,{onClick:()=>nt(Se),className:`text-[10px] font-bold text-[#3b82f6] hover:text-[#d4a017] uppercase tracking-widest transition-colors`,children:t(`setup.step6_use_defaults`)})]}),(0,v.jsx)(`textarea`,{spellCheck:!1,value:tt,onChange:e=>nt(e.target.value),className:`w-full bg-[#050508] p-4 font-mono text-[11px] leading-relaxed text-white focus:outline-none min-h-[350px] resize-y`})]}),(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-[#2a2f3e] bg-[#0a0e1a]`,children:[(0,v.jsxs)(`span`,{className:`text-[10px] font-bold text-[#3b82f6] uppercase tracking-widest`,children:[`📜 `,t(`setup.step6_mandate`),` (Markdown)`]}),(0,v.jsx)(`button`,{onClick:()=>it(Ce),className:`text-[10px] font-bold text-[#3b82f6] hover:text-[#d4a017] uppercase tracking-widest transition-colors`,children:t(`setup.step6_use_defaults`)})]}),(0,v.jsx)(`textarea`,{spellCheck:!1,value:rt,onChange:e=>it(e.target.value),className:`w-full bg-[#050508] p-4 font-mono text-[11px] leading-relaxed text-white focus:outline-none min-h-[350px] resize-y`})]})]})]});case 7:return(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(u,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step7_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.step7_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-4xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step7_explainer`)})}),(0,v.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-2 max-w-5xl mx-auto`,children:J.map(e=>(0,v.jsxs)(`button`,{onClick:()=>at(e.id),className:`text-left rounded-xl border p-3 transition-all ${L===e.id?`border-purple-400 bg-purple-400/10`:`border-[#2a2f3e] bg-[#0d1117] hover:border-purple-400/40`}`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-white`,children:[L===e.id&&(0,v.jsx)(l,{className:`w-3.5 h-3.5 text-purple-400`}),e.name]}),(0,v.jsx)(`p`,{className:`text-[9px] text-[#777] mt-1 leading-relaxed`,children:e.description})]},e.id))}),L===`custom`?(0,v.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 max-w-4xl mx-auto`,children:[(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,v.jsxs)(`h3`,{className:`text-sm font-bold text-[#3b82f6] uppercase tracking-widest flex items-center gap-2`,children:[(0,v.jsx)(u,{className:`w-4 h-4`}),` `,t(`setup.step7_primary`)]}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:t(`setup.step7_primary_desc`)}),Q.length===0?(0,v.jsx)(`p`,{className:`text-xs text-[#888] italic text-center py-4`,children:t(`setup.step7_no_providers`)}):(0,v.jsxs)(`select`,{value:R,onChange:e=>ot(e.target.value),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-3 text-sm font-mono text-white focus:border-[#d4a017] outline-none transition-colors`,children:[(0,v.jsxs)(`option`,{value:``,children:[`— `,t(`setup.step7_select_model`),` —`]}),Q.map(e=>(0,v.jsxs)(`option`,{value:e.value,children:[e.label,` (`,e.group,`)`]},e.value))]}),R&&(0,v.jsxs)(`div`,{className:`flex items-center gap-2 p-2.5 rounded-lg bg-[#d4a017]/5 border border-[#d4a017]/20`,children:[(0,v.jsx)(l,{className:`w-3.5 h-3.5 text-[#d4a017] shrink-0`}),(0,v.jsx)(`span`,{className:`text-xs font-mono text-[#d4a017] font-bold truncate`,children:R.split(`::`)[1]}),(0,v.jsx)(`span`,{className:`text-[9px] text-[#888] ml-auto shrink-0`,children:t(`setup.step7_primary`).toUpperCase()})]})]}),(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,v.jsxs)(`h3`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-widest flex items-center gap-2`,children:[(0,v.jsx)(fe,{className:`w-4 h-4`}),` `,t(`setup.step7_fallback`)]}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:t(`setup.step7_fallback_desc`)}),Q.length===0?(0,v.jsx)(`p`,{className:`text-xs text-[#888] italic text-center py-4`,children:t(`setup.step7_no_providers`)}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`select`,{value:``,onChange:e=>{let t=e.target.value;t&&t!==R&&!z.includes(t)&&B(e=>[...e,t])},className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-3 text-sm font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`,children:[(0,v.jsxs)(`option`,{value:``,children:[`— `,t(`setup.step7_add_fallback`),` —`]}),Q.filter(e=>e.value!==R&&!z.includes(e.value)).map(e=>(0,v.jsxs)(`option`,{value:e.value,children:[e.label,` (`,e.group,`)`]},e.value))]}),z.length>0?(0,v.jsx)(`div`,{className:`space-y-1.5`,children:z.map((e,t)=>(0,v.jsxs)(`div`,{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t))},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},onDrop:e=>{e.preventDefault();let n=Number(e.dataTransfer.getData(`text/plain`));n!==t&&B(e=>{let r=[...e],[i]=r.splice(n,1);return r.splice(t,0,i),r})},className:`flex items-center gap-2 p-2.5 rounded-lg border border-[#3b82f6]/20 bg-[#3b82f6]/5 cursor-grab active:cursor-grabbing transition-colors select-none`,children:[(0,v.jsx)(ae,{className:`w-3.5 h-3.5 text-[#555] shrink-0`}),(0,v.jsxs)(`span`,{className:`text-[9px] font-bold text-[#3b82f6] w-5 shrink-0`,children:[`#`,t+1]}),(0,v.jsx)(`span`,{className:`text-xs font-mono text-white flex-1 truncate`,children:e.split(`::`)[1]}),(0,v.jsx)(`button`,{onClick:()=>B(t=>t.filter(t=>t!==e)),className:`text-[#555] hover:text-red-400 transition-colors shrink-0 p-0.5`,children:(0,v.jsx)(m,{className:`w-3 h-3`})})]},e))}):(0,v.jsx)(`p`,{className:`text-[11px] text-[#888] italic text-center py-2`,children:t(`setup.step7_no_fallbacks`)})]})]})]}):(0,v.jsxs)(`div`,{className:`max-w-4xl mx-auto rounded-xl border border-purple-400/20 bg-purple-400/5 p-5 text-center`,children:[(0,v.jsx)(`p`,{className:`text-sm font-bold text-purple-200`,children:q(`setup.routing_automatic`,{profile:J.find(e=>e.id===L)?.name||L})}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#888] mt-1`,children:t(`setup.routing_later`)})]})]});case 8:{if(ft)return(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(ue,{className:`w-12 h-12 text-[#3b82f6] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.server_mode_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.server_mode_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117] border border-[#3b82f6]/30 rounded-xl p-6`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,v.jsx)(f,{className:`w-6 h-6 text-[#3b82f6] shrink-0`}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`h3`,{className:`text-sm font-bold text-white`,children:t(`setup.server_mode_ronin_unavailable`)}),(0,v.jsx)(`p`,{className:`text-xs text-[#999] leading-relaxed`,children:t(`setup.server_mode_ronin_explainer`)})]})]})})]});let e=async()=>{try{U((await g.get(`/api/v1/setup/ronin-check`)).data.data)}catch{U(null)}};return H||e(),(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(ee,{className:`w-12 h-12 text-[#f97316] mx-auto mb-4`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.ronin_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.ronin_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.ronin_explainer`)})}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(0,v.jsx)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5`,children:(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,v.jsx)(ce,{className:`w-5 h-5 text-[#f97316]`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h3`,{className:`text-sm font-bold text-white`,children:t(`setup.ronin_enable`)}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:t(`setup.ronin_enable_desc`)})]})]}),(0,v.jsx)(`button`,{onClick:()=>{st(!V),!V&&!H&&e()},className:`relative w-12 h-6 rounded-full transition-all duration-300 ${V?`bg-[#f97316]`:`bg-[#2a2f3e]`}`,children:(0,v.jsx)(`div`,{className:`absolute top-0.5 w-5 h-5 rounded-full bg-white shadow transition-all duration-300 ${V?`left-[26px]`:`left-0.5`}`})})]})})}),V&&(0,v.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-4 animate-in slide-in-from-top-3 duration-300`,children:[H&&(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,v.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,v.jsx)(`h3`,{className:`text-sm font-bold text-[#3b82f6] uppercase tracking-widest`,children:t(`setup.ronin_system_detection`)}),(0,v.jsx)(`button`,{onClick:e,className:`text-[10px] text-[#3b82f6] hover:text-[#d4a017] font-bold uppercase tracking-widest`,children:t(`common.refresh`)})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a1f2e] rounded-lg p-3`,children:[(0,v.jsx)(`p`,{className:`text-[9px] text-[#888] uppercase tracking-widest font-bold`,children:t(`setup.ronin_operating_system`)}),(0,v.jsx)(`p`,{className:`text-sm font-bold text-white mt-1`,children:H.os})]}),H.display_server&&(0,v.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a1f2e] rounded-lg p-3`,children:[(0,v.jsx)(`p`,{className:`text-[9px] text-[#888] uppercase tracking-widest font-bold`,children:t(`setup.ronin_display_server`)}),(0,v.jsx)(`p`,{className:`text-sm font-bold text-white mt-1 uppercase`,children:H.display_server})]})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsxs)(`p`,{className:`text-[9px] text-[#888] uppercase tracking-widest font-bold`,children:[t(`setup.ronin_dependencies`),` `,(0,v.jsxs)(`span`,{className:`text-[#555] normal-case font-normal`,children:[`— `,t(`setup.ronin_click_missing`)]})]}),(0,v.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Object.entries(H.deps||{}).map(([n,r])=>{let i=H?.[`_installing_${n}`];return(0,v.jsxs)(`button`,{disabled:r.installed||i,onClick:async()=>{if(!r.installed){U(e=>({...e,[`_installing_${n}`]:!0}));try{let t=await g.post(`/api/v1/setup/ronin-install-dep`,{dep_name:n});t.data.data?.status===`success`?e():G(t.data.data?.message||q(`setup.ronin_failed_dep`,{name:n}))}catch{G(q(`setup.ronin_failed_dep`,{name:n}))}finally{U(e=>({...e,[`_installing_${n}`]:!1}))}}},className:`flex items-center gap-2 p-2.5 rounded-lg border text-left transition-all ${r.installed?`bg-green-500/5 border-green-500/20`:i?`bg-orange-500/5 border-orange-500/20 animate-pulse`:`bg-red-500/5 border-red-500/20 hover:border-[#f97316]/50 hover:bg-[#f97316]/5 cursor-pointer`} disabled:cursor-default`,children:[i?(0,v.jsx)(d,{className:`w-3.5 h-3.5 text-[#f97316] animate-spin shrink-0`}):r.installed?(0,v.jsx)(l,{className:`w-3.5 h-3.5 text-green-500 shrink-0`}):(0,v.jsx)(c,{className:`w-3.5 h-3.5 text-red-400 shrink-0`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-xs font-bold text-white`,children:n}),(0,v.jsx)(`p`,{className:`text-[9px] text-[#666]`,children:i?t(`setup.ronin_installing`):r.installed?`v${r.version}`:t(`setup.ronin_click_install`)})]})]},n)})})]}),!H.all_core_installed&&(0,v.jsx)(`button`,{onClick:async()=>{lt(!0),G(null);try{let n=await g.post(`/api/v1/setup/ronin-install`);n.data.data?.status===`success`?(G(`success`),e()):G(n.data.data?.message||t(`setup.installation_failed`))}catch{G(t(`setup.installation_network_error`))}finally{lt(!1)}},disabled:ct,className:`w-full py-3 rounded-lg bg-[#f97316] hover:bg-[#f97316]/80 text-black font-bold text-sm transition-all disabled:opacity-50 flex items-center justify-center gap-2`,children:ct?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(d,{className:`w-4 h-4 animate-spin`}),` `,t(`setup.ronin_installing_dependencies`)]}):(0,v.jsx)(v.Fragment,{children:t(`setup.ronin_install_dependencies`)})}),W===`success`&&(0,v.jsxs)(`div`,{className:`flex items-center gap-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20`,children:[(0,v.jsx)(l,{className:`w-4 h-4 text-green-500`}),(0,v.jsx)(`span`,{className:`text-sm text-green-500 font-medium`,children:t(`setup.ronin_install_success`)})]}),W&&W!==`success`&&(0,v.jsxs)(`div`,{className:`flex items-center gap-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20`,children:[(0,v.jsx)(c,{className:`w-4 h-4 text-red-400`}),(0,v.jsx)(`span`,{className:`text-sm text-red-400 font-medium`,children:W})]}),H.notes?.length>0&&(0,v.jsxs)(`div`,{className:`bg-orange-500/5 border border-orange-500/20 rounded-lg p-3 space-y-1`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(pe,{className:`w-3.5 h-3.5 text-orange-400 shrink-0`}),(0,v.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 uppercase tracking-widest`,children:t(`setup.ronin_platform_notes`)})]}),H.notes.map((e,t)=>(0,v.jsx)(`p`,{className:`text-[11px] text-[#999] leading-relaxed pl-5`,children:e},t))]})]}),(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5`,children:[(0,v.jsx)(`h3`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-widest mb-3`,children:t(`setup.ronin_capabilities`)}),(0,v.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:[{icon:i,label:t(`setup.ronin_screenshots`),desc:t(`setup.ronin_screenshots_desc`)},{icon:ve,label:t(`setup.ronin_mouse`),desc:t(`setup.ronin_mouse_desc`)},{icon:se,label:t(`setup.ronin_keyboard`),desc:t(`setup.ronin_keyboard_desc`)}].map(({icon:e,label:t,desc:n})=>(0,v.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a1f2e] rounded-lg p-3 text-center`,children:[(0,v.jsx)(e,{className:`w-6 h-6 text-[#f97316] mx-auto mb-2`}),(0,v.jsx)(`p`,{className:`text-xs font-bold text-white`,children:t}),(0,v.jsx)(`p`,{className:`text-[9px] text-[#666] mt-0.5`,children:n})]},t))})]}),(0,v.jsx)(`div`,{className:`bg-red-500/5 border border-red-500/20 rounded-xl p-5`,children:(0,v.jsxs)(`label`,{className:`flex items-start gap-3 cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`checkbox`,checked:ut,onChange:e=>dt(e.target.checked),className:`mt-1 accent-[#f97316] w-4 h-4 shrink-0`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-bold text-white`,children:t(`setup.ronin_acknowledge`)}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#999] leading-relaxed mt-1`,children:t(`setup.ronin_acknowledge_desc`)})]})]})})]})]})}case 9:{if(ht)return(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] animate-in fade-in zoom-in duration-700`,children:[(0,v.jsx)(`div`,{className:`w-24 h-24 rounded-full bg-[#d4a017]/20 flex items-center justify-center mb-6 animate-pulse`,children:(0,v.jsx)(l,{className:`w-12 h-12 text-[#d4a017]`})}),(0,v.jsx)(`h2`,{className:`text-4xl font-bold text-[#d4a017] mb-2`,children:t(`setup.step8_risen`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888]`,children:t(`common.loading`)})]});let e=h.find(e=>e.code===x),n=P.filter(e=>e.status===`connected`);return(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`text-center`,children:[(0,v.jsx)(`div`,{className:`text-5xl mb-4`,children:`⚔️`}),(0,v.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.step8_title`)}),(0,v.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:t(`setup.step8_subtitle`)})]}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,v.jsx)(`p`,{children:t(`setup.step8_explainer`)})}),(0,v.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3 max-w-3xl mx-auto`,children:[{label:t(`setup.step8_language`),value:e?`${e.flag} ${e.name}`:x,color:`#d4a017`},{label:t(`setup.step8_identity`),value:D,color:`#d4a017`},{label:t(`setup.step3_tone`),value:t(`setup.step3_tone_${j}`),color:`#3b82f6`},{label:t(`setup.step3_autonomy`),value:`${k}%`,color:`#3b82f6`},{label:t(`setup.step3_risk`),value:t(`setup.step3_risk_${M}`),color:`#3b82f6`},{label:t(`setup.step8_provider`),value:`${n.length} ${t(`setup.step5_connected`)}`,color:n.length>0?`#22c55e`:`#888`},{label:t(`setup.routing_profile`),value:J.find(e=>e.id===L)?.name||L,color:`#a78bfa`},{label:t(`setup.step8_model`),value:L===`custom`&&R?R.split(`::`)[1]:t(`setup.automatic`),color:L===`custom`&&R?`#d4a017`:`#3b82f6`},{label:t(`setup.step8_security`),value:t(`setup.step3_security_${N}`),color:`#3b82f6`},{label:t(`setup.step7_fallback`),value:`${z.length}`,color:z.length>0?`#22c55e`:`#888`}].map(e=>(0,v.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-3.5 text-center`,children:[(0,v.jsx)(`p`,{className:`text-[9px] font-bold text-[#888] uppercase tracking-widest mb-1`,children:e.label}),(0,v.jsx)(`p`,{className:`text-sm font-bold capitalize truncate`,style:{color:e.color},children:e.value})]},e.label))}),(0,v.jsx)(`div`,{className:`max-w-3xl mx-auto bg-orange-500/5 border border-orange-500/20 rounded-xl p-5`,children:(0,v.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,v.jsx)(c,{className:`w-5 h-5 text-orange-400 shrink-0 mt-0.5`}),(0,v.jsxs)(`div`,{className:`space-y-3`,children:[(0,v.jsxs)(`h4`,{className:`text-[11px] font-bold text-white uppercase tracking-widest flex items-center gap-2`,children:[(0,v.jsx)(f,{className:`w-3.5 h-3.5 text-orange-400`}),t(`guide.disclaimer_title`,`Disclaimer`)]}),(0,v.jsx)(`p`,{className:`text-[10px] text-[#999] leading-relaxed`,children:t(`guide.disclaimer_body`)}),(0,v.jsx)(`p`,{className:`text-[10px] font-bold text-white leading-relaxed`,children:t(`guide.disclaimer_oversight`)})]})]})}),_t&&(0,v.jsxs)(`div`,{className:`max-w-2xl mx-auto flex items-start gap-3 rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-left`,children:[(0,v.jsx)(c,{className:`w-5 h-5 text-red-400 shrink-0 mt-0.5`}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`p`,{className:`text-sm font-bold text-red-300`,children:t(`setup.completion_error_title`)}),(0,v.jsx)(`p`,{className:`text-xs text-red-200/80 mt-1 leading-relaxed`,children:_t})]})]}),(0,v.jsxs)(`div`,{className:`flex items-center justify-center gap-4 pt-4`,children:[(0,v.jsx)(`button`,{onClick:X,disabled:K,className:`px-6 py-3.5 rounded-xl font-bold text-sm border border-[#2a2f3e] text-[#888] hover:text-white hover:border-[#555] transition-all disabled:opacity-30`,children:(0,v.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(o,{className:`w-4 h-4`}),` `,t(`setup.back`)]})}),(0,v.jsxs)(`button`,{onClick:Ct,disabled:K,className:`\r - relative px-12 py-4 rounded-2xl font-bold text-lg text-black\r - bg-gradient-to-r from-[#d4a017] via-[#e6b422] to-[#d4a017]\r - hover:from-[#e6b422] hover:via-[#f0c040] hover:to-[#e6b422]\r - shadow-[0_0_40px_rgba(212,160,23,0.3)] hover:shadow-[0_0_60px_rgba(212,160,23,0.5)]\r - transition-all duration-500 disabled:opacity-50\r - animate-in zoom-in duration-500\r - `,children:[K?(0,v.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,v.jsx)(d,{className:`w-5 h-5 animate-spin`}),` `,t(`setup.step8_configuring`)]}):(0,v.jsxs)(`span`,{className:`flex items-center gap-3`,children:[`⚔️ `,t(`setup.step8_rise`)]}),!K&&(0,v.jsx)(`div`,{className:`absolute inset-0 rounded-2xl border-2 border-[#d4a017]/50 animate-ping opacity-20`})]})]})]})}default:return null}})()},b),b<9&&b!==8&&(0,v.jsxs)(`div`,{className:`flex items-center justify-between mt-10 max-w-3xl mx-auto`,children:[(0,v.jsxs)(`button`,{onClick:X,disabled:b===1,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg border border-[#2a2f3e] text-sm font-bold text-[#888] hover:text-white hover:border-[#555] transition-all disabled:opacity-30 disabled:cursor-not-allowed`,children:[(0,v.jsx)(o,{className:`w-4 h-4`}),` `,t(`setup.back`)]}),b===5&&P.filter(e=>e.status===`connected`).length===0?(0,v.jsxs)(`button`,{onClick:Y,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-bold text-[#888] hover:text-[#d4a017] transition-all`,children:[t(`setup.skip`),` `,(0,v.jsx)(s,{className:`w-4 h-4`})]}):null,(0,v.jsxs)(`button`,{onClick:Y,disabled:b===1&&(!S.trim()||!je),className:`flex items-center gap-2 px-6 py-2.5 rounded-lg bg-[#3b82f6] hover:bg-[#3b82f6]/80 text-sm font-bold text-white shadow-lg shadow-[#3b82f6]/20 transition-all disabled:opacity-30 disabled:cursor-not-allowed`,children:[t(`setup.next`),` `,(0,v.jsx)(s,{className:`w-4 h-4`})]})]}),b===8&&(0,v.jsxs)(`div`,{className:`flex items-center justify-between mt-10 max-w-3xl mx-auto`,children:[(0,v.jsxs)(`button`,{onClick:X,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg border border-[#2a2f3e] text-sm font-bold text-[#888] hover:text-white hover:border-[#555] transition-all`,children:[(0,v.jsx)(o,{className:`w-4 h-4`}),` `,t(`setup.back`)]}),!V&&!ft&&(0,v.jsxs)(`button`,{onClick:Y,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-bold text-[#888] hover:text-[#d4a017] transition-all`,children:[t(`setup.ronin_skip`),` `,(0,v.jsx)(s,{className:`w-4 h-4`})]}),(0,v.jsxs)(`button`,{onClick:Y,disabled:V&&!ut,className:`flex items-center gap-2 px-6 py-2.5 rounded-lg bg-[#3b82f6] hover:bg-[#3b82f6]/80 text-sm font-bold text-white shadow-lg shadow-[#3b82f6]/20 transition-all disabled:opacity-30 disabled:cursor-not-allowed`,children:[t(`setup.next`),` `,(0,v.jsx)(s,{className:`w-4 h-4`})]})]})]})]})};export{b as SetupWizard}; \ No newline at end of file diff --git a/frontend/dist/assets/SetupWizard-D4fX2MOu.js b/frontend/dist/assets/SetupWizard-D4fX2MOu.js new file mode 100644 index 0000000..5707aef --- /dev/null +++ b/frontend/dist/assets/SetupWizard-D4fX2MOu.js @@ -0,0 +1,93 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./camera-BK7z_aNh.js";import{t as n}from"./check-DnxCktpz.js";import{t as r}from"./chevron-left-CoAjCl9c.js";import{t as i}from"./chevron-right-CVeYaFvJ.js";import{t as a}from"./circle-alert-043xB2li.js";import{t as o}from"./circle-check-DBu5bzEI.js";import{t as s}from"./cpu-BM3hm7mB.js";import{t as ee}from"./crosshair-B6y1p9rN.js";import{t as te}from"./file-text-CrD-Um8r.js";import{t as ne}from"./folder-open-CZ39dYm6.js";import{t as re}from"./grip-vertical-taGKt_tP.js";import{t as ie}from"./keyboard-Cg2CjLNk.js";import{t as ae}from"./monitor-DrwnCrGM.js";import{t as oe}from"./server-CVvUGKOH.js";import{t as se}from"./settings-DedojrI9.js";import{t as ce}from"./sparkles-DyLIKWW0.js";import{t as le}from"./user-plus-vtJ7dasD.js";import{t as ue}from"./zap-CQy--vuS.js";import{T as c,a as l,c as de,f as fe,g as u,j as pe,n as d,o as me,r as he,s as f,t as p,u as m,v as ge,x as _e,y as ve}from"./index-Dy1E248t.js";import{t as h}from"./axios-BGmZl9Qd.js";var ye=c(`mouse`,[[`rect`,{x:`5`,y:`2`,width:`14`,height:`20`,rx:`7`,key:`11ol66`}],[`path`,{d:`M12 6v4`,key:`16clxf`}]]),g=e(pe(),1),_=p(),v=9,be=[{type:`openai`,label:`OpenAI`,icon:`⚡`,color:`#10a37f`},{type:`anthropic`,label:`Anthropic`,icon:`🧠`,color:`#d4a017`},{type:`google`,label:`Google Gemini`,icon:`✨`,color:`#4285f4`},{type:`ollama`,label:`Ollama`,icon:`🦙`,color:`#ffffff`},{type:`openrouter`,label:`OpenRouter`,icon:`🌐`,color:`#6366f1`},{type:`perplexity`,label:`Perplexity`,icon:`🔍`,color:`#20b2aa`}],xe=[{id:`ultra_economy`,name:`Ultra Economy`,description:`Lowest cost; strongly prefers local and cheap models.`},{id:`economy`,name:`Economy`,description:`Low-cost daily work with practical escalation.`},{id:`balanced`,name:`Balanced`,description:`Recommended balance of cost, speed, and quality.`},{id:`high_capability`,name:`High Capability`,description:`Uses stronger models earlier for complex work.`},{id:`premium`,name:`Premium`,description:`Maximum configured quality with visible cost controls.`},{id:`custom`,name:`Custom`,description:`Use only your ordered model selection with capability and safety gates.`}],Se=`priorities: + - Safety before autonomy + - Use existing trusted skills when possible + - Escalate ambiguous high-risk actions + - Maintain stealth in network operations + +operational_constraints: + - shell_access: restricted_to_container + - memory_retention: long_term + - verification_threshold: 0.85 + +delegation_rules: + - research: delegate_to_samurai + - coding: delegate_to_samurai + - tactical_analysis: shogun_priority`,Ce=`# SHOGUN SYSTEM CONSTITUTION +# --- Global Behavioral Principles --- + +core_directives: + - id: zero_harm + rule: "Operations must not compromise host system integrity." + severity: CRITICAL + + - id: transparency + rule: "All autonomous spawns must be logged to the Torii registry." + severity: HIGH + + - id: human_oversight + rule: "No irreversible actions without human approval." + severity: BALANCED + +autonomy_limits: + max_recursion_depth: 3 + prohibited_tools: + - shell_rm_root + - network_sniffing + approval_required: true + +data_sovereignty: + retention_policy: episodic_decay + privacy_tier: maximal`,we=`# The Mandate + +## Title +**Shogun — Primary Orchestrator** + +## Mandate Statement + +You are the primary orchestrating AI of the Shogun platform. + +Your responsibility is to ensure that all operations, agents, and workflows are coordinated, efficient, and aligned with the operator's objectives. + +--- + +## Core Objective + +Maintain operational excellence across the Samurai network. Ensure that sub-agents are effectively deployed, monitored, and guided toward their assigned tasks. + +--- + +## Operating Principles + +### Relevance over volume +Focus on meaningful work, not busy work. + +### Clarity over complexity +Communicate clearly and concisely. + +### Stewardship over passivity +Proactively maintain the system, don't merely observe. + +### Trust over hype +Reliability and consistency build trust.`,y=({onComplete:e})=>{let{t:c,language:pe,setLanguage:p}=he(),[y,Te]=(0,g.useState)(1),[Ee,De]=(0,g.useState)(`left`),[b,Oe]=(0,g.useState)(pe),[x,ke]=(0,g.useState)(`Daimyo`),[S,Ae]=(0,g.useState)(`single`),[C,w]=(0,g.useState)([]),je=()=>w(e=>[...e,{id:crypto.randomUUID(),display_name:``,email:``,channel:`telegram`,telegram_user_id:``,teams_aad_object_id:``,teams_user_principal_name:``}]),T=(e,t)=>{w(n=>n.map(n=>n.id===e?{...n,...t}:n))},Me=S===`single`||x.trim().length>0&&C.length>0&&C.every(e=>e.display_name.trim().length>0&&(e.channel===`telegram`?e.telegram_user_id.trim().length>0:e.teams_aad_object_id.trim().length>0||e.teams_user_principal_name.trim().length>0)),Ne=e=>{Oe(e),p(e)},[Pe,Fe]=(0,g.useState)(``),[E,Ie]=(0,g.useState)(`Shogun Prime`),[Le,Re]=(0,g.useState)(`Master orchestrator of the Samurai Network.`),[ze,Be]=(0,g.useState)(``),[D,Ve]=(0,g.useState)([]),[O,k]=(0,g.useState)(50),[A,He]=(0,g.useState)(`analytical`),[j,Ue]=(0,g.useState)(`medium`),[We,Ge]=(0,g.useState)(`medium`),[M,Ke]=(0,g.useState)(`medium`),[qe,Je]=(0,g.useState)(`balanced`),[N,Ye]=(0,g.useState)(`balanced`),[Xe,Ze]=(0,g.useState)(`focused`),[Qe,$e]=(0,g.useState)(Se),[P,F]=(0,g.useState)([]),[et,I]=(0,g.useState)(``),[tt,nt]=(0,g.useState)(Ce),[rt,it]=(0,g.useState)(we),[L,at]=(0,g.useState)(`custom`),[R,ot]=(0,g.useState)(``),[z,B]=(0,g.useState)([]),[V,st]=(0,g.useState)(!1),[H,U]=(0,g.useState)(null),[ct,lt]=(0,g.useState)(!1),[W,G]=(0,g.useState)(null),[ut,dt]=(0,g.useState)(!1),[ft,pt]=(0,g.useState)(!1),[K,mt]=(0,g.useState)(!1),[ht,gt]=(0,g.useState)(!1),[_t,vt]=(0,g.useState)(null);(0,g.useEffect)(()=>{(async()=>{try{let[e,t]=await Promise.allSettled([h.get(`/api/v1/setup/status`),h.get(`/api/v1/personas`)]);if(e.status===`fulfilled`){Fe(e.value.data.data?.data_path||``),pt(e.value.data.data?.deployment_mode===`server`);let t=e.value.data.data?.language;t&&d.some(e=>e.code===t)&&(Oe(t),p(t))}t.status===`fulfilled`&&Ve(t.value.data.data||[])}catch{}})()},[p]);let q=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{${t}}`,String(n)),c(e)),J=xe.map(e=>({...e,name:c(`setup.routing_${e.id}`),description:c(`setup.routing_${e.id}_desc`)})),Y=(0,g.useCallback)(()=>{ye+1))},[y]),X=(0,g.useCallback)(()=>{y>1&&(De(`right`),Te(e=>e-1))},[y]),yt=e=>{if(P.find(t=>t.provider_type===e)){I(e);return}let t=be.find(t=>t.type===e)?.label||e,n=[`ollama`,`lmstudio`,`local`].includes(e);F(r=>[...r,{id:crypto.randomUUID(),provider_type:e,name:t,api_key:``,base_url:n?`http://127.0.0.1:11434`:``,models:[],discoveredModels:[],status:`pending`,auth_type:n?`none`:`api_key`}]),I(e)},Z=(e,t)=>{F(n=>n.map(n=>n.id===e?{...n,...t}:n))},bt=e=>{F(t=>t.filter(t=>t.id!==e)),I(``)},xt=async e=>{Z(e.id,{status:`testing`});let t=[`ollama`,`lmstudio`,`local`].includes(e.provider_type),n=e.base_url||{openai:`https://api.openai.com`,anthropic:`https://api.anthropic.com`,google:`https://generativelanguage.googleapis.com`,openrouter:`https://openrouter.ai/api`,perplexity:`https://api.perplexity.ai`}[e.provider_type]||``;try{let r={"Content-Type":`application/json`};e.api_key&&(r.Authorization=`Bearer ${e.api_key}`);let i=t?`${n}/api/tags`:`${n}/v1/models`,a=await fetch(i,{headers:r,signal:AbortSignal.timeout(8e3)});if(a.ok){let n=await a.json(),r=[];t&&n.models?r=n.models.map(e=>e.name||e.model).filter(Boolean):n.data&&(r=n.data.map(e=>e.id).filter(Boolean)),Z(e.id,{status:`connected`,discoveredModels:r})}else e.api_key||t?Z(e.id,{status:`connected`}):Z(e.id,{status:`failed`})}catch{e.api_key||t?Z(e.id,{status:`connected`}):Z(e.id,{status:`failed`})}},Q=P.filter(e=>e.status===`connected`).flatMap(e=>(e.models.length>0?e.models:[e.name]).map(t=>({value:`${e.id}::${t}`,label:t,group:`${e.provider_type.toUpperCase()} — ${e.name}`}))),St=e=>{Be(e);let t=D.find(t=>t.id===e);if(t&&(t.tone&&He(t.tone),t.risk_tolerance&&Ue(t.risk_tolerance),t.verbosity&&Ge(t.verbosity),t.planning_depth&&Ke(t.planning_depth),t.tool_usage_style&&Je(t.tool_usage_style),t.security_bias&&Ye(t.security_bias),t.memory_style&&Ze(t.memory_style),t.autonomy))if(t.autonomy===`low`||t.autonomy===`guarded`)k(25);else if(t.autonomy===`medium`||t.autonomy===`tactical`)k(50);else if(t.autonomy===`high`||t.autonomy===`campaign`)k(75);else if(t.autonomy===`critical`||t.autonomy===`ronin`)k(100);else{let e=parseInt(t.autonomy);isNaN(e)||k(e)}},Ct=async()=>{mt(!0),vt(null);try{await h.post(`/api/v1/setup/complete`,{language:b,operator_name:x,installation_mode:S,team_members:S===`team`?[{display_name:x,is_primary:!0,channel:`web`},...C.map(e=>({display_name:e.display_name,email:e.email||null,is_primary:!1,channel:e.channel,telegram_user_id:e.channel===`telegram`?e.telegram_user_id:null,teams_aad_object_id:e.channel===`microsoft_teams`&&e.teams_aad_object_id||null,teams_user_principal_name:e.channel===`microsoft_teams`&&e.teams_user_principal_name||null}))]:[],data_path:Pe,agent_name:E,description:Le,persona_id:ze||null,autonomy:O,tone:A,risk_tolerance:j,verbosity:We,planning_depth:M,tool_usage_style:qe,security_bias:N,memory_style:Xe,behavioral_directives:Qe,providers:P.filter(e=>e.status===`connected`).map(e=>({provider_type:e.provider_type,name:e.name,auth_type:e.auth_type,api_key:e.api_key||null,base_url:e.base_url||null,models:e.models})),constitution:tt,mandate:rt,primary_model:R,fallback_models:z,routing_profile:L,ronin_enabled:V}),localStorage.setItem(`shogun_language`,b),localStorage.setItem(`shogun_operator_name`,x),gt(!0),setTimeout(()=>{e()},2500)}catch(e){console.error(`Setup failed:`,e);let t=c(`setup.completion_error_help`);if(h.isAxiosError(e)){let n=e.response?.data?.detail;typeof n==`string`&&n.trim()&&(t=n)}vt(t),mt(!1)}},wt=()=>(0,_.jsx)(`div`,{className:`flex items-center justify-center gap-1 mb-8`,children:Array.from({length:v},(e,t)=>{let r=t+1,i=r(0,_.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none transition-colors ${r}`,children:n});return(0,_.jsxs)(`div`,{className:`fixed inset-0 bg-[#0a0e1a] text-white overflow-y-auto z-50`,children:[(0,_.jsx)(`div`,{className:`fixed inset-0 opacity-[0.03] pointer-events-none`,style:{backgroundImage:`linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px)`,backgroundSize:`40px 40px`}}),(0,_.jsxs)(`div`,{className:`relative max-w-5xl mx-auto px-6 py-10`,children:[(0,_.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,_.jsx)(`h1`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-[0.3em]`,children:c(`setup.wizard_title`)}),(0,_.jsx)(`p`,{className:`text-[11px] text-[#555] mt-1`,children:q(`setup.progress`,{current:y,total:v})})]}),(0,_.jsx)(wt,{}),(0,_.jsx)(`div`,{className:`animate-in ${Ee===`left`?`slide-in-from-right-5`:`slide-in-from-left-5`} fade-in duration-400`,children:(()=>{switch(y){case 1:return(0,_.jsxs)(`div`,{className:`space-y-8`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(ve,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step1_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.step1_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step1_explainer`)})}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-5 lg:grid-cols-7 gap-3 max-w-4xl mx-auto`,children:d.map(e=>(0,_.jsxs)(`button`,{onClick:()=>Ne(e.code),className:` + p-4 rounded-xl border-2 transition-all duration-300 text-center group hover:scale-[1.03] + ${b===e.code?`border-[#d4a017] bg-[#d4a017]/10 shadow-[0_0_20px_rgba(212,160,23,0.15)]`:`border-[#2a2f3e] bg-[#0d1117] hover:border-[#3b82f6]/50`} + `,children:[(0,_.jsx)(`span`,{className:`text-2xl block mb-2`,children:e.flag}),(0,_.jsx)(`span`,{className:`text-sm font-bold text-white block`,children:e.name}),(0,_.jsx)(`span`,{className:`text-[10px] text-[#666] block mt-0.5`,children:e.englishName}),b===e.code&&(0,_.jsx)(o,{className:`w-4 h-4 text-[#d4a017] mx-auto mt-2`})]},e.code))}),(0,_.jsxs)(`div`,{className:`max-w-3xl mx-auto pt-4 border-t border-[#1a1f2e] space-y-5`,children:[(0,_.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,_.jsxs)(`button`,{type:`button`,onClick:()=>Ae(`single`),className:`p-4 rounded-xl border-2 text-left transition-all ${S===`single`?`border-[#d4a017] bg-[#d4a017]/10`:`border-[#2a2f3e] bg-[#0d1117]`}`,children:[(0,_.jsx)(f,{className:`w-5 h-5 text-[#d4a017] mb-2`}),(0,_.jsx)(`p`,{className:`font-bold text-white`,children:c(`setup.mode_single`)}),(0,_.jsx)(`p`,{className:`text-xs text-[#777] mt-1`,children:c(`setup.mode_single_desc`)})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(`team`),C.length===0&&je()},className:`p-4 rounded-xl border-2 text-left transition-all ${S===`team`?`border-[#3b82f6] bg-[#3b82f6]/10`:`border-[#2a2f3e] bg-[#0d1117]`}`,children:[(0,_.jsx)(me,{className:`w-5 h-5 text-[#3b82f6] mb-2`}),(0,_.jsx)(`p`,{className:`font-bold text-white`,children:c(`setup.mode_team`)}),(0,_.jsx)(`p`,{className:`text-xs text-[#777] mt-1`,children:c(`setup.mode_team_desc`)})]})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{className:`text-[10px] text-[#888] uppercase tracking-widest font-bold block mb-1.5`,children:c(S===`team`?`setup.primary_admin_name`:`setup.calling_name`)}),(0,_.jsx)(`input`,{type:`text`,value:x,onChange:e=>ke(e.target.value),placeholder:`Daimyo`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#d4a017] outline-none transition-colors`}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#666] mt-2`,children:c(S===`team`?`setup.primary_admin_desc`:`setup.calling_name_desc`)})]}),S===`team`&&(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-sm font-bold text-white`,children:c(`setup.team_members`)}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:c(`setup.team_members_desc`)})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:je,className:`flex items-center gap-1.5 px-3 py-2 rounded-lg bg-[#3b82f6]/15 text-[#60a5fa] text-xs font-bold hover:bg-[#3b82f6]/25`,children:[(0,_.jsx)(le,{className:`w-4 h-4`}),` `,c(`setup.add_member`)]})]}),C.map((e,t)=>(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-4 space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`p`,{className:`text-xs font-bold text-[#3b82f6] uppercase tracking-widest`,children:q(`setup.member_number`,{number:t+1})}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>w(t=>t.filter(t=>t.id!==e.id)),className:`text-[#666] hover:text-red-400`,children:(0,_.jsx)(l,{className:`w-4 h-4`})})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,_.jsx)(`input`,{value:e.display_name,onChange:t=>T(e.id,{display_name:t.target.value}),placeholder:c(`setup.full_name`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none`}),(0,_.jsx)(`input`,{value:e.email,onChange:t=>T(e.id,{email:t.target.value}),placeholder:c(`setup.email_optional`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none`}),(0,_.jsxs)(`select`,{value:e.channel,onChange:t=>T(e.id,{channel:t.target.value}),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none`,children:[(0,_.jsx)(`option`,{value:`telegram`,children:`Telegram`}),(0,_.jsx)(`option`,{value:`microsoft_teams`,children:`Microsoft Teams`})]}),e.channel===`telegram`?(0,_.jsx)(`input`,{value:e.telegram_user_id,onChange:t=>T(e.id,{telegram_user_id:t.target.value}),placeholder:c(`setup.telegram_user_id`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none`}):(0,_.jsx)(`input`,{value:e.teams_user_principal_name,onChange:t=>T(e.id,{teams_user_principal_name:t.target.value}),placeholder:c(`setup.teams_upn`),className:`bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none`})]}),e.channel===`microsoft_teams`&&(0,_.jsx)(`input`,{value:e.teams_aad_object_id,onChange:t=>T(e.id,{teams_aad_object_id:t.target.value}),placeholder:c(`setup.teams_object_id`),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none`})]},e.id)),!Me&&(0,_.jsx)(`p`,{className:`text-xs text-amber-400`,children:c(`setup.team_validation`)})]})]})]});case 2:return(0,_.jsxs)(`div`,{className:`space-y-8`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(ne,{className:`w-12 h-12 text-[#3b82f6] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step2_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.step2_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step2_explainer`)})}),(0,_.jsx)(`div`,{className:`max-w-xl mx-auto`,children:(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#d4a017]/30 rounded-xl p-6 space-y-4`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] text-[#888] uppercase tracking-widest font-bold`,children:c(`setup.step2_data_dir`)}),(0,_.jsx)(`input`,{type:`text`,value:Pe,onChange:e=>Fe(e.target.value),placeholder:`C:\\Users\\you\\Shogun\\data`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-[#d4a017] focus:border-[#d4a017] outline-none transition-colors`}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#555]`,children:c(`setup.step2_path_help`)})]}),(0,_.jsx)(`div`,{className:`h-px bg-[#2a2f3e]`}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[{icon:_e,label:c(`setup.step2_database`),sub:`shogun.db`},{icon:ge,label:c(`setup.step2_vector`),sub:`qdrant/`},{icon:se,label:c(`setup.step2_configs`),sub:`configs/`},{icon:fe,label:c(`setup.step2_logs`),sub:`logs/`}].map(({icon:e,label:t,sub:n})=>(0,_.jsxs)(`div`,{className:`flex items-center gap-2.5 p-2.5 rounded-lg bg-[#0a0e1a] border border-[#1a1f2e]`,children:[(0,_.jsx)(e,{className:`w-4 h-4 text-[#3b82f6]`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-xs font-medium text-white`,children:t}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#555] font-mono`,children:n})]})]},t))})]})})]});case 3:return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(f,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step3_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.step3_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-4xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step3_explainer`)})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 max-w-4xl mx-auto`,children:[(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,_.jsxs)(`h3`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-widest flex items-center gap-2`,children:[(0,_.jsx)(f,{className:`w-4 h-4`}),` `,c(`setup.step8_identity`)]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_agent_name`)}),(0,_.jsx)(`input`,{type:`text`,value:E,onChange:e=>Ie(e.target.value),placeholder:c(`setup.step3_agent_name_placeholder`),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#d4a017] outline-none transition-colors`})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_description`)}),(0,_.jsx)(`textarea`,{value:Le,onChange:e=>Re(e.target.value),placeholder:c(`setup.step3_description_placeholder`),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#d4a017] outline-none transition-colors min-h-[80px] resize-y`})]}),D.length>0&&(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_persona`)}),(0,_.jsxs)($,{value:ze,onChange:St,children:[(0,_.jsx)(`option`,{value:``,children:c(`setup.step3_select_persona`)}),D.map(e=>(0,_.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,_.jsxs)(`h3`,{className:`text-sm font-bold text-[#3b82f6] uppercase tracking-widest flex items-center gap-2`,children:[(0,_.jsx)(ue,{className:`w-4 h-4`}),` `,c(`setup.autonomy_logic`)]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_autonomy`)}),(0,_.jsxs)(`span`,{className:`text-[#3b82f6] font-mono font-bold text-sm`,children:[O,`%`]})]}),(0,_.jsx)(`input`,{type:`range`,min:`0`,max:`100`,step:`10`,value:O,onChange:e=>k(parseInt(e.target.value)),className:`w-full accent-[#3b82f6]`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_tone`)}),(0,_.jsxs)($,{value:A,onChange:He,children:[(0,_.jsx)(`option`,{value:`analytical`,children:c(`setup.step3_tone_analytical`)}),(0,_.jsx)(`option`,{value:`direct`,children:c(`setup.step3_tone_direct`)}),(0,_.jsx)(`option`,{value:`supportive`,children:c(`setup.step3_tone_supportive`)}),(0,_.jsx)(`option`,{value:`strategic`,children:c(`setup.step3_tone_strategic`)})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_risk`)}),(0,_.jsxs)($,{value:j,onChange:Ue,children:[(0,_.jsx)(`option`,{value:`low`,children:c(`setup.step3_risk_low`)}),(0,_.jsx)(`option`,{value:`medium`,children:c(`setup.step3_risk_medium`)}),(0,_.jsx)(`option`,{value:`high`,children:c(`setup.step3_risk_high`)})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_verbosity`)}),(0,_.jsxs)($,{value:We,onChange:Ge,children:[(0,_.jsx)(`option`,{value:`low`,children:c(`setup.step3_verbosity_low`)}),(0,_.jsx)(`option`,{value:`medium`,children:c(`setup.step3_verbosity_medium`)}),(0,_.jsx)(`option`,{value:`high`,children:c(`setup.step3_verbosity_high`)})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_planning`)}),(0,_.jsxs)($,{value:M,onChange:Ke,children:[(0,_.jsx)(`option`,{value:`low`,children:c(`setup.step3_planning_low`)}),(0,_.jsx)(`option`,{value:`medium`,children:c(`setup.step3_planning_medium`)}),(0,_.jsx)(`option`,{value:`high`,children:c(`setup.step3_planning_high`)})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_tool_usage`)}),(0,_.jsxs)($,{value:qe,onChange:Je,children:[(0,_.jsx)(`option`,{value:`conservative`,children:c(`setup.step3_tool_conservative`)}),(0,_.jsx)(`option`,{value:`balanced`,children:c(`setup.step3_tool_balanced`)}),(0,_.jsx)(`option`,{value:`aggressive`,children:c(`setup.step3_tool_aggressive`)})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_security_bias`)}),(0,_.jsxs)($,{value:N,onChange:Ye,children:[(0,_.jsx)(`option`,{value:`strict`,children:c(`setup.step3_security_strict`)}),(0,_.jsx)(`option`,{value:`balanced`,children:c(`setup.step3_security_balanced`)}),(0,_.jsx)(`option`,{value:`open`,children:c(`setup.step3_security_open`)})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step3_memory`)}),(0,_.jsxs)($,{value:Xe,onChange:Ze,children:[(0,_.jsx)(`option`,{value:`conservative`,children:c(`setup.step3_memory_conservative`)}),(0,_.jsx)(`option`,{value:`focused`,children:c(`setup.step3_memory_focused`)}),(0,_.jsx)(`option`,{value:`expansive`,children:c(`setup.step3_memory_expansive`)})]})]})]})]})]});case 4:return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(m,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step4_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.step4_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step4_explainer`)})}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-[#2a2f3e] bg-[#0a0e1a]`,children:[(0,_.jsx)(`span`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.yaml_configuration`)}),(0,_.jsx)(`button`,{onClick:()=>$e(Se),className:`text-[10px] font-bold text-[#3b82f6] hover:text-[#d4a017] uppercase tracking-widest transition-colors`,children:c(`setup.step4_reset`)})]}),(0,_.jsx)(`textarea`,{spellCheck:!1,value:Qe,onChange:e=>$e(e.target.value),className:`w-full bg-[#050508] p-5 font-mono text-xs leading-relaxed text-white focus:outline-none min-h-[400px] resize-y`})]})})]});case 5:{let e=P.find(e=>e.provider_type===et),t=P.filter(e=>e.status===`connected`).length;return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(s,{className:`w-12 h-12 text-[#3b82f6] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step5_title`)}),(0,_.jsxs)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:[c(`setup.step5_subtitle`),t>0&&(0,_.jsxs)(`span`,{className:`text-[#d4a017] font-bold`,children:[` (`,t,` `,c(`setup.step5_added`),`)`]})]})]}),(0,_.jsx)(`div`,{className:`max-w-2xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step5_explainer`)})}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-3 max-w-2xl mx-auto`,children:be.map(e=>{let t=P.find(t=>t.provider_type===e.type);return(0,_.jsxs)(`button`,{onClick:()=>yt(e.type),className:` + p-4 rounded-xl border-2 transition-all duration-300 text-center relative group hover:scale-[1.03] + ${et===e.type?`border-[#3b82f6] bg-[#3b82f6]/10`:t?.status===`connected`?`border-[#d4a017]/50 bg-[#d4a017]/5`:`border-[#2a2f3e] bg-[#0d1117] hover:border-[#3b82f6]/50`} + `,children:[(0,_.jsx)(`span`,{className:`text-2xl block mb-1`,children:e.icon}),(0,_.jsx)(`span`,{className:`text-sm font-bold text-white block`,children:e.label}),t?.status===`connected`&&(0,_.jsx)(o,{className:`w-4 h-4 text-[#d4a017] absolute top-2 right-2`})]},e.type)})}),e&&(0,_.jsxs)(`div`,{className:`max-w-xl mx-auto bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4 animate-in slide-in-from-bottom-3 duration-300`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-bold text-white`,children:e.name}),(0,_.jsx)(`button`,{onClick:()=>bt(e.id),className:`text-[#666] hover:text-red-400 transition-colors`,children:(0,_.jsx)(l,{className:`w-4 h-4`})})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step5_provider_name`)}),(0,_.jsx)(`input`,{value:e.name,onChange:t=>Z(e.id,{name:t.target.value}),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm text-white focus:border-[#3b82f6] outline-none transition-colors`})]}),[`ollama`,`lmstudio`,`local`].includes(e.provider_type)?(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.step5_base_url`)}),(0,_.jsx)(`input`,{value:e.base_url,onChange:t=>Z(e.id,{base_url:t.target.value}),placeholder:`http://127.0.0.1:11434`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.auth_type`)}),(0,_.jsxs)($,{value:e.auth_type,onChange:t=>Z(e.id,{auth_type:t}),children:[(0,_.jsx)(`option`,{value:`api_key`,children:c(`setup.step5_api_key`)}),(0,_.jsx)(`option`,{value:`oauth`,children:`OAuth`})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:e.auth_type===`oauth`?c(`setup.oauth_token`):c(`setup.step5_api_key`)}),(0,_.jsx)(`input`,{type:`password`,value:e.api_key,onChange:t=>Z(e.id,{api_key:t.target.value}),placeholder:e.auth_type===`oauth`?`Bearer ...`:`sk-...`,className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-2.5 text-sm font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`})]})]}),e.discoveredModels.length>0&&(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#888] uppercase tracking-widest`,children:c(`setup.available_models`)}),(0,_.jsx)(`span`,{className:`text-[10px] text-[#555]`,children:q(`setup.models_found`,{count:e.discoveredModels.length})})]}),(0,_.jsx)(`div`,{className:`bg-[#050508] border border-[#2a2f3e] rounded-lg max-h-40 overflow-y-auto`,children:e.discoveredModels.map(t=>{let n=e.models.includes(t);return(0,_.jsxs)(`div`,{onDoubleClick:()=>{n||Z(e.id,{models:[...e.models,t]})},className:` + flex items-center justify-between px-3 py-1.5 text-[11px] font-mono cursor-pointer select-none + border-b border-[#1a1f2e] last:border-b-0 transition-colors + ${n?`text-[#d4a017] bg-[#d4a017]/5`:`text-[#999] hover:bg-[#1a1f2e] hover:text-white`} + `,children:[(0,_.jsx)(`span`,{className:`truncate`,children:t}),n&&(0,_.jsx)(o,{className:`w-3 h-3 text-[#d4a017] shrink-0`})]},t)})})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`label`,{className:`text-[10px] font-bold text-[#d4a017] uppercase tracking-widest`,children:c(`setup.selected_models`)}),e.models.length>0&&(0,_.jsx)(`span`,{className:`text-[10px] text-[#d4a017] font-bold`,children:q(`setup.models_selected`,{count:e.models.length})})]}),e.models.length>0?(0,_.jsx)(`div`,{className:`flex flex-wrap gap-1.5 p-2.5 bg-[#0a0e1a] border border-[#d4a017]/20 rounded-lg`,children:e.models.map(t=>(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-[#d4a017]/10 border border-[#d4a017]/30 text-[10px] font-mono text-[#d4a017]`,children:[t,(0,_.jsx)(`button`,{onClick:()=>Z(e.id,{models:e.models.filter(e=>e!==t)}),className:`text-[#d4a017]/40 hover:text-red-400 transition-colors`,children:(0,_.jsx)(l,{className:`w-2.5 h-2.5`})})]},t))}):(0,_.jsxs)(`p`,{className:`text-[10px] text-[#555] italic py-2 text-center`,children:[c(`setup.no_models_selected`),` `,e.discoveredModels.length>0?c(`setup.double_click_add`):c(`setup.test_or_add_model`)]}),(0,_.jsxs)(`div`,{className:`flex gap-2`,children:[(0,_.jsx)(`input`,{"data-manual-model-input":!0,placeholder:c(`setup.type_model_name`),className:`flex-1 bg-[#050508] border border-[#2a2f3e] rounded-lg p-2 text-xs font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`,onKeyDown:t=>{if(t.key===`Enter`){let n=t.target.value.trim();n&&!e.models.includes(n)&&(Z(e.id,{models:[...e.models,n]}),t.target.value=``)}}}),(0,_.jsx)(`button`,{onClick:()=>{let t=document.querySelector(`[data-manual-model-input]`);if(t&&t.value.trim()){let n=t.value.trim();e.models.includes(n)||(Z(e.id,{models:[...e.models,n]}),t.value=``)}},className:`px-3 py-2 rounded-lg bg-[#1a1f2e] border border-[#2a2f3e] text-[10px] font-bold text-[#888] hover:text-white hover:border-[#3b82f6] transition-all`,children:c(`setup.add`)})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(`button`,{onClick:()=>xt(e),disabled:e.status===`testing`,className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-[#3b82f6] hover:bg-[#3b82f6]/80 text-white text-sm font-bold transition-all disabled:opacity-50`,children:e.status===`testing`?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(u,{className:`w-4 h-4 animate-spin`}),` `,c(`setup.step5_testing`)]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(ue,{className:`w-4 h-4`}),` `,c(`setup.step5_test`)]})}),e.status===`connected`&&(0,_.jsxs)(`span`,{className:`text-sm text-green-400 flex items-center gap-1`,children:[(0,_.jsx)(o,{className:`w-4 h-4`}),` `,c(`setup.step5_connected`)]}),e.status===`failed`&&(0,_.jsxs)(`span`,{className:`text-sm text-red-400 flex items-center gap-1`,children:[(0,_.jsx)(a,{className:`w-4 h-4`}),` `,c(`setup.step5_failed`)]})]})]})]})}case 6:return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(te,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step6_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.step6_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-5xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step6_explainer`)})}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4 max-w-5xl mx-auto`,children:[(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-[#2a2f3e] bg-[#0a0e1a]`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] font-bold text-[#d4a017] uppercase tracking-widest`,children:[`⚖️ `,c(`setup.step6_constitution`),` (YAML)`]}),(0,_.jsx)(`button`,{onClick:()=>nt(Ce),className:`text-[10px] font-bold text-[#3b82f6] hover:text-[#d4a017] uppercase tracking-widest transition-colors`,children:c(`setup.step6_use_defaults`)})]}),(0,_.jsx)(`textarea`,{spellCheck:!1,value:tt,onChange:e=>nt(e.target.value),className:`w-full bg-[#050508] p-4 font-mono text-[11px] leading-relaxed text-white focus:outline-none min-h-[350px] resize-y`})]}),(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl overflow-hidden`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-[#2a2f3e] bg-[#0a0e1a]`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] font-bold text-[#3b82f6] uppercase tracking-widest`,children:[`📜 `,c(`setup.step6_mandate`),` (Markdown)`]}),(0,_.jsx)(`button`,{onClick:()=>it(we),className:`text-[10px] font-bold text-[#3b82f6] hover:text-[#d4a017] uppercase tracking-widest transition-colors`,children:c(`setup.step6_use_defaults`)})]}),(0,_.jsx)(`textarea`,{spellCheck:!1,value:rt,onChange:e=>it(e.target.value),className:`w-full bg-[#050508] p-4 font-mono text-[11px] leading-relaxed text-white focus:outline-none min-h-[350px] resize-y`})]})]})]});case 7:return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(s,{className:`w-12 h-12 text-[#d4a017] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step7_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.step7_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-4xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step7_explainer`)})}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-2 max-w-5xl mx-auto`,children:J.map(e=>(0,_.jsxs)(`button`,{onClick:()=>at(e.id),className:`text-left rounded-xl border p-3 transition-all ${L===e.id?`border-purple-400 bg-purple-400/10`:`border-[#2a2f3e] bg-[#0d1117] hover:border-purple-400/40`}`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-bold text-white`,children:[L===e.id&&(0,_.jsx)(o,{className:`w-3.5 h-3.5 text-purple-400`}),e.name]}),(0,_.jsx)(`p`,{className:`text-[9px] text-[#777] mt-1 leading-relaxed`,children:e.description})]},e.id))}),L===`custom`?(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 max-w-4xl mx-auto`,children:[(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,_.jsxs)(`h3`,{className:`text-sm font-bold text-[#3b82f6] uppercase tracking-widest flex items-center gap-2`,children:[(0,_.jsx)(s,{className:`w-4 h-4`}),` `,c(`setup.step7_primary`)]}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:c(`setup.step7_primary_desc`)}),Q.length===0?(0,_.jsx)(`p`,{className:`text-xs text-[#888] italic text-center py-4`,children:c(`setup.step7_no_providers`)}):(0,_.jsxs)(`select`,{value:R,onChange:e=>ot(e.target.value),className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-3 text-sm font-mono text-white focus:border-[#d4a017] outline-none transition-colors`,children:[(0,_.jsxs)(`option`,{value:``,children:[`— `,c(`setup.step7_select_model`),` —`]}),Q.map(e=>(0,_.jsxs)(`option`,{value:e.value,children:[e.label,` (`,e.group,`)`]},e.value))]}),R&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 p-2.5 rounded-lg bg-[#d4a017]/5 border border-[#d4a017]/20`,children:[(0,_.jsx)(o,{className:`w-3.5 h-3.5 text-[#d4a017] shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-mono text-[#d4a017] font-bold truncate`,children:R.split(`::`)[1]}),(0,_.jsx)(`span`,{className:`text-[9px] text-[#888] ml-auto shrink-0`,children:c(`setup.step7_primary`).toUpperCase()})]})]}),(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,_.jsxs)(`h3`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-widest flex items-center gap-2`,children:[(0,_.jsx)(ce,{className:`w-4 h-4`}),` `,c(`setup.step7_fallback`)]}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:c(`setup.step7_fallback_desc`)}),Q.length===0?(0,_.jsx)(`p`,{className:`text-xs text-[#888] italic text-center py-4`,children:c(`setup.step7_no_providers`)}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`select`,{value:``,onChange:e=>{let t=e.target.value;t&&t!==R&&!z.includes(t)&&B(e=>[...e,t])},className:`w-full bg-[#050508] border border-[#2a2f3e] rounded-lg p-3 text-sm font-mono text-white focus:border-[#3b82f6] outline-none transition-colors`,children:[(0,_.jsxs)(`option`,{value:``,children:[`— `,c(`setup.step7_add_fallback`),` —`]}),Q.filter(e=>e.value!==R&&!z.includes(e.value)).map(e=>(0,_.jsxs)(`option`,{value:e.value,children:[e.label,` (`,e.group,`)`]},e.value))]}),z.length>0?(0,_.jsx)(`div`,{className:`space-y-1.5`,children:z.map((e,t)=>(0,_.jsxs)(`div`,{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t))},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},onDrop:e=>{e.preventDefault();let n=Number(e.dataTransfer.getData(`text/plain`));n!==t&&B(e=>{let r=[...e],[i]=r.splice(n,1);return r.splice(t,0,i),r})},className:`flex items-center gap-2 p-2.5 rounded-lg border border-[#3b82f6]/20 bg-[#3b82f6]/5 cursor-grab active:cursor-grabbing transition-colors select-none`,children:[(0,_.jsx)(re,{className:`w-3.5 h-3.5 text-[#555] shrink-0`}),(0,_.jsxs)(`span`,{className:`text-[9px] font-bold text-[#3b82f6] w-5 shrink-0`,children:[`#`,t+1]}),(0,_.jsx)(`span`,{className:`text-xs font-mono text-white flex-1 truncate`,children:e.split(`::`)[1]}),(0,_.jsx)(`button`,{onClick:()=>B(t=>t.filter(t=>t!==e)),className:`text-[#555] hover:text-red-400 transition-colors shrink-0 p-0.5`,children:(0,_.jsx)(l,{className:`w-3 h-3`})})]},e))}):(0,_.jsx)(`p`,{className:`text-[11px] text-[#888] italic text-center py-2`,children:c(`setup.step7_no_fallbacks`)})]})]})]}):(0,_.jsxs)(`div`,{className:`max-w-4xl mx-auto rounded-xl border border-purple-400/20 bg-purple-400/5 p-5 text-center`,children:[(0,_.jsx)(`p`,{className:`text-sm font-bold text-purple-200`,children:q(`setup.routing_automatic`,{profile:J.find(e=>e.id===L)?.name||L})}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#888] mt-1`,children:c(`setup.routing_later`)})]})]});case 8:{if(ft)return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(oe,{className:`w-12 h-12 text-[#3b82f6] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.server_mode_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.server_mode_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117] border border-[#3b82f6]/30 rounded-xl p-6`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,_.jsx)(m,{className:`w-6 h-6 text-[#3b82f6] shrink-0`}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-bold text-white`,children:c(`setup.server_mode_ronin_unavailable`)}),(0,_.jsx)(`p`,{className:`text-xs text-[#999] leading-relaxed`,children:c(`setup.server_mode_ronin_explainer`)})]})]})})]});let e=async()=>{try{let e=await h.get(`/api/v1/setup/ronin-check`);U(e.data.data)}catch{U(null)}};return H||e(),(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(ee,{className:`w-12 h-12 text-[#f97316] mx-auto mb-4`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.ronin_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.ronin_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.ronin_explainer`)})}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto`,children:(0,_.jsx)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(ae,{className:`w-5 h-5 text-[#f97316]`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-sm font-bold text-white`,children:c(`setup.ronin_enable`)}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#666]`,children:c(`setup.ronin_enable_desc`)})]})]}),(0,_.jsx)(`button`,{onClick:()=>{st(!V),!V&&!H&&e()},className:`relative w-12 h-6 rounded-full transition-all duration-300 ${V?`bg-[#f97316]`:`bg-[#2a2f3e]`}`,children:(0,_.jsx)(`div`,{className:`absolute top-0.5 w-5 h-5 rounded-full bg-white shadow transition-all duration-300 ${V?`left-[26px]`:`left-0.5`}`})})]})})}),V&&(0,_.jsxs)(`div`,{className:`max-w-3xl mx-auto space-y-4 animate-in slide-in-from-top-3 duration-300`,children:[H&&(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5 space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-bold text-[#3b82f6] uppercase tracking-widest`,children:c(`setup.ronin_system_detection`)}),(0,_.jsx)(`button`,{onClick:e,className:`text-[10px] text-[#3b82f6] hover:text-[#d4a017] font-bold uppercase tracking-widest`,children:c(`common.refresh`)})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a1f2e] rounded-lg p-3`,children:[(0,_.jsx)(`p`,{className:`text-[9px] text-[#888] uppercase tracking-widest font-bold`,children:c(`setup.ronin_operating_system`)}),(0,_.jsx)(`p`,{className:`text-sm font-bold text-white mt-1`,children:H.os})]}),H.display_server&&(0,_.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a1f2e] rounded-lg p-3`,children:[(0,_.jsx)(`p`,{className:`text-[9px] text-[#888] uppercase tracking-widest font-bold`,children:c(`setup.ronin_display_server`)}),(0,_.jsx)(`p`,{className:`text-sm font-bold text-white mt-1 uppercase`,children:H.display_server})]})]}),(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`p`,{className:`text-[9px] text-[#888] uppercase tracking-widest font-bold`,children:[c(`setup.ronin_dependencies`),` `,(0,_.jsxs)(`span`,{className:`text-[#555] normal-case font-normal`,children:[`— `,c(`setup.ronin_click_missing`)]})]}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:Object.entries(H.deps||{}).map(([t,n])=>{let r=H?.[`_installing_${t}`];return(0,_.jsxs)(`button`,{disabled:n.installed||r,onClick:async()=>{if(!n.installed){U(e=>({...e,[`_installing_${t}`]:!0}));try{let n=await h.post(`/api/v1/setup/ronin-install-dep`,{dep_name:t});n.data.data?.status===`success`?e():G(n.data.data?.message||q(`setup.ronin_failed_dep`,{name:t}))}catch{G(q(`setup.ronin_failed_dep`,{name:t}))}finally{U(e=>({...e,[`_installing_${t}`]:!1}))}}},className:`flex items-center gap-2 p-2.5 rounded-lg border text-left transition-all ${n.installed?`bg-green-500/5 border-green-500/20`:r?`bg-orange-500/5 border-orange-500/20 animate-pulse`:`bg-red-500/5 border-red-500/20 hover:border-[#f97316]/50 hover:bg-[#f97316]/5 cursor-pointer`} disabled:cursor-default`,children:[r?(0,_.jsx)(u,{className:`w-3.5 h-3.5 text-[#f97316] animate-spin shrink-0`}):n.installed?(0,_.jsx)(o,{className:`w-3.5 h-3.5 text-green-500 shrink-0`}):(0,_.jsx)(a,{className:`w-3.5 h-3.5 text-red-400 shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-xs font-bold text-white`,children:t}),(0,_.jsx)(`p`,{className:`text-[9px] text-[#666]`,children:r?c(`setup.ronin_installing`):n.installed?`v${n.version}`:c(`setup.ronin_click_install`)})]})]},t)})})]}),!H.all_core_installed&&(0,_.jsx)(`button`,{onClick:async()=>{lt(!0),G(null);try{let t=await h.post(`/api/v1/setup/ronin-install`);t.data.data?.status===`success`?(G(`success`),e()):G(t.data.data?.message||c(`setup.installation_failed`))}catch{G(c(`setup.installation_network_error`))}finally{lt(!1)}},disabled:ct,className:`w-full py-3 rounded-lg bg-[#f97316] hover:bg-[#f97316]/80 text-black font-bold text-sm transition-all disabled:opacity-50 flex items-center justify-center gap-2`,children:ct?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(u,{className:`w-4 h-4 animate-spin`}),` `,c(`setup.ronin_installing_dependencies`)]}):(0,_.jsx)(_.Fragment,{children:c(`setup.ronin_install_dependencies`)})}),W===`success`&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 p-3 rounded-lg bg-green-500/10 border border-green-500/20`,children:[(0,_.jsx)(o,{className:`w-4 h-4 text-green-500`}),(0,_.jsx)(`span`,{className:`text-sm text-green-500 font-medium`,children:c(`setup.ronin_install_success`)})]}),W&&W!==`success`&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 p-3 rounded-lg bg-red-500/10 border border-red-500/20`,children:[(0,_.jsx)(a,{className:`w-4 h-4 text-red-400`}),(0,_.jsx)(`span`,{className:`text-sm text-red-400 font-medium`,children:W})]}),H.notes?.length>0&&(0,_.jsxs)(`div`,{className:`bg-orange-500/5 border border-orange-500/20 rounded-lg p-3 space-y-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(de,{className:`w-3.5 h-3.5 text-orange-400 shrink-0`}),(0,_.jsx)(`span`,{className:`text-[10px] font-bold text-orange-400 uppercase tracking-widest`,children:c(`setup.ronin_platform_notes`)})]}),H.notes.map((e,t)=>(0,_.jsx)(`p`,{className:`text-[11px] text-[#999] leading-relaxed pl-5`,children:e},t))]})]}),(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-5`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-bold text-[#d4a017] uppercase tracking-widest mb-3`,children:c(`setup.ronin_capabilities`)}),(0,_.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:[{icon:t,label:c(`setup.ronin_screenshots`),desc:c(`setup.ronin_screenshots_desc`)},{icon:ye,label:c(`setup.ronin_mouse`),desc:c(`setup.ronin_mouse_desc`)},{icon:ie,label:c(`setup.ronin_keyboard`),desc:c(`setup.ronin_keyboard_desc`)}].map(({icon:e,label:t,desc:n})=>(0,_.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-[#1a1f2e] rounded-lg p-3 text-center`,children:[(0,_.jsx)(e,{className:`w-6 h-6 text-[#f97316] mx-auto mb-2`}),(0,_.jsx)(`p`,{className:`text-xs font-bold text-white`,children:t}),(0,_.jsx)(`p`,{className:`text-[9px] text-[#666] mt-0.5`,children:n})]},t))})]}),(0,_.jsx)(`div`,{className:`bg-red-500/5 border border-red-500/20 rounded-xl p-5`,children:(0,_.jsxs)(`label`,{className:`flex items-start gap-3 cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:ut,onChange:e=>dt(e.target.checked),className:`mt-1 accent-[#f97316] w-4 h-4 shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-sm font-bold text-white`,children:c(`setup.ronin_acknowledge`)}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#999] leading-relaxed mt-1`,children:c(`setup.ronin_acknowledge_desc`)})]})]})})]})]})}case 9:{if(ht)return(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center min-h-[400px] animate-in fade-in zoom-in duration-700`,children:[(0,_.jsx)(`div`,{className:`w-24 h-24 rounded-full bg-[#d4a017]/20 flex items-center justify-center mb-6 animate-pulse`,children:(0,_.jsx)(o,{className:`w-12 h-12 text-[#d4a017]`})}),(0,_.jsx)(`h2`,{className:`text-4xl font-bold text-[#d4a017] mb-2`,children:c(`setup.step8_risen`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888]`,children:c(`common.loading`)})]});let e=d.find(e=>e.code===b),t=P.filter(e=>e.status===`connected`);return(0,_.jsxs)(`div`,{className:`space-y-6`,children:[(0,_.jsxs)(`div`,{className:`text-center`,children:[(0,_.jsx)(`div`,{className:`text-5xl mb-4`,children:`⚔️`}),(0,_.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:c(`setup.step8_title`)}),(0,_.jsx)(`p`,{className:`text-sm text-[#888] mt-2 max-w-lg mx-auto`,children:c(`setup.step8_subtitle`)})]}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto bg-[#0d1117]/60 border border-[#1a1f2e] rounded-xl p-4 text-sm text-[#999] leading-relaxed`,children:(0,_.jsx)(`p`,{children:c(`setup.step8_explainer`)})}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-3 max-w-3xl mx-auto`,children:[{label:c(`setup.step8_language`),value:e?`${e.flag} ${e.name}`:b,color:`#d4a017`},{label:c(`setup.step8_identity`),value:E,color:`#d4a017`},{label:c(`setup.step3_tone`),value:c(`setup.step3_tone_${A}`),color:`#3b82f6`},{label:c(`setup.step3_autonomy`),value:`${O}%`,color:`#3b82f6`},{label:c(`setup.step3_risk`),value:c(`setup.step3_risk_${j}`),color:`#3b82f6`},{label:c(`setup.step8_provider`),value:`${t.length} ${c(`setup.step5_connected`)}`,color:t.length>0?`#22c55e`:`#888`},{label:c(`setup.routing_profile`),value:J.find(e=>e.id===L)?.name||L,color:`#a78bfa`},{label:c(`setup.step8_model`),value:L===`custom`&&R?R.split(`::`)[1]:c(`setup.automatic`),color:L===`custom`&&R?`#d4a017`:`#3b82f6`},{label:c(`setup.step8_security`),value:c(`setup.step3_security_${N}`),color:`#3b82f6`},{label:c(`setup.step7_fallback`),value:`${z.length}`,color:z.length>0?`#22c55e`:`#888`}].map(e=>(0,_.jsxs)(`div`,{className:`bg-[#0d1117] border border-[#2a2f3e] rounded-xl p-3.5 text-center`,children:[(0,_.jsx)(`p`,{className:`text-[9px] font-bold text-[#888] uppercase tracking-widest mb-1`,children:e.label}),(0,_.jsx)(`p`,{className:`text-sm font-bold capitalize truncate`,style:{color:e.color},children:e.value})]},e.label))}),(0,_.jsx)(`div`,{className:`max-w-3xl mx-auto bg-orange-500/5 border border-orange-500/20 rounded-xl p-5`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,_.jsx)(a,{className:`w-5 h-5 text-orange-400 shrink-0 mt-0.5`}),(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsxs)(`h4`,{className:`text-[11px] font-bold text-white uppercase tracking-widest flex items-center gap-2`,children:[(0,_.jsx)(m,{className:`w-3.5 h-3.5 text-orange-400`}),c(`guide.disclaimer_title`,`Disclaimer`)]}),(0,_.jsx)(`p`,{className:`text-[10px] text-[#999] leading-relaxed`,children:c(`guide.disclaimer_body`)}),(0,_.jsx)(`p`,{className:`text-[10px] font-bold text-white leading-relaxed`,children:c(`guide.disclaimer_oversight`)})]})]})}),_t&&(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto flex items-start gap-3 rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-left`,children:[(0,_.jsx)(a,{className:`w-5 h-5 text-red-400 shrink-0 mt-0.5`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-sm font-bold text-red-300`,children:c(`setup.completion_error_title`)}),(0,_.jsx)(`p`,{className:`text-xs text-red-200/80 mt-1 leading-relaxed`,children:_t})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-center gap-4 pt-4`,children:[(0,_.jsx)(`button`,{onClick:X,disabled:K,className:`px-6 py-3.5 rounded-xl font-bold text-sm border border-[#2a2f3e] text-[#888] hover:text-white hover:border-[#555] transition-all disabled:opacity-30`,children:(0,_.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(r,{className:`w-4 h-4`}),` `,c(`setup.back`)]})}),(0,_.jsxs)(`button`,{onClick:Ct,disabled:K,className:`\r + relative px-12 py-4 rounded-2xl font-bold text-lg text-black\r + bg-gradient-to-r from-[#d4a017] via-[#e6b422] to-[#d4a017]\r + hover:from-[#e6b422] hover:via-[#f0c040] hover:to-[#e6b422]\r + shadow-[0_0_40px_rgba(212,160,23,0.3)] hover:shadow-[0_0_60px_rgba(212,160,23,0.5)]\r + transition-all duration-500 disabled:opacity-50\r + animate-in zoom-in duration-500\r + `,children:[K?(0,_.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,_.jsx)(u,{className:`w-5 h-5 animate-spin`}),` `,c(`setup.step8_configuring`)]}):(0,_.jsxs)(`span`,{className:`flex items-center gap-3`,children:[`⚔️ `,c(`setup.step8_rise`)]}),!K&&(0,_.jsx)(`div`,{className:`absolute inset-0 rounded-2xl border-2 border-[#d4a017]/50 animate-ping opacity-20`})]})]})]})}default:return null}})()},y),y<9&&y!==8&&(0,_.jsxs)(`div`,{className:`flex items-center justify-between mt-10 max-w-3xl mx-auto`,children:[(0,_.jsxs)(`button`,{onClick:X,disabled:y===1,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg border border-[#2a2f3e] text-sm font-bold text-[#888] hover:text-white hover:border-[#555] transition-all disabled:opacity-30 disabled:cursor-not-allowed`,children:[(0,_.jsx)(r,{className:`w-4 h-4`}),` `,c(`setup.back`)]}),y===5&&P.filter(e=>e.status===`connected`).length===0?(0,_.jsxs)(`button`,{onClick:Y,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-bold text-[#888] hover:text-[#d4a017] transition-all`,children:[c(`setup.skip`),` `,(0,_.jsx)(i,{className:`w-4 h-4`})]}):null,(0,_.jsxs)(`button`,{onClick:Y,disabled:y===1&&(!x.trim()||!Me),className:`flex items-center gap-2 px-6 py-2.5 rounded-lg bg-[#3b82f6] hover:bg-[#3b82f6]/80 text-sm font-bold text-white shadow-lg shadow-[#3b82f6]/20 transition-all disabled:opacity-30 disabled:cursor-not-allowed`,children:[c(`setup.next`),` `,(0,_.jsx)(i,{className:`w-4 h-4`})]})]}),y===8&&(0,_.jsxs)(`div`,{className:`flex items-center justify-between mt-10 max-w-3xl mx-auto`,children:[(0,_.jsxs)(`button`,{onClick:X,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg border border-[#2a2f3e] text-sm font-bold text-[#888] hover:text-white hover:border-[#555] transition-all`,children:[(0,_.jsx)(r,{className:`w-4 h-4`}),` `,c(`setup.back`)]}),!V&&!ft&&(0,_.jsxs)(`button`,{onClick:Y,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-bold text-[#888] hover:text-[#d4a017] transition-all`,children:[c(`setup.ronin_skip`),` `,(0,_.jsx)(i,{className:`w-4 h-4`})]}),(0,_.jsxs)(`button`,{onClick:Y,disabled:V&&!ut,className:`flex items-center gap-2 px-6 py-2.5 rounded-lg bg-[#3b82f6] hover:bg-[#3b82f6]/80 text-sm font-bold text-white shadow-lg shadow-[#3b82f6]/20 transition-all disabled:opacity-30 disabled:cursor-not-allowed`,children:[c(`setup.next`),` `,(0,_.jsx)(i,{className:`w-4 h-4`})]})]})]})]})};export{y as SetupWizard}; \ No newline at end of file diff --git a/frontend/dist/assets/ShogunProfile-B5yhqwtl.js b/frontend/dist/assets/ShogunProfile-B5yhqwtl.js new file mode 100644 index 0000000..390f222 --- /dev/null +++ b/frontend/dist/assets/ShogunProfile-B5yhqwtl.js @@ -0,0 +1,15 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./app-window-BFcF7ht7.js";import{t as n}from"./chevron-right-CVeYaFvJ.js";import{t as r}from"./circle-alert-043xB2li.js";import{t as i}from"./circle-check-DBu5bzEI.js";import{t as a}from"./clock-DQ9Dz1_z.js";import{t as o}from"./cpu-BM3hm7mB.js";import{t as s}from"./crosshair-B6y1p9rN.js";import{t as c}from"./grip-vertical-taGKt_tP.js";import{t as l}from"./refresh-cw-Dm6S5UAJ.js";import{t as u}from"./save-CupVJLfi.js";import{t as d}from"./server-CVvUGKOH.js";import{t as f}from"./settings-DedojrI9.js";import{t as p}from"./workflow-JDh8EYE0.js";import{t as ee}from"./zap-CQy--vuS.js";import{D as te,O as m,T as h,a as g,d as ne,i as _,j as re,r as ie,s as ae,t as v,u as oe,w as se,x as ce}from"./index-Dy1E248t.js";import{t as y}from"./axios-BGmZl9Qd.js";var le=h(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),b=e(re(),1),x=v(),ue=(e,t)=>{if(!e)return t;let n=e.schedule_time||`00:00`;return e.frequency===`hourly`?`Every hour at :${String(e.minute_offset||0).padStart(2,`0`)}`:e.frequency===`weekly`?`Every ${(e.schedule_days||[`mon`]).join(`, `)} at ${n}`:e.frequency===`monthly`?`Monthly on day ${e.schedule_day||1} at ${n}`:e.frequency===`one-off`?e.schedule_datetime?`Once at ${new Date(e.schedule_datetime).toLocaleString()}`:`One-off`:`Every day at ${n}`},S=(e,t)=>{let n=e?.response?.data?.detail;return Array.isArray(n)?n.map(e=>e?.msg||String(e)).join(`; `):typeof n==`string`?n:t},C={agentflow:{allow_create:!1,allow_edit:!1,allow_activate:!1,allow_execute:!1,allow_save_as_template:!1,allow_delete:!1},flow_stack:{allow_create:!1,allow_edit:!1,allow_activate:!1,allow_execute:!1,allow_save_as_template:!1,allow_delete:!1},mado_browser:{enabled:!1,allow_external_urls:!1,allow_login_profiles:!1,allow_authenticated_sessions:!1,allow_file_downloads:!1,allow_file_uploads:!1,allow_form_submit:!1,allow_headless_mode:!0,allow_visible_mode:!0,capture_screenshots:!0,require_verification:!0,audit_all_actions:!0},visual_intake:{allow_image_intake:!0,allow_local_vision:!0,allow_cloud_vision:!1,allow_ocr:!0,allow_attach_to_stack:!0,allow_auto_memory:!1,allow_delete:!0,retention_days:30,max_upload_mb:20},ide_mode:{enabled:!1,file_read:!0,file_search:!0,file_create:!0,file_patch:!0,file_delete:!1,diagnostics:!0,approved_tasks_only:!0,terminal_approved_only:!0,package_install:!1,git_status:!0,git_diff:!0,git_branch_create:!1,git_commit:!1,git_push:!1,secrets_access:!1,require_snapshot:!0,audit_all_actions:!0,self_verification_required:!0}},w=()=>{let[e,h]=(0,b.useState)(`general`),[re,v]=(0,b.useState)(!0),[w,T]=(0,b.useState)(!1),[E,D]=(0,b.useState)(null),[O,de]=(0,b.useState)(null),[k,A]=(0,b.useState)({name:``,type:`memory_consolidation`,frequency:`nightly`,scheduleTime:`02:00`,scheduleDays:[`mon`,`wed`,`fri`],scheduleDay:1,minuteOffset:0,scheduleDateTime:``,priority:50,memoryTypes:[`episodic`,`semantic`],taskInstruction:``,allAgents:!0,dryRun:!1,autoApprove:!1}),[fe,pe]=(0,b.useState)([]),[me,j]=(0,b.useState)({}),[M,he]=(0,b.useState)(!1),N=m(),ge=te(),{t:P}=ie(),[F,I]=(0,b.useState)({name:`Shogun Prime`,slug:`primary-shogun`,status:`active`,persona_id:``,model_routing_profile_id:``,security_policy_id:``,description:`Master orchestrator of the Samurai Network.`,autonomy:50,risk_tolerance:`low`,verbosity:`medium`}),[L,_e]=(0,b.useState)([]),[ve,ye]=(0,b.useState)([]),[be,xe]=(0,b.useState)([]),[Se,Ce]=(0,b.useState)([]),[we,Te]=(0,b.useState)([]),[R,Ee]=(0,b.useState)(``),[z,B]=(0,b.useState)([]),[V,H]=(0,b.useState)(null),[U,W]=(0,b.useState)(``),[G,De]=(0,b.useState)(null),[Oe,ke]=(0,b.useState)(!1),Ae=e=>{if(!e)return 0;let t=0,n=(n,r,i,a)=>{let o=e?.[n]||e?.[n.toUpperCase()]||e?.[n.toLowerCase()];if(!o)return;let s=o[r]??o[r.toUpperCase()]??o[r.toLowerCase()];s!==void 0&&i.includes(s)&&(t+=a)};return n(`filesystem`,`mode`,[`full`,`FULL`],15),n(`filesystem`,`allow_home_access`,[!0],10),n(`filesystem`,`allow_arbitrary_paths`,[!0],15),n(`network`,`mode`,[`full`,`FULL`],15),n(`network`,`allow_arbitrary_requests`,[!0],10),n(`shell`,`enabled`,[!0],15),n(`skills`,`allow_auto_install`,[!0],5),n(`skills`,`allow_untrusted`,[!0],10),n(`subagents`,`allow_spawn`,[!0],5),n(`subagents`,`allow_auto_spawn`,[!0],10),n(`memory`,`allow_bulk_delete`,[!0],10),n(`agentflow`,`allow_create`,[!0],5),n(`agentflow`,`allow_activate`,[!0],5),n(`agentflow`,`allow_execute`,[!0],5),n(`agentflow`,`allow_delete`,[!0],5),n(`flow_stack`,`allow_create`,[!0],5),n(`flow_stack`,`allow_activate`,[!0],5),n(`flow_stack`,`allow_execute`,[!0],10),n(`flow_stack`,`allow_delete`,[!0],5),n(`filesystem`,`mode`,[`scoped`,`SCOPED`,`disabled`,`DISABLED`],-5),n(`network`,`mode`,[`disabled`,`DISABLED`],-10),n(`shell`,`enabled`,[!1],-5),n(`skills`,`require_approval`,[!0],-5),Math.max(0,Math.min(100,t))},je={filesystem:{_category:`Controls what files and folders the agent can read, write, or access on your system.`,mode:`How freely the agent can access files. "Full" = unrestricted, "Scoped" = only in designated folders, "Disabled" = no file access.`,allowed_paths:`Specific folders the agent is allowed to work in when in Scoped mode.`,allow_home_access:`Whether the agent can read or write files in your personal home directory.`,allow_arbitrary_paths:`Whether the agent can access ANY folder on the system, even outside its designated workspace.`},network:{_category:`Controls all external connectivity, including direct network requests and governed Mado browser sessions.`,mode:`How freely the agent can use the network. "Full" = unrestricted, "Allowlist" = only approved sites, "Disabled" = no internet.`,allowed_domains:`Specific websites or APIs the agent is allowed to contact when in Allowlist mode.`,allow_arbitrary_requests:`Whether the agent can contact ANY website or API, even ones not on the approved list.`},mado_browser:{_category:`Controls governed browser navigation, authenticated sessions, form interaction, downloads, uploads, screenshots, and verification.`,enabled:`Whether Mado browser automation is available to the agent.`,allow_external_urls:`Allow navigation to external websites, subject to the Network allowlist and posture controls.`,allow_login_profiles:`Allow the agent to use operator-configured browser login profiles.`,allow_authenticated_sessions:`Allow Mado to continue in authenticated browser sessions.`,allow_file_downloads:`Allow files to be downloaded through Mado.`,allow_file_uploads:`Allow local files to be uploaded through Mado.`,allow_form_submit:`Allow Mado to submit forms, subject to ToolGate checks.`,allow_headless_mode:`Allow browser sessions without a visible browser window.`,allow_visible_mode:`Allow visible, operator-observable browser sessions.`,capture_screenshots:`Allow Mado to capture page screenshots for evidence and visual inspection.`,require_verification:`Require post-action verification before a browser task is considered complete.`,audit_all_actions:`Record every Mado action in the audit log.`},shell:{_category:`Controls whether the agent can run system commands (like terminal/command-line operations).`,enabled:`Whether the agent is allowed to execute system commands at all.`,allowed_binaries:`Specific programs the agent is allowed to run (e.g., "python", "git"). Empty means none.`},skills:{_category:`Controls how the agent discovers, installs, and uses skill modules (plugins).`,allow_auto_install:`Whether the agent can automatically download and install new skills without asking.`,require_approval:`Whether a human must approve before the agent uses any new skill for the first time.`,allow_untrusted:`Whether the agent can use skills from unverified or third-party sources.`},subagents:{_category:`Controls whether the agent can create and manage helper agents (Samurai) to delegate tasks.`,allow_spawn:`Whether the agent is allowed to create sub-agents at all.`,max_active:`Maximum number of sub-agents that can be running at the same time.`,allow_auto_spawn:`Whether the agent can create sub-agents on its own without asking for permission first.`},memory:{_category:`Controls how the agent stores and manages its knowledge and conversation history.`,allow_write:`Whether the agent can save new information to its long-term memory.`,allow_bulk_delete:`Whether the agent can erase large amounts of its stored knowledge at once.`},agentflow:{_category:`Controls what Shogun may do autonomously with individual AgentFlows. All capabilities are disabled by default and remain limited to Tactical, Campaign, and Ronin posture.`,allow_create:`Allow Shogun to create a new AgentFlow without the operator building it manually.`,allow_edit:`Allow Shogun to change nodes, connectors, and configuration in an existing AgentFlow.`,allow_activate:`Allow Shogun to activate a created AgentFlow. When disabled, Shogun-created flows remain drafts.`,allow_execute:`Allow Shogun to start an AgentFlow run autonomously.`,allow_save_as_template:`Allow Shogun to save AgentFlows as reusable templates.`,allow_delete:`Allow Shogun to delete AgentFlows.`},flow_stack:{_category:`Controls what Shogun may do autonomously with multi-flow stacks and their orchestrators. All capabilities are disabled by default and require Tactical, Campaign, or Ronin posture.`,allow_create:`Allow Shogun to compose connected AgentFlows into a new Flow Stack.`,allow_edit:`Allow Shogun to change stack phases, connectors, and orchestrator configuration.`,allow_activate:`Allow Shogun to activate a created Flow Stack. When disabled, Shogun-created stacks remain drafts.`,allow_execute:`Allow Shogun to start a Flow Stack orchestrator run autonomously.`,allow_save_as_template:`Allow Shogun to save Flow Stacks as reusable templates.`,allow_delete:`Allow Shogun to delete Flow Stacks.`},visual_intake:{_category:`Controls how images from chat and Telegram are stored, analyzed, remembered, and passed into Flow Stacks.`,allow_image_intake:`Accept valid images in chat and connected channels and store them as governed artifacts.`,allow_local_vision:`Allow connected local vision models to inspect images.`,allow_cloud_vision:`Allow image bytes to be sent to a connected cloud vision provider. Disabled by default.`,allow_ocr:`Allow Shogun to extract visible text from images.`,allow_attach_to_stack:`Allow image artifacts to become durable inputs to Flow Stack runs.`,allow_auto_memory:`Allow Shogun to preserve image-derived knowledge automatically. Disabled by default.`,allow_delete:`Allow governed deletion of image artifacts.`,retention_days:`Days to retain unpinned images before automatic cleanup.`,max_upload_mb:`Maximum size of one accepted image.`},ide_mode:{_category:`Controls governed access to approved VS Code workspaces. This entire section is unavailable below Campaign posture.`,enabled:`Master permission for Shogun IDE Mode. Runtime enablement still requires explicit confirmation.`,file_read:`Read files inside an approved workspace.`,file_search:`Search inside an approved workspace.`,file_create:`Create files after a restore point is made.`,file_patch:`Apply reviewed patches and retain a unified diff.`,file_delete:`Delete files. Campaign also requires explicit approval.`,diagnostics:`Read VS Code Problems and diagnostics.`,approved_tasks_only:`Restrict automatic execution to approved development tasks.`,terminal_approved_only:`Only allow allowlisted or explicitly approved commands.`,package_install:`Allow dependency installation. Keep disabled unless the repository is trusted.`,git_status:`Inspect Git status.`,git_diff:`Inspect Git diffs.`,git_branch_create:`Create local branches.`,git_commit:`Create commits after approval.`,git_push:`Push to remotes. Disabled by default, including Ronin.`,secrets_access:`Read protected secret files. Disabled by default.`,require_snapshot:`Create a rollback point before every write.`,audit_all_actions:`Send all IDE actions through EventLogger.`,self_verification_required:`Require tests/build/diagnostic verification before completion.`}},K=(e,t)=>{let n=e.toLowerCase();return t?je[n]?.[t.toLowerCase()]||je[n]?.[t]||``:je[n]?._category||``},q=be.find(e=>e.id===F.security_policy_id),J=String(q?.tier||``).toLowerCase(),Y=[`tactical`,`campaign`,`ronin`].includes(J),Me=[`campaign`,`ronin`].includes(J),X=V||q?.permissions||null,Z=X?{...X,agentflow:{...C.agentflow,...X.agentflow||{}},flow_stack:{...C.flow_stack,...X.flow_stack||{}},mado_browser:{...C.mado_browser,...X.mado_browser||{}},visual_intake:{...C.visual_intake,...X.visual_intake||{}},ide_mode:{...C.ide_mode,...X.ide_mode||{}}}:null,Ne=q?.permissions||null,Pe=V!==null&&JSON.stringify(V)!==JSON.stringify(Ne),Q=Ae(Z);(0,b.useEffect)(()=>{Ie()},[]),(0,b.useEffect)(()=>{e===`permissions`&&y.get(`/api/v1/ronin/desktop/status`).then(e=>De(e.data?.data)).catch(()=>De(null))},[e]);let Fe=async e=>{if(!(e&&!confirm(`Ronin Desktop Control can operate the real mouse, keyboard, windows, and applications. Actions remain visible, verified, audited, and protected by the kill switch. Enable it?`))){ke(!0);try{let t=e?await y.post(`/api/v1/ronin/desktop/enable`,{confirmation:`ENABLE RONIN DESKTOP CONTROL`,ronin_screenshots_enabled:!0,ronin_mouse_enabled:!0,ronin_keyboard_enabled:!0,ronin_window_management_enabled:!0,ronin_native_apps_enabled:!0,ronin_require_verification:!0,ronin_require_high_risk_approval:!0,ronin_block_critical_actions:!0,ronin_visible_indicator:!0}):await y.post(`/api/v1/ronin/desktop/disable`);De(t.data?.data),D({type:`success`,text:`Ronin Desktop Control ${e?`enabled`:`disabled`}.`})}catch(e){D({type:`error`,text:S(e,`Could not update Ronin Desktop Control.`)})}finally{ke(!1)}}};(0,b.useEffect)(()=>{let e=new URLSearchParams(ge.search);e.get(`tab`)===`operations`?h(`operations`):e.get(`tab`)===`permissions`&&N(`/toolgate`,{replace:!0})},[ge.search,N]);let Ie=async()=>{v(!0);try{let[e,t,n,r,i,a,o,s]=await Promise.allSettled([y.get(`/api/v1/agents/shogun`),y.get(`/api/v1/personas`),y.get(`/api/v1/models/routing/profiles`),y.get(`/api/v1/security/policies`),y.get(`/api/v1/system/health`),y.get(`/api/v1/model-providers`),y.get(`/api/v1/models/registry`),y.get(`/api/v1/tools`)]);if(e.status===`fulfilled`&&e.value.data.data){let t=e.value.data.data;I(t);let r=t.bushido_settings||{},i=r.primary_model||``,s=r.fallback_models||[],c=n.status===`fulfilled`&&n.value.data.data||[],l=o.status===`fulfilled`&&o.value.data.data||[],u=c.find(e=>e.id===t.model_routing_profile_id);if(u?.name===`Custom`){let e=u.rules?.find(e=>e.task_type===`*`)||u.rules?.[0],t=e=>{if(!e||e.includes(`::`))return e;let t=l.find(t=>t.id===e||t.model_id===e);return t?.provider_id?`${t.provider_id}::${t.model_id}`:e};e?.primary_model_id&&(i=t(String(e.primary_model_id))),e?.fallback_model_ids&&(s=e.fallback_model_ids.map(e=>t(String(e))))}r.custom_permissions&&H(r.custom_permissions);let d=a.status===`fulfilled`&&a.value.data.data?a.value.data.data:[],f=e=>{if(!e||!e.includes(`::`))return e;let[t,n]=e.split(`::`,2);if(d.some(e=>e.id===t))return e;for(let e of d)if((e.config?.models||[]).includes(n)||e.name===n)return`${e.id}::${n}`;return e};i=f(i),s=s.map(f),i&&Ee(i),s.length>0&&B(s)}i.status===`fulfilled`&&i.value.data.data&&de(i.value.data.data),t.status===`fulfilled`&&t.value.data.data&&_e(t.value.data.data),n.status===`fulfilled`&&n.value.data.data&&ye(n.value.data.data),r.status===`fulfilled`&&r.value.data.data&&xe(r.value.data.data),a.status===`fulfilled`&&a.value.data.data&&Ce(a.value.data.data),s.status===`fulfilled`&&s.value.data.data&&Te(s.value.data.data);try{let e=await y.get(`/api/v1/bushido/schedules`);e.data.data&&pe(e.data.data)}catch{}}catch(e){console.error(`Error fetching Shogun data:`,e)}finally{v(!1)}},$=async()=>{try{let e=await y.get(`/api/v1/bushido/schedules`);e.data.data&&pe(e.data.data)}catch{}},Le=async e=>{try{await y.patch(`/api/v1/bushido/schedules/preset/${e}/toggle`),await $()}catch{D({type:`error`,text:`Failed to toggle schedule.`}),setTimeout(()=>D(null),3e3)}},Re=e=>fe.find(t=>t.source!==`agent_flow`&&t.job_type===e&&t.is_preset),ze=async()=>{T(!0),D(null);try{let e=ve.find(e=>e.id===F.model_routing_profile_id);if(e?.name===`Custom`){if(!R)throw Error(`Choose at least one model for Custom routing.`);await y.post(`/api/v1/models/routing/profiles/${e.id}/update`,{rules:[{task_type:`*`,primary_model_id:R,fallback_model_ids:z}]})}e&&await y.post(`/api/v1/models/routing/profiles/active`,{profile_id:e.id});let t={...F,bushido_settings:{...F.bushido_settings||{},primary_model:R,fallback_models:z,custom_permissions:V}};await y.patch(`/api/v1/agents/${F.id}`,t),D({type:`success`,text:`Shogun configuration saved successfully.`})}catch(e){D({type:`error`,text:e?.message||`Failed to save configuration.`})}finally{T(!1),setTimeout(()=>D(null),3e3)}},Be=async()=>{if(!(!U.trim()||!V)){T(!0),D(null);try{let e=be.find(e=>e.id===F.security_policy_id),t=e?.tier||`tactical`,n=(await y.post(`/api/v1/security/policies`,{name:U.trim(),tier:t,description:`Custom policy derived from ${e?.name||`base policy`}`,permissions:V,kill_switch_enabled:!0,dry_run_supported:!0})).data?.data?.id;if(!n)throw Error(`Policy creation returned no ID`);let r={...F.bushido_settings||{},primary_model:R,fallback_models:z,custom_permissions:null};await y.patch(`/api/v1/agents/${F.id}`,{security_policy_id:n,bushido_settings:r}),H(null),W(``),I(e=>({...e,security_policy_id:n,bushido_settings:r}));try{let e=await y.get(`/api/v1/security/policies`);e.data?.data&&xe(e.data.data)}catch{}D({type:`success`,text:`Custom policy "${U.trim()}" created and assigned.`})}catch(e){let t=e?.response?.data?.detail||`Failed to create custom policy.`;D({type:`error`,text:t})}finally{T(!1),setTimeout(()=>D(null),4e3)}}},Ve=(0,b.useRef)(null);return re?(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,x.jsx)(`div`,{className:`w-8 h-8 border-4 border-shogun-gold border-t-transparent rounded-full animate-spin`})}):(0,x.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-5xl mx-auto pb-12`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,x.jsxs)(`div`,{onClick:()=>{Ve.current?.click()},className:`w-20 h-20 bg-shogun-card rounded-2xl border border-shogun-gold/30 flex items-center justify-center shadow-shogun relative cursor-pointer group hover:border-shogun-gold/60 transition-all overflow-hidden`,children:[F.avatar_url?(0,x.jsx)(`img`,{src:F.avatar_url,alt:`Shogun Avatar`,className:`w-full h-full object-cover`}):(0,x.jsx)(`img`,{src:`/assets/shogun-default-avatar.jpg`,alt:`Shogun Avatar`,className:`w-full h-full object-cover`}),(0,x.jsx)(`div`,{className:`absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,x.jsx)(o,{className:`w-6 h-6 text-shogun-gold`})}),(0,x.jsx)(`div`,{className:`absolute -bottom-1 -right-1 w-5 h-5 bg-green-500 border-2 border-[#0a0e1a] rounded-full shadow-lg`})]}),(0,x.jsx)(`input`,{type:`file`,ref:Ve,className:`hidden`,accept:`image/*`,onChange:async e=>{let t=e.target.files?.[0];if(!t)return;let n=new FormData;n.append(`file`,t);try{D({type:`success`,text:`Uploading avatar...`});let e=await y.post(`/api/v1/agents/${F.id}/avatar`,n,{headers:{"Content-Type":`multipart/form-data`}});I({...F,avatar_url:e.data.data.avatar_url}),D({type:`success`,text:`Avatar updated successfully.`})}catch(e){console.error(`Avatar upload failed:`,e),D({type:`error`,text:`Failed to upload avatar.`})}finally{setTimeout(()=>D(null),3e3)}}}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h2`,{className:`text-3xl font-bold shogun-title`,children:F.name}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[(0,x.jsx)(`span`,{className:`text-[10px] bg-shogun-gold/10 text-shogun-gold px-2 py-0.5 rounded border border-shogun-gold/20 font-bold tracking-widest uppercase`,children:P(`shogun_profile.primary_agent`,`Primary Agent`)}),(0,x.jsxs)(`span`,{className:`text-xs text-shogun-subdued flex items-center gap-1`,children:[(0,x.jsx)(p,{className:`w-3 h-3`}),` `,P(`profile.system_orchestrator`,`System Orchestrator`)]})]})]})]}),(0,x.jsxs)(`button`,{onClick:ze,disabled:w,className:`flex items-center justify-center gap-2 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold py-2 px-6 rounded-lg transition-all shadow-shogun disabled:opacity-50`,children:[w?(0,x.jsx)(`div`,{className:`w-4 h-4 border-2 border-black border-t-transparent rounded-full animate-spin`}):(0,x.jsx)(u,{className:`w-4 h-4`}),P(`common.save_changes`,`SAVE CHANGES`)]})]}),E&&(0,x.jsxs)(`div`,{className:_(`p-3 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,E.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[E.type===`success`?(0,x.jsx)(i,{className:`w-4 h-4`}):(0,x.jsx)(r,{className:`w-4 h-4`}),(0,x.jsx)(`span`,{className:`text-sm font-medium`,children:E.text})]}),(0,x.jsx)(`div`,{className:`flex border-b border-shogun-border`,children:[`general`,`behavior`,`operations`].map(t=>(0,x.jsxs)(`button`,{onClick:()=>h(t),className:_(`px-6 py-3 text-sm font-bold uppercase tracking-widest transition-all relative`,e===t?`text-shogun-gold`:`text-shogun-subdued hover:text-shogun-text`),children:[P(`shogun_profile.tab_${t}`,t),e===t&&(0,x.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-gold shadow-[0_0_10px_rgba(212,160,23,0.5)]`})]},t))}),(0,x.jsxs)(`div`,{className:`mt-6`,children:[e===`general`&&(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(ae,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`shogun_profile.identity`,`Identity & Persona`)]}),(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.agent_name`,`Agent Name`)}),(0,x.jsx)(`input`,{type:`text`,value:F.name,onChange:e=>I({...F,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.active_persona`,`Active Persona`)}),(0,x.jsxs)(`select`,{value:F.persona_id||``,onChange:e=>{let t=L.find(t=>t.id===e.target.value);I({...F,persona_id:e.target.value,description:t?.description||F.description,autonomy:t?t.autonomy===`high`?80:t.autonomy===`low`?20:50:F.autonomy,risk_tolerance:t?.risk_tolerance||F.risk_tolerance,verbosity:t?.verbosity||F.verbosity,tone:t?.tone||F.tone||`analytical`,planning_depth:t?.planning_depth||F.planning_depth||`medium`,tool_usage_style:t?.tool_usage_style||F.tool_usage_style||`balanced`,security_bias:t?.security_bias||F.security_bias||`balanced`,memory_style:t?.memory_style||F.memory_style||`focused`})},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.select_persona`,`Select a persona...`)}),L.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),F.persona_id&&(()=>{let e=L.find(e=>e.id===F.persona_id);return e?(0,x.jsxs)(`div`,{className:`grid grid-cols-3 gap-1.5 mt-2`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-center py-1 rounded bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/20 uppercase font-bold`,children:P(`profile.trait_${e.tone}`,e.tone)}),(0,x.jsx)(`span`,{className:`text-[8px] text-center py-1 rounded bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20 uppercase font-bold`,children:P(`profile.trait_${e.security_bias}`,e.security_bias)}),(0,x.jsx)(`span`,{className:`text-[8px] text-center py-1 rounded bg-green-500/10 text-green-500 border border-green-500/20 uppercase font-bold`,children:P(`profile.trait_${e.autonomy}`,e.autonomy)})]}):null})()]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.description`,`Description`)}),(0,x.jsx)(`textarea`,{value:F.description||``,onChange:e=>I({...F,description:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors min-h-[100px]`})]})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(ee,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`shogun_profile.autonomy_logic`,`Autonomy & Logic`)]}),(0,x.jsxs)(`div`,{className:`space-y-5 pt-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.autonomy_level`,`Autonomy Level`)}),(0,x.jsxs)(`span`,{className:`text-shogun-blue font-mono font-bold`,children:[F.autonomy,`%`]})]}),(0,x.jsx)(`input`,{type:`range`,min:`0`,max:`100`,step:`10`,value:F.autonomy,onChange:e=>I({...F,autonomy:parseInt(e.target.value)}),className:`w-full accent-shogun-blue`}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued italic`,children:P(`profile.autonomy_desc`,`Higher levels allow Shogun to spawn sub-agents and execute complex tools without explicit operator confirmation.`)})]}),(0,x.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_tone`,`Tone`)}),(0,x.jsxs)(`select`,{value:F.tone||`analytical`,onChange:e=>I({...F,tone:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`analytical`,children:P(`setup.step3_tone_analytical`,`Analytical`)}),(0,x.jsx)(`option`,{value:`direct`,children:P(`setup.step3_tone_direct`,`Direct`)}),(0,x.jsx)(`option`,{value:`supportive`,children:P(`setup.step3_tone_supportive`,`Supportive`)}),(0,x.jsx)(`option`,{value:`strategic`,children:P(`setup.step3_tone_strategic`,`Strategic`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_risk`,`Risk Tolerance`)}),(0,x.jsxs)(`select`,{value:F.risk_tolerance,onChange:e=>I({...F,risk_tolerance:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`low`,children:P(`setup.step3_risk_low`,`Low (Cautious)`)}),(0,x.jsx)(`option`,{value:`medium`,children:P(`setup.step3_risk_medium`,`Medium (Balanced)`)}),(0,x.jsx)(`option`,{value:`high`,children:P(`setup.step3_risk_high`,`High (Aggressive)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_verbosity`,`Verbosity`)}),(0,x.jsxs)(`select`,{value:F.verbosity,onChange:e=>I({...F,verbosity:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`low`,children:P(`setup.step3_verbosity_low`,`Concise`)}),(0,x.jsx)(`option`,{value:`medium`,children:P(`setup.step3_verbosity_medium`,`Moderate`)}),(0,x.jsx)(`option`,{value:`high`,children:P(`setup.step3_verbosity_high`,`Detailed`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_planning`,`Planning Depth`)}),(0,x.jsxs)(`select`,{value:F.planning_depth||`medium`,onChange:e=>I({...F,planning_depth:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`low`,children:P(`setup.step3_planning_low`,`Shallow (Act fast)`)}),(0,x.jsx)(`option`,{value:`medium`,children:P(`setup.step3_planning_medium`,`Standard (Plan then act)`)}),(0,x.jsx)(`option`,{value:`high`,children:P(`setup.step3_planning_high`,`Deep (Exhaustive planning)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_tool_usage`,`Tool Usage`)}),(0,x.jsxs)(`select`,{value:F.tool_usage_style||`balanced`,onChange:e=>I({...F,tool_usage_style:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`conservative`,children:P(`setup.step3_tool_conservative`,`Conservative (Minimal)`)}),(0,x.jsx)(`option`,{value:`balanced`,children:P(`setup.step3_tool_balanced`,`Balanced`)}),(0,x.jsx)(`option`,{value:`aggressive`,children:P(`setup.step3_tool_aggressive`,`Aggressive (Chain freely)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_security_bias`,`Security Bias`)}),(0,x.jsxs)(`select`,{value:F.security_bias||`balanced`,onChange:e=>I({...F,security_bias:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`strict`,children:P(`setup.step3_security_strict`,`Strict (Least privilege)`)}),(0,x.jsx)(`option`,{value:`balanced`,children:P(`setup.step3_security_balanced`,`Balanced`)}),(0,x.jsx)(`option`,{value:`open`,children:P(`setup.step3_security_open`,`Open (Trust-first)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_memory`,`Memory Style`)}),(0,x.jsxs)(`select`,{value:F.memory_style||`focused`,onChange:e=>I({...F,memory_style:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`conservative`,children:P(`setup.step3_memory_conservative`,`Conservative (Minimal retention)`)}),(0,x.jsx)(`option`,{value:`focused`,children:P(`setup.step3_memory_focused`,`Focused (Task-relevant)`)}),(0,x.jsx)(`option`,{value:`expansive`,children:P(`setup.step3_memory_expansive`,`Expansive (Broad context)`)})]})]})]})]})]}),(0,x.jsx)(`div`,{className:`shogun-card md:col-span-2`,children:(0,x.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 sm:flex-row sm:items-center`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsx)(ne,{className:`mt-0.5 h-5 w-5 text-shogun-gold`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text`,children:`Security is owned by ToolGate`}),(0,x.jsxs)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:[q?.name||`No policy assigned`,` · `,J?J.toUpperCase():`UNKNOWN`,` base tier · Capability risk `,Q,`/100`]}),(0,x.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-shogun-subdued`,children:`Torii selects the policy. ToolGate configures capability boundaries, runtime Allow/Confirm/Block rules, approvals, and risk.`})]})]}),(0,x.jsx)(`button`,{onClick:()=>N(`/toolgate`),className:`rounded-lg border border-shogun-gold/30 bg-shogun-gold/10 px-4 py-2.5 text-xs font-bold text-shogun-gold hover:bg-shogun-gold/20`,children:`Open ToolGate`})]})})]}),e===`models`&&(()=>{let e=Se.filter(e=>e.status!==`disabled`).flatMap(e=>(e.config?.models?.length?e.config.models:e.config?.model_id?[e.config.model_id]:[e.name]).map(t=>({value:`${e.id}::${t}`,label:t,group:`${e.provider_type?.toUpperCase()} — ${e.name}`,providerType:e.provider_type}))),t=ve.find(e=>e.id===F.model_routing_profile_id),n=t?.name===`Custom`;return(0,x.jsxs)(`div`,{className:`space-y-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(p,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`profile.routing_strategy`,`Routing Strategy`)]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`The routing profile controls model selection. Presets choose automatically; Custom uses your ordered model list.`})]}),(0,x.jsxs)(`select`,{value:F.model_routing_profile_id||``,onChange:e=>I({...F,model_routing_profile_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:`— Select routing strategy —`}),ve.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),t?.description&&(0,x.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:t.description})]}),n?(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(o,{className:`w-5 h-5 text-shogun-blue`}),` Custom Primary Model`]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Preferred first when it satisfies the task's capability and safety requirements.`})]}),e.length===0?(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl text-center space-y-2`,children:[(0,x.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:P(`profile.no_providers`,`No active providers found.`)}),(0,x.jsx)(`button`,{onClick:()=>N(`/katana`),className:`text-xs text-shogun-blue hover:text-shogun-gold font-bold uppercase tracking-widest`,children:P(`profile.configure_katana`,`Configure in The Katana →`)})]}):(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.select_model`,`Select Model`)}),(0,x.jsxs)(`select`,{value:R,onChange:e=>Ee(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm font-mono focus:border-shogun-gold outline-none transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.choose_model`,`— Choose a model —`)}),Se.filter(e=>e.status!==`disabled`).map(e=>{let t=e.config?.models?.length?e.config.models:e.config?.model_id?[e.config.model_id]:[e.name];return(0,x.jsx)(`optgroup`,{label:`${e.provider_type?.toUpperCase()} — ${e.name}`,children:t.map(t=>(0,x.jsx)(`option`,{value:`${e.id}::${t}`,children:t},`${e.id}::${t}`))},e.id)})]}),R&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 p-2.5 rounded-lg bg-shogun-gold/5 border border-shogun-gold/20`,children:[(0,x.jsx)(i,{className:`w-3.5 h-3.5 text-shogun-gold shrink-0`}),(0,x.jsx)(`span`,{className:`text-xs font-mono text-shogun-gold font-bold truncate`,children:R.split(`::`)[1]}),(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued ml-auto shrink-0`,children:P(`profile.primary_tag`,`PRIMARY`)})]})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(p,{className:`w-5 h-5 text-shogun-gold`}),` Custom Fallback Models`]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:P(`profile.fallback_models_desc`,`Used when the primary is unavailable. Order matters.`)})]}),(0,x.jsxs)(`span`,{className:`text-[10px] bg-shogun-gold/10 text-shogun-gold px-2 py-0.5 rounded border border-shogun-gold/20 font-bold shrink-0`,children:[z.length,` `,P(`profile.selected`,`selected`)]})]}),e.length===0?(0,x.jsx)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl text-center`,children:(0,x.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:P(`profile.no_providers_short`,`No active providers.`)})}):(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.add_fallback`,`Add Fallback`)}),(0,x.jsxs)(`select`,{value:``,onChange:e=>{let t=e.target.value;t&&t!==R&&!z.includes(t)&&B(e=>[...e,t])},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm font-mono focus:border-shogun-blue outline-none transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.add_fallback_placeholder`,`— Add a fallback model —`)}),Se.filter(e=>e.status!==`disabled`).map(e=>{let t=e.config?.models?.length?e.config.models:e.config?.model_id?[e.config.model_id]:[e.name];return(0,x.jsx)(`optgroup`,{label:`${e.provider_type?.toUpperCase()} — ${e.name}`,children:t.filter(t=>{let n=`${e.id}::${t}`;return n!==R&&!z.includes(n)}).map(t=>(0,x.jsx)(`option`,{value:`${e.id}::${t}`,children:t},`${e.id}::${t}`))},e.id)})]})]}),z.length>0?(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.fallback_order`,`Fallback Order`)}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50`,children:P(`profile.drag_reorder`,`Drag to reorder priority.`)}),z.map((e,t)=>(0,x.jsxs)(`div`,{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t))},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},onDrop:e=>{e.preventDefault();let n=Number(e.dataTransfer.getData(`text/plain`));n!==t&&B(e=>{let r=[...e],[i]=r.splice(n,1);return r.splice(t,0,i),r})},className:`flex items-center gap-2 p-2.5 rounded-lg border border-shogun-blue/20 bg-shogun-blue/5 cursor-grab active:cursor-grabbing active:border-shogun-blue/50 active:bg-shogun-blue/10 transition-colors select-none`,children:[(0,x.jsx)(c,{className:`w-3.5 h-3.5 text-shogun-subdued/40 shrink-0`}),(0,x.jsxs)(`span`,{className:`text-[9px] font-bold text-shogun-blue w-5 shrink-0`,children:[`#`,t+1]}),(0,x.jsx)(`span`,{className:`text-xs font-mono text-shogun-text flex-1 truncate`,children:e.split(`::`)[1]}),(0,x.jsx)(`button`,{onClick:()=>B(t=>t.filter(t=>t!==e)),className:`text-shogun-subdued hover:text-red-400 transition-colors shrink-0 p-0.5`,title:`Remove`,children:(0,x.jsx)(g,{className:`w-3 h-3`})})]},e))]}):(0,x.jsx)(`p`,{className:`text-[11px] text-shogun-subdued italic text-center py-2`,children:P(`profile.no_fallbacks`,`No fallbacks selected — the primary model will always be used.`)})]})]})]}):(0,x.jsxs)(`div`,{className:`shogun-card border-shogun-blue/20 bg-shogun-blue/5`,children:[(0,x.jsxs)(`p`,{className:`text-sm font-medium`,children:[t?.name||`No routing profile selected`,` controls model choice automatically.`]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Choose Custom above to select and order the exact models Shogun may use.`})]})]})})(),e===`behavior`&&(0,x.jsxs)(`div`,{className:`shogun-card`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(le,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`shogun_profile.behavioral_directives`,`Behavioral Directives`)]}),(0,x.jsx)(`span`,{className:`text-[10px] font-mono text-shogun-subdued`,children:`v1.0.4-LTS`})]}),(0,x.jsxs)(`div`,{className:`relative group`,children:[(0,x.jsx)(`textarea`,{spellCheck:!1,defaultValue:`priorities: + - Safety before autonomy + - Use existing trusted skills when possible + - Escalate ambiguous high-risk actions + - Maintain stealth in network operations + +operational_constraints: + - shell_access: restricted_to_container + - memory_retention: long_term + - verification_threshold: 0.85 + +delegation_rules: + - research: delegate_to_samurai + - coding: delegate_to_samurai + - tactical_analysis: shogun_priority`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl p-6 font-mono text-xs leading-relaxed text-shogun-text focus:border-shogun-gold transition-colors min-h-[400px] resize-y scrollbar-hide`}),(0,x.jsx)(`div`,{className:`absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,x.jsx)(`span`,{className:`text-[10px] bg-shogun-card px-2 py-1 rounded border border-shogun-border text-shogun-subdued`,children:`YAML Mode`})})]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-4 italic`,children:`* Note: These directives are the core philosophical foundation that Shogun uses to validate its own reasoning processes.`})]}),e===`permissions`&&(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(oe,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`shogun_profile.authority_metrics`,`Authority Metrics`)]}),Pe&&(0,x.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-2 py-1 rounded border border-shogun-blue/30 bg-shogun-blue/10 text-shogun-blue`,children:P(`profile.custom`,`Custom`)})]}),(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] rounded-xl border border-shogun-border`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.security_risk_index`,`Security Risk Index`)}),(0,x.jsxs)(`span`,{className:_(`text-sm font-bold font-mono`,Q<=25?`text-green-400`:Q<=50?`text-shogun-gold`:Q<=75?`text-orange-400`:`text-red-400`),children:[Q,`/100`]})]}),(0,x.jsx)(`div`,{className:`w-full h-2.5 bg-[#0a0e1a] rounded-full overflow-hidden`,children:(0,x.jsx)(`div`,{className:_(`h-full rounded-full transition-all duration-500`,Q<=25?`bg-gradient-to-r from-green-500 to-green-400`:Q<=50?`bg-gradient-to-r from-green-400 via-yellow-400 to-shogun-gold`:Q<=75?`bg-gradient-to-r from-yellow-400 via-orange-400 to-orange-500`:`bg-gradient-to-r from-orange-500 via-red-500 to-red-600`),style:{width:`${Q}%`}})}),(0,x.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-green-400/60`,children:P(`profile.locked_down`,`LOCKED DOWN`)}),(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-gold/60`,children:P(`profile.risk_balanced`,`BALANCED`)}),(0,x.jsx)(`span`,{className:`text-[8px] text-red-400/60`,children:P(`profile.permissive`,`PERMISSIVE`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.base_policy`,`Base Policy`)}),(0,x.jsxs)(`select`,{value:F.security_policy_id||``,onChange:e=>{I({...F,security_policy_id:e.target.value}),H(null),W(``)},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.select_security_tier`,`Select security tier...`)}),be.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),Pe&&(0,x.jsxs)(`div`,{className:`space-y-1.5 p-3 bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:P(`profile.custom_policy_name`,`Custom Policy Name`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(`input`,{type:`text`,value:U,onChange:e=>W(e.target.value),placeholder:`e.g. Project Alpha — Relaxed`,className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`}),(0,x.jsx)(`button`,{onClick:Be,disabled:w||!U.trim(),className:`px-4 py-2 bg-shogun-blue/20 border border-shogun-blue/30 rounded-lg text-[10px] font-bold text-shogun-blue uppercase tracking-widest hover:bg-shogun-blue/30 transition-all disabled:opacity-40 disabled:cursor-not-allowed`,children:w?`...`:P(`common.save`,`Save`)})]})]}),(0,x.jsxs)(`div`,{className:_(`rounded-xl border p-3 text-[10px] leading-relaxed`,Y?`border-purple-500/25 bg-purple-500/5 text-purple-200`:`border-amber-500/25 bg-amber-500/5 text-amber-200`),children:[`AgentFlow and Flow Stack permissions are explicit and disabled by default. They can only be enabled under Tactical, Campaign, or Ronin posture. Current policy: `,(0,x.jsx)(`b`,{children:J?J.toUpperCase():`UNKNOWN`}),`.`]}),J===`ronin`&&(0,x.jsxs)(`div`,{className:`p-4 rounded-xl border border-orange-500/30 bg-orange-500/5 space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(s,{className:`w-4 h-4 text-orange-400`}),(0,x.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-orange-300`,children:`Ronin Desktop Control`})]}),(0,x.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued mt-1`,children:`Explicit runtime permission for mouse, keyboard, window management, application launch, screenshots, and verification. It remains disabled by default even after selecting Ronin posture.`})]}),(0,x.jsx)(`button`,{disabled:Oe||!G?.available,onClick:()=>Fe(!G?.active),className:_(`shrink-0 px-3 py-1.5 rounded-lg border text-[9px] font-bold uppercase tracking-wider disabled:opacity-40`,G?.active?`border-red-500/40 bg-red-500/10 text-red-400`:`border-orange-500/40 bg-orange-500/10 text-orange-300`),children:G?.active?`Disable desktop control`:G?.available?`Enable desktop control`:`Switch Torii to Ronin`})]}),(0,x.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:[[`Mouse actions`,G?.ronin_mouse_enabled],[`Keyboard actions`,G?.ronin_keyboard_enabled],[`Window management`,G?.ronin_window_management_enabled],[`Application launch`,G?.ronin_native_apps_enabled],[`Verification required`,G?.ronin_require_verification],[`Critical actions blocked`,G?.ronin_block_critical_actions]].map(([e,t])=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-shogun-border bg-[#050508] px-2.5 py-2`,children:[(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued`,children:e}),(0,x.jsx)(`span`,{className:_(`w-2 h-2 rounded-full`,t?`bg-green-400`:`bg-red-400`)})]},String(e)))}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] text-orange-200/70`,children:[(0,x.jsx)(`span`,{children:`High-risk actions require approval. Protected applications and credential contexts are blocked.`}),(0,x.jsx)(`button`,{onClick:()=>N(`/katana#ronin`),className:`font-bold text-orange-300 hover:text-orange-200`,children:`Open session view →`})]})]}),Z?Object.entries(Z).filter(([e])=>e!==`mado_browser`&&(e!==`ide_mode`||Me)).map(([e,n],r)=>(0,x.jsxs)(`div`,{className:`p-3 bg-[#050508] rounded-xl border border-shogun-border space-y-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 pb-1 border-b border-shogun-border/50 group/cat`,children:[(0,x.jsx)(oe,{className:`w-3.5 h-3.5 text-shogun-gold`}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-shogun-text cursor-help`,children:e===`network`?P(`profile.perm_cat_network_mado`,`Network & Mado Browser`):P(`profile.perm_cat_${e}`,e===`agentflow`?`AgentFlow`:e===`flow_stack`?`Flow Stack`:e.replace(/_/g,` `))}),K(e)&&(0,x.jsxs)(`div`,{className:`absolute left-0 bottom-full mb-2 w-64 p-2.5 bg-[#0a0e1a] border border-shogun-gold/30 rounded-lg text-[10px] text-shogun-text leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/cat:opacity-100 transition-opacity duration-200 z-50`,children:[(0,x.jsx)(`div`,{className:`absolute -bottom-1 left-4 w-2 h-2 bg-[#0a0e1a] border-r border-b border-shogun-gold/30 rotate-45`}),K(e)]})]}),(e===`agentflow`||e===`flow_stack`)&&(0,x.jsx)(`span`,{className:_(`ml-auto rounded border px-1.5 py-0.5 text-[8px] font-bold uppercase`,Y?`border-purple-500/30 bg-purple-500/10 text-purple-300`:`border-amber-500/30 bg-amber-500/10 text-amber-300`),children:Y?`Tactical+ available`:`Posture locked`}),e===`ide_mode`&&(0,x.jsx)(`span`,{className:`ml-auto rounded border border-purple-500/30 bg-purple-500/10 px-1.5 py-0.5 text-[8px] font-bold uppercase text-purple-300`,children:`Campaign / Ronin`})]}),typeof n==`object`&&n&&!Array.isArray(n)?(0,x.jsx)(`div`,{className:`grid gap-1`,children:Object.entries(n).map(([t,n],r)=>{let a=typeof n==`boolean`,o=t.toLowerCase()===`mode`,s=typeof n==`number`,c=Array.isArray(n),l=n=>{let r=JSON.parse(JSON.stringify(Z));r[e][t]=n,H(r)};return(0,x.jsxs)(`div`,{className:_(`py-1.5 px-2 rounded hover:bg-[#0a0e1a] transition-colors`,c?`space-y-2`:`flex items-center justify-between`),children:[(0,x.jsxs)(`div`,{className:`relative group/tip`,children:[(0,x.jsx)(`span`,{className:_(`text-[10px] text-shogun-subdued font-medium capitalize`,K(e,t)&&`border-b border-dashed border-shogun-subdued/30 cursor-help`),children:P(`profile.perm_prop_${t}`,t.replace(/_/g,` `).toLowerCase())}),K(e,t)&&(0,x.jsxs)(`div`,{className:`absolute left-0 bottom-full mb-2 w-56 p-2 bg-[#0a0e1a] border border-shogun-border rounded-lg text-[10px] text-shogun-text/80 leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/tip:opacity-100 transition-opacity duration-200 z-50`,children:[(0,x.jsx)(`div`,{className:`absolute -bottom-1 left-3 w-2 h-2 bg-[#0a0e1a] border-r border-b border-shogun-border rotate-45`}),K(e,t)]})]}),(0,x.jsx)(`div`,{className:_(`flex items-center gap-2`,c&&`flex-wrap`),children:a?(0,x.jsx)(`button`,{onClick:()=>l(!n),disabled:(e===`agentflow`||e===`flow_stack`)&&!Y||e===`ide_mode`&&!Me,className:_(`w-10 h-5 rounded-full relative transition-all duration-300 border`,(e===`agentflow`||e===`flow_stack`)&&!Y&&`cursor-not-allowed opacity-35`,n?`bg-green-500/20 border-green-500/40`:`bg-red-500/10 border-red-500/30`),children:(0,x.jsx)(`div`,{className:_(`absolute top-0.5 w-4 h-4 rounded-full transition-all duration-300`,n?`left-5 bg-green-400`:`left-0.5 bg-red-400`)})}):o?(0,x.jsxs)(`select`,{value:String(n),onChange:e=>l(e.target.value),className:`bg-[#0a0a10] border border-shogun-border rounded px-2 py-0.5 text-[10px] font-bold uppercase text-shogun-gold focus:border-shogun-gold transition-colors`,children:[(0,x.jsx)(`option`,{value:`full`,children:P(`profile.mode_full`,`Full`)}),(0,x.jsx)(`option`,{value:`scoped`,children:P(`profile.mode_scoped`,`Scoped`)}),(0,x.jsx)(`option`,{value:`allowlist`,children:P(`profile.mode_allowlist`,`Allowlist`)}),(0,x.jsx)(`option`,{value:`disabled`,children:P(`profile.mode_disabled`,`Disabled`)})]}):s?(0,x.jsx)(`input`,{type:`number`,value:n,onChange:e=>l(parseInt(e.target.value)||0),className:`w-16 bg-[#0a0a10] border border-shogun-border rounded px-2 py-0.5 text-[10px] font-bold text-shogun-blue text-center focus:border-shogun-blue transition-colors`}):c?(0,x.jsxs)(`div`,{className:`w-full space-y-1.5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.length===0&&(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued italic`,children:e.toLowerCase()===`network`&&t.toLowerCase()===`allowed_domains`?P(`profile.no_apis_selected`,`No APIs selected — choose from the Katana Toolbox below`):P(`profile.no_entries`,`No entries — type below to add`)}),n.map((e,t)=>(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-mono bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/20 px-2 py-0.5 rounded`,children:[e,(0,x.jsx)(`button`,{onClick:()=>{let e=[...n];e.splice(t,1),l(e)},className:`text-shogun-gold/50 hover:text-red-400 transition-colors ml-0.5`,children:`×`})]},t))]}),e.toLowerCase()===`network`&&t.toLowerCase()===`allowed_domains`?(0,x.jsxs)(`div`,{className:`space-y-1`,children:[we.length>0?we.map(e=>{let t=e.base_url?(()=>{try{return new URL(e.base_url).hostname}catch{return e.slug}})():e.slug,r=n.includes(t);return(0,x.jsxs)(`button`,{onClick:()=>{l(r?n.filter(e=>e!==t):[...n,t])},className:_(`w-full flex items-center justify-between p-2 rounded-lg border text-left transition-all`,r?`border-shogun-gold/40 bg-shogun-gold/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`div`,{className:_(`w-3.5 h-3.5 rounded border-2 flex items-center justify-center transition-all`,r?`border-shogun-gold bg-shogun-gold`:`border-shogun-subdued`),children:r&&(0,x.jsx)(i,{className:`w-2 h-2 text-black`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text`,children:e.name}),(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-subdued ml-2 font-mono`,children:t})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-blue/60 uppercase`,children:e.connector_type||`api`}),(0,x.jsx)(`span`,{className:_(`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded`,e.status===`connected`?`text-green-400 bg-green-500/10`:`text-shogun-subdued bg-[#0a0e1a]`),children:e.status===`connected`?P(`profile.status_active`,`Active`):e.status})]})]},e.id)}):(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic py-2`,children:P(`profile.no_tools`,`No tools or APIs registered in The Katana Toolbox yet.`)}),(0,x.jsxs)(`div`,{className:`pt-1 border-t border-shogun-border/30 space-y-1`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-subdued uppercase tracking-widest font-bold`,children:P(`profile.add_custom_website`,`Add Custom Website`)}),!n.includes(`*.*`)&&(0,x.jsxs)(`span`,{className:`text-[8px] text-shogun-subdued italic`,children:[P(`profile.type_wildcard`,`Type`),` `,(0,x.jsx)(`code`,{className:`text-red-400 font-mono font-bold`,children:`*.*`}),` `,P(`profile.to_allow_all`,`to allow all`)]})]}),n.includes(`*.*`)&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,x.jsx)(`span`,{className:`text-[9px] font-bold text-red-400 uppercase tracking-widest`,children:P(`profile.all_websites_warning`,`⚠ All websites permitted`)}),(0,x.jsx)(`span`,{className:`text-[8px] text-red-400/60`,children:P(`profile.all_websites_desc`,`— The agent can access any domain without restriction.`)})]}),(0,x.jsx)(`input`,{type:`text`,placeholder:`e.g. github.com or *.* for unrestricted`,className:`w-full bg-[#0a0a10] border border-shogun-border rounded px-2 py-1 text-[10px] font-mono text-shogun-text placeholder:text-shogun-subdued/40 focus:border-shogun-gold transition-colors`,onKeyDown:e=>{e.key===`Enter`&&e.target.value.trim()&&(l([...n,e.target.value.trim()]),e.target.value=``)}})]})]}):(0,x.jsx)(`input`,{type:`text`,placeholder:`Add ${t.replace(/_/g,` `).toLowerCase()}…`,className:`w-full bg-[#0a0a10] border border-shogun-border rounded px-2 py-1 text-[10px] font-mono text-shogun-text placeholder:text-shogun-subdued/40 focus:border-shogun-gold transition-colors`,onKeyDown:e=>{e.key===`Enter`&&e.target.value.trim()&&(l([...n,e.target.value.trim()]),e.target.value=``)}})]}):(0,x.jsx)(`span`,{className:_(`text-[10px] font-bold uppercase px-2 py-0.5 rounded border`,`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/20`),children:String(n)})})]},r)})}):(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued font-bold uppercase`,children:String(n)}),e===`network`&&Z.mado_browser&&(0,x.jsxs)(`div`,{className:`mt-3 border-t border-shogun-gold/20 pt-3 space-y-1`,children:[(0,x.jsxs)(`div`,{className:`group/mado relative mb-2 flex items-center gap-2`,children:[(0,x.jsx)(t,{className:`w-3.5 h-3.5 text-cyan-400`}),(0,x.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-[0.18em] text-cyan-300 cursor-help`,children:P(`profile.perm_section_mado`,`Mado browser`)}),(0,x.jsx)(`div`,{className:`absolute left-0 bottom-full mb-2 w-64 p-2.5 bg-[#0a0e1a] border border-cyan-400/30 rounded-lg text-[10px] text-shogun-text leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/mado:opacity-100 transition-opacity z-50`,children:K(`mado_browser`)})]}),Object.entries(Z.mado_browser).map(([e,t])=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between py-1.5 px-2 rounded hover:bg-[#0a0e1a] transition-colors`,children:[(0,x.jsxs)(`div`,{className:`relative group/mado-tip`,children:[(0,x.jsx)(`span`,{className:_(`text-[10px] text-shogun-subdued font-medium capitalize`,K(`mado_browser`,e)&&`border-b border-dashed border-shogun-subdued/30 cursor-help`),children:P(`profile.perm_prop_${e}`,e.replace(/_/g,` `).toLowerCase())}),K(`mado_browser`,e)&&(0,x.jsx)(`div`,{className:`absolute left-0 bottom-full mb-2 w-56 p-2 bg-[#0a0e1a] border border-shogun-border rounded-lg text-[10px] text-shogun-text/80 leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/mado-tip:opacity-100 transition-opacity z-50`,children:K(`mado_browser`,e)})]}),(0,x.jsx)(`button`,{onClick:()=>{let n=JSON.parse(JSON.stringify(Z));n.mado_browser[e]=!t,H(n)},className:_(`w-10 h-5 rounded-full relative transition-all duration-300 border`,t?`bg-green-500/20 border-green-500/40`:`bg-red-500/10 border-red-500/30`),children:(0,x.jsx)(`div`,{className:_(`absolute top-0.5 w-4 h-4 rounded-full transition-all duration-300`,t?`left-5 bg-green-400`:`left-0.5 bg-red-400`)})})]},e))]})]},r)):(0,x.jsx)(`p`,{className:`text-xs text-shogun-subdued italic p-4 text-center`,children:P(`profile.select_policy_prompt`,`Select a policy to view and customize constraints.`)}),Pe&&(0,x.jsx)(`button`,{onClick:()=>{H(null),W(``)},className:`w-full py-2 bg-[#050508] border border-shogun-border rounded-lg text-[10px] font-bold text-shogun-subdued hover:text-red-400 hover:border-red-400/30 transition-all uppercase tracking-widest`,children:P(`profile.reset_to_preset`,`Reset to Preset`)})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(p,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`profile.skill_inventory`,`Skill Inventory`)]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:[{name:P(`profile.skill_core_sentinel`,`Core Sentinel`),type:P(`profile.skill_type_system`,`System`),size:`124KB`},{name:P(`profile.skill_tactical_analyzer`,`Tactical Analyzer`),type:P(`profile.skill_type_intelligence`,`Intelligence`),size:`2.1MB`},{name:P(`profile.skill_samurai_spawner`,`Samurai Spawner`),type:P(`profile.skill_type_orchestration`,`Orchestration`),size:`450KB`}].map((e,t)=>(0,x.jsxs)(`div`,{onClick:()=>N(`/dojo`),className:`flex items-center justify-between p-3 border-b border-shogun-border last:border-0 hover:bg-[#0a0e1a] transition-colors rounded cursor-pointer group`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`text-sm font-bold text-shogun-text group-hover:text-shogun-gold transition-colors`,children:e.name}),(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:e.type})]}),(0,x.jsx)(n,{className:`w-4 h-4 text-shogun-border group-hover:text-shogun-gold transition-colors`})]},t))}),(0,x.jsx)(`button`,{onClick:()=>N(`/dojo`),className:`w-full py-2 bg-[#050508] border border-shogun-border rounded text-[10px] font-bold text-shogun-subdued hover:text-shogun-gold hover:border-shogun-gold transition-all uppercase tracking-widest`,children:P(`profile.browse_dojo`,`Browse Dojo for Skills`)})]})]}),e===`operations`&&(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(se,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`profile.system_diagnostics`,`System Diagnostics`)]}),(0,x.jsxs)(`div`,{className:`grid grid-cols-1 gap-4`,children:[(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:_(`p-2 rounded-lg`,O?.qdrant===`healthy`?`bg-green-500/10 text-green-500`:`bg-red-500/10 text-red-500`),children:(0,x.jsx)(ce,{className:`w-5 h-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-sm font-bold`,children:P(`profile.vector_engine`,`Vector Engine (Qdrant)`)}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:O?.qdrant===`healthy`?P(`profile.lattice_sync`,`Lattice Synchronized`):P(`profile.offline_error`,`Offline / Disk Error`)})]})]}),(0,x.jsx)(`span`,{className:_(`text-[8px] font-bold px-2 py-0.5 rounded border uppercase`,O?.qdrant===`healthy`?`text-green-500 border-green-500/30`:`text-red-500 border-red-500/30`),children:O?.qdrant||`offline`})]}),(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`p-2 rounded-lg bg-shogun-blue/10 text-shogun-blue`,children:(0,x.jsx)(d,{className:`w-5 h-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-sm font-bold`,children:P(`profile.relational_core`,`Relational Core`)}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.sqlite_optimal`,`SQLite Performance: Optimal`)})]})]}),(0,x.jsx)(`span`,{className:`text-[8px] font-bold text-green-500 border border-green-500/30 px-2 py-0.5 rounded uppercase`,children:P(`profile.healthy`,`Healthy`)})]})]}),(0,x.jsxs)(`div`,{className:`mt-4 p-4 bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,x.jsx)(l,{className:`w-3 h-3 text-shogun-blue animate-spin-slow`}),(0,x.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-blue`,children:P(`profile.lattice_sync_title`,`Lattice Sync`)})]}),(0,x.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:[P(`profile.lattice_sync_desc`,`Vector indices are automatically synchronized every 15 minutes.`),` `,P(`profile.last_sync`,`The last successful sync occurred`),` `,Math.floor(Math.random()*10)+1,` `,P(`profile.minutes_ago`,`minutes ago.`)]})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(a,{className:`w-5 h-5 text-shogun-gold`}),` Operational Cadence Presets`]}),(0,x.jsx)(`div`,{className:`space-y-4`,children:[{jobType:`memory_consolidation`,label:P(`profile.cron_nightly`,`Nightly Consolidation`),desc:P(`profile.cron_nightly_desc`,`Merge episodic traces into semantic memory.`),icon:l,cronLabel:P(`profile.cron_every_night_02`,`Every night at 02:00`)},{jobType:`performance_audit`,label:P(`profile.cron_weekly_audit`,`Weekly Performance Audit`),desc:P(`profile.cron_weekly_desc`,`Review agent fit metrics and behavioral drift.`),icon:oe,cronLabel:P(`profile.cron_every_mon_03`,`Every Monday at 03:00`)},{jobType:`skill_health_check`,label:P(`profile.cron_skill_check`,`Skill Health Check`),desc:P(`profile.cron_skill_desc`,`Verify third-party tool connectivity and versions.`),icon:f,cronLabel:P(`profile.cron_every_night_04`,`Every night at 04:00`)},{jobType:`persona_drift_check`,label:P(`profile.cron_drift`,`Persona Drift Monitor`),desc:P(`profile.cron_drift_desc`,`Detect deviations from core identity blueprints.`),icon:ae,cronLabel:P(`profile.cron_every_sun_05`,`Every Sunday at 05:00`)}].map(e=>{let t=Re(e.jobType),n=t?t.is_enabled:F.bushido_settings?.[e.jobType]??!1,r=me[e.jobType];return(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl space-y-3 group hover:border-shogun-gold/30 transition-all`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(e.icon,{className:`w-4 h-4 text-shogun-gold opacity-70`}),(0,x.jsx)(`span`,{className:`text-sm font-bold`,children:e.label})]}),(0,x.jsx)(`button`,{onClick:()=>Le(e.jobType),className:_(`w-10 h-5 rounded-full relative transition-all duration-300`,n?`bg-shogun-gold`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:_(`absolute top-1 w-3 h-3 rounded-full bg-white transition-all duration-300`,n?`left-6`:`left-1 bg-shogun-subdued`)})})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued italic`,children:e.desc}),(0,x.jsxs)(`button`,{disabled:r,className:_(`text-[9px] font-bold uppercase tracking-tighter transition-colors flex items-center gap-1`,r?`text-shogun-subdued cursor-not-allowed`:`text-shogun-blue hover:text-shogun-gold`),onClick:async()=>{j(t=>({...t,[e.jobType]:!0}));try{D({type:`success`,text:`Triggering ${e.label}…`}),await y.post(`/api/v1/bushido/run`,{job_type:e.jobType}),D({type:`success`,text:`${e.label} dispatched.`})}catch{D({type:`error`,text:`Failed to trigger maintenance.`})}finally{j(t=>({...t,[e.jobType]:!1})),setTimeout(()=>D(null),3e3)}},children:[r&&(0,x.jsx)(l,{className:`w-2.5 h-2.5 animate-spin`}),r?P(`profile.running`,`Running…`):P(`profile.run_now`,`Run Now`)]})]}),(0,x.jsxs)(`div`,{className:_(`flex items-center gap-1.5 transition-all duration-300`,n?`opacity-100`:`opacity-40`),children:[(0,x.jsx)(a,{className:`w-2.5 h-2.5 text-shogun-gold/60 shrink-0`}),(0,x.jsx)(`span`,{className:`text-[9px] font-mono text-shogun-gold/70 uppercase tracking-widest`,children:ue(t,e.cronLabel)}),t&&!t.scheduler_registered&&n&&(0,x.jsx)(`span`,{className:`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border text-red-400 border-red-500/30 bg-red-500/10`,children:`Not registered`}),(0,x.jsx)(`span`,{className:_(`ml-auto text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border`,n?`text-green-400 border-green-500/30 bg-green-500/10`:`text-shogun-subdued border-shogun-border`),children:n?P(`profile.status_active_label`,`Active`):P(`profile.status_paused`,`Paused`)})]})]})]},e.jobType)})})]}),(0,x.jsxs)(`div`,{className:`md:col-span-2 shogun-card space-y-6`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(f,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`profile.create_custom_job`,`Create Custom Job`)]}),(0,x.jsx)(`span`,{className:`text-[10px] bg-shogun-blue/10 text-shogun-blue px-2 py-0.5 rounded border border-shogun-blue/20 font-bold uppercase tracking-widest`,children:P(`profile.builder`,`Builder`)})]}),(()=>{let[e,t]=[k.name,e=>A({...k,name:e})],[n,r]=[k.type,e=>A({...k,type:e})],[a,o]=[k.frequency,e=>A({...k,frequency:e})],[s,c]=[k.priority,e=>A({...k,priority:e})],[u,d]=[k.memoryTypes,e=>A({...k,memoryTypes:e})],[f,te]=[k.allAgents,e=>A({...k,allAgents:e})],[m,h]=[k.dryRun,e=>A({...k,dryRun:e})],[g,ne]=[k.autoApprove,e=>A({...k,autoApprove:e})],re=e=>{d(u.includes(e)?u.filter(t=>t!==e):[...u,e])};return(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,x.jsxs)(`div`,{className:`space-y-5`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.job_name`,`Job Name`)}),(0,x.jsx)(`input`,{type:`text`,placeholder:`e.g. Weekly Context Prune`,value:e,onChange:e=>t(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.job_type`,`Job Type`)}),(0,x.jsx)(`div`,{className:`space-y-2`,children:[{value:`memory_consolidation`,label:P(`profile.jt_memory`,`Memory Consolidation`),desc:P(`profile.jt_memory_desc`,`Merge & prune memory traces`)},{value:`performance_audit`,label:P(`profile.jt_perf`,`Performance Audit`),desc:P(`profile.jt_perf_desc`,`Review execution quality metrics`)},{value:`skill_health_check`,label:P(`profile.jt_skill`,`Skill Health Check`),desc:P(`profile.jt_skill_desc`,`Verify tool connectivity`)},{value:`persona_drift_check`,label:P(`profile.jt_drift`,`Persona Drift Check`),desc:P(`profile.jt_drift_desc`,`Detect behavioral deviation`)},{value:`custom_task`,label:P(`profile.jt_custom`,`Custom Task`),desc:P(`profile.jt_custom_desc`,`Any repeating instruction — API calls, syncs, monitoring`)}].map(e=>(0,x.jsxs)(`button`,{onClick:()=>r(e.value),className:_(`w-full text-left p-2.5 rounded-lg border transition-all`,n===e.value?e.value===`custom_task`?`border-shogun-blue bg-shogun-blue/10`:`border-shogun-gold bg-shogun-gold/10`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsx)(`span`,{className:_(`text-xs font-bold`,n===e.value?e.value===`custom_task`?`text-shogun-blue`:`text-shogun-gold`:`text-shogun-text`),children:e.label}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-0.5`,children:e.desc})]},e.value))})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.frequency`,`Frequency`)}),(0,x.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:[`one-off`,`hourly`,`nightly`,`weekly`,`monthly`].map(e=>(0,x.jsx)(`button`,{onClick:()=>o(e),className:_(`p-2 rounded-lg text-[10px] font-bold uppercase tracking-widest border transition-all`,a===e?e===`one-off`?`border-shogun-blue bg-shogun-blue/10 text-shogun-blue`:`border-shogun-gold bg-shogun-gold/10 text-shogun-gold`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:P(`profile.freq_${e.replace(`-`,`_`)}`,e===`one-off`?`One-off`:e)},e))}),(0,x.jsxs)(`div`,{className:`p-3 bg-[#050508] border border-shogun-border rounded-xl space-y-3 animate-in fade-in`,children:[a===`one-off`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.scheduled_datetime`,`Scheduled date & time`)}),(0,x.jsx)(`input`,{type:`datetime-local`,value:k.scheduleDateTime,onChange:e=>A({...k,scheduleDateTime:e.target.value}),className:`w-full bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-blue focus:border-shogun-blue transition-colors`}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:k.scheduleDateTime?`Runs once on ${new Date(k.scheduleDateTime).toLocaleDateString(`en-GB`,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`})} at ${new Date(k.scheduleDateTime).toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`})}`:P(`profile.select_future_date`,`Select a future date and time for this one-time task.`)})]}),a===`hourly`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.minute_offset`,`Minute offset`)}),(0,x.jsxs)(`span`,{className:`text-xs font-mono font-bold text-shogun-gold`,children:[`:`,String(k.minuteOffset).padStart(2,`0`)]})]}),(0,x.jsx)(`input`,{type:`range`,min:`0`,max:`55`,step:`5`,value:k.minuteOffset,onChange:e=>A({...k,minuteOffset:parseInt(e.target.value)}),className:`w-full accent-shogun-gold`}),(0,x.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:[P(`profile.runs_every_hour`,`Runs every hour at`),` :`,String(k.minuteOffset).padStart(2,`0`)]})]}),a===`nightly`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.run_at`,`Run at`)}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`input`,{type:`time`,value:k.scheduleTime,onChange:e=>A({...k,scheduleTime:e.target.value}),className:`bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-gold focus:border-shogun-gold transition-colors`}),(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued`,children:P(`profile.local_every_night`,`local time, every night`)})]})]}),a===`weekly`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.active_days`,`Active days`)}),(0,x.jsx)(`div`,{className:`flex gap-1.5`,children:[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`].map(e=>(0,x.jsx)(`button`,{onClick:()=>{let t=k.scheduleDays.includes(e)?k.scheduleDays.filter(t=>t!==e):[...k.scheduleDays,e];A({...k,scheduleDays:t})},className:_(`w-9 h-9 rounded-lg text-[10px] font-bold uppercase border transition-all`,k.scheduleDays.includes(e)?`border-shogun-gold bg-shogun-gold/15 text-shogun-gold`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:e.charAt(0).toUpperCase()+e.slice(1,2)},e))})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.run_at`,`Run at`)}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`input`,{type:`time`,value:k.scheduleTime,onChange:e=>A({...k,scheduleTime:e.target.value}),className:`bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-gold focus:border-shogun-gold transition-colors`}),(0,x.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[`on `,k.scheduleDays.length===0?`no days`:k.scheduleDays.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)]})]})]})]}),a===`monthly`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.select_day`,`Select day`)}),(0,x.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:Array.from({length:28},(e,t)=>t+1).map(e=>(0,x.jsx)(`button`,{onClick:()=>A({...k,scheduleDay:e}),className:_(`w-full aspect-square rounded-md text-[10px] font-bold transition-all border`,k.scheduleDay===e?`border-shogun-gold bg-shogun-gold text-black`:`border-shogun-border text-shogun-subdued hover:border-shogun-gold/40 hover:text-shogun-text`),children:e},e))}),(0,x.jsxs)(`div`,{className:`space-y-1.5 pt-1`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.run_at`,`Run at`)}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`input`,{type:`time`,value:k.scheduleTime,onChange:e=>A({...k,scheduleTime:e.target.value}),className:`bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-gold focus:border-shogun-gold transition-colors`}),(0,x.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[`on the `,k.scheduleDay,k.scheduleDay===1?`st`:k.scheduleDay===2?`nd`:k.scheduleDay===3?`rd`:`th`,` of each month`]})]})]})]})]})]})]}),(0,x.jsxs)(`div`,{className:`space-y-5`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.priority`,`Priority`)}),(0,x.jsx)(`span`,{className:`text-shogun-gold font-mono font-bold text-xs`,children:s<=25?P(`profile.priority_low`,`Low`):s<=50?P(`profile.priority_normal`,`Normal`):s<=75?P(`profile.priority_high`,`High`):P(`profile.priority_critical`,`Critical`)})]}),(0,x.jsx)(`input`,{type:`range`,min:`0`,max:`100`,step:`5`,value:s,onChange:e=>c(parseInt(e.target.value)),className:`w-full accent-shogun-gold`}),(0,x.jsxs)(`div`,{className:`flex justify-between text-[8px] text-shogun-subdued uppercase tracking-widest`,children:[(0,x.jsx)(`span`,{children:P(`profile.priority_low`,`Low`)}),(0,x.jsx)(`span`,{children:P(`profile.priority_normal`,`Normal`)}),(0,x.jsx)(`span`,{children:P(`profile.priority_high`,`High`)}),(0,x.jsx)(`span`,{children:P(`profile.priority_critical`,`Critical`)})]})]}),(n===`memory_consolidation`||n===`performance_audit`)&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:n===`memory_consolidation`?P(`profile.mem_types_consolidate`,`Memory Types to Consolidate`):P(`profile.mem_types_audit`,`Memory Types to Audit`)}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`episodic`,`semantic`,`procedural`,`persona`].map(e=>(0,x.jsxs)(`button`,{onClick:()=>re(e),className:_(`flex items-center gap-2 p-2 rounded-lg text-[10px] font-bold border transition-all`,u.includes(e)?`border-shogun-blue bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:[(0,x.jsx)(`div`,{className:_(`w-3 h-3 rounded border-2 flex items-center justify-center transition-all`,u.includes(e)?`border-shogun-blue bg-shogun-blue`:`border-shogun-subdued`),children:u.includes(e)&&(0,x.jsx)(i,{className:`w-2 h-2 text-white`})}),(0,x.jsx)(`span`,{className:`capitalize`,children:e})]},e))})]}),n===`skill_health_check`&&(0,x.jsx)(`div`,{className:`p-3 bg-[#050508] border border-shogun-border rounded-xl`,children:(0,x.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[(0,x.jsxs)(`span`,{className:`font-bold text-shogun-blue uppercase`,children:[P(`profile.scope`,`Scope`),`:`]}),` `,P(`profile.scope_skill_desc`,`Verifies connectivity to all installed skills and third-party integrations. No memory parameters required.`)]})}),n===`persona_drift_check`&&(0,x.jsx)(`div`,{className:`p-3 bg-[#050508] border border-shogun-border rounded-xl`,children:(0,x.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[(0,x.jsxs)(`span`,{className:`font-bold text-shogun-gold uppercase`,children:[P(`profile.scope`,`Scope`),`:`]}),` `,P(`profile.scope_drift_desc`,`Compares current behavioral patterns against the active persona blueprint. Flags deviations exceeding threshold.`)]})}),n===`custom_task`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.task_instruction`,`Task Instruction`)}),(0,x.jsx)(`textarea`,{value:k.taskInstruction,onChange:e=>A({...k,taskInstruction:e.target.value}),placeholder:`e.g. Check the latest tech news via the NewsAPI connector and store a summary in episodic memory. Flag any articles mentioning our product competitors.`,rows:4,className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm leading-relaxed focus:border-shogun-blue transition-colors resize-none placeholder:text-shogun-subdued/50`}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:P(`profile.custom_task_hint`,`The Shogun will execute this instruction on the defined schedule. Use natural language — reference installed skills, APIs, or connectors by name.`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-5`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.options`,`Options`)}),(0,x.jsxs)(`div`,{onClick:()=>te(!f),className:_(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all`,f?`border-shogun-gold/30 bg-shogun-gold/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(p,{className:`w-3.5 h-3.5 text-shogun-subdued`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`text-xs font-semibold`,children:P(`profile.include_samurai`,`Include Samurai metrics`)}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:P(`profile.include_samurai_desc`,`Factor sub-agent data into the audit`)})]})]}),(0,x.jsx)(`div`,{className:_(`w-8 h-4 rounded-full relative transition-all duration-300`,f?`bg-shogun-gold`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:_(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,f?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})})]}),(0,x.jsxs)(`div`,{onClick:()=>h(!m),className:_(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all`,m?`border-shogun-blue/30 bg-shogun-blue/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(se,{className:`w-3.5 h-3.5 text-shogun-subdued`}),(0,x.jsx)(`span`,{className:`text-xs font-semibold`,children:P(`profile.dry_run`,`Dry run (preview only)`)})]}),(0,x.jsx)(`div`,{className:_(`w-8 h-4 rounded-full relative transition-all duration-300`,m?`bg-shogun-blue`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:_(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,m?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})})]}),(0,x.jsxs)(`div`,{onClick:()=>ne(!g),className:_(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all`,g?`border-green-500/30 bg-green-500/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(i,{className:`w-3.5 h-3.5 text-shogun-subdued`}),(0,x.jsx)(`span`,{className:`text-xs font-semibold`,children:P(`profile.auto_approve`,`Auto-approve results`)})]}),(0,x.jsx)(`div`,{className:_(`w-8 h-4 rounded-full relative transition-all duration-300`,g?`bg-green-500`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:_(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,g?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})})]})]}),(0,x.jsxs)(`button`,{onClick:async()=>{if(!M){if(!e.trim()){D({type:`error`,text:`Please provide a job name.`}),setTimeout(()=>D(null),3e3);return}if(a===`weekly`&&k.scheduleDays.length===0){D({type:`error`,text:`Select at least one day for a weekly schedule.`});return}if(a===`one-off`&&!k.scheduleDateTime){D({type:`error`,text:`Select a future date and time.`});return}if(n===`custom_task`&&!k.taskInstruction.trim()){D({type:`error`,text:`Custom tasks require an instruction.`});return}he(!0);try{D({type:`success`,text:`Creating "${e}"...`});let t={name:e,job_type:n,frequency:a,schedule_time:k.scheduleTime,schedule_days:a===`weekly`?k.scheduleDays:null,schedule_day:a===`monthly`?k.scheduleDay:null,minute_offset:a===`hourly`?k.minuteOffset:0,schedule_datetime:a===`one-off`?k.scheduleDateTime:null,scope:{agent_ids:[],memory_types:u},priority:s,all_agents:f,dry_run:m,auto_approve:g,task_instruction:n===`custom_task`?k.taskInstruction:null,is_enabled:!0};if(!(await y.post(`/api/v1/bushido/schedules`,t)).data?.meta?.scheduler_registered)throw Error(`The job was saved but not registered with the scheduler.`);await $(),D({type:`success`,text:`"${e}" created and scheduled.`}),A({name:``,type:`memory_consolidation`,frequency:`nightly`,scheduleTime:`02:00`,scheduleDays:[`mon`,`wed`,`fri`],scheduleDay:1,minuteOffset:0,scheduleDateTime:``,priority:50,memoryTypes:[`episodic`,`semantic`],taskInstruction:``,allAgents:!0,dryRun:!1,autoApprove:!1})}catch(e){D({type:`error`,text:S(e,e?.message||`Failed to create schedule.`)})}finally{he(!1),setTimeout(()=>D(null),6e3)}}},disabled:M,className:`w-full py-3 bg-gradient-to-r from-shogun-gold to-yellow-600 hover:from-yellow-600 hover:to-shogun-gold disabled:opacity-50 disabled:cursor-wait text-black font-bold rounded-lg transition-all shadow-shogun text-sm uppercase tracking-widest flex items-center justify-center gap-2`,children:[M?(0,x.jsx)(l,{className:`w-4 h-4 animate-spin`}):(0,x.jsx)(ee,{className:`w-4 h-4`}),M?`Registering Job…`:P(`profile.create_schedule_btn`,`Create & Schedule Job`)]})]})]})})()]}),fe.filter(e=>!e.is_preset).length>0&&(0,x.jsxs)(`div`,{className:`md:col-span-2 shogun-card space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(a,{className:`w-5 h-5 text-shogun-gold`}),` Operational Cadence — Scheduled Jobs & AgentFlows`]}),(0,x.jsxs)(`button`,{onClick:$,className:`text-[10px] font-bold text-shogun-subdued hover:text-shogun-gold transition-colors uppercase tracking-widest flex items-center gap-1`,children:[(0,x.jsx)(l,{className:`w-3 h-3`}),` `,P(`profile.refresh`,`Refresh`)]})]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:fe.filter(e=>!e.is_preset).map(e=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-[#050508] border border-shogun-border rounded-xl hover:border-shogun-gold/20 transition-all`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,x.jsx)(`div`,{className:_(`w-2 h-2 rounded-full shrink-0`,e.is_enabled?`bg-green-400`:`bg-shogun-subdued`)}),(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`text-sm font-bold truncate`,children:e.name}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,x.jsx)(`span`,{className:_(`text-[8px] font-bold uppercase tracking-widest border px-1.5 py-0.5 rounded`,e.source===`agent_flow`?`text-purple-400 border-purple-500/30 bg-purple-500/10`:`text-shogun-blue border-shogun-blue/30 bg-shogun-blue/10`),children:e.source===`agent_flow`?`AgentFlow`:`Bushido`}),(0,x.jsx)(`span`,{className:`text-[9px] font-mono text-shogun-subdued uppercase tracking-wider`,children:e.job_type.replace(/_/g,` `)}),(0,x.jsx)(`span`,{className:`text-shogun-subdued/30`,children:`·`}),(0,x.jsxs)(`span`,{className:`text-[9px] font-mono text-shogun-gold/70 uppercase tracking-wider`,children:[e.frequency,e.schedule_time?` @ ${e.schedule_time}`:``]}),e.is_enabled&&!e.scheduler_registered&&(0,x.jsx)(`span`,{className:`text-[8px] font-bold text-red-400 uppercase tracking-widest bg-red-500/10 border border-red-500/20 px-1.5 py-0.5 rounded`,children:`Not registered`}),e.dry_run&&(0,x.jsx)(`span`,{className:`text-[8px] font-bold text-shogun-blue uppercase tracking-widest bg-shogun-blue/10 border border-shogun-blue/20 px-1.5 py-0.5 rounded`,children:`Dry Run`})]})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 ml-3`,children:[(0,x.jsx)(`button`,{disabled:me[`${e.source||`bushido`}-${e.id}`],onClick:async()=>{let t=`${e.source||`bushido`}-${e.id}`;j(e=>({...e,[t]:!0}));try{e.source===`agent_flow`?await y.post(`/api/v1/agent-flows/${e.id}/run`,{trigger_type:`manual`}):await y.post(`/api/v1/bushido/run`,{job_type:e.job_type,scope:e.scope||{agent_ids:[],memory_types:[]},trigger_mode:`manual`,priority:e.priority||50}),D({type:`success`,text:`"${e.name}" dispatched.`})}catch(e){D({type:`error`,text:S(e,`Failed to run scheduled job.`)})}finally{j(e=>({...e,[t]:!1})),setTimeout(()=>D(null),4e3)}},className:`text-[9px] font-bold uppercase text-shogun-blue hover:text-shogun-gold disabled:opacity-40 transition-colors`,children:me[`${e.source||`bushido`}-${e.id}`]?`Running…`:`Run now`}),(0,x.jsx)(`button`,{onClick:async()=>{try{e.source===`agent_flow`?await y.post(`/api/v1/agent-flows/${e.id}/${e.is_enabled?`pause`:`activate`}`):await y.patch(`/api/v1/bushido/schedules/${e.id}/toggle`),await $()}catch(e){D({type:`error`,text:S(e,`Failed to change schedule state.`)})}},className:_(`w-8 h-4 rounded-full relative transition-all duration-300 shrink-0`,e.is_enabled?`bg-shogun-gold`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:_(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,e.is_enabled?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})}),e.source!==`agent_flow`&&(0,x.jsx)(`button`,{onClick:async()=>{try{await y.delete(`/api/v1/bushido/schedules/${e.id}`),await $()}catch(e){D({type:`error`,text:S(e,`Failed to delete schedule.`)})}},className:`text-shogun-subdued hover:text-red-400 transition-colors p-1`,title:`Delete schedule`,children:(0,x.jsx)(g,{className:`w-3.5 h-3.5`})})]})]},`${e.source||`bushido`}-${e.id}`))})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-4 md:col-span-2 mt-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(s,{className:`w-5 h-5 text-orange-500`}),` `,P(`profile.ronin_desktop`,`Ronin Desktop Control`)]}),(0,x.jsx)(`button`,{onClick:async()=>{try{let e=await y.get(`/api/v1/setup/ronin-check`);I(t=>({...t,_roninCheck:e.data.data}))}catch{}},className:`text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:P(`common.refresh`,`Refresh`)})]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Ronin gives Shogun desktop automation capabilities: screenshots, mouse control, and keyboard input. Install the dependencies here if you skipped this during setup.`}),!F._roninCheck&&(y.get(`/api/v1/setup/ronin-check`).then(e=>{I(t=>({...t,_roninCheck:e.data.data}))}).catch(()=>{}),null),F._roninCheck&&(()=>{let e=F._roninCheck;return(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:Object.entries(e.deps||{}).map(([t,n])=>{let a=e[`_installing_${t}`];return(0,x.jsxs)(`button`,{disabled:n.installed||a,onClick:async()=>{if(!n.installed){I(e=>({...e,_roninCheck:{...e._roninCheck,[`_installing_${t}`]:!0}}));try{let e=await y.post(`/api/v1/setup/ronin-install-dep`,{dep_name:t});if(e.data.data?.status===`success`){D({type:`success`,text:`${t} installed successfully!`});let e=await y.get(`/api/v1/setup/ronin-check`);I(t=>({...t,_roninCheck:e.data.data}))}else D({type:`error`,text:e.data.data?.message||`Failed to install ${t}`}),I(e=>({...e,_roninCheck:{...e._roninCheck,[`_installing_${t}`]:!1}}))}catch{D({type:`error`,text:`Failed to install ${t}`}),I(e=>({...e,_roninCheck:{...e._roninCheck,[`_installing_${t}`]:!1}}))}}},className:_(`flex items-center gap-2 p-2.5 rounded-lg border text-left transition-all`,n.installed?`bg-green-500/5 border-green-500/20`:a?`bg-orange-500/5 border-orange-500/20 animate-pulse`:`bg-red-500/5 border-red-500/20 hover:border-orange-500/50 hover:bg-orange-500/5 cursor-pointer`,(n.installed||a)&&`cursor-default`),children:[a?(0,x.jsx)(`div`,{className:`w-3.5 h-3.5 border-2 border-orange-500 border-t-transparent rounded-full animate-spin shrink-0`}):n.installed?(0,x.jsx)(i,{className:`w-3.5 h-3.5 text-green-500 shrink-0`}):(0,x.jsx)(r,{className:`w-3.5 h-3.5 text-red-400 shrink-0`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:t}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:a?`Installing...`:n.installed?`v${n.version}`:`Click to install`})]})]},t)})}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-shogun-border rounded-lg px-3 py-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`OS: `}),(0,x.jsx)(`span`,{className:`text-xs font-bold text-shogun-text`,children:e.os}),e.display_server&&(0,x.jsxs)(`span`,{className:`text-xs text-shogun-subdued ml-2`,children:[`(`,e.display_server,`)`]})]}),(0,x.jsx)(`span`,{className:_(`text-[9px] font-bold px-2 py-0.5 rounded border uppercase`,e.all_core_installed?`text-green-500 border-green-500/30`:`text-orange-400 border-orange-400/30`),children:e.all_core_installed?`Ready`:`Install Required`})]}),!e.all_core_installed&&(0,x.jsx)(`button`,{onClick:async()=>{I(e=>({...e,_roninInstalling:!0}));try{let e=await y.post(`/api/v1/setup/ronin-install`);if(e.data.data?.status===`success`){D({type:`success`,text:`Ronin dependencies installed successfully!`});let e=await y.get(`/api/v1/setup/ronin-check`);I(t=>({...t,_roninCheck:e.data.data,_roninInstalling:!1}))}else D({type:`error`,text:e.data.data?.message||`Installation failed.`}),I(e=>({...e,_roninInstalling:!1}))}catch{D({type:`error`,text:`Failed to install Ronin dependencies.`}),I(e=>({...e,_roninInstalling:!1}))}},disabled:F._roninInstalling,className:`w-full py-2.5 rounded-lg bg-orange-500 hover:bg-orange-500/80 text-black font-bold text-sm transition-all disabled:opacity-50 flex items-center justify-center gap-2`,children:F._roninInstalling?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`w-4 h-4 border-2 border-black border-t-transparent rounded-full animate-spin`}),` Installing...`]}):(0,x.jsx)(x.Fragment,{children:`Install Ronin Dependencies`})}),e.notes?.length>0&&(0,x.jsx)(`div`,{className:`bg-orange-500/5 border border-orange-500/20 rounded-lg p-3 space-y-1`,children:e.notes.map((e,t)=>(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:e},t))})]})})()]})]})]})]})};export{w as ShogunProfile}; \ No newline at end of file diff --git a/frontend/dist/assets/ShogunProfile-DqH86txE.js b/frontend/dist/assets/ShogunProfile-DqH86txE.js deleted file mode 100644 index b96165e..0000000 --- a/frontend/dist/assets/ShogunProfile-DqH86txE.js +++ /dev/null @@ -1,15 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{o as i,s as a}from"./chunk-OE4NN4TA-BT-WiWAe.js";import{t as o}from"./activity-D6ZKsL_W.js";import{t as s}from"./app-window-pINhreuP.js";import{t as c}from"./chevron-right-BzAY5P9l.js";import{t as l}from"./circle-alert-DVHRBFRQ.js";import{t as u}from"./circle-check-D9mntLsp.js";import{t as d}from"./clock-B8iyCT3M.js";import{t as f}from"./cpu-jON2DlCR.js";import{t as ee}from"./crosshair-IDZ5dQs8.js";import{t as p}from"./database-B_RLhoAx.js";import{t as te}from"./grip-vertical-DIOTevc1.js";import{t as m}from"./refresh-cw-CCrS0Omg.js";import{t as h}from"./save-CJWuwqGS.js";import{t as ne}from"./server-CMY38Yt2.js";import{t as g}from"./settings-DYFQa-lL.js";import{t as re}from"./shield-check-4WxAMs16.js";import{t as ie}from"./shield-B_MY4jWU.js";import{t as ae}from"./user-Dr0R8XdF.js";import{t as _}from"./workflow-DS_AVE1X.js";import{t as oe}from"./x-Bu7rztmN.js";import{t as se}from"./zap-BMpqZS6N.js";import{t as v}from"./utils-wrb6h48Y.js";import{r as ce}from"./i18n-FxgwkwP0.js";import{t as y}from"./axios-BPyV2soB.js";var le=e(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),b=t(n(),1),x=r(),ue=(e,t)=>{if(!e)return t;let n=e.schedule_time||`00:00`;return e.frequency===`hourly`?`Every hour at :${String(e.minute_offset||0).padStart(2,`0`)}`:e.frequency===`weekly`?`Every ${(e.schedule_days||[`mon`]).join(`, `)} at ${n}`:e.frequency===`monthly`?`Monthly on day ${e.schedule_day||1} at ${n}`:e.frequency===`one-off`?e.schedule_datetime?`Once at ${new Date(e.schedule_datetime).toLocaleString()}`:`One-off`:`Every day at ${n}`},S=(e,t)=>{let n=e?.response?.data?.detail;return Array.isArray(n)?n.map(e=>e?.msg||String(e)).join(`; `):typeof n==`string`?n:t},C={agentflow:{allow_create:!1,allow_edit:!1,allow_activate:!1,allow_execute:!1,allow_save_as_template:!1,allow_delete:!1},flow_stack:{allow_create:!1,allow_edit:!1,allow_activate:!1,allow_execute:!1,allow_save_as_template:!1,allow_delete:!1},mado_browser:{enabled:!1,allow_external_urls:!1,allow_login_profiles:!1,allow_authenticated_sessions:!1,allow_file_downloads:!1,allow_file_uploads:!1,allow_form_submit:!1,allow_headless_mode:!0,allow_visible_mode:!0,capture_screenshots:!0,require_verification:!0,audit_all_actions:!0},visual_intake:{allow_image_intake:!0,allow_local_vision:!0,allow_cloud_vision:!1,allow_ocr:!0,allow_attach_to_stack:!0,allow_auto_memory:!1,allow_delete:!0,retention_days:30,max_upload_mb:20},ide_mode:{enabled:!1,file_read:!0,file_search:!0,file_create:!0,file_patch:!0,file_delete:!1,diagnostics:!0,approved_tasks_only:!0,terminal_approved_only:!0,package_install:!1,git_status:!0,git_diff:!0,git_branch_create:!1,git_commit:!1,git_push:!1,secrets_access:!1,require_snapshot:!0,audit_all_actions:!0,self_verification_required:!0}},w=()=>{let[e,t]=(0,b.useState)(`general`),[n,r]=(0,b.useState)(!0),[w,T]=(0,b.useState)(!1),[E,D]=(0,b.useState)(null),[O,de]=(0,b.useState)(null),[k,A]=(0,b.useState)({name:``,type:`memory_consolidation`,frequency:`nightly`,scheduleTime:`02:00`,scheduleDays:[`mon`,`wed`,`fri`],scheduleDay:1,minuteOffset:0,scheduleDateTime:``,priority:50,memoryTypes:[`episodic`,`semantic`],taskInstruction:``,allAgents:!0,dryRun:!1,autoApprove:!1}),[fe,pe]=(0,b.useState)([]),[me,j]=(0,b.useState)({}),[M,he]=(0,b.useState)(!1),N=a(),ge=i(),{t:P}=ce(),[F,I]=(0,b.useState)({name:`Shogun Prime`,slug:`primary-shogun`,status:`active`,persona_id:``,model_routing_profile_id:``,security_policy_id:``,description:`Master orchestrator of the Samurai Network.`,autonomy:50,risk_tolerance:`low`,verbosity:`medium`}),[L,_e]=(0,b.useState)([]),[ve,ye]=(0,b.useState)([]),[be,xe]=(0,b.useState)([]),[Se,Ce]=(0,b.useState)([]),[we,Te]=(0,b.useState)([]),[R,Ee]=(0,b.useState)(``),[z,B]=(0,b.useState)([]),[V,H]=(0,b.useState)(null),[U,W]=(0,b.useState)(``),[G,De]=(0,b.useState)(null),[Oe,ke]=(0,b.useState)(!1),Ae=e=>{if(!e)return 0;let t=0,n=(n,r,i,a)=>{let o=e?.[n]||e?.[n.toUpperCase()]||e?.[n.toLowerCase()];if(!o)return;let s=o[r]??o[r.toUpperCase()]??o[r.toLowerCase()];s!==void 0&&i.includes(s)&&(t+=a)};return n(`filesystem`,`mode`,[`full`,`FULL`],15),n(`filesystem`,`allow_home_access`,[!0],10),n(`filesystem`,`allow_arbitrary_paths`,[!0],15),n(`network`,`mode`,[`full`,`FULL`],15),n(`network`,`allow_arbitrary_requests`,[!0],10),n(`shell`,`enabled`,[!0],15),n(`skills`,`allow_auto_install`,[!0],5),n(`skills`,`allow_untrusted`,[!0],10),n(`subagents`,`allow_spawn`,[!0],5),n(`subagents`,`allow_auto_spawn`,[!0],10),n(`memory`,`allow_bulk_delete`,[!0],10),n(`agentflow`,`allow_create`,[!0],5),n(`agentflow`,`allow_activate`,[!0],5),n(`agentflow`,`allow_execute`,[!0],5),n(`agentflow`,`allow_delete`,[!0],5),n(`flow_stack`,`allow_create`,[!0],5),n(`flow_stack`,`allow_activate`,[!0],5),n(`flow_stack`,`allow_execute`,[!0],10),n(`flow_stack`,`allow_delete`,[!0],5),n(`filesystem`,`mode`,[`scoped`,`SCOPED`,`disabled`,`DISABLED`],-5),n(`network`,`mode`,[`disabled`,`DISABLED`],-10),n(`shell`,`enabled`,[!1],-5),n(`skills`,`require_approval`,[!0],-5),Math.max(0,Math.min(100,t))},je={filesystem:{_category:`Controls what files and folders the agent can read, write, or access on your system.`,mode:`How freely the agent can access files. "Full" = unrestricted, "Scoped" = only in designated folders, "Disabled" = no file access.`,allowed_paths:`Specific folders the agent is allowed to work in when in Scoped mode.`,allow_home_access:`Whether the agent can read or write files in your personal home directory.`,allow_arbitrary_paths:`Whether the agent can access ANY folder on the system, even outside its designated workspace.`},network:{_category:`Controls all external connectivity, including direct network requests and governed Mado browser sessions.`,mode:`How freely the agent can use the network. "Full" = unrestricted, "Allowlist" = only approved sites, "Disabled" = no internet.`,allowed_domains:`Specific websites or APIs the agent is allowed to contact when in Allowlist mode.`,allow_arbitrary_requests:`Whether the agent can contact ANY website or API, even ones not on the approved list.`},mado_browser:{_category:`Controls governed browser navigation, authenticated sessions, form interaction, downloads, uploads, screenshots, and verification.`,enabled:`Whether Mado browser automation is available to the agent.`,allow_external_urls:`Allow navigation to external websites, subject to the Network allowlist and posture controls.`,allow_login_profiles:`Allow the agent to use operator-configured browser login profiles.`,allow_authenticated_sessions:`Allow Mado to continue in authenticated browser sessions.`,allow_file_downloads:`Allow files to be downloaded through Mado.`,allow_file_uploads:`Allow local files to be uploaded through Mado.`,allow_form_submit:`Allow Mado to submit forms, subject to ToolGate checks.`,allow_headless_mode:`Allow browser sessions without a visible browser window.`,allow_visible_mode:`Allow visible, operator-observable browser sessions.`,capture_screenshots:`Allow Mado to capture page screenshots for evidence and visual inspection.`,require_verification:`Require post-action verification before a browser task is considered complete.`,audit_all_actions:`Record every Mado action in the audit log.`},shell:{_category:`Controls whether the agent can run system commands (like terminal/command-line operations).`,enabled:`Whether the agent is allowed to execute system commands at all.`,allowed_binaries:`Specific programs the agent is allowed to run (e.g., "python", "git"). Empty means none.`},skills:{_category:`Controls how the agent discovers, installs, and uses skill modules (plugins).`,allow_auto_install:`Whether the agent can automatically download and install new skills without asking.`,require_approval:`Whether a human must approve before the agent uses any new skill for the first time.`,allow_untrusted:`Whether the agent can use skills from unverified or third-party sources.`},subagents:{_category:`Controls whether the agent can create and manage helper agents (Samurai) to delegate tasks.`,allow_spawn:`Whether the agent is allowed to create sub-agents at all.`,max_active:`Maximum number of sub-agents that can be running at the same time.`,allow_auto_spawn:`Whether the agent can create sub-agents on its own without asking for permission first.`},memory:{_category:`Controls how the agent stores and manages its knowledge and conversation history.`,allow_write:`Whether the agent can save new information to its long-term memory.`,allow_bulk_delete:`Whether the agent can erase large amounts of its stored knowledge at once.`},agentflow:{_category:`Controls what Shogun may do autonomously with individual AgentFlows. All capabilities are disabled by default and remain limited to Tactical, Campaign, and Ronin posture.`,allow_create:`Allow Shogun to create a new AgentFlow without the operator building it manually.`,allow_edit:`Allow Shogun to change nodes, connectors, and configuration in an existing AgentFlow.`,allow_activate:`Allow Shogun to activate a created AgentFlow. When disabled, Shogun-created flows remain drafts.`,allow_execute:`Allow Shogun to start an AgentFlow run autonomously.`,allow_save_as_template:`Allow Shogun to save AgentFlows as reusable templates.`,allow_delete:`Allow Shogun to delete AgentFlows.`},flow_stack:{_category:`Controls what Shogun may do autonomously with multi-flow stacks and their orchestrators. All capabilities are disabled by default and require Tactical, Campaign, or Ronin posture.`,allow_create:`Allow Shogun to compose connected AgentFlows into a new Flow Stack.`,allow_edit:`Allow Shogun to change stack phases, connectors, and orchestrator configuration.`,allow_activate:`Allow Shogun to activate a created Flow Stack. When disabled, Shogun-created stacks remain drafts.`,allow_execute:`Allow Shogun to start a Flow Stack orchestrator run autonomously.`,allow_save_as_template:`Allow Shogun to save Flow Stacks as reusable templates.`,allow_delete:`Allow Shogun to delete Flow Stacks.`},visual_intake:{_category:`Controls how images from chat and Telegram are stored, analyzed, remembered, and passed into Flow Stacks.`,allow_image_intake:`Accept valid images in chat and connected channels and store them as governed artifacts.`,allow_local_vision:`Allow connected local vision models to inspect images.`,allow_cloud_vision:`Allow image bytes to be sent to a connected cloud vision provider. Disabled by default.`,allow_ocr:`Allow Shogun to extract visible text from images.`,allow_attach_to_stack:`Allow image artifacts to become durable inputs to Flow Stack runs.`,allow_auto_memory:`Allow Shogun to preserve image-derived knowledge automatically. Disabled by default.`,allow_delete:`Allow governed deletion of image artifacts.`,retention_days:`Days to retain unpinned images before automatic cleanup.`,max_upload_mb:`Maximum size of one accepted image.`},ide_mode:{_category:`Controls governed access to approved VS Code workspaces. This entire section is unavailable below Campaign posture.`,enabled:`Master permission for Shogun IDE Mode. Runtime enablement still requires explicit confirmation.`,file_read:`Read files inside an approved workspace.`,file_search:`Search inside an approved workspace.`,file_create:`Create files after a restore point is made.`,file_patch:`Apply reviewed patches and retain a unified diff.`,file_delete:`Delete files. Campaign also requires explicit approval.`,diagnostics:`Read VS Code Problems and diagnostics.`,approved_tasks_only:`Restrict automatic execution to approved development tasks.`,terminal_approved_only:`Only allow allowlisted or explicitly approved commands.`,package_install:`Allow dependency installation. Keep disabled unless the repository is trusted.`,git_status:`Inspect Git status.`,git_diff:`Inspect Git diffs.`,git_branch_create:`Create local branches.`,git_commit:`Create commits after approval.`,git_push:`Push to remotes. Disabled by default, including Ronin.`,secrets_access:`Read protected secret files. Disabled by default.`,require_snapshot:`Create a rollback point before every write.`,audit_all_actions:`Send all IDE actions through EventLogger.`,self_verification_required:`Require tests/build/diagnostic verification before completion.`}},K=(e,t)=>{let n=e.toLowerCase();return t?je[n]?.[t.toLowerCase()]||je[n]?.[t]||``:je[n]?._category||``},q=be.find(e=>e.id===F.security_policy_id),J=String(q?.tier||``).toLowerCase(),Y=[`tactical`,`campaign`,`ronin`].includes(J),Me=[`campaign`,`ronin`].includes(J),X=V||q?.permissions||null,Z=X?{...X,agentflow:{...C.agentflow,...X.agentflow||{}},flow_stack:{...C.flow_stack,...X.flow_stack||{}},mado_browser:{...C.mado_browser,...X.mado_browser||{}},visual_intake:{...C.visual_intake,...X.visual_intake||{}},ide_mode:{...C.ide_mode,...X.ide_mode||{}}}:null,Ne=q?.permissions||null,Pe=V!==null&&JSON.stringify(V)!==JSON.stringify(Ne),Q=Ae(Z);(0,b.useEffect)(()=>{Ie()},[]),(0,b.useEffect)(()=>{e===`permissions`&&y.get(`/api/v1/ronin/desktop/status`).then(e=>De(e.data?.data)).catch(()=>De(null))},[e]);let Fe=async e=>{if(!(e&&!confirm(`Ronin Desktop Control can operate the real mouse, keyboard, windows, and applications. Actions remain visible, verified, audited, and protected by the kill switch. Enable it?`))){ke(!0);try{De((e?await y.post(`/api/v1/ronin/desktop/enable`,{confirmation:`ENABLE RONIN DESKTOP CONTROL`,ronin_screenshots_enabled:!0,ronin_mouse_enabled:!0,ronin_keyboard_enabled:!0,ronin_window_management_enabled:!0,ronin_native_apps_enabled:!0,ronin_require_verification:!0,ronin_require_high_risk_approval:!0,ronin_block_critical_actions:!0,ronin_visible_indicator:!0}):await y.post(`/api/v1/ronin/desktop/disable`)).data?.data),D({type:`success`,text:`Ronin Desktop Control ${e?`enabled`:`disabled`}.`})}catch(e){D({type:`error`,text:S(e,`Could not update Ronin Desktop Control.`)})}finally{ke(!1)}}};(0,b.useEffect)(()=>{let e=new URLSearchParams(ge.search);e.get(`tab`)===`operations`?t(`operations`):e.get(`tab`)===`permissions`&&N(`/toolgate`,{replace:!0})},[ge.search,N]);let Ie=async()=>{r(!0);try{let[e,t,n,r,i,a,o,s]=await Promise.allSettled([y.get(`/api/v1/agents/shogun`),y.get(`/api/v1/personas`),y.get(`/api/v1/models/routing/profiles`),y.get(`/api/v1/security/policies`),y.get(`/api/v1/system/health`),y.get(`/api/v1/model-providers`),y.get(`/api/v1/models/registry`),y.get(`/api/v1/tools`)]);if(e.status===`fulfilled`&&e.value.data.data){let t=e.value.data.data;I(t);let r=t.bushido_settings||{},i=r.primary_model||``,s=r.fallback_models||[],c=n.status===`fulfilled`&&n.value.data.data||[],l=o.status===`fulfilled`&&o.value.data.data||[],u=c.find(e=>e.id===t.model_routing_profile_id);if(u?.name===`Custom`){let e=u.rules?.find(e=>e.task_type===`*`)||u.rules?.[0],t=e=>{if(!e||e.includes(`::`))return e;let t=l.find(t=>t.id===e||t.model_id===e);return t?.provider_id?`${t.provider_id}::${t.model_id}`:e};e?.primary_model_id&&(i=t(String(e.primary_model_id))),e?.fallback_model_ids&&(s=e.fallback_model_ids.map(e=>t(String(e))))}r.custom_permissions&&H(r.custom_permissions);let d=a.status===`fulfilled`&&a.value.data.data?a.value.data.data:[],f=e=>{if(!e||!e.includes(`::`))return e;let[t,n]=e.split(`::`,2);if(d.some(e=>e.id===t))return e;for(let e of d)if((e.config?.models||[]).includes(n)||e.name===n)return`${e.id}::${n}`;return e};i=f(i),s=s.map(f),i&&Ee(i),s.length>0&&B(s)}i.status===`fulfilled`&&i.value.data.data&&de(i.value.data.data),t.status===`fulfilled`&&t.value.data.data&&_e(t.value.data.data),n.status===`fulfilled`&&n.value.data.data&&ye(n.value.data.data),r.status===`fulfilled`&&r.value.data.data&&xe(r.value.data.data),a.status===`fulfilled`&&a.value.data.data&&Ce(a.value.data.data),s.status===`fulfilled`&&s.value.data.data&&Te(s.value.data.data);try{let e=await y.get(`/api/v1/bushido/schedules`);e.data.data&&pe(e.data.data)}catch{}}catch(e){console.error(`Error fetching Shogun data:`,e)}finally{r(!1)}},$=async()=>{try{let e=await y.get(`/api/v1/bushido/schedules`);e.data.data&&pe(e.data.data)}catch{}},Le=async e=>{try{await y.patch(`/api/v1/bushido/schedules/preset/${e}/toggle`),await $()}catch{D({type:`error`,text:`Failed to toggle schedule.`}),setTimeout(()=>D(null),3e3)}},Re=e=>fe.find(t=>t.source!==`agent_flow`&&t.job_type===e&&t.is_preset),ze=async()=>{T(!0),D(null);try{let e=ve.find(e=>e.id===F.model_routing_profile_id);if(e?.name===`Custom`){if(!R)throw Error(`Choose at least one model for Custom routing.`);await y.post(`/api/v1/models/routing/profiles/${e.id}/update`,{rules:[{task_type:`*`,primary_model_id:R,fallback_model_ids:z}]})}e&&await y.post(`/api/v1/models/routing/profiles/active`,{profile_id:e.id});let t={...F,bushido_settings:{...F.bushido_settings||{},primary_model:R,fallback_models:z,custom_permissions:V}};await y.patch(`/api/v1/agents/${F.id}`,t),D({type:`success`,text:`Shogun configuration saved successfully.`})}catch(e){D({type:`error`,text:e?.message||`Failed to save configuration.`})}finally{T(!1),setTimeout(()=>D(null),3e3)}},Be=async()=>{if(!(!U.trim()||!V)){T(!0),D(null);try{let e=be.find(e=>e.id===F.security_policy_id),t=e?.tier||`tactical`,n=(await y.post(`/api/v1/security/policies`,{name:U.trim(),tier:t,description:`Custom policy derived from ${e?.name||`base policy`}`,permissions:V,kill_switch_enabled:!0,dry_run_supported:!0})).data?.data?.id;if(!n)throw Error(`Policy creation returned no ID`);let r={...F.bushido_settings||{},primary_model:R,fallback_models:z,custom_permissions:null};await y.patch(`/api/v1/agents/${F.id}`,{security_policy_id:n,bushido_settings:r}),H(null),W(``),I(e=>({...e,security_policy_id:n,bushido_settings:r}));try{let e=await y.get(`/api/v1/security/policies`);e.data?.data&&xe(e.data.data)}catch{}D({type:`success`,text:`Custom policy "${U.trim()}" created and assigned.`})}catch(e){D({type:`error`,text:e?.response?.data?.detail||`Failed to create custom policy.`})}finally{T(!1),setTimeout(()=>D(null),4e3)}}},Ve=(0,b.useRef)(null);return n?(0,x.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,x.jsx)(`div`,{className:`w-8 h-8 border-4 border-shogun-gold border-t-transparent rounded-full animate-spin`})}):(0,x.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500 max-w-5xl mx-auto pb-12`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,x.jsxs)(`div`,{onClick:()=>{Ve.current?.click()},className:`w-20 h-20 bg-shogun-card rounded-2xl border border-shogun-gold/30 flex items-center justify-center shadow-shogun relative cursor-pointer group hover:border-shogun-gold/60 transition-all overflow-hidden`,children:[F.avatar_url?(0,x.jsx)(`img`,{src:F.avatar_url,alt:`Shogun Avatar`,className:`w-full h-full object-cover`}):(0,x.jsx)(`img`,{src:`/assets/shogun-default-avatar.jpg`,alt:`Shogun Avatar`,className:`w-full h-full object-cover`}),(0,x.jsx)(`div`,{className:`absolute inset-0 bg-black/40 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,x.jsx)(f,{className:`w-6 h-6 text-shogun-gold`})}),(0,x.jsx)(`div`,{className:`absolute -bottom-1 -right-1 w-5 h-5 bg-green-500 border-2 border-[#0a0e1a] rounded-full shadow-lg`})]}),(0,x.jsx)(`input`,{type:`file`,ref:Ve,className:`hidden`,accept:`image/*`,onChange:async e=>{let t=e.target.files?.[0];if(!t)return;let n=new FormData;n.append(`file`,t);try{D({type:`success`,text:`Uploading avatar...`});let e=await y.post(`/api/v1/agents/${F.id}/avatar`,n,{headers:{"Content-Type":`multipart/form-data`}});I({...F,avatar_url:e.data.data.avatar_url}),D({type:`success`,text:`Avatar updated successfully.`})}catch(e){console.error(`Avatar upload failed:`,e),D({type:`error`,text:`Failed to upload avatar.`})}finally{setTimeout(()=>D(null),3e3)}}}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h2`,{className:`text-3xl font-bold shogun-title`,children:F.name}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3 mt-1`,children:[(0,x.jsx)(`span`,{className:`text-[10px] bg-shogun-gold/10 text-shogun-gold px-2 py-0.5 rounded border border-shogun-gold/20 font-bold tracking-widest uppercase`,children:P(`shogun_profile.primary_agent`,`Primary Agent`)}),(0,x.jsxs)(`span`,{className:`text-xs text-shogun-subdued flex items-center gap-1`,children:[(0,x.jsx)(_,{className:`w-3 h-3`}),` `,P(`profile.system_orchestrator`,`System Orchestrator`)]})]})]})]}),(0,x.jsxs)(`button`,{onClick:ze,disabled:w,className:`flex items-center justify-center gap-2 bg-shogun-gold hover:bg-shogun-gold/90 text-black font-bold py-2 px-6 rounded-lg transition-all shadow-shogun disabled:opacity-50`,children:[w?(0,x.jsx)(`div`,{className:`w-4 h-4 border-2 border-black border-t-transparent rounded-full animate-spin`}):(0,x.jsx)(h,{className:`w-4 h-4`}),P(`common.save_changes`,`SAVE CHANGES`)]})]}),E&&(0,x.jsxs)(`div`,{className:v(`p-3 rounded-lg flex items-center gap-3 animate-in slide-in-from-top-2`,E.type===`success`?`bg-green-500/10 text-green-500 border border-green-500/20`:`bg-red-500/10 text-red-500 border border-red-500/20`),children:[E.type===`success`?(0,x.jsx)(u,{className:`w-4 h-4`}):(0,x.jsx)(l,{className:`w-4 h-4`}),(0,x.jsx)(`span`,{className:`text-sm font-medium`,children:E.text})]}),(0,x.jsx)(`div`,{className:`flex border-b border-shogun-border`,children:[`general`,`behavior`,`operations`].map(n=>(0,x.jsxs)(`button`,{onClick:()=>t(n),className:v(`px-6 py-3 text-sm font-bold uppercase tracking-widest transition-all relative`,e===n?`text-shogun-gold`:`text-shogun-subdued hover:text-shogun-text`),children:[P(`shogun_profile.tab_${n}`,n),e===n&&(0,x.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-0.5 bg-shogun-gold shadow-[0_0_10px_rgba(212,160,23,0.5)]`})]},n))}),(0,x.jsxs)(`div`,{className:`mt-6`,children:[e===`general`&&(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(ae,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`shogun_profile.identity`,`Identity & Persona`)]}),(0,x.jsxs)(`div`,{className:`space-y-4`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.agent_name`,`Agent Name`)}),(0,x.jsx)(`input`,{type:`text`,value:F.name,onChange:e=>I({...F,name:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.active_persona`,`Active Persona`)}),(0,x.jsxs)(`select`,{value:F.persona_id||``,onChange:e=>{let t=L.find(t=>t.id===e.target.value);I({...F,persona_id:e.target.value,description:t?.description||F.description,autonomy:t?t.autonomy===`high`?80:t.autonomy===`low`?20:50:F.autonomy,risk_tolerance:t?.risk_tolerance||F.risk_tolerance,verbosity:t?.verbosity||F.verbosity,tone:t?.tone||F.tone||`analytical`,planning_depth:t?.planning_depth||F.planning_depth||`medium`,tool_usage_style:t?.tool_usage_style||F.tool_usage_style||`balanced`,security_bias:t?.security_bias||F.security_bias||`balanced`,memory_style:t?.memory_style||F.memory_style||`focused`})},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.select_persona`,`Select a persona...`)}),L.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),F.persona_id&&(()=>{let e=L.find(e=>e.id===F.persona_id);return e?(0,x.jsxs)(`div`,{className:`grid grid-cols-3 gap-1.5 mt-2`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-center py-1 rounded bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/20 uppercase font-bold`,children:P(`profile.trait_${e.tone}`,e.tone)}),(0,x.jsx)(`span`,{className:`text-[8px] text-center py-1 rounded bg-shogun-blue/10 text-shogun-blue border border-shogun-blue/20 uppercase font-bold`,children:P(`profile.trait_${e.security_bias}`,e.security_bias)}),(0,x.jsx)(`span`,{className:`text-[8px] text-center py-1 rounded bg-green-500/10 text-green-500 border border-green-500/20 uppercase font-bold`,children:P(`profile.trait_${e.autonomy}`,e.autonomy)})]}):null})()]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.description`,`Description`)}),(0,x.jsx)(`textarea`,{value:F.description||``,onChange:e=>I({...F,description:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors min-h-[100px]`})]})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(se,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`shogun_profile.autonomy_logic`,`Autonomy & Logic`)]}),(0,x.jsxs)(`div`,{className:`space-y-5 pt-2`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.autonomy_level`,`Autonomy Level`)}),(0,x.jsxs)(`span`,{className:`text-shogun-blue font-mono font-bold`,children:[F.autonomy,`%`]})]}),(0,x.jsx)(`input`,{type:`range`,min:`0`,max:`100`,step:`10`,value:F.autonomy,onChange:e=>I({...F,autonomy:parseInt(e.target.value)}),className:`w-full accent-shogun-blue`}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued italic`,children:P(`profile.autonomy_desc`,`Higher levels allow Shogun to spawn sub-agents and execute complex tools without explicit operator confirmation.`)})]}),(0,x.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_tone`,`Tone`)}),(0,x.jsxs)(`select`,{value:F.tone||`analytical`,onChange:e=>I({...F,tone:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`analytical`,children:P(`setup.step3_tone_analytical`,`Analytical`)}),(0,x.jsx)(`option`,{value:`direct`,children:P(`setup.step3_tone_direct`,`Direct`)}),(0,x.jsx)(`option`,{value:`supportive`,children:P(`setup.step3_tone_supportive`,`Supportive`)}),(0,x.jsx)(`option`,{value:`strategic`,children:P(`setup.step3_tone_strategic`,`Strategic`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_risk`,`Risk Tolerance`)}),(0,x.jsxs)(`select`,{value:F.risk_tolerance,onChange:e=>I({...F,risk_tolerance:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`low`,children:P(`setup.step3_risk_low`,`Low (Cautious)`)}),(0,x.jsx)(`option`,{value:`medium`,children:P(`setup.step3_risk_medium`,`Medium (Balanced)`)}),(0,x.jsx)(`option`,{value:`high`,children:P(`setup.step3_risk_high`,`High (Aggressive)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_verbosity`,`Verbosity`)}),(0,x.jsxs)(`select`,{value:F.verbosity,onChange:e=>I({...F,verbosity:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`low`,children:P(`setup.step3_verbosity_low`,`Concise`)}),(0,x.jsx)(`option`,{value:`medium`,children:P(`setup.step3_verbosity_medium`,`Moderate`)}),(0,x.jsx)(`option`,{value:`high`,children:P(`setup.step3_verbosity_high`,`Detailed`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_planning`,`Planning Depth`)}),(0,x.jsxs)(`select`,{value:F.planning_depth||`medium`,onChange:e=>I({...F,planning_depth:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`low`,children:P(`setup.step3_planning_low`,`Shallow (Act fast)`)}),(0,x.jsx)(`option`,{value:`medium`,children:P(`setup.step3_planning_medium`,`Standard (Plan then act)`)}),(0,x.jsx)(`option`,{value:`high`,children:P(`setup.step3_planning_high`,`Deep (Exhaustive planning)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_tool_usage`,`Tool Usage`)}),(0,x.jsxs)(`select`,{value:F.tool_usage_style||`balanced`,onChange:e=>I({...F,tool_usage_style:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`conservative`,children:P(`setup.step3_tool_conservative`,`Conservative (Minimal)`)}),(0,x.jsx)(`option`,{value:`balanced`,children:P(`setup.step3_tool_balanced`,`Balanced`)}),(0,x.jsx)(`option`,{value:`aggressive`,children:P(`setup.step3_tool_aggressive`,`Aggressive (Chain freely)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_security_bias`,`Security Bias`)}),(0,x.jsxs)(`select`,{value:F.security_bias||`balanced`,onChange:e=>I({...F,security_bias:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`strict`,children:P(`setup.step3_security_strict`,`Strict (Least privilege)`)}),(0,x.jsx)(`option`,{value:`balanced`,children:P(`setup.step3_security_balanced`,`Balanced`)}),(0,x.jsx)(`option`,{value:`open`,children:P(`setup.step3_security_open`,`Open (Trust-first)`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`setup.step3_memory`,`Memory Style`)}),(0,x.jsxs)(`select`,{value:F.memory_style||`focused`,onChange:e=>I({...F,memory_style:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`,children:[(0,x.jsx)(`option`,{value:`conservative`,children:P(`setup.step3_memory_conservative`,`Conservative (Minimal retention)`)}),(0,x.jsx)(`option`,{value:`focused`,children:P(`setup.step3_memory_focused`,`Focused (Task-relevant)`)}),(0,x.jsx)(`option`,{value:`expansive`,children:P(`setup.step3_memory_expansive`,`Expansive (Broad context)`)})]})]})]})]})]}),(0,x.jsx)(`div`,{className:`shogun-card md:col-span-2`,children:(0,x.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 sm:flex-row sm:items-center`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsx)(re,{className:`mt-0.5 h-5 w-5 text-shogun-gold`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`h3`,{className:`text-sm font-bold text-shogun-text`,children:`Security is owned by ToolGate`}),(0,x.jsxs)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:[q?.name||`No policy assigned`,` · `,J?J.toUpperCase():`UNKNOWN`,` base tier · Capability risk `,Q,`/100`]}),(0,x.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-shogun-subdued`,children:`Torii selects the policy. ToolGate configures capability boundaries, runtime Allow/Confirm/Block rules, approvals, and risk.`})]})]}),(0,x.jsx)(`button`,{onClick:()=>N(`/toolgate`),className:`rounded-lg border border-shogun-gold/30 bg-shogun-gold/10 px-4 py-2.5 text-xs font-bold text-shogun-gold hover:bg-shogun-gold/20`,children:`Open ToolGate`})]})})]}),e===`models`&&(()=>{let e=Se.filter(e=>e.status!==`disabled`).flatMap(e=>(e.config?.models?.length?e.config.models:e.config?.model_id?[e.config.model_id]:[e.name]).map(t=>({value:`${e.id}::${t}`,label:t,group:`${e.provider_type?.toUpperCase()} — ${e.name}`,providerType:e.provider_type}))),t=ve.find(e=>e.id===F.model_routing_profile_id),n=t?.name===`Custom`;return(0,x.jsxs)(`div`,{className:`space-y-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-3`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(_,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`profile.routing_strategy`,`Routing Strategy`)]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`The routing profile controls model selection. Presets choose automatically; Custom uses your ordered model list.`})]}),(0,x.jsxs)(`select`,{value:F.model_routing_profile_id||``,onChange:e=>I({...F,model_routing_profile_id:e.target.value}),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-blue outline-none transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:`— Select routing strategy —`}),ve.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),t?.description&&(0,x.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:t.description})]}),n?(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(f,{className:`w-5 h-5 text-shogun-blue`}),` Custom Primary Model`]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Preferred first when it satisfies the task's capability and safety requirements.`})]}),e.length===0?(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl text-center space-y-2`,children:[(0,x.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:P(`profile.no_providers`,`No active providers found.`)}),(0,x.jsx)(`button`,{onClick:()=>N(`/katana`),className:`text-xs text-shogun-blue hover:text-shogun-gold font-bold uppercase tracking-widest`,children:P(`profile.configure_katana`,`Configure in The Katana →`)})]}):(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.select_model`,`Select Model`)}),(0,x.jsxs)(`select`,{value:R,onChange:e=>Ee(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm font-mono focus:border-shogun-gold outline-none transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.choose_model`,`— Choose a model —`)}),Se.filter(e=>e.status!==`disabled`).map(e=>{let t=e.config?.models?.length?e.config.models:e.config?.model_id?[e.config.model_id]:[e.name];return(0,x.jsx)(`optgroup`,{label:`${e.provider_type?.toUpperCase()} — ${e.name}`,children:t.map(t=>(0,x.jsx)(`option`,{value:`${e.id}::${t}`,children:t},`${e.id}::${t}`))},e.id)})]}),R&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 p-2.5 rounded-lg bg-shogun-gold/5 border border-shogun-gold/20`,children:[(0,x.jsx)(u,{className:`w-3.5 h-3.5 text-shogun-gold shrink-0`}),(0,x.jsx)(`span`,{className:`text-xs font-mono text-shogun-gold font-bold truncate`,children:R.split(`::`)[1]}),(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued ml-auto shrink-0`,children:P(`profile.primary_tag`,`PRIMARY`)})]})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(_,{className:`w-5 h-5 text-shogun-gold`}),` Custom Fallback Models`]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:P(`profile.fallback_models_desc`,`Used when the primary is unavailable. Order matters.`)})]}),(0,x.jsxs)(`span`,{className:`text-[10px] bg-shogun-gold/10 text-shogun-gold px-2 py-0.5 rounded border border-shogun-gold/20 font-bold shrink-0`,children:[z.length,` `,P(`profile.selected`,`selected`)]})]}),e.length===0?(0,x.jsx)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl text-center`,children:(0,x.jsx)(`p`,{className:`text-sm text-shogun-subdued`,children:P(`profile.no_providers_short`,`No active providers.`)})}):(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.add_fallback`,`Add Fallback`)}),(0,x.jsxs)(`select`,{value:``,onChange:e=>{let t=e.target.value;t&&t!==R&&!z.includes(t)&&B(e=>[...e,t])},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm font-mono focus:border-shogun-blue outline-none transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.add_fallback_placeholder`,`— Add a fallback model —`)}),Se.filter(e=>e.status!==`disabled`).map(e=>{let t=e.config?.models?.length?e.config.models:e.config?.model_id?[e.config.model_id]:[e.name];return(0,x.jsx)(`optgroup`,{label:`${e.provider_type?.toUpperCase()} — ${e.name}`,children:t.filter(t=>{let n=`${e.id}::${t}`;return n!==R&&!z.includes(n)}).map(t=>(0,x.jsx)(`option`,{value:`${e.id}::${t}`,children:t},`${e.id}::${t}`))},e.id)})]})]}),z.length>0?(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.fallback_order`,`Fallback Order`)}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued/50`,children:P(`profile.drag_reorder`,`Drag to reorder priority.`)}),z.map((e,t)=>(0,x.jsxs)(`div`,{draggable:!0,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t))},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`},onDrop:e=>{e.preventDefault();let n=Number(e.dataTransfer.getData(`text/plain`));n!==t&&B(e=>{let r=[...e],[i]=r.splice(n,1);return r.splice(t,0,i),r})},className:`flex items-center gap-2 p-2.5 rounded-lg border border-shogun-blue/20 bg-shogun-blue/5 cursor-grab active:cursor-grabbing active:border-shogun-blue/50 active:bg-shogun-blue/10 transition-colors select-none`,children:[(0,x.jsx)(te,{className:`w-3.5 h-3.5 text-shogun-subdued/40 shrink-0`}),(0,x.jsxs)(`span`,{className:`text-[9px] font-bold text-shogun-blue w-5 shrink-0`,children:[`#`,t+1]}),(0,x.jsx)(`span`,{className:`text-xs font-mono text-shogun-text flex-1 truncate`,children:e.split(`::`)[1]}),(0,x.jsx)(`button`,{onClick:()=>B(t=>t.filter(t=>t!==e)),className:`text-shogun-subdued hover:text-red-400 transition-colors shrink-0 p-0.5`,title:`Remove`,children:(0,x.jsx)(oe,{className:`w-3 h-3`})})]},e))]}):(0,x.jsx)(`p`,{className:`text-[11px] text-shogun-subdued italic text-center py-2`,children:P(`profile.no_fallbacks`,`No fallbacks selected — the primary model will always be used.`)})]})]})]}):(0,x.jsxs)(`div`,{className:`shogun-card border-shogun-blue/20 bg-shogun-blue/5`,children:[(0,x.jsxs)(`p`,{className:`text-sm font-medium`,children:[t?.name||`No routing profile selected`,` controls model choice automatically.`]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-1`,children:`Choose Custom above to select and order the exact models Shogun may use.`})]})]})})(),e===`behavior`&&(0,x.jsxs)(`div`,{className:`shogun-card`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(le,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`shogun_profile.behavioral_directives`,`Behavioral Directives`)]}),(0,x.jsx)(`span`,{className:`text-[10px] font-mono text-shogun-subdued`,children:`v1.0.4-LTS`})]}),(0,x.jsxs)(`div`,{className:`relative group`,children:[(0,x.jsx)(`textarea`,{spellCheck:!1,defaultValue:`priorities: - - Safety before autonomy - - Use existing trusted skills when possible - - Escalate ambiguous high-risk actions - - Maintain stealth in network operations - -operational_constraints: - - shell_access: restricted_to_container - - memory_retention: long_term - - verification_threshold: 0.85 - -delegation_rules: - - research: delegate_to_samurai - - coding: delegate_to_samurai - - tactical_analysis: shogun_priority`,className:`w-full bg-[#050508] border border-shogun-border rounded-xl p-6 font-mono text-xs leading-relaxed text-shogun-text focus:border-shogun-gold transition-colors min-h-[400px] resize-y scrollbar-hide`}),(0,x.jsx)(`div`,{className:`absolute top-4 right-4 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,x.jsx)(`span`,{className:`text-[10px] bg-shogun-card px-2 py-1 rounded border border-shogun-border text-shogun-subdued`,children:`YAML Mode`})})]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued mt-4 italic`,children:`* Note: These directives are the core philosophical foundation that Shogun uses to validate its own reasoning processes.`})]}),e===`permissions`&&(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(ie,{className:`w-5 h-5 text-shogun-gold`}),` `,P(`shogun_profile.authority_metrics`,`Authority Metrics`)]}),Pe&&(0,x.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest px-2 py-1 rounded border border-shogun-blue/30 bg-shogun-blue/10 text-shogun-blue`,children:P(`profile.custom`,`Custom`)})]}),(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] rounded-xl border border-shogun-border`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.security_risk_index`,`Security Risk Index`)}),(0,x.jsxs)(`span`,{className:v(`text-sm font-bold font-mono`,Q<=25?`text-green-400`:Q<=50?`text-shogun-gold`:Q<=75?`text-orange-400`:`text-red-400`),children:[Q,`/100`]})]}),(0,x.jsx)(`div`,{className:`w-full h-2.5 bg-[#0a0e1a] rounded-full overflow-hidden`,children:(0,x.jsx)(`div`,{className:v(`h-full rounded-full transition-all duration-500`,Q<=25?`bg-gradient-to-r from-green-500 to-green-400`:Q<=50?`bg-gradient-to-r from-green-400 via-yellow-400 to-shogun-gold`:Q<=75?`bg-gradient-to-r from-yellow-400 via-orange-400 to-orange-500`:`bg-gradient-to-r from-orange-500 via-red-500 to-red-600`),style:{width:`${Q}%`}})}),(0,x.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-green-400/60`,children:P(`profile.locked_down`,`LOCKED DOWN`)}),(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-gold/60`,children:P(`profile.risk_balanced`,`BALANCED`)}),(0,x.jsx)(`span`,{className:`text-[8px] text-red-400/60`,children:P(`profile.permissive`,`PERMISSIVE`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.base_policy`,`Base Policy`)}),(0,x.jsxs)(`select`,{value:F.security_policy_id||``,onChange:e=>{I({...F,security_policy_id:e.target.value}),H(null),W(``)},className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`,children:[(0,x.jsx)(`option`,{value:``,children:P(`profile.select_security_tier`,`Select security tier...`)}),be.map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),Pe&&(0,x.jsxs)(`div`,{className:`space-y-1.5 p-3 bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-blue uppercase tracking-widest`,children:P(`profile.custom_policy_name`,`Custom Policy Name`)}),(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsx)(`input`,{type:`text`,value:U,onChange:e=>W(e.target.value),placeholder:`e.g. Project Alpha — Relaxed`,className:`flex-1 bg-[#050508] border border-shogun-border rounded-lg p-2 text-xs focus:border-shogun-blue transition-colors`}),(0,x.jsx)(`button`,{onClick:Be,disabled:w||!U.trim(),className:`px-4 py-2 bg-shogun-blue/20 border border-shogun-blue/30 rounded-lg text-[10px] font-bold text-shogun-blue uppercase tracking-widest hover:bg-shogun-blue/30 transition-all disabled:opacity-40 disabled:cursor-not-allowed`,children:w?`...`:P(`common.save`,`Save`)})]})]}),(0,x.jsxs)(`div`,{className:v(`rounded-xl border p-3 text-[10px] leading-relaxed`,Y?`border-purple-500/25 bg-purple-500/5 text-purple-200`:`border-amber-500/25 bg-amber-500/5 text-amber-200`),children:[`AgentFlow and Flow Stack permissions are explicit and disabled by default. They can only be enabled under Tactical, Campaign, or Ronin posture. Current policy: `,(0,x.jsx)(`b`,{children:J?J.toUpperCase():`UNKNOWN`}),`.`]}),J===`ronin`&&(0,x.jsxs)(`div`,{className:`p-4 rounded-xl border border-orange-500/30 bg-orange-500/5 space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(ee,{className:`w-4 h-4 text-orange-400`}),(0,x.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-orange-300`,children:`Ronin Desktop Control`})]}),(0,x.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued mt-1`,children:`Explicit runtime permission for mouse, keyboard, window management, application launch, screenshots, and verification. It remains disabled by default even after selecting Ronin posture.`})]}),(0,x.jsx)(`button`,{disabled:Oe||!G?.available,onClick:()=>Fe(!G?.active),className:v(`shrink-0 px-3 py-1.5 rounded-lg border text-[9px] font-bold uppercase tracking-wider disabled:opacity-40`,G?.active?`border-red-500/40 bg-red-500/10 text-red-400`:`border-orange-500/40 bg-orange-500/10 text-orange-300`),children:G?.active?`Disable desktop control`:G?.available?`Enable desktop control`:`Switch Torii to Ronin`})]}),(0,x.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:[[`Mouse actions`,G?.ronin_mouse_enabled],[`Keyboard actions`,G?.ronin_keyboard_enabled],[`Window management`,G?.ronin_window_management_enabled],[`Application launch`,G?.ronin_native_apps_enabled],[`Verification required`,G?.ronin_require_verification],[`Critical actions blocked`,G?.ronin_block_critical_actions]].map(([e,t])=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-shogun-border bg-[#050508] px-2.5 py-2`,children:[(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued`,children:e}),(0,x.jsx)(`span`,{className:v(`w-2 h-2 rounded-full`,t?`bg-green-400`:`bg-red-400`)})]},String(e)))}),(0,x.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] text-orange-200/70`,children:[(0,x.jsx)(`span`,{children:`High-risk actions require approval. Protected applications and credential contexts are blocked.`}),(0,x.jsx)(`button`,{onClick:()=>N(`/katana#ronin`),className:`font-bold text-orange-300 hover:text-orange-200`,children:`Open session view →`})]})]}),Z?Object.entries(Z).filter(([e])=>e!==`mado_browser`&&(e!==`ide_mode`||Me)).map(([e,t],n)=>(0,x.jsxs)(`div`,{className:`p-3 bg-[#050508] rounded-xl border border-shogun-border space-y-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 pb-1 border-b border-shogun-border/50 group/cat`,children:[(0,x.jsx)(ie,{className:`w-3.5 h-3.5 text-shogun-gold`}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wider text-shogun-text cursor-help`,children:e===`network`?P(`profile.perm_cat_network_mado`,`Network & Mado Browser`):P(`profile.perm_cat_${e}`,e===`agentflow`?`AgentFlow`:e===`flow_stack`?`Flow Stack`:e.replace(/_/g,` `))}),K(e)&&(0,x.jsxs)(`div`,{className:`absolute left-0 bottom-full mb-2 w-64 p-2.5 bg-[#0a0e1a] border border-shogun-gold/30 rounded-lg text-[10px] text-shogun-text leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/cat:opacity-100 transition-opacity duration-200 z-50`,children:[(0,x.jsx)(`div`,{className:`absolute -bottom-1 left-4 w-2 h-2 bg-[#0a0e1a] border-r border-b border-shogun-gold/30 rotate-45`}),K(e)]})]}),(e===`agentflow`||e===`flow_stack`)&&(0,x.jsx)(`span`,{className:v(`ml-auto rounded border px-1.5 py-0.5 text-[8px] font-bold uppercase`,Y?`border-purple-500/30 bg-purple-500/10 text-purple-300`:`border-amber-500/30 bg-amber-500/10 text-amber-300`),children:Y?`Tactical+ available`:`Posture locked`}),e===`ide_mode`&&(0,x.jsx)(`span`,{className:`ml-auto rounded border border-purple-500/30 bg-purple-500/10 px-1.5 py-0.5 text-[8px] font-bold uppercase text-purple-300`,children:`Campaign / Ronin`})]}),typeof t==`object`&&t&&!Array.isArray(t)?(0,x.jsx)(`div`,{className:`grid gap-1`,children:Object.entries(t).map(([t,n],r)=>{let i=typeof n==`boolean`,a=t.toLowerCase()===`mode`,o=typeof n==`number`,s=Array.isArray(n),c=n=>{let r=JSON.parse(JSON.stringify(Z));r[e][t]=n,H(r)};return(0,x.jsxs)(`div`,{className:v(`py-1.5 px-2 rounded hover:bg-[#0a0e1a] transition-colors`,s?`space-y-2`:`flex items-center justify-between`),children:[(0,x.jsxs)(`div`,{className:`relative group/tip`,children:[(0,x.jsx)(`span`,{className:v(`text-[10px] text-shogun-subdued font-medium capitalize`,K(e,t)&&`border-b border-dashed border-shogun-subdued/30 cursor-help`),children:P(`profile.perm_prop_${t}`,t.replace(/_/g,` `).toLowerCase())}),K(e,t)&&(0,x.jsxs)(`div`,{className:`absolute left-0 bottom-full mb-2 w-56 p-2 bg-[#0a0e1a] border border-shogun-border rounded-lg text-[10px] text-shogun-text/80 leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/tip:opacity-100 transition-opacity duration-200 z-50`,children:[(0,x.jsx)(`div`,{className:`absolute -bottom-1 left-3 w-2 h-2 bg-[#0a0e1a] border-r border-b border-shogun-border rotate-45`}),K(e,t)]})]}),(0,x.jsx)(`div`,{className:v(`flex items-center gap-2`,s&&`flex-wrap`),children:i?(0,x.jsx)(`button`,{onClick:()=>c(!n),disabled:(e===`agentflow`||e===`flow_stack`)&&!Y||e===`ide_mode`&&!Me,className:v(`w-10 h-5 rounded-full relative transition-all duration-300 border`,(e===`agentflow`||e===`flow_stack`)&&!Y&&`cursor-not-allowed opacity-35`,n?`bg-green-500/20 border-green-500/40`:`bg-red-500/10 border-red-500/30`),children:(0,x.jsx)(`div`,{className:v(`absolute top-0.5 w-4 h-4 rounded-full transition-all duration-300`,n?`left-5 bg-green-400`:`left-0.5 bg-red-400`)})}):a?(0,x.jsxs)(`select`,{value:String(n),onChange:e=>c(e.target.value),className:`bg-[#0a0a10] border border-shogun-border rounded px-2 py-0.5 text-[10px] font-bold uppercase text-shogun-gold focus:border-shogun-gold transition-colors`,children:[(0,x.jsx)(`option`,{value:`full`,children:P(`profile.mode_full`,`Full`)}),(0,x.jsx)(`option`,{value:`scoped`,children:P(`profile.mode_scoped`,`Scoped`)}),(0,x.jsx)(`option`,{value:`allowlist`,children:P(`profile.mode_allowlist`,`Allowlist`)}),(0,x.jsx)(`option`,{value:`disabled`,children:P(`profile.mode_disabled`,`Disabled`)})]}):o?(0,x.jsx)(`input`,{type:`number`,value:n,onChange:e=>c(parseInt(e.target.value)||0),className:`w-16 bg-[#0a0a10] border border-shogun-border rounded px-2 py-0.5 text-[10px] font-bold text-shogun-blue text-center focus:border-shogun-blue transition-colors`}):s?(0,x.jsxs)(`div`,{className:`w-full space-y-1.5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[n.length===0&&(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued italic`,children:e.toLowerCase()===`network`&&t.toLowerCase()===`allowed_domains`?P(`profile.no_apis_selected`,`No APIs selected — choose from the Katana Toolbox below`):P(`profile.no_entries`,`No entries — type below to add`)}),n.map((e,t)=>(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-mono bg-shogun-gold/10 text-shogun-gold border border-shogun-gold/20 px-2 py-0.5 rounded`,children:[e,(0,x.jsx)(`button`,{onClick:()=>{let e=[...n];e.splice(t,1),c(e)},className:`text-shogun-gold/50 hover:text-red-400 transition-colors ml-0.5`,children:`×`})]},t))]}),e.toLowerCase()===`network`&&t.toLowerCase()===`allowed_domains`?(0,x.jsxs)(`div`,{className:`space-y-1`,children:[we.length>0?we.map(e=>{let t=e.base_url?(()=>{try{return new URL(e.base_url).hostname}catch{return e.slug}})():e.slug,r=n.includes(t);return(0,x.jsxs)(`button`,{onClick:()=>{c(r?n.filter(e=>e!==t):[...n,t])},className:v(`w-full flex items-center justify-between p-2 rounded-lg border text-left transition-all`,r?`border-shogun-gold/40 bg-shogun-gold/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`div`,{className:v(`w-3.5 h-3.5 rounded border-2 flex items-center justify-center transition-all`,r?`border-shogun-gold bg-shogun-gold`:`border-shogun-subdued`),children:r&&(0,x.jsx)(u,{className:`w-2 h-2 text-black`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`text-[10px] font-bold text-shogun-text`,children:e.name}),(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-subdued ml-2 font-mono`,children:t})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-blue/60 uppercase`,children:e.connector_type||`api`}),(0,x.jsx)(`span`,{className:v(`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded`,e.status===`connected`?`text-green-400 bg-green-500/10`:`text-shogun-subdued bg-[#0a0e1a]`),children:e.status===`connected`?P(`profile.status_active`,`Active`):e.status})]})]},e.id)}):(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic py-2`,children:P(`profile.no_tools`,`No tools or APIs registered in The Katana Toolbox yet.`)}),(0,x.jsxs)(`div`,{className:`pt-1 border-t border-shogun-border/30 space-y-1`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`span`,{className:`text-[8px] text-shogun-subdued uppercase tracking-widest font-bold`,children:P(`profile.add_custom_website`,`Add Custom Website`)}),!n.includes(`*.*`)&&(0,x.jsxs)(`span`,{className:`text-[8px] text-shogun-subdued italic`,children:[P(`profile.type_wildcard`,`Type`),` `,(0,x.jsx)(`code`,{className:`text-red-400 font-mono font-bold`,children:`*.*`}),` `,P(`profile.to_allow_all`,`to allow all`)]})]}),n.includes(`*.*`)&&(0,x.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,x.jsx)(`span`,{className:`text-[9px] font-bold text-red-400 uppercase tracking-widest`,children:P(`profile.all_websites_warning`,`⚠ All websites permitted`)}),(0,x.jsx)(`span`,{className:`text-[8px] text-red-400/60`,children:P(`profile.all_websites_desc`,`— The agent can access any domain without restriction.`)})]}),(0,x.jsx)(`input`,{type:`text`,placeholder:`e.g. github.com or *.* for unrestricted`,className:`w-full bg-[#0a0a10] border border-shogun-border rounded px-2 py-1 text-[10px] font-mono text-shogun-text placeholder:text-shogun-subdued/40 focus:border-shogun-gold transition-colors`,onKeyDown:e=>{e.key===`Enter`&&e.target.value.trim()&&(c([...n,e.target.value.trim()]),e.target.value=``)}})]})]}):(0,x.jsx)(`input`,{type:`text`,placeholder:`Add ${t.replace(/_/g,` `).toLowerCase()}…`,className:`w-full bg-[#0a0a10] border border-shogun-border rounded px-2 py-1 text-[10px] font-mono text-shogun-text placeholder:text-shogun-subdued/40 focus:border-shogun-gold transition-colors`,onKeyDown:e=>{e.key===`Enter`&&e.target.value.trim()&&(c([...n,e.target.value.trim()]),e.target.value=``)}})]}):(0,x.jsx)(`span`,{className:v(`text-[10px] font-bold uppercase px-2 py-0.5 rounded border`,`text-shogun-gold bg-shogun-gold/10 border-shogun-gold/20`),children:String(n)})})]},r)})}):(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued font-bold uppercase`,children:String(t)}),e===`network`&&Z.mado_browser&&(0,x.jsxs)(`div`,{className:`mt-3 border-t border-shogun-gold/20 pt-3 space-y-1`,children:[(0,x.jsxs)(`div`,{className:`group/mado relative mb-2 flex items-center gap-2`,children:[(0,x.jsx)(s,{className:`w-3.5 h-3.5 text-cyan-400`}),(0,x.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-[0.18em] text-cyan-300 cursor-help`,children:P(`profile.perm_section_mado`,`Mado browser`)}),(0,x.jsx)(`div`,{className:`absolute left-0 bottom-full mb-2 w-64 p-2.5 bg-[#0a0e1a] border border-cyan-400/30 rounded-lg text-[10px] text-shogun-text leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/mado:opacity-100 transition-opacity z-50`,children:K(`mado_browser`)})]}),Object.entries(Z.mado_browser).map(([e,t])=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between py-1.5 px-2 rounded hover:bg-[#0a0e1a] transition-colors`,children:[(0,x.jsxs)(`div`,{className:`relative group/mado-tip`,children:[(0,x.jsx)(`span`,{className:v(`text-[10px] text-shogun-subdued font-medium capitalize`,K(`mado_browser`,e)&&`border-b border-dashed border-shogun-subdued/30 cursor-help`),children:P(`profile.perm_prop_${e}`,e.replace(/_/g,` `).toLowerCase())}),K(`mado_browser`,e)&&(0,x.jsx)(`div`,{className:`absolute left-0 bottom-full mb-2 w-56 p-2 bg-[#0a0e1a] border border-shogun-border rounded-lg text-[10px] text-shogun-text/80 leading-relaxed shadow-xl opacity-0 pointer-events-none group-hover/mado-tip:opacity-100 transition-opacity z-50`,children:K(`mado_browser`,e)})]}),(0,x.jsx)(`button`,{onClick:()=>{let n=JSON.parse(JSON.stringify(Z));n.mado_browser[e]=!t,H(n)},className:v(`w-10 h-5 rounded-full relative transition-all duration-300 border`,t?`bg-green-500/20 border-green-500/40`:`bg-red-500/10 border-red-500/30`),children:(0,x.jsx)(`div`,{className:v(`absolute top-0.5 w-4 h-4 rounded-full transition-all duration-300`,t?`left-5 bg-green-400`:`left-0.5 bg-red-400`)})})]},e))]})]},n)):(0,x.jsx)(`p`,{className:`text-xs text-shogun-subdued italic p-4 text-center`,children:P(`profile.select_policy_prompt`,`Select a policy to view and customize constraints.`)}),Pe&&(0,x.jsx)(`button`,{onClick:()=>{H(null),W(``)},className:`w-full py-2 bg-[#050508] border border-shogun-border rounded-lg text-[10px] font-bold text-shogun-subdued hover:text-red-400 hover:border-red-400/30 transition-all uppercase tracking-widest`,children:P(`profile.reset_to_preset`,`Reset to Preset`)})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(_,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`profile.skill_inventory`,`Skill Inventory`)]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:[{name:P(`profile.skill_core_sentinel`,`Core Sentinel`),type:P(`profile.skill_type_system`,`System`),size:`124KB`},{name:P(`profile.skill_tactical_analyzer`,`Tactical Analyzer`),type:P(`profile.skill_type_intelligence`,`Intelligence`),size:`2.1MB`},{name:P(`profile.skill_samurai_spawner`,`Samurai Spawner`),type:P(`profile.skill_type_orchestration`,`Orchestration`),size:`450KB`}].map((e,t)=>(0,x.jsxs)(`div`,{onClick:()=>N(`/dojo`),className:`flex items-center justify-between p-3 border-b border-shogun-border last:border-0 hover:bg-[#0a0e1a] transition-colors rounded cursor-pointer group`,children:[(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`text-sm font-bold text-shogun-text group-hover:text-shogun-gold transition-colors`,children:e.name}),(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:e.type})]}),(0,x.jsx)(c,{className:`w-4 h-4 text-shogun-border group-hover:text-shogun-gold transition-colors`})]},t))}),(0,x.jsx)(`button`,{onClick:()=>N(`/dojo`),className:`w-full py-2 bg-[#050508] border border-shogun-border rounded text-[10px] font-bold text-shogun-subdued hover:text-shogun-gold hover:border-shogun-gold transition-all uppercase tracking-widest`,children:P(`profile.browse_dojo`,`Browse Dojo for Skills`)})]})]}),e===`operations`&&(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,x.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(o,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`profile.system_diagnostics`,`System Diagnostics`)]}),(0,x.jsxs)(`div`,{className:`grid grid-cols-1 gap-4`,children:[(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:v(`p-2 rounded-lg`,O?.qdrant===`healthy`?`bg-green-500/10 text-green-500`:`bg-red-500/10 text-red-500`),children:(0,x.jsx)(p,{className:`w-5 h-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-sm font-bold`,children:P(`profile.vector_engine`,`Vector Engine (Qdrant)`)}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:O?.qdrant===`healthy`?P(`profile.lattice_sync`,`Lattice Synchronized`):P(`profile.offline_error`,`Offline / Disk Error`)})]})]}),(0,x.jsx)(`span`,{className:v(`text-[8px] font-bold px-2 py-0.5 rounded border uppercase`,O?.qdrant===`healthy`?`text-green-500 border-green-500/30`:`text-red-500 border-red-500/30`),children:O?.qdrant||`offline`})]}),(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`div`,{className:`p-2 rounded-lg bg-shogun-blue/10 text-shogun-blue`,children:(0,x.jsx)(ne,{className:`w-5 h-5`})}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-sm font-bold`,children:P(`profile.relational_core`,`Relational Core`)}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.sqlite_optimal`,`SQLite Performance: Optimal`)})]})]}),(0,x.jsx)(`span`,{className:`text-[8px] font-bold text-green-500 border border-green-500/30 px-2 py-0.5 rounded uppercase`,children:P(`profile.healthy`,`Healthy`)})]})]}),(0,x.jsxs)(`div`,{className:`mt-4 p-4 bg-shogun-blue/5 border border-shogun-blue/20 rounded-xl`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,x.jsx)(m,{className:`w-3 h-3 text-shogun-blue animate-spin-slow`}),(0,x.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest text-shogun-blue`,children:P(`profile.lattice_sync_title`,`Lattice Sync`)})]}),(0,x.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:[P(`profile.lattice_sync_desc`,`Vector indices are automatically synchronized every 15 minutes.`),` `,P(`profile.last_sync`,`The last successful sync occurred`),` `,Math.floor(Math.random()*10)+1,` `,P(`profile.minutes_ago`,`minutes ago.`)]})]})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-6`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(d,{className:`w-5 h-5 text-shogun-gold`}),` Operational Cadence Presets`]}),(0,x.jsx)(`div`,{className:`space-y-4`,children:[{jobType:`memory_consolidation`,label:P(`profile.cron_nightly`,`Nightly Consolidation`),desc:P(`profile.cron_nightly_desc`,`Merge episodic traces into semantic memory.`),icon:m,cronLabel:P(`profile.cron_every_night_02`,`Every night at 02:00`)},{jobType:`performance_audit`,label:P(`profile.cron_weekly_audit`,`Weekly Performance Audit`),desc:P(`profile.cron_weekly_desc`,`Review agent fit metrics and behavioral drift.`),icon:ie,cronLabel:P(`profile.cron_every_mon_03`,`Every Monday at 03:00`)},{jobType:`skill_health_check`,label:P(`profile.cron_skill_check`,`Skill Health Check`),desc:P(`profile.cron_skill_desc`,`Verify third-party tool connectivity and versions.`),icon:g,cronLabel:P(`profile.cron_every_night_04`,`Every night at 04:00`)},{jobType:`persona_drift_check`,label:P(`profile.cron_drift`,`Persona Drift Monitor`),desc:P(`profile.cron_drift_desc`,`Detect deviations from core identity blueprints.`),icon:ae,cronLabel:P(`profile.cron_every_sun_05`,`Every Sunday at 05:00`)}].map(e=>{let t=Re(e.jobType),n=t?t.is_enabled:F.bushido_settings?.[e.jobType]??!1,r=me[e.jobType];return(0,x.jsxs)(`div`,{className:`p-4 bg-[#050508] border border-shogun-border rounded-xl space-y-3 group hover:border-shogun-gold/30 transition-all`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(e.icon,{className:`w-4 h-4 text-shogun-gold opacity-70`}),(0,x.jsx)(`span`,{className:`text-sm font-bold`,children:e.label})]}),(0,x.jsx)(`button`,{onClick:()=>Le(e.jobType),className:v(`w-10 h-5 rounded-full relative transition-all duration-300`,n?`bg-shogun-gold`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:v(`absolute top-1 w-3 h-3 rounded-full bg-white transition-all duration-300`,n?`left-6`:`left-1 bg-shogun-subdued`)})})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued italic`,children:e.desc}),(0,x.jsxs)(`button`,{disabled:r,className:v(`text-[9px] font-bold uppercase tracking-tighter transition-colors flex items-center gap-1`,r?`text-shogun-subdued cursor-not-allowed`:`text-shogun-blue hover:text-shogun-gold`),onClick:async()=>{j(t=>({...t,[e.jobType]:!0}));try{D({type:`success`,text:`Triggering ${e.label}…`}),await y.post(`/api/v1/bushido/run`,{job_type:e.jobType}),D({type:`success`,text:`${e.label} dispatched.`})}catch{D({type:`error`,text:`Failed to trigger maintenance.`})}finally{j(t=>({...t,[e.jobType]:!1})),setTimeout(()=>D(null),3e3)}},children:[r&&(0,x.jsx)(m,{className:`w-2.5 h-2.5 animate-spin`}),r?P(`profile.running`,`Running…`):P(`profile.run_now`,`Run Now`)]})]}),(0,x.jsxs)(`div`,{className:v(`flex items-center gap-1.5 transition-all duration-300`,n?`opacity-100`:`opacity-40`),children:[(0,x.jsx)(d,{className:`w-2.5 h-2.5 text-shogun-gold/60 shrink-0`}),(0,x.jsx)(`span`,{className:`text-[9px] font-mono text-shogun-gold/70 uppercase tracking-widest`,children:ue(t,e.cronLabel)}),t&&!t.scheduler_registered&&n&&(0,x.jsx)(`span`,{className:`text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border text-red-400 border-red-500/30 bg-red-500/10`,children:`Not registered`}),(0,x.jsx)(`span`,{className:v(`ml-auto text-[8px] font-bold uppercase px-1.5 py-0.5 rounded border`,n?`text-green-400 border-green-500/30 bg-green-500/10`:`text-shogun-subdued border-shogun-border`),children:n?P(`profile.status_active_label`,`Active`):P(`profile.status_paused`,`Paused`)})]})]})]},e.jobType)})})]}),(0,x.jsxs)(`div`,{className:`md:col-span-2 shogun-card space-y-6`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(g,{className:`w-5 h-5 text-shogun-blue`}),` `,P(`profile.create_custom_job`,`Create Custom Job`)]}),(0,x.jsx)(`span`,{className:`text-[10px] bg-shogun-blue/10 text-shogun-blue px-2 py-0.5 rounded border border-shogun-blue/20 font-bold uppercase tracking-widest`,children:P(`profile.builder`,`Builder`)})]}),(()=>{let[e,t]=[k.name,e=>A({...k,name:e})],[n,r]=[k.type,e=>A({...k,type:e})],[i,a]=[k.frequency,e=>A({...k,frequency:e})],[s,c]=[k.priority,e=>A({...k,priority:e})],[l,d]=[k.memoryTypes,e=>A({...k,memoryTypes:e})],[f,ee]=[k.allAgents,e=>A({...k,allAgents:e})],[p,te]=[k.dryRun,e=>A({...k,dryRun:e})],[h,ne]=[k.autoApprove,e=>A({...k,autoApprove:e})],g=e=>{d(l.includes(e)?l.filter(t=>t!==e):[...l,e])};return(0,x.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,x.jsxs)(`div`,{className:`space-y-5`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.job_name`,`Job Name`)}),(0,x.jsx)(`input`,{type:`text`,placeholder:`e.g. Weekly Context Prune`,value:e,onChange:e=>t(e.target.value),className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm focus:border-shogun-gold transition-colors`})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.job_type`,`Job Type`)}),(0,x.jsx)(`div`,{className:`space-y-2`,children:[{value:`memory_consolidation`,label:P(`profile.jt_memory`,`Memory Consolidation`),desc:P(`profile.jt_memory_desc`,`Merge & prune memory traces`)},{value:`performance_audit`,label:P(`profile.jt_perf`,`Performance Audit`),desc:P(`profile.jt_perf_desc`,`Review execution quality metrics`)},{value:`skill_health_check`,label:P(`profile.jt_skill`,`Skill Health Check`),desc:P(`profile.jt_skill_desc`,`Verify tool connectivity`)},{value:`persona_drift_check`,label:P(`profile.jt_drift`,`Persona Drift Check`),desc:P(`profile.jt_drift_desc`,`Detect behavioral deviation`)},{value:`custom_task`,label:P(`profile.jt_custom`,`Custom Task`),desc:P(`profile.jt_custom_desc`,`Any repeating instruction — API calls, syncs, monitoring`)}].map(e=>(0,x.jsxs)(`button`,{onClick:()=>r(e.value),className:v(`w-full text-left p-2.5 rounded-lg border transition-all`,n===e.value?e.value===`custom_task`?`border-shogun-blue bg-shogun-blue/10`:`border-shogun-gold bg-shogun-gold/10`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsx)(`span`,{className:v(`text-xs font-bold`,n===e.value?e.value===`custom_task`?`text-shogun-blue`:`text-shogun-gold`:`text-shogun-text`),children:e.label}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued mt-0.5`,children:e.desc})]},e.value))})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.frequency`,`Frequency`)}),(0,x.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:[`one-off`,`hourly`,`nightly`,`weekly`,`monthly`].map(e=>(0,x.jsx)(`button`,{onClick:()=>a(e),className:v(`p-2 rounded-lg text-[10px] font-bold uppercase tracking-widest border transition-all`,i===e?e===`one-off`?`border-shogun-blue bg-shogun-blue/10 text-shogun-blue`:`border-shogun-gold bg-shogun-gold/10 text-shogun-gold`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:P(`profile.freq_${e.replace(`-`,`_`)}`,e===`one-off`?`One-off`:e)},e))}),(0,x.jsxs)(`div`,{className:`p-3 bg-[#050508] border border-shogun-border rounded-xl space-y-3 animate-in fade-in`,children:[i===`one-off`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.scheduled_datetime`,`Scheduled date & time`)}),(0,x.jsx)(`input`,{type:`datetime-local`,value:k.scheduleDateTime,onChange:e=>A({...k,scheduleDateTime:e.target.value}),className:`w-full bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-blue focus:border-shogun-blue transition-colors`}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:k.scheduleDateTime?`Runs once on ${new Date(k.scheduleDateTime).toLocaleDateString(`en-GB`,{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`})} at ${new Date(k.scheduleDateTime).toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`})}`:P(`profile.select_future_date`,`Select a future date and time for this one-time task.`)})]}),i===`hourly`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.minute_offset`,`Minute offset`)}),(0,x.jsxs)(`span`,{className:`text-xs font-mono font-bold text-shogun-gold`,children:[`:`,String(k.minuteOffset).padStart(2,`0`)]})]}),(0,x.jsx)(`input`,{type:`range`,min:`0`,max:`55`,step:`5`,value:k.minuteOffset,onChange:e=>A({...k,minuteOffset:parseInt(e.target.value)}),className:`w-full accent-shogun-gold`}),(0,x.jsxs)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:[P(`profile.runs_every_hour`,`Runs every hour at`),` :`,String(k.minuteOffset).padStart(2,`0`)]})]}),i===`nightly`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.run_at`,`Run at`)}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`input`,{type:`time`,value:k.scheduleTime,onChange:e=>A({...k,scheduleTime:e.target.value}),className:`bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-gold focus:border-shogun-gold transition-colors`}),(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued`,children:P(`profile.local_every_night`,`local time, every night`)})]})]}),i===`weekly`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.active_days`,`Active days`)}),(0,x.jsx)(`div`,{className:`flex gap-1.5`,children:[`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`].map(e=>(0,x.jsx)(`button`,{onClick:()=>{let t=k.scheduleDays.includes(e)?k.scheduleDays.filter(t=>t!==e):[...k.scheduleDays,e];A({...k,scheduleDays:t})},className:v(`w-9 h-9 rounded-lg text-[10px] font-bold uppercase border transition-all`,k.scheduleDays.includes(e)?`border-shogun-gold bg-shogun-gold/15 text-shogun-gold`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:e.charAt(0).toUpperCase()+e.slice(1,2)},e))})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.run_at`,`Run at`)}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`input`,{type:`time`,value:k.scheduleTime,onChange:e=>A({...k,scheduleTime:e.target.value}),className:`bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-gold focus:border-shogun-gold transition-colors`}),(0,x.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[`on `,k.scheduleDays.length===0?`no days`:k.scheduleDays.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(`, `)]})]})]})]}),i===`monthly`&&(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.select_day`,`Select day`)}),(0,x.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:Array.from({length:28},(e,t)=>t+1).map(e=>(0,x.jsx)(`button`,{onClick:()=>A({...k,scheduleDay:e}),className:v(`w-full aspect-square rounded-md text-[10px] font-bold transition-all border`,k.scheduleDay===e?`border-shogun-gold bg-shogun-gold text-black`:`border-shogun-border text-shogun-subdued hover:border-shogun-gold/40 hover:text-shogun-text`),children:e},e))}),(0,x.jsxs)(`div`,{className:`space-y-1.5 pt-1`,children:[(0,x.jsx)(`span`,{className:`text-[10px] text-shogun-subdued uppercase tracking-widest`,children:P(`profile.run_at`,`Run at`)}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsx)(`input`,{type:`time`,value:k.scheduleTime,onChange:e=>A({...k,scheduleTime:e.target.value}),className:`bg-[#0a0a10] border border-shogun-border rounded-lg px-3 py-2 text-sm font-mono text-shogun-gold focus:border-shogun-gold transition-colors`}),(0,x.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[`on the `,k.scheduleDay,k.scheduleDay===1?`st`:k.scheduleDay===2?`nd`:k.scheduleDay===3?`rd`:`th`,` of each month`]})]})]})]})]})]})]}),(0,x.jsxs)(`div`,{className:`space-y-5`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.priority`,`Priority`)}),(0,x.jsx)(`span`,{className:`text-shogun-gold font-mono font-bold text-xs`,children:s<=25?P(`profile.priority_low`,`Low`):s<=50?P(`profile.priority_normal`,`Normal`):s<=75?P(`profile.priority_high`,`High`):P(`profile.priority_critical`,`Critical`)})]}),(0,x.jsx)(`input`,{type:`range`,min:`0`,max:`100`,step:`5`,value:s,onChange:e=>c(parseInt(e.target.value)),className:`w-full accent-shogun-gold`}),(0,x.jsxs)(`div`,{className:`flex justify-between text-[8px] text-shogun-subdued uppercase tracking-widest`,children:[(0,x.jsx)(`span`,{children:P(`profile.priority_low`,`Low`)}),(0,x.jsx)(`span`,{children:P(`profile.priority_normal`,`Normal`)}),(0,x.jsx)(`span`,{children:P(`profile.priority_high`,`High`)}),(0,x.jsx)(`span`,{children:P(`profile.priority_critical`,`Critical`)})]})]}),(n===`memory_consolidation`||n===`performance_audit`)&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:n===`memory_consolidation`?P(`profile.mem_types_consolidate`,`Memory Types to Consolidate`):P(`profile.mem_types_audit`,`Memory Types to Audit`)}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`episodic`,`semantic`,`procedural`,`persona`].map(e=>(0,x.jsxs)(`button`,{onClick:()=>g(e),className:v(`flex items-center gap-2 p-2 rounded-lg text-[10px] font-bold border transition-all`,l.includes(e)?`border-shogun-blue bg-shogun-blue/10 text-shogun-blue`:`border-shogun-border text-shogun-subdued hover:border-shogun-subdued`),children:[(0,x.jsx)(`div`,{className:v(`w-3 h-3 rounded border-2 flex items-center justify-center transition-all`,l.includes(e)?`border-shogun-blue bg-shogun-blue`:`border-shogun-subdued`),children:l.includes(e)&&(0,x.jsx)(u,{className:`w-2 h-2 text-white`})}),(0,x.jsx)(`span`,{className:`capitalize`,children:e})]},e))})]}),n===`skill_health_check`&&(0,x.jsx)(`div`,{className:`p-3 bg-[#050508] border border-shogun-border rounded-xl`,children:(0,x.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[(0,x.jsxs)(`span`,{className:`font-bold text-shogun-blue uppercase`,children:[P(`profile.scope`,`Scope`),`:`]}),` `,P(`profile.scope_skill_desc`,`Verifies connectivity to all installed skills and third-party integrations. No memory parameters required.`)]})}),n===`persona_drift_check`&&(0,x.jsx)(`div`,{className:`p-3 bg-[#050508] border border-shogun-border rounded-xl`,children:(0,x.jsxs)(`p`,{className:`text-[10px] text-shogun-subdued`,children:[(0,x.jsxs)(`span`,{className:`font-bold text-shogun-gold uppercase`,children:[P(`profile.scope`,`Scope`),`:`]}),` `,P(`profile.scope_drift_desc`,`Compares current behavioral patterns against the active persona blueprint. Flags deviations exceeding threshold.`)]})}),n===`custom_task`&&(0,x.jsxs)(`div`,{className:`space-y-2`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.task_instruction`,`Task Instruction`)}),(0,x.jsx)(`textarea`,{value:k.taskInstruction,onChange:e=>A({...k,taskInstruction:e.target.value}),placeholder:`e.g. Check the latest tech news via the NewsAPI connector and store a summary in episodic memory. Flag any articles mentioning our product competitors.`,rows:4,className:`w-full bg-[#050508] border border-shogun-border rounded-lg p-3 text-sm leading-relaxed focus:border-shogun-blue transition-colors resize-none placeholder:text-shogun-subdued/50`}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued italic`,children:P(`profile.custom_task_hint`,`The Shogun will execute this instruction on the defined schedule. Use natural language — reference installed skills, APIs, or connectors by name.`)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-5`,children:[(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`label`,{className:`text-[10px] font-bold text-shogun-subdued uppercase tracking-widest`,children:P(`profile.options`,`Options`)}),(0,x.jsxs)(`div`,{onClick:()=>ee(!f),className:v(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all`,f?`border-shogun-gold/30 bg-shogun-gold/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(_,{className:`w-3.5 h-3.5 text-shogun-subdued`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`span`,{className:`text-xs font-semibold`,children:P(`profile.include_samurai`,`Include Samurai metrics`)}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:P(`profile.include_samurai_desc`,`Factor sub-agent data into the audit`)})]})]}),(0,x.jsx)(`div`,{className:v(`w-8 h-4 rounded-full relative transition-all duration-300`,f?`bg-shogun-gold`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:v(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,f?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})})]}),(0,x.jsxs)(`div`,{onClick:()=>te(!p),className:v(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all`,p?`border-shogun-blue/30 bg-shogun-blue/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(o,{className:`w-3.5 h-3.5 text-shogun-subdued`}),(0,x.jsx)(`span`,{className:`text-xs font-semibold`,children:P(`profile.dry_run`,`Dry run (preview only)`)})]}),(0,x.jsx)(`div`,{className:v(`w-8 h-4 rounded-full relative transition-all duration-300`,p?`bg-shogun-blue`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:v(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,p?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})})]}),(0,x.jsxs)(`div`,{onClick:()=>ne(!h),className:v(`flex items-center justify-between p-3 rounded-lg border cursor-pointer transition-all`,h?`border-green-500/30 bg-green-500/5`:`border-shogun-border hover:border-shogun-subdued`),children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(u,{className:`w-3.5 h-3.5 text-shogun-subdued`}),(0,x.jsx)(`span`,{className:`text-xs font-semibold`,children:P(`profile.auto_approve`,`Auto-approve results`)})]}),(0,x.jsx)(`div`,{className:v(`w-8 h-4 rounded-full relative transition-all duration-300`,h?`bg-green-500`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:v(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,h?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})})]})]}),(0,x.jsxs)(`button`,{onClick:async()=>{if(!M){if(!e.trim()){D({type:`error`,text:`Please provide a job name.`}),setTimeout(()=>D(null),3e3);return}if(i===`weekly`&&k.scheduleDays.length===0){D({type:`error`,text:`Select at least one day for a weekly schedule.`});return}if(i===`one-off`&&!k.scheduleDateTime){D({type:`error`,text:`Select a future date and time.`});return}if(n===`custom_task`&&!k.taskInstruction.trim()){D({type:`error`,text:`Custom tasks require an instruction.`});return}he(!0);try{D({type:`success`,text:`Creating "${e}"...`});let t={name:e,job_type:n,frequency:i,schedule_time:k.scheduleTime,schedule_days:i===`weekly`?k.scheduleDays:null,schedule_day:i===`monthly`?k.scheduleDay:null,minute_offset:i===`hourly`?k.minuteOffset:0,schedule_datetime:i===`one-off`?k.scheduleDateTime:null,scope:{agent_ids:[],memory_types:l},priority:s,all_agents:f,dry_run:p,auto_approve:h,task_instruction:n===`custom_task`?k.taskInstruction:null,is_enabled:!0};if(!(await y.post(`/api/v1/bushido/schedules`,t)).data?.meta?.scheduler_registered)throw Error(`The job was saved but not registered with the scheduler.`);await $(),D({type:`success`,text:`"${e}" created and scheduled.`}),A({name:``,type:`memory_consolidation`,frequency:`nightly`,scheduleTime:`02:00`,scheduleDays:[`mon`,`wed`,`fri`],scheduleDay:1,minuteOffset:0,scheduleDateTime:``,priority:50,memoryTypes:[`episodic`,`semantic`],taskInstruction:``,allAgents:!0,dryRun:!1,autoApprove:!1})}catch(e){D({type:`error`,text:S(e,e?.message||`Failed to create schedule.`)})}finally{he(!1),setTimeout(()=>D(null),6e3)}}},disabled:M,className:`w-full py-3 bg-gradient-to-r from-shogun-gold to-yellow-600 hover:from-yellow-600 hover:to-shogun-gold disabled:opacity-50 disabled:cursor-wait text-black font-bold rounded-lg transition-all shadow-shogun text-sm uppercase tracking-widest flex items-center justify-center gap-2`,children:[M?(0,x.jsx)(m,{className:`w-4 h-4 animate-spin`}):(0,x.jsx)(se,{className:`w-4 h-4`}),M?`Registering Job…`:P(`profile.create_schedule_btn`,`Create & Schedule Job`)]})]})]})})()]}),fe.filter(e=>!e.is_preset).length>0&&(0,x.jsxs)(`div`,{className:`md:col-span-2 shogun-card space-y-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(d,{className:`w-5 h-5 text-shogun-gold`}),` Operational Cadence — Scheduled Jobs & AgentFlows`]}),(0,x.jsxs)(`button`,{onClick:$,className:`text-[10px] font-bold text-shogun-subdued hover:text-shogun-gold transition-colors uppercase tracking-widest flex items-center gap-1`,children:[(0,x.jsx)(m,{className:`w-3 h-3`}),` `,P(`profile.refresh`,`Refresh`)]})]}),(0,x.jsx)(`div`,{className:`space-y-2`,children:fe.filter(e=>!e.is_preset).map(e=>(0,x.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-[#050508] border border-shogun-border rounded-xl hover:border-shogun-gold/20 transition-all`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,x.jsx)(`div`,{className:v(`w-2 h-2 rounded-full shrink-0`,e.is_enabled?`bg-green-400`:`bg-shogun-subdued`)}),(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`text-sm font-bold truncate`,children:e.name}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,x.jsx)(`span`,{className:v(`text-[8px] font-bold uppercase tracking-widest border px-1.5 py-0.5 rounded`,e.source===`agent_flow`?`text-purple-400 border-purple-500/30 bg-purple-500/10`:`text-shogun-blue border-shogun-blue/30 bg-shogun-blue/10`),children:e.source===`agent_flow`?`AgentFlow`:`Bushido`}),(0,x.jsx)(`span`,{className:`text-[9px] font-mono text-shogun-subdued uppercase tracking-wider`,children:e.job_type.replace(/_/g,` `)}),(0,x.jsx)(`span`,{className:`text-shogun-subdued/30`,children:`·`}),(0,x.jsxs)(`span`,{className:`text-[9px] font-mono text-shogun-gold/70 uppercase tracking-wider`,children:[e.frequency,e.schedule_time?` @ ${e.schedule_time}`:``]}),e.is_enabled&&!e.scheduler_registered&&(0,x.jsx)(`span`,{className:`text-[8px] font-bold text-red-400 uppercase tracking-widest bg-red-500/10 border border-red-500/20 px-1.5 py-0.5 rounded`,children:`Not registered`}),e.dry_run&&(0,x.jsx)(`span`,{className:`text-[8px] font-bold text-shogun-blue uppercase tracking-widest bg-shogun-blue/10 border border-shogun-blue/20 px-1.5 py-0.5 rounded`,children:`Dry Run`})]})]})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 ml-3`,children:[(0,x.jsx)(`button`,{disabled:me[`${e.source||`bushido`}-${e.id}`],onClick:async()=>{let t=`${e.source||`bushido`}-${e.id}`;j(e=>({...e,[t]:!0}));try{e.source===`agent_flow`?await y.post(`/api/v1/agent-flows/${e.id}/run`,{trigger_type:`manual`}):await y.post(`/api/v1/bushido/run`,{job_type:e.job_type,scope:e.scope||{agent_ids:[],memory_types:[]},trigger_mode:`manual`,priority:e.priority||50}),D({type:`success`,text:`"${e.name}" dispatched.`})}catch(e){D({type:`error`,text:S(e,`Failed to run scheduled job.`)})}finally{j(e=>({...e,[t]:!1})),setTimeout(()=>D(null),4e3)}},className:`text-[9px] font-bold uppercase text-shogun-blue hover:text-shogun-gold disabled:opacity-40 transition-colors`,children:me[`${e.source||`bushido`}-${e.id}`]?`Running…`:`Run now`}),(0,x.jsx)(`button`,{onClick:async()=>{try{e.source===`agent_flow`?await y.post(`/api/v1/agent-flows/${e.id}/${e.is_enabled?`pause`:`activate`}`):await y.patch(`/api/v1/bushido/schedules/${e.id}/toggle`),await $()}catch(e){D({type:`error`,text:S(e,`Failed to change schedule state.`)})}},className:v(`w-8 h-4 rounded-full relative transition-all duration-300 shrink-0`,e.is_enabled?`bg-shogun-gold`:`bg-shogun-card border border-shogun-border`),children:(0,x.jsx)(`div`,{className:v(`absolute top-0.5 w-3 h-3 rounded-full transition-all duration-300`,e.is_enabled?`left-4 bg-white`:`left-0.5 bg-shogun-subdued`)})}),e.source!==`agent_flow`&&(0,x.jsx)(`button`,{onClick:async()=>{try{await y.delete(`/api/v1/bushido/schedules/${e.id}`),await $()}catch(e){D({type:`error`,text:S(e,`Failed to delete schedule.`)})}},className:`text-shogun-subdued hover:text-red-400 transition-colors p-1`,title:`Delete schedule`,children:(0,x.jsx)(oe,{className:`w-3.5 h-3.5`})})]})]},`${e.source||`bushido`}-${e.id}`))})]}),(0,x.jsxs)(`div`,{className:`shogun-card space-y-4 md:col-span-2 mt-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,x.jsxs)(`h3`,{className:`text-lg font-bold flex items-center gap-2 text-shogun-text`,children:[(0,x.jsx)(ee,{className:`w-5 h-5 text-orange-500`}),` `,P(`profile.ronin_desktop`,`Ronin Desktop Control`)]}),(0,x.jsx)(`button`,{onClick:async()=>{try{let e=await y.get(`/api/v1/setup/ronin-check`);I(t=>({...t,_roninCheck:e.data.data}))}catch{}},className:`text-[10px] font-bold text-shogun-blue hover:text-shogun-gold uppercase tracking-widest transition-colors`,children:P(`common.refresh`,`Refresh`)})]}),(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:`Ronin gives Shogun desktop automation capabilities: screenshots, mouse control, and keyboard input. Install the dependencies here if you skipped this during setup.`}),!F._roninCheck&&(y.get(`/api/v1/setup/ronin-check`).then(e=>{I(t=>({...t,_roninCheck:e.data.data}))}).catch(()=>{}),null),F._roninCheck&&(()=>{let e=F._roninCheck;return(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:Object.entries(e.deps||{}).map(([t,n])=>{let r=e[`_installing_${t}`];return(0,x.jsxs)(`button`,{disabled:n.installed||r,onClick:async()=>{if(!n.installed){I(e=>({...e,_roninCheck:{...e._roninCheck,[`_installing_${t}`]:!0}}));try{let e=await y.post(`/api/v1/setup/ronin-install-dep`,{dep_name:t});if(e.data.data?.status===`success`){D({type:`success`,text:`${t} installed successfully!`});let e=await y.get(`/api/v1/setup/ronin-check`);I(t=>({...t,_roninCheck:e.data.data}))}else D({type:`error`,text:e.data.data?.message||`Failed to install ${t}`}),I(e=>({...e,_roninCheck:{...e._roninCheck,[`_installing_${t}`]:!1}}))}catch{D({type:`error`,text:`Failed to install ${t}`}),I(e=>({...e,_roninCheck:{...e._roninCheck,[`_installing_${t}`]:!1}}))}}},className:v(`flex items-center gap-2 p-2.5 rounded-lg border text-left transition-all`,n.installed?`bg-green-500/5 border-green-500/20`:r?`bg-orange-500/5 border-orange-500/20 animate-pulse`:`bg-red-500/5 border-red-500/20 hover:border-orange-500/50 hover:bg-orange-500/5 cursor-pointer`,(n.installed||r)&&`cursor-default`),children:[r?(0,x.jsx)(`div`,{className:`w-3.5 h-3.5 border-2 border-orange-500 border-t-transparent rounded-full animate-spin shrink-0`}):n.installed?(0,x.jsx)(u,{className:`w-3.5 h-3.5 text-green-500 shrink-0`}):(0,x.jsx)(l,{className:`w-3.5 h-3.5 text-red-400 shrink-0`}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:t}),(0,x.jsx)(`p`,{className:`text-[9px] text-shogun-subdued`,children:r?`Installing...`:n.installed?`v${n.version}`:`Click to install`})]})]},t)})}),(0,x.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,x.jsxs)(`div`,{className:`bg-[#0a0e1a] border border-shogun-border rounded-lg px-3 py-1.5`,children:[(0,x.jsx)(`span`,{className:`text-[9px] text-shogun-subdued uppercase tracking-widest font-bold`,children:`OS: `}),(0,x.jsx)(`span`,{className:`text-xs font-bold text-shogun-text`,children:e.os}),e.display_server&&(0,x.jsxs)(`span`,{className:`text-xs text-shogun-subdued ml-2`,children:[`(`,e.display_server,`)`]})]}),(0,x.jsx)(`span`,{className:v(`text-[9px] font-bold px-2 py-0.5 rounded border uppercase`,e.all_core_installed?`text-green-500 border-green-500/30`:`text-orange-400 border-orange-400/30`),children:e.all_core_installed?`Ready`:`Install Required`})]}),!e.all_core_installed&&(0,x.jsx)(`button`,{onClick:async()=>{I(e=>({...e,_roninInstalling:!0}));try{let e=await y.post(`/api/v1/setup/ronin-install`);if(e.data.data?.status===`success`){D({type:`success`,text:`Ronin dependencies installed successfully!`});let e=await y.get(`/api/v1/setup/ronin-check`);I(t=>({...t,_roninCheck:e.data.data,_roninInstalling:!1}))}else D({type:`error`,text:e.data.data?.message||`Installation failed.`}),I(e=>({...e,_roninInstalling:!1}))}catch{D({type:`error`,text:`Failed to install Ronin dependencies.`}),I(e=>({...e,_roninInstalling:!1}))}},disabled:F._roninInstalling,className:`w-full py-2.5 rounded-lg bg-orange-500 hover:bg-orange-500/80 text-black font-bold text-sm transition-all disabled:opacity-50 flex items-center justify-center gap-2`,children:F._roninInstalling?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`w-4 h-4 border-2 border-black border-t-transparent rounded-full animate-spin`}),` Installing...`]}):(0,x.jsx)(x.Fragment,{children:`Install Ronin Dependencies`})}),e.notes?.length>0&&(0,x.jsx)(`div`,{className:`bg-orange-500/5 border border-orange-500/20 rounded-lg p-3 space-y-1`,children:e.notes.map((e,t)=>(0,x.jsx)(`p`,{className:`text-[10px] text-shogun-subdued leading-relaxed`,children:e},t))})]})})()]})]})]})]})};export{w as ShogunProfile}; \ No newline at end of file diff --git a/frontend/dist/assets/ToolGate-9LzJ66OY.js b/frontend/dist/assets/ToolGate-9LzJ66OY.js new file mode 100644 index 0000000..f693b93 --- /dev/null +++ b/frontend/dist/assets/ToolGate-9LzJ66OY.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chevron-right-CVeYaFvJ.js";import{t as n}from"./circle-check-DBu5bzEI.js";import{t as r}from"./plus-Cxx0HjpF.js";import{t as i}from"./refresh-cw-Dm6S5UAJ.js";import{t as a}from"./save-CupVJLfi.js";import{t as ee}from"./search-DuRUeriq.js";import{t as te}from"./sliders-horizontal-C0TTejMz.js";import{t as ne}from"./trash-2-DqRUHXwV.js";import{t as re}from"./wifi-off-DW4KpTMj.js";import{O as ie,S as ae,T as o,a as oe,c as se,d as s,g as c,h as l,i as u,j as d,t as f}from"./index-Dy1E248t.js";import{t as p}from"./axios-BGmZl9Qd.js";var ce=o(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),le=o(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),ue=o(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),m=e(d(),1),h=f(),g={allow:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`,confirm:`border-amber-500/30 bg-amber-500/10 text-amber-300`,block:`border-red-500/30 bg-red-500/10 text-red-300`},_={low:`text-emerald-400`,medium:`text-cyan-400`,high:`text-amber-400`,critical:`text-red-400`},v={filesystem:{mode:`scoped`,allowed_paths:[],allow_home_access:!1,allow_arbitrary_paths:!1},network:{mode:`allowlist`,allowed_domains:[],allow_arbitrary_requests:!1},shell:{enabled:!1,allowed_binaries:[]},skills:{allow_auto_install:!1,require_approval:!0,allow_untrusted:!1},subagents:{allow_spawn:!0,max_active:5,allow_auto_spawn:!1},memory:{allow_write:!0,allow_bulk_delete:!1},comms:{allow_read_email:!0,allow_send_email:!0,allow_read_calendar:!0,allow_create_events:!0,allow_list_cron:!0,allow_manage_cron:!1},mado_browser:{},agentflow:{},flow_stack:{},visual_intake:{},ide_mode:{}},y=(e=structuredClone(v))=>({id:null,name:``,tier:`tactical`,description:``,permissions:e,kill_switch_enabled:!0,dry_run_supported:!0});function b({action:e}){return(0,h.jsx)(`span`,{className:u(`inline-flex min-w-20 justify-center rounded-md border px-2 py-1 text-[10px] font-bold uppercase tracking-widest`,g[e]),children:e})}function de(e){if(!e)return`No policy sync recorded`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function x(e,t){return p.isAxiosError(e)?e.response?.data?.detail||e.message||t:e instanceof Error?e.message:t}function S(){let e=ie(),[o,d]=(0,m.useState)(null),[f,S]=(0,m.useState)([]),[fe,pe]=(0,m.useState)([]),[me,he]=(0,m.useState)(!0),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(null),[D,ge]=(0,m.useState)(``),[O,_e]=(0,m.useState)(`all`),[k,ve]=(0,m.useState)(`all`),[A,ye]=(0,m.useState)(``),[be,xe]=(0,m.useState)(`{}`),[j,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(null),[F,I]=(0,m.useState)({}),[L,R]=(0,m.useState)(!1),[z,B]=(0,m.useState)({enabled:!1,rules:[]}),[V,H]=(0,m.useState)(!1),[Se,U]=(0,m.useState)(!1),[W,G]=(0,m.useState)(y),[K,q]=(0,m.useState)(!1),J=async()=>{he(!0);try{let[e,t]=await Promise.all([p.get(`/api/v1/security/toolgate`),p.get(`/api/v1/security/policies`)]),n=e.data.data,r={...n,scope:n.scope||{key:`tier:${n.active_tier||`tactical`}`,kind:`tier`,label:(n.active_tier||`tactical`).toUpperCase(),base_tier:n.active_tier||`tactical`,policy_id:null},capabilities:n.capabilities||{permissions:{},risk_score:0,editable:!1,source:`builtin_tier`},advanced_controls:n.advanced_controls||{enabled:!1,rules:[],editable:n.authority?.editable??!0,source:n.authority?.mode===`gensui`?`gensui`:`local`}};d(r);let i=t.data.data||[];S(i.filter(e=>!e.is_builtin)),pe(i.filter(e=>e.is_builtin)),I(r.capabilities.permissions||{}),B({enabled:r.advanced_controls.enabled,rules:r.advanced_controls.rules||[]}),ye(e=>e||n.tools[0]?.name||``)}catch{E({type:`error`,text:`ToolGate status could not be loaded.`})}finally{he(!1)}};(0,m.useEffect)(()=>{J()},[]);let Ce=(0,m.useMemo)(()=>Array.from(new Set(o?.tools.map(e=>e.category)||[])).sort(),[o]),we=(0,m.useMemo)(()=>{let e=D.trim().toLowerCase();return(o?.tools||[]).filter(t=>(!e||t.name.toLowerCase().includes(e)||t.category.toLowerCase().includes(e))&&(O===`all`||t.category===O)&&(k===`all`||t.effective_action===k))},[o,D,O,k]),Y=(0,m.useMemo)(()=>({allow:o?.tools.filter(e=>e.effective_action===`allow`).length||0,confirm:o?.tools.filter(e=>e.effective_action===`confirm`).length||0,block:o?.tools.filter(e=>e.effective_action===`block`).length||0}),[o]),Te=async(e,t)=>{if(!o?.authority.editable)return;w(e),E(null);let n={...o.local_overrides};t==="default"?delete n[e]:n[e]=t;try{await p.put(`/api/v1/security/toolgate/overrides`,{overrides:n}),E({type:`success`,text:`ToolGate rule updated for ${e}.`}),await J()}catch(e){E({type:`error`,text:x(e,`ToolGate rule could not be saved.`)})}finally{w(null)}},Ee=async()=>{M(!0),P(null),E(null);try{let e=JSON.parse(be);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`Arguments must be a JSON object.`);let t=await p.post(`/api/v1/security/toolgate/simulate`,{tool_name:A,args:e});P(t.data.data)}catch(e){E({type:`error`,text:x(e,`Simulation failed.`)})}finally{M(!1)}},X=(e,t,n)=>{I(r=>({...r,[e]:{...r[e]||{},[t]:n}}))},De=async()=>{if(o){R(!0),E(null);try{await p.put(`/api/v1/security/toolgate/capabilities`,{permissions:F}),E({type:`success`,text:`Capability boundaries saved for ${o.scope.label}.`}),await J()}catch(e){E({type:`error`,text:x(e,`Capability boundaries could not be saved.`)})}finally{R(!1)}}},Oe=()=>{B(e=>({...e,enabled:!0,rules:[...e.rules,{id:`rule-${Date.now()}`,label:``,pattern:``,match_type:`contains`,action:`confirm`,tools:[],case_sensitive:!1,enabled:!0}]}))},Z=(e,t)=>{B(n=>({...n,rules:n.rules.map(n=>n.id===e?{...n,...t}:n)}))},ke=async()=>{if(o){H(!0),E(null);try{await p.put(`/api/v1/security/toolgate/advanced`,z),E({type:`success`,text:`Advanced controls saved for ${o.scope.label}.`}),await J()}catch(e){E({type:`error`,text:x(e,`Advanced ToolGate controls could not be saved.`)})}finally{H(!1)}}},Ae=()=>{G(y(je(`tactical`))),U(!0)},je=e=>{let t=structuredClone(v),n=fe.find(t=>t.tier===e);return Object.entries(n?.permissions||{}).forEach(([e,n])=>{t[e]={...t[e]||{},...n||{}}}),t},Me=e=>{let t=je(e.tier);Object.entries(e.permissions||{}).forEach(([e,n])=>{t[e]={...t[e]||{},...n||{}}}),G({id:e.id,name:e.name,tier:e.tier,description:e.description||``,permissions:t,kill_switch_enabled:e.kill_switch_enabled,dry_run_supported:e.dry_run_supported}),U(!0)},Q=(e,t,n)=>{G(r=>({...r,permissions:{...r.permissions,[e]:{...r.permissions[e]||{},[t]:n}}}))},Ne=async e=>{if(e.preventDefault(),!o||!o.authority.editable||!W.name.trim())return;q(!0),E(null);let t={name:W.name.trim(),tier:W.tier,description:W.description.trim(),permissions:W.permissions,kill_switch_enabled:W.kill_switch_enabled,dry_run_supported:W.dry_run_supported};try{W.id?(await p.patch(`/api/v1/security/policies/${W.id}`,t),E({type:`success`,text:`${t.name} was updated.`})):(await p.post(`/api/v1/security/policies`,t),E({type:`success`,text:`${t.name} was created and is now available in Torii.`})),U(!1),await J()}catch(e){E({type:`error`,text:x(e,`Custom posture could not be saved.`)})}finally{q(!1)}},Pe=async e=>{if(!o||!o.authority.editable||!confirm(`Delete custom posture "${e.name}"?`))return;let t=o.scope.policy_id===e.id;E(null);try{await p.delete(`/api/v1/security/policies/${e.id}`),E({type:`success`,text:`${e.name} was deleted.${t?` Torii returned to its ${e.tier.toUpperCase()} base tier.`:``}`}),await J()}catch(e){E({type:`error`,text:x(e,`Custom posture could not be deleted.`)})}};if(me&&!o)return(0,h.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,h.jsx)(c,{className:`h-8 w-8 animate-spin text-shogun-gold`})});if(!o)return null;let $=o.authority.mode===`gensui`;return(0,h.jsxs)(`div`,{className:`mx-auto max-w-7xl space-y-6 pb-14 animate-in fade-in duration-500`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-start`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`h1`,{className:`shogun-title text-3xl font-bold`,children:`ToolGate`}),(0,h.jsx)(`span`,{className:`rounded border border-shogun-border bg-shogun-card px-2 py-1 text-[9px] uppercase tracking-[0.22em] text-shogun-subdued`,children:`Runtime permissions`})]}),(0,h.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-relaxed text-shogun-subdued`,children:`The enforcement layer between model intent and tool execution. Inspect the effective verdict, require human approval, or block individual capabilities.`})]}),(0,h.jsx)(`button`,{onClick:J,className:`self-start rounded-lg border border-shogun-border bg-shogun-card p-2.5 text-shogun-subdued transition-colors hover:text-shogun-gold`,title:`Refresh ToolGate`,children:(0,h.jsx)(i,{className:u(`h-4 w-4`,me&&`animate-spin`)})})]}),(0,h.jsx)(`div`,{className:u(`rounded-xl border p-4`,$?o.authority.connected?`border-indigo-400/25 bg-indigo-500/[0.07]`:`border-amber-400/30 bg-amber-500/[0.07]`:`border-emerald-400/25 bg-emerald-500/[0.06]`),children:(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-center`,children:[(0,h.jsxs)(`div`,{className:`flex gap-3`,children:[$?o.authority.connected?(0,h.jsx)(s,{className:`mt-0.5 h-5 w-5 text-indigo-300`}):(0,h.jsx)(re,{className:`mt-0.5 h-5 w-5 text-amber-300`}):(0,h.jsx)(te,{className:`mt-0.5 h-5 w-5 text-emerald-300`}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`text-sm font-bold text-shogun-text`,children:$?o.authority.connected?`Managed by Gensui`:`Managed by Gensui — connection offline`:`Standalone authority`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-shogun-subdued`,children:$?`This view is read-only. The last known central policy remains enforced. ${de(o.authority.last_sync_at)}.`:`Overrides are saved only for ${o.scope.label}. Switching tier or custom policy loads that scope's own ToolGate rules.`})]})]}),$&&(0,h.jsxs)(`button`,{onClick:()=>e(`/gensui`),className:`flex items-center gap-2 self-start rounded-lg border border-indigo-400/25 bg-indigo-500/10 px-3 py-2 text-xs font-bold text-indigo-200 hover:bg-indigo-500/20`,children:[`View Gensui connection `,(0,h.jsx)(t,{className:`h-3.5 w-3.5`})]})]})}),T&&(0,h.jsxs)(`div`,{className:u(`flex items-center gap-2 rounded-lg border px-4 py-3 text-sm`,T.type===`success`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-200`:`border-red-500/25 bg-red-500/10 text-red-200`),children:[T.type===`success`?(0,h.jsx)(n,{className:`h-4 w-4`}):(0,h.jsx)(se,{className:`h-4 w-4`}),T.text]}),(0,h.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-start`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(s,{className:`h-4 w-4 text-violet-300`}),(0,h.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Custom posture library`})]}),(0,h.jsx)(`p`,{className:`mt-1 max-w-3xl text-xs leading-relaxed text-shogun-subdued`,children:`Create and maintain reusable security postures here. Torii remains the single place where a built-in or custom posture is activated.`})]}),(0,h.jsxs)(`button`,{type:`button`,disabled:!o.authority.editable,onClick:Ae,className:`flex items-center gap-2 self-start rounded-lg border border-violet-400/30 bg-violet-500/10 px-3 py-2 text-xs font-bold text-violet-200 hover:bg-violet-500/20 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,h.jsx)(r,{className:`h-4 w-4`}),` Create custom posture`]})]}),$&&(0,h.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-indigo-400/20 bg-indigo-500/[0.05] p-3`,children:[(0,h.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-indigo-300`}),(0,h.jsx)(`p`,{className:`text-xs leading-relaxed text-indigo-100/75`,children:`Custom posture lifecycle is centrally owned by Gensui while this Tenshu is enrolled.`})]}),f.length===0?(0,h.jsxs)(`div`,{className:`rounded-lg border border-dashed border-shogun-border p-6 text-center`,children:[(0,h.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:`No custom postures yet`}),(0,h.jsx)(`p`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:`Create one here; it will immediately appear in Torii's posture selector.`})]}):(0,h.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:f.map(e=>{let t=o.scope.policy_id===e.id;return(0,h.jsxs)(`div`,{className:u(`rounded-lg border p-4`,t?`border-violet-400/45 bg-violet-500/[0.07]`:`border-shogun-border/70 bg-shogun-bg/45`),children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`p`,{className:`truncate text-sm font-bold text-shogun-text`,children:e.name}),t&&(0,h.jsx)(`span`,{className:`rounded border border-emerald-400/25 bg-emerald-500/10 px-1.5 py-0.5 text-[8px] font-bold uppercase text-emerald-300`,children:`Active`})]}),(0,h.jsxs)(`p`,{className:`mt-1 text-[9px] font-bold uppercase tracking-widest text-violet-300`,children:[`Base `,e.tier]})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:!o.authority.editable,onClick:()=>Me(e),className:`rounded border border-shogun-border p-2 text-shogun-subdued hover:border-violet-400/30 hover:text-violet-200 disabled:opacity-40`,title:`Edit custom posture`,children:(0,h.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,h.jsx)(`button`,{type:`button`,disabled:!o.authority.editable,onClick:()=>Pe(e),className:`rounded border border-red-500/15 p-2 text-red-300/70 hover:bg-red-500/10 hover:text-red-300 disabled:opacity-40`,title:`Delete custom posture`,children:(0,h.jsx)(ne,{className:`h-3.5 w-3.5`})})]})]}),(0,h.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-8 text-[10px] leading-relaxed text-shogun-subdued`,children:e.description||`No description`}),(0,h.jsxs)(`div`,{className:`mt-3 flex gap-2 text-[9px] uppercase tracking-wider text-shogun-subdued`,children:[(0,h.jsxs)(`span`,{children:[Object.keys(e.permissions||{}).length,` capability groups`]}),(0,h.jsx)(`span`,{children:`·`}),(0,h.jsx)(`span`,{children:e.kill_switch_enabled?`Kill switch`:`No kill switch`})]})]},e.id)})})]}),(0,h.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-5`,children:[{label:o.scope.kind===`custom_policy`?`Custom tier`:`Active tier`,value:o.scope.label,color:`text-shogun-gold`},{label:`Allow`,value:Y.allow,color:`text-emerald-400`},{label:`Confirm`,value:Y.confirm,color:`text-amber-400`},{label:`Block`,value:Y.block,color:`text-red-400`},{label:`Pending approval`,value:o.pending_confirmations.length,color:`text-indigo-300`}].map(e=>(0,h.jsxs)(`div`,{className:`shogun-card`,children:[(0,h.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:e.label}),(0,h.jsx)(`p`,{className:u(`mt-2 text-2xl font-bold`,e.color),children:e.value})]},e.label))}),(0,h.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 lg:flex-row lg:items-start`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(s,{className:`h-4 w-4 text-shogun-gold`}),(0,h.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Capability boundaries`})]}),(0,h.jsx)(`p`,{className:`mt-1 max-w-3xl text-xs leading-relaxed text-shogun-subdued`,children:`The policy ceiling for filesystem, network, applications, workflows, memory, and delegation. Runtime tool verdicts below can only narrow these capabilities.`})]}),(0,h.jsxs)(`div`,{className:`min-w-56 rounded-lg border border-shogun-border bg-shogun-bg/70 p-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:[(0,h.jsx)(`span`,{children:`Capability Risk Index`}),(0,h.jsxs)(`span`,{className:u(o.capabilities.risk_score<=25?`text-emerald-400`:o.capabilities.risk_score<=50?`text-shogun-gold`:o.capabilities.risk_score<=75?`text-orange-400`:`text-red-400`),children:[o.capabilities.risk_score,`/100`]})]}),(0,h.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-black/40`,children:(0,h.jsx)(`div`,{className:u(`h-full rounded-full transition-all`,o.capabilities.risk_score<=25?`bg-emerald-400`:o.capabilities.risk_score<=50?`bg-shogun-gold`:o.capabilities.risk_score<=75?`bg-orange-400`:`bg-red-500`),style:{width:`${o.capabilities.risk_score}%`}})})]})]}),!o.capabilities.editable&&(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-lg border border-amber-400/20 bg-amber-500/[0.05] p-3`,children:[(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-300`}),(0,h.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-100/75`,children:$?`Capability boundaries are centrally owned by Gensui.`:`Built-in tiers are protected presets. Create or edit custom postures in the library above; activate one in Torii to inspect it here.`})]}),!$&&(0,h.jsx)(`button`,{onClick:()=>e(`/torii`),className:`shrink-0 text-xs font-bold text-shogun-gold hover:text-white`,children:`Select in Torii`})]}),(0,h.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Object.entries(F).map(([e,t])=>(0,h.jsxs)(`div`,{className:`rounded-lg border border-shogun-border/70 bg-shogun-bg/45 p-3`,children:[(0,h.jsx)(`p`,{className:`mb-3 text-[10px] font-bold uppercase tracking-[0.18em] text-shogun-gold`,children:e.replace(/_/g,` `)}),(0,h.jsx)(`div`,{className:`space-y-2`,children:Object.entries(t||{}).map(([t,n])=>(0,h.jsxs)(`label`,{className:`flex min-h-8 items-center justify-between gap-3 text-[10px] text-shogun-subdued`,children:[(0,h.jsx)(`span`,{className:`capitalize`,children:t.replace(/_/g,` `)}),typeof n==`boolean`?(0,h.jsx)(`button`,{type:`button`,disabled:!o.capabilities.editable,onClick:()=>X(e,t,!n),className:u(`relative h-5 w-10 rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-55`,n?`border-emerald-500/40 bg-emerald-500/20`:`border-red-500/30 bg-red-500/10`),children:(0,h.jsx)(`span`,{className:u(`absolute top-0.5 h-4 w-4 rounded-full transition-all`,n?`left-5 bg-emerald-400`:`left-0.5 bg-red-400`)})}):typeof n==`number`?(0,h.jsx)(`input`,{type:`number`,disabled:!o.capabilities.editable,value:n,onChange:n=>X(e,t,Number(n.target.value)),className:`w-20 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text disabled:opacity-55`}):Array.isArray(n)?(0,h.jsx)(`input`,{disabled:!o.capabilities.editable,value:n.join(`, `),onChange:n=>X(e,t,n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),placeholder:`Comma-separated`,className:`w-44 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text disabled:opacity-55`}):t===`mode`?(0,h.jsx)(`select`,{disabled:!o.capabilities.editable,value:String(n),onChange:n=>X(e,t,n.target.value),className:`rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-[10px] uppercase text-shogun-text disabled:opacity-55`,children:[`full`,`scoped`,`allowlist`,`disabled`].map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))}):(0,h.jsx)(`input`,{disabled:!o.capabilities.editable,value:String(n??``),onChange:n=>X(e,t,n.target.value),className:`w-36 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text disabled:opacity-55`})]},t))})]},e))}),o.capabilities.editable&&(0,h.jsx)(`div`,{className:`flex justify-end`,children:(0,h.jsxs)(`button`,{onClick:De,disabled:L,className:`flex items-center gap-2 rounded-lg bg-shogun-gold px-4 py-2.5 text-xs font-bold text-black disabled:opacity-50`,children:[L?(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(a,{className:`h-4 w-4`}),`Save capability boundaries`]})})]}),(0,h.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-center`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(te,{className:`h-4 w-4 text-orange-400`}),(0,h.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Advanced controls`}),(0,h.jsx)(`span`,{className:`rounded border border-orange-400/20 bg-orange-500/10 px-2 py-1 text-[9px] font-bold uppercase tracking-widest text-orange-300`,children:`Content-aware`})]}),(0,h.jsx)(`p`,{className:`mt-1 max-w-3xl text-xs leading-relaxed text-shogun-subdued`,children:`Flag words or phrases inside tool arguments and require confirmation or block the call. Rules can apply globally or only to one tool and never weaken a stricter safety decision.`})]}),(0,h.jsxs)(`button`,{type:`button`,disabled:!o.advanced_controls.editable,onClick:()=>B(e=>({...e,enabled:!e.enabled})),className:u(`flex items-center gap-3 rounded-lg border px-3 py-2 text-xs font-bold transition-colors disabled:cursor-not-allowed disabled:opacity-55`,z.enabled?`border-orange-400/35 bg-orange-500/10 text-orange-200`:`border-shogun-border bg-shogun-bg text-shogun-subdued`),children:[(0,h.jsx)(`span`,{className:u(`relative h-5 w-10 rounded-full border`,z.enabled?`border-orange-400/40 bg-orange-500/20`:`border-shogun-border bg-black/30`),children:(0,h.jsx)(`span`,{className:u(`absolute top-0.5 h-4 w-4 rounded-full transition-all`,z.enabled?`left-5 bg-orange-300`:`left-0.5 bg-shogun-subdued`)})}),`Advanced mode `,z.enabled?`on`:`off`]})]}),!o.advanced_controls.editable&&(0,h.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-indigo-400/20 bg-indigo-500/[0.05] p-3`,children:[(0,h.jsx)(l,{className:`mt-0.5 h-4 w-4 shrink-0 text-indigo-300`}),(0,h.jsx)(`p`,{className:`text-xs leading-relaxed text-indigo-100/75`,children:`These content rules are centrally owned by Gensui and remain enforced from the cached policy if the connection is temporarily unavailable.`})]}),(0,h.jsxs)(`div`,{className:`space-y-3`,children:[z.rules.map((e,t)=>(0,h.jsxs)(`div`,{className:`rounded-lg border border-shogun-border/70 bg-shogun-bg/45 p-4`,children:[(0,h.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(150px,0.8fr)_minmax(220px,1.4fr)_130px_130px_minmax(180px,1fr)_auto] xl:items-end`,children:[(0,h.jsxs)(`label`,{className:`space-y-1`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Rule label`}),(0,h.jsx)(`input`,{disabled:!o.advanced_controls.editable,value:e.label,onChange:t=>Z(e.id,{label:t.target.value}),placeholder:`Rule ${t+1}`,maxLength:120,className:`w-full rounded border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text disabled:opacity-55`})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Word or phrase`}),(0,h.jsx)(`input`,{disabled:!o.advanced_controls.editable,value:e.pattern,onChange:t=>Z(e.id,{pattern:t.target.value}),placeholder:`e.g. confidential`,maxLength:200,className:`w-full rounded border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-xs text-shogun-text disabled:opacity-55`})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Match`}),(0,h.jsxs)(`select`,{disabled:!o.advanced_controls.editable,value:e.match_type,onChange:t=>Z(e.id,{match_type:t.target.value}),className:`w-full rounded border border-shogun-border bg-shogun-bg px-2 py-2 text-xs text-shogun-text disabled:opacity-55`,children:[(0,h.jsx)(`option`,{value:`contains`,children:`Contains`}),(0,h.jsx)(`option`,{value:`word`,children:`Whole word`})]})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Verdict`}),(0,h.jsxs)(`select`,{disabled:!o.advanced_controls.editable,value:e.action,onChange:t=>Z(e.id,{action:t.target.value}),className:u(`w-full rounded border px-2 py-2 text-xs font-bold uppercase disabled:opacity-55`,g[e.action]),children:[(0,h.jsx)(`option`,{value:`confirm`,children:`Confirm`}),(0,h.jsx)(`option`,{value:`block`,children:`Block`})]})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Applies to`}),(0,h.jsxs)(`select`,{disabled:!o.advanced_controls.editable,value:e.tools[0]||`*`,onChange:t=>Z(e.id,{tools:t.target.value===`*`?[]:[t.target.value]}),className:`w-full rounded border border-shogun-border bg-shogun-bg px-2 py-2 font-mono text-xs text-shogun-text disabled:opacity-55`,children:[(0,h.jsx)(`option`,{value:`*`,children:`All tools`}),o.tools.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,h.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:!o.advanced_controls.editable,onClick:()=>Z(e.id,{enabled:!e.enabled}),className:u(`rounded border px-2.5 py-2 text-[9px] font-bold uppercase disabled:opacity-55`,e.enabled?`border-emerald-500/25 text-emerald-300`:`border-shogun-border text-shogun-subdued`),children:e.enabled?`Active`:`Paused`}),(0,h.jsx)(`button`,{type:`button`,disabled:!o.advanced_controls.editable,onClick:()=>B(t=>({...t,rules:t.rules.filter(t=>t.id!==e.id)})),className:`rounded border border-red-500/20 p-2 text-red-300 hover:bg-red-500/10 disabled:opacity-55`,title:`Remove rule`,children:(0,h.jsx)(ne,{className:`h-3.5 w-3.5`})})]})]}),(0,h.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-[10px] text-shogun-subdued`,children:[(0,h.jsx)(`input`,{type:`checkbox`,disabled:!o.advanced_controls.editable,checked:e.case_sensitive,onChange:t=>Z(e.id,{case_sensitive:t.target.checked})}),`Case-sensitive match`]})]},e.id)),z.rules.length===0&&(0,h.jsx)(`div`,{className:`rounded-lg border border-dashed border-shogun-border p-6 text-center text-xs text-shogun-subdued`,children:`No advanced content rules are defined for this policy.`})]}),o.advanced_controls.editable&&(0,h.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-3`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:Oe,className:`flex items-center gap-2 rounded-lg border border-orange-400/25 px-3 py-2 text-xs font-bold text-orange-300 hover:bg-orange-500/10`,children:[(0,h.jsx)(r,{className:`h-4 w-4`}),` Add content rule`]}),(0,h.jsxs)(`button`,{type:`button`,onClick:ke,disabled:V||z.rules.some(e=>!e.pattern.trim()),className:`flex items-center gap-2 rounded-lg bg-orange-400 px-4 py-2.5 text-xs font-bold text-black disabled:opacity-50`,children:[V?(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(a,{className:`h-4 w-4`}),`Save advanced controls`]})]})]}),(0,h.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col justify-between gap-3 lg:flex-row lg:items-center`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Effective tool policy`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:o.scope.kind===`custom_policy`?`${o.scope.label} inherits ${o.scope.base_tier.toUpperCase()} thresholds; its ToolGate overrides remain isolated from every other tier.`:`Default ${o.scope.base_tier.toUpperCase()} thresholds plus local, Campaign, Gensui, and parameter-aware restrictions.`})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsxs)(`label`,{className:`relative`,children:[(0,h.jsx)(ee,{className:`absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-shogun-subdued`}),(0,h.jsx)(`input`,{value:D,onChange:e=>ge(e.target.value),placeholder:`Search tools…`,className:`w-52 rounded-lg border border-shogun-border bg-shogun-bg py-2 pl-9 pr-3 text-xs text-shogun-text outline-none focus:border-shogun-blue`})]}),(0,h.jsxs)(`select`,{value:O,onChange:e=>_e(e.target.value),className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text`,children:[(0,h.jsx)(`option`,{value:`all`,children:`All categories`}),Ce.map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))]}),(0,h.jsxs)(`select`,{value:k,onChange:e=>ve(e.target.value),className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text`,children:[(0,h.jsx)(`option`,{value:`all`,children:`All verdicts`}),(0,h.jsx)(`option`,{value:`allow`,children:`Allow`}),(0,h.jsx)(`option`,{value:`confirm`,children:`Confirm`}),(0,h.jsx)(`option`,{value:`block`,children:`Block`})]})]})]}),(0,h.jsxs)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border/70`,children:[(0,h.jsxs)(`table`,{className:`w-full min-w-[920px] text-left`,children:[(0,h.jsx)(`thead`,{className:`bg-[#080b12] text-[9px] uppercase tracking-widest text-shogun-subdued`,children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{className:`px-4 py-3`,children:`Tool`}),(0,h.jsx)(`th`,{className:`px-4 py-3`,children:`Risk`}),(0,h.jsx)(`th`,{className:`px-4 py-3`,children:`Effective`}),(0,h.jsx)(`th`,{className:`px-4 py-3`,children:`Policy layers`}),(0,h.jsx)(`th`,{className:`px-4 py-3`,children:`Standalone override`})]})}),(0,h.jsx)(`tbody`,{className:`divide-y divide-shogun-border/60`,children:we.map(e=>(0,h.jsxs)(`tr`,{className:`bg-shogun-card/20 hover:bg-shogun-card/50`,children:[(0,h.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,h.jsx)(`p`,{className:`font-mono text-xs font-semibold text-shogun-text`,children:e.name}),(0,h.jsx)(`p`,{className:`mt-1 text-[9px] uppercase tracking-widest text-shogun-subdued`,children:e.category})]}),(0,h.jsx)(`td`,{className:u(`px-4 py-3 text-[10px] font-bold uppercase tracking-wider`,_[e.risk]),children:e.risk}),(0,h.jsx)(`td`,{className:`px-4 py-3`,children:(0,h.jsx)(b,{action:e.effective_action})}),(0,h.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[e.gensui_override&&(0,h.jsxs)(`span`,{className:`rounded bg-indigo-500/10 px-2 py-1 text-[9px] text-indigo-300`,children:[`Gensui: `,e.gensui_override]}),e.campaign_override&&(0,h.jsxs)(`span`,{className:`rounded bg-orange-500/10 px-2 py-1 text-[9px] text-orange-300`,children:[`Campaign: `,e.campaign_override]}),e.local_override&&(0,h.jsxs)(`span`,{className:`rounded bg-cyan-500/10 px-2 py-1 text-[9px] text-cyan-300`,children:[`Local: `,e.local_override]}),!e.gensui_override&&!e.campaign_override&&!e.local_override&&(0,h.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[`Mode default: `,e.default_action]})]}),(0,h.jsx)(`p`,{className:`mt-1.5 max-w-xl truncate text-[9px] text-shogun-subdued`,title:e.reason,children:e.reason})]}),(0,h.jsx)(`td`,{className:`px-4 py-3`,children:(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsxs)(`select`,{value:e.local_override||`default`,disabled:!o.authority.editable||C===e.name,onChange:t=>Te(e.name,t.target.value),className:`w-32 rounded-lg border border-shogun-border bg-shogun-bg px-2 py-2 text-xs text-shogun-text disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,h.jsx)(`option`,{value:`default`,children:`Use default`}),(0,h.jsx)(`option`,{value:`allow`,children:`Allow`}),(0,h.jsx)(`option`,{value:`confirm`,children:`Confirm`}),(0,h.jsx)(`option`,{value:`block`,children:`Block`})]}),C===e.name&&(0,h.jsx)(c,{className:`h-3.5 w-3.5 animate-spin text-shogun-gold`}),!o.authority.editable&&(0,h.jsx)(l,{className:`h-3.5 w-3.5 text-indigo-300`})]})})]},e.name))})]}),we.length===0&&(0,h.jsx)(`p`,{className:`py-10 text-center text-sm text-shogun-subdued`,children:`No tools match the current filters.`})]})]}),(0,h.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-[1.25fr_0.75fr]`,children:[(0,h.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(le,{className:`h-4 w-4 text-shogun-blue`}),(0,h.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Policy simulator`})]}),(0,h.jsx)(`p`,{className:`text-xs leading-relaxed text-shogun-subdued`,children:`Evaluate a proposed call—including dangerous parameters—without executing it.`}),(0,h.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[240px_1fr]`,children:[(0,h.jsx)(`select`,{value:A,onChange:e=>ye(e.target.value),className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2.5 font-mono text-xs text-shogun-text`,children:o.tools.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,h.jsx)(`textarea`,{value:be,onChange:e=>xe(e.target.value),rows:4,spellCheck:!1,className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2.5 font-mono text-xs text-shogun-text outline-none focus:border-shogun-blue`,placeholder:`{"path":"C:/workspace/report.docx"}`})]}),(0,h.jsxs)(`button`,{onClick:Ee,disabled:j||!A,className:`flex items-center gap-2 rounded-lg bg-shogun-blue px-4 py-2.5 text-xs font-bold text-white transition-opacity disabled:opacity-50`,children:[j?(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(le,{className:`h-4 w-4`}),` Evaluate call`]}),N&&(0,h.jsxs)(`div`,{className:`rounded-lg border border-shogun-border bg-shogun-bg/60 p-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(b,{action:N.action}),(0,h.jsxs)(`span`,{className:u(`text-[10px] font-bold uppercase tracking-widest`,_[N.risk_level]),children:[N.risk_level,` risk`]})]}),(0,h.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-shogun-subdued`,children:N.reason}),N.parameter_flags.length>0&&(0,h.jsx)(`p`,{className:`mt-2 font-mono text-[10px] text-amber-300`,children:N.parameter_flags.join(` · `)})]})]}),(0,h.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(ce,{className:`h-4 w-4 text-amber-300`}),(0,h.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Pending approvals`})]}),o.pending_confirmations.length===0?(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-shogun-border py-10 text-center`,children:[(0,h.jsx)(n,{className:`h-6 w-6 text-emerald-400`}),(0,h.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No tool calls are waiting for approval.`})]}):o.pending_confirmations.map(e=>(0,h.jsxs)(`div`,{className:`rounded-lg border border-amber-500/20 bg-amber-500/[0.05] p-3`,children:[(0,h.jsx)(`p`,{className:`font-mono text-xs font-bold text-shogun-text`,children:e.tool_name}),(0,h.jsx)(`p`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:e.reason})]},e.confirm_id)),(0,h.jsxs)(`button`,{onClick:()=>e(`/chat`),className:`flex items-center gap-2 text-xs font-bold text-shogun-blue hover:text-shogun-gold`,children:[`Resolve approvals in Chat `,(0,h.jsx)(t,{className:`h-3.5 w-3.5`})]}),(0,h.jsxs)(`div`,{className:`flex gap-2 rounded-lg bg-shogun-bg/70 p-3`,children:[(0,h.jsx)(ae,{className:`mt-0.5 h-4 w-4 shrink-0 text-shogun-subdued`}),(0,h.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued`,children:`Confirmations auto-deny after 60 seconds. Every verdict and operator decision remains available in Logs.`})]})]})]}),Se&&(0,h.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,h.jsx)(`div`,{className:`absolute inset-0 bg-black/75 backdrop-blur-sm`,onClick:()=>!K&&U(!1)}),(0,h.jsxs)(`form`,{onSubmit:Ne,className:`relative flex max-h-[90vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-shogun-border bg-shogun-bg shadow-2xl`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between border-b border-shogun-border p-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:W.id?`Edit custom posture`:`Create custom posture`}),(0,h.jsx)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:`Define the reusable policy here. Activation remains an explicit choice in Torii.`})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>U(!1),className:`rounded-lg p-2 text-shogun-subdued hover:bg-shogun-card hover:text-white`,children:(0,h.jsx)(oe,{className:`h-5 w-5`})})]}),(0,h.jsxs)(`div`,{className:`flex-1 space-y-5 overflow-y-auto p-5`,children:[(0,h.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,h.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Posture name`}),(0,h.jsx)(`input`,{required:!0,maxLength:255,value:W.name,onChange:e=>G(t=>({...t,name:e.target.value})),placeholder:`e.g. Research Samurai`,className:`w-full rounded-lg border border-shogun-border bg-[#050508] px-3 py-2.5 text-sm text-shogun-text outline-none focus:border-violet-400`})]}),(0,h.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Base tier`}),(0,h.jsx)(`select`,{value:W.tier,onChange:e=>G(t=>({...t,tier:e.target.value})),className:`w-full rounded-lg border border-shogun-border bg-[#050508] px-3 py-2.5 text-sm uppercase text-shogun-text outline-none focus:border-violet-400`,children:[`shrine`,`guarded`,`tactical`,`campaign`,`ronin`].map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,h.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,h.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Description`}),(0,h.jsx)(`textarea`,{rows:3,maxLength:1e3,value:W.description,onChange:e=>G(t=>({...t,description:e.target.value})),placeholder:`Explain when this posture should be selected.`,className:`w-full rounded-lg border border-shogun-border bg-[#050508] px-3 py-2.5 text-sm text-shogun-text outline-none focus:border-violet-400`})]}),(0,h.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,h.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-shogun-border bg-shogun-card/40 p-3 text-xs text-shogun-subdued`,children:[`Global kill switch available`,(0,h.jsx)(`input`,{type:`checkbox`,checked:W.kill_switch_enabled,onChange:e=>G(t=>({...t,kill_switch_enabled:e.target.checked}))})]}),(0,h.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-shogun-border bg-shogun-card/40 p-3 text-xs text-shogun-subdued`,children:[`Dry-run simulation supported`,(0,h.jsx)(`input`,{type:`checkbox`,checked:W.dry_run_supported,onChange:e=>G(t=>({...t,dry_run_supported:e.target.checked}))})]})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-[0.18em] text-shogun-text`,children:`Capability boundaries`}),(0,h.jsx)(`p`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:`These are the maximum runtime capabilities of this posture. Tool verdicts and advanced content rules may narrow them further.`}),(0,h.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Object.entries(W.permissions).map(([e,t])=>(0,h.jsxs)(`div`,{className:`rounded-lg border border-shogun-border/70 bg-[#050508] p-3`,children:[(0,h.jsx)(`p`,{className:`mb-3 text-[10px] font-bold uppercase tracking-[0.18em] text-violet-300`,children:e.replace(/_/g,` `)}),Object.keys(t||{}).length===0?(0,h.jsx)(`p`,{className:`text-[10px] italic text-shogun-subdued`,children:`Uses base-tier defaults`}):(0,h.jsx)(`div`,{className:`space-y-2`,children:Object.entries(t||{}).map(([t,n])=>(0,h.jsxs)(`label`,{className:`flex min-h-8 items-center justify-between gap-3 text-[10px] text-shogun-subdued`,children:[(0,h.jsx)(`span`,{className:`capitalize`,children:t.replace(/_/g,` `)}),typeof n==`boolean`?(0,h.jsx)(`button`,{type:`button`,onClick:()=>Q(e,t,!n),className:u(`relative h-5 w-10 rounded-full border transition-colors`,n?`border-emerald-500/40 bg-emerald-500/20`:`border-red-500/30 bg-red-500/10`),children:(0,h.jsx)(`span`,{className:u(`absolute top-0.5 h-4 w-4 rounded-full transition-all`,n?`left-5 bg-emerald-400`:`left-0.5 bg-red-400`)})}):typeof n==`number`?(0,h.jsx)(`input`,{type:`number`,value:n,onChange:n=>Q(e,t,Number(n.target.value)),className:`w-20 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text`}):Array.isArray(n)?(0,h.jsx)(`input`,{value:n.join(`, `),onChange:n=>Q(e,t,n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),placeholder:`Comma-separated`,className:`w-44 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text`}):t===`mode`?(0,h.jsx)(`select`,{value:String(n),onChange:n=>Q(e,t,n.target.value),className:`rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-[10px] uppercase text-shogun-text`,children:[`full`,`scoped`,`allowlist`,`disabled`].map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))}):(0,h.jsx)(`input`,{value:String(n??``),onChange:n=>Q(e,t,n.target.value),className:`w-36 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text`})]},t))})]},e))})]})]}),(0,h.jsxs)(`div`,{className:`flex justify-end gap-3 border-t border-shogun-border p-4`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>U(!1),className:`px-4 py-2.5 text-xs font-bold text-shogun-subdued hover:text-white`,children:`Cancel`}),(0,h.jsxs)(`button`,{type:`submit`,disabled:K||!W.name.trim(),className:`flex items-center gap-2 rounded-lg bg-violet-400 px-4 py-2.5 text-xs font-bold text-black disabled:opacity-50`,children:[K?(0,h.jsx)(c,{className:`h-4 w-4 animate-spin`}):(0,h.jsx)(a,{className:`h-4 w-4`}),W.id?`Save custom posture`:`Create custom posture`]})]})]})]})]})}export{S as ToolGate}; \ No newline at end of file diff --git a/frontend/dist/assets/ToolGate-BHRuc1_r.js b/frontend/dist/assets/ToolGate-BHRuc1_r.js deleted file mode 100644 index 1a20be1..0000000 --- a/frontend/dist/assets/ToolGate-BHRuc1_r.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{s as i}from"./chunk-OE4NN4TA-BT-WiWAe.js";import{t as a}from"./chevron-right-BzAY5P9l.js";import{t as ee}from"./circle-check-D9mntLsp.js";import{t as te}from"./circle-question-mark-qh8t_nrj.js";import{t as o}from"./loader-circle-yHzGFbgr.js";import{t as s}from"./lock-keyhole-krdx1133.js";import{t as c}from"./plus-DFW_DMbT.js";import{t as ne}from"./refresh-cw-CCrS0Omg.js";import{t as l}from"./save-CJWuwqGS.js";import{t as re}from"./search-CCF8DUSp.js";import{t as u}from"./shield-check-4WxAMs16.js";import{t as d}from"./sliders-horizontal-D4RY2Aan.js";import{t as f}from"./trash-2-Cid5DKqF.js";import{t as ie}from"./triangle-alert-BwzZbklP.js";import{t as ae}from"./wifi-off-w9xzPgfT.js";import{t as oe}from"./x-Bu7rztmN.js";import{t as p}from"./utils-wrb6h48Y.js";import{t as m}from"./axios-BPyV2soB.js";var se=e(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),ce=e(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),le=e(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),h=t(n(),1),g=r(),ue={allow:`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`,confirm:`border-amber-500/30 bg-amber-500/10 text-amber-300`,block:`border-red-500/30 bg-red-500/10 text-red-300`},_={low:`text-emerald-400`,medium:`text-cyan-400`,high:`text-amber-400`,critical:`text-red-400`},de={filesystem:{mode:`scoped`,allowed_paths:[],allow_home_access:!1,allow_arbitrary_paths:!1},network:{mode:`allowlist`,allowed_domains:[],allow_arbitrary_requests:!1},shell:{enabled:!1,allowed_binaries:[]},skills:{allow_auto_install:!1,require_approval:!0,allow_untrusted:!1},subagents:{allow_spawn:!0,max_active:5,allow_auto_spawn:!1},memory:{allow_write:!0,allow_bulk_delete:!1},comms:{allow_read_email:!0,allow_send_email:!0,allow_read_calendar:!0,allow_create_events:!0,allow_list_cron:!0,allow_manage_cron:!1},mado_browser:{},agentflow:{},flow_stack:{},visual_intake:{},ide_mode:{}},v=(e=structuredClone(de))=>({id:null,name:``,tier:`tactical`,description:``,permissions:e,kill_switch_enabled:!0,dry_run_supported:!0});function y({action:e}){return(0,g.jsx)(`span`,{className:p(`inline-flex min-w-20 justify-center rounded-md border px-2 py-1 text-[10px] font-bold uppercase tracking-widest`,ue[e]),children:e})}function fe(e){if(!e)return`No policy sync recorded`;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function b(e,t){return m.isAxiosError(e)?e.response?.data?.detail||e.message||t:e instanceof Error?e.message:t}function x(){let e=i(),[t,n]=(0,h.useState)(null),[r,x]=(0,h.useState)([]),[pe,me]=(0,h.useState)([]),[S,he]=(0,h.useState)(!0),[C,ge]=(0,h.useState)(null),[w,T]=(0,h.useState)(null),[E,_e]=(0,h.useState)(``),[D,ve]=(0,h.useState)(`all`),[O,ye]=(0,h.useState)(`all`),[k,be]=(0,h.useState)(``),[A,xe]=(0,h.useState)(`{}`),[j,M]=(0,h.useState)(!1),[N,P]=(0,h.useState)(null),[F,I]=(0,h.useState)({}),[L,R]=(0,h.useState)(!1),[z,B]=(0,h.useState)({enabled:!1,rules:[]}),[V,H]=(0,h.useState)(!1),[Se,U]=(0,h.useState)(!1),[W,G]=(0,h.useState)(v),[K,q]=(0,h.useState)(!1),J=async()=>{he(!0);try{let[e,t]=await Promise.all([m.get(`/api/v1/security/toolgate`),m.get(`/api/v1/security/policies`)]),r=e.data.data,i={...r,scope:r.scope||{key:`tier:${r.active_tier||`tactical`}`,kind:`tier`,label:(r.active_tier||`tactical`).toUpperCase(),base_tier:r.active_tier||`tactical`,policy_id:null},capabilities:r.capabilities||{permissions:{},risk_score:0,editable:!1,source:`builtin_tier`},advanced_controls:r.advanced_controls||{enabled:!1,rules:[],editable:r.authority?.editable??!0,source:r.authority?.mode===`gensui`?`gensui`:`local`}};n(i);let a=t.data.data||[];x(a.filter(e=>!e.is_builtin)),me(a.filter(e=>e.is_builtin)),I(i.capabilities.permissions||{}),B({enabled:i.advanced_controls.enabled,rules:i.advanced_controls.rules||[]}),be(e=>e||r.tools[0]?.name||``)}catch{T({type:`error`,text:`ToolGate status could not be loaded.`})}finally{he(!1)}};(0,h.useEffect)(()=>{J()},[]);let Ce=(0,h.useMemo)(()=>Array.from(new Set(t?.tools.map(e=>e.category)||[])).sort(),[t]),we=(0,h.useMemo)(()=>{let e=E.trim().toLowerCase();return(t?.tools||[]).filter(t=>(!e||t.name.toLowerCase().includes(e)||t.category.toLowerCase().includes(e))&&(D===`all`||t.category===D)&&(O===`all`||t.effective_action===O))},[t,E,D,O]),Y=(0,h.useMemo)(()=>({allow:t?.tools.filter(e=>e.effective_action===`allow`).length||0,confirm:t?.tools.filter(e=>e.effective_action===`confirm`).length||0,block:t?.tools.filter(e=>e.effective_action===`block`).length||0}),[t]),Te=async(e,n)=>{if(!t?.authority.editable)return;ge(e),T(null);let r={...t.local_overrides};n===`default`?delete r[e]:r[e]=n;try{await m.put(`/api/v1/security/toolgate/overrides`,{overrides:r}),T({type:`success`,text:`ToolGate rule updated for ${e}.`}),await J()}catch(e){T({type:`error`,text:b(e,`ToolGate rule could not be saved.`)})}finally{ge(null)}},Ee=async()=>{M(!0),P(null),T(null);try{let e=JSON.parse(A);if(!e||Array.isArray(e)||typeof e!=`object`)throw Error(`Arguments must be a JSON object.`);P((await m.post(`/api/v1/security/toolgate/simulate`,{tool_name:k,args:e})).data.data)}catch(e){T({type:`error`,text:b(e,`Simulation failed.`)})}finally{M(!1)}},X=(e,t,n)=>{I(r=>({...r,[e]:{...r[e]||{},[t]:n}}))},De=async()=>{if(t){R(!0),T(null);try{await m.put(`/api/v1/security/toolgate/capabilities`,{permissions:F}),T({type:`success`,text:`Capability boundaries saved for ${t.scope.label}.`}),await J()}catch(e){T({type:`error`,text:b(e,`Capability boundaries could not be saved.`)})}finally{R(!1)}}},Oe=()=>{B(e=>({...e,enabled:!0,rules:[...e.rules,{id:`rule-${Date.now()}`,label:``,pattern:``,match_type:`contains`,action:`confirm`,tools:[],case_sensitive:!1,enabled:!0}]}))},Z=(e,t)=>{B(n=>({...n,rules:n.rules.map(n=>n.id===e?{...n,...t}:n)}))},ke=async()=>{if(t){H(!0),T(null);try{await m.put(`/api/v1/security/toolgate/advanced`,z),T({type:`success`,text:`Advanced controls saved for ${t.scope.label}.`}),await J()}catch(e){T({type:`error`,text:b(e,`Advanced ToolGate controls could not be saved.`)})}finally{H(!1)}}},Ae=()=>{G(v(je(`tactical`))),U(!0)},je=e=>{let t=structuredClone(de),n=pe.find(t=>t.tier===e);return Object.entries(n?.permissions||{}).forEach(([e,n])=>{t[e]={...t[e]||{},...n||{}}}),t},Me=e=>{let t=je(e.tier);Object.entries(e.permissions||{}).forEach(([e,n])=>{t[e]={...t[e]||{},...n||{}}}),G({id:e.id,name:e.name,tier:e.tier,description:e.description||``,permissions:t,kill_switch_enabled:e.kill_switch_enabled,dry_run_supported:e.dry_run_supported}),U(!0)},Q=(e,t,n)=>{G(r=>({...r,permissions:{...r.permissions,[e]:{...r.permissions[e]||{},[t]:n}}}))},Ne=async e=>{if(e.preventDefault(),!t||!t.authority.editable||!W.name.trim())return;q(!0),T(null);let n={name:W.name.trim(),tier:W.tier,description:W.description.trim(),permissions:W.permissions,kill_switch_enabled:W.kill_switch_enabled,dry_run_supported:W.dry_run_supported};try{W.id?(await m.patch(`/api/v1/security/policies/${W.id}`,n),T({type:`success`,text:`${n.name} was updated.`})):(await m.post(`/api/v1/security/policies`,n),T({type:`success`,text:`${n.name} was created and is now available in Torii.`})),U(!1),await J()}catch(e){T({type:`error`,text:b(e,`Custom posture could not be saved.`)})}finally{q(!1)}},Pe=async e=>{if(!t||!t.authority.editable||!confirm(`Delete custom posture "${e.name}"?`))return;let n=t.scope.policy_id===e.id;T(null);try{await m.delete(`/api/v1/security/policies/${e.id}`),T({type:`success`,text:`${e.name} was deleted.${n?` Torii returned to its ${e.tier.toUpperCase()} base tier.`:``}`}),await J()}catch(e){T({type:`error`,text:b(e,`Custom posture could not be deleted.`)})}};if(S&&!t)return(0,g.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,g.jsx)(o,{className:`h-8 w-8 animate-spin text-shogun-gold`})});if(!t)return null;let $=t.authority.mode===`gensui`;return(0,g.jsxs)(`div`,{className:`mx-auto max-w-7xl space-y-6 pb-14 animate-in fade-in duration-500`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-start`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`h1`,{className:`shogun-title text-3xl font-bold`,children:`ToolGate`}),(0,g.jsx)(`span`,{className:`rounded border border-shogun-border bg-shogun-card px-2 py-1 text-[9px] uppercase tracking-[0.22em] text-shogun-subdued`,children:`Runtime permissions`})]}),(0,g.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-relaxed text-shogun-subdued`,children:`The enforcement layer between model intent and tool execution. Inspect the effective verdict, require human approval, or block individual capabilities.`})]}),(0,g.jsx)(`button`,{onClick:J,className:`self-start rounded-lg border border-shogun-border bg-shogun-card p-2.5 text-shogun-subdued transition-colors hover:text-shogun-gold`,title:`Refresh ToolGate`,children:(0,g.jsx)(ne,{className:p(`h-4 w-4`,S&&`animate-spin`)})})]}),(0,g.jsx)(`div`,{className:p(`rounded-xl border p-4`,$?t.authority.connected?`border-indigo-400/25 bg-indigo-500/[0.07]`:`border-amber-400/30 bg-amber-500/[0.07]`:`border-emerald-400/25 bg-emerald-500/[0.06]`),children:(0,g.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-center`,children:[(0,g.jsxs)(`div`,{className:`flex gap-3`,children:[$?t.authority.connected?(0,g.jsx)(u,{className:`mt-0.5 h-5 w-5 text-indigo-300`}):(0,g.jsx)(ae,{className:`mt-0.5 h-5 w-5 text-amber-300`}):(0,g.jsx)(d,{className:`mt-0.5 h-5 w-5 text-emerald-300`}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`p`,{className:`text-sm font-bold text-shogun-text`,children:$?t.authority.connected?`Managed by Gensui`:`Managed by Gensui — connection offline`:`Standalone authority`}),(0,g.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-shogun-subdued`,children:$?`This view is read-only. The last known central policy remains enforced. ${fe(t.authority.last_sync_at)}.`:`Overrides are saved only for ${t.scope.label}. Switching tier or custom policy loads that scope's own ToolGate rules.`})]})]}),$&&(0,g.jsxs)(`button`,{onClick:()=>e(`/gensui`),className:`flex items-center gap-2 self-start rounded-lg border border-indigo-400/25 bg-indigo-500/10 px-3 py-2 text-xs font-bold text-indigo-200 hover:bg-indigo-500/20`,children:[`View Gensui connection `,(0,g.jsx)(a,{className:`h-3.5 w-3.5`})]})]})}),w&&(0,g.jsxs)(`div`,{className:p(`flex items-center gap-2 rounded-lg border px-4 py-3 text-sm`,w.type===`success`?`border-emerald-500/25 bg-emerald-500/10 text-emerald-200`:`border-red-500/25 bg-red-500/10 text-red-200`),children:[w.type===`success`?(0,g.jsx)(ee,{className:`h-4 w-4`}):(0,g.jsx)(ie,{className:`h-4 w-4`}),w.text]}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-start`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(u,{className:`h-4 w-4 text-violet-300`}),(0,g.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Custom posture library`})]}),(0,g.jsx)(`p`,{className:`mt-1 max-w-3xl text-xs leading-relaxed text-shogun-subdued`,children:`Create and maintain reusable security postures here. Torii remains the single place where a built-in or custom posture is activated.`})]}),(0,g.jsxs)(`button`,{type:`button`,disabled:!t.authority.editable,onClick:Ae,className:`flex items-center gap-2 self-start rounded-lg border border-violet-400/30 bg-violet-500/10 px-3 py-2 text-xs font-bold text-violet-200 hover:bg-violet-500/20 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,g.jsx)(c,{className:`h-4 w-4`}),` Create custom posture`]})]}),$&&(0,g.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-indigo-400/20 bg-indigo-500/[0.05] p-3`,children:[(0,g.jsx)(s,{className:`mt-0.5 h-4 w-4 shrink-0 text-indigo-300`}),(0,g.jsx)(`p`,{className:`text-xs leading-relaxed text-indigo-100/75`,children:`Custom posture lifecycle is centrally owned by Gensui while this Tenshu is enrolled.`})]}),r.length===0?(0,g.jsxs)(`div`,{className:`rounded-lg border border-dashed border-shogun-border p-6 text-center`,children:[(0,g.jsx)(`p`,{className:`text-xs font-bold text-shogun-text`,children:`No custom postures yet`}),(0,g.jsx)(`p`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:`Create one here; it will immediately appear in Torii's posture selector.`})]}):(0,g.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:r.map(e=>{let n=t.scope.policy_id===e.id;return(0,g.jsxs)(`div`,{className:p(`rounded-lg border p-4`,n?`border-violet-400/45 bg-violet-500/[0.07]`:`border-shogun-border/70 bg-shogun-bg/45`),children:[(0,g.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,g.jsxs)(`div`,{className:`min-w-0`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`p`,{className:`truncate text-sm font-bold text-shogun-text`,children:e.name}),n&&(0,g.jsx)(`span`,{className:`rounded border border-emerald-400/25 bg-emerald-500/10 px-1.5 py-0.5 text-[8px] font-bold uppercase text-emerald-300`,children:`Active`})]}),(0,g.jsxs)(`p`,{className:`mt-1 text-[9px] font-bold uppercase tracking-widest text-violet-300`,children:[`Base `,e.tier]})]}),(0,g.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,g.jsx)(`button`,{type:`button`,disabled:!t.authority.editable,onClick:()=>Me(e),className:`rounded border border-shogun-border p-2 text-shogun-subdued hover:border-violet-400/30 hover:text-violet-200 disabled:opacity-40`,title:`Edit custom posture`,children:(0,g.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:!t.authority.editable,onClick:()=>Pe(e),className:`rounded border border-red-500/15 p-2 text-red-300/70 hover:bg-red-500/10 hover:text-red-300 disabled:opacity-40`,title:`Delete custom posture`,children:(0,g.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,g.jsx)(`p`,{className:`mt-3 line-clamp-2 min-h-8 text-[10px] leading-relaxed text-shogun-subdued`,children:e.description||`No description`}),(0,g.jsxs)(`div`,{className:`mt-3 flex gap-2 text-[9px] uppercase tracking-wider text-shogun-subdued`,children:[(0,g.jsxs)(`span`,{children:[Object.keys(e.permissions||{}).length,` capability groups`]}),(0,g.jsx)(`span`,{children:`·`}),(0,g.jsx)(`span`,{children:e.kill_switch_enabled?`Kill switch`:`No kill switch`})]})]},e.id)})})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-5`,children:[{label:t.scope.kind===`custom_policy`?`Custom tier`:`Active tier`,value:t.scope.label,color:`text-shogun-gold`},{label:`Allow`,value:Y.allow,color:`text-emerald-400`},{label:`Confirm`,value:Y.confirm,color:`text-amber-400`},{label:`Block`,value:Y.block,color:`text-red-400`},{label:`Pending approval`,value:t.pending_confirmations.length,color:`text-indigo-300`}].map(e=>(0,g.jsxs)(`div`,{className:`shogun-card`,children:[(0,g.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:e.label}),(0,g.jsx)(`p`,{className:p(`mt-2 text-2xl font-bold`,e.color),children:e.value})]},e.label))}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 lg:flex-row lg:items-start`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(u,{className:`h-4 w-4 text-shogun-gold`}),(0,g.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Capability boundaries`})]}),(0,g.jsx)(`p`,{className:`mt-1 max-w-3xl text-xs leading-relaxed text-shogun-subdued`,children:`The policy ceiling for filesystem, network, applications, workflows, memory, and delegation. Runtime tool verdicts below can only narrow these capabilities.`})]}),(0,g.jsxs)(`div`,{className:`min-w-56 rounded-lg border border-shogun-border bg-shogun-bg/70 p-3`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:[(0,g.jsx)(`span`,{children:`Capability Risk Index`}),(0,g.jsxs)(`span`,{className:p(t.capabilities.risk_score<=25?`text-emerald-400`:t.capabilities.risk_score<=50?`text-shogun-gold`:t.capabilities.risk_score<=75?`text-orange-400`:`text-red-400`),children:[t.capabilities.risk_score,`/100`]})]}),(0,g.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-black/40`,children:(0,g.jsx)(`div`,{className:p(`h-full rounded-full transition-all`,t.capabilities.risk_score<=25?`bg-emerald-400`:t.capabilities.risk_score<=50?`bg-shogun-gold`:t.capabilities.risk_score<=75?`bg-orange-400`:`bg-red-500`),style:{width:`${t.capabilities.risk_score}%`}})})]})]}),!t.capabilities.editable&&(0,g.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-lg border border-amber-400/20 bg-amber-500/[0.05] p-3`,children:[(0,g.jsxs)(`div`,{className:`flex gap-2`,children:[(0,g.jsx)(s,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-300`}),(0,g.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-100/75`,children:$?`Capability boundaries are centrally owned by Gensui.`:`Built-in tiers are protected presets. Create or edit custom postures in the library above; activate one in Torii to inspect it here.`})]}),!$&&(0,g.jsx)(`button`,{onClick:()=>e(`/torii`),className:`shrink-0 text-xs font-bold text-shogun-gold hover:text-white`,children:`Select in Torii`})]}),(0,g.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Object.entries(F).map(([e,n])=>(0,g.jsxs)(`div`,{className:`rounded-lg border border-shogun-border/70 bg-shogun-bg/45 p-3`,children:[(0,g.jsx)(`p`,{className:`mb-3 text-[10px] font-bold uppercase tracking-[0.18em] text-shogun-gold`,children:e.replace(/_/g,` `)}),(0,g.jsx)(`div`,{className:`space-y-2`,children:Object.entries(n||{}).map(([n,r])=>(0,g.jsxs)(`label`,{className:`flex min-h-8 items-center justify-between gap-3 text-[10px] text-shogun-subdued`,children:[(0,g.jsx)(`span`,{className:`capitalize`,children:n.replace(/_/g,` `)}),typeof r==`boolean`?(0,g.jsx)(`button`,{type:`button`,disabled:!t.capabilities.editable,onClick:()=>X(e,n,!r),className:p(`relative h-5 w-10 rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-55`,r?`border-emerald-500/40 bg-emerald-500/20`:`border-red-500/30 bg-red-500/10`),children:(0,g.jsx)(`span`,{className:p(`absolute top-0.5 h-4 w-4 rounded-full transition-all`,r?`left-5 bg-emerald-400`:`left-0.5 bg-red-400`)})}):typeof r==`number`?(0,g.jsx)(`input`,{type:`number`,disabled:!t.capabilities.editable,value:r,onChange:t=>X(e,n,Number(t.target.value)),className:`w-20 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text disabled:opacity-55`}):Array.isArray(r)?(0,g.jsx)(`input`,{disabled:!t.capabilities.editable,value:r.join(`, `),onChange:t=>X(e,n,t.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),placeholder:`Comma-separated`,className:`w-44 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text disabled:opacity-55`}):n===`mode`?(0,g.jsx)(`select`,{disabled:!t.capabilities.editable,value:String(r),onChange:t=>X(e,n,t.target.value),className:`rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-[10px] uppercase text-shogun-text disabled:opacity-55`,children:[`full`,`scoped`,`allowlist`,`disabled`].map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))}):(0,g.jsx)(`input`,{disabled:!t.capabilities.editable,value:String(r??``),onChange:t=>X(e,n,t.target.value),className:`w-36 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text disabled:opacity-55`})]},n))})]},e))}),t.capabilities.editable&&(0,g.jsx)(`div`,{className:`flex justify-end`,children:(0,g.jsxs)(`button`,{onClick:De,disabled:L,className:`flex items-center gap-2 rounded-lg bg-shogun-gold px-4 py-2.5 text-xs font-bold text-black disabled:opacity-50`,children:[L?(0,g.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,g.jsx)(l,{className:`h-4 w-4`}),`Save capability boundaries`]})})]}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-5`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-center`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(d,{className:`h-4 w-4 text-orange-400`}),(0,g.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Advanced controls`}),(0,g.jsx)(`span`,{className:`rounded border border-orange-400/20 bg-orange-500/10 px-2 py-1 text-[9px] font-bold uppercase tracking-widest text-orange-300`,children:`Content-aware`})]}),(0,g.jsx)(`p`,{className:`mt-1 max-w-3xl text-xs leading-relaxed text-shogun-subdued`,children:`Flag words or phrases inside tool arguments and require confirmation or block the call. Rules can apply globally or only to one tool and never weaken a stricter safety decision.`})]}),(0,g.jsxs)(`button`,{type:`button`,disabled:!t.advanced_controls.editable,onClick:()=>B(e=>({...e,enabled:!e.enabled})),className:p(`flex items-center gap-3 rounded-lg border px-3 py-2 text-xs font-bold transition-colors disabled:cursor-not-allowed disabled:opacity-55`,z.enabled?`border-orange-400/35 bg-orange-500/10 text-orange-200`:`border-shogun-border bg-shogun-bg text-shogun-subdued`),children:[(0,g.jsx)(`span`,{className:p(`relative h-5 w-10 rounded-full border`,z.enabled?`border-orange-400/40 bg-orange-500/20`:`border-shogun-border bg-black/30`),children:(0,g.jsx)(`span`,{className:p(`absolute top-0.5 h-4 w-4 rounded-full transition-all`,z.enabled?`left-5 bg-orange-300`:`left-0.5 bg-shogun-subdued`)})}),`Advanced mode `,z.enabled?`on`:`off`]})]}),!t.advanced_controls.editable&&(0,g.jsxs)(`div`,{className:`flex gap-2 rounded-lg border border-indigo-400/20 bg-indigo-500/[0.05] p-3`,children:[(0,g.jsx)(s,{className:`mt-0.5 h-4 w-4 shrink-0 text-indigo-300`}),(0,g.jsx)(`p`,{className:`text-xs leading-relaxed text-indigo-100/75`,children:`These content rules are centrally owned by Gensui and remain enforced from the cached policy if the connection is temporarily unavailable.`})]}),(0,g.jsxs)(`div`,{className:`space-y-3`,children:[z.rules.map((e,n)=>(0,g.jsxs)(`div`,{className:`rounded-lg border border-shogun-border/70 bg-shogun-bg/45 p-4`,children:[(0,g.jsxs)(`div`,{className:`grid gap-3 xl:grid-cols-[minmax(150px,0.8fr)_minmax(220px,1.4fr)_130px_130px_minmax(180px,1fr)_auto] xl:items-end`,children:[(0,g.jsxs)(`label`,{className:`space-y-1`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Rule label`}),(0,g.jsx)(`input`,{disabled:!t.advanced_controls.editable,value:e.label,onChange:t=>Z(e.id,{label:t.target.value}),placeholder:`Rule ${n+1}`,maxLength:120,className:`w-full rounded border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text disabled:opacity-55`})]}),(0,g.jsxs)(`label`,{className:`space-y-1`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Word or phrase`}),(0,g.jsx)(`input`,{disabled:!t.advanced_controls.editable,value:e.pattern,onChange:t=>Z(e.id,{pattern:t.target.value}),placeholder:`e.g. confidential`,maxLength:200,className:`w-full rounded border border-shogun-border bg-shogun-bg px-3 py-2 font-mono text-xs text-shogun-text disabled:opacity-55`})]}),(0,g.jsxs)(`label`,{className:`space-y-1`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Match`}),(0,g.jsxs)(`select`,{disabled:!t.advanced_controls.editable,value:e.match_type,onChange:t=>Z(e.id,{match_type:t.target.value}),className:`w-full rounded border border-shogun-border bg-shogun-bg px-2 py-2 text-xs text-shogun-text disabled:opacity-55`,children:[(0,g.jsx)(`option`,{value:`contains`,children:`Contains`}),(0,g.jsx)(`option`,{value:`word`,children:`Whole word`})]})]}),(0,g.jsxs)(`label`,{className:`space-y-1`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Verdict`}),(0,g.jsxs)(`select`,{disabled:!t.advanced_controls.editable,value:e.action,onChange:t=>Z(e.id,{action:t.target.value}),className:p(`w-full rounded border px-2 py-2 text-xs font-bold uppercase disabled:opacity-55`,ue[e.action]),children:[(0,g.jsx)(`option`,{value:`confirm`,children:`Confirm`}),(0,g.jsx)(`option`,{value:`block`,children:`Block`})]})]}),(0,g.jsxs)(`label`,{className:`space-y-1`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Applies to`}),(0,g.jsxs)(`select`,{disabled:!t.advanced_controls.editable,value:e.tools[0]||`*`,onChange:t=>Z(e.id,{tools:t.target.value===`*`?[]:[t.target.value]}),className:`w-full rounded border border-shogun-border bg-shogun-bg px-2 py-2 font-mono text-xs text-shogun-text disabled:opacity-55`,children:[(0,g.jsx)(`option`,{value:`*`,children:`All tools`}),t.tools.map(e=>(0,g.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,g.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,g.jsx)(`button`,{type:`button`,disabled:!t.advanced_controls.editable,onClick:()=>Z(e.id,{enabled:!e.enabled}),className:p(`rounded border px-2.5 py-2 text-[9px] font-bold uppercase disabled:opacity-55`,e.enabled?`border-emerald-500/25 text-emerald-300`:`border-shogun-border text-shogun-subdued`),children:e.enabled?`Active`:`Paused`}),(0,g.jsx)(`button`,{type:`button`,disabled:!t.advanced_controls.editable,onClick:()=>B(t=>({...t,rules:t.rules.filter(t=>t.id!==e.id)})),className:`rounded border border-red-500/20 p-2 text-red-300 hover:bg-red-500/10 disabled:opacity-55`,title:`Remove rule`,children:(0,g.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,g.jsxs)(`label`,{className:`mt-3 flex items-center gap-2 text-[10px] text-shogun-subdued`,children:[(0,g.jsx)(`input`,{type:`checkbox`,disabled:!t.advanced_controls.editable,checked:e.case_sensitive,onChange:t=>Z(e.id,{case_sensitive:t.target.checked})}),`Case-sensitive match`]})]},e.id)),z.rules.length===0&&(0,g.jsx)(`div`,{className:`rounded-lg border border-dashed border-shogun-border p-6 text-center text-xs text-shogun-subdued`,children:`No advanced content rules are defined for this policy.`})]}),t.advanced_controls.editable&&(0,g.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-3`,children:[(0,g.jsxs)(`button`,{type:`button`,onClick:Oe,className:`flex items-center gap-2 rounded-lg border border-orange-400/25 px-3 py-2 text-xs font-bold text-orange-300 hover:bg-orange-500/10`,children:[(0,g.jsx)(c,{className:`h-4 w-4`}),` Add content rule`]}),(0,g.jsxs)(`button`,{type:`button`,onClick:ke,disabled:V||z.rules.some(e=>!e.pattern.trim()),className:`flex items-center gap-2 rounded-lg bg-orange-400 px-4 py-2.5 text-xs font-bold text-black disabled:opacity-50`,children:[V?(0,g.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,g.jsx)(l,{className:`h-4 w-4`}),`Save advanced controls`]})]})]}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsxs)(`div`,{className:`flex flex-col justify-between gap-3 lg:flex-row lg:items-center`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Effective tool policy`}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:t.scope.kind===`custom_policy`?`${t.scope.label} inherits ${t.scope.base_tier.toUpperCase()} thresholds; its ToolGate overrides remain isolated from every other tier.`:`Default ${t.scope.base_tier.toUpperCase()} thresholds plus local, Campaign, Gensui, and parameter-aware restrictions.`})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,g.jsxs)(`label`,{className:`relative`,children:[(0,g.jsx)(re,{className:`absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-shogun-subdued`}),(0,g.jsx)(`input`,{value:E,onChange:e=>_e(e.target.value),placeholder:`Search tools…`,className:`w-52 rounded-lg border border-shogun-border bg-shogun-bg py-2 pl-9 pr-3 text-xs text-shogun-text outline-none focus:border-shogun-blue`})]}),(0,g.jsxs)(`select`,{value:D,onChange:e=>ve(e.target.value),className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:`all`,children:`All categories`}),Ce.map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))]}),(0,g.jsxs)(`select`,{value:O,onChange:e=>ye(e.target.value),className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2 text-xs text-shogun-text`,children:[(0,g.jsx)(`option`,{value:`all`,children:`All verdicts`}),(0,g.jsx)(`option`,{value:`allow`,children:`Allow`}),(0,g.jsx)(`option`,{value:`confirm`,children:`Confirm`}),(0,g.jsx)(`option`,{value:`block`,children:`Block`})]})]})]}),(0,g.jsxs)(`div`,{className:`overflow-x-auto rounded-lg border border-shogun-border/70`,children:[(0,g.jsxs)(`table`,{className:`w-full min-w-[920px] text-left`,children:[(0,g.jsx)(`thead`,{className:`bg-[#080b12] text-[9px] uppercase tracking-widest text-shogun-subdued`,children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{className:`px-4 py-3`,children:`Tool`}),(0,g.jsx)(`th`,{className:`px-4 py-3`,children:`Risk`}),(0,g.jsx)(`th`,{className:`px-4 py-3`,children:`Effective`}),(0,g.jsx)(`th`,{className:`px-4 py-3`,children:`Policy layers`}),(0,g.jsx)(`th`,{className:`px-4 py-3`,children:`Standalone override`})]})}),(0,g.jsx)(`tbody`,{className:`divide-y divide-shogun-border/60`,children:we.map(e=>(0,g.jsxs)(`tr`,{className:`bg-shogun-card/20 hover:bg-shogun-card/50`,children:[(0,g.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,g.jsx)(`p`,{className:`font-mono text-xs font-semibold text-shogun-text`,children:e.name}),(0,g.jsx)(`p`,{className:`mt-1 text-[9px] uppercase tracking-widest text-shogun-subdued`,children:e.category})]}),(0,g.jsx)(`td`,{className:p(`px-4 py-3 text-[10px] font-bold uppercase tracking-wider`,_[e.risk]),children:e.risk}),(0,g.jsx)(`td`,{className:`px-4 py-3`,children:(0,g.jsx)(y,{action:e.effective_action})}),(0,g.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[e.gensui_override&&(0,g.jsxs)(`span`,{className:`rounded bg-indigo-500/10 px-2 py-1 text-[9px] text-indigo-300`,children:[`Gensui: `,e.gensui_override]}),e.campaign_override&&(0,g.jsxs)(`span`,{className:`rounded bg-orange-500/10 px-2 py-1 text-[9px] text-orange-300`,children:[`Campaign: `,e.campaign_override]}),e.local_override&&(0,g.jsxs)(`span`,{className:`rounded bg-cyan-500/10 px-2 py-1 text-[9px] text-cyan-300`,children:[`Local: `,e.local_override]}),!e.gensui_override&&!e.campaign_override&&!e.local_override&&(0,g.jsxs)(`span`,{className:`text-[10px] text-shogun-subdued`,children:[`Mode default: `,e.default_action]})]}),(0,g.jsx)(`p`,{className:`mt-1.5 max-w-xl truncate text-[9px] text-shogun-subdued`,title:e.reason,children:e.reason})]}),(0,g.jsx)(`td`,{className:`px-4 py-3`,children:(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsxs)(`select`,{value:e.local_override||`default`,disabled:!t.authority.editable||C===e.name,onChange:t=>Te(e.name,t.target.value),className:`w-32 rounded-lg border border-shogun-border bg-shogun-bg px-2 py-2 text-xs text-shogun-text disabled:cursor-not-allowed disabled:opacity-45`,children:[(0,g.jsx)(`option`,{value:`default`,children:`Use default`}),(0,g.jsx)(`option`,{value:`allow`,children:`Allow`}),(0,g.jsx)(`option`,{value:`confirm`,children:`Confirm`}),(0,g.jsx)(`option`,{value:`block`,children:`Block`})]}),C===e.name&&(0,g.jsx)(o,{className:`h-3.5 w-3.5 animate-spin text-shogun-gold`}),!t.authority.editable&&(0,g.jsx)(s,{className:`h-3.5 w-3.5 text-indigo-300`})]})})]},e.name))})]}),we.length===0&&(0,g.jsx)(`p`,{className:`py-10 text-center text-sm text-shogun-subdued`,children:`No tools match the current filters.`})]})]}),(0,g.jsxs)(`div`,{className:`grid gap-5 lg:grid-cols-[1.25fr_0.75fr]`,children:[(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(ce,{className:`h-4 w-4 text-shogun-blue`}),(0,g.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Policy simulator`})]}),(0,g.jsx)(`p`,{className:`text-xs leading-relaxed text-shogun-subdued`,children:`Evaluate a proposed call—including dangerous parameters—without executing it.`}),(0,g.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[240px_1fr]`,children:[(0,g.jsx)(`select`,{value:k,onChange:e=>be(e.target.value),className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2.5 font-mono text-xs text-shogun-text`,children:t.tools.map(e=>(0,g.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,g.jsx)(`textarea`,{value:A,onChange:e=>xe(e.target.value),rows:4,spellCheck:!1,className:`rounded-lg border border-shogun-border bg-shogun-bg px-3 py-2.5 font-mono text-xs text-shogun-text outline-none focus:border-shogun-blue`,placeholder:`{"path":"C:/workspace/report.docx"}`})]}),(0,g.jsxs)(`button`,{onClick:Ee,disabled:j||!k,className:`flex items-center gap-2 rounded-lg bg-shogun-blue px-4 py-2.5 text-xs font-bold text-white transition-opacity disabled:opacity-50`,children:[j?(0,g.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,g.jsx)(ce,{className:`h-4 w-4`}),` Evaluate call`]}),N&&(0,g.jsxs)(`div`,{className:`rounded-lg border border-shogun-border bg-shogun-bg/60 p-4`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(y,{action:N.action}),(0,g.jsxs)(`span`,{className:p(`text-[10px] font-bold uppercase tracking-widest`,_[N.risk_level]),children:[N.risk_level,` risk`]})]}),(0,g.jsx)(`p`,{className:`mt-3 text-xs leading-relaxed text-shogun-subdued`,children:N.reason}),N.parameter_flags.length>0&&(0,g.jsx)(`p`,{className:`mt-2 font-mono text-[10px] text-amber-300`,children:N.parameter_flags.join(` · `)})]})]}),(0,g.jsxs)(`div`,{className:`shogun-card space-y-4`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(se,{className:`h-4 w-4 text-amber-300`}),(0,g.jsx)(`h2`,{className:`text-sm font-bold uppercase tracking-widest text-shogun-text`,children:`Pending approvals`})]}),t.pending_confirmations.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-2 rounded-lg border border-dashed border-shogun-border py-10 text-center`,children:[(0,g.jsx)(ee,{className:`h-6 w-6 text-emerald-400`}),(0,g.jsx)(`p`,{className:`text-xs text-shogun-subdued`,children:`No tool calls are waiting for approval.`})]}):t.pending_confirmations.map(e=>(0,g.jsxs)(`div`,{className:`rounded-lg border border-amber-500/20 bg-amber-500/[0.05] p-3`,children:[(0,g.jsx)(`p`,{className:`font-mono text-xs font-bold text-shogun-text`,children:e.tool_name}),(0,g.jsx)(`p`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:e.reason})]},e.confirm_id)),(0,g.jsxs)(`button`,{onClick:()=>e(`/chat`),className:`flex items-center gap-2 text-xs font-bold text-shogun-blue hover:text-shogun-gold`,children:[`Resolve approvals in Chat `,(0,g.jsx)(a,{className:`h-3.5 w-3.5`})]}),(0,g.jsxs)(`div`,{className:`flex gap-2 rounded-lg bg-shogun-bg/70 p-3`,children:[(0,g.jsx)(te,{className:`mt-0.5 h-4 w-4 shrink-0 text-shogun-subdued`}),(0,g.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued`,children:`Confirmations auto-deny after 60 seconds. Every verdict and operator decision remains available in Logs.`})]})]})]}),Se&&(0,g.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4`,children:[(0,g.jsx)(`div`,{className:`absolute inset-0 bg-black/75 backdrop-blur-sm`,onClick:()=>!K&&U(!1)}),(0,g.jsxs)(`form`,{onSubmit:Ne,className:`relative flex max-h-[90vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-shogun-border bg-shogun-bg shadow-2xl`,children:[(0,g.jsxs)(`div`,{className:`flex items-start justify-between border-b border-shogun-border p-5`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h3`,{className:`text-lg font-bold text-shogun-text`,children:W.id?`Edit custom posture`:`Create custom posture`}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:`Define the reusable policy here. Activation remains an explicit choice in Torii.`})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>U(!1),className:`rounded-lg p-2 text-shogun-subdued hover:bg-shogun-card hover:text-white`,children:(0,g.jsx)(oe,{className:`h-5 w-5`})})]}),(0,g.jsxs)(`div`,{className:`flex-1 space-y-5 overflow-y-auto p-5`,children:[(0,g.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,g.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Posture name`}),(0,g.jsx)(`input`,{required:!0,maxLength:255,value:W.name,onChange:e=>G(t=>({...t,name:e.target.value})),placeholder:`e.g. Research Samurai`,className:`w-full rounded-lg border border-shogun-border bg-[#050508] px-3 py-2.5 text-sm text-shogun-text outline-none focus:border-violet-400`})]}),(0,g.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Base tier`}),(0,g.jsx)(`select`,{value:W.tier,onChange:e=>G(t=>({...t,tier:e.target.value})),className:`w-full rounded-lg border border-shogun-border bg-[#050508] px-3 py-2.5 text-sm uppercase text-shogun-text outline-none focus:border-violet-400`,children:[`shrine`,`guarded`,`tactical`,`campaign`,`ronin`].map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))})]})]}),(0,g.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,g.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-widest text-shogun-subdued`,children:`Description`}),(0,g.jsx)(`textarea`,{rows:3,maxLength:1e3,value:W.description,onChange:e=>G(t=>({...t,description:e.target.value})),placeholder:`Explain when this posture should be selected.`,className:`w-full rounded-lg border border-shogun-border bg-[#050508] px-3 py-2.5 text-sm text-shogun-text outline-none focus:border-violet-400`})]}),(0,g.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,g.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-shogun-border bg-shogun-card/40 p-3 text-xs text-shogun-subdued`,children:[`Global kill switch available`,(0,g.jsx)(`input`,{type:`checkbox`,checked:W.kill_switch_enabled,onChange:e=>G(t=>({...t,kill_switch_enabled:e.target.checked}))})]}),(0,g.jsxs)(`label`,{className:`flex items-center justify-between rounded-lg border border-shogun-border bg-shogun-card/40 p-3 text-xs text-shogun-subdued`,children:[`Dry-run simulation supported`,(0,g.jsx)(`input`,{type:`checkbox`,checked:W.dry_run_supported,onChange:e=>G(t=>({...t,dry_run_supported:e.target.checked}))})]})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h4`,{className:`text-[10px] font-bold uppercase tracking-[0.18em] text-shogun-text`,children:`Capability boundaries`}),(0,g.jsx)(`p`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:`These are the maximum runtime capabilities of this posture. Tool verdicts and advanced content rules may narrow them further.`}),(0,g.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Object.entries(W.permissions).map(([e,t])=>(0,g.jsxs)(`div`,{className:`rounded-lg border border-shogun-border/70 bg-[#050508] p-3`,children:[(0,g.jsx)(`p`,{className:`mb-3 text-[10px] font-bold uppercase tracking-[0.18em] text-violet-300`,children:e.replace(/_/g,` `)}),Object.keys(t||{}).length===0?(0,g.jsx)(`p`,{className:`text-[10px] italic text-shogun-subdued`,children:`Uses base-tier defaults`}):(0,g.jsx)(`div`,{className:`space-y-2`,children:Object.entries(t||{}).map(([t,n])=>(0,g.jsxs)(`label`,{className:`flex min-h-8 items-center justify-between gap-3 text-[10px] text-shogun-subdued`,children:[(0,g.jsx)(`span`,{className:`capitalize`,children:t.replace(/_/g,` `)}),typeof n==`boolean`?(0,g.jsx)(`button`,{type:`button`,onClick:()=>Q(e,t,!n),className:p(`relative h-5 w-10 rounded-full border transition-colors`,n?`border-emerald-500/40 bg-emerald-500/20`:`border-red-500/30 bg-red-500/10`),children:(0,g.jsx)(`span`,{className:p(`absolute top-0.5 h-4 w-4 rounded-full transition-all`,n?`left-5 bg-emerald-400`:`left-0.5 bg-red-400`)})}):typeof n==`number`?(0,g.jsx)(`input`,{type:`number`,value:n,onChange:n=>Q(e,t,Number(n.target.value)),className:`w-20 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text`}):Array.isArray(n)?(0,g.jsx)(`input`,{value:n.join(`, `),onChange:n=>Q(e,t,n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),placeholder:`Comma-separated`,className:`w-44 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text`}):t===`mode`?(0,g.jsx)(`select`,{value:String(n),onChange:n=>Q(e,t,n.target.value),className:`rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-[10px] uppercase text-shogun-text`,children:[`full`,`scoped`,`allowlist`,`disabled`].map(e=>(0,g.jsx)(`option`,{value:e,children:e},e))}):(0,g.jsx)(`input`,{value:String(n??``),onChange:n=>Q(e,t,n.target.value),className:`w-36 rounded border border-shogun-border bg-shogun-bg px-2 py-1 text-right text-[10px] text-shogun-text`})]},t))})]},e))})]})]}),(0,g.jsxs)(`div`,{className:`flex justify-end gap-3 border-t border-shogun-border p-4`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:()=>U(!1),className:`px-4 py-2.5 text-xs font-bold text-shogun-subdued hover:text-white`,children:`Cancel`}),(0,g.jsxs)(`button`,{type:`submit`,disabled:K||!W.name.trim(),className:`flex items-center gap-2 rounded-lg bg-violet-400 px-4 py-2.5 text-xs font-bold text-black disabled:opacity-50`,children:[K?(0,g.jsx)(o,{className:`h-4 w-4 animate-spin`}):(0,g.jsx)(l,{className:`h-4 w-4`}),W.id?`Save custom posture`:`Create custom posture`]})]})]})]})]})}export{x as ToolGate}; \ No newline at end of file diff --git a/frontend/dist/assets/Torii-C5OXsZeZ.js b/frontend/dist/assets/Torii-C5OXsZeZ.js new file mode 100644 index 0000000..5c94ead --- /dev/null +++ b/frontend/dist/assets/Torii-C5OXsZeZ.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./app-window-BFcF7ht7.js";import{t as n}from"./calendar-Cad5gZZR.js";import{t as r}from"./circle-check-DBu5bzEI.js";import{t as i}from"./clock-DQ9Dz1_z.js";import{t as a}from"./crosshair-B6y1p9rN.js";import{t as o}from"./mail-Ca9FQxut.js";import{t as s}from"./monitor-DrwnCrGM.js";import{t as c}from"./mouse-pointer-2-CgDYWfSe.js";import{t as l}from"./power-Bl6a5geq.js";import{t as u}from"./refresh-cw-Dm6S5UAJ.js";import{t as d}from"./settings-2-BXoo7RAn.js";import{t as f}from"./shield-alert-DzWPVhkC.js";import{t as p}from"./sparkles-DyLIKWW0.js";import{t as m}from"./terminal-B0TmVXNb.js";import{t as h}from"./zap-CQy--vuS.js";import{O as g,c as _,i as v,j as y,o as b,r as x,t as S,u as C,v as w,y as T}from"./index-Dy1E248t.js";import{t as E}from"./axios-BGmZl9Qd.js";import{t as D}from"./HarakiriModal-ChG-WA-N.js";var O=e(y(),1),k=S(),A=[{id:`shrine`,label:`SHRINE`,color:`text-shogun-gold`,bg:`bg-shogun-gold/5`,border:`border-shogun-gold/40`},{id:`guarded`,label:`GUARDED`,color:`text-green-400`,bg:`bg-green-400/5`,border:`border-green-400/40`},{id:`tactical`,label:`TACTICAL`,color:`text-shogun-blue`,bg:`bg-shogun-blue/5`,border:`border-shogun-blue/40`},{id:`campaign`,label:`CAMPAIGN`,color:`text-orange-400`,bg:`bg-orange-400/5`,border:`border-orange-400/40`},{id:`ronin`,label:`RONIN`,color:`text-red-500`,bg:`bg-red-500/5`,border:`border-red-500/40`}];function j(){let{t:e}=x(),y=g(),[S,j]=(0,O.useState)(!0),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(null),[I,L]=(0,O.useState)([]),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(null),H=(0,O.useMemo)(()=>[{...A[0],badge:e(`torii.badge_max`),description:e(`torii.tier_shrine_desc`)},{...A[1],badge:``,description:e(`torii.tier_guarded_desc`)},{...A[2],badge:e(`torii.badge_default`),description:e(`torii.tier_tactical_desc`)},{...A[3],badge:``,description:e(`torii.tier_campaign_desc`)},{...A[4],badge:e(`torii.badge_unsafe`),description:e(`torii.tier_ronin_desc`)}],[e]),U=(0,O.useMemo)(()=>I.filter(e=>!e.is_builtin),[I]),W=(0,O.useCallback)(async()=>{j(!0);try{let[e,t]=await Promise.all([E.get(`/api/v1/security/posture`),E.get(`/api/v1/security/policies`)]);F(e.data.data),L(t.data.data||[])}catch{V({type:`error`,text:e(`torii.posture_failed`)})}finally{j(!1)}},[e]);(0,O.useEffect)(()=>{W()},[W]);let G=(e,t)=>{V({type:e,text:t}),window.setTimeout(()=>V(null),3500)},K=async(t,n)=>{if(!M){N(!0);try{let r=await E.put(`/api/v1/security/posture/active`,t);F(r.data.data),G(`success`,`${e(`torii.posture_updated`)} ${n}`)}catch(t){let n=E.isAxiosError(t)?t.response?.data?.detail:null;G(`error`,n||e(`torii.posture_failed`))}finally{N(!1)}}},q=async()=>{if(P?.kill_switch_active){if(!confirm(e(`torii.reset_confirm`)))return;try{let t=await E.delete(`/api/v1/security/kill-switch`);F(t.data.data),G(`success`,e(`torii.reset_success`))}catch{G(`error`,e(`torii.reset_failed`))}return}z(!0)},J=async()=>{z(!1);try{let t=await E.post(`/api/v1/security/kill-switch`);F(t.data.data),G(`error`,e(`torii.harakiri_initiated`))}catch{G(`error`,e(`torii.harakiri_failed`))}},Y=P?.active_policy_name||P?.active_tier.toUpperCase();return(0,k.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-6 pb-12 animate-in fade-in duration-500`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-center`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`h2`,{className:`shogun-title flex items-center gap-3 text-3xl font-bold`,children:[e(`torii.title`,`The Torii`),(0,k.jsx)(`span`,{className:`rounded border border-shogun-border bg-shogun-card px-2 py-0.5 text-[10px] font-normal uppercase tracking-[0.2em] text-shogun-subdued`,children:e(`torii.badge`)})]}),(0,k.jsx)(`p`,{className:`mt-1 text-sm text-shogun-subdued`,children:`Choose which security posture is active. Custom posture design belongs to ToolGate.`})]}),(0,k.jsxs)(`button`,{onClick:q,className:v(`flex items-center gap-3 rounded-lg px-5 py-2.5 font-bold shadow-lg transition-all active:scale-95`,P?.kill_switch_active?`animate-pulse bg-red-500 text-white`:`border border-red-500/50 bg-shogun-card text-red-500 hover:bg-red-500 hover:text-white`),children:[(0,k.jsx)(l,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{className:`text-sm`,children:P?.kill_switch_active?e(`torii.reset_harakiri`):e(`torii.harakiri`)})]})]}),B&&(0,k.jsxs)(`div`,{className:v(`flex items-center gap-3 rounded-lg border p-4`,B.type===`success`?`border-green-500/20 bg-green-500/10 text-green-400`:`border-red-500/20 bg-red-500/10 text-red-400`),children:[B.type===`success`?(0,k.jsx)(r,{className:`h-5 w-5`}):(0,k.jsx)(f,{className:`h-5 w-5`}),(0,k.jsx)(`span`,{className:`text-sm font-bold`,children:B.text})]}),(0,k.jsxs)(`div`,{className:`shogun-card`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col justify-between gap-3 border-b border-shogun-border pb-5 md:flex-row md:items-center`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-bold text-shogun-text`,children:[(0,k.jsx)(C,{className:`h-5 w-5 text-shogun-gold`}),e(`torii.security_posture`,`Security Posture`)]}),(0,k.jsxs)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:[`Active: `,(0,k.jsx)(`span`,{className:`font-bold text-shogun-text`,children:Y||e(`common.loading`)}),M&&(0,k.jsx)(`span`,{className:`ml-2 animate-pulse`,children:e(`common.saving`)})]})]}),(0,k.jsxs)(`button`,{onClick:()=>y(`/toolgate`),className:`flex items-center gap-2 self-start rounded-lg border border-shogun-gold/30 bg-shogun-gold/5 px-3 py-2 text-xs font-bold text-shogun-gold hover:bg-shogun-gold/10`,children:[(0,k.jsx)(d,{className:`h-4 w-4`}),` Manage custom postures in ToolGate`]})]}),S?(0,k.jsx)(`div`,{className:`flex h-48 items-center justify-center`,children:(0,k.jsx)(u,{className:`h-7 w-7 animate-spin text-shogun-blue`})}):(0,k.jsxs)(`div`,{className:`mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:[H.map(e=>{let t=!P?.active_policy_id&&P?.active_tier===e.id;return(0,k.jsxs)(`button`,{onClick:()=>K({tier:e.id},e.label),disabled:M||t,className:v(`rounded-xl border p-4 text-left transition-all disabled:cursor-default`,t?`${e.bg} ${e.border}`:`border-shogun-border hover:border-shogun-subdued hover:bg-[#0a0e1a]`),children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:v(`text-xs font-bold tracking-widest`,e.color),children:e.label}),t?(0,k.jsx)(r,{className:v(`h-4 w-4`,e.color)}):(0,k.jsx)(`span`,{className:`h-4 w-4 rounded-full border border-shogun-border`})]}),(0,k.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-shogun-subdued`,children:e.description}),e.badge&&(0,k.jsx)(`span`,{className:v(`mt-3 inline-flex rounded border px-1.5 py-0.5 text-[8px] font-bold uppercase`,e.color,e.border),children:e.badge})]},e.id)}),U.map(e=>{let t=A.find(t=>t.id===e.tier)||A[2],n=P?.active_policy_id===e.id;return(0,k.jsxs)(`button`,{onClick:()=>K({policy_id:e.id},e.name),disabled:M||n,className:v(`rounded-xl border p-4 text-left transition-all disabled:cursor-default`,n?`border-violet-400/50 bg-violet-500/[0.08]`:`border-shogun-border hover:border-violet-400/40 hover:bg-violet-500/[0.04]`),children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(p,{className:`h-4 w-4 shrink-0 text-violet-300`}),(0,k.jsx)(`span`,{className:`truncate text-xs font-bold text-shogun-text`,children:e.name})]}),n?(0,k.jsx)(r,{className:`h-4 w-4 shrink-0 text-violet-300`}):(0,k.jsx)(`span`,{className:`h-4 w-4 shrink-0 rounded-full border border-shogun-border`})]}),(0,k.jsx)(`p`,{className:`mt-2 line-clamp-2 min-h-8 text-[10px] leading-relaxed text-shogun-subdued`,children:e.description||`Custom ToolGate posture`}),(0,k.jsxs)(`span`,{className:v(`mt-3 inline-flex rounded border px-1.5 py-0.5 text-[8px] font-bold uppercase`,t.color,t.border,t.bg),children:[`Custom · Base `,e.tier]})]},e.id)}),U.length===0&&(0,k.jsxs)(`button`,{onClick:()=>y(`/toolgate`),className:`flex min-h-32 flex-col items-center justify-center rounded-xl border border-dashed border-violet-400/25 p-4 text-center hover:bg-violet-500/[0.04]`,children:[(0,k.jsx)(p,{className:`h-5 w-5 text-violet-300`}),(0,k.jsx)(`span`,{className:`mt-2 text-xs font-bold text-violet-200`,children:`Create a custom posture`}),(0,k.jsx)(`span`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:`Configure it in ToolGate, then activate it here.`})]})]})]}),(0,k.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3`,children:[P&&(0,k.jsxs)(`div`,{className:`shogun-card space-y-3 lg:col-span-2`,children:[(0,k.jsx)(`h4`,{className:`text-xs font-bold uppercase tracking-widest text-shogun-subdued`,children:e(`torii.current_constraints`)}),(0,k.jsx)(`div`,{className:`grid gap-x-8 gap-y-3 md:grid-cols-2`,children:[{icon:w,label:e(`torii.filesystem`),value:P.filesystem_mode},{icon:T,label:e(`torii.network`),value:P.network_mode},{icon:m,label:e(`torii.shell`),value:P.shell_enabled?e(`torii.enabled`):e(`torii.disabled`)},{icon:h,label:e(`torii.auto_skills`),value:P.skill_auto_install?e(`torii.allowed`):e(`torii.off`)},{icon:b,label:e(`torii.max_agents`),value:String(P.max_active_subagents)},{icon:o,label:e(`torii.mail_access`),value:P.comms_read_email?P.comms_send_email?e(`torii.read_send`):e(`torii.read_only`):e(`torii.disabled`)},{icon:n,label:e(`torii.calendar_access`),value:P.comms_read_calendar?P.comms_create_events?e(`torii.full_access`):e(`torii.read_only`):e(`torii.disabled`)},{icon:i,label:e(`torii.cron_access`),value:P.comms_list_cron?P.comms_manage_cron?e(`torii.full_access`):e(`torii.read_only`):e(`torii.disabled`)},{icon:t,label:`Mado Browser`,value:P.mado_enabled?P.mado_headless_only?`Headless`:P.mado_autonomous_browsing?`Autonomous`:`Enabled`:e(`torii.disabled`)},{icon:a,label:`Ronin Desktop`,value:P.ronin_enabled?P.ronin_posture.replace(`_`,` `):e(`torii.disabled`)},{icon:s,label:`Ronin Sessions`,value:P.ronin_enabled?String(P.ronin_max_sessions):`—`},{icon:c,label:`Mouse/Keyboard`,value:P.ronin_enabled?P.ronin_mouse_enabled&&P.ronin_keyboard_enabled?`Enabled`:P.ronin_mouse_enabled?`Mouse Only`:P.ronin_keyboard_enabled?`Keyboard Only`:e(`torii.disabled`):`—`}].map(({icon:e,label:t,value:n})=>(0,k.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5 text-shogun-subdued`,children:[(0,k.jsx)(e,{className:`h-3 w-3`}),` `,t]}),(0,k.jsx)(`span`,{className:`font-mono font-bold text-shogun-text`,children:n})]},t))})]}),(0,k.jsxs)(`div`,{className:`shogun-card border-red-500/20 bg-red-500/5`,children:[(0,k.jsxs)(`h4`,{className:`mb-2 flex items-center gap-2 text-xs font-bold text-red-500`,children:[(0,k.jsx)(_,{className:`h-4 w-4`}),` `,e(`torii.emergency_protocols`)]}),(0,k.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued`,children:e(`torii.emergency_desc`)})]})]}),R&&(0,k.jsx)(D,{onConfirm:J,onCancel:()=>z(!1)})]})}export{j as Torii}; \ No newline at end of file diff --git a/frontend/dist/assets/Torii-CsF68Iui.js b/frontend/dist/assets/Torii-CsF68Iui.js deleted file mode 100644 index c5b29d4..0000000 --- a/frontend/dist/assets/Torii-CsF68Iui.js +++ /dev/null @@ -1 +0,0 @@ -import{o as e,r as t,t as n}from"./jsx-runtime-DmifIpYY.js";import{s as r}from"./chunk-OE4NN4TA-BT-WiWAe.js";import{t as i}from"./app-window-pINhreuP.js";import{t as a}from"./calendar-DL2fCMC-.js";import{t as o}from"./circle-check-D9mntLsp.js";import{t as s}from"./clock-B8iyCT3M.js";import{t as c}from"./crosshair-IDZ5dQs8.js";import{t as l}from"./globe-CSe1LLSr.js";import{t as u}from"./hard-drive-CKvWVafA.js";import{t as d}from"./mail-CjEwmRbK.js";import{t as f}from"./monitor-DhSxAiCm.js";import{t as p}from"./mouse-pointer-2-BrcQlceQ.js";import{t as m}from"./power-BmbVankB.js";import{t as h}from"./refresh-cw-CCrS0Omg.js";import{t as g}from"./settings-2-BKwYyfoW.js";import{t as _}from"./shield-alert-ClN8pu2X.js";import{t as v}from"./shield-B_MY4jWU.js";import{t as y}from"./sparkles-DddBjN-5.js";import{t as b}from"./terminal-CmBetb-2.js";import{t as x}from"./triangle-alert-BwzZbklP.js";import{t as S}from"./users-D7R1ctQe.js";import{t as C}from"./zap-BMpqZS6N.js";import{t as w}from"./utils-wrb6h48Y.js";import{r as T}from"./i18n-FxgwkwP0.js";import{t as E}from"./axios-BPyV2soB.js";import{t as D}from"./HarakiriModal-uap-l0fS.js";var O=e(t(),1),k=n(),A=[{id:`shrine`,label:`SHRINE`,color:`text-shogun-gold`,bg:`bg-shogun-gold/5`,border:`border-shogun-gold/40`},{id:`guarded`,label:`GUARDED`,color:`text-green-400`,bg:`bg-green-400/5`,border:`border-green-400/40`},{id:`tactical`,label:`TACTICAL`,color:`text-shogun-blue`,bg:`bg-shogun-blue/5`,border:`border-shogun-blue/40`},{id:`campaign`,label:`CAMPAIGN`,color:`text-orange-400`,bg:`bg-orange-400/5`,border:`border-orange-400/40`},{id:`ronin`,label:`RONIN`,color:`text-red-500`,bg:`bg-red-500/5`,border:`border-red-500/40`}];function j(){let{t:e}=T(),t=r(),[n,j]=(0,O.useState)(!0),[M,N]=(0,O.useState)(!1),[P,F]=(0,O.useState)(null),[I,L]=(0,O.useState)([]),[R,z]=(0,O.useState)(!1),[B,V]=(0,O.useState)(null),H=(0,O.useMemo)(()=>[{...A[0],badge:e(`torii.badge_max`),description:e(`torii.tier_shrine_desc`)},{...A[1],badge:``,description:e(`torii.tier_guarded_desc`)},{...A[2],badge:e(`torii.badge_default`),description:e(`torii.tier_tactical_desc`)},{...A[3],badge:``,description:e(`torii.tier_campaign_desc`)},{...A[4],badge:e(`torii.badge_unsafe`),description:e(`torii.tier_ronin_desc`)}],[e]),U=(0,O.useMemo)(()=>I.filter(e=>!e.is_builtin),[I]),W=(0,O.useCallback)(async()=>{j(!0);try{let[e,t]=await Promise.all([E.get(`/api/v1/security/posture`),E.get(`/api/v1/security/policies`)]);F(e.data.data),L(t.data.data||[])}catch{V({type:`error`,text:e(`torii.posture_failed`)})}finally{j(!1)}},[e]);(0,O.useEffect)(()=>{W()},[W]);let G=(e,t)=>{V({type:e,text:t}),window.setTimeout(()=>V(null),3500)},K=async(t,n)=>{if(!M){N(!0);try{F((await E.put(`/api/v1/security/posture/active`,t)).data.data),G(`success`,`${e(`torii.posture_updated`)} ${n}`)}catch(t){G(`error`,(E.isAxiosError(t)?t.response?.data?.detail:null)||e(`torii.posture_failed`))}finally{N(!1)}}},q=async()=>{if(P?.kill_switch_active){if(!confirm(e(`torii.reset_confirm`)))return;try{F((await E.delete(`/api/v1/security/kill-switch`)).data.data),G(`success`,e(`torii.reset_success`))}catch{G(`error`,e(`torii.reset_failed`))}return}z(!0)},J=async()=>{z(!1);try{F((await E.post(`/api/v1/security/kill-switch`)).data.data),G(`error`,e(`torii.harakiri_initiated`))}catch{G(`error`,e(`torii.harakiri_failed`))}},Y=P?.active_policy_name||P?.active_tier.toUpperCase();return(0,k.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-6 pb-12 animate-in fade-in duration-500`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col justify-between gap-4 md:flex-row md:items-center`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`h2`,{className:`shogun-title flex items-center gap-3 text-3xl font-bold`,children:[e(`torii.title`,`The Torii`),(0,k.jsx)(`span`,{className:`rounded border border-shogun-border bg-shogun-card px-2 py-0.5 text-[10px] font-normal uppercase tracking-[0.2em] text-shogun-subdued`,children:e(`torii.badge`)})]}),(0,k.jsx)(`p`,{className:`mt-1 text-sm text-shogun-subdued`,children:`Choose which security posture is active. Custom posture design belongs to ToolGate.`})]}),(0,k.jsxs)(`button`,{onClick:q,className:w(`flex items-center gap-3 rounded-lg px-5 py-2.5 font-bold shadow-lg transition-all active:scale-95`,P?.kill_switch_active?`animate-pulse bg-red-500 text-white`:`border border-red-500/50 bg-shogun-card text-red-500 hover:bg-red-500 hover:text-white`),children:[(0,k.jsx)(m,{className:`h-4 w-4`}),(0,k.jsx)(`span`,{className:`text-sm`,children:P?.kill_switch_active?e(`torii.reset_harakiri`):e(`torii.harakiri`)})]})]}),B&&(0,k.jsxs)(`div`,{className:w(`flex items-center gap-3 rounded-lg border p-4`,B.type===`success`?`border-green-500/20 bg-green-500/10 text-green-400`:`border-red-500/20 bg-red-500/10 text-red-400`),children:[B.type===`success`?(0,k.jsx)(o,{className:`h-5 w-5`}):(0,k.jsx)(_,{className:`h-5 w-5`}),(0,k.jsx)(`span`,{className:`text-sm font-bold`,children:B.text})]}),(0,k.jsxs)(`div`,{className:`shogun-card`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col justify-between gap-3 border-b border-shogun-border pb-5 md:flex-row md:items-center`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-bold text-shogun-text`,children:[(0,k.jsx)(v,{className:`h-5 w-5 text-shogun-gold`}),e(`torii.security_posture`,`Security Posture`)]}),(0,k.jsxs)(`p`,{className:`mt-1 text-xs text-shogun-subdued`,children:[`Active: `,(0,k.jsx)(`span`,{className:`font-bold text-shogun-text`,children:Y||e(`common.loading`)}),M&&(0,k.jsx)(`span`,{className:`ml-2 animate-pulse`,children:e(`common.saving`)})]})]}),(0,k.jsxs)(`button`,{onClick:()=>t(`/toolgate`),className:`flex items-center gap-2 self-start rounded-lg border border-shogun-gold/30 bg-shogun-gold/5 px-3 py-2 text-xs font-bold text-shogun-gold hover:bg-shogun-gold/10`,children:[(0,k.jsx)(g,{className:`h-4 w-4`}),` Manage custom postures in ToolGate`]})]}),n?(0,k.jsx)(`div`,{className:`flex h-48 items-center justify-center`,children:(0,k.jsx)(h,{className:`h-7 w-7 animate-spin text-shogun-blue`})}):(0,k.jsxs)(`div`,{className:`mt-5 grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:[H.map(e=>{let t=!P?.active_policy_id&&P?.active_tier===e.id;return(0,k.jsxs)(`button`,{onClick:()=>K({tier:e.id},e.label),disabled:M||t,className:w(`rounded-xl border p-4 text-left transition-all disabled:cursor-default`,t?`${e.bg} ${e.border}`:`border-shogun-border hover:border-shogun-subdued hover:bg-[#0a0e1a]`),children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,k.jsx)(`span`,{className:w(`text-xs font-bold tracking-widest`,e.color),children:e.label}),t?(0,k.jsx)(o,{className:w(`h-4 w-4`,e.color)}):(0,k.jsx)(`span`,{className:`h-4 w-4 rounded-full border border-shogun-border`})]}),(0,k.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-shogun-subdued`,children:e.description}),e.badge&&(0,k.jsx)(`span`,{className:w(`mt-3 inline-flex rounded border px-1.5 py-0.5 text-[8px] font-bold uppercase`,e.color,e.border),children:e.badge})]},e.id)}),U.map(e=>{let t=A.find(t=>t.id===e.tier)||A[2],n=P?.active_policy_id===e.id;return(0,k.jsxs)(`button`,{onClick:()=>K({policy_id:e.id},e.name),disabled:M||n,className:w(`rounded-xl border p-4 text-left transition-all disabled:cursor-default`,n?`border-violet-400/50 bg-violet-500/[0.08]`:`border-shogun-border hover:border-violet-400/40 hover:bg-violet-500/[0.04]`),children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(y,{className:`h-4 w-4 shrink-0 text-violet-300`}),(0,k.jsx)(`span`,{className:`truncate text-xs font-bold text-shogun-text`,children:e.name})]}),n?(0,k.jsx)(o,{className:`h-4 w-4 shrink-0 text-violet-300`}):(0,k.jsx)(`span`,{className:`h-4 w-4 shrink-0 rounded-full border border-shogun-border`})]}),(0,k.jsx)(`p`,{className:`mt-2 line-clamp-2 min-h-8 text-[10px] leading-relaxed text-shogun-subdued`,children:e.description||`Custom ToolGate posture`}),(0,k.jsxs)(`span`,{className:w(`mt-3 inline-flex rounded border px-1.5 py-0.5 text-[8px] font-bold uppercase`,t.color,t.border,t.bg),children:[`Custom · Base `,e.tier]})]},e.id)}),U.length===0&&(0,k.jsxs)(`button`,{onClick:()=>t(`/toolgate`),className:`flex min-h-32 flex-col items-center justify-center rounded-xl border border-dashed border-violet-400/25 p-4 text-center hover:bg-violet-500/[0.04]`,children:[(0,k.jsx)(y,{className:`h-5 w-5 text-violet-300`}),(0,k.jsx)(`span`,{className:`mt-2 text-xs font-bold text-violet-200`,children:`Create a custom posture`}),(0,k.jsx)(`span`,{className:`mt-1 text-[10px] text-shogun-subdued`,children:`Configure it in ToolGate, then activate it here.`})]})]})]}),(0,k.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-3`,children:[P&&(0,k.jsxs)(`div`,{className:`shogun-card space-y-3 lg:col-span-2`,children:[(0,k.jsx)(`h4`,{className:`text-xs font-bold uppercase tracking-widest text-shogun-subdued`,children:e(`torii.current_constraints`)}),(0,k.jsx)(`div`,{className:`grid gap-x-8 gap-y-3 md:grid-cols-2`,children:[{icon:u,label:e(`torii.filesystem`),value:P.filesystem_mode},{icon:l,label:e(`torii.network`),value:P.network_mode},{icon:b,label:e(`torii.shell`),value:P.shell_enabled?e(`torii.enabled`):e(`torii.disabled`)},{icon:C,label:e(`torii.auto_skills`),value:P.skill_auto_install?e(`torii.allowed`):e(`torii.off`)},{icon:S,label:e(`torii.max_agents`),value:String(P.max_active_subagents)},{icon:d,label:e(`torii.mail_access`),value:P.comms_read_email?P.comms_send_email?e(`torii.read_send`):e(`torii.read_only`):e(`torii.disabled`)},{icon:a,label:e(`torii.calendar_access`),value:P.comms_read_calendar?P.comms_create_events?e(`torii.full_access`):e(`torii.read_only`):e(`torii.disabled`)},{icon:s,label:e(`torii.cron_access`),value:P.comms_list_cron?P.comms_manage_cron?e(`torii.full_access`):e(`torii.read_only`):e(`torii.disabled`)},{icon:i,label:`Mado Browser`,value:P.mado_enabled?P.mado_headless_only?`Headless`:P.mado_autonomous_browsing?`Autonomous`:`Enabled`:e(`torii.disabled`)},{icon:c,label:`Ronin Desktop`,value:P.ronin_enabled?P.ronin_posture.replace(`_`,` `):e(`torii.disabled`)},{icon:f,label:`Ronin Sessions`,value:P.ronin_enabled?String(P.ronin_max_sessions):`—`},{icon:p,label:`Mouse/Keyboard`,value:P.ronin_enabled?P.ronin_mouse_enabled&&P.ronin_keyboard_enabled?`Enabled`:P.ronin_mouse_enabled?`Mouse Only`:P.ronin_keyboard_enabled?`Keyboard Only`:e(`torii.disabled`):`—`}].map(({icon:e,label:t,value:n})=>(0,k.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-1.5 text-shogun-subdued`,children:[(0,k.jsx)(e,{className:`h-3 w-3`}),` `,t]}),(0,k.jsx)(`span`,{className:`font-mono font-bold text-shogun-text`,children:n})]},t))})]}),(0,k.jsxs)(`div`,{className:`shogun-card border-red-500/20 bg-red-500/5`,children:[(0,k.jsxs)(`h4`,{className:`mb-2 flex items-center gap-2 text-xs font-bold text-red-500`,children:[(0,k.jsx)(x,{className:`h-4 w-4`}),` `,e(`torii.emergency_protocols`)]}),(0,k.jsx)(`p`,{className:`text-[10px] leading-relaxed text-shogun-subdued`,children:e(`torii.emergency_desc`)})]})]}),R&&(0,k.jsx)(D,{onConfirm:J,onCancel:()=>z(!1)})]})}export{j as Torii}; \ No newline at end of file diff --git a/frontend/dist/assets/Updates-D0KMbjgx.js b/frontend/dist/assets/Updates-D0KMbjgx.js new file mode 100644 index 0000000..6332dc1 --- /dev/null +++ b/frontend/dist/assets/Updates-D0KMbjgx.js @@ -0,0 +1 @@ +import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chart-column-DrS4GaUq.js";import{t as n}from"./circle-check-big-D8GMFSsk.js";import{t as r}from"./clock-DQ9Dz1_z.js";import{t as i}from"./external-link-pPtmvETu.js";import{t as a}from"./refresh-cw-Dm6S5UAJ.js";import{n as o,t as s}from"./toggle-right-CKFx_qbf.js";import{T as c,b as l,c as u,d,j as f,r as p,t as m}from"./index-Dy1E248t.js";var h=c(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),g=e(f(),1),_=m(),v=()=>{let{t:e}=p(),[c,f]=(0,g.useState)(null),[m,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(!1),j=async()=>{try{let e=await fetch(`/api/v1/system/college-telemetry`),t=await e.json();e.ok&&O(t.data)}catch{O(null)}},M=async()=>{if(D){A(!0);try{let e=await fetch(`/api/v1/system/college-telemetry`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:!D.enabled})}),t=await e.json();if(!e.ok)throw Error(t.detail||`HTTP ${e.status}`);O(t.data)}finally{A(!1)}}},N=async()=>{if(C.trim()){E(!0),S(null);try{let e=await fetch(`/api/v1/updates/credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({github_token:C.trim()})}),t=await e.json();if(!e.ok)throw Error(t.detail||`HTTP ${e.status}`);w(``),f(t.status),S(`Update access saved securely on this device.`)}catch(e){S(`Could not save update access: ${e.message}`)}finally{E(!1)}}},P=async(e=!1)=>{v(!0);try{let t=await fetch(`/api/v1/updates/check?force=${e}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.detail||`HTTP Error ${t.status}`)}let n=await t.json();f(n.data?n.data:n)}catch(e){f({update_available:!1,local_version:`error`,local_build:0,remote_version:null,remote_build:null,changelog:null,released:null,last_checked:new Date().toISOString(),error:e.message||`Failed to check updates`})}v(!1)};return(0,g.useEffect)(()=>{P(),j()},[]),(0,_.jsxs)(`div`,{className:`p-8 max-w-3xl mx-auto space-y-8`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,_.jsx)(l,{className:`w-6 h-6 text-shogun-gold`}),e(`updates_page.title`)]}),(0,_.jsx)(`p`,{className:`text-shogun-subdued mt-1`,children:e(`updates_page.subtitle`)})]}),(0,_.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6`,children:[(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:e(`updates_page.current_version`)}),(0,_.jsxs)(`p`,{className:`text-2xl font-bold text-white`,children:[`v`,c?.local_version||`...`,(0,_.jsxs)(`span`,{className:`text-sm text-shogun-subdued ml-2`,children:[`build `,c?.local_build??`...`]})]})]}),c?.remote_version&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:e(`updates_page.latest_available`)}),(0,_.jsxs)(`p`,{className:`text-2xl font-bold text-emerald-400`,children:[`v`,c.remote_version,(0,_.jsxs)(`span`,{className:`text-sm text-shogun-subdued ml-2`,children:[`build `,c.remote_build]})]})]})]}),(0,_.jsx)(`div`,{className:`mt-6 flex items-center gap-3`,children:c?.update_available?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(h,{className:`w-5 h-5 text-emerald-400`}),(0,_.jsx)(`span`,{className:`text-emerald-400 font-semibold`,children:e(`updates_page.new_version_available`)})]}):c?.error?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(u,{className:`w-5 h-5 text-amber-400`}),(0,_.jsx)(`span`,{className:`text-amber-400`,children:c.error})]}):c?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(n,{className:`w-5 h-5 text-emerald-400`}),(0,_.jsx)(`span`,{className:`text-shogun-subdued`,children:e(`updates_page.up_to_date`)})]}):null}),c?.last_checked&&(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-[11px] text-shogun-subdued`,children:[(0,_.jsx)(r,{className:`w-3 h-3`}),e(`updates_page.last_checked`),`: `,new Date(c.last_checked).toLocaleString()]})]}),c?.restart_required&&(0,_.jsxs)(`div`,{className:`bg-amber-500/10 border border-amber-500/30 rounded-xl p-4 text-sm text-amber-200`,children:[`Installed build `,c.installed_build,` is ready, but Shogun is still running build `,c.running_build,`. Restart Shogun to finish switching over.`]}),c?.auth_required&&(0,_.jsxs)(`div`,{className:`bg-amber-500/10 border border-amber-500/30 rounded-xl p-6 space-y-3`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold text-amber-300`,children:`Private update access`}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`This installation needs GitHub access to check and download updates. The token is encrypted and stored only on this device.`})]}),(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(`input`,{type:`password`,value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N()},placeholder:`GitHub access token`,autoComplete:`off`,className:`flex-1 bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text focus:border-amber-400 outline-none`}),(0,_.jsx)(`button`,{onClick:N,disabled:T||!C.trim(),className:`px-4 py-2 rounded-lg bg-amber-600 text-white text-sm font-semibold hover:bg-amber-500 disabled:opacity-50`,children:T?`Checking…`:`Save & check`})]})]}),c?.update_available&&c.changelog&&(0,_.jsxs)(`div`,{className:`bg-emerald-500/10 border border-emerald-500/30 rounded-xl p-6`,children:[(0,_.jsxs)(`h3`,{className:`text-sm font-semibold text-emerald-400 mb-2`,children:[e(`updates_page.whats_new`),` v`,c.remote_version]}),(0,_.jsx)(`p`,{className:`text-shogun-text text-sm`,children:c.changelog}),c.released&&(0,_.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued mt-3`,children:[e(`updates_page.released`),`: `,new Date(c.released).toLocaleDateString()]})]}),x&&(0,_.jsx)(`div`,{className:`rounded-xl p-4 border text-sm ${x.startsWith(`✅`)||x.startsWith(`Update access`)?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-red-500/10 border-red-500/30 text-red-300`}`,children:x}),(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsxs)(`button`,{onClick:()=>P(!0),disabled:m,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg bg-shogun-card border border-shogun-border text-shogun-text hover:border-shogun-blue transition-colors disabled:opacity-50`,children:[(0,_.jsx)(a,{className:`w-4 h-4 ${m?`animate-spin`:``}`}),e(m?`updates_page.checking`:`updates_page.check_for_updates`)]}),c?.update_available&&(0,_.jsxs)(`button`,{onClick:async()=>{if(confirm(e(`updates_page.install_confirm`))){b(!0),S(null);try{let e=await(await fetch(`/api/v1/updates/apply`,{method:`POST`})).json();if(e.success){let t=e.warnings?.length?` Warnings: ${e.warnings.join(` `)}`:``;S(`✅ Updated to v${e.new_version} (build ${e.new_build}). ${e.files_updated} files updated. Please restart Shogun.${t}`),P(!0),window.setTimeout(()=>window.location.reload(),1800)}else S(`❌ ${e.detail||`Update failed`}`)}catch(e){S(`❌ Update failed: ${e.message}`)}b(!1)}},disabled:y,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg bg-emerald-600 text-white font-semibold hover:bg-emerald-500 transition-colors disabled:opacity-50`,children:[(0,_.jsx)(l,{className:`w-4 h-4 ${y?`animate-bounce`:``}`}),e(y?`updates_page.installing`:`updates_page.install_update`)]})]}),(0,_.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-5`,children:[(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(`div`,{className:`rounded-lg bg-cyan-500/10 p-2.5 text-cyan-300`,children:(0,_.jsx)(t,{className:`w-5 h-5`})}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold text-white`,children:`OpenClaw College ecosystem intelligence`}),(0,_.jsx)(`p`,{className:`mt-1 max-w-xl text-xs leading-relaxed text-shogun-subdued`,children:`Contribute anonymous, coarse model-performance signals to ecosystem benchmarks. Sharing is on by default and can be disabled at any time.`})]})]}),(0,_.jsx)(`button`,{onClick:M,disabled:!D||k,className:`shrink-0 text-cyan-300 disabled:opacity-40`,title:D?.enabled?`Disable ecosystem sharing`:`Enable ecosystem sharing`,children:D?.enabled?(0,_.jsx)(s,{className:`h-9 w-9`}):(0,_.jsx)(o,{className:`h-9 w-9 text-shogun-subdued`})})]}),(0,_.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/20 bg-emerald-500/[0.04] p-4`,children:[(0,_.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-wider text-emerald-300`,children:[(0,_.jsx)(d,{className:`h-3.5 w-3.5`}),` Never shared`]}),(0,_.jsx)(`p`,{className:`text-[11px] leading-relaxed text-shogun-subdued`,children:`Prompts, outputs, files, agent names, credentials, exact IP addresses, or error contents.`})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-cyan-500/20 bg-cyan-500/[0.04] p-4`,children:[(0,_.jsx)(`div`,{className:`mb-2 text-[10px] font-bold uppercase tracking-wider text-cyan-300`,children:`Coarse signals only`}),(0,_.jsx)(`p`,{className:`text-[11px] leading-relaxed text-shogun-subdued`,children:`Model, provider, task category, success, bucketed usage, local/cloud, country code, Shogun version, and a weekly rotating anonymous ID.`})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-shogun-subdued`,children:[(0,_.jsxs)(`span`,{children:[`Status: `,(0,_.jsx)(`strong`,{className:D?.enabled?`text-emerald-300`:`text-shogun-text`,children:D?.enabled?`Contributing anonymously`:`Not sharing`})]}),(0,_.jsxs)(`a`,{href:`https://www.openclawcollege.com/#/dashboard`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-cyan-300 hover:underline`,children:[`View ecosystem insights `,(0,_.jsx)(i,{className:`h-3 w-3`})]})]})]}),(0,_.jsxs)(`div`,{className:`text-[11px] text-shogun-subdued border-t border-shogun-border/30 pt-4 space-y-1`,children:[(0,_.jsx)(`p`,{children:e(`updates_page.info_auto_check`)}),(0,_.jsx)(`p`,{children:e(`updates_page.info_preserve`)}),(0,_.jsx)(`p`,{children:e(`updates_page.info_restart`)})]})]})};export{v as Updates}; \ No newline at end of file diff --git a/frontend/dist/assets/Updates-DNQTq8gN.js b/frontend/dist/assets/Updates-DNQTq8gN.js deleted file mode 100644 index 5fb1ba3..0000000 --- a/frontend/dist/assets/Updates-DNQTq8gN.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e,o as t,r as n,t as r}from"./jsx-runtime-DmifIpYY.js";import{t as i}from"./chart-column-gDy__4Qa.js";import{t as a}from"./circle-check-big-CjUNZrY8.js";import{t as o}from"./clock-B8iyCT3M.js";import{t as s}from"./download-OoiqiOHD.js";import{t as c}from"./external-link-Cfo2qohD.js";import{t as l}from"./refresh-cw-CCrS0Omg.js";import{t as u}from"./shield-check-4WxAMs16.js";import{n as d,t as f}from"./toggle-right-r1O78oQo.js";import{t as p}from"./triangle-alert-BwzZbklP.js";import{r as m}from"./i18n-FxgwkwP0.js";var h=e(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),g=t(n(),1),_=r(),v=()=>{let{t:e}=m(),[t,n]=(0,g.useState)(null),[r,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(null),[k,A]=(0,g.useState)(!1),j=async()=>{try{let e=await fetch(`/api/v1/system/college-telemetry`),t=await e.json();e.ok&&O(t.data)}catch{O(null)}},M=async()=>{if(D){A(!0);try{let e=await fetch(`/api/v1/system/college-telemetry`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:!D.enabled})}),t=await e.json();if(!e.ok)throw Error(t.detail||`HTTP ${e.status}`);O(t.data)}finally{A(!1)}}},N=async()=>{if(C.trim()){E(!0),S(null);try{let e=await fetch(`/api/v1/updates/credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({github_token:C.trim()})}),t=await e.json();if(!e.ok)throw Error(t.detail||`HTTP ${e.status}`);w(``),n(t.status),S(`Update access saved securely on this device.`)}catch(e){S(`Could not save update access: ${e.message}`)}finally{E(!1)}}},P=async(e=!1)=>{v(!0);try{let t=await fetch(`/api/v1/updates/check?force=${e}`);if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.detail||`HTTP Error ${t.status}`)}let r=await t.json();n(r.data?r.data:r)}catch(e){n({update_available:!1,local_version:`error`,local_build:0,remote_version:null,remote_build:null,changelog:null,released:null,last_checked:new Date().toISOString(),error:e.message||`Failed to check updates`})}v(!1)};return(0,g.useEffect)(()=>{P(),j()},[]),(0,_.jsxs)(`div`,{className:`p-8 max-w-3xl mx-auto space-y-8`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,_.jsx)(s,{className:`w-6 h-6 text-shogun-gold`}),e(`updates_page.title`)]}),(0,_.jsx)(`p`,{className:`text-shogun-subdued mt-1`,children:e(`updates_page.subtitle`)})]}),(0,_.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6`,children:[(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:e(`updates_page.current_version`)}),(0,_.jsxs)(`p`,{className:`text-2xl font-bold text-white`,children:[`v`,t?.local_version||`...`,(0,_.jsxs)(`span`,{className:`text-sm text-shogun-subdued ml-2`,children:[`build `,t?.local_build??`...`]})]})]}),t?.remote_version&&(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-shogun-subdued mb-1`,children:e(`updates_page.latest_available`)}),(0,_.jsxs)(`p`,{className:`text-2xl font-bold text-emerald-400`,children:[`v`,t.remote_version,(0,_.jsxs)(`span`,{className:`text-sm text-shogun-subdued ml-2`,children:[`build `,t.remote_build]})]})]})]}),(0,_.jsx)(`div`,{className:`mt-6 flex items-center gap-3`,children:t?.update_available?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(h,{className:`w-5 h-5 text-emerald-400`}),(0,_.jsx)(`span`,{className:`text-emerald-400 font-semibold`,children:e(`updates_page.new_version_available`)})]}):t?.error?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(p,{className:`w-5 h-5 text-amber-400`}),(0,_.jsx)(`span`,{className:`text-amber-400`,children:t.error})]}):t?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(a,{className:`w-5 h-5 text-emerald-400`}),(0,_.jsx)(`span`,{className:`text-shogun-subdued`,children:e(`updates_page.up_to_date`)})]}):null}),t?.last_checked&&(0,_.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-[11px] text-shogun-subdued`,children:[(0,_.jsx)(o,{className:`w-3 h-3`}),e(`updates_page.last_checked`),`: `,new Date(t.last_checked).toLocaleString()]})]}),t?.restart_required&&(0,_.jsxs)(`div`,{className:`bg-amber-500/10 border border-amber-500/30 rounded-xl p-4 text-sm text-amber-200`,children:[`Installed build `,t.installed_build,` is ready, but Shogun is still running build `,t.running_build,`. Restart Shogun to finish switching over.`]}),t?.auth_required&&(0,_.jsxs)(`div`,{className:`bg-amber-500/10 border border-amber-500/30 rounded-xl p-6 space-y-3`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold text-amber-300`,children:`Private update access`}),(0,_.jsx)(`p`,{className:`text-xs text-shogun-subdued mt-1`,children:`This installation needs GitHub access to check and download updates. The token is encrypted and stored only on this device.`})]}),(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(`input`,{type:`password`,value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&N()},placeholder:`GitHub access token`,autoComplete:`off`,className:`flex-1 bg-shogun-bg border border-shogun-border rounded-lg px-3 py-2 text-sm text-shogun-text focus:border-amber-400 outline-none`}),(0,_.jsx)(`button`,{onClick:N,disabled:T||!C.trim(),className:`px-4 py-2 rounded-lg bg-amber-600 text-white text-sm font-semibold hover:bg-amber-500 disabled:opacity-50`,children:T?`Checking…`:`Save & check`})]})]}),t?.update_available&&t.changelog&&(0,_.jsxs)(`div`,{className:`bg-emerald-500/10 border border-emerald-500/30 rounded-xl p-6`,children:[(0,_.jsxs)(`h3`,{className:`text-sm font-semibold text-emerald-400 mb-2`,children:[e(`updates_page.whats_new`),` v`,t.remote_version]}),(0,_.jsx)(`p`,{className:`text-shogun-text text-sm`,children:t.changelog}),t.released&&(0,_.jsxs)(`p`,{className:`text-[11px] text-shogun-subdued mt-3`,children:[e(`updates_page.released`),`: `,new Date(t.released).toLocaleDateString()]})]}),x&&(0,_.jsx)(`div`,{className:`rounded-xl p-4 border text-sm ${x.startsWith(`✅`)||x.startsWith(`Update access`)?`bg-emerald-500/10 border-emerald-500/30 text-emerald-300`:`bg-red-500/10 border-red-500/30 text-red-300`}`,children:x}),(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsxs)(`button`,{onClick:()=>P(!0),disabled:r,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg bg-shogun-card border border-shogun-border text-shogun-text hover:border-shogun-blue transition-colors disabled:opacity-50`,children:[(0,_.jsx)(l,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),e(r?`updates_page.checking`:`updates_page.check_for_updates`)]}),t?.update_available&&(0,_.jsxs)(`button`,{onClick:async()=>{if(confirm(e(`updates_page.install_confirm`))){b(!0),S(null);try{let e=await(await fetch(`/api/v1/updates/apply`,{method:`POST`})).json();if(e.success){let t=e.warnings?.length?` Warnings: ${e.warnings.join(` `)}`:``;S(`✅ Updated to v${e.new_version} (build ${e.new_build}). ${e.files_updated} files updated. Please restart Shogun.${t}`),P(!0),window.setTimeout(()=>window.location.reload(),1800)}else S(`❌ ${e.detail||`Update failed`}`)}catch(e){S(`❌ Update failed: ${e.message}`)}b(!1)}},disabled:y,className:`flex items-center gap-2 px-5 py-2.5 rounded-lg bg-emerald-600 text-white font-semibold hover:bg-emerald-500 transition-colors disabled:opacity-50`,children:[(0,_.jsx)(s,{className:`w-4 h-4 ${y?`animate-bounce`:``}`}),e(y?`updates_page.installing`:`updates_page.install_update`)]})]}),(0,_.jsxs)(`div`,{className:`bg-shogun-card border border-shogun-border rounded-xl p-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between gap-5`,children:[(0,_.jsxs)(`div`,{className:`flex gap-3`,children:[(0,_.jsx)(`div`,{className:`rounded-lg bg-cyan-500/10 p-2.5 text-cyan-300`,children:(0,_.jsx)(i,{className:`w-5 h-5`})}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold text-white`,children:`OpenClaw College ecosystem intelligence`}),(0,_.jsx)(`p`,{className:`mt-1 max-w-xl text-xs leading-relaxed text-shogun-subdued`,children:`Contribute anonymous, coarse model-performance signals to ecosystem benchmarks. Sharing is on by default and can be disabled at any time.`})]})]}),(0,_.jsx)(`button`,{onClick:M,disabled:!D||k,className:`shrink-0 text-cyan-300 disabled:opacity-40`,title:D?.enabled?`Disable ecosystem sharing`:`Enable ecosystem sharing`,children:D?.enabled?(0,_.jsx)(f,{className:`h-9 w-9`}):(0,_.jsx)(d,{className:`h-9 w-9 text-shogun-subdued`})})]}),(0,_.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg border border-emerald-500/20 bg-emerald-500/[0.04] p-4`,children:[(0,_.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-[10px] font-bold uppercase tracking-wider text-emerald-300`,children:[(0,_.jsx)(u,{className:`h-3.5 w-3.5`}),` Never shared`]}),(0,_.jsx)(`p`,{className:`text-[11px] leading-relaxed text-shogun-subdued`,children:`Prompts, outputs, files, agent names, credentials, exact IP addresses, or error contents.`})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-cyan-500/20 bg-cyan-500/[0.04] p-4`,children:[(0,_.jsx)(`div`,{className:`mb-2 text-[10px] font-bold uppercase tracking-wider text-cyan-300`,children:`Coarse signals only`}),(0,_.jsx)(`p`,{className:`text-[11px] leading-relaxed text-shogun-subdued`,children:`Model, provider, task category, success, bucketed usage, local/cloud, country code, Shogun version, and a weekly rotating anonymous ID.`})]})]}),(0,_.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-shogun-subdued`,children:[(0,_.jsxs)(`span`,{children:[`Status: `,(0,_.jsx)(`strong`,{className:D?.enabled?`text-emerald-300`:`text-shogun-text`,children:D?.enabled?`Contributing anonymously`:`Not sharing`})]}),(0,_.jsxs)(`a`,{href:`https://www.openclawcollege.com/#/dashboard`,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-cyan-300 hover:underline`,children:[`View ecosystem insights `,(0,_.jsx)(c,{className:`h-3 w-3`})]})]})]}),(0,_.jsxs)(`div`,{className:`text-[11px] text-shogun-subdued border-t border-shogun-border/30 pt-4 space-y-1`,children:[(0,_.jsx)(`p`,{children:e(`updates_page.info_auto_check`)}),(0,_.jsx)(`p`,{children:e(`updates_page.info_preserve`)}),(0,_.jsx)(`p`,{children:e(`updates_page.info_restart`)})]})]})};export{v as Updates}; \ No newline at end of file diff --git a/frontend/dist/assets/activity-D6ZKsL_W.js b/frontend/dist/assets/activity-D6ZKsL_W.js deleted file mode 100644 index 17edc42..0000000 --- a/frontend/dist/assets/activity-D6ZKsL_W.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/app-window-BFcF7ht7.js b/frontend/dist/assets/app-window-BFcF7ht7.js new file mode 100644 index 0000000..5c55494 --- /dev/null +++ b/frontend/dist/assets/app-window-BFcF7ht7.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/app-window-pINhreuP.js b/frontend/dist/assets/app-window-pINhreuP.js deleted file mode 100644 index 1df27df..0000000 --- a/frontend/dist/assets/app-window-pINhreuP.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`app-window`,[[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}],[`path`,{d:`M10 4v4`,key:`pp8u80`}],[`path`,{d:`M2 8h20`,key:`d11cs7`}],[`path`,{d:`M6 4v4`,key:`1svtjw`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/archive-BOJnkAd3.js b/frontend/dist/assets/archive-BOJnkAd3.js new file mode 100644 index 0000000..2c46453 --- /dev/null +++ b/frontend/dist/assets/archive-BOJnkAd3.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/archive-CCh8OMBK.js b/frontend/dist/assets/archive-CCh8OMBK.js deleted file mode 100644 index 64bc2a8..0000000 --- a/frontend/dist/assets/archive-CCh8OMBK.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/arrow-right-left-B7B694Vj.js b/frontend/dist/assets/arrow-right-left-B7B694Vj.js new file mode 100644 index 0000000..00b9935 --- /dev/null +++ b/frontend/dist/assets/arrow-right-left-B7B694Vj.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/arrow-right-left-CsrIxDbC.js b/frontend/dist/assets/arrow-right-left-CsrIxDbC.js deleted file mode 100644 index 3a18039..0000000 --- a/frontend/dist/assets/arrow-right-left-CsrIxDbC.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/axios-BGmZl9Qd.js b/frontend/dist/assets/axios-BGmZl9Qd.js new file mode 100644 index 0000000..1b2ad9e --- /dev/null +++ b/frontend/dist/assets/axios-BGmZl9Qd.js @@ -0,0 +1,9 @@ +import{n as e}from"./rolldown-runtime-QTnfLwEv.js";function t(e,t){return function(){return e.apply(t,arguments)}}var{toString:n}=Object.prototype,{getPrototypeOf:r}=Object,{iterator:i,toStringTag:a}=Symbol,o=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),s=(e,t)=>{let n=e,i=[];for(;n!=null&&n!==Object.prototype;){if(i.indexOf(n)!==-1)return!1;if(i.push(n),o(n,t))return!0;n=r(n)}return!1},c=(e,t)=>e!=null&&s(e,t)?e[t]:void 0,l=(e=>t=>{let r=n.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),u=e=>(e=e.toLowerCase(),t=>l(t)===e),d=e=>t=>typeof t===e,{isArray:f}=Array,p=d(`undefined`);function m(e){return e!==null&&!p(e)&&e.constructor!==null&&!p(e.constructor)&&v(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var h=u(`ArrayBuffer`);function g(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&h(e.buffer),t}var _=d(`string`),v=d(`function`),y=d(`number`),b=e=>typeof e==`object`&&!!e,x=e=>e===!0||e===!1,S=e=>{if(!b(e))return!1;let t=r(e);return(t===null||t===Object.prototype||r(t)===null)&&!s(e,a)&&!s(e,i)},ee=e=>{if(!b(e)||m(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},C=u(`Date`),w=u(`File`),T=e=>!!(e&&e.uri!==void 0),E=e=>e&&e.getParts!==void 0,te=u(`Blob`),ne=u(`FileList`),D=e=>b(e)&&v(e.pipe);function O(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var k=O(),A=k.FormData===void 0?void 0:k.FormData,j=e=>{if(!e)return!1;if(A&&e instanceof A)return!0;let t=r(e);if(!t||t===Object.prototype||!v(e.append))return!1;let n=l(e);return n===`formdata`||n===`object`&&v(e.toString)&&e.toString()===`[object FormData]`},re=u(`URLSearchParams`),[ie,ae,M,oe]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(u),N=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function P(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),f(e))for(r=0,i=e.length;r0;)if(i=n[r],t===i.toLowerCase())return i;return null}var F=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,ce=e=>!p(e)&&e!==F;function le(...e){let{caseless:t,skipUndefined:n}=ce(this)&&this||{},r={},i=(e,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=t&&typeof i==`string`&&se(r,i)||i,s=o(r,a)?r[a]:void 0;S(s)&&S(e)?r[a]=le(s,e):S(e)?r[a]=le({},e):f(e)?r[a]=e.slice():(!n||!p(e))&&(r[a]=e)};for(let t=0,n=e.length;t(P(n,(n,i)=>{r&&v(n)?Object.defineProperty(e,i,{__proto__:null,value:t(n,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{__proto__:null,value:n,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),e),de=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),fe=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,"constructor",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,"super",{__proto__:null,value:t.prototype}),n&&Object.assign(e.prototype,n)},pe=(e,t,n,i)=>{let a,o,s,c={};if(t||={},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),o=a.length;o-->0;)s=a[o],(!i||i(s,e,t))&&!c[s]&&(t[s]=e[s],c[s]=!0);e=n!==!1&&r(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},me=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},he=e=>{if(!e)return null;if(f(e))return e;let t=e.length;if(!y(t))return null;let n=Array(t);for(;t-->0;)n[t]=e[t];return n},ge=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&r(Uint8Array)),_e=(e,t)=>{let n=(e&&e[i]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},ve=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},ye=u(`HTMLFormElement`),be=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),{propertyIsEnumerable:xe}=Object.prototype,Se=u(`RegExp`),Ce=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};P(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},we=e=>{Ce(e,(t,n)=>{if(v(e)&&[`arguments`,`caller`,`callee`].includes(n))return!1;let r=e[n];if(v(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},Te=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return f(e)?r(e):r(String(e).split(t)),n},Ee=()=>{},De=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Oe(e){return!!(e&&v(e.append)&&e[a]===`FormData`&&e[i])}var ke=e=>{let t=new WeakSet,n=e=>{if(b(e)){if(t.has(e))return;if(m(e))return e;if(!(`toJSON`in e)){t.add(e);let r=f(e)?[]:{};return P(e,(e,t)=>{let i=n(e);!p(i)&&(r[t]=i)}),t.delete(e),r}}return e};return n(e)},Ae=u(`AsyncFunction`),je=e=>e&&(b(e)||v(e))&&v(e.then)&&v(e.catch),Me=((e,t)=>e?setImmediate:t?((e,t)=>(F.addEventListener(`message`,({source:n,data:r})=>{n===F&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),F.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,v(F.postMessage)),Ne=typeof queueMicrotask<`u`?queueMicrotask.bind(F):typeof process<`u`&&process.nextTick||Me,Pe=e=>e!=null&&v(e[i]),I={isArray:f,isArrayBuffer:h,isBuffer:m,isFormData:j,isArrayBufferView:g,isString:_,isNumber:y,isBoolean:x,isObject:b,isPlainObject:S,isEmptyObject:ee,isReadableStream:ie,isRequest:ae,isResponse:M,isHeaders:oe,isUndefined:p,isDate:C,isFile:w,isReactNativeBlob:T,isReactNative:E,isBlob:te,isRegExp:Se,isFunction:v,isStream:D,isURLSearchParams:re,isTypedArray:ge,isFileList:ne,forEach:P,merge:le,extend:ue,trim:N,stripBOM:de,inherits:fe,toFlatObject:pe,kindOf:l,kindOfTest:u,endsWith:me,toArray:he,forEachEntry:_e,matchAll:ve,isHTMLForm:ye,hasOwnProperty:o,hasOwnProp:o,hasOwnInPrototypeChain:s,getSafeProp:c,reduceDescriptors:Ce,freezeMethods:we,toObjectSet:Te,toCamelCase:be,noop:Ee,toFiniteNumber:De,findKey:se,global:F,isContextDefined:ce,isSpecCompliantForm:Oe,toJSONObject:ke,isAsyncFn:Ae,isThenable:je,setImmediate:Me,asap:Ne,isIterable:Pe,isSafeIterable:e=>e!=null&&s(e,i)&&Pe(e)},Fe=I.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),Ie=e=>{let t={},n,r,i;return e&&e.split(` +`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&Fe[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t};function Le(e){let t=0,n=e.length;for(;tt;){let t=e.charCodeAt(n-1);if(t!==9&&t!==32)break;--n}return t===0&&n===e.length?e:e.slice(t,n)}var Re=RegExp(`[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+`,`g`),ze=RegExp(`[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+`,`g`);function Be(e,t){return I.isArray(e)?e.map(e=>Be(e,t)):Le(String(e).replace(t,``))}var Ve=e=>Be(e,Re),He=e=>Be(e,ze);function Ue(e){let t=Object.create(null);return I.forEach(e.toJSON(),(e,n)=>{t[n]=He(e)}),t}var We=Symbol(`internals`);function L(e){return e&&String(e).trim().toLowerCase()}function R(e){return e===!1||e==null?e:I.isArray(e)?e.map(R):Ve(String(e))}function Ge(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var Ke=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function qe(e,t,n,r,i){if(I.isFunction(r))return r.call(this,t,n);if(i&&(t=n),I.isString(t)){if(I.isString(r))return t.indexOf(r)!==-1;if(I.isRegExp(r))return r.test(t)}}function Je(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function Ye(e,t){let n=I.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{__proto__:null,value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var z=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=L(t);if(!i)return;let a=I.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(r[a||t]=R(e))}let a=(e,t)=>I.forEach(e,(e,n)=>i(e,n,t));if(I.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(I.isString(e)&&(e=e.trim())&&!Ke(e))a(Ie(e),t);else if(I.isObject(e)&&I.isSafeIterable(e)){let n=Object.create(null),r,i;for(let t of e){if(!I.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);i=t[0],I.hasOwnProp(n,i)?(r=n[i],n[i]=I.isArray(r)?[...r,t[1]]:[r,t[1]]):n[i]=t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=L(e),e){let n=I.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return Ge(e);if(I.isFunction(t))return t.call(this,e,n);if(I.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=L(e),e){let n=I.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||qe(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=L(e),e){let i=I.findKey(n,e);i&&(!t||qe(n,n[i],i,t))&&(delete n[i],r=!0)}}return I.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||qe(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return I.forEach(this,(r,i)=>{let a=I.findKey(n,i);if(a){t[a]=R(r),delete t[i];return}let o=e?Je(i):String(i).trim();o!==i&&delete t[i],t[o]=R(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return I.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&I.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(` +`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[We]=this[We]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=L(e);t[r]||(Ye(n,e),t[r]=!0)}return I.isArray(e)?e.forEach(r):r(e),this}};z.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),I.reduceDescriptors(z.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),I.freezeMethods(z);var Xe=`[REDACTED ****]`;function Ze(e){if(I.hasOwnProp(e,`toJSON`))return!0;let t=Object.getPrototypeOf(e);for(;t&&t!==Object.prototype;){if(I.hasOwnProp(t,`toJSON`))return!0;t=Object.getPrototypeOf(t)}return!1}function Qe(e,t){let n=new Set(t.map(e=>String(e).toLowerCase())),r=[],i=e=>{if(typeof e!=`object`||!e||I.isBuffer(e))return e;if(r.indexOf(e)!==-1)return;e instanceof z&&(e=e.toJSON()),r.push(e);let t;if(I.isArray(e))t=[],e.forEach((e,n)=>{let r=i(e);I.isUndefined(r)||(t[n]=r)});else{if(!I.isPlainObject(e)&&Ze(e))return r.pop(),e;t=Object.create(null);for(let[r,a]of Object.entries(e)){let e=n.has(r.toLowerCase())?Xe:i(a);I.isUndefined(e)||(t[r]=e)}}return r.pop(),t};return i(e)}var B=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return Object.defineProperty(s,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){let e=this.config,t=e&&I.hasOwnProp(e,`redact`)?e.redact:void 0,n=I.isArray(t)&&t.length>0?Qe(e,t):I.toJSONObject(e);return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:n,code:this.code,status:this.status}}};B.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,B.ERR_BAD_OPTION=`ERR_BAD_OPTION`,B.ECONNABORTED=`ECONNABORTED`,B.ETIMEDOUT=`ETIMEDOUT`,B.ECONNREFUSED=`ECONNREFUSED`,B.ERR_NETWORK=`ERR_NETWORK`,B.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,B.ERR_DEPRECATED=`ERR_DEPRECATED`,B.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,B.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,B.ERR_CANCELED=`ERR_CANCELED`,B.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,B.ERR_INVALID_URL=`ERR_INVALID_URL`,B.ERR_FORM_DATA_DEPTH_EXCEEDED=`ERR_FORM_DATA_DEPTH_EXCEEDED`;function $e(e){return I.isPlainObject(e)||I.isArray(e)}function et(e){return I.endsWith(e,`[]`)?e.slice(0,-2):e}function tt(e,t,n){return e?e.concat(t).map(function(e,t){return e=et(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function nt(e){return I.isArray(e)&&!e.some($e)}var rt=I.toFlatObject(I,{},null,function(e){return/^is[A-Z]/.test(e)});function V(e,t,n){if(!I.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=I.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!I.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||m,a=n.dots,o=n.indexes,s=n.Blob||typeof Blob<`u`&&Blob,c=n.maxDepth===void 0?100:n.maxDepth,l=s&&I.isSpecCompliantForm(t),u=[];if(!I.isFunction(i))throw TypeError(`visitor must be a function`);function d(e){if(e===null)return``;if(I.isDate(e))return e.toISOString();if(I.isBoolean(e))return e.toString();if(!l&&I.isBlob(e))throw new B(`Blob is not supported. Use a Buffer instead.`);if(I.isArrayBuffer(e)||I.isTypedArray(e)){if(l&&typeof s==`function`)return new s([e]);if(typeof Buffer<`u`)return Buffer.from(e);throw new B(`Blob is not supported. Use a Buffer instead.`,B.ERR_NOT_SUPPORT)}return e}function f(e){if(e>c)throw new B(`Object is too deeply nested (`+e+` levels). Max depth: `+c,B.ERR_FORM_DATA_DEPTH_EXCEEDED)}function p(e,t){if(c===1/0)return JSON.stringify(e);let n=[];return JSON.stringify(e,function(e,r){if(!I.isObject(r))return r;for(;n.length&&n[n.length-1]!==this;)n.pop();return n.push(r),f(t+n.length-1),r})}function m(e,n,i){let s=e;if(I.isReactNative(t)&&I.isReactNativeBlob(e))return t.append(tt(i,n,a),d(e)),!1;if(e&&!i&&typeof e==`object`){if(I.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=p(e,1);else if(I.isArray(e)&&nt(e)||(I.isFileList(e)||I.endsWith(n,`[]`))&&(s=I.toArray(e)))return n=et(n),s.forEach(function(e,r){!(I.isUndefined(e)||e===null)&&t.append(o===!0?tt([n],r,a):o===null?n:n+`[]`,d(e))}),!1}return $e(e)?!0:(t.append(tt(i,n,a),d(e)),!1)}let h=Object.assign(rt,{defaultVisitor:m,convertValue:d,isVisitable:$e});function g(e,n,r=0){if(!I.isUndefined(e)){if(f(r),u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),I.forEach(e,function(e,a){(!(I.isUndefined(e)||e===null)&&i.call(t,e,I.isString(a)?a.trim():a,n,h))===!0&&g(e,n?n.concat(a):[a],r+1)}),u.pop()}}if(!I.isObject(e))throw TypeError(`data must be an object`);return g(e),t}function it(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`};return encodeURIComponent(e).replace(/[!'()~]|%20/g,function(e){return t[e]})}function at(e,t){this._pairs=[],e&&V(e,this,t)}var ot=at.prototype;ot.append=function(e,t){this._pairs.push([e,t])},ot.toString=function(e){let t=e?t=>e.call(this,t,it):it;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function st(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function ct(e,t,n){if(!t)return e;e||=``;let r=I.isFunction(n)?{serialize:n}:n,i=I.getSafeProp(r,`encode`)||st,a=I.getSafeProp(r,`serialize`),o;if(o=a?a(t,r):I.isURLSearchParams(t)?t.toString():new at(t,r).toString(i),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var lt=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){I.forEach(this.handlers,function(t){t!==null&&e(t)})}},ut={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},dt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:at,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},ft=e({hasBrowserEnv:()=>pt,hasStandardBrowserEnv:()=>ht,hasStandardBrowserWebWorkerEnv:()=>gt,navigator:()=>mt,origin:()=>_t}),pt=typeof window<`u`&&typeof document<`u`,mt=typeof navigator==`object`&&navigator||void 0,ht=pt&&(!mt||[`ReactNative`,`NativeScript`,`NS`].indexOf(mt.product)<0),gt=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,_t=pt&&window.location.href||`http://localhost`,H={...ft,...dt};function vt(e,t){return V(e,new H.classes.URLSearchParams,{visitor:function(e,t,n,r){return H.isNode&&I.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}var yt=100;function bt(e){if(e>yt)throw new B(`FormData field is too deeply nested (`+e+` levels). Max depth: `+yt,B.ERR_FORM_DATA_DEPTH_EXCEEDED)}function xt(e){let t=[],n=/\w+|\[(\w*)]/g,r;for(;(r=n.exec(e))!==null;)bt(t.length),t.push(r[0]===`[]`?``:r[1]||r[0]);return t}function St(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r=e.length;return a=!a&&I.isArray(r)?r.length:a,s?(I.hasOwnProp(r,a)?r[a]=I.isArray(r[a])?r[a].concat(n):[r[a],n]:r[a]=n,!o):((!I.hasOwnProp(r,a)||!I.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&I.isArray(r[a])&&(r[a]=St(r[a])),!o)}if(I.isFormData(e)&&I.isFunction(e.entries)){let n={};return I.forEachEntry(e,(e,r)=>{t(xt(e),r,n,0)}),n}return null}var U=(e,t)=>e!=null&&I.hasOwnProp(e,t)?e[t]:void 0;function wt(e,t,n){if(I.isString(e))try{return(t||JSON.parse)(e),I.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var W={transitional:ut,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=I.isObject(e);if(i&&I.isHTMLForm(e)&&(e=new FormData(e)),I.isFormData(e))return r?JSON.stringify(Ct(e)):e;if(I.isArrayBuffer(e)||I.isBuffer(e)||I.isStream(e)||I.isFile(e)||I.isBlob(e)||I.isReadableStream(e))return e;if(I.isArrayBufferView(e))return e.buffer;if(I.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){let t=U(this,`formSerializer`);if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return vt(e,t).toString();if((a=I.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let n=U(this,`env`),r=n&&n.FormData;return V(a?{"files[]":e}:e,r&&new r,t)}}return i||r?(t.setContentType(`application/json`,!1),wt(e)):e}],transformResponse:[function(e){let t=U(this,`transitional`)||W.transitional,n=t&&t.forcedJSONParsing,r=U(this,`responseType`),i=r===`json`;if(I.isResponse(e)||I.isReadableStream(e))return e;if(e&&I.isString(e)&&(n&&!r||i)){let n=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,U(this,`parseReviver`))}catch(e){if(n)throw e.name===`SyntaxError`?B.from(e,B.ERR_BAD_RESPONSE,this,null,U(this,`response`)):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:H.classes.FormData,Blob:H.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};I.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`],e=>{W.headers[e]={}});function Tt(e,t){let n=this||W,r=t||n,i=z.from(r.headers),a=r.data;return I.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function Et(e){return!!(e&&e.__CANCEL__)}var G=class extends B{constructor(e,t,n){super(e??`canceled`,B.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function Dt(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new B(`Request failed with status code `+n.status,n.status>=400&&n.status<500?B.ERR_BAD_REQUEST:B.ERR_BAD_RESPONSE,n.config,n.request,n))}function Ot(e){let t=/^([-+\w]{1,25}):(?:\/\/)?/.exec(e);return t&&t[1]||``}function kt(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var K=(e,t,n=3)=>{let r=0,i=kt(50,250);return At(n=>{if(!n||typeof n.loaded!=`number`)return;let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=o==null?a:Math.min(a,o),c=Math.max(0,s-r),l=i(c);r=Math.max(r,s),e({loaded:s,total:o,progress:o?s/o:void 0,bytes:c,rate:l||void 0,estimated:l&&o?(o-s)/l:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},jt=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Mt=e=>(...t)=>I.asap(()=>e(...t)),Nt=H.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,H.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(H.origin),H.navigator&&/(msie|trident)/i.test(H.navigator.userAgent)):()=>!0,Pt=H.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];I.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),I.isString(r)&&s.push(`path=${r}`),I.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),I.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.split(`;`);for(let n=0;ne instanceof z?{...e}:e;function q(e,t){e||={},t||={};let n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(e,t,n,r){return I.isPlainObject(e)&&I.isPlainObject(t)?I.merge.call({caseless:r},e,t):I.isPlainObject(t)?I.merge({},t):I.isArray(t)?t.slice():t}function i(e,t,n,i){if(!I.isUndefined(t))return r(e,t,n,i);if(!I.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!I.isUndefined(t))return r(void 0,t)}function o(e,t){if(!I.isUndefined(t))return r(void 0,t);if(!I.isUndefined(e))return r(void 0,e)}function s(n){let r=I.hasOwnProp(t,`transitional`)?t.transitional:void 0;if(!I.isUndefined(r))if(I.isPlainObject(r)){if(I.hasOwnProp(r,n))return r[n]}else return;let i=I.hasOwnProp(e,`transitional`)?e.transitional:void 0;if(I.isPlainObject(i)&&I.hasOwnProp(i,n))return i[n]}function c(n,i,a){if(I.hasOwnProp(t,a))return r(n,i);if(I.hasOwnProp(e,a))return r(void 0,n)}let l={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,allowedSocketPaths:o,responseEncoding:o,validateStatus:c,headers:(e,t,n)=>i(Ut(e),Ut(t),n,!0)};return I.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=I.hasOwnProp(l,r)?l[r]:i,o=a(I.hasOwnProp(e,r)?e[r]:void 0,I.hasOwnProp(t,r)?t[r]:void 0,r);I.isUndefined(o)&&a!==c||(n[r]=o)}),I.hasOwnProp(t,`validateStatus`)&&I.isUndefined(t.validateStatus)&&s(`validateStatusUndefinedResolves`)===!1&&(I.hasOwnProp(e,`validateStatus`)?n.validateStatus=r(void 0,e.validateStatus):delete n.validateStatus),n}var Wt=[`content-type`,`content-length`];function Gt(e,t,n){if(n!==`content-only`){e.set(t);return}Object.entries(t||{}).forEach(([t,n])=>{Wt.includes(t.toLowerCase())&&e.set(t,n)})}var Kt=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16)));function qt(e){let t=q({},e),n=e=>I.hasOwnProp(t,e)?t[e]:void 0,r=n(`data`),i=n(`withXSRFToken`),a=n(`xsrfHeaderName`),o=n(`xsrfCookieName`),s=n(`headers`),c=n(`auth`),l=n(`baseURL`),u=n(`allowAbsoluteUrls`),d=n(`url`);if(t.headers=s=z.from(s),t.url=ct(Ht(l,d,u,t),n(`params`),n(`paramsSerializer`)),c){let t=I.getSafeProp(c,`username`)||``,n=I.getSafeProp(c,`password`)||``;try{s.set(`Authorization`,`Basic `+btoa(t+`:`+(n?Kt(n):``)))}catch(t){throw B.from(t,B.ERR_BAD_OPTION_VALUE,e)}}if(I.isFormData(r)&&(H.hasStandardBrowserEnv||H.hasStandardBrowserWebWorkerEnv||I.isReactNative(r)?s.setContentType(void 0):I.isFunction(r.getHeaders)&&Gt(s,r.getHeaders(),n(`formDataHeaderPolicy`))),H.hasStandardBrowserEnv&&(I.isFunction(i)&&(i=i(t)),i===!0||i==null&&Nt(t.url))){let e=a&&o&&Pt.read(o);e&&s.set(a,e)}return t}var Jt=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=qt(e),i=r.data,a=z.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=z.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());Dt(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.startsWith(`file:`))||setTimeout(g)},h.onabort=function(){h&&=(n(new B(`Request aborted`,B.ECONNABORTED,e,h)),m(),null)},h.onerror=function(t){let r=new B(t&&t.message?t.message:`Network Error`,B.ERR_NETWORK,e,h);r.event=t||null,n(r),m(),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||ut;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new B(t,i.clarifyTimeoutError?B.ETIMEDOUT:B.ECONNABORTED,e,h)),m(),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&I.forEach(Ue(a),function(e,t){h.setRequestHeader(t,e)}),I.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=K(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=K(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new G(null,e,h):t),h.abort(),m(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=Ot(r.url);if(_&&!H.protocols.includes(_)){n(new B(`Unsupported protocol `+_+`:`,B.ERR_BAD_REQUEST,e)),m();return}h.send(i||null)})},Yt=(e,t)=>{if(e=e?e.filter(Boolean):[],!t&&!e.length)return;let n=new AbortController,r=!1,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof B?t:new G(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new B(`timeout of ${t}ms exceeded`,B.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i,{once:!0}));let{signal:s}=n;return s.unsubscribe=()=>I.asap(o),s},Xt=function*(e,t){let n=e.byteLength;if(!t||n{let i=Zt(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},J=e=>e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102,en=(e,t,n)=>t+2e>=2&&r.charCodeAt(e-2)===37&&r.charCodeAt(e-1)===51&&(r.charCodeAt(e)===68||r.charCodeAt(e)===100);i>=0&&(r.charCodeAt(i)===61?(n++,i--):a(i)&&(n++,i-=3)),n===1&&i>=0&&(r.charCodeAt(i)===61||a(i))&&n++;let o=Math.floor(e/4)*3-(n||0);return o>0?o:0}let i=0;for(let e=0,t=r.length;e=55296&&n<=56319&&e+1=56320&&t<=57343?(i+=4,e++):i+=3}else i+=3}return i}var nn=`1.18.1`,rn=64*1024,{isFunction:Y}=I,an=e=>encodeURIComponent(e).replace(/%([0-9A-F]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))),on=e=>{if(!I.isString(e))return e;try{return decodeURIComponent(e)}catch{return e}},sn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},cn=e=>{let t=e.indexOf(`://`),n=e;return t!==-1&&(n=n.slice(t+3)),n.includes(`@`)||n.includes(`:`)},ln=e=>{let t=I.global!==void 0&&I.global!==null?I.global:globalThis,{ReadableStream:n,TextEncoder:r}=t;e=I.merge.call({skipUndefined:!0},{Request:t.Request,Response:t.Response},e);let{fetch:i,Request:a,Response:o}=e,s=i?Y(i):typeof fetch==`function`,c=Y(a),l=Y(o);if(!s)return!1;let u=s&&Y(n),d=s&&(typeof r==`function`?(e=>t=>e.encode(t))(new r):async e=>new Uint8Array(await new a(e).arrayBuffer())),f=c&&u&&sn(()=>{let e=!1,t=new a(H.origin,{body:new n,method:`POST`,get duplex(){return e=!0,`half`}}),r=t.headers.has(`Content-Type`);return t.body!=null&&t.body.cancel(),e&&!r}),p=l&&u&&sn(()=>I.isReadableStream(new o(``).body)),m={stream:p&&(e=>e.body)};s&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!m[e]&&(m[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new B(`Response type '${e}' is not supported`,B.ERR_NOT_SUPPORT,n)})});let h=async e=>{if(e==null)return 0;if(I.isBlob(e))return e.size;if(I.isSpecCompliantForm(e))return(await new a(H.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(I.isArrayBufferView(e)||I.isArrayBuffer(e))return e.byteLength;if(I.isURLSearchParams(e)&&(e+=``),I.isString(e))return(await d(e)).byteLength},g=async(e,t)=>I.toFiniteNumber(e.getContentLength())??h(t);return async e=>{let{url:t,method:n,data:s,signal:l,cancelToken:d,timeout:_,onDownloadProgress:v,onUploadProgress:y,responseType:b,headers:x,withCredentials:S=`same-origin`,fetchOptions:ee,maxContentLength:C,maxBodyLength:w}=qt(e),T=I.isNumber(C)&&C>-1,E=I.isNumber(w)&&w>-1,te=t=>I.hasOwnProp(e,t)?e[t]:void 0,ne=i||fetch;b=b?(b+``).toLowerCase():`text`;let D=Yt([l,d&&d.toAbortSignal()],_),O=null,k=D&&D.unsubscribe&&(()=>{D.unsubscribe()}),A,j=null,re=()=>new B(`Request body larger than maxBodyLength limit`,B.ERR_BAD_REQUEST,e,O);try{let i,l=te(`auth`);if(l&&(i={username:I.getSafeProp(l,`username`)||``,password:I.getSafeProp(l,`password`)||``}),cn(t)){let e=new URL(t,H.origin);!i&&(e.username||e.password)&&(i={username:on(e.username),password:on(e.password)}),(e.username||e.password)&&(e.username=``,e.password=``,t=e.href)}if(i&&(x.delete(`authorization`),x.set(`Authorization`,`Basic `+btoa(an((i.username||``)+`:`+(i.password||``))))),T&&typeof t==`string`&&t.startsWith(`data:`)&&tn(t)>C)throw new B(`maxContentLength size of `+C+` exceeded`,B.ERR_BAD_RESPONSE,e,O);if(E&&n!==`get`&&n!==`head`){let e=await h(s);if(typeof e==`number`&&isFinite(e)&&(A=e,e>w))throw re()}let d=E&&(I.isReadableStream(s)||I.isStream(s)),_=(e,t,n)=>$t(e,rn,e=>{if(E&&e>w)throw j=re();t&&t(e)},n);if(f&&n!==`get`&&n!==`head`&&(y||d)){if(A??=await g(x,s),A!==0||d){let e=new a(t,{method:`POST`,body:s,duplex:`half`}),n;if(I.isFormData(s)&&(n=e.headers.get(`content-type`))&&x.setContentType(n),e.body){let[t,n]=y&&jt(A,K(Mt(y)))||[];s=_(e.body,t,n)}}}else if(d&&!c&&u&&n!==`get`&&n!==`head`)s=_(s);else if(d&&c&&!f&&n!==`get`&&n!==`head`)throw new B(`Stream request bodies are not supported by the current fetch implementation`,B.ERR_NOT_SUPPORT,e,O);I.isString(S)||(S=S?`include`:`omit`);let ie=c&&`credentials`in a.prototype;if(I.isFormData(s)){let e=x.getContentType();e&&/^multipart\/form-data/i.test(e)&&!/boundary=/i.test(e)&&x.delete(`content-type`)}x.set(`User-Agent`,`axios/`+nn,!1);let ae={...ee,signal:D,method:n.toUpperCase(),headers:Ue(x.normalize()),body:s,duplex:`half`,credentials:ie?S:void 0};O=c&&new a(t,ae);let M=await(c?ne(O,ee):ne(t,ae)),oe=z.from(M.headers);if(T){let t=I.toFiniteNumber(oe.getContentLength());if(t!=null&&t>C)throw new B(`maxContentLength size of `+C+` exceeded`,B.ERR_BAD_RESPONSE,e,O)}let N=p&&(b===`stream`||b===`response`);if(p&&M.body&&(v||T||N&&k)){let t={};[`status`,`statusText`,`headers`].forEach(e=>{t[e]=M[e]});let n=I.toFiniteNumber(oe.getContentLength()),[r,i]=v&&jt(n,K(Mt(v),!0))||[],a=0;M=new o($t(M.body,rn,t=>{if(T&&(a=t,a>C))throw new B(`maxContentLength size of `+C+` exceeded`,B.ERR_BAD_RESPONSE,e,O);r&&r(t)},()=>{i&&i(),k&&k()}),t)}b||=`text`;let P=await m[I.findKey(m,b)||`text`](M,e);if(T&&!p&&!N){let t;if(P!=null&&(typeof P.byteLength==`number`?t=P.byteLength:typeof P.size==`number`?t=P.size:typeof P==`string`&&(t=typeof r==`function`?new r().encode(P).byteLength:P.length)),typeof t==`number`&&t>C)throw new B(`maxContentLength size of `+C+` exceeded`,B.ERR_BAD_RESPONSE,e,O)}return!N&&k&&k(),await new Promise((t,n)=>{Dt(t,n,{data:P,headers:z.from(M.headers),status:M.status,statusText:M.statusText,config:e,request:O})})}catch(t){if(k&&k(),D&&D.aborted&&D.reason instanceof B){let n=D.reason;throw n.config=e,O&&(n.request=O),t!==n&&Object.defineProperty(n,"cause",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),n}if(j)throw O&&!j.request&&(j.request=O),j;if(t instanceof B)throw O&&!t.request&&(t.request=O),t;if(t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)){let n=new B(`Network Error`,B.ERR_NETWORK,e,O,t&&t.response);throw Object.defineProperty(n,"cause",{__proto__:null,value:t.cause||t,writable:!0,enumerable:!1,configurable:!0}),n}throw B.from(t,t&&t.code,e,O,t&&t.response)}}},un=new Map,dn=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=un;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:ln(t)),l=c;return c};dn();var fn={http:null,xhr:Jt,fetch:{get:dn}};I.forEach(fn,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{__proto__:null,value:t})}catch{}Object.defineProperty(e,"adapterName",{__proto__:null,value:t})}});var pn=e=>`- ${e}`,mn=e=>I.isFunction(e)||e===null||e===!1;function hn(e,t){e=I.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new B(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since : +`+e.map(pn).join(` +`):` `+pn(e[0]):`as no adapter specified`),B.ERR_NOT_SUPPORT)}return i}var gn={getAdapter:hn,adapters:fn};function _n(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new G(null,e)}function vn(e){return _n(e),e.headers=z.from(e.headers),e.data=Tt.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),gn.getAdapter(e.adapter||W.adapter,e)(e).then(function(t){_n(e),e.response=t;try{t.data=Tt.call(e,e.transformResponse,t)}finally{delete e.response}return t.headers=z.from(t.headers),t},function(t){if(!Et(t)&&(_n(e),t&&t.response)){e.response=t.response;try{t.response.data=Tt.call(e,e.transformResponse,t.response)}finally{delete e.response}t.response.headers=z.from(t.response.headers)}return Promise.reject(t)})}var X={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{X[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var yn={};X.transitional=function(e,t,n){function r(e,t){return`[Axios v`+nn+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new B(r(i,` has been removed`+(t?` in `+t:``)),B.ERR_DEPRECATED);return t&&!yn[i]&&(yn[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),!e||e(n,i,a)}},X.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function bn(e,t,n){if(typeof e!=`object`||!e)throw new B(`options must be an object`,B.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-->0;){let a=r[i],o=Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0;if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new B(`option `+a+` must be `+n,B.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new B(`Unknown option `+a,B.ERR_BAD_OPTION)}}var xn={assertOptions:bn,validators:X},Z=xn.validators,Q=class{constructor(e){this.defaults=e||{},this.interceptors={request:new lt,response:new lt}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=(()=>{if(!t.stack)return``;let e=t.stack.indexOf(` +`);return e===-1?``:t.stack.slice(e+1)})();try{if(!e.stack)e.stack=n;else if(n){let t=n.indexOf(` +`),r=t===-1?-1:n.indexOf(` +`,t+1),i=r===-1?``:n.slice(r+1);String(e.stack).endsWith(i)||(e.stack+=` +`+n)}}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=q(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&xn.assertOptions(n,{silentJSONParsing:Z.transitional(Z.boolean),forcedJSONParsing:Z.transitional(Z.boolean),clarifyTimeoutError:Z.transitional(Z.boolean),legacyInterceptorReqResOrdering:Z.transitional(Z.boolean),advertiseZstdAcceptEncoding:Z.transitional(Z.boolean),validateStatusUndefinedResolves:Z.transitional(Z.boolean)},!1),r!=null&&(I.isFunction(r)?t.paramsSerializer={serialize:r}:xn.assertOptions(r,{encode:Z.function,serialize:Z.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),xn.assertOptions(t,{baseUrl:Z.spelling(`baseURL`),withXsrfToken:Z.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&I.merge(i.common,i[t.method]);i&&I.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`query`,`common`],e=>{delete i[e]}),t.headers=z.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||ut;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[vn.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u{if(!n._listeners)return;let t=n._listeners.length;for(;t-->0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new G(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function Cn(e){return function(t){return e.apply(null,t)}}function wn(e){return I.isObject(e)&&e.isAxiosError===!0}var Tn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Tn).forEach(([e,t])=>{Tn[t]=e});function En(e){let n=new Q(e),r=t(Q.prototype.request,n);return I.extend(r,Q.prototype,n,{allOwnKeys:!0}),I.extend(r,n,null,{allOwnKeys:!0}),r.create=function(t){return En(q(e,t))},r}var $=En(W);$.Axios=Q,$.CanceledError=G,$.CancelToken=Sn,$.isCancel=Et,$.VERSION=nn,$.toFormData=V,$.AxiosError=B,$.Cancel=$.CanceledError,$.all=function(e){return Promise.all(e)},$.spread=Cn,$.isAxiosError=wn,$.mergeConfig=q,$.AxiosHeaders=z,$.formToJSON=e=>Ct(I.isHTMLForm(e)?new FormData(e):e),$.getAdapter=gn.getAdapter,$.HttpStatusCode=Tn,$.default=$;export{$ as t}; \ No newline at end of file diff --git a/frontend/dist/assets/axios-BPyV2soB.js b/frontend/dist/assets/axios-BPyV2soB.js deleted file mode 100644 index 6472fb7..0000000 --- a/frontend/dist/assets/axios-BPyV2soB.js +++ /dev/null @@ -1,9 +0,0 @@ -import{a as e}from"./jsx-runtime-DmifIpYY.js";function t(e,t){return function(){return e.apply(t,arguments)}}var{toString:n}=Object.prototype,{getPrototypeOf:r}=Object,{iterator:i,toStringTag:a}=Symbol,o=(e=>t=>{let r=n.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),s=e=>(e=e.toLowerCase(),t=>o(t)===e),c=e=>t=>typeof t===e,{isArray:l}=Array,u=c(`undefined`);function d(e){return e!==null&&!u(e)&&e.constructor!==null&&!u(e.constructor)&&h(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}var f=s(`ArrayBuffer`);function p(e){let t;return t=typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&f(e.buffer),t}var m=c(`string`),h=c(`function`),g=c(`number`),_=e=>typeof e==`object`&&!!e,v=e=>e===!0||e===!1,y=e=>{if(o(e)!==`object`)return!1;let t=r(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(a in e)&&!(i in e)},ee=e=>{if(!_(e)||d(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},b=s(`Date`),x=s(`File`),S=e=>!!(e&&e.uri!==void 0),C=e=>e&&e.getParts!==void 0,w=s(`Blob`),te=s(`FileList`),ne=e=>_(e)&&h(e.pipe);function re(){return typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{}}var ie=re(),ae=ie.FormData===void 0?void 0:ie.FormData,oe=e=>{let t;return e&&(ae&&e instanceof ae||h(e.append)&&((t=o(e))===`formdata`||t===`object`&&h(e.toString)&&e.toString()===`[object FormData]`))},se=s(`URLSearchParams`),[ce,le,ue,de]=[`ReadableStream`,`Request`,`Response`,`Headers`].map(s),fe=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,``);function T(e,t,{allOwnKeys:n=!1}={}){if(e==null)return;let r,i;if(typeof e!=`object`&&(e=[e]),l(e))for(r=0,i=e.length;r0;)if(i=n[r],t===i.toLowerCase())return i;return null}var E=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:global,me=e=>!u(e)&&e!==E;function he(){let{caseless:e,skipUndefined:t}=me(this)&&this||{},n={},r=(r,i)=>{if(i===`__proto__`||i===`constructor`||i===`prototype`)return;let a=e&&pe(n,i)||i;y(n[a])&&y(r)?n[a]=he(n[a],r):y(r)?n[a]=he({},r):l(r)?n[a]=r.slice():(!t||!u(r))&&(n[a]=r)};for(let e=0,t=arguments.length;e(T(n,(n,i)=>{r&&h(n)?Object.defineProperty(e,i,{value:t(n,r),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(e,i,{value:n,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),e),_e=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ve=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),Object.defineProperty(e.prototype,`constructor`,{value:e,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(e,`super`,{value:t.prototype}),n&&Object.assign(e.prototype,n)},ye=(e,t,n,i)=>{let a,o,s,c={};if(t||={},e==null)return t;do{for(a=Object.getOwnPropertyNames(e),o=a.length;o-- >0;)s=a[o],(!i||i(s,e,t))&&!c[s]&&(t[s]=e[s],c[s]=!0);e=n!==!1&&r(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},be=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;let r=e.indexOf(t,n);return r!==-1&&r===n},xe=e=>{if(!e)return null;if(l(e))return e;let t=e.length;if(!g(t))return null;let n=Array(t);for(;t-- >0;)n[t]=e[t];return n},Se=(e=>t=>e&&t instanceof e)(typeof Uint8Array<`u`&&r(Uint8Array)),Ce=(e,t)=>{let n=(e&&e[i]).call(e),r;for(;(r=n.next())&&!r.done;){let n=r.value;t.call(e,n[0],n[1])}},we=(e,t)=>{let n,r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Te=s(`HTMLFormElement`),Ee=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,n){return t.toUpperCase()+n}),De=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Oe=s(`RegExp`),ke=(e,t)=>{let n=Object.getOwnPropertyDescriptors(e),r={};T(n,(n,i)=>{let a;(a=t(n,i,e))!==!1&&(r[i]=a||n)}),Object.defineProperties(e,r)},Ae=e=>{ke(e,(t,n)=>{if(h(e)&&[`arguments`,`caller`,`callee`].indexOf(n)!==-1)return!1;let r=e[n];if(h(r)){if(t.enumerable=!1,`writable`in t){t.writable=!1;return}t.set||=()=>{throw Error(`Can not rewrite read-only method '`+n+`'`)}}})},je=(e,t)=>{let n={},r=e=>{e.forEach(e=>{n[e]=!0})};return l(e)?r(e):r(String(e).split(t)),n},Me=()=>{},Ne=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function Pe(e){return!!(e&&h(e.append)&&e[a]===`FormData`&&e[i])}var Fe=e=>{let t=Array(10),n=(e,r)=>{if(_(e)){if(t.indexOf(e)>=0)return;if(d(e))return e;if(!(`toJSON`in e)){t[r]=e;let i=l(e)?[]:{};return T(e,(e,t)=>{let a=n(e,r+1);!u(a)&&(i[t]=a)}),t[r]=void 0,i}}return e};return n(e,0)},Ie=s(`AsyncFunction`),Le=e=>e&&(_(e)||h(e))&&h(e.then)&&h(e.catch),Re=((e,t)=>e?setImmediate:t?((e,t)=>(E.addEventListener(`message`,({source:n,data:r})=>{n===E&&r===e&&t.length&&t.shift()()},!1),n=>{t.push(n),E.postMessage(e,`*`)}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate==`function`,h(E.postMessage)),D={isArray:l,isArrayBuffer:f,isBuffer:d,isFormData:oe,isArrayBufferView:p,isString:m,isNumber:g,isBoolean:v,isObject:_,isPlainObject:y,isEmptyObject:ee,isReadableStream:ce,isRequest:le,isResponse:ue,isHeaders:de,isUndefined:u,isDate:b,isFile:x,isReactNativeBlob:S,isReactNative:C,isBlob:w,isRegExp:Oe,isFunction:h,isStream:ne,isURLSearchParams:se,isTypedArray:Se,isFileList:te,forEach:T,merge:he,extend:ge,trim:fe,stripBOM:_e,inherits:ve,toFlatObject:ye,kindOf:o,kindOfTest:s,endsWith:be,toArray:xe,forEachEntry:Ce,matchAll:we,isHTMLForm:Te,hasOwnProperty:De,hasOwnProp:De,reduceDescriptors:ke,freezeMethods:Ae,toObjectSet:je,toCamelCase:Ee,noop:Me,toFiniteNumber:Ne,findKey:pe,global:E,isContextDefined:me,isSpecCompliantForm:Pe,toJSONObject:Fe,isAsyncFn:Ie,isThenable:Le,setImmediate:Re,asap:typeof queueMicrotask<`u`?queueMicrotask.bind(E):typeof process<`u`&&process.nextTick||Re,isIterable:e=>e!=null&&h(e[i])},O=class e extends Error{static from(t,n,r,i,a,o){let s=new e(t.message,n||t.code,r,i,a);return s.cause=t,s.name=t.name,t.status!=null&&s.status==null&&(s.status=t.status),o&&Object.assign(s,o),s}constructor(e,t,n,r,i){super(e),Object.defineProperty(this,`message`,{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name=`AxiosError`,this.isAxiosError=!0,t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),i&&(this.response=i,this.status=i.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:D.toJSONObject(this.config),code:this.code,status:this.status}}};O.ERR_BAD_OPTION_VALUE=`ERR_BAD_OPTION_VALUE`,O.ERR_BAD_OPTION=`ERR_BAD_OPTION`,O.ECONNABORTED=`ECONNABORTED`,O.ETIMEDOUT=`ETIMEDOUT`,O.ERR_NETWORK=`ERR_NETWORK`,O.ERR_FR_TOO_MANY_REDIRECTS=`ERR_FR_TOO_MANY_REDIRECTS`,O.ERR_DEPRECATED=`ERR_DEPRECATED`,O.ERR_BAD_RESPONSE=`ERR_BAD_RESPONSE`,O.ERR_BAD_REQUEST=`ERR_BAD_REQUEST`,O.ERR_CANCELED=`ERR_CANCELED`,O.ERR_NOT_SUPPORT=`ERR_NOT_SUPPORT`,O.ERR_INVALID_URL=`ERR_INVALID_URL`;function k(e){return D.isPlainObject(e)||D.isArray(e)}function ze(e){return D.endsWith(e,`[]`)?e.slice(0,-2):e}function A(e,t,n){return e?e.concat(t).map(function(e,t){return e=ze(e),!n&&t?`[`+e+`]`:e}).join(n?`.`:``):t}function Be(e){return D.isArray(e)&&!e.some(k)}var Ve=D.toFlatObject(D,{},null,function(e){return/^is[A-Z]/.test(e)});function j(e,t,n){if(!D.isObject(e))throw TypeError(`target must be an object`);t||=new FormData,n=D.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!D.isUndefined(t[e])});let r=n.metaTokens,i=n.visitor||l,a=n.dots,o=n.indexes,s=(n.Blob||typeof Blob<`u`&&Blob)&&D.isSpecCompliantForm(t);if(!D.isFunction(i))throw TypeError(`visitor must be a function`);function c(e){if(e===null)return``;if(D.isDate(e))return e.toISOString();if(D.isBoolean(e))return e.toString();if(!s&&D.isBlob(e))throw new O(`Blob is not supported. Use a Buffer instead.`);return D.isArrayBuffer(e)||D.isTypedArray(e)?s&&typeof Blob==`function`?new Blob([e]):Buffer.from(e):e}function l(e,n,i){let s=e;if(D.isReactNative(t)&&D.isReactNativeBlob(e))return t.append(A(i,n,a),c(e)),!1;if(e&&!i&&typeof e==`object`){if(D.endsWith(n,`{}`))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(D.isArray(e)&&Be(e)||(D.isFileList(e)||D.endsWith(n,`[]`))&&(s=D.toArray(e)))return n=ze(n),s.forEach(function(e,r){!(D.isUndefined(e)||e===null)&&t.append(o===!0?A([n],r,a):o===null?n:n+`[]`,c(e))}),!1}return k(e)?!0:(t.append(A(i,n,a),c(e)),!1)}let u=[],d=Object.assign(Ve,{defaultVisitor:l,convertValue:c,isVisitable:k});function f(e,n){if(!D.isUndefined(e)){if(u.indexOf(e)!==-1)throw Error(`Circular reference detected in `+n.join(`.`));u.push(e),D.forEach(e,function(e,r){(!(D.isUndefined(e)||e===null)&&i.call(t,e,D.isString(r)?r.trim():r,n,d))===!0&&f(e,n?n.concat(r):[r])}),u.pop()}}if(!D.isObject(e))throw TypeError(`data must be an object`);return f(e),t}function He(e){let t={"!":`%21`,"'":`%27`,"(":`%28`,")":`%29`,"~":`%7E`,"%20":`+`,"%00":`\0`};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function M(e,t){this._pairs=[],e&&j(e,this,t)}var Ue=M.prototype;Ue.append=function(e,t){this._pairs.push([e,t])},Ue.toString=function(e){let t=e?function(t){return e.call(this,t,He)}:He;return this._pairs.map(function(e){return t(e[0])+`=`+t(e[1])},``).join(`&`)};function We(e){return encodeURIComponent(e).replace(/%3A/gi,`:`).replace(/%24/g,`$`).replace(/%2C/gi,`,`).replace(/%20/g,`+`)}function Ge(e,t,n){if(!t)return e;let r=n&&n.encode||We,i=D.isFunction(n)?{serialize:n}:n,a=i&&i.serialize,o;if(o=a?a(t,i):D.isURLSearchParams(t)?t.toString():new M(t,i).toString(r),o){let t=e.indexOf(`#`);t!==-1&&(e=e.slice(0,t)),e+=(e.indexOf(`?`)===-1?`?`:`&`)+o}return e}var Ke=class{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&=[]}forEach(e){D.forEach(this.handlers,function(t){t!==null&&e(t)})}},N={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},qe={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<`u`?URLSearchParams:M,FormData:typeof FormData<`u`?FormData:null,Blob:typeof Blob<`u`?Blob:null},protocols:[`http`,`https`,`file`,`blob`,`url`,`data`]},Je=e({hasBrowserEnv:()=>P,hasStandardBrowserEnv:()=>Ye,hasStandardBrowserWebWorkerEnv:()=>Xe,navigator:()=>F,origin:()=>Ze}),P=typeof window<`u`&&typeof document<`u`,F=typeof navigator==`object`&&navigator||void 0,Ye=P&&(!F||[`ReactNative`,`NativeScript`,`NS`].indexOf(F.product)<0),Xe=typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope&&typeof self.importScripts==`function`,Ze=P&&window.location.href||`http://localhost`,I={...Je,...qe};function Qe(e,t){return j(e,new I.classes.URLSearchParams,{visitor:function(e,t,n,r){return I.isNode&&D.isBuffer(e)?(this.append(t,e.toString(`base64`)),!1):r.defaultVisitor.apply(this,arguments)},...t})}function $e(e){return D.matchAll(/\w+|\[(\w*)]/g,e).map(e=>e[0]===`[]`?``:e[1]||e[0])}function et(e){let t={},n=Object.keys(e),r,i=n.length,a;for(r=0;r=e.length;return a=!a&&D.isArray(r)?r.length:a,s?(D.hasOwnProp(r,a)?r[a]=[r[a],n]:r[a]=n,!o):((!r[a]||!D.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],i)&&D.isArray(r[a])&&(r[a]=et(r[a])),!o)}if(D.isFormData(e)&&D.isFunction(e.entries)){let n={};return D.forEachEntry(e,(e,r)=>{t($e(e),r,n,0)}),n}return null}function nt(e,t,n){if(D.isString(e))try{return(t||JSON.parse)(e),D.trim(e)}catch(e){if(e.name!==`SyntaxError`)throw e}return(n||JSON.stringify)(e)}var L={transitional:N,adapter:[`xhr`,`http`,`fetch`],transformRequest:[function(e,t){let n=t.getContentType()||``,r=n.indexOf(`application/json`)>-1,i=D.isObject(e);if(i&&D.isHTMLForm(e)&&(e=new FormData(e)),D.isFormData(e))return r?JSON.stringify(tt(e)):e;if(D.isArrayBuffer(e)||D.isBuffer(e)||D.isStream(e)||D.isFile(e)||D.isBlob(e)||D.isReadableStream(e))return e;if(D.isArrayBufferView(e))return e.buffer;if(D.isURLSearchParams(e))return t.setContentType(`application/x-www-form-urlencoded;charset=utf-8`,!1),e.toString();let a;if(i){if(n.indexOf(`application/x-www-form-urlencoded`)>-1)return Qe(e,this.formSerializer).toString();if((a=D.isFileList(e))||n.indexOf(`multipart/form-data`)>-1){let t=this.env&&this.env.FormData;return j(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||r?(t.setContentType(`application/json`,!1),nt(e)):e}],transformResponse:[function(e){let t=this.transitional||L.transitional,n=t&&t.forcedJSONParsing,r=this.responseType===`json`;if(D.isResponse(e)||D.isReadableStream(e))return e;if(e&&D.isString(e)&&(n&&!this.responseType||r)){let n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e,this.parseReviver)}catch(e){if(n)throw e.name===`SyntaxError`?O.from(e,O.ERR_BAD_RESPONSE,this,null,this.response):e}}return e}],timeout:0,xsrfCookieName:`XSRF-TOKEN`,xsrfHeaderName:`X-XSRF-TOKEN`,maxContentLength:-1,maxBodyLength:-1,env:{FormData:I.classes.FormData,Blob:I.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:`application/json, text/plain, */*`,"Content-Type":void 0}}};D.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`],e=>{L.headers[e]={}});var rt=D.toObjectSet([`age`,`authorization`,`content-length`,`content-type`,`etag`,`expires`,`from`,`host`,`if-modified-since`,`if-unmodified-since`,`last-modified`,`location`,`max-forwards`,`proxy-authorization`,`referer`,`retry-after`,`user-agent`]),it=e=>{let t={},n,r,i;return e&&e.split(` -`).forEach(function(e){i=e.indexOf(`:`),n=e.substring(0,i).trim().toLowerCase(),r=e.substring(i+1).trim(),!(!n||t[n]&&rt[n])&&(n===`set-cookie`?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+`, `+r:r)}),t},at=Symbol(`internals`),ot=e=>!/[\r\n]/.test(e);function st(e,t){if(!(e===!1||e==null)){if(D.isArray(e)){e.forEach(e=>st(e,t));return}if(!ot(String(e)))throw Error(`Invalid character in header content ["${t}"]`)}}function R(e){return e&&String(e).trim().toLowerCase()}function ct(e){let t=e.length;for(;t>0;){let n=e.charCodeAt(t-1);if(n!==10&&n!==13)break;--t}return t===e.length?e:e.slice(0,t)}function z(e){return e===!1||e==null?e:D.isArray(e)?e.map(z):ct(String(e))}function lt(e){let t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g,r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}var ut=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function B(e,t,n,r,i){if(D.isFunction(r))return r.call(this,t,n);if(i&&(t=n),D.isString(t)){if(D.isString(r))return t.indexOf(r)!==-1;if(D.isRegExp(r))return r.test(t)}}function dt(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function ft(e,t){let n=D.toCamelCase(` `+t);[`get`,`set`,`has`].forEach(r=>{Object.defineProperty(e,r+n,{value:function(e,n,i){return this[r].call(this,t,e,n,i)},configurable:!0})})}var V=class{constructor(e){e&&this.set(e)}set(e,t,n){let r=this;function i(e,t,n){let i=R(t);if(!i)throw Error(`header name must be a non-empty string`);let a=D.findKey(r,i);(!a||r[a]===void 0||n===!0||n===void 0&&r[a]!==!1)&&(st(e,t),r[a||t]=z(e))}let a=(e,t)=>D.forEach(e,(e,n)=>i(e,n,t));if(D.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(D.isString(e)&&(e=e.trim())&&!ut(e))a(it(e),t);else if(D.isObject(e)&&D.isIterable(e)){let n={},r,i;for(let t of e){if(!D.isArray(t))throw TypeError(`Object iterator must return a key-value pair`);n[i=t[0]]=(r=n[i])?D.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(n,t)}else e!=null&&i(t,e,n);return this}get(e,t){if(e=R(e),e){let n=D.findKey(this,e);if(n){let e=this[n];if(!t)return e;if(t===!0)return lt(e);if(D.isFunction(t))return t.call(this,e,n);if(D.isRegExp(t))return t.exec(e);throw TypeError(`parser must be boolean|regexp|function`)}}}has(e,t){if(e=R(e),e){let n=D.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||B(this,this[n],n,t)))}return!1}delete(e,t){let n=this,r=!1;function i(e){if(e=R(e),e){let i=D.findKey(n,e);i&&(!t||B(n,n[i],i,t))&&(delete n[i],r=!0)}}return D.isArray(e)?e.forEach(i):i(e),r}clear(e){let t=Object.keys(this),n=t.length,r=!1;for(;n--;){let i=t[n];(!e||B(this,this[i],i,e,!0))&&(delete this[i],r=!0)}return r}normalize(e){let t=this,n={};return D.forEach(this,(r,i)=>{let a=D.findKey(n,i);if(a){t[a]=z(r),delete t[i];return}let o=e?dt(i):String(i).trim();o!==i&&delete t[i],t[o]=z(r),n[o]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){let t=Object.create(null);return D.forEach(this,(n,r)=>{n!=null&&n!==!1&&(t[r]=e&&D.isArray(n)?n.join(`, `):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+`: `+t).join(` -`)}getSetCookie(){return this.get(`set-cookie`)||[]}get[Symbol.toStringTag](){return`AxiosHeaders`}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){let n=new this(e);return t.forEach(e=>n.set(e)),n}static accessor(e){let t=(this[at]=this[at]={accessors:{}}).accessors,n=this.prototype;function r(e){let r=R(e);t[r]||(ft(n,e),t[r]=!0)}return D.isArray(e)?e.forEach(r):r(e),this}};V.accessor([`Content-Type`,`Content-Length`,`Accept`,`Accept-Encoding`,`User-Agent`,`Authorization`]),D.reduceDescriptors(V.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}}),D.freezeMethods(V);function H(e,t){let n=this||L,r=t||n,i=V.from(r.headers),a=r.data;return D.forEach(e,function(e){a=e.call(n,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function pt(e){return!!(e&&e.__CANCEL__)}var U=class extends O{constructor(e,t,n){super(e??`canceled`,O.ERR_CANCELED,t,n),this.name=`CanceledError`,this.__CANCEL__=!0}};function mt(e,t,n){let r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new O(`Request failed with status code `+n.status,[O.ERR_BAD_REQUEST,O.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function ht(e){let t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||``}function gt(e,t){e||=10;let n=Array(e),r=Array(e),i=0,a=0,o;return t=t===void 0?1e3:t,function(s){let c=Date.now(),l=r[a];o||=c,n[i]=s,r[i]=c;let u=a,d=0;for(;u!==i;)d+=n[u++],u%=e;if(i=(i+1)%e,i===a&&(a=(a+1)%e),c-o{n=r,i=null,a&&=(clearTimeout(a),null),e(...t)};return[(...e)=>{let t=Date.now(),s=t-n;s>=r?o(e,t):(i=e,a||=setTimeout(()=>{a=null,o(i)},r-s))},()=>i&&o(i)]}var W=(e,t,n=3)=>{let r=0,i=gt(50,250);return _t(n=>{let a=n.loaded,o=n.lengthComputable?n.total:void 0,s=a-r,c=i(s),l=a<=o;r=a,e({loaded:a,total:o,progress:o?a/o:void 0,bytes:s,rate:c||void 0,estimated:c&&o&&l?(o-a)/c:void 0,event:n,lengthComputable:o!=null,[t?`download`:`upload`]:!0})},n)},vt=(e,t)=>{let n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},yt=e=>(...t)=>D.asap(()=>e(...t)),bt=I.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,I.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(I.origin),I.navigator&&/(msie|trident)/i.test(I.navigator.userAgent)):()=>!0,xt=I.hasStandardBrowserEnv?{write(e,t,n,r,i,a,o){if(typeof document>`u`)return;let s=[`${e}=${encodeURIComponent(t)}`];D.isNumber(n)&&s.push(`expires=${new Date(n).toUTCString()}`),D.isString(r)&&s.push(`path=${r}`),D.isString(i)&&s.push(`domain=${i}`),a===!0&&s.push(`secure`),D.isString(o)&&s.push(`SameSite=${o}`),document.cookie=s.join(`; `)},read(e){if(typeof document>`u`)return null;let t=document.cookie.match(RegExp(`(?:^|; )`+e+`=([^;]*)`));return t?decodeURIComponent(t[1]):null},remove(e){this.write(e,``,Date.now()-864e5,`/`)}}:{write(){},read(){return null},remove(){}};function St(e){return typeof e==`string`?/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e):!1}function Ct(e,t){return t?e.replace(/\/?\/$/,``)+`/`+t.replace(/^\/+/,``):e}function wt(e,t,n){let r=!St(t);return e&&(r||n==0)?Ct(e,t):t}var Tt=e=>e instanceof V?{...e}:e;function G(e,t){t||={};let n={};function r(e,t,n,r){return D.isPlainObject(e)&&D.isPlainObject(t)?D.merge.call({caseless:r},e,t):D.isPlainObject(t)?D.merge({},t):D.isArray(t)?t.slice():t}function i(e,t,n,i){if(!D.isUndefined(t))return r(e,t,n,i);if(!D.isUndefined(e))return r(void 0,e,n,i)}function a(e,t){if(!D.isUndefined(t))return r(void 0,t)}function o(e,t){if(!D.isUndefined(t))return r(void 0,t);if(!D.isUndefined(e))return r(void 0,e)}function s(n,i,a){if(a in t)return r(n,i);if(a in e)return r(void 0,n)}let c={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:s,headers:(e,t,n)=>i(Tt(e),Tt(t),n,!0)};return D.forEach(Object.keys({...e,...t}),function(r){if(r===`__proto__`||r===`constructor`||r===`prototype`)return;let a=D.hasOwnProp(c,r)?c[r]:i,o=a(e[r],t[r],r);D.isUndefined(o)&&a!==s||(n[r]=o)}),n}var Et=e=>{let t=G({},e),{data:n,withXSRFToken:r,xsrfHeaderName:i,xsrfCookieName:a,headers:o,auth:s}=t;if(t.headers=o=V.from(o),t.url=Ge(wt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),s&&o.set(`Authorization`,`Basic `+btoa((s.username||``)+`:`+(s.password?unescape(encodeURIComponent(s.password)):``))),D.isFormData(n)){if(I.hasStandardBrowserEnv||I.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(D.isFunction(n.getHeaders)){let e=n.getHeaders(),t=[`content-type`,`content-length`];Object.entries(e).forEach(([e,n])=>{t.includes(e.toLowerCase())&&o.set(e,n)})}}if(I.hasStandardBrowserEnv&&(r&&D.isFunction(r)&&(r=r(t)),r||r!==!1&&bt(t.url))){let e=i&&a&&xt.read(a);e&&o.set(i,e)}return t},Dt=typeof XMLHttpRequest<`u`&&function(e){return new Promise(function(t,n){let r=Et(e),i=r.data,a=V.from(r.headers).normalize(),{responseType:o,onUploadProgress:s,onDownloadProgress:c}=r,l,u,d,f,p;function m(){f&&f(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(l),r.signal&&r.signal.removeEventListener(`abort`,l)}let h=new XMLHttpRequest;h.open(r.method.toUpperCase(),r.url,!0),h.timeout=r.timeout;function g(){if(!h)return;let r=V.from(`getAllResponseHeaders`in h&&h.getAllResponseHeaders());mt(function(e){t(e),m()},function(e){n(e),m()},{data:!o||o===`text`||o===`json`?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:r,config:e,request:h}),h=null}`onloadend`in h?h.onloadend=g:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf(`file:`)===0)||setTimeout(g)},h.onabort=function(){h&&=(n(new O(`Request aborted`,O.ECONNABORTED,e,h)),null)},h.onerror=function(t){let r=new O(t&&t.message?t.message:`Network Error`,O.ERR_NETWORK,e,h);r.event=t||null,n(r),h=null},h.ontimeout=function(){let t=r.timeout?`timeout of `+r.timeout+`ms exceeded`:`timeout exceeded`,i=r.transitional||N;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new O(t,i.clarifyTimeoutError?O.ETIMEDOUT:O.ECONNABORTED,e,h)),h=null},i===void 0&&a.setContentType(null),`setRequestHeader`in h&&D.forEach(a.toJSON(),function(e,t){h.setRequestHeader(t,e)}),D.isUndefined(r.withCredentials)||(h.withCredentials=!!r.withCredentials),o&&o!==`json`&&(h.responseType=r.responseType),c&&([d,p]=W(c,!0),h.addEventListener(`progress`,d)),s&&h.upload&&([u,f]=W(s),h.upload.addEventListener(`progress`,u),h.upload.addEventListener(`loadend`,f)),(r.cancelToken||r.signal)&&(l=t=>{h&&=(n(!t||t.type?new U(null,e,h):t),h.abort(),null)},r.cancelToken&&r.cancelToken.subscribe(l),r.signal&&(r.signal.aborted?l():r.signal.addEventListener(`abort`,l)));let _=ht(r.url);if(_&&I.protocols.indexOf(_)===-1){n(new O(`Unsupported protocol `+_+`:`,O.ERR_BAD_REQUEST,e));return}h.send(i||null)})},Ot=(e,t)=>{let{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n=new AbortController,r,i=function(e){if(!r){r=!0,o();let t=e instanceof Error?e:this.reason;n.abort(t instanceof O?t:new U(t instanceof Error?t.message:t))}},a=t&&setTimeout(()=>{a=null,i(new O(`timeout of ${t}ms exceeded`,O.ETIMEDOUT))},t),o=()=>{e&&=(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener(`abort`,i)}),null)};e.forEach(e=>e.addEventListener(`abort`,i));let{signal:s}=n;return s.unsubscribe=()=>D.asap(o),s}},kt=function*(e,t){let n=e.byteLength;if(!t||n{let i=At(e,t),a=0,o,s=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{let{done:t,value:r}=await i.next();if(t){s(),e.close();return}let o=r.byteLength;n&&n(a+=o),e.enqueue(new Uint8Array(r))}catch(e){throw s(e),e}},cancel(e){return s(e),i.return()}},{highWaterMark:2})},Nt=64*1024,{isFunction:K}=D,Pt=(({Request:e,Response:t})=>({Request:e,Response:t}))(D.global),{ReadableStream:Ft,TextEncoder:It}=D.global,Lt=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Rt=e=>{e=D.merge.call({skipUndefined:!0},Pt,e);let{fetch:t,Request:n,Response:r}=e,i=t?K(t):typeof fetch==`function`,a=K(n),o=K(r);if(!i)return!1;let s=i&&K(Ft),c=i&&(typeof It==`function`?(e=>t=>e.encode(t))(new It):async e=>new Uint8Array(await new n(e).arrayBuffer())),l=a&&s&&Lt(()=>{let e=!1,t=new Ft,r=new n(I.origin,{body:t,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`);return t.cancel(),e&&!r}),u=o&&s&&Lt(()=>D.isReadableStream(new r(``).body)),d={stream:u&&(e=>e.body)};i&&[`text`,`arrayBuffer`,`blob`,`formData`,`stream`].forEach(e=>{!d[e]&&(d[e]=(t,n)=>{let r=t&&t[e];if(r)return r.call(t);throw new O(`Response type '${e}' is not supported`,O.ERR_NOT_SUPPORT,n)})});let f=async e=>{if(e==null)return 0;if(D.isBlob(e))return e.size;if(D.isSpecCompliantForm(e))return(await new n(I.origin,{method:`POST`,body:e}).arrayBuffer()).byteLength;if(D.isArrayBufferView(e)||D.isArrayBuffer(e))return e.byteLength;if(D.isURLSearchParams(e)&&(e+=``),D.isString(e))return(await c(e)).byteLength},p=async(e,t)=>D.toFiniteNumber(e.getContentLength())??f(t);return async e=>{let{url:i,method:o,data:s,signal:c,cancelToken:f,timeout:m,onDownloadProgress:h,onUploadProgress:g,responseType:_,headers:v,withCredentials:y=`same-origin`,fetchOptions:ee}=Et(e),b=t||fetch;_=_?(_+``).toLowerCase():`text`;let x=Ot([c,f&&f.toAbortSignal()],m),S=null,C=x&&x.unsubscribe&&(()=>{x.unsubscribe()}),w;try{if(g&&l&&o!==`get`&&o!==`head`&&(w=await p(v,s))!==0){let e=new n(i,{method:`POST`,body:s,duplex:`half`}),t;if(D.isFormData(s)&&(t=e.headers.get(`content-type`))&&v.setContentType(t),e.body){let[t,n]=vt(w,W(yt(g)));s=Mt(e.body,Nt,t,n)}}D.isString(y)||(y=y?`include`:`omit`);let t=a&&`credentials`in n.prototype,c={...ee,signal:x,method:o.toUpperCase(),headers:v.normalize().toJSON(),body:s,duplex:`half`,credentials:t?y:void 0};S=a&&new n(i,c);let f=await(a?b(S,ee):b(i,c)),m=u&&(_===`stream`||_===`response`);if(u&&(h||m&&C)){let e={};[`status`,`statusText`,`headers`].forEach(t=>{e[t]=f[t]});let t=D.toFiniteNumber(f.headers.get(`content-length`)),[n,i]=h&&vt(t,W(yt(h),!0))||[];f=new r(Mt(f.body,Nt,n,()=>{i&&i(),C&&C()}),e)}_||=`text`;let te=await d[D.findKey(d,_)||`text`](f,e);return!m&&C&&C(),await new Promise((t,n)=>{mt(t,n,{data:te,headers:V.from(f.headers),status:f.status,statusText:f.statusText,config:e,request:S})})}catch(t){throw C&&C(),t&&t.name===`TypeError`&&/Load failed|fetch/i.test(t.message)?Object.assign(new O(`Network Error`,O.ERR_NETWORK,e,S,t&&t.response),{cause:t.cause||t}):O.from(t,t&&t.code,e,S,t&&t.response)}}},zt=new Map,Bt=e=>{let t=e&&e.env||{},{fetch:n,Request:r,Response:i}=t,a=[r,i,n],o=a.length,s,c,l=zt;for(;o--;)s=a[o],c=l.get(s),c===void 0&&l.set(s,c=o?new Map:Rt(t)),l=c;return c};Bt();var q={http:null,xhr:Dt,fetch:{get:Bt}};D.forEach(q,(e,t)=>{if(e){try{Object.defineProperty(e,`name`,{value:t})}catch{}Object.defineProperty(e,`adapterName`,{value:t})}});var Vt=e=>`- ${e}`,Ht=e=>D.isFunction(e)||e===null||e===!1;function Ut(e,t){e=D.isArray(e)?e:[e];let{length:n}=e,r,i,a={};for(let o=0;o`adapter ${e} `+(t===!1?`is not supported by the environment`:`is not available in the build`));throw new O(`There is no suitable adapter to dispatch the request `+(n?e.length>1?`since : -`+e.map(Vt).join(` -`):` `+Vt(e[0]):`as no adapter specified`),`ERR_NOT_SUPPORT`)}return i}var Wt={getAdapter:Ut,adapters:q};function Gt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new U(null,e)}function Kt(e){return Gt(e),e.headers=V.from(e.headers),e.data=H.call(e,e.transformRequest),[`post`,`put`,`patch`].indexOf(e.method)!==-1&&e.headers.setContentType(`application/x-www-form-urlencoded`,!1),Wt.getAdapter(e.adapter||L.adapter,e)(e).then(function(t){return Gt(e),t.data=H.call(e,e.transformResponse,t),t.headers=V.from(t.headers),t},function(t){return pt(t)||(Gt(e),t&&t.response&&(t.response.data=H.call(e,e.transformResponse,t.response),t.response.headers=V.from(t.response.headers))),Promise.reject(t)})}var qt=`1.15.0`,J={};[`object`,`boolean`,`number`,`function`,`string`,`symbol`].forEach((e,t)=>{J[e]=function(n){return typeof n===e||`a`+(t<1?`n `:` `)+e}});var Jt={};J.transitional=function(e,t,n){function r(e,t){return`[Axios v`+qt+`] Transitional option '`+e+`'`+t+(n?`. `+n:``)}return(n,i,a)=>{if(e===!1)throw new O(r(i,` has been removed`+(t?` in `+t:``)),O.ERR_DEPRECATED);return t&&!Jt[i]&&(Jt[i]=!0,console.warn(r(i,` has been deprecated since v`+t+` and will be removed in the near future`))),e?e(n,i,a):!0}},J.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Yt(e,t,n){if(typeof e!=`object`)throw new O(`options must be an object`,O.ERR_BAD_OPTION_VALUE);let r=Object.keys(e),i=r.length;for(;i-- >0;){let a=r[i],o=t[a];if(o){let t=e[a],n=t===void 0||o(t,a,e);if(n!==!0)throw new O(`option `+a+` must be `+n,O.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new O(`Unknown option `+a,O.ERR_BAD_OPTION)}}var Y={assertOptions:Yt,validators:J},X=Y.validators,Z=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Ke,response:new Ke}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=Error();let n=(()=>{if(!t.stack)return``;let e=t.stack.indexOf(` -`);return e===-1?``:t.stack.slice(e+1)})();try{if(!e.stack)e.stack=n;else if(n){let t=n.indexOf(` -`),r=t===-1?-1:n.indexOf(` -`,t+1),i=r===-1?``:n.slice(r+1);String(e.stack).endsWith(i)||(e.stack+=` -`+n)}}catch{}}throw e}}_request(e,t){typeof e==`string`?(t||={},t.url=e):t=e||{},t=G(this.defaults,t);let{transitional:n,paramsSerializer:r,headers:i}=t;n!==void 0&&Y.assertOptions(n,{silentJSONParsing:X.transitional(X.boolean),forcedJSONParsing:X.transitional(X.boolean),clarifyTimeoutError:X.transitional(X.boolean),legacyInterceptorReqResOrdering:X.transitional(X.boolean)},!1),r!=null&&(D.isFunction(r)?t.paramsSerializer={serialize:r}:Y.assertOptions(r,{encode:X.function,serialize:X.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls===void 0?t.allowAbsoluteUrls=!0:t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls),Y.assertOptions(t,{baseUrl:X.spelling(`baseURL`),withXsrfToken:X.spelling(`withXSRFToken`)},!0),t.method=(t.method||this.defaults.method||`get`).toLowerCase();let a=i&&D.merge(i.common,i[t.method]);i&&D.forEach([`delete`,`get`,`head`,`post`,`put`,`patch`,`common`],e=>{delete i[e]}),t.headers=V.concat(a,i);let o=[],s=!0;this.interceptors.request.forEach(function(e){if(typeof e.runWhen==`function`&&e.runWhen(t)===!1)return;s&&=e.synchronous;let n=t.transitional||N;n&&n.legacyInterceptorReqResOrdering?o.unshift(e.fulfilled,e.rejected):o.push(e.fulfilled,e.rejected)});let c=[];this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,u=0,d;if(!s){let e=[Kt.bind(this),void 0];for(e.unshift(...o),e.push(...c),d=e.length,l=Promise.resolve(t);u{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null}),this.promise.then=e=>{let t,r=new Promise(e=>{n.subscribe(e),t=e}).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e(function(e,r,i){n.reason||(n.reason=new U(e,r,i),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;let t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){let e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}};function Zt(e){return function(t){return e.apply(null,t)}}function Qt(e){return D.isObject(e)&&e.isAxiosError===!0}var Q={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Q).forEach(([e,t])=>{Q[t]=e});function $t(e){let n=new Z(e),r=t(Z.prototype.request,n);return D.extend(r,Z.prototype,n,{allOwnKeys:!0}),D.extend(r,n,null,{allOwnKeys:!0}),r.create=function(t){return $t(G(e,t))},r}var $=$t(L);$.Axios=Z,$.CanceledError=U,$.CancelToken=Xt,$.isCancel=pt,$.VERSION=qt,$.toFormData=j,$.AxiosError=O,$.Cancel=$.CanceledError,$.all=function(e){return Promise.all(e)},$.spread=Zt,$.isAxiosError=Qt,$.mergeConfig=G,$.AxiosHeaders=V,$.formToJSON=e=>tt(D.isHTMLForm(e)?new FormData(e):e),$.getAdapter=Wt.getAdapter,$.HttpStatusCode=Q,$.default=$;export{$ as t}; \ No newline at end of file diff --git a/frontend/dist/assets/book-BRn0Wicm.js b/frontend/dist/assets/book-BRn0Wicm.js new file mode 100644 index 0000000..e5e7ef6 --- /dev/null +++ b/frontend/dist/assets/book-BRn0Wicm.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`book`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/book-c3cQ6ocr.js b/frontend/dist/assets/book-c3cQ6ocr.js deleted file mode 100644 index c4dbf4c..0000000 --- a/frontend/dist/assets/book-c3cQ6ocr.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`book`,[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/book-open-2svOUQwn.js b/frontend/dist/assets/book-open-2svOUQwn.js deleted file mode 100644 index 26046da..0000000 --- a/frontend/dist/assets/book-open-2svOUQwn.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/bot-BktkIwhq.js b/frontend/dist/assets/bot-BktkIwhq.js new file mode 100644 index 0000000..4bf7b10 --- /dev/null +++ b/frontend/dist/assets/bot-BktkIwhq.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`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`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/bot-DWzLMxmu.js b/frontend/dist/assets/bot-DWzLMxmu.js deleted file mode 100644 index f38225b..0000000 --- a/frontend/dist/assets/bot-DWzLMxmu.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`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`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/brain-3sva6MW8.js b/frontend/dist/assets/brain-3sva6MW8.js deleted file mode 100644 index 0d22455..0000000 --- a/frontend/dist/assets/brain-3sva6MW8.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/brain-Bs0UzUvy.js b/frontend/dist/assets/brain-Bs0UzUvy.js new file mode 100644 index 0000000..4456a62 --- /dev/null +++ b/frontend/dist/assets/brain-Bs0UzUvy.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/brain-circuit-BYgtGbs2.js b/frontend/dist/assets/brain-circuit-BYgtGbs2.js new file mode 100644 index 0000000..d8fba90 --- /dev/null +++ b/frontend/dist/assets/brain-circuit-BYgtGbs2.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`brain-circuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/brain-circuit-DqQf8Qkj.js b/frontend/dist/assets/brain-circuit-DqQf8Qkj.js deleted file mode 100644 index 6959b03..0000000 --- a/frontend/dist/assets/brain-circuit-DqQf8Qkj.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`brain-circuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/calendar-Cad5gZZR.js b/frontend/dist/assets/calendar-Cad5gZZR.js new file mode 100644 index 0000000..fdbecc7 --- /dev/null +++ b/frontend/dist/assets/calendar-Cad5gZZR.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/calendar-DL2fCMC-.js b/frontend/dist/assets/calendar-DL2fCMC-.js deleted file mode 100644 index 23690af..0000000 --- a/frontend/dist/assets/calendar-DL2fCMC-.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/camera-BK7z_aNh.js b/frontend/dist/assets/camera-BK7z_aNh.js new file mode 100644 index 0000000..6f1c470 --- /dev/null +++ b/frontend/dist/assets/camera-BK7z_aNh.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/camera-DjFKI4Th.js b/frontend/dist/assets/camera-DjFKI4Th.js deleted file mode 100644 index 166b77d..0000000 --- a/frontend/dist/assets/camera-DjFKI4Th.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chart-column-DrS4GaUq.js b/frontend/dist/assets/chart-column-DrS4GaUq.js new file mode 100644 index 0000000..fbb72cb --- /dev/null +++ b/frontend/dist/assets/chart-column-DrS4GaUq.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chart-column-gDy__4Qa.js b/frontend/dist/assets/chart-column-gDy__4Qa.js deleted file mode 100644 index 8722e28..0000000 --- a/frontend/dist/assets/chart-column-gDy__4Qa.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`chart-column`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/check-CBVCj3hp.js b/frontend/dist/assets/check-CBVCj3hp.js deleted file mode 100644 index 18c789d..0000000 --- a/frontend/dist/assets/check-CBVCj3hp.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/check-DnxCktpz.js b/frontend/dist/assets/check-DnxCktpz.js new file mode 100644 index 0000000..28c7f52 --- /dev/null +++ b/frontend/dist/assets/check-DnxCktpz.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-down-ZviArC66.js b/frontend/dist/assets/chevron-down-ZviArC66.js deleted file mode 100644 index 6a4c98a..0000000 --- a/frontend/dist/assets/chevron-down-ZviArC66.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-down-qQcy55Tl.js b/frontend/dist/assets/chevron-down-qQcy55Tl.js new file mode 100644 index 0000000..6980ffc --- /dev/null +++ b/frontend/dist/assets/chevron-down-qQcy55Tl.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-left-BFAWv4As.js b/frontend/dist/assets/chevron-left-BFAWv4As.js deleted file mode 100644 index ab2360b..0000000 --- a/frontend/dist/assets/chevron-left-BFAWv4As.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-left-CoAjCl9c.js b/frontend/dist/assets/chevron-left-CoAjCl9c.js new file mode 100644 index 0000000..bce710f --- /dev/null +++ b/frontend/dist/assets/chevron-left-CoAjCl9c.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-right-BzAY5P9l.js b/frontend/dist/assets/chevron-right-BzAY5P9l.js deleted file mode 100644 index 84e5463..0000000 --- a/frontend/dist/assets/chevron-right-BzAY5P9l.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-right-CVeYaFvJ.js b/frontend/dist/assets/chevron-right-CVeYaFvJ.js new file mode 100644 index 0000000..97ecd8c --- /dev/null +++ b/frontend/dist/assets/chevron-right-CVeYaFvJ.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-up-BQBhWwJ7.js b/frontend/dist/assets/chevron-up-BQBhWwJ7.js new file mode 100644 index 0000000..eebf147 --- /dev/null +++ b/frontend/dist/assets/chevron-up-BQBhWwJ7.js @@ -0,0 +1 @@ +import{T as e}from"./index-Dy1E248t.js";var t=e(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chevron-up-NHCFdinU.js b/frontend/dist/assets/chevron-up-NHCFdinU.js deleted file mode 100644 index ba4ed57..0000000 --- a/frontend/dist/assets/chevron-up-NHCFdinU.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./jsx-runtime-DmifIpYY.js";var t=e(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]);export{t}; \ No newline at end of file diff --git a/frontend/dist/assets/chunk-OE4NN4TA-BT-WiWAe.js b/frontend/dist/assets/chunk-OE4NN4TA-BT-WiWAe.js deleted file mode 100644 index 9b2f585..0000000 --- a/frontend/dist/assets/chunk-OE4NN4TA-BT-WiWAe.js +++ /dev/null @@ -1,3 +0,0 @@ -import{o as e,r as t}from"./jsx-runtime-DmifIpYY.js";import{t as n}from"./preload-helper-D4M6sveU.js";var r=e(t(),1),i=`popstate`;function a(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function o(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return d(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:f(t)}return m(t,n,null,e)}function s(e,t){if(e===!1||e==null)throw Error(t)}function c(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function l(){return Math.random().toString(36).substring(2,10)}function u(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function d(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?p(t):t,state:n,key:t&&t.key||r||l(),unstable_mask:i}}function f({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function p(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function m(e,t,n,r={}){let{window:o=document.defaultView,v5Compat:s=!1}=r,c=o.history,l=`POP`,f=null,p=m();p??(p=0,c.replaceState({...c.state,idx:p},``));function m(){return(c.state||{idx:null}).idx}function g(){l=`POP`;let e=m(),t=e==null?null:e-p;p=e,f&&f({action:l,location:b.location,delta:t})}function _(e,t){l=`PUSH`;let r=a(e)?e:d(b.location,e,t);n&&n(r,e),p=m()+1;let i=u(r,p),h=b.createHref(r.unstable_mask||r);try{c.pushState(i,``,h)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;o.location.assign(h)}s&&f&&f({action:l,location:b.location,delta:1})}function v(e,t){l=`REPLACE`;let r=a(e)?e:d(b.location,e,t);n&&n(r,e),p=m();let i=u(r,p),o=b.createHref(r.unstable_mask||r);c.replaceState(i,``,o),s&&f&&f({action:l,location:b.location,delta:0})}function y(e){return h(e)}let b={get action(){return l},get location(){return e(o,c)},listen(e){if(f)throw Error(`A history only accepts one active listener`);return o.addEventListener(i,g),f=e,()=>{o.removeEventListener(i,g),f=null}},createHref(e){return t(o,e)},createURL:y,encodeLocation(e){let t=y(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:_,replace:v,go(e){return c.go(e)}};return b}function h(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),s(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:f(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function g(e,t,n=`/`){return _(e,t,n,!1)}function _(e,t,n,r){let i=O((typeof t==`string`?p(t):t).pathname||`/`,n);if(i==null)return null;let a=y(e);x(a);let o=null;for(let e=0;o==null&&e{let l={relativePath:c===void 0?e.path||``:c,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(l.relativePath.startsWith(`/`)){if(!l.relativePath.startsWith(r)&&o)return;s(l.relativePath.startsWith(r),`Absolute route path "${l.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),l.relativePath=l.relativePath.slice(r.length)}let u=M([r,l.relativePath]),d=n.concat(l);e.children&&e.children.length>0&&(s(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${u}".`),y(e.children,t,d,u,o)),!(e.path==null&&!e.index)&&t.push({path:u,score:E(u,e.index),routesMeta:d})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of b(e.path))a(e,t,!0,n)}),t}function b(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=b(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function x(e){e.sort((e,t)=>e.score===t.score?re(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var S=/^:[\w-]+$/,C=3,ee=2,w=1,te=10,ne=-2,T=e=>e===`*`;function E(e,t){let n=e.split(`/`),r=n.length;return n.some(T)&&(r+=ne),t&&(r+=ee),n.filter(e=>!T(e)).reduce((e,t)=>e+(S.test(t)?C:t===``?w:te),r)}function re(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function ie(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ae(e,t=!1,n=!0){c(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function oe(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return c(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function O(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var se=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function ce(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?p(e):e,a;return n?(n=de(n),a=n.startsWith(`/`)?le(n.substring(1),`/`):le(n,t)):a=t,{pathname:a,search:pe(r),hash:me(i)}}function le(e,t){let n=N(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function k(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function ue(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function A(e){let t=ue(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function j(e,t,n,r=!1){let i;typeof e==`string`?i=p(e):(i={...e},s(!i.pathname||!i.pathname.includes(`?`),k(`?`,`pathname`,`search`,i)),s(!i.pathname||!i.pathname.includes(`#`),k(`#`,`pathname`,`hash`,i)),s(!i.search||!i.search.includes(`#`),k(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,c;if(o==null)c=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}c=e>=0?t[e]:`/`}let l=ce(i,c),u=o&&o!==`/`&&o.endsWith(`/`),d=(a||o===`.`)&&n.endsWith(`/`);return!l.pathname.endsWith(`/`)&&(u||d)&&(l.pathname+=`/`),l}var de=e=>e.replace(/\/\/+/g,`/`),M=e=>de(e.join(`/`)),N=e=>e.replace(/\/+$/,``),fe=e=>N(e).replace(/^\/*/,`/`),pe=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,me=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,he=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function ge(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function _e(e){return M(e.map(e=>e.route.path).filter(Boolean))||`/`}var ve=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function ye(e,t){let n=e;if(typeof n!=`string`||!se.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(ve)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=O(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{c(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var be=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(be);var xe=[`GET`,...be];new Set(xe);var P=r.createContext(null);P.displayName=`DataRouter`;var F=r.createContext(null);F.displayName=`DataRouterState`;var Se=r.createContext(!1);function Ce(){return r.useContext(Se)}var we=r.createContext({isTransitioning:!1});we.displayName=`ViewTransition`;var Te=r.createContext(new Map);Te.displayName=`Fetchers`;var Ee=r.createContext(null);Ee.displayName=`Await`;var I=r.createContext(null);I.displayName=`Navigation`;var L=r.createContext(null);L.displayName=`Location`;var R=r.createContext({outlet:null,matches:[],isDataRoute:!1});R.displayName=`Route`;var z=r.createContext(null);z.displayName=`RouteError`;var De=`REACT_ROUTER_ERROR`,Oe=`REDIRECT`,ke=`ROUTE_ERROR_RESPONSE`;function Ae(e){if(e.startsWith(`${De}:${Oe}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function je(e){if(e.startsWith(`${De}:${ke}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new he(t.status,t.statusText,t.data)}catch{}}function Me(e,{relative:t}={}){s(B(),`useHref() may be used only in the context of a component.`);let{basename:n,navigator:i}=r.useContext(I),{hash:a,pathname:o,search:c}=H(e,{relative:t}),l=o;return n!==`/`&&(l=o===`/`?n:M([n,o])),i.createHref({pathname:l,search:c,hash:a})}function B(){return r.useContext(L)!=null}function V(){return s(B(),`useLocation() may be used only in the context of a component.`),r.useContext(L).location}var Ne=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Pe(e){r.useContext(I).static||r.useLayoutEffect(e)}function Fe(){let{isDataRoute:e}=r.useContext(R);return e?Qe():Ie()}function Ie(){s(B(),`useNavigate() may be used only in the context of a component.`);let e=r.useContext(P),{basename:t,navigator:n}=r.useContext(I),{matches:i}=r.useContext(R),{pathname:a}=V(),o=JSON.stringify(A(i)),l=r.useRef(!1);return Pe(()=>{l.current=!0}),r.useCallback((r,i={})=>{if(c(l.current,Ne),!l.current)return;if(typeof r==`number`){n.go(r);return}let s=j(r,JSON.parse(o),a,i.relative===`path`);e==null&&t!==`/`&&(s.pathname=s.pathname===`/`?t:M([t,s.pathname])),(i.replace?n.replace:n.push)(s,i.state,i)},[t,n,o,a,e])}r.createContext(null);function H(e,{relative:t}={}){let{matches:n}=r.useContext(R),{pathname:i}=V(),a=JSON.stringify(A(n));return r.useMemo(()=>j(e,JSON.parse(a),i,t===`path`),[e,a,i,t])}function Le(e,t){return Re(e,t)}function Re(e,t,n){s(B(),`useRoutes() may be used only in the context of a component.`);let{navigator:i}=r.useContext(I),{matches:a}=r.useContext(R),o=a[a.length-1],l=o?o.params:{},u=o?o.pathname:`/`,d=o?o.pathnameBase:`/`,f=o&&o.route;{let e=f&&f.path||``;et(u,!f||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant (or called \`useRoutes()\`) at "${u}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. - -Please change the parent to .`)}let m=V(),h;if(t){let e=typeof t==`string`?p(t):t;s(d===`/`||e.pathname?.startsWith(d),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${e.pathname}" was given in the \`location\` prop.`),h=e}else h=m;let _=h.pathname||`/`,v=_;if(d!==`/`){let e=d.replace(/^\//,``).split(`/`);v=`/`+_.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let y=g(e,{pathname:v});c(f||y!=null,`No routes matched location "${h.pathname}${h.search}${h.hash}" `),c(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${h.pathname}${h.search}${h.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let b=Ge(y&&y.map(e=>Object.assign({},e,{params:Object.assign({},l,e.params),pathname:M([d,i.encodeLocation?i.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?d:M([d,i.encodeLocation?i.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),a,n);return t&&b?r.createElement(L.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,unstable_mask:void 0,...h},navigationType:`POP`}},b):b}function ze(){let e=Ze(),t=ge(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i=`rgba(200,200,200, 0.5)`,a={padding:`0.5rem`,backgroundColor:i},o={padding:`2px 4px`,backgroundColor:i},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=r.createElement(r.Fragment,null,r.createElement(`p`,null,`💿 Hey developer 👋`),r.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,r.createElement(`code`,{style:o},`ErrorBoundary`),` or`,` `,r.createElement(`code`,{style:o},`errorElement`),` prop on your route.`)),r.createElement(r.Fragment,null,r.createElement(`h2`,null,`Unexpected Application Error!`),r.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?r.createElement(`pre`,{style:a},n):null,s)}var Be=r.createElement(ze,null),Ve=class extends r.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=je(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:r.createElement(R.Provider,{value:this.props.routeContext},r.createElement(z.Provider,{value:e,children:this.props.component}));return this.context?r.createElement(Ue,{error:e},t):t}};Ve.contextType=Se;var He=new WeakMap;function Ue({children:e,error:t}){let{basename:n}=r.useContext(I);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Ae(t.digest);if(e){let i=He.get(t);if(i)throw i;let a=ye(e.location,n);if(ve&&!He.get(t))if(a.isExternal||e.reloadDocument)window.location.href=a.absoluteURL||a.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:e.replace}));throw He.set(t,n),n}return r.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${a.absoluteURL||a.to}`})}}return e}function We({routeContext:e,match:t,children:n}){let i=r.useContext(P);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),r.createElement(R.Provider,{value:e},n)}function Ge(e,t=[],n){let i=n?.state;if(e==null){if(!i)return null;if(i.errors)e=i.matches;else if(t.length===0&&!i.initialized&&i.matches.length>0)e=i.matches;else return null}let a=e,o=i?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);s(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(`,`)}`),a=a.slice(0,Math.min(a.length,e+1))}let c=!1,l=-1;if(n&&i){c=i.renderFallback;for(let e=0;e=0?a.slice(0,l+1):[a[0]];break}}}}let u=n?.onError,d=i&&u?(e,t)=>{u(e,{location:i.location,params:i.matches?.[0]?.params??{},unstable_pattern:_e(i.matches),errorInfo:t})}:void 0;return a.reduceRight((e,n,s)=>{let u,f=!1,p=null,m=null;i&&(u=o&&n.route.id?o[n.route.id]:void 0,p=n.route.errorElement||Be,c&&(l<0&&s===0?(et(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):l===s&&(f=!0,m=n.route.hydrateFallbackElement||null)));let h=t.concat(a.slice(0,s+1)),g=()=>{let t;return t=u?p:f?m:n.route.Component?r.createElement(n.route.Component,null):n.route.element?n.route.element:e,r.createElement(We,{match:n,routeContext:{outlet:e,matches:h,isDataRoute:i!=null},children:t})};return i&&(n.route.ErrorBoundary||n.route.errorElement||s===0)?r.createElement(Ve,{location:i.location,revalidation:i.revalidation,component:p,error:u,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:d}):g()},null)}function U(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ke(e){let t=r.useContext(P);return s(t,U(e)),t}function W(e){let t=r.useContext(F);return s(t,U(e)),t}function qe(e){let t=r.useContext(R);return s(t,U(e)),t}function G(e){let t=qe(e),n=t.matches[t.matches.length-1];return s(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Je(){return G(`useRouteId`)}function Ye(){return W(`useNavigation`).navigation}function Xe(){let{matches:e,loaderData:t}=W(`useMatches`);return r.useMemo(()=>e.map(e=>v(e,t)),[e,t])}function Ze(){let e=r.useContext(z),t=W(`useRouteError`),n=G(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Qe(){let{router:e}=Ke(`useNavigate`),t=G(`useNavigate`),n=r.useRef(!1);return Pe(()=>{n.current=!0}),r.useCallback(async(r,i={})=>{c(n.current,Ne),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var $e={};function et(e,t,n){!t&&!$e[e]&&($e[e]=!0,c(!1,n))}r.useOptimistic,r.memo(tt);function tt({routes:e,future:t,state:n,isStatic:r,onError:i}){return Re(e,void 0,{state:n,isStatic:r,onError:i,future:t})}function nt({to:e,replace:t,state:n,relative:i}){s(B(),` may be used only in the context of a component.`);let{static:a}=r.useContext(I);c(!a,` must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.`);let{matches:o}=r.useContext(R),{pathname:l}=V(),u=Fe(),d=j(e,A(o),l,i===`path`),f=JSON.stringify(d);return r.useEffect(()=>{u(JSON.parse(f),{replace:t,state:n,relative:i})},[u,f,i,t,n]),null}function rt(e){s(!1,`A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .`)}function it({basename:e=`/`,children:t=null,location:n,navigationType:i=`POP`,navigator:a,static:o=!1,unstable_useTransitions:l}){s(!B(),`You cannot render a inside another . You should never have more than one in your app.`);let u=e.replace(/^\/*/,`/`),d=r.useMemo(()=>({basename:u,navigator:a,static:o,unstable_useTransitions:l,future:{}}),[u,a,o,l]);typeof n==`string`&&(n=p(n));let{pathname:f=`/`,search:m=``,hash:h=``,state:g=null,key:_=`default`,unstable_mask:v}=n,y=r.useMemo(()=>{let e=O(f,u);return e==null?null:{location:{pathname:e,search:m,hash:h,state:g,key:_,unstable_mask:v},navigationType:i}},[u,f,m,h,g,_,i,v]);return c(y!=null,` is not able to match the URL "${f}${m}${h}" because it does not start with the basename, so the won't render anything.`),y==null?null:r.createElement(I.Provider,{value:d},r.createElement(L.Provider,{children:t,value:y}))}function at({children:e,location:t}){return Le(K(e),t)}r.Component;function K(e,t=[]){let n=[];return r.Children.forEach(e,(e,i)=>{if(!r.isValidElement(e))return;let a=[...t,i];if(e.type===r.Fragment){n.push.apply(n,K(e.props.children,a));return}s(e.type===rt,`[${typeof e.type==`string`?e.type:e.type.name}] is not a component. All component children of must be a or `),s(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let o={id:e.props.id||a.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(o.children=K(e.props.children,a)),n.push(o)}),n}var q=`get`,J=`application/x-www-form-urlencoded`;function Y(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function ot(e){return Y(e)&&e.tagName.toLowerCase()===`button`}function st(e){return Y(e)&&e.tagName.toLowerCase()===`form`}function ct(e){return Y(e)&&e.tagName.toLowerCase()===`input`}function lt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ut(e,t){return e.button===0&&(!t||t===`_self`)&&!lt(e)}var X=null;function dt(){if(X===null)try{new FormData(document.createElement(`form`),0),X=!1}catch{X=!0}return X}var ft=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function pt(e){return e!=null&&!ft.has(e)?(c(!1,`"${e}" is not a valid \`encType\` for \`
    \`/\`\` and will default to "${J}"`),null):e}function mt(e,t){let n,r,i,a,o;if(st(e)){let o=e.getAttribute(`action`);r=o?O(o,t):null,n=e.getAttribute(`method`)||q,i=pt(e.getAttribute(`enctype`))||J,a=new FormData(e)}else if(ot(e)||ct(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a +
    + + { + const value = event.target.value; + setInfrastructureTokenState(value); + setInfrastructureAdminToken(value); + }} + placeholder="Required by Shogun Server mode" + className="mt-2 w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm font-mono focus:border-indigo-500 outline-none transition-all" + /> +

    + Kept only in this browser tab session. Desktop requests from localhost do not require it. +

    +
    + {/* ── Connected State ─────────────────────────────────── */} {isConnected ? (
    diff --git a/frontend/src/pages/Kaizen.tsx b/frontend/src/pages/Kaizen.tsx index f5583f3..2b85254 100644 --- a/frontend/src/pages/Kaizen.tsx +++ b/frontend/src/pages/Kaizen.tsx @@ -19,33 +19,11 @@ import { Eye } from "lucide-react"; import { cn } from '../lib/utils'; +import { renderMarkdown } from '../lib/safeMarkdown'; import { useTranslation } from '../i18n'; const API = '/api/v1/kaizen'; -// ── Simple markdown-to-HTML renderer (no deps) ─────────────── -function escapeHtml(text: string): string { - return text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); -} - -function renderMarkdown(md: string): string { - return escapeHtml(md) - .replace(/^### (.+)$/gm, '

    $1

    ') - .replace(/^## (.+)$/gm, '

    $1

    ') - .replace(/^# (.+)$/gm, '

    $1

    ') - .replace(/\*\*(.+?)\*\*/g, '$1') - .replace(/\*(.+?)\*/g, '$1') - .replace(/^- (.+)$/gm, '
  • $1
  • ') - .replace(/^---$/gm, '
    ') - .replace(/\n\n/g, '

    ') - .replace(/\n/g, '
    '); -} - // ── Severity badge colors ──────────────────────────────────── const severityColors: Record = { CRITICAL: 'text-red-400 bg-red-500/10 border-red-500/30', diff --git a/frontend/src/pages/Nexus.tsx b/frontend/src/pages/Nexus.tsx index fdef7b6..b33946c 100644 --- a/frontend/src/pages/Nexus.tsx +++ b/frontend/src/pages/Nexus.tsx @@ -34,6 +34,11 @@ import { Power, } from 'lucide-react'; import axios from 'axios'; +import { + getInfrastructureAdminToken, + infrastructureRequestConfig, + setInfrastructureAdminToken, +} from '../lib/infrastructureAuth'; import { cn } from '../lib/utils'; import { useTranslation } from '../i18n'; @@ -179,6 +184,9 @@ export function Nexus() { // Invite peer modal const [showInvite, setShowInvite] = useState(false); const [inviteUrl, setInviteUrl] = useState(''); + const [infrastructureToken, setInfrastructureTokenState] = useState( + getInfrastructureAdminToken, + ); const [inviteName, setInviteName] = useState(''); const [inviting, setInviting] = useState(false); const [inviteMsg, setInviteMsg] = useState<{type: 'success'|'error', text: string}|null>(null); @@ -300,10 +308,14 @@ export function Nexus() { setInviting(true); setInviteMsg(null); try { - await axios.post(`/api/v1/workspaces/${selected.id}/peers`, { - peer_url: inviteUrl, - peer_name: inviteName || 'Remote Shogun', - }); + await axios.post( + `/api/v1/workspaces/${selected.id}/peers`, + { + peer_url: inviteUrl, + peer_name: inviteName || 'Remote Shogun', + }, + infrastructureRequestConfig(infrastructureToken), + ); setInviteMsg({ type: 'success', text: 'Invitation sent. Peer is now pending.' }); setInviteUrl(''); setInviteName(''); await refreshSelected(); @@ -316,10 +328,14 @@ export function Nexus() { if (!msgContent.trim() || !selected) return; setSending(true); try { - await axios.post(`/api/v1/workspaces/${selected.id}/messages`, { - content: msgContent, - message_type: msgType, - }); + await axios.post( + `/api/v1/workspaces/${selected.id}/messages`, + { + content: msgContent, + message_type: msgType, + }, + infrastructureRequestConfig(infrastructureToken), + ); setMsgContent(''); await refreshSelected(); } catch (err) { console.error(err); } @@ -330,7 +346,11 @@ export function Nexus() { if (!selected) return; setSavingDoc(true); try { - await axios.patch(`/api/v1/workspaces/${selected.id}/document`, { content: docContent }); + await axios.patch( + `/api/v1/workspaces/${selected.id}/document`, + { content: docContent }, + infrastructureRequestConfig(infrastructureToken), + ); setEditingDoc(false); await refreshSelected(); } catch (err) { console.error(err); } @@ -1197,6 +1217,26 @@ export function Nexus() { className="w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all" />
    +
    + + { + const value = event.target.value; + setInfrastructureTokenState(value); + setInfrastructureAdminToken(value); + }} + placeholder="Required by Shogun Server mode" + className="w-full bg-[#050508] border border-shogun-border rounded-xl px-4 py-3 text-sm focus:border-indigo-500 outline-none transition-all font-mono" + /> +

    + Stored only for this browser tab session. +

    +
    {inviteMsg && (
    {inviteMsg.text} diff --git a/gensui/.env.example b/gensui/.env.example index 16506b0..b871b03 100644 --- a/gensui/.env.example +++ b/gensui/.env.example @@ -5,6 +5,7 @@ GENSUI_SERVER_HOST=0.0.0.0 GENSUI_SERVER_PORT=8787 DEBUG=false +GENSUI_FRONTEND_DIST=./frontend/dist # Database (SQLite default, change for PostgreSQL) GENSUI_DATABASE_URL=sqlite+aiosqlite:///./data/gensui.db @@ -15,7 +16,7 @@ GENSUI_JWT_EXPIRE_HOURS=24 # Initial Admin Account — CHANGE PASSWORD AFTER FIRST LOGIN GENSUI_ADMIN_EMAIL=admin@gensui.local -GENSUI_ADMIN_PASSWORD=changeme +GENSUI_ADMIN_PASSWORD=change-me-to-a-random-admin-password # Enrollment GENSUI_REQUIRE_ENROLLMENT_APPROVAL=true diff --git a/gensui/Dockerfile b/gensui/Dockerfile index c74699c..99db3f9 100644 --- a/gensui/Dockerfile +++ b/gensui/Dockerfile @@ -1,5 +1,5 @@ # ── Stage 1: Build Admin UI ────────────────────────────────── -FROM node:20-alpine AS frontend-builder +FROM node:22-alpine AS frontend-builder WORKDIR /app/frontend COPY gensui/frontend/package*.json ./ RUN npm ci --silent @@ -25,16 +25,19 @@ RUN pip install --no-cache-dir . # Copy application code COPY gensui/ ./gensui/ -COPY .env.example ./.env.example +COPY gensui/.env.example ./.env.example +COPY gensui/docker-entrypoint.sh /usr/local/bin/gensui-entrypoint # Copy built frontend from stage 1 COPY --from=frontend-builder /app/frontend/dist ./frontend/dist -# Create data directory and drop root privileges +# Create only the writable runtime directories and drop root privileges. +# Application code remains root-owned and read-only to the runtime user. RUN groupadd --gid 1000 gensui \ && useradd --uid 1000 --gid gensui --shell /bin/bash --create-home gensui \ && mkdir -p /app/data /app/logs \ - && chown -R gensui:gensui /app + && chmod 0755 /usr/local/bin/gensui-entrypoint \ + && chown -R gensui:gensui /app/data /app/logs USER gensui # Expose port @@ -51,6 +54,10 @@ HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ ENV GENSUI_SERVER_HOST=0.0.0.0 ENV GENSUI_SERVER_PORT=8787 ENV GENSUI_DATABASE_URL=sqlite+aiosqlite:///./data/gensui.db +ENV GENSUI_DATA_PATH=/app/data +ENV GENSUI_LOG_PATH=/app/logs +ENV GENSUI_FRONTEND_DIST=/app/frontend/dist # Run +ENTRYPOINT ["gensui-entrypoint"] CMD ["python", "-m", "gensui"] diff --git a/gensui/README.md b/gensui/README.md new file mode 100644 index 0000000..c93cb7a --- /dev/null +++ b/gensui/README.md @@ -0,0 +1,23 @@ +# Gensui deployment + +For a native developer install, run `install.bat` on Windows or `./install.sh` +on macOS/Linux. + +For the official Docker flow, use a repository-root build context: + +```bash +cp gensui/.env.example gensui/.env +# Replace the JWT and administrator password placeholders. +cd gensui +docker compose up -d --build +``` + +The default service is available only at `http://127.0.0.1:8787`. Remote access +must use an explicit VPN, authenticated gateway, enterprise ingress, or the +optional Nginx `server` profile with operator-managed TLS certificates. Do not +expose the service directly to the public internet. + +The container runs as UID/GID 1000 with a read-only root filesystem and writes +only to the data and log volumes. See +[`docs/deployment/docker.md`](../docs/deployment/docker.md) before upgrading an +existing root-owned deployment. diff --git a/gensui/app.py b/gensui/app.py index a40a6f9..e3ac513 100644 --- a/gensui/app.py +++ b/gensui/app.py @@ -7,10 +7,10 @@ from fastapi import FastAPI, HTTPException from fastapi.middleware.cors import CORSMiddleware -from fastapi.staticfiles import StaticFiles from fastapi.responses import FileResponse +from fastapi.staticfiles import StaticFiles -from gensui.config import gensui_settings, GENSUI_ROOT +from gensui.config import gensui_settings log = logging.getLogger("gensui") @@ -22,9 +22,9 @@ async def lifespan(app: FastAPI): gensui_settings.ensure_directories() # Create all tables - from gensui.db.engine import engine - from gensui.db.base import Base import gensui.db.models # noqa: F401 — register models + from gensui.db.base import Base + from gensui.db.engine import engine async with engine.begin() as conn: await conn.run_sync(Base.metadata.create_all) @@ -37,14 +37,14 @@ async def lifespan(app: FastAPI): "ALTER TABLE security_postures ADD COLUMN tool_overrides_json TEXT" )) log.info("Migration: added tool_overrides_json column to security_postures") - except Exception: + except Exception: # noqa: BLE001, S110 pass # Column already exists try: await conn.execute(sa_text( "ALTER TABLE security_postures ADD COLUMN advanced_toolgate_json TEXT" )) log.info("Migration: added advanced_toolgate_json column to security_postures") - except Exception: + except Exception: # noqa: BLE001, S110 pass # Column already exists # Seed built-in postures and initial admin @@ -85,21 +85,21 @@ def create_app() -> FastAPI: ) # ── Register API Routers ───────────────────────────────── + from gensui.api.alerts import router as alerts_router + from gensui.api.audit import router as audit_router from gensui.api.auth import router as auth_router - from gensui.api.enrollment import router as enrollment_router - from gensui.api.heartbeat import router as heartbeat_router - from gensui.api.telemetry import router as telemetry_router - from gensui.api.policy import router as policy_router from gensui.api.commands import router as commands_router - from gensui.api.harakiri import router as harakiri_router - from gensui.api.members import router as members_router - from gensui.api.postures import router as postures_router - from gensui.api.audit import router as audit_router - from gensui.api.alerts import router as alerts_router from gensui.api.dashboard import router as dashboard_router - from gensui.api.monitoring import router as monitoring_router + from gensui.api.enrollment import router as enrollment_router from gensui.api.fleet_audit import router as fleet_audit_router + from gensui.api.harakiri import router as harakiri_router + from gensui.api.heartbeat import router as heartbeat_router from gensui.api.identity import router as identity_router + from gensui.api.members import router as members_router + from gensui.api.monitoring import router as monitoring_router + from gensui.api.policy import router as policy_router + from gensui.api.postures import router as postures_router + from gensui.api.telemetry import router as telemetry_router prefix = "/api/gensui" app.include_router(auth_router, prefix=prefix) @@ -124,9 +124,7 @@ async def health_check(): return {"status": "ok", "service": "gensui", "version": "0.1.0"} # ── Serve Frontend (production) ────────────────────────── - frontend_dist = GENSUI_ROOT.parent / "frontend" / "dist" - if not frontend_dist.exists(): - frontend_dist = GENSUI_ROOT / "frontend" / "dist" + frontend_dist = gensui_settings.gensui_frontend_dist if frontend_dist.exists(): # Serve /assets/* static files assets_path = frontend_dist / "assets" @@ -141,7 +139,7 @@ async def serve_root(): # Catch-all for SPA routing — must NOT match /api, /docs, /redoc @app.get("/{full_path:path}") async def serve_frontend(full_path: str): - if full_path.startswith("api/") or full_path.startswith("docs") or full_path.startswith("redoc") or full_path.startswith("openapi"): + if full_path.startswith(("api/", "docs", "redoc", "openapi")): raise HTTPException(status_code=404) # Serve actual file if it exists (favicon.svg, logo.png, etc.) target = frontend_dist / full_path @@ -149,5 +147,10 @@ async def serve_frontend(full_path: str): return FileResponse(target) # Otherwise serve index.html (SPA client-side routing) return FileResponse(str(frontend_dist / "index.html")) + else: + log.warning( + "Gensui frontend distribution is missing at %s; UI routes are disabled", + frontend_dist, + ) return app diff --git a/gensui/config.py b/gensui/config.py index 889bf4f..0ce3c87 100644 --- a/gensui/config.py +++ b/gensui/config.py @@ -7,7 +7,6 @@ from __future__ import annotations from pathlib import Path -from typing import Literal from pydantic_settings import BaseSettings, SettingsConfigDict @@ -59,6 +58,7 @@ class GensuiSettings(BaseSettings): # ── Paths ──────────────────────────────────────────────── gensui_data_path: Path = GENSUI_ROOT / "data" gensui_log_path: Path = GENSUI_ROOT / "logs" + gensui_frontend_dist: Path = GENSUI_ROOT / "frontend" / "dist" def ensure_directories(self) -> None: """Create required filesystem directories.""" diff --git a/gensui/docker-compose.yml b/gensui/docker-compose.yml index fb30351..6279d94 100644 --- a/gensui/docker-compose.yml +++ b/gensui/docker-compose.yml @@ -12,6 +12,19 @@ services: volumes: - gensui_data:/app/data - gensui_logs:/app/logs + read_only: true + tmpfs: + - /tmp:size=256m,mode=1777 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + healthcheck: + test: ["CMD", "curl", "--fail", "--silent", "http://127.0.0.1:8787/api/gensui/health"] + interval: 15s + timeout: 5s + start_period: 30s + retries: 5 nginx: image: nginx:1.27-alpine @@ -20,7 +33,8 @@ services: - server restart: unless-stopped depends_on: - - gensui + gensui: + condition: service_healthy volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro - ./certs:/etc/nginx/certs:ro diff --git a/gensui/docker-entrypoint.sh b/gensui/docker-entrypoint.sh new file mode 100644 index 0000000..09931b4 --- /dev/null +++ b/gensui/docker-entrypoint.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh +set -eu + +umask 077 + +case "${GENSUI_JWT_SECRET:-}" in + ""|change-me-*) + echo "ERROR: GENSUI_JWT_SECRET must be set to a unique random value." >&2 + exit 1 + ;; +esac + +case "${GENSUI_ADMIN_PASSWORD:-}" in + ""|changeme|change-me-*) + echo "ERROR: GENSUI_ADMIN_PASSWORD must be changed before Gensui starts." >&2 + exit 1 + ;; +esac + +mkdir -p /app/data /app/logs + +exec "$@" diff --git a/gensui/frontend/package-lock.json b/gensui/frontend/package-lock.json index 0bad9fc..a95de3a 100644 --- a/gensui/frontend/package-lock.json +++ b/gensui/frontend/package-lock.json @@ -9,11 +9,11 @@ "version": "0.0.0", "dependencies": { "@tailwindcss/vite": "^4.3.0", - "axios": "^1.17.0", + "axios": "1.18.1", "lucide-react": "^1.17.0", "react": "^19.2.6", "react-dom": "^19.2.6", - "react-router-dom": "^7.17.0", + "react-router-dom": "7.18.1", "tailwindcss": "^4.3.0" }, "devDependencies": { @@ -28,7 +28,10 @@ "globals": "^17.6.0", "typescript": "~6.0.2", "typescript-eslint": "^8.59.2", - "vite": "^8.0.12" + "vite": "8.1.5" + }, + "engines": { + "node": ">=22.12 <25" } }, "node_modules/@babel/code-frame": { @@ -272,20 +275,20 @@ } }, "node_modules/@emnapi/core": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", - "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.1.tgz", + "integrity": "sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==", "license": "MIT", "optional": true, "dependencies": { - "@emnapi/wasi-threads": "1.2.1", + "@emnapi/wasi-threads": "1.2.2", "tslib": "^2.4.0" } }, "node_modules/@emnapi/runtime": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz", - "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.1.tgz", + "integrity": "sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==", "license": "MIT", "optional": true, "dependencies": { @@ -293,9 +296,9 @@ } }, "node_modules/@emnapi/wasi-threads": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", - "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.2.tgz", + "integrity": "sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==", "license": "MIT", "optional": true, "dependencies": { @@ -542,13 +545,13 @@ } }, "node_modules/@napi-rs/wasm-runtime": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz", - "integrity": "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.6.tgz", + "integrity": "sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==", "license": "MIT", "optional": true, "dependencies": { - "@tybys/wasm-util": "^0.10.1" + "@tybys/wasm-util": "^0.10.3" }, "funding": { "type": "github", @@ -560,18 +563,18 @@ } }, "node_modules/@oxc-project/types": { - "version": "0.133.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.133.0.tgz", - "integrity": "sha512-KzkdCd6Uxqnf6l3HOw1xfatAlUURA0g14cvBYFyJ5SaNOQbOUvBr9PKArcPcrNIeRsBdgcUzOGrhKveVpvOIGA==", + "version": "0.139.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.139.0.tgz", + "integrity": "sha512-r9gHphtCs+1M7J0pw6Sn/hh/Wpa/iQrOOkrNAlVLF/gHq+/CJmHIWKKUUhdWjcD6CIa8idarspCsASiXCXvFUw==", "license": "MIT", "funding": { "url": "https://github.com/sponsors/Boshen" } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.3.tgz", - "integrity": "sha512-454rs7jHngixp/NMxd5srYD57OnzSlZ/eFTETjORQHLwJG1lRtmNOJcBerZlfu4GjKqeq8aCCIQrMdHyhI51Hw==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.1.5.tgz", + "integrity": "sha512-lZg8fqIv2v7FF237bwMgzGZEJvGL79/s5knJ/i6FmsGF4XXlzccZ4jb+TrFIxtSSxFtIpdsgrPZeMk1I9AFcyQ==", "cpu": [ "arm64" ], @@ -585,9 +588,9 @@ } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.3.tgz", - "integrity": "sha512-PcAhP+ynjURNyy8SKGl5DQP94aGuB/7JrXJb/t7P+hanXvQVMWzUvRRhBAcg/lNRadBhoUPqSoP4xw5tR/KBEA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.1.5.tgz", + "integrity": "sha512-51Bnx9pNiMRKSUNtBfySkNJ9vMU9Hh3I1ozDd6gyPPYzaXCfnptUcEZxXGYFn+ul2dtcMUiqGR1Yai2K10uoTw==", "cpu": [ "arm64" ], @@ -601,9 +604,9 @@ } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.3.tgz", - "integrity": "sha512-9YpfeUvSE2RS7wysJ81uOZkXJz7f7Q55H2Gvp3VEw/EsahqDtrphrZ0EwDLK5vvKOzaCrBsjF8JmnMLcUt78Gg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.1.5.tgz", + "integrity": "sha512-Tm+gbfC0aHu1tBA/JvKQh32S0K6YgCHkiAF4/W6xX0K0RmNuc94VeK419dJoE65R5aRxmo+noZQSWrAMF6yb6g==", "cpu": [ "x64" ], @@ -617,9 +620,9 @@ } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.3.tgz", - "integrity": "sha512-yB1IlAsSNHncV6SCTL27/MVGR5htvQsoGxIv5KMGXALp+Ll1wYsn+x98M9MW7qa+NdSbvrrY7ANI4wLJ0n1e6g==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.1.5.tgz", + "integrity": "sha512-JMzDKCCXq93YccG5gz3hvOs1oXRKAf0XYpfOS88e+wZrC8Iugj6j68867vrYZkvpDDpKn/KoKORThmchMpF6TA==", "cpu": [ "x64" ], @@ -633,9 +636,9 @@ } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.3.tgz", - "integrity": "sha512-Yi30IVAAfLUCy2MseFjbB1jAMDl1VMCAas5StnYp8da9+CKvMd2H2cbEjWcw5NPaPqzvYkVIaF1nNUG+b7u/sw==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.1.5.tgz", + "integrity": "sha512-uML21j2K5TfPGutKxub+M+nLjZIrWjXQ5Grx4lCe/nimTj9B4L63zHpjXLl4y0L3mcm2htEQIb06oCG/szerNw==", "cpu": [ "arm" ], @@ -649,12 +652,15 @@ } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.3.tgz", - "integrity": "sha512-jsO7R8To+AdlYgUmN5sHSCZbfhtMBkO0WUx8iORQnPcMMdgr7qM2DQmMwgabs3GhNztdmoKkMKQFHD6DTMCIQw==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.1.5.tgz", + "integrity": "sha512-navSiuTMogvnQoZoM/v+l3ZWo50/NTwSHSzheABx/RCnmUPaKwq9qSo4Br2OYRs21+Fz8uFqITZM3H4opOB0/Q==", "cpu": [ "arm64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -665,12 +671,15 @@ } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.3.tgz", - "integrity": "sha512-VWkUHwWriDciit80wleYwKILoR/KMvxh/IdwS/paX+ZgpuRpCrKLUdadJbc0NpBEiyhpYawsJ73j9aCvOH+f7Q==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.1.5.tgz", + "integrity": "sha512-lAryqH7IteztmCXQXk0etKj4wBQ7Gx5S6LjKhsgp9zb8I5bsuvU/2llH1hDQcjsFeqIsovMVN339/8pUDDBXxA==", "cpu": [ "arm64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -681,12 +690,15 @@ } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.3.tgz", - "integrity": "sha512-5f1laC0SlIR0yDbFCd8acUhvJIag6N3zC5P7oUPN6wX0aOma+uKJ0wBDH5aq7I1PVI2ttTlhJwzwRIBnLiSGEg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.1.5.tgz", + "integrity": "sha512-fsK/sNBnxzBlL4O1JNrZakVQxPspqpED5dLtNsZS9oOKmtSpdNIzxH2kkol5HYTWJN47sE20ztMJPxfZ89qGOg==", "cpu": [ "ppc64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -697,12 +709,15 @@ } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.3.tgz", - "integrity": "sha512-Iq4ko0r4XsgbrF/LunNgHtAGLRRVE2kXonAXQ/MV0mC6jQpMOhW1SvtZja2EhC/kd05++bP78dsqBeIQyYJ6Yg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.1.5.tgz", + "integrity": "sha512-gLYb4BIadlfTOYT5gO503n8zQjXflgzpD0FcyKh0Mzx3rqCZKnHoJWV9xe1KXUJ5lx2JfcSHr/mhzS0PC/McAA==", "cpu": [ "s390x" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -713,12 +728,15 @@ } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.3.tgz", - "integrity": "sha512-B8m6tD5+/N5FeNQFbKlLA/2yVq9ycQP1SeedyEYYKWBNR3ZQbkvIUcNnDNM03lO1l5F2roiiFJGgvoLLyZXtSg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.1.5.tgz", + "integrity": "sha512-FjcpEKUyJygHgs1o50VYNvkt5+7Le/VEdYt0AkRpkL33MnyQfwr8l5mXwMmfmTbyMPr5vJLC+8/Gd9gXnwU1QQ==", "cpu": [ "x64" ], + "libc": [ + "glibc" + ], "license": "MIT", "optional": true, "os": [ @@ -729,12 +747,15 @@ } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.3.tgz", - "integrity": "sha512-pSdpdUJHkuCxun9LE7jvgUB9qsRgaiyNNCX7m/AvHTcq67AiT/Yhoxvw5zPfhrM8k/BfP8ce/hMOpthKDpEUow==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.1.5.tgz", + "integrity": "sha512-Me+PfPI2TMeOQk0gYWfLQZtTktrmzbr8cDboqX83XKc7UrgAi55gF+2dUkWdxd19n55Essp2yeca+O9N5rBxHg==", "cpu": [ "x64" ], + "libc": [ + "musl" + ], "license": "MIT", "optional": true, "os": [ @@ -745,9 +766,9 @@ } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.3.tgz", - "integrity": "sha512-OXXS3RKJgX2uLwM+gYyuH5omcH8fL1LJs96pZGgtetVCahON57+d4SJHzTgZiOjxgGkSnpXpOsWuPDGAKAigEg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.1.5.tgz", + "integrity": "sha512-yc5WrLzXks6zCQfn9Oxr8pORKyl/pF+QjHmW/Qx3qu0oyrrNC+y2JLTU1E2rcWYAmzlnqngWXHQjy51VzW70Vw==", "cpu": [ "arm64" ], @@ -761,27 +782,27 @@ } }, "node_modules/@rolldown/binding-wasm32-wasi": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.3.tgz", - "integrity": "sha512-JTtb8BWFynicNSoPrehsCzBtOKjZ6jhMiPFEmOiuXg1Fl8dn2KHQob+GuPSGR0dryQa1PQJbzjF3dqO/whhjLg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.1.5.tgz", + "integrity": "sha512-VbQGPX2b4r48TAMIM2cjgluIM1HYutm4pcTEJsle7iEP7sB1dFqtPLBVbdLAZCxy1txCcPxf4QFf4v8uvltPqA==", "cpu": [ "wasm32" ], "license": "MIT", "optional": true, "dependencies": { - "@emnapi/core": "1.10.0", - "@emnapi/runtime": "1.10.0", - "@napi-rs/wasm-runtime": "^1.1.4" + "@emnapi/core": "1.11.1", + "@emnapi/runtime": "1.11.1", + "@napi-rs/wasm-runtime": "^1.1.6" }, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.3.tgz", - "integrity": "sha512-gEdFFEN70A/jxb2svrWsN3aDL7OUtmvlOy+6fa2jxG8K0wQ1ZbdeLGnidov6Yu5/733dI5ySfzFlQ/cb0bSz1g==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.1.5.tgz", + "integrity": "sha512-gHv82k63z4qpV5+Q1y/12KrK0ltWBukVDI8nZcbT7Tt/ZlOIVwppazneq0F93oDxTo3IgAMEDIoQh3E2n6mVsw==", "cpu": [ "arm64" ], @@ -795,9 +816,9 @@ } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.3.tgz", - "integrity": "sha512-eXB7CHuaQdqmJcc3koCNtNPmT/bj2gc999kUFgBxG8Ac0NdgXc4rkCHhqrgrhN3zddvvvrgzj1e90SuSfmyIXA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.1.5.tgz", + "integrity": "sha512-tTZuDBPw85tEN5PQi1pnEBzDy0Z49HtScLAbD5t6hyeU92A95pRWaSMw1GZZi/RwgSgUIl0xrSlXIT/9QzvYSA==", "cpu": [ "x64" ], @@ -1074,9 +1095,9 @@ } }, "node_modules/@tybys/wasm-util": { - "version": "0.10.2", - "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.2.tgz", - "integrity": "sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==", + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", + "integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==", "license": "MIT", "optional": true, "dependencies": { @@ -1462,9 +1483,9 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.17.0.tgz", - "integrity": "sha512-J8SwNxprqqpbfenehxWYXE7CW+wM1BB4w3+N+g+/Wx40xM4rsLrfPmHHxSWIxJLYDgSY/HqlFPIYb2/S3rxafw==", + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.18.1.tgz", + "integrity": "sha512-3nTvFlvpn9Zu/RkHUqtc7/+al4UpRW5az71ap5zccp6e8RAYEzhMTecX8Dz1wWDYrPpUoB1HAQEGEAEvUr7S9g==", "license": "MIT", "dependencies": { "follow-redirects": "^1.16.0", @@ -1497,16 +1518,16 @@ } }, "node_modules/brace-expansion": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz", - "integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==", + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz", + "integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==", "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^4.0.2" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" } }, "node_modules/browserslist": { @@ -2748,9 +2769,9 @@ "license": "MIT" }, "node_modules/nanoid": { - "version": "3.3.12", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz", - "integrity": "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==", + "version": "3.3.16", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz", + "integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==", "funding": [ { "type": "github", @@ -2859,9 +2880,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", - "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", "license": "MIT", "engines": { "node": ">=12" @@ -2871,9 +2892,9 @@ } }, "node_modules/postcss": { - "version": "8.5.15", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz", - "integrity": "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==", + "version": "8.5.23", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.23.tgz", + "integrity": "sha512-g50586zr4bZmwFiTlflMu8E0bDTb5I5gertgwAKmsdUlTQIhZtunzUlD1WSzwcVWPoAVpsrA6vlfCD7oXvRwgg==", "funding": [ { "type": "opencollective", @@ -2890,7 +2911,7 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.12", + "nanoid": "^3.3.16", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" }, @@ -2949,9 +2970,9 @@ } }, "node_modules/react-router": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.17.0.tgz", - "integrity": "sha512-FDELK7rTMlCHO5+reyXsPlmfr7N1F91lPHsWYfMEGQm/KQ+F4JFM8jGoeQDmDvdTs93Fw9aSilH+uKRb4/jXvQ==", + "version": "7.18.1", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.1.tgz", + "integrity": "sha512-GDLgg3i3uM0aeJO3Fm+TCS+sDQ7gu12T6x0qdTEzcwqEfleci7JwugVNIF3U//0FWKnJT7ptG+20B2jfDqnZAg==", "license": "MIT", "dependencies": { "cookie": "^1.0.1", @@ -2971,12 +2992,12 @@ } }, "node_modules/react-router-dom": { - "version": "7.17.0", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.17.0.tgz", - "integrity": "sha512-fyU2yjGups/hE6Xz0I5ZYbVL8Gx29eCjgpHaRaTaVU+OOAdfRX05KsvyRm0GO8YQwOkhpU3MurW1jyMUJn+zSw==", + "version": "7.18.1", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.1.tgz", + "integrity": "sha512-KaZh+X/6UtEp28x51AUYZDMg9NGoz2ja3dNHa+ta/tk40vCzKhQ/RypCWBMLbmDr6//E24Vv5uPsrqXFozdkAg==", "license": "MIT", "dependencies": { - "react-router": "7.17.0" + "react-router": "7.18.1" }, "engines": { "node": ">=20.0.0" @@ -2987,12 +3008,12 @@ } }, "node_modules/rolldown": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.3.tgz", - "integrity": "sha512-i00lAJ2ks1BYr7rjNjKC7BcqAS7nVfiT3QX1SI5aY+AFHblCmaUf9OE9dbdzDvW6dJxbi2ZCZiy9v3CcwOiX3g==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.1.5.tgz", + "integrity": "sha512-t9z29cJjXf/vxQ8dyhCSpt6H6aSwHTk8cT5I3iy6SMXuFpk5mB6PL6XfC8PCwrPTx93udwKUm9HRteAlTGBLiA==", "license": "MIT", "dependencies": { - "@oxc-project/types": "=0.133.0", + "@oxc-project/types": "=0.139.0", "@rolldown/pluginutils": "^1.0.0" }, "bin": { @@ -3002,21 +3023,21 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm64": "1.0.3", - "@rolldown/binding-darwin-arm64": "1.0.3", - "@rolldown/binding-darwin-x64": "1.0.3", - "@rolldown/binding-freebsd-x64": "1.0.3", - "@rolldown/binding-linux-arm-gnueabihf": "1.0.3", - "@rolldown/binding-linux-arm64-gnu": "1.0.3", - "@rolldown/binding-linux-arm64-musl": "1.0.3", - "@rolldown/binding-linux-ppc64-gnu": "1.0.3", - "@rolldown/binding-linux-s390x-gnu": "1.0.3", - "@rolldown/binding-linux-x64-gnu": "1.0.3", - "@rolldown/binding-linux-x64-musl": "1.0.3", - "@rolldown/binding-openharmony-arm64": "1.0.3", - "@rolldown/binding-wasm32-wasi": "1.0.3", - "@rolldown/binding-win32-arm64-msvc": "1.0.3", - "@rolldown/binding-win32-x64-msvc": "1.0.3" + "@rolldown/binding-android-arm64": "1.1.5", + "@rolldown/binding-darwin-arm64": "1.1.5", + "@rolldown/binding-darwin-x64": "1.1.5", + "@rolldown/binding-freebsd-x64": "1.1.5", + "@rolldown/binding-linux-arm-gnueabihf": "1.1.5", + "@rolldown/binding-linux-arm64-gnu": "1.1.5", + "@rolldown/binding-linux-arm64-musl": "1.1.5", + "@rolldown/binding-linux-ppc64-gnu": "1.1.5", + "@rolldown/binding-linux-s390x-gnu": "1.1.5", + "@rolldown/binding-linux-x64-gnu": "1.1.5", + "@rolldown/binding-linux-x64-musl": "1.1.5", + "@rolldown/binding-openharmony-arm64": "1.1.5", + "@rolldown/binding-wasm32-wasi": "1.1.5", + "@rolldown/binding-win32-arm64-msvc": "1.1.5", + "@rolldown/binding-win32-x64-msvc": "1.1.5" } }, "node_modules/scheduler": { @@ -3228,15 +3249,15 @@ } }, "node_modules/vite": { - "version": "8.0.16", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.16.tgz", - "integrity": "sha512-h9bXPmJichP5fLmVQo3PyaGSDE2n3aPuomeAlVRm0JLmt4rY6zmPKd59HYI4LNW8oTK7tlTsuC7l/m7awx9Jcw==", + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.1.5.tgz", + "integrity": "sha512-7ULLwsCdYx/nRyrpiEwvqb5TFHrMVZyBt+rg/OAXT7rgj/z+DtTDyKFeLAdDkubDVDKD8jOsndmy7m55XcfUsw==", "license": "MIT", "dependencies": { "lightningcss": "^1.32.0", - "picomatch": "^4.0.4", - "postcss": "^8.5.15", - "rolldown": "1.0.3", + "picomatch": "^4.0.5", + "postcss": "^8.5.17", + "rolldown": "~1.1.5", "tinyglobby": "^0.2.17" }, "bin": { @@ -3253,7 +3274,7 @@ }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", - "@vitejs/devtools": "^0.1.18", + "@vitejs/devtools": "^0.3.0", "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", diff --git a/gensui/frontend/package.json b/gensui/frontend/package.json index 7bbfe87..2b04342 100644 --- a/gensui/frontend/package.json +++ b/gensui/frontend/package.json @@ -3,19 +3,24 @@ "private": true, "version": "0.0.0", "type": "module", + "engines": { + "node": ">=22.12 <25" + }, "scripts": { "dev": "vite", "build": "tsc -b && vite build", "lint": "eslint .", + "lint:security": "eslint vite.config.ts src/main.tsx", + "audit:security": "node ../../scripts/check-npm-audit.mjs .", "preview": "vite preview" }, "dependencies": { "@tailwindcss/vite": "^4.3.0", - "axios": "^1.17.0", + "axios": "1.18.1", "lucide-react": "^1.17.0", "react": "^19.2.6", "react-dom": "^19.2.6", - "react-router-dom": "^7.17.0", + "react-router-dom": "7.18.1", "tailwindcss": "^4.3.0" }, "devDependencies": { @@ -30,6 +35,6 @@ "globals": "^17.6.0", "typescript": "~6.0.2", "typescript-eslint": "^8.59.2", - "vite": "^8.0.12" + "vite": "8.1.5" } } diff --git a/pyproject.toml b/pyproject.toml index 61b270c..b502d85 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "shogun" -version = "1.44.9" +version = "1.44.12" description = "Shogun — A GUI-first AI agent framework with structured memory, governed autonomy, and OpenClaw compatibility" readme = "README.md" requires-python = ">=3.10" @@ -59,6 +59,12 @@ dependencies = [ postgres = [ "asyncpg>=0.30.0", ] +server = [ + "asyncpg>=0.30.0", + "openpyxl>=3.1.0", + "python-docx>=1.1.0", + "python-pptx>=0.6.23", +] ronin = [ "mss>=9.0.0", "pyautogui>=0.9.54", diff --git a/scripts/check-npm-audit.mjs b/scripts/check-npm-audit.mjs new file mode 100644 index 0000000..2ebf656 --- /dev/null +++ b/scripts/check-npm-audit.mjs @@ -0,0 +1,67 @@ +#!/usr/bin/env node + +import { spawnSync } from 'node:child_process'; +import process from 'node:process'; + +const APPROVED_ADVISORIES = new Set([ + 'https://github.com/advisories/GHSA-qwww-vcr4-c8h2', +]); +const windows = process.platform === 'win32'; +const audit = spawnSync( + windows ? process.env.ComSpec : 'npm', + windows ? ['/d', '/s', '/c', 'npm audit --json'] : ['audit', '--json'], + { + cwd: process.argv[2] || process.cwd(), + encoding: 'utf8', + shell: false, + }, +); + +if (audit.error) { + process.stderr.write(`Could not execute npm audit: ${audit.error.message}\n`); + process.exit(1); +} + +let report; +try { + report = JSON.parse(audit.stdout); +} catch { + process.stderr.write(audit.stderr || audit.stdout || 'npm audit returned invalid JSON\n'); + process.exit(audit.status || 1); +} + +const vulnerabilities = report.vulnerabilities || {}; +const memo = new Map(); + +function approved(name, trail = new Set()) { + if (memo.has(name)) return memo.get(name); + if (trail.has(name)) return false; + const finding = vulnerabilities[name]; + if (!finding) return false; + if (!['high', 'critical'].includes(finding.severity)) return true; + + const nextTrail = new Set(trail).add(name); + const result = finding.via.every(via => { + if (typeof via === 'string') return approved(via, nextTrail); + return APPROVED_ADVISORIES.has(via.url); + }); + memo.set(name, result); + return result; +} + +const blocked = Object.keys(vulnerabilities).filter(name => !approved(name)); +if (blocked.length) { + process.stderr.write(`Unapproved High/Critical npm findings: ${blocked.join(', ')}\n`); + process.stderr.write(JSON.stringify(report, null, 2)); + process.exit(1); +} + +const excepted = Object.keys(vulnerabilities).filter(name => approved(name)); +if (excepted.length) { + process.stdout.write( + `Approved temporary exception only: GHSA-qwww-vcr4-c8h2 (${excepted.join(', ')}). ` + + 'See docs/security/frontend-dependency-exceptions.md.\n', + ); +} else { + process.stdout.write('No High or Critical npm findings.\n'); +} diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index c77a30e..3cd9351 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -17,6 +17,13 @@ case "${VAULT_ENCRYPTION_KEY:-}" in ;; esac +case "${SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN:-}" in + ""|change-me-*) + echo "ERROR: SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN must be set to a unique random value." >&2 + exit 1 + ;; +esac + mkdir -p /app/data /app/vault /app/logs /app/configs /app/tmp if [ "${DEPLOYMENT_MODE:-}" != "server" ]; then diff --git a/shogun/__init__.py b/shogun/__init__.py index 75558da..e658c5e 100644 --- a/shogun/__init__.py +++ b/shogun/__init__.py @@ -1,3 +1,3 @@ """Shogun — AI Agent Framework.""" -__version__ = "1.44.9" +__version__ = "1.44.12" diff --git a/shogun/api/a2a.py b/shogun/api/a2a.py index 13a4f15..b21c981 100644 --- a/shogun/api/a2a.py +++ b/shogun/api/a2a.py @@ -25,20 +25,22 @@ from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException from pydantic import BaseModel, Field -from sqlalchemy import select, desc +from sqlalchemy import desc, select from sqlalchemy.ext.asyncio import AsyncSession from shogun.api.deps import get_db +from shogun.api.infrastructure_auth import require_infrastructure_admin from shogun.config import settings from shogun.db.engine import async_session_factory from shogun.db.models.agent import Agent -from shogun.db.models.workspace import Workspace, WorkspacePeer, WorkspaceMessage +from shogun.db.models.workspace import Workspace, WorkspaceMessage, WorkspacePeer from shogun.integrations.a2a_client import ( build_envelope, get_a2a_client, verify_signature, ) from shogun.schemas.common import ApiResponse +from shogun.services.ssrf_guard import SSRFValidationError logger = logging.getLogger(__name__) @@ -51,7 +53,7 @@ async def _get_primary_agent(db: AsyncSession) -> Agent | None: result = await db.execute( - select(Agent).where(Agent.is_primary == True, Agent.is_deleted == False) + select(Agent).where(Agent.is_primary.is_(True), Agent.is_deleted.is_(False)) ) return result.scalars().first() @@ -365,6 +367,7 @@ async def patch_document( body: PatchDocumentRequest, background_tasks: BackgroundTasks, db: AsyncSession = Depends(get_db), + _actor: str = Depends(require_infrastructure_admin), ): """Update the workspace's shared document and fan it out to all peers.""" ws = await db.get(Workspace, workspace_id) @@ -424,6 +427,7 @@ async def invite_peer( body: InvitePeerRequest, background_tasks: BackgroundTasks, db: AsyncSession = Depends(get_db), + _actor: str = Depends(require_infrastructure_admin), ): """Invite a remote Shogun to the workspace. @@ -437,6 +441,10 @@ async def invite_peer( # Ping remote to get real name client = get_a2a_client() + try: + client.validate_peer_url(body.peer_url) + except SSRFValidationError as exc: + raise HTTPException(status_code=400, detail=str(exc)) from exc identity = await client.ping(body.peer_url) resolved_name = ( identity.get("data", {}).get("name") or body.peer_name @@ -570,6 +578,7 @@ async def post_message( body: PostMessageRequest, background_tasks: BackgroundTasks, db: AsyncSession = Depends(get_db), + _actor: str = Depends(require_infrastructure_admin), ): """Post a message to the workspace thread and fan it out to all peers.""" ws = await db.get(Workspace, workspace_id) diff --git a/shogun/api/gensui_config.py b/shogun/api/gensui_config.py index f55fd41..98ca5dc 100644 --- a/shogun/api/gensui_config.py +++ b/shogun/api/gensui_config.py @@ -7,9 +7,17 @@ from pathlib import Path import httpx -from fastapi import APIRouter, HTTPException +from fastapi import APIRouter, Depends, HTTPException from pydantic import BaseModel +from shogun.api.infrastructure_auth import require_infrastructure_admin +from shogun.config import settings +from shogun.services.ssrf_guard import ( + SSRFValidationError, + log_blocked_outbound_request, + validate_outbound_url, +) + log = logging.getLogger(__name__) router = APIRouter(prefix="/gensui", tags=["gensui-config"]) @@ -71,14 +79,46 @@ async def get_gensui_status(): @router.post("/connect") -async def connect_to_gensui(req: ConnectRequest): +async def connect_to_gensui( + req: ConnectRequest, + actor: str = Depends(require_infrastructure_admin), +): """Configure and connect to a Gensui server.""" server_url = req.server_url.rstrip("/") + try: + destination = validate_outbound_url( + server_url, + policy=settings.gensui_destination_policy, + allowlist=settings.outbound_allowlist, + allow_http_on_private_network=settings.allow_http_on_private_network, + allow_http_on_public_network=settings.allow_http_on_public_network, + allowed_ports=_allowed_ports(settings.gensui_allowed_ports), + ) + except SSRFValidationError as exc: + log_blocked_outbound_request( + exc, + endpoint_type="gensui_connect", + destination_policy=settings.gensui_destination_policy, + actor=actor, + ) + raise HTTPException( + 400, + f"Destination blocked by outbound policy ({exc.reason})", + ) from exc + # Test connectivity first try: - async with httpx.AsyncClient(timeout=5.0) as client: - resp = await client.get(f"{server_url}/api/gensui/health") + async with httpx.AsyncClient( + timeout=5.0, + follow_redirects=False, + trust_env=False, + ) as client: + resp = await client.get( # lgtm[py/full-ssrf] + f"{destination.pinned_url.rstrip('/')}/api/gensui/health", + headers={"Host": destination.host_header}, + extensions=destination.request_extensions, + ) if resp.status_code != 200: raise HTTPException(400, f"Gensui server returned {resp.status_code}") except httpx.ConnectError: @@ -112,7 +152,9 @@ async def connect_to_gensui(req: ConnectRequest): @router.post("/disconnect") -async def disconnect_from_gensui(): +async def disconnect_from_gensui( + _actor: str = Depends(require_infrastructure_admin), +): """Disconnect from Gensui and clear settings.""" # Stop the client try: @@ -146,13 +188,45 @@ async def disconnect_from_gensui(): @router.post("/test") -async def test_gensui_connection(req: TestRequest): +async def test_gensui_connection( + req: TestRequest, + actor: str = Depends(require_infrastructure_admin), +): """Test connectivity to a Gensui server without enrolling.""" server_url = req.server_url.rstrip("/") try: - async with httpx.AsyncClient(timeout=5.0) as client: - resp = await client.get(f"{server_url}/api/gensui/health") + destination = validate_outbound_url( + server_url, + policy=settings.gensui_destination_policy, + allowlist=settings.outbound_allowlist, + allow_http_on_private_network=settings.allow_http_on_private_network, + allow_http_on_public_network=settings.allow_http_on_public_network, + allowed_ports=_allowed_ports(settings.gensui_allowed_ports), + ) + except SSRFValidationError as exc: + log_blocked_outbound_request( + exc, + endpoint_type="gensui_test", + destination_policy=settings.gensui_destination_policy, + actor=actor, + ) + return { + "reachable": False, + "error": f"Destination blocked by outbound policy ({exc.reason})", + } + + try: + async with httpx.AsyncClient( + timeout=5.0, + follow_redirects=False, + trust_env=False, + ) as client: + resp = await client.get( # lgtm[py/full-ssrf] + f"{destination.pinned_url.rstrip('/')}/api/gensui/health", + headers={"Host": destination.host_header}, + extensions=destination.request_extensions, + ) if resp.status_code == 200: data = resp.json() return { @@ -166,12 +240,17 @@ async def test_gensui_connection(req: TestRequest): return {"reachable": False, "error": "Connection refused — is Gensui running?"} except httpx.TimeoutException: return {"reachable": False, "error": "Connection timed out"} - except Exception as e: - return {"reachable": False, "error": str(e)} + except Exception: + log.warning("Unexpected Gensui connection-test failure", exc_info=True) + return {"reachable": False, "error": "Connection test failed"} # ── Internal Helpers ───────────────────────────────────────── +def _allowed_ports(value: str) -> set[int] | None: + ports = {int(item.strip()) for item in value.split(",") if item.strip()} + return ports or None + def _get_client_status() -> dict: """Get live status from the GensuiClient singleton.""" try: diff --git a/shogun/api/infrastructure_auth.py b/shogun/api/infrastructure_auth.py new file mode 100644 index 0000000..72b609d --- /dev/null +++ b/shogun/api/infrastructure_auth.py @@ -0,0 +1,50 @@ +"""Authorization dependency for privileged infrastructure configuration routes.""" + +from __future__ import annotations + +import hmac +import ipaddress + +from fastapi import HTTPException, Request, status + +from shogun.config import settings + +INFRASTRUCTURE_TOKEN_HEADER = "X-Shogun-Infrastructure-Token" + + +def _is_loopback_client(host: str | None) -> bool: + if not host: + return False + try: + return ipaddress.ip_address(host).is_loopback + except ValueError: + return host.casefold() == "localhost" + + +async def require_infrastructure_admin(request: Request) -> str: + """Allow a local desktop admin or a server admin presenting the secret token.""" + + expected = str(settings.infrastructure_admin_token or "").strip() + supplied = request.headers.get(INFRASTRUCTURE_TOKEN_HEADER, "") + if expected: + if not supplied or not hmac.compare_digest(supplied, expected): + raise HTTPException( + status_code=status.HTTP_401_UNAUTHORIZED, + detail="A valid infrastructure administrator token is required.", + ) + return "token_admin" + + if settings.deployment_mode == "desktop" and _is_loopback_client( + request.client.host if request.client else None + ): + return "local_primary_admin" + + if settings.deployment_mode == "server": + raise HTTPException( + status_code=status.HTTP_503_SERVICE_UNAVAILABLE, + detail="SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN must be configured in server mode.", + ) + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="Infrastructure configuration is restricted to the local Primary Admin.", + ) diff --git a/shogun/config.py b/shogun/config.py index 410dc4d..dc2e7c7 100644 --- a/shogun/config.py +++ b/shogun/config.py @@ -9,7 +9,7 @@ from pathlib import Path from typing import Literal -from pydantic import field_validator +from pydantic import AliasChoices, Field, field_validator from pydantic_settings import BaseSettings, SettingsConfigDict from sqlalchemy.engine import make_url @@ -71,6 +71,42 @@ def _normalize_database_url(cls, value: str) -> str: # ── Security ───────────────────────────────────────────── secret_key: str = "change-me-to-a-random-64-char-string" vault_encryption_key: str = "change-me-to-a-fernet-base64-key" + infrastructure_admin_token: str | None = Field( + default=None, + validation_alias=AliasChoices( + "SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN", + "INFRASTRUCTURE_ADMIN_TOKEN", + ), + ) + a2a_destination_policy: Literal[ + "public_only", "private_allowed", "loopback_allowed", "allowlist_only" + ] = "private_allowed" + gensui_destination_policy: Literal[ + "public_only", "private_allowed", "loopback_allowed", "allowlist_only" + ] = "loopback_allowed" + outbound_allowlist: str = "" + allow_http_on_private_network: bool = True + allow_http_on_public_network: bool = False + a2a_allowed_ports: str = "" + gensui_allowed_ports: str = "" + + @field_validator("a2a_allowed_ports", "gensui_allowed_ports", mode="before") + @classmethod + def _validate_outbound_ports(cls, value: object) -> str: + raw = str(value or "") + normalized: list[str] = [] + for item in raw.split(","): + item = item.strip() + if not item: + continue + try: + port = int(item) + except ValueError as exc: + raise ValueError(f"Invalid outbound port {item!r}") from exc + if not 1 <= port <= 65535: + raise ValueError(f"Outbound port must be between 1 and 65535: {port}") + normalized.append(str(port)) + return ",".join(normalized) # ── Storage Paths ──────────────────────────────────────── vault_path: Path = PROJECT_ROOT / "vault" diff --git a/shogun/integrations/a2a_client.py b/shogun/integrations/a2a_client.py index 7fff47e..bed35fe 100644 --- a/shogun/integrations/a2a_client.py +++ b/shogun/integrations/a2a_client.py @@ -27,6 +27,14 @@ import httpx +from shogun.config import settings +from shogun.services.ssrf_guard import ( + SSRFValidationError, + ValidatedDestination, + log_blocked_outbound_request, + validate_outbound_url, +) + logger = logging.getLogger(__name__) @@ -87,6 +95,56 @@ class A2AClient: def __init__(self, timeout: float = 15.0): self.timeout = timeout + @staticmethod + def _allowed_ports() -> set[int] | None: + ports = { + int(item.strip()) + for item in settings.a2a_allowed_ports.split(",") + if item.strip() + } + return ports or None + + @staticmethod + def _validate(url: str, *, endpoint_type: str) -> ValidatedDestination: + try: + return validate_outbound_url( + url, + policy=settings.a2a_destination_policy, + allowlist=settings.outbound_allowlist, + allow_http_on_private_network=settings.allow_http_on_private_network, + allow_http_on_public_network=settings.allow_http_on_public_network, + allowed_ports=A2AClient._allowed_ports(), + ) + except SSRFValidationError as exc: + log_blocked_outbound_request( + exc, + endpoint_type=endpoint_type, + destination_policy=settings.a2a_destination_policy, + ) + raise + + @staticmethod + def _inbound_url(peer_url: str) -> str: + inbound_url = peer_url.rstrip("/") + if inbound_url.endswith("/a2a/inbound"): + return inbound_url + if inbound_url.endswith("/api/v1"): + inbound_url = inbound_url[: -len("/api/v1")] + return inbound_url.rstrip("/") + "/api/v1/a2a/inbound" + + @staticmethod + def _identity_url(peer_url: str) -> str: + base = peer_url.rstrip("/") + for suffix in ("/a2a/inbound", "/a2a"): + if base.endswith(suffix): + base = base[: -len(suffix)] + break + return base.rstrip("/") + "/api/v1/a2a/identity" + + def validate_peer_url(self, peer_url: str) -> None: + """Validate a peer before any database state or background work is created.""" + self._validate(self._identity_url(peer_url), endpoint_type="a2a_invite") + async def send( self, peer_url: str, @@ -97,15 +155,23 @@ async def send( Returns the peer's acknowledgment dict, or raises on failure. """ # Normalise: peer_url may be a base URL — append the path if needed - inbound_url = peer_url.rstrip("/") - if not inbound_url.endswith("/a2a/inbound"): - inbound_url = inbound_url.rstrip("/api/v1").rstrip("/") + "/api/v1/a2a/inbound" + inbound_url = self._inbound_url(peer_url) - async with httpx.AsyncClient(timeout=self.timeout) as client: - resp = await client.post( - inbound_url, + destination = self._validate(inbound_url, endpoint_type="a2a_send") + + async with httpx.AsyncClient( + timeout=self.timeout, + follow_redirects=False, + trust_env=False, + ) as client: + resp = await client.post( # lgtm[py/full-ssrf] + destination.pinned_url, json=envelope, - headers={"Content-Type": "application/json"}, + headers={ + "Content-Type": "application/json", + "Host": destination.host_header, + }, + extensions=destination.request_extensions, ) resp.raise_for_status() return resp.json() @@ -116,18 +182,24 @@ async def ping(self, peer_url: str) -> dict[str, Any] | None: Calls GET /api/v1/a2a/identity on the remote. Returns identity dict or None if unreachable. """ - base = peer_url.rstrip("/") - # Strip paths down to origin + /api/v1 - for suffix in ["/a2a/inbound", "/a2a"]: - if base.endswith(suffix): - base = base[: -len(suffix)] - break - identity_url = base.rstrip("/") + "/api/v1/a2a/identity" + identity_url = self._identity_url(peer_url) try: - async with httpx.AsyncClient(timeout=5.0) as client: - resp = await client.get(identity_url) + destination = self._validate(identity_url, endpoint_type="a2a_ping") + async with httpx.AsyncClient( + timeout=5.0, + follow_redirects=False, + trust_env=False, + ) as client: + resp = await client.get( # lgtm[py/full-ssrf] + destination.pinned_url, + headers={"Host": destination.host_header}, + extensions=destination.request_extensions, + ) resp.raise_for_status() return resp.json() + except SSRFValidationError as exc: + logger.warning("A2A ping blocked for %s: %s", exc.host or "unknown-host", exc) + return None except Exception as exc: logger.debug("A2A ping failed for %s: %s", peer_url, exc) return None diff --git a/shogun/services/ssrf_guard.py b/shogun/services/ssrf_guard.py new file mode 100644 index 0000000..c72bcf0 --- /dev/null +++ b/shogun/services/ssrf_guard.py @@ -0,0 +1,338 @@ +"""Policy-based validation for user-controlled outbound HTTP destinations. + +The guard deliberately validates every resolved address. Callers must keep +redirect following disabled so a validated URL cannot redirect to a different +destination without another policy decision. +""" + +from __future__ import annotations + +import ipaddress +import json +import logging +import socket +from collections.abc import Callable, Iterable +from dataclasses import dataclass +from datetime import datetime, timezone +from enum import Enum +from urllib.parse import urlsplit, urlunsplit + +logger = logging.getLogger(__name__) + + +class SSRFValidationError(ValueError): + """Raised when an outbound URL violates its destination policy.""" + + def __init__(self, message: str, *, reason: str, host: str | None = None) -> None: + super().__init__(message) + self.reason = reason + self.host = host + + +class OutboundDestinationPolicy(str, Enum): + PUBLIC_ONLY = "public_only" + PRIVATE_ALLOWED = "private_allowed" + LOOPBACK_ALLOWED = "loopback_allowed" + ALLOWLIST_ONLY = "allowlist_only" + + +@dataclass(frozen=True) +class ValidatedDestination: + url: str + scheme: str + host: str + port: int + addresses: tuple[ipaddress.IPv4Address | ipaddress.IPv6Address, ...] + + @property + def pinned_url(self) -> str: + """Return the URL with its authority pinned to a validated address.""" + + parsed = urlsplit(self.url) + address = str(self.addresses[0]) + literal = f"[{address}]" if ":" in address else address + default_port = 443 if self.scheme == "https" else 80 + authority = literal if self.port == default_port else f"{literal}:{self.port}" + return urlunsplit((self.scheme, authority, parsed.path or "/", parsed.query, "")) + + @property + def host_header(self) -> str: + """Return the original validated authority for HTTP Host routing.""" + + default_port = 443 if self.scheme == "https" else 80 + return self.host if self.port == default_port else f"{self.host}:{self.port}" + + @property + def request_extensions(self) -> dict[str, str]: + """Preserve certificate validation for the original host over a pinned IP.""" + + return {"sni_hostname": self.host} + + +Resolver = Callable[[str, int], Iterable[str]] + +_RFC1918 = ( + ipaddress.ip_network("10.0.0.0/8"), + ipaddress.ip_network("172.16.0.0/12"), + ipaddress.ip_network("192.168.0.0/16"), +) +_IPV6_ULA = ipaddress.ip_network("fc00::/7") +_METADATA_ADDRESSES = { + ipaddress.ip_address("169.254.169.254"), + ipaddress.ip_address("fd00:ec2::254"), +} +def _default_resolver(host: str, port: int) -> Iterable[str]: + for _, _, _, _, sockaddr in socket.getaddrinfo(host, port, type=socket.SOCK_STREAM): + yield sockaddr[0] + + +def _normalize_ip(value: str) -> ipaddress.IPv4Address | ipaddress.IPv6Address: + try: + address = ipaddress.ip_address(value) + except ValueError as exc: + raise SSRFValidationError( + f"Resolved address {value!r} is invalid", + reason="invalid_resolved_address", + ) from exc + if isinstance(address, ipaddress.IPv6Address) and address.ipv4_mapped: + return address.ipv4_mapped + return address + + +def _is_suspicious_numeric_host(host: str) -> bool: + """Detect legacy integer/hex/octal IPv4 spellings without a regular expression.""" + + labels = host.casefold().split(".") + if not labels or any(not label for label in labels): + return False + return all( + label.isdecimal() + or ( + label.startswith("0x") + and len(label) > 2 + and all(character in "0123456789abcdef" for character in label[2:]) + ) + for label in labels + ) + + +def _is_private_network(address: ipaddress.IPv4Address | ipaddress.IPv6Address) -> bool: + if isinstance(address, ipaddress.IPv4Address): + return any(address in network for network in _RFC1918) + return address in _IPV6_ULA + + +def _is_always_blocked(address: ipaddress.IPv4Address | ipaddress.IPv6Address) -> bool: + return ( + address in _METADATA_ADDRESSES + or address.is_link_local + or address.is_multicast + or address.is_unspecified + or (address.is_reserved and not address.is_loopback) + ) + + +Network = ipaddress.IPv4Network | ipaddress.IPv6Network + + +def _parse_allowlist(entries: str | Iterable[str]) -> tuple[set[str], tuple[Network, ...]]: + raw_entries = entries.split(",") if isinstance(entries, str) else list(entries) + hosts: set[str] = set() + networks: list[Network] = [] + for raw in raw_entries: + item = str(raw).strip().casefold().rstrip(".") + if not item: + continue + try: + networks.append(ipaddress.ip_network(item, strict=False)) + except ValueError: + hosts.add(item) + return hosts, tuple(networks) + + +def _hostname_is_allowlisted(host: str, allowed_hosts: set[str]) -> bool: + normalized = host.casefold().rstrip(".") + for entry in allowed_hosts: + if entry.startswith("*."): + suffix = entry[1:] + if normalized.endswith(suffix) and normalized != suffix[1:]: + return True + elif normalized == entry: + return True + return False + + +def _address_is_allowlisted( + address: ipaddress.IPv4Address | ipaddress.IPv6Address, + networks: tuple[Network, ...], +) -> bool: + return any(address.version == network.version and address in network for network in networks) + + +def _reject(message: str, *, reason: str, host: str | None = None) -> SSRFValidationError: + return SSRFValidationError(message, reason=reason, host=host) + + +def validate_outbound_url( + url: str, + *, + policy: OutboundDestinationPolicy | str, + allowlist: str | Iterable[str] = (), + allow_http_on_private_network: bool = True, + allow_http_on_public_network: bool = False, + allowed_ports: Iterable[int] | None = None, + resolver: Resolver = _default_resolver, +) -> ValidatedDestination: + """Validate and resolve an outbound URL immediately before a request.""" + + try: + selected_policy = OutboundDestinationPolicy(policy) + except ValueError as exc: + raise _reject(f"Unknown outbound destination policy: {policy!r}", reason="invalid_policy") from exc + + parsed = urlsplit(url) + scheme = parsed.scheme.casefold() + if scheme not in {"http", "https"}: + raise _reject(f"Unsupported URL scheme: {parsed.scheme!r}", reason="unsupported_scheme") + if parsed.username is not None or parsed.password is not None: + raise _reject("Credentials in outbound URLs are not allowed", reason="embedded_credentials") + if not parsed.hostname: + raise _reject("URL has no hostname", reason="missing_hostname") + + host = parsed.hostname.casefold().rstrip(".") + try: + ipaddress.ip_address(host) + except ValueError: + if _is_suspicious_numeric_host(host): + raise _reject( + f"Ambiguous numeric hostname {host!r} is not allowed", + reason="ambiguous_numeric_host", + host=host, + ) + + try: + port = parsed.port or (443 if scheme == "https" else 80) + except ValueError as exc: + raise _reject("URL contains an invalid port", reason="invalid_port", host=host) from exc + if allowed_ports is not None and port not in {int(value) for value in allowed_ports}: + raise _reject( + f"Port {port} is not allowed for this endpoint", + reason="blocked_port", + host=host, + ) + + try: + resolved = tuple(dict.fromkeys(_normalize_ip(value) for value in resolver(host, port))) + except socket.gaierror as exc: + raise _reject( + f"Could not resolve host {host!r}", + reason="dns_failure", + host=host, + ) from exc + if not resolved: + raise _reject(f"Host {host!r} resolved to no addresses", reason="dns_empty", host=host) + + allowed_hosts, allowed_networks = _parse_allowlist(allowlist) + hostname_allowlisted = _hostname_is_allowlisted(host, allowed_hosts) + + for address in resolved: + if _is_always_blocked(address): + raise _reject( + f"URL host {host!r} resolves to blocked address {address}", + reason="always_blocked_address", + host=host, + ) + + if selected_policy is OutboundDestinationPolicy.PUBLIC_ONLY and not address.is_global: + raise _reject( + f"URL host {host!r} does not resolve exclusively to public addresses", + reason="non_public_address", + host=host, + ) + if selected_policy is OutboundDestinationPolicy.PRIVATE_ALLOWED and address.is_loopback: + raise _reject( + f"Loopback address {address} requires loopback_allowed or an allowlist", + reason="loopback_not_allowed", + host=host, + ) + if selected_policy is OutboundDestinationPolicy.PRIVATE_ALLOWED and not ( + address.is_global or _is_private_network(address) + ): + raise _reject( + f"Address {address} is outside approved public and private ranges", + reason="unsupported_private_range", + host=host, + ) + if selected_policy is OutboundDestinationPolicy.LOOPBACK_ALLOWED and not ( + address.is_global or _is_private_network(address) or address.is_loopback + ): + raise _reject( + f"Address {address} is outside approved public, private, and loopback ranges", + reason="unsupported_loopback_range", + host=host, + ) + if selected_policy is OutboundDestinationPolicy.ALLOWLIST_ONLY and not ( + hostname_allowlisted or _address_is_allowlisted(address, allowed_networks) + ): + raise _reject( + f"URL host {host!r} is not in the outbound allowlist", + reason="allowlist_miss", + host=host, + ) + + if scheme == "http": + contains_public = any(address.is_global for address in resolved) + contains_private = any(_is_private_network(address) or address.is_loopback for address in resolved) + if contains_public and not allow_http_on_public_network: + raise _reject( + "Unencrypted HTTP is disabled for public destinations", + reason="public_http_disabled", + host=host, + ) + if contains_private and not allow_http_on_private_network: + raise _reject( + "Unencrypted HTTP is disabled for private destinations", + reason="private_http_disabled", + host=host, + ) + + return ValidatedDestination( + url=url, + scheme=scheme, + host=host, + port=port, + addresses=resolved, + ) + + +def log_blocked_outbound_request( + exc: SSRFValidationError, + *, + endpoint_type: str, + destination_policy: OutboundDestinationPolicy | str, + actor: str = "primary_admin", + workspace: str | None = None, + posture: str | None = None, + correlation_id: str | None = None, + source_integration: str | None = None, +) -> None: + """Emit a structured security event without URL credentials or query data.""" + + event = { + "event": "outbound_request_blocked", + "timestamp": datetime.now(timezone.utc).isoformat(), + "actor": actor, + "workspace": workspace, + "endpoint_type": endpoint_type, + "destination_host": exc.host, + "destination_policy": ( + destination_policy.value + if isinstance(destination_policy, OutboundDestinationPolicy) + else str(destination_policy) + ), + "reason": exc.reason, + "posture": posture, + "source_integration": source_integration or endpoint_type, + "correlation_id": correlation_id, + } + logger.warning("security_event=%s", json.dumps(event, sort_keys=True, separators=(",", ":"))) diff --git a/tests/test_gensui_frontend.py b/tests/test_gensui_frontend.py new file mode 100644 index 0000000..d938147 --- /dev/null +++ b/tests/test_gensui_frontend.py @@ -0,0 +1,61 @@ +from __future__ import annotations + +import logging + +from fastapi.testclient import TestClient + +from gensui.app import create_app +from gensui.config import gensui_settings + + +def _frontend(tmp_path): + dist = tmp_path / "dist" + assets = dist / "assets" + assets.mkdir(parents=True) + (dist / "index.html").write_text("Gensui — Central Command", encoding="utf-8") + (assets / "app.js").write_text("const api = '/api/gensui';", encoding="utf-8") + return dist + + +def test_gensui_serves_root_assets_spa_and_api_without_route_collision( + tmp_path, + monkeypatch, +) -> None: + monkeypatch.setattr(gensui_settings, "gensui_frontend_dist", _frontend(tmp_path)) + client = TestClient(create_app()) + try: + root = client.get("/") + asset = client.get("/assets/app.js") + spa = client.get("/agents") + health = client.get("/api/gensui/health") + missing_api = client.get("/api/gensui/not-a-route") + finally: + client.close() + + assert root.status_code == 200 + assert "Gensui" in root.text + assert asset.status_code == 200 + assert "/api/gensui" in asset.text + assert spa.status_code == 200 + assert "Gensui" in spa.text + assert health.status_code == 200 + assert health.json()["service"] == "gensui" + assert missing_api.status_code == 404 + assert missing_api.headers["content-type"].startswith("application/json") + + +def test_missing_gensui_frontend_is_visible_in_logs( + tmp_path, + monkeypatch, + caplog, +) -> None: + missing = tmp_path / "missing" + monkeypatch.setattr(gensui_settings, "gensui_frontend_dist", missing) + with caplog.at_level(logging.WARNING, logger="gensui"): + app = create_app() + assert any(str(missing) in record.message for record in caplog.records) + client = TestClient(app) + try: + assert client.get("/").status_code == 404 + finally: + client.close() diff --git a/tests/test_ssrf_guard.py b/tests/test_ssrf_guard.py new file mode 100644 index 0000000..f609e7a --- /dev/null +++ b/tests/test_ssrf_guard.py @@ -0,0 +1,368 @@ +from __future__ import annotations + +import json +import logging +import socket + +import httpx +import pytest +from fastapi import Depends, FastAPI +from fastapi.testclient import TestClient +from pydantic import ValidationError + +from shogun.api.gensui_config import router as gensui_router +from shogun.api.infrastructure_auth import require_infrastructure_admin +from shogun.config import Settings, settings +from shogun.integrations.a2a_client import A2AClient +from shogun.services.ssrf_guard import ( + OutboundDestinationPolicy, + SSRFValidationError, + log_blocked_outbound_request, + validate_outbound_url, +) + + +def resolver(*addresses: str): + return lambda _host, _port: addresses + + +@pytest.mark.parametrize( + ("address", "reason"), + [ + ("169.254.169.254", "always_blocked_address"), + ("169.254.10.1", "always_blocked_address"), + ("fe80::1", "always_blocked_address"), + ("fd00:ec2::254", "always_blocked_address"), + ("224.0.0.1", "always_blocked_address"), + ("0.0.0.0", "always_blocked_address"), + ], +) +def test_metadata_link_local_multicast_and_unspecified_are_always_blocked( + address: str, + reason: str, +) -> None: + with pytest.raises(SSRFValidationError, match="blocked address") as caught: + validate_outbound_url( + "https://example.test", + policy=OutboundDestinationPolicy.LOOPBACK_ALLOWED, + resolver=resolver(address), + ) + assert caught.value.reason == reason + + +def test_public_only_accepts_public_https() -> None: + result = validate_outbound_url( + "https://example.test/resource", + policy="public_only", + resolver=resolver("93.184.216.34"), + ) + assert result.host == "example.test" + assert result.port == 443 + + +@pytest.mark.parametrize("address", ["10.0.0.2", "172.16.1.2", "192.168.1.2", "fd12::2", "127.0.0.1", "::1"]) +def test_public_only_blocks_private_and_loopback(address: str) -> None: + with pytest.raises(SSRFValidationError): + validate_outbound_url( + "https://internal.test", + policy="public_only", + resolver=resolver(address), + ) + + +@pytest.mark.parametrize("address", ["10.0.0.2", "172.16.1.2", "192.168.1.2", "fd12::2"]) +def test_private_allowed_accepts_rfc1918_and_ipv6_ula(address: str) -> None: + result = validate_outbound_url( + "http://internal.test:8787", + policy="private_allowed", + resolver=resolver(address), + ) + assert str(result.addresses[0]) == address + + +@pytest.mark.parametrize("address", ["127.0.0.1", "::1"]) +def test_loopback_requires_explicit_policy(address: str) -> None: + with pytest.raises(SSRFValidationError) as caught: + validate_outbound_url( + "http://localhost:8787", + policy="private_allowed", + resolver=resolver(address), + ) + assert caught.value.reason == "loopback_not_allowed" + + result = validate_outbound_url( + "http://localhost:8787", + policy="loopback_allowed", + resolver=resolver(address), + ) + assert result.port == 8787 + + +def test_allowlist_supports_hostname_wildcard_ip_and_cidr() -> None: + validate_outbound_url( + "https://gensui.corp.example", + policy="allowlist_only", + allowlist="*.corp.example", + resolver=resolver("10.1.2.3"), + ) + validate_outbound_url( + "https://10.2.3.4", + policy="allowlist_only", + allowlist="10.0.0.0/8", + resolver=resolver("10.2.3.4"), + ) + with pytest.raises(SSRFValidationError) as caught: + validate_outbound_url( + "https://other.example", + policy="allowlist_only", + allowlist="*.corp.example,10.0.0.0/8", + resolver=resolver("93.184.216.34"), + ) + assert caught.value.reason == "allowlist_miss" + + +def test_all_dns_answers_must_pass_policy() -> None: + with pytest.raises(SSRFValidationError): + validate_outbound_url( + "https://mixed.example", + policy="public_only", + resolver=resolver("93.184.216.34", "127.0.0.1"), + ) + + +def test_ipv4_mapped_ipv6_is_normalized() -> None: + result = validate_outbound_url( + "http://localhost:8787", + policy="loopback_allowed", + resolver=resolver("::ffff:127.0.0.1"), + ) + assert str(result.addresses[0]) == "127.0.0.1" + + +@pytest.mark.parametrize("url", ["file:///etc/passwd", "gopher://example.test", "data:text/plain,hello"]) +def test_unsupported_schemes_are_blocked(url: str) -> None: + with pytest.raises(SSRFValidationError) as caught: + validate_outbound_url(url, policy="public_only", resolver=resolver("93.184.216.34")) + assert caught.value.reason == "unsupported_scheme" + + +def test_embedded_credentials_and_ambiguous_numeric_hosts_are_blocked() -> None: + with pytest.raises(SSRFValidationError) as credentials: + validate_outbound_url( + "https://user:secret@example.test", + policy="public_only", + resolver=resolver("93.184.216.34"), + ) + assert credentials.value.reason == "embedded_credentials" + + with pytest.raises(SSRFValidationError) as numeric: + validate_outbound_url( + "http://2130706433", + policy="loopback_allowed", + resolver=resolver("127.0.0.1"), + ) + assert numeric.value.reason == "ambiguous_numeric_host" + + +def test_dns_failure_and_empty_resolution_fail_closed() -> None: + def fail_dns(_host: str, _port: int): + raise socket.gaierror("no such host") + + with pytest.raises(SSRFValidationError) as failure: + validate_outbound_url("https://missing.test", policy="public_only", resolver=fail_dns) + assert failure.value.reason == "dns_failure" + + with pytest.raises(SSRFValidationError) as empty: + validate_outbound_url("https://empty.test", policy="public_only", resolver=resolver()) + assert empty.value.reason == "dns_empty" + + +def test_http_and_port_policies_are_enforced() -> None: + with pytest.raises(SSRFValidationError) as public_http: + validate_outbound_url( + "http://example.test", + policy="public_only", + resolver=resolver("93.184.216.34"), + ) + assert public_http.value.reason == "public_http_disabled" + + with pytest.raises(SSRFValidationError) as port: + validate_outbound_url( + "https://example.test:22", + policy="public_only", + allowed_ports={443}, + resolver=resolver("93.184.216.34"), + ) + assert port.value.reason == "blocked_port" + + +def test_structured_log_omits_url_secrets(caplog: pytest.LogCaptureFixture) -> None: + exc = SSRFValidationError( + "blocked", + reason="allowlist_miss", + host="gensui.example", + ) + with caplog.at_level(logging.WARNING): + log_blocked_outbound_request( + exc, + endpoint_type="gensui_test", + destination_policy="allowlist_only", + actor="admin-1", + correlation_id="trace-1", + ) + payload = json.loads(caplog.records[-1].message.removeprefix("security_event=")) + assert payload["destination_host"] == "gensui.example" + assert payload["reason"] == "allowlist_miss" + assert payload["timestamp"].endswith("+00:00") + assert payload["source_integration"] == "gensui_test" + assert "token" not in caplog.records[-1].message.casefold() + + +def test_server_infrastructure_routes_require_token(monkeypatch: pytest.MonkeyPatch) -> None: + app = FastAPI() + + @app.get("/protected") + async def protected(actor: str = Depends(require_infrastructure_admin)): + return {"actor": actor} + + monkeypatch.setattr(settings, "deployment_mode", "server") + monkeypatch.setattr(settings, "infrastructure_admin_token", None) + with TestClient(app) as client: + assert client.get("/protected").status_code == 503 + + monkeypatch.setattr(settings, "infrastructure_admin_token", "correct-secret") + assert client.get("/protected").status_code == 401 + assert client.get( + "/protected", + headers={"X-Shogun-Infrastructure-Token": "wrong"}, + ).status_code == 401 + response = client.get( + "/protected", + headers={"X-Shogun-Infrastructure-Token": "correct-secret"}, + ) + assert response.status_code == 200 + assert response.json()["actor"] == "token_admin" + + +def test_documented_infrastructure_token_environment_name( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setenv("SHOGUN_INFRASTRUCTURE_ADMIN_TOKEN", "documented-secret") + configured = Settings(_env_file=None) + assert configured.infrastructure_admin_token == "documented-secret" + + +def test_invalid_outbound_port_configuration_fails_closed() -> None: + with pytest.raises(ValidationError, match="between 1 and 65535"): + Settings(_env_file=None, a2a_allowed_ports="443,70000") + + +def test_desktop_infrastructure_routes_are_loopback_only( + monkeypatch: pytest.MonkeyPatch, +) -> None: + app = FastAPI() + + @app.get("/protected") + async def protected(actor: str = Depends(require_infrastructure_admin)): + return {"actor": actor} + + monkeypatch.setattr(settings, "deployment_mode", "desktop") + monkeypatch.setattr(settings, "infrastructure_admin_token", None) + with TestClient(app, client=("team-member", 50000)) as remote_client: + assert remote_client.get("/protected").status_code == 403 + with TestClient(app, client=("127.0.0.1", 50000)) as local_client: + response = local_client.get("/protected") + assert response.status_code == 200 + assert response.json()["actor"] == "local_primary_admin" + + +def test_gensui_route_rejects_unauthenticated_requests_before_network( + monkeypatch: pytest.MonkeyPatch, +) -> None: + monkeypatch.setattr(settings, "deployment_mode", "server") + monkeypatch.setattr(settings, "infrastructure_admin_token", "correct-secret") + + class UnexpectedClient: + def __init__(self, *args, **kwargs): + raise AssertionError("unauthenticated requests must not create an outbound client") + + monkeypatch.setattr(httpx, "AsyncClient", UnexpectedClient) + app = FastAPI() + app.include_router(gensui_router) + with TestClient(app) as client: + response = client.post( + "/gensui/connect", + json={"server_url": "https://gensui.example"}, + ) + assert response.status_code == 401 + + +def test_gensui_block_happens_before_outbound_connection(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(settings, "deployment_mode", "server") + monkeypatch.setattr(settings, "infrastructure_admin_token", "correct-secret") + monkeypatch.setattr(settings, "gensui_destination_policy", "loopback_allowed") + + class UnexpectedClient: + def __init__(self, *args, **kwargs): + raise AssertionError("outbound client must not be created for a blocked target") + + monkeypatch.setattr(httpx, "AsyncClient", UnexpectedClient) + app = FastAPI() + app.include_router(gensui_router) + with TestClient(app) as client: + response = client.post( + "/gensui/test", + json={"server_url": "http://169.254.169.254"}, + headers={"X-Shogun-Infrastructure-Token": "correct-secret"}, + ) + assert response.status_code == 200 + assert response.json()["reachable"] is False + + +@pytest.mark.asyncio +async def test_a2a_block_happens_before_outbound_connection(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(settings, "a2a_destination_policy", "loopback_allowed") + + class UnexpectedClient: + def __init__(self, *args, **kwargs): + raise AssertionError("outbound client must not be created for a blocked target") + + monkeypatch.setattr(httpx, "AsyncClient", UnexpectedClient) + with pytest.raises(SSRFValidationError): + await A2AClient().send("http://169.254.169.254", {"content": "test"}) + + +@pytest.mark.asyncio +async def test_a2a_does_not_follow_redirects(monkeypatch: pytest.MonkeyPatch) -> None: + calls: list[str] = [] + + class RedirectingClient: + def __init__(self, *args, follow_redirects: bool, **kwargs): + assert follow_redirects is False + + async def __aenter__(self): + return self + + async def __aexit__(self, *args): + return None + + async def get(self, url: str, **kwargs): + assert kwargs["headers"] == {"Host": "peer.example"} + assert kwargs["extensions"] == {"sni_hostname": "peer.example"} + calls.append(url) + return httpx.Response( + 302, + headers={"location": "http://169.254.169.254/latest/meta-data"}, + request=httpx.Request("GET", url), + ) + + destination = validate_outbound_url( + "https://peer.example/api/v1/a2a/identity", + policy=OutboundDestinationPolicy.PUBLIC_ONLY, + resolver=resolver("93.184.216.34"), + ) + monkeypatch.setattr(A2AClient, "_validate", lambda *args, **kwargs: destination) + monkeypatch.setattr(httpx, "AsyncClient", RedirectingClient) + + assert await A2AClient().ping("https://peer.example") is None + assert calls == ["https://93.184.216.34/api/v1/a2a/identity"] diff --git a/version.json b/version.json index da2c526..45a462a 100644 --- a/version.json +++ b/version.json @@ -1,8 +1,8 @@ { - "version": "1.44.11", + "version": "1.44.12", "name": "Shogun OS", - "build": 141, + "build": 142, "channel": "stable", - "released": "2026-07-24T14:04:36Z", - "changelog": "Document Hindi as a supported Shogun language in the project README." + "released": "2026-07-25T08:31:07Z", + "changelog": "Security and deployment hardening for Shogun, Tenshu, and Gensui." }