openryoko 2026.10.8 → 2026.10.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/jimmy.js +51 -1
- package/dist/bin/jimmy.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/src/backup/archive.d.ts +65 -0
- package/dist/src/backup/archive.d.ts.map +1 -0
- package/dist/src/backup/archive.js +214 -0
- package/dist/src/backup/archive.js.map +1 -0
- package/dist/src/backup/catalog.d.ts +64 -0
- package/dist/src/backup/catalog.d.ts.map +1 -0
- package/dist/src/backup/catalog.js +252 -0
- package/dist/src/backup/catalog.js.map +1 -0
- package/dist/src/backup/database-restore.d.ts +63 -0
- package/dist/src/backup/database-restore.d.ts.map +1 -0
- package/dist/src/backup/database-restore.js +236 -0
- package/dist/src/backup/database-restore.js.map +1 -0
- package/dist/src/backup/database-source.d.ts +70 -0
- package/dist/src/backup/database-source.d.ts.map +1 -0
- package/dist/src/backup/database-source.js +70 -0
- package/dist/src/backup/database-source.js.map +1 -0
- package/dist/src/backup/format.d.ts +4 -0
- package/dist/src/backup/format.d.ts.map +1 -0
- package/dist/src/backup/format.js +15 -0
- package/dist/src/backup/format.js.map +1 -0
- package/dist/src/backup/gateway-liveness.d.ts +44 -0
- package/dist/src/backup/gateway-liveness.d.ts.map +1 -0
- package/dist/src/backup/gateway-liveness.js +120 -0
- package/dist/src/backup/gateway-liveness.js.map +1 -0
- package/dist/src/backup/inspect.d.ts +45 -0
- package/dist/src/backup/inspect.d.ts.map +1 -0
- package/dist/src/backup/inspect.js +291 -0
- package/dist/src/backup/inspect.js.map +1 -0
- package/dist/src/backup/layout.d.ts +11 -0
- package/dist/src/backup/layout.d.ts.map +1 -0
- package/dist/src/backup/layout.js +16 -0
- package/dist/src/backup/layout.js.map +1 -0
- package/dist/src/backup/limits.d.ts +54 -0
- package/dist/src/backup/limits.d.ts.map +1 -0
- package/dist/src/backup/limits.js +59 -0
- package/dist/src/backup/limits.js.map +1 -0
- package/dist/src/backup/manifest.d.ts +45 -0
- package/dist/src/backup/manifest.d.ts.map +1 -0
- package/dist/src/backup/manifest.js +77 -0
- package/dist/src/backup/manifest.js.map +1 -0
- package/dist/src/backup/restore.d.ts +73 -0
- package/dist/src/backup/restore.d.ts.map +1 -0
- package/dist/src/backup/restore.js +685 -0
- package/dist/src/backup/restore.js.map +1 -0
- package/dist/src/backup/run.d.ts +76 -0
- package/dist/src/backup/run.d.ts.map +1 -0
- package/dist/src/backup/run.js +181 -0
- package/dist/src/backup/run.js.map +1 -0
- package/dist/src/backup/scheduler.d.ts +51 -0
- package/dist/src/backup/scheduler.d.ts.map +1 -0
- package/dist/src/backup/scheduler.js +198 -0
- package/dist/src/backup/scheduler.js.map +1 -0
- package/dist/src/backup/settings.d.ts +44 -0
- package/dist/src/backup/settings.d.ts.map +1 -0
- package/dist/src/backup/settings.js +91 -0
- package/dist/src/backup/settings.js.map +1 -0
- package/dist/src/backup/space.d.ts +22 -0
- package/dist/src/backup/space.d.ts.map +1 -0
- package/dist/src/backup/space.js +47 -0
- package/dist/src/backup/space.js.map +1 -0
- package/dist/src/backup/state.d.ts +46 -0
- package/dist/src/backup/state.d.ts.map +1 -0
- package/dist/src/backup/state.js +137 -0
- package/dist/src/backup/state.js.map +1 -0
- package/dist/src/backup/tar.d.ts +64 -0
- package/dist/src/backup/tar.d.ts.map +1 -0
- package/dist/src/backup/tar.js +274 -0
- package/dist/src/backup/tar.js.map +1 -0
- package/dist/src/backup/targets.d.ts +85 -0
- package/dist/src/backup/targets.d.ts.map +1 -0
- package/dist/src/backup/targets.js +104 -0
- package/dist/src/backup/targets.js.map +1 -0
- package/dist/src/backup/walk.d.ts +42 -0
- package/dist/src/backup/walk.d.ts.map +1 -0
- package/dist/src/backup/walk.js +324 -0
- package/dist/src/backup/walk.js.map +1 -0
- package/dist/src/cli/backup.d.ts +45 -0
- package/dist/src/cli/backup.d.ts.map +1 -0
- package/dist/src/cli/backup.js +344 -0
- package/dist/src/cli/backup.js.map +1 -0
- package/dist/src/cli/bundled-skills.d.ts +7 -1
- package/dist/src/cli/bundled-skills.d.ts.map +1 -1
- package/dist/src/cli/bundled-skills.js +12 -2
- package/dist/src/cli/bundled-skills.js.map +1 -1
- package/dist/src/cli/config-failure.d.ts +18 -0
- package/dist/src/cli/config-failure.d.ts.map +1 -0
- package/dist/src/cli/config-failure.js +39 -0
- package/dist/src/cli/config-failure.js.map +1 -0
- package/dist/src/cli/gateway-audit.d.ts +3 -0
- package/dist/src/cli/gateway-audit.d.ts.map +1 -1
- package/dist/src/cli/gateway-audit.js +61 -14
- package/dist/src/cli/gateway-audit.js.map +1 -1
- package/dist/src/cli/gateway-url-backup.d.ts +21 -0
- package/dist/src/cli/gateway-url-backup.d.ts.map +1 -0
- package/dist/src/cli/gateway-url-backup.js +87 -0
- package/dist/src/cli/gateway-url-backup.js.map +1 -0
- package/dist/src/cli/home-copy.d.ts +37 -0
- package/dist/src/cli/home-copy.d.ts.map +1 -0
- package/dist/src/cli/home-copy.js +155 -0
- package/dist/src/cli/home-copy.js.map +1 -0
- package/dist/src/cli/interactive-config.d.ts +5 -0
- package/dist/src/cli/interactive-config.d.ts.map +1 -1
- package/dist/src/cli/interactive-config.js +16 -7
- package/dist/src/cli/interactive-config.js.map +1 -1
- package/dist/src/cli/migrate.d.ts +20 -0
- package/dist/src/cli/migrate.d.ts.map +1 -1
- package/dist/src/cli/migrate.js +365 -68
- package/dist/src/cli/migrate.js.map +1 -1
- package/dist/src/cli/migration-declarations.d.ts +24 -0
- package/dist/src/cli/migration-declarations.d.ts.map +1 -0
- package/dist/src/cli/migration-declarations.js +54 -0
- package/dist/src/cli/migration-declarations.js.map +1 -0
- package/dist/src/cli/start.d.ts.map +1 -1
- package/dist/src/cli/start.js +40 -1
- package/dist/src/cli/start.js.map +1 -1
- package/dist/src/connectors/chunked-send.d.ts +27 -0
- package/dist/src/connectors/chunked-send.d.ts.map +1 -0
- package/dist/src/connectors/chunked-send.js +40 -0
- package/dist/src/connectors/chunked-send.js.map +1 -0
- package/dist/src/connectors/cron/index.d.ts +10 -0
- package/dist/src/connectors/cron/index.d.ts.map +1 -1
- package/dist/src/connectors/cron/index.js +26 -3
- package/dist/src/connectors/cron/index.js.map +1 -1
- package/dist/src/connectors/discord/attachments.d.ts +25 -0
- package/dist/src/connectors/discord/attachments.d.ts.map +1 -0
- package/dist/src/connectors/discord/attachments.js +33 -0
- package/dist/src/connectors/discord/attachments.js.map +1 -0
- package/dist/src/connectors/discord/format.d.ts +17 -1
- package/dist/src/connectors/discord/format.d.ts.map +1 -1
- package/dist/src/connectors/discord/format.js +36 -6
- package/dist/src/connectors/discord/format.js.map +1 -1
- package/dist/src/connectors/discord/index.d.ts +12 -0
- package/dist/src/connectors/discord/index.d.ts.map +1 -1
- package/dist/src/connectors/discord/index.js +47 -40
- package/dist/src/connectors/discord/index.js.map +1 -1
- package/dist/src/connectors/discord/remote.d.ts +45 -1
- package/dist/src/connectors/discord/remote.d.ts.map +1 -1
- package/dist/src/connectors/discord/remote.js +147 -22
- package/dist/src/connectors/discord/remote.js.map +1 -1
- package/dist/src/connectors/slack/attachments.d.ts +25 -0
- package/dist/src/connectors/slack/attachments.d.ts.map +1 -0
- package/dist/src/connectors/slack/attachments.js +32 -0
- package/dist/src/connectors/slack/attachments.js.map +1 -0
- package/dist/src/connectors/slack/auth-test-cache.d.ts +22 -0
- package/dist/src/connectors/slack/auth-test-cache.d.ts.map +1 -0
- package/dist/src/connectors/slack/auth-test-cache.js +34 -0
- package/dist/src/connectors/slack/auth-test-cache.js.map +1 -0
- package/dist/src/connectors/slack/format.d.ts +6 -1
- package/dist/src/connectors/slack/format.d.ts.map +1 -1
- package/dist/src/connectors/slack/format.js +65 -13
- package/dist/src/connectors/slack/format.js.map +1 -1
- package/dist/src/connectors/slack/index.d.ts +4 -0
- package/dist/src/connectors/slack/index.d.ts.map +1 -1
- package/dist/src/connectors/slack/index.js +64 -52
- package/dist/src/connectors/slack/index.js.map +1 -1
- package/dist/src/connectors/slack/provider-auth-blocks.d.ts +62 -0
- package/dist/src/connectors/slack/provider-auth-blocks.d.ts.map +1 -0
- package/dist/src/connectors/slack/provider-auth-blocks.js +204 -0
- package/dist/src/connectors/slack/provider-auth-blocks.js.map +1 -0
- package/dist/src/connectors/slack/provider-auth.d.ts +126 -0
- package/dist/src/connectors/slack/provider-auth.d.ts.map +1 -0
- package/dist/src/connectors/slack/provider-auth.js +357 -0
- package/dist/src/connectors/slack/provider-auth.js.map +1 -0
- package/dist/src/connectors/telegram/index.d.ts +5 -0
- package/dist/src/connectors/telegram/index.d.ts.map +1 -1
- package/dist/src/connectors/telegram/index.js +14 -22
- package/dist/src/connectors/telegram/index.js.map +1 -1
- package/dist/src/connectors/whatsapp/index.d.ts +3 -0
- package/dist/src/connectors/whatsapp/index.d.ts.map +1 -1
- package/dist/src/connectors/whatsapp/index.js +33 -14
- package/dist/src/connectors/whatsapp/index.js.map +1 -1
- package/dist/src/cron/alert-throttle.d.ts +28 -0
- package/dist/src/cron/alert-throttle.d.ts.map +1 -0
- package/dist/src/cron/alert-throttle.js +106 -0
- package/dist/src/cron/alert-throttle.js.map +1 -0
- package/dist/src/cron/jobs.d.ts +8 -0
- package/dist/src/cron/jobs.d.ts.map +1 -1
- package/dist/src/cron/jobs.js +27 -1
- package/dist/src/cron/jobs.js.map +1 -1
- package/dist/src/cron/run-outcome.d.ts +28 -0
- package/dist/src/cron/run-outcome.d.ts.map +1 -0
- package/dist/src/cron/run-outcome.js +66 -0
- package/dist/src/cron/run-outcome.js.map +1 -0
- package/dist/src/cron/runner.d.ts.map +1 -1
- package/dist/src/cron/runner.js +68 -5
- package/dist/src/cron/runner.js.map +1 -1
- package/dist/src/cron/scheduler.d.ts +8 -1
- package/dist/src/cron/scheduler.d.ts.map +1 -1
- package/dist/src/cron/scheduler.js +11 -4
- package/dist/src/cron/scheduler.js.map +1 -1
- package/dist/src/cron/waiting-fires.d.ts +18 -0
- package/dist/src/cron/waiting-fires.d.ts.map +1 -0
- package/dist/src/cron/waiting-fires.js +49 -0
- package/dist/src/cron/waiting-fires.js.map +1 -0
- package/dist/src/engines/claude-interactive.d.ts +19 -3
- package/dist/src/engines/claude-interactive.d.ts.map +1 -1
- package/dist/src/engines/claude-interactive.js +42 -17
- package/dist/src/engines/claude-interactive.js.map +1 -1
- package/dist/src/engines/claude.d.ts.map +1 -1
- package/dist/src/engines/claude.js +38 -5
- package/dist/src/engines/claude.js.map +1 -1
- package/dist/src/engines/codex.d.ts.map +1 -1
- package/dist/src/engines/codex.js +1 -0
- package/dist/src/engines/codex.js.map +1 -1
- package/dist/src/engines/gemini.d.ts.map +1 -1
- package/dist/src/engines/gemini.js +1 -0
- package/dist/src/engines/gemini.js.map +1 -1
- package/dist/src/gateway/api.d.ts.map +1 -1
- package/dist/src/gateway/api.js +184 -160
- package/dist/src/gateway/api.js.map +1 -1
- package/dist/src/gateway/config-redaction.d.ts +32 -0
- package/dist/src/gateway/config-redaction.d.ts.map +1 -0
- package/dist/src/gateway/config-redaction.js +139 -0
- package/dist/src/gateway/config-redaction.js.map +1 -0
- package/dist/src/gateway/config-revision.d.ts +46 -0
- package/dist/src/gateway/config-revision.d.ts.map +1 -0
- package/dist/src/gateway/config-revision.js +63 -0
- package/dist/src/gateway/config-revision.js.map +1 -0
- package/dist/src/gateway/connector-config.d.ts +21 -0
- package/dist/src/gateway/connector-config.d.ts.map +1 -0
- package/dist/src/gateway/connector-config.js +24 -0
- package/dist/src/gateway/connector-config.js.map +1 -0
- package/dist/src/gateway/daemon-entry.js +5 -0
- package/dist/src/gateway/daemon-entry.js.map +1 -1
- package/dist/src/gateway/engine-health-monitor.d.ts +67 -0
- package/dist/src/gateway/engine-health-monitor.d.ts.map +1 -0
- package/dist/src/gateway/engine-health-monitor.js +221 -0
- package/dist/src/gateway/engine-health-monitor.js.map +1 -0
- package/dist/src/gateway/files.d.ts +7 -1
- package/dist/src/gateway/files.d.ts.map +1 -1
- package/dist/src/gateway/files.js +110 -217
- package/dist/src/gateway/files.js.map +1 -1
- package/dist/src/gateway/onboarding-personalize.d.ts +2 -0
- package/dist/src/gateway/onboarding-personalize.d.ts.map +1 -1
- package/dist/src/gateway/onboarding-personalize.js +17 -1
- package/dist/src/gateway/onboarding-personalize.js.map +1 -1
- package/dist/src/gateway/portal-config.d.ts +17 -3
- package/dist/src/gateway/portal-config.d.ts.map +1 -1
- package/dist/src/gateway/portal-config.js +52 -3
- package/dist/src/gateway/portal-config.js.map +1 -1
- package/dist/src/gateway/request-origin.d.ts +9 -0
- package/dist/src/gateway/request-origin.d.ts.map +1 -1
- package/dist/src/gateway/request-origin.js +10 -0
- package/dist/src/gateway/request-origin.js.map +1 -1
- package/dist/src/gateway/server.d.ts.map +1 -1
- package/dist/src/gateway/server.js +82 -59
- package/dist/src/gateway/server.js.map +1 -1
- package/dist/src/gateway/slack-connect-rollback.d.ts +23 -0
- package/dist/src/gateway/slack-connect-rollback.d.ts.map +1 -0
- package/dist/src/gateway/slack-connect-rollback.js +53 -0
- package/dist/src/gateway/slack-connect-rollback.js.map +1 -0
- package/dist/src/gateway/status-reconciler.d.ts +25 -7
- package/dist/src/gateway/status-reconciler.d.ts.map +1 -1
- package/dist/src/gateway/status-reconciler.js +86 -43
- package/dist/src/gateway/status-reconciler.js.map +1 -1
- package/dist/src/gateway/watcher.d.ts.map +1 -1
- package/dist/src/gateway/watcher.js +44 -3
- package/dist/src/gateway/watcher.js.map +1 -1
- package/dist/src/mcp/gateway-server.js +21 -3
- package/dist/src/mcp/gateway-server.js.map +1 -1
- package/dist/src/mcp/resolver.d.ts.map +1 -1
- package/dist/src/mcp/resolver.js +51 -1
- package/dist/src/mcp/resolver.js.map +1 -1
- package/dist/src/models/service.d.ts.map +1 -1
- package/dist/src/models/service.js +14 -8
- package/dist/src/models/service.js.map +1 -1
- package/dist/src/provider-auth/discovery.d.ts +16 -0
- package/dist/src/provider-auth/discovery.d.ts.map +1 -0
- package/dist/src/provider-auth/discovery.js +66 -0
- package/dist/src/provider-auth/discovery.js.map +1 -0
- package/dist/src/provider-auth/failure-notices.d.ts +29 -0
- package/dist/src/provider-auth/failure-notices.d.ts.map +1 -0
- package/dist/src/provider-auth/failure-notices.js +48 -0
- package/dist/src/provider-auth/failure-notices.js.map +1 -0
- package/dist/src/provider-auth/failure-signal.d.ts +22 -0
- package/dist/src/provider-auth/failure-signal.d.ts.map +1 -0
- package/dist/src/provider-auth/failure-signal.js +79 -0
- package/dist/src/provider-auth/failure-signal.js.map +1 -0
- package/dist/src/provider-auth/index.d.ts +26 -0
- package/dist/src/provider-auth/index.d.ts.map +1 -0
- package/dist/src/provider-auth/index.js +51 -0
- package/dist/src/provider-auth/index.js.map +1 -0
- package/dist/src/provider-auth/input.d.ts +44 -0
- package/dist/src/provider-auth/input.d.ts.map +1 -0
- package/dist/src/provider-auth/input.js +86 -0
- package/dist/src/provider-auth/input.js.map +1 -0
- package/dist/src/provider-auth/providers.d.ts +26 -0
- package/dist/src/provider-auth/providers.d.ts.map +1 -0
- package/dist/src/provider-auth/providers.js +86 -0
- package/dist/src/provider-auth/providers.js.map +1 -0
- package/dist/src/provider-auth/runtime.d.ts +21 -0
- package/dist/src/provider-auth/runtime.d.ts.map +1 -0
- package/dist/src/provider-auth/runtime.js +104 -0
- package/dist/src/provider-auth/runtime.js.map +1 -0
- package/dist/src/provider-auth/service.d.ts +70 -0
- package/dist/src/provider-auth/service.d.ts.map +1 -0
- package/dist/src/provider-auth/service.js +349 -0
- package/dist/src/provider-auth/service.js.map +1 -0
- package/dist/src/provider-auth/terminal.d.ts +21 -0
- package/dist/src/provider-auth/terminal.d.ts.map +1 -0
- package/dist/src/provider-auth/terminal.js +46 -0
- package/dist/src/provider-auth/terminal.js.map +1 -0
- package/dist/src/provider-auth/types.d.ts +123 -0
- package/dist/src/provider-auth/types.d.ts.map +1 -0
- package/dist/src/provider-auth/types.js +10 -0
- package/dist/src/provider-auth/types.js.map +1 -0
- package/dist/src/sessions/accounting.d.ts +3 -0
- package/dist/src/sessions/accounting.d.ts.map +1 -1
- package/dist/src/sessions/accounting.js +5 -0
- package/dist/src/sessions/accounting.js.map +1 -1
- package/dist/src/sessions/backup-integrity.d.ts +45 -0
- package/dist/src/sessions/backup-integrity.d.ts.map +1 -0
- package/dist/src/sessions/backup-integrity.js +122 -0
- package/dist/src/sessions/backup-integrity.js.map +1 -0
- package/dist/src/sessions/backup.d.ts +40 -2
- package/dist/src/sessions/backup.d.ts.map +1 -1
- package/dist/src/sessions/backup.js +88 -12
- package/dist/src/sessions/backup.js.map +1 -1
- package/dist/src/sessions/callbacks.d.ts +9 -0
- package/dist/src/sessions/callbacks.d.ts.map +1 -1
- package/dist/src/sessions/callbacks.js +55 -10
- package/dist/src/sessions/callbacks.js.map +1 -1
- package/dist/src/sessions/completion-batching.d.ts +82 -0
- package/dist/src/sessions/completion-batching.d.ts.map +1 -0
- package/dist/src/sessions/completion-batching.js +126 -0
- package/dist/src/sessions/completion-batching.js.map +1 -0
- package/dist/src/sessions/connector-command-guard.d.ts +66 -0
- package/dist/src/sessions/connector-command-guard.d.ts.map +1 -0
- package/dist/src/sessions/connector-command-guard.js +145 -0
- package/dist/src/sessions/connector-command-guard.js.map +1 -0
- package/dist/src/sessions/context.d.ts.map +1 -1
- package/dist/src/sessions/context.js +3 -4
- package/dist/src/sessions/context.js.map +1 -1
- package/dist/src/sessions/engine-fallback.d.ts +43 -1
- package/dist/src/sessions/engine-fallback.d.ts.map +1 -1
- package/dist/src/sessions/engine-fallback.js +266 -15
- package/dist/src/sessions/engine-fallback.js.map +1 -1
- package/dist/src/sessions/engine-health-gate.d.ts +83 -0
- package/dist/src/sessions/engine-health-gate.d.ts.map +1 -0
- package/dist/src/sessions/engine-health-gate.js +186 -0
- package/dist/src/sessions/engine-health-gate.js.map +1 -0
- package/dist/src/sessions/engine-login.d.ts +58 -0
- package/dist/src/sessions/engine-login.d.ts.map +1 -0
- package/dist/src/sessions/engine-login.js +107 -0
- package/dist/src/sessions/engine-login.js.map +1 -0
- package/dist/src/sessions/fork.d.ts.map +1 -1
- package/dist/src/sessions/fork.js +3 -1
- package/dist/src/sessions/fork.js.map +1 -1
- package/dist/src/sessions/goal-execution.d.ts.map +1 -1
- package/dist/src/sessions/goal-execution.js +8 -1
- package/dist/src/sessions/goal-execution.js.map +1 -1
- package/dist/src/sessions/limit-failure-notice.d.ts +41 -0
- package/dist/src/sessions/limit-failure-notice.d.ts.map +1 -0
- package/dist/src/sessions/limit-failure-notice.js +87 -0
- package/dist/src/sessions/limit-failure-notice.js.map +1 -0
- package/dist/src/sessions/lost-turn.d.ts +39 -0
- package/dist/src/sessions/lost-turn.d.ts.map +1 -0
- package/dist/src/sessions/lost-turn.js +32 -0
- package/dist/src/sessions/lost-turn.js.map +1 -0
- package/dist/src/sessions/manager.d.ts.map +1 -1
- package/dist/src/sessions/manager.js +104 -47
- package/dist/src/sessions/manager.js.map +1 -1
- package/dist/src/sessions/new-session-engine.d.ts +42 -0
- package/dist/src/sessions/new-session-engine.d.ts.map +1 -0
- package/dist/src/sessions/new-session-engine.js +100 -0
- package/dist/src/sessions/new-session-engine.js.map +1 -0
- package/dist/src/sessions/origin-delivery.d.ts +50 -4
- package/dist/src/sessions/origin-delivery.d.ts.map +1 -1
- package/dist/src/sessions/origin-delivery.js +108 -9
- package/dist/src/sessions/origin-delivery.js.map +1 -1
- package/dist/src/sessions/queue.d.ts +14 -0
- package/dist/src/sessions/queue.d.ts.map +1 -1
- package/dist/src/sessions/queue.js +38 -2
- package/dist/src/sessions/queue.js.map +1 -1
- package/dist/src/sessions/registry.d.ts +4 -2
- package/dist/src/sessions/registry.d.ts.map +1 -1
- package/dist/src/sessions/registry.js +21 -4
- package/dist/src/sessions/registry.js.map +1 -1
- package/dist/src/sessions/reply-disposition.d.ts +8 -0
- package/dist/src/sessions/reply-disposition.d.ts.map +1 -1
- package/dist/src/sessions/reply-disposition.js +8 -0
- package/dist/src/sessions/reply-disposition.js.map +1 -1
- package/dist/src/sessions/restart-resume.d.ts +234 -0
- package/dist/src/sessions/restart-resume.d.ts.map +1 -0
- package/dist/src/sessions/restart-resume.js +596 -0
- package/dist/src/sessions/restart-resume.js.map +1 -0
- package/dist/src/sessions/speaker-prefix.d.ts.map +1 -1
- package/dist/src/sessions/speaker-prefix.js +3 -1
- package/dist/src/sessions/speaker-prefix.js.map +1 -1
- package/dist/src/sessions/turn-delivery.d.ts +26 -0
- package/dist/src/sessions/turn-delivery.d.ts.map +1 -0
- package/dist/src/sessions/turn-delivery.js +34 -0
- package/dist/src/sessions/turn-delivery.js.map +1 -0
- package/dist/src/sessions/unrequested-stop.d.ts +26 -0
- package/dist/src/sessions/unrequested-stop.d.ts.map +1 -0
- package/dist/src/sessions/unrequested-stop.js +19 -0
- package/dist/src/sessions/unrequested-stop.js.map +1 -0
- package/dist/src/sessions/usage-limit-wait.d.ts +14 -0
- package/dist/src/sessions/usage-limit-wait.d.ts.map +1 -0
- package/dist/src/sessions/usage-limit-wait.js +9 -0
- package/dist/src/sessions/usage-limit-wait.js.map +1 -0
- package/dist/src/shared/attachment-download.d.ts +41 -0
- package/dist/src/shared/attachment-download.d.ts.map +1 -0
- package/dist/src/shared/attachment-download.js +110 -0
- package/dist/src/shared/attachment-download.js.map +1 -0
- package/dist/src/shared/attachment-notice.d.ts +24 -0
- package/dist/src/shared/attachment-notice.d.ts.map +1 -0
- package/dist/src/shared/attachment-notice.js +37 -0
- package/dist/src/shared/attachment-notice.js.map +1 -0
- package/dist/src/shared/attachments.d.ts +65 -0
- package/dist/src/shared/attachments.d.ts.map +1 -0
- package/dist/src/shared/attachments.js +153 -0
- package/dist/src/shared/attachments.js.map +1 -0
- package/dist/src/shared/childEnv.d.ts +15 -0
- package/dist/src/shared/childEnv.d.ts.map +1 -1
- package/dist/src/shared/childEnv.js +15 -0
- package/dist/src/shared/childEnv.js.map +1 -1
- package/dist/src/shared/claude-auto-memory.d.ts +33 -0
- package/dist/src/shared/claude-auto-memory.d.ts.map +1 -0
- package/dist/src/shared/claude-auto-memory.js +156 -0
- package/dist/src/shared/claude-auto-memory.js.map +1 -0
- package/dist/src/shared/claude-limit-reset.d.ts +54 -0
- package/dist/src/shared/claude-limit-reset.d.ts.map +1 -0
- package/dist/src/shared/claude-limit-reset.js +99 -0
- package/dist/src/shared/claude-limit-reset.js.map +1 -0
- package/dist/src/shared/config-error.d.ts +21 -0
- package/dist/src/shared/config-error.d.ts.map +1 -0
- package/dist/src/shared/config-error.js +37 -0
- package/dist/src/shared/config-error.js.map +1 -0
- package/dist/src/shared/config-file.d.ts +57 -0
- package/dist/src/shared/config-file.d.ts.map +1 -0
- package/dist/src/shared/config-file.js +217 -0
- package/dist/src/shared/config-file.js.map +1 -0
- package/dist/src/shared/config-yaml-edit.d.ts +20 -0
- package/dist/src/shared/config-yaml-edit.d.ts.map +1 -0
- package/dist/src/shared/config-yaml-edit.js +468 -0
- package/dist/src/shared/config-yaml-edit.js.map +1 -0
- package/dist/src/shared/config.d.ts.map +1 -1
- package/dist/src/shared/config.js +12 -4
- package/dist/src/shared/config.js.map +1 -1
- package/dist/src/shared/engine-fallback.d.ts +22 -0
- package/dist/src/shared/engine-fallback.d.ts.map +1 -1
- package/dist/src/shared/engine-fallback.js +55 -4
- package/dist/src/shared/engine-fallback.js.map +1 -1
- package/dist/src/shared/engine-health.d.ts +16 -0
- package/dist/src/shared/engine-health.d.ts.map +1 -1
- package/dist/src/shared/engine-health.js +42 -0
- package/dist/src/shared/engine-health.js.map +1 -1
- package/dist/src/shared/list-alignment.d.ts +23 -0
- package/dist/src/shared/list-alignment.d.ts.map +1 -0
- package/dist/src/shared/list-alignment.js +61 -0
- package/dist/src/shared/list-alignment.js.map +1 -0
- package/dist/src/shared/logger.d.ts.map +1 -1
- package/dist/src/shared/logger.js +104 -33
- package/dist/src/shared/logger.js.map +1 -1
- package/dist/src/shared/map-limited.d.ts +11 -0
- package/dist/src/shared/map-limited.d.ts.map +1 -0
- package/dist/src/shared/map-limited.js +30 -0
- package/dist/src/shared/map-limited.js.map +1 -0
- package/dist/src/shared/oneShotCli.d.ts.map +1 -1
- package/dist/src/shared/oneShotCli.js +4 -2
- package/dist/src/shared/oneShotCli.js.map +1 -1
- package/dist/src/shared/partial-delivery.d.ts +24 -0
- package/dist/src/shared/partial-delivery.d.ts.map +1 -0
- package/dist/src/shared/partial-delivery.js +46 -0
- package/dist/src/shared/partial-delivery.js.map +1 -0
- package/dist/src/shared/process-safety-net.d.ts +44 -0
- package/dist/src/shared/process-safety-net.d.ts.map +1 -0
- package/dist/src/shared/process-safety-net.js +88 -0
- package/dist/src/shared/process-safety-net.js.map +1 -0
- package/dist/src/shared/rateLimit.d.ts +45 -2
- package/dist/src/shared/rateLimit.d.ts.map +1 -1
- package/dist/src/shared/rateLimit.js +64 -2
- package/dist/src/shared/rateLimit.js.map +1 -1
- package/dist/src/shared/redact.d.ts.map +1 -1
- package/dist/src/shared/redact.js +11 -1
- package/dist/src/shared/redact.js.map +1 -1
- package/dist/src/shared/safe-file-name.d.ts +9 -0
- package/dist/src/shared/safe-file-name.d.ts.map +1 -0
- package/dist/src/shared/safe-file-name.js +16 -0
- package/dist/src/shared/safe-file-name.js.map +1 -0
- package/dist/src/shared/terminal-safe-text.d.ts +2 -0
- package/dist/src/shared/terminal-safe-text.d.ts.map +1 -0
- package/dist/src/shared/terminal-safe-text.js +21 -0
- package/dist/src/shared/terminal-safe-text.js.map +1 -0
- package/dist/src/shared/types.d.ts +75 -4
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/skills-sync/apply.d.ts +21 -0
- package/dist/src/skills-sync/apply.d.ts.map +1 -0
- package/dist/src/skills-sync/apply.js +209 -0
- package/dist/src/skills-sync/apply.js.map +1 -0
- package/dist/src/skills-sync/backup-run.d.ts +47 -0
- package/dist/src/skills-sync/backup-run.d.ts.map +1 -0
- package/dist/src/skills-sync/backup-run.js +150 -0
- package/dist/src/skills-sync/backup-run.js.map +1 -0
- package/dist/src/skills-sync/bounded-read.d.ts +32 -0
- package/dist/src/skills-sync/bounded-read.d.ts.map +1 -0
- package/dist/src/skills-sync/bounded-read.js +104 -0
- package/dist/src/skills-sync/bounded-read.js.map +1 -0
- package/dist/src/skills-sync/bundled.d.ts +28 -0
- package/dist/src/skills-sync/bundled.d.ts.map +1 -0
- package/dist/src/skills-sync/bundled.js +84 -0
- package/dist/src/skills-sync/bundled.js.map +1 -0
- package/dist/src/skills-sync/fingerprint.d.ts +32 -0
- package/dist/src/skills-sync/fingerprint.d.ts.map +1 -0
- package/dist/src/skills-sync/fingerprint.js +58 -0
- package/dist/src/skills-sync/fingerprint.js.map +1 -0
- package/dist/src/skills-sync/history.d.ts +44 -0
- package/dist/src/skills-sync/history.d.ts.map +1 -0
- package/dist/src/skills-sync/history.js +115 -0
- package/dist/src/skills-sync/history.js.map +1 -0
- package/dist/src/skills-sync/home-skill.d.ts +28 -0
- package/dist/src/skills-sync/home-skill.d.ts.map +1 -0
- package/dist/src/skills-sync/home-skill.js +67 -0
- package/dist/src/skills-sync/home-skill.js.map +1 -0
- package/dist/src/skills-sync/instance.d.ts +26 -0
- package/dist/src/skills-sync/instance.d.ts.map +1 -0
- package/dist/src/skills-sync/instance.js +128 -0
- package/dist/src/skills-sync/instance.js.map +1 -0
- package/dist/src/skills-sync/names.d.ts +25 -0
- package/dist/src/skills-sync/names.d.ts.map +1 -0
- package/dist/src/skills-sync/names.js +56 -0
- package/dist/src/skills-sync/names.js.map +1 -0
- package/dist/src/skills-sync/plan.d.ts +58 -0
- package/dist/src/skills-sync/plan.d.ts.map +1 -0
- package/dist/src/skills-sync/plan.js +132 -0
- package/dist/src/skills-sync/plan.js.map +1 -0
- package/dist/src/skills-sync/receipt.d.ts +61 -0
- package/dist/src/skills-sync/receipt.d.ts.map +1 -0
- package/dist/src/skills-sync/receipt.js +149 -0
- package/dist/src/skills-sync/receipt.js.map +1 -0
- package/dist/src/skills-sync/staging.d.ts +21 -0
- package/dist/src/skills-sync/staging.d.ts.map +1 -0
- package/dist/src/skills-sync/staging.js +81 -0
- package/dist/src/skills-sync/staging.js.map +1 -0
- package/dist/src/skills-sync/sync.d.ts +37 -0
- package/dist/src/skills-sync/sync.d.ts.map +1 -0
- package/dist/src/skills-sync/sync.js +201 -0
- package/dist/src/skills-sync/sync.js.map +1 -0
- package/dist/src/skills-sync/types.d.ts +66 -0
- package/dist/src/skills-sync/types.d.ts.map +1 -0
- package/dist/src/skills-sync/types.js +2 -0
- package/dist/src/skills-sync/types.js.map +1 -0
- package/dist/src/stt/config.d.ts +5 -0
- package/dist/src/stt/config.d.ts.map +1 -0
- package/dist/src/stt/config.js +18 -0
- package/dist/src/stt/config.js.map +1 -0
- package/dist/src/updates/maintenance.d.ts.map +1 -1
- package/dist/src/updates/maintenance.js +24 -4
- package/dist/src/updates/maintenance.js.map +1 -1
- package/dist/src/workflows/repository-mutex.d.ts +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +11 -11
- package/dist/web/__next._full.txt +12 -12
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/chunks/{0g5c5ppr8zmup.js → 20v6mri7epga5.js} +1 -1
- package/dist/web/_next/static/chunks/2u0328ngpt-ek.js +1 -0
- package/dist/web/_next/static/chunks/3f9i3f9q6v6_j.css +1 -0
- package/dist/web/_next/static/chunks/{08i7uo3uz6_fn.js → 3yy053rafgrzy.js} +1 -1
- package/dist/web/_not-found/__next._full.txt +10 -10
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +9 -9
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +10 -10
- package/dist/web/chat/__next._full.txt +12 -12
- package/dist/web/chat/__next._tree.txt +2 -2
- package/dist/web/chat/__next.chat.__PAGE__.txt +11 -11
- package/dist/web/chat.html +1 -1
- package/dist/web/chat.txt +12 -12
- package/dist/web/cron/__next._full.txt +12 -12
- package/dist/web/cron/__next._tree.txt +2 -2
- package/dist/web/cron/__next.cron.__PAGE__.txt +11 -11
- package/dist/web/cron.html +1 -1
- package/dist/web/cron.txt +12 -12
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +12 -12
- package/dist/web/kanban/__next._full.txt +12 -12
- package/dist/web/kanban/__next._tree.txt +2 -2
- package/dist/web/kanban/__next.kanban.__PAGE__.txt +11 -11
- package/dist/web/kanban.html +1 -1
- package/dist/web/kanban.txt +12 -12
- package/dist/web/logs/__next._full.txt +12 -12
- package/dist/web/logs/__next._tree.txt +2 -2
- package/dist/web/logs/__next.logs.__PAGE__.txt +11 -11
- package/dist/web/logs.html +1 -1
- package/dist/web/logs.txt +12 -12
- package/dist/web/models/__next._full.txt +12 -12
- package/dist/web/models/__next._tree.txt +2 -2
- package/dist/web/models/__next.models.__PAGE__.txt +11 -11
- package/dist/web/models.html +1 -1
- package/dist/web/models.txt +12 -12
- package/dist/web/org/__next._full.txt +12 -12
- package/dist/web/org/__next._tree.txt +2 -2
- package/dist/web/org/__next.org.__PAGE__.txt +11 -11
- package/dist/web/org.html +1 -1
- package/dist/web/org.txt +12 -12
- package/dist/web/sessions/__next._full.txt +10 -10
- package/dist/web/sessions/__next._tree.txt +2 -2
- package/dist/web/sessions/__next.sessions.__PAGE__.txt +9 -9
- package/dist/web/sessions.html +1 -1
- package/dist/web/sessions.txt +10 -10
- package/dist/web/settings/__next._full.txt +12 -12
- package/dist/web/settings/__next._tree.txt +2 -2
- package/dist/web/settings/__next.settings.__PAGE__.txt +11 -11
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +12 -12
- package/dist/web/skills/__next._full.txt +12 -12
- package/dist/web/skills/__next._tree.txt +2 -2
- package/dist/web/skills/__next.skills.__PAGE__.txt +11 -11
- package/dist/web/skills.html +1 -1
- package/dist/web/skills.txt +12 -12
- package/package.json +2 -1
- package/template/AGENTS.md +48 -308
- package/template/CLAUDE.md +4 -349
- package/template/bundled-skill-history.json +377 -0
- package/template/config.default.yaml +52 -3
- package/template/docs/architecture.md +41 -3
- package/template/docs/backup.md +142 -0
- package/template/docs/connectors.md +192 -16
- package/template/docs/cron.md +30 -11
- package/template/docs/memory.md +47 -0
- package/template/docs/overview.md +6 -2
- package/template/docs/self-modification.md +11 -10
- package/template/docs/skills.md +77 -4
- package/template/migrations/0.3.0/MIGRATION.md +6 -0
- package/template/migrations/0.7.3/MIGRATION.md +6 -0
- package/template/migrations/0.7.5/MIGRATION.md +1 -1
- package/template/migrations/0.9.0/MIGRATION.md +6 -0
- package/template/migrations/2026.10.13/MIGRATION.md +76 -0
- package/template/migrations/2026.10.13/files/docs/architecture.md +112 -0
- package/template/migrations/2026.10.13/files/docs/automations.md +110 -0
- package/template/migrations/2026.10.13/files/docs/backup.md +142 -0
- package/template/migrations/2026.10.13/files/docs/connectors.md +370 -0
- package/template/migrations/2026.10.13/files/docs/cron-commands.md +52 -0
- package/template/migrations/2026.10.13/files/docs/cron.md +178 -0
- package/template/migrations/2026.10.13/files/docs/mcp.md +108 -0
- package/template/migrations/2026.10.13/files/docs/memory.md +47 -0
- package/template/migrations/2026.10.13/files/docs/org.md +111 -0
- package/template/migrations/2026.10.13/files/docs/overview.md +44 -0
- package/template/migrations/2026.10.13/files/docs/self-modification.md +71 -0
- package/template/migrations/2026.10.13/files/docs/skills.md +140 -0
- package/template/migrations/2026.10.13/files/skills/cron-manager/SKILL.md +107 -0
- package/template/migrations/2026.10.13/files/skills/management/SKILL.md +227 -0
- package/template/migrations/2026.10.13/files/skills/migrate/SKILL.md +194 -0
- package/template/migrations/2026.10.13/files/skills/onboarding/SKILL.md +153 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/SKILL.md +35 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/engine-fallback.md +98 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/jev.md +89 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/maintenance.md +49 -0
- package/template/migrations/2026.10.13/files/skills/openryoko-config/references/platform.md +100 -0
- package/template/migrations/2026.10.13/files/skills/self-heal/SKILL.md +187 -0
- package/template/migrations/2026.10.9/MIGRATION.md +44 -0
- package/template/migrations/2026.10.9/files/docs/memory.md +47 -0
- package/template/migrations/2026.10.9/files/skills/migrate/SKILL.md +194 -0
- package/template/migrations/2026.5.7/MIGRATION.md +6 -0
- package/template/migrations/2026.8.28/MIGRATION.md +6 -0
- package/template/migrations/2026.9.11/MIGRATION.md +6 -0
- package/template/skills/cron-manager/SKILL.md +10 -0
- package/template/skills/management/SKILL.md +5 -4
- package/template/skills/migrate/SKILL.md +47 -14
- package/template/skills/onboarding/SKILL.md +3 -3
- package/template/skills/openryoko-config/SKILL.md +1 -1
- package/template/skills/openryoko-config/references/engine-fallback.md +16 -5
- package/template/skills/openryoko-config/references/platform.md +23 -4
- package/template/skills/self-heal/SKILL.md +117 -44
- package/dist/src/engines/mock.d.ts +0 -16
- package/dist/src/engines/mock.d.ts.map +0 -1
- package/dist/src/engines/mock.js +0 -47
- package/dist/src/engines/mock.js.map +0 -1
- package/dist/src/shared/test-support/posix-mode.d.ts +0 -17
- package/dist/src/shared/test-support/posix-mode.d.ts.map +0 -1
- package/dist/src/shared/test-support/posix-mode.js +0 -23
- package/dist/src/shared/test-support/posix-mode.js.map +0 -1
- package/dist/web/_next/static/Oux0UBcCkbX5eOp9-vC4k/_buildManifest.js +0 -11
- package/dist/web/_next/static/Oux0UBcCkbX5eOp9-vC4k/_clientMiddlewareManifest.js +0 -1
- package/dist/web/_next/static/Oux0UBcCkbX5eOp9-vC4k/_ssgManifest.js +0 -1
- package/dist/web/_next/static/chunks/02h65sho8c14h.js +0 -1
- package/dist/web/_next/static/chunks/0ic18n-m7ixyw.css +0 -1
- package/dist/web/_next/static/chunks/19s8vn2kgy7q1.js +0 -1
- package/dist/web/_next/static/chunks/1_jm0szyu2the.js +0 -1
- package/dist/web/_next/static/chunks/1omdg4m5w9lgx.js +0 -1
- package/dist/web/_next/static/chunks/25nob1new8t4s.js +0 -79
- package/dist/web/_next/static/chunks/2iqxlc9wtxzm2.js +0 -1
- package/dist/web/_next/static/chunks/3_6klkygi417n.js +0 -1
- package/dist/web/_next/static/chunks/3alc-b00c58_3.css +0 -1
- /package/dist/web/_next/static/{70PNIyOj8-2kywAG6J41- → ov0mWzyHx0B5oEnTHE_pa}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{70PNIyOj8-2kywAG6J41- → ov0mWzyHx0B5oEnTHE_pa}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{70PNIyOj8-2kywAG6J41- → ov0mWzyHx0B5oEnTHE_pa}/_ssgManifest.js +0 -0
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,59794,e=>{"use strict";let i,s,r,n,o,a,l,h,c,d,u,f,_;var p=e.i(47565),g=e.i(28225),m=e.i(38407),v=e.i(47721),b=e.i(91113),x=e.i(62671),S=e.i(83650),y=e.i(20750);let w=(0,y.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),C=(0,y.default)("clock-3",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]]),k=(0,y.default)("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"}]]),E=(0,y.default)("pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);var M=e.i(80719),D=e.i(4322),D=D,R=e.i(76300),L=e.i(24817),B=e.i(58963);function P(e){let i=e;return(i=(i=(i=(i=(i=(i=(i=(i=(i=(i=(i=i.replace(/@[\w-]+/g,"")).replace(/^#\d+\s*/g,"")).replace(/^#{1,6}\s+/gm,"")).replace(/\*{1,3}|_{1,3}/g,"")).replace(/^[\s]*[-*•]\s+/gm,"")).replace(/^[\s]*\d+[.)]\s+/gm,"")).replace(/^>\s*/gm,"")).replace(/`+/g,"")).replace(/^```\w*$/gm,"")).replace(/\[([^\]]*)\]\([^)]*\)/g,"$1")).replace(/\s+/g," ").trim()).length>0&&i[0]!==i[0].toUpperCase()&&(i=i[0].toUpperCase()+i.slice(1)),i}var T=e.i(57244);e.i(87690),e.i(94948),(0,y.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var N=e.i(99300),I=e.i(43836),j=e.i(64503),A=e.i(56316),O=e.i(54379),H=e.i(76173),z=e.i(28461),W=e.i(98037),F=e.i(25948),$=e.i(47776),K=e.i(44726);let U=["top","right","bottom","left"],q=Math.min,V=Math.max,Y=Math.round,X=Math.floor,G=e=>({x:e,y:e}),J={left:"right",right:"left",bottom:"top",top:"bottom"};function Z(e,i){return"function"==typeof e?e(i):e}function Q(e){return e.split("-")[0]}function ee(e){return e.split("-")[1]}function et(e){return"x"===e?"y":"x"}function ei(e){return"y"===e?"height":"width"}function es(e){let i=e[0];return"t"===i||"b"===i?"y":"x"}function er(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}let en=["left","right"],eo=["right","left"],ea=["top","bottom"],el=["bottom","top"];function eh(e){let i=Q(e);return J[i]+e.slice(i.length)}function ec(e){var i,s,r,n;return"number"!=typeof e?{top:null!=(i=e.top)?i:0,right:null!=(s=e.right)?s:0,bottom:null!=(r=e.bottom)?r:0,left:null!=(n=e.left)?n:0}:{top:e,right:e,bottom:e,left:e}}function ed(e){let{x:i,y:s,width:r,height:n}=e;return{width:r,height:n,top:s,left:i,right:i+r,bottom:s+n,x:i,y:s}}function eu(e,i,s){let r,{reference:n,floating:o}=e,a=es(i),l=et(es(i)),h=ei(l),c=Q(i),d=n.x+n.width/2-o.width/2,u=n.y+n.height/2-o.height/2,f=n[h]/2-o[h]/2;switch(c){case"top":r={x:d,y:n.y-o.height};break;case"bottom":r={x:d,y:n.y+n.height};break;case"right":r={x:n.x+n.width,y:u};break;case"left":r={x:n.x-o.width,y:u};break;default:r={x:n.x,y:n.y}}let _=ee(i);return _&&(r[l]+=f*("end"===_?1:-1)*(s&&"y"===a?-1:1)),r}async function ef(e,i){var s;void 0===i&&(i={});let{x:r,y:n,platform:o,rects:a,elements:l,strategy:h}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:f=!1,padding:_=0}=Z(i,e),p=ec(_),g=l[f?"floating"===u?"reference":"floating":u],m=ed(await o.getClippingRect({element:null==(s=await (null==o.isElement?void 0:o.isElement(g)))||s?g:g.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:h})),v="floating"===u?{x:r,y:n,width:a.floating.width,height:a.floating.height}:a.reference,b=await (null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),x=await (null==o.isElement?void 0:o.isElement(b))&&await (null==o.getScale?void 0:o.getScale(b))||{x:1,y:1},S=ed(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:b,strategy:h}):v);return{top:(m.top-S.top+p.top)/x.y,bottom:(S.bottom-m.bottom+p.bottom)/x.y,left:(m.left-S.left+p.left)/x.x,right:(S.right-m.right+p.right)/x.x}}let e_=async(e,i,s)=>{let{placement:r="bottom",strategy:n="absolute",middleware:o=[],platform:a}=s,l=a.detectOverflow?a:{...a,detectOverflow:ef},h=await (null==a.isRTL?void 0:a.isRTL(i)),c=await a.getElementRects({reference:e,floating:i,strategy:n}),{x:d,y:u}=eu(c,r,h),f=r,_=0,p={};for(let s=0;s<o.length;s++){let g=o[s];if(!g)continue;let{name:m,fn:v}=g,{x:b,y:x,data:S,reset:y}=await v({x:d,y:u,initialPlacement:r,placement:f,strategy:n,middlewareData:p,rects:c,platform:l,elements:{reference:e,floating:i}});d=null!=b?b:d,u=null!=x?x:u,p[m]={...p[m],...S},y&&_<50&&(_++,"object"==typeof y&&(y.placement&&(f=y.placement),y.rects&&(c=!0===y.rects?await a.getElementRects({reference:e,floating:i,strategy:n}):y.rects),{x:d,y:u}=eu(c,f,h)),s=-1)}return{x:d,y:u,placement:f,strategy:n,middlewareData:p}};function ep(e,i){return{top:e.top-i.height,right:e.right-i.width,bottom:e.bottom-i.height,left:e.left-i.width}}function eg(e){return U.some(i=>e[i]>=0)}let em=new Set(["left","top"]);async function ev(e,i){let{placement:s,platform:r,elements:n}=e,o=await (null==r.isRTL?void 0:r.isRTL(n.floating)),a=Q(s),l=ee(s),h="y"===es(s),c=em.has(a)?-1:1,d=o&&h?-1:1,u=Z(i,e),{mainAxis:f,crossAxis:_,alignmentAxis:p}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&"number"==typeof p&&(_="end"===l?-1*p:p),h?{x:_*d,y:f*c}:{x:f*c,y:_*d}}function eb(){return"u">typeof window}function ex(e){return ew(e)?(e.nodeName||"").toLowerCase():"#document"}function eS(e){var i;return(null==e||null==(i=e.ownerDocument)?void 0:i.defaultView)||window}function ey(e){var i;return null==(i=(ew(e)?e.ownerDocument:e.document)||window.document)?void 0:i.documentElement}function ew(e){return!!eb()&&(e instanceof Node||e instanceof eS(e).Node)}function eC(e){return!!eb()&&(e instanceof Element||e instanceof eS(e).Element)}function ek(e){return!!eb()&&(e instanceof HTMLElement||e instanceof eS(e).HTMLElement)}function eE(e){return!(!eb()||"u"<typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof eS(e).ShadowRoot)}function eM(e){let{overflow:i,overflowX:s,overflowY:r,display:n}=eI(e);return/auto|scroll|overlay|hidden|clip/.test(i+r+s)&&"inline"!==n&&"contents"!==n}function eD(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}let eR=/transform|translate|scale|rotate|perspective|filter/,eL=/paint|layout|strict|content/,eB=e=>!!e&&"none"!==e;function eP(e){let i=eC(e)?eI(e):e;return eB(i.transform)||eB(i.translate)||eB(i.scale)||eB(i.rotate)||eB(i.perspective)||!eT()&&(eB(i.backdropFilter)||eB(i.filter))||eR.test(i.willChange||"")||eL.test(i.contain||"")}function eT(){return null==i&&(i="u">typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),i}function eN(e){return/^(html|body|#document)$/.test(ex(e))}function eI(e){return eS(e).getComputedStyle(e)}function ej(e){return eC(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function eA(e){if("html"===ex(e))return e;let i=e.assignedSlot||e.parentNode||eE(e)&&e.host||ey(e);return eE(i)?i.host:i}function eO(e,i,s){var r;void 0===i&&(i=[]),void 0===s&&(s=!0);let n=function e(i){let s=eA(i);return eN(s)?(i.ownerDocument||i).body:ek(s)&&eM(s)?s:e(s)}(e),o=n===(null==(r=e.ownerDocument)?void 0:r.body),a=eS(n);if(!o)return i.concat(n,eO(n,[],s));{let e=eH(a);return i.concat(a,a.visualViewport||[],eM(n)?n:[],e&&s?eO(e):[])}}function eH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ez(e){let i=eI(e),s=parseFloat(i.width)||0,r=parseFloat(i.height)||0,n=ek(e),o=n?e.offsetWidth:s,a=n?e.offsetHeight:r,l=Y(s)!==o||Y(r)!==a;return l&&(s=o,r=a),{width:s,height:r,$:l}}function eW(e){return eC(e)?e:e.contextElement}function eF(e){let i=eW(e);if(!ek(i))return G(1);let s=i.getBoundingClientRect(),{width:r,height:n,$:o}=ez(i),a=(o?Y(s.width):s.width)/r,l=(o?Y(s.height):s.height)/n;return a&&Number.isFinite(a)||(a=1),l&&Number.isFinite(l)||(l=1),{x:a,y:l}}let e$=G(0);function eK(e){let i=eS(e);return eT()&&i.visualViewport?{x:i.visualViewport.offsetLeft,y:i.visualViewport.offsetTop}:e$}function eU(e,i,s,r){var n;void 0===i&&(i=!1),void 0===s&&(s=!1);let o=e.getBoundingClientRect(),a=eW(e),l=G(1);i&&(r?eC(r)&&(l=eF(r)):l=eF(e));let h=(void 0===(n=s)&&(n=!1),r&&n&&r===eS(a))?eK(a):G(0),c=(o.left+h.x)/l.x,d=(o.top+h.y)/l.y,u=o.width/l.x,f=o.height/l.y;if(a&&r){let e=eS(a),i=eC(r)?eS(r):r,s=e,n=eH(s);for(;n&&i!==s;){let e=eF(n),i=n.getBoundingClientRect(),r=eI(n),o=i.left+(n.clientLeft+parseFloat(r.paddingLeft))*e.x,a=i.top+(n.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,d*=e.y,u*=e.x,f*=e.y,c+=o,d+=a,n=eH(s=eS(n))}}return ed({width:u,height:f,x:c,y:d})}function eq(e,i){let s=ej(e).scrollLeft;return i?i.left+s:eU(ey(e)).left+s}function eV(e,i){let s=e.getBoundingClientRect();return{x:s.left+i.scrollLeft-eq(e,s),y:s.top+i.scrollTop}}function eY(e,i,s){var r;let n;if("viewport"===i||"layoutViewport"===i)n=function(e,i,s){void 0===s&&(s="viewport");let r="layoutViewport"===s,n=eS(e),o=ey(e),a=n.visualViewport,l=o.clientWidth,h=o.clientHeight,c=0,d=0;if(a){let e=!eT()||"fixed"===i;r?e||(c=-a.offsetLeft,d=-a.offsetTop):(l=a.width,h=a.height,e&&(c=a.offsetLeft,d=a.offsetTop))}if(0>=eq(o)){let e=o.ownerDocument,i=e.body,s=getComputedStyle(i),r="CSS1Compat"===e.compatMode&&parseFloat(s.marginLeft)+parseFloat(s.marginRight)||0,n=Math.abs(o.clientWidth-i.clientWidth-r),a="stable both-edges"===getComputedStyle(o).scrollbarGutter?n/2:n;a<=25&&(l-=a)}return{width:l,height:h,x:c,y:d}}(e,s,i);else if("document"===i){let i,s,o,a,l,h;i=ej(r=ey(e)),s=r.ownerDocument.body,o=V(r.scrollWidth,r.clientWidth,s.scrollWidth,s.clientWidth),a=V(r.scrollHeight,r.clientHeight,s.scrollHeight,s.clientHeight),l=-i.scrollLeft+eq(r),h=-i.scrollTop,"rtl"===eI(s).direction&&(l+=V(r.clientWidth,s.clientWidth)-o),n={width:o,height:a,x:l,y:h}}else if(eC(i)){let e,r,o,a,l,h;r=(e=eU(i,!0,"fixed"===s)).top+i.clientTop,o=e.left+i.clientLeft,a=eF(i),l=i.clientWidth*a.x,h=i.clientHeight*a.y,n={width:l,height:h,x:o*a.x,y:r*a.y}}else{let s=eK(e);n={x:i.x-s.x,y:i.y-s.y,width:i.width,height:i.height}}return ed(n)}function eX(e){return"static"===eI(e).position}function eG(e,i){if(!ek(e)||"fixed"===eI(e).position)return null;if(i)return i(e);let s=e.offsetParent;return ey(e)===s&&(s=s.ownerDocument.body),s}function eJ(e,i){var s;let r=eS(e);if(eD(e))return r;if(!ek(e)){let i=eA(e);for(;i&&!eN(i);){if(eC(i)&&!eX(i))return i;i=eA(i)}return r}let n=eG(e,i);for(;n&&(s=n,/^(table|td|th)$/.test(ex(s)))&&eX(n);)n=eG(n,i);return n&&eN(n)&&eX(n)&&!eP(n)?r:n||function(e){let i=eA(e);for(;ek(i)&&!eN(i);){if(eP(i))return i;if(eD(i))break;i=eA(i)}return null}(e)||r}let eZ=async function(e){let i=this.getOffsetParent||eJ,s=this.getDimensions,r=await s(e.floating);return{reference:function(e,i,s){let r=ek(i),n=ey(i),o="fixed"===s,a=eU(e,!0,o,i),l={scrollLeft:0,scrollTop:0},h=G(0);if((r||!o)&&(("body"!==ex(i)||eM(n))&&(l=ej(i)),r)){let e=eU(i,!0,o,i);h.x=e.x+i.clientLeft,h.y=e.y+i.clientTop}!r&&n&&(h.x=eq(n));let c=!n||r||o?G(0):eV(n,l);return{x:a.left+l.scrollLeft-h.x-c.x,y:a.top+l.scrollTop-h.y-c.y,width:a.width,height:a.height}}(e.reference,await i(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}},eQ={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:i,rect:s,offsetParent:r,strategy:n}=e,o="fixed"===n,a=ey(r),l=!!i&&eD(i.floating);if(r===a||l&&o)return s;let h={scrollLeft:0,scrollTop:0},c=G(1),d=G(0),u=ek(r);if((u||!o)&&(("body"!==ex(r)||eM(a))&&(h=ej(r)),u)){let e=eU(r);c=eF(r),d.x=e.x+r.clientLeft,d.y=e.y+r.clientTop}let f=!a||u||o?G(0):eV(a,h);return{width:s.width*c.x,height:s.height*c.y,x:s.x*c.x-h.scrollLeft*c.x+d.x+f.x,y:s.y*c.y-h.scrollTop*c.y+d.y+f.y}},getDocumentElement:ey,getClippingRect:function(e){let{element:i,boundary:s,rootBoundary:r,strategy:n}=e,o=[..."clippingAncestors"===s?eD(i)?[]:function(e,i){let s=i.get(e);if(s)return s;let r=eO(e,[],!1).filter(e=>eC(e)&&"body"!==ex(e)),n=null,o="fixed"===eI(e).position,a=o?eA(e):e;for(;eC(a)&&!eN(a);){let e=eI(a),i=eP(a),s=n?n.position:o?"fixed":"";i||"fixed"!==s&&("absolute"!==s||"static"!==e.position)?n=e:r=r.filter(e=>e!==a),a=eA(a)}return i.set(e,r),r}(i,this._c):[].concat(s),r],a=eY(i,o[0],n),l=a.top,h=a.right,c=a.bottom,d=a.left;for(let e=1;e<o.length;e++){let s=eY(i,o[e],n);l=V(s.top,l),h=q(s.right,h),c=q(s.bottom,c),d=V(s.left,d)}return{width:h-d,height:c-l,x:d,y:l}},getOffsetParent:eJ,getElementRects:eZ,getClientRects:function(e){return e.getClientRects?Array.from(e.getClientRects()):[]},getDimensions:function(e){let{width:i,height:s}=ez(e);return{width:i,height:s}},getScale:eF,isElement:eC,isRTL:function(e){return"rtl"===eI(e).direction}};function e0(e,i){return e.x===i.x&&e.y===i.y&&e.width===i.width&&e.height===i.height}let e1=e=>({name:"arrow",options:e,async fn(i){let{x:s,y:r,placement:n,rects:o,platform:a,elements:l,middlewareData:h}=i,{element:c,padding:d=0}=Z(e,i)||{};if(null==c)return{};let u=ec(d),f={x:s,y:r},_=et(es(n)),p=ei(_),g=await a.getDimensions(c),m="y"===_,v=m?"clientHeight":"clientWidth",b=o.reference[p]+o.reference[_]-f[_]-o.floating[p],x=f[_]-o.reference[_],S=await (null==a.getOffsetParent?void 0:a.getOffsetParent(c)),y=S?S[v]:0;y&&await (null==a.isElement?void 0:a.isElement(S))||(y=l.floating[v]||o.floating[p]);let w=y/2-g[p]/2-1,C=q(u[m?"top":"left"],w),k=q(u[m?"bottom":"right"],w),E=y-g[p]-k,M=y/2-g[p]/2+(b/2-x/2),D=V(C,q(M,E)),R=!h.arrow&&null!=ee(n)&&M!==D&&o.reference[p]/2-(M<C?C:k)-g[p]/2<0,L=R?M<C?M-C:M-E:0;return{[_]:f[_]+L,data:{[_]:D,centerOffset:M-D-L,...R&&{alignmentOffset:L}},reset:R}}});var e2=e.i(44808),e5="u">typeof document?g.useLayoutEffect:function(){};function e3(e,i){let s,r,n;if(e===i)return!0;if(typeof e!=typeof i)return!1;if("function"==typeof e&&e.toString()===i.toString())return!0;if(e&&i&&"object"==typeof e){if(Array.isArray(e)){if((s=e.length)!==i.length)return!1;for(r=s;0!=r--;)if(!e3(e[r],i[r]))return!1;return!0}if((s=(n=Object.keys(e)).length)!==Object.keys(i).length)return!1;for(r=s;0!=r--;)if(!({}).hasOwnProperty.call(i,n[r]))return!1;for(r=s;0!=r--;){let s=n[r];if(("_owner"!==s||!e.$$typeof)&&!e3(e[s],i[s]))return!1}return!0}return e!=e&&i!=i}function e4(e){return"u"<typeof window?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function e6(e,i){let s=e4(e);return Math.round(i*s)/s}function e8(e){let i=g.useRef(e);return e5(()=>{i.current=e}),i}var e7=Object.defineProperty,e9=g.forwardRef(e7(function(e,i){let{children:s,width:r=10,height:n=5,...o}=e;return(0,p.jsx)(A.Primitive.svg,{...o,ref:i,width:r,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:(0,p.jsx)("polygon",{points:"0,0 30,0 15,10"})})},"name",{value:"Arrow",configurable:!0})),te=e.i(28755),tt=e.i(87114);function ti(e){let[i,s]=g.useState(void 0);return(0,tt.useLayoutEffect)(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});let i=new ResizeObserver(i=>{let r,n;if(!Array.isArray(i)||!i.length)return;let o=i[0];if("borderBoxSize"in o){let e=o.borderBoxSize,i=Array.isArray(e)?e[0]:e;r=i.inlineSize,n=i.blockSize}else r=e.offsetWidth,n=e.offsetHeight;s({width:r,height:n})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}s(void 0)},[e]),i}(0,Object.defineProperty)(ti,"name",{value:"useSize",configurable:!0});var ts=Object.defineProperty,tr=(e,i)=>ts(e,"name",{value:i,configurable:!0}),tn="Popper",[to,ta]=(0,j.createContextScope)(tn),[tl,th]=to(tn),tc=tr(e=>{let{__scopePopper:i,children:s}=e,[r,n]=g.useState(null),[o,a]=g.useState(void 0);return(0,p.jsx)(tl,{scope:i,anchor:r,onAnchorChange:n,placementState:o,setPlacementState:a,children:s})},"Popper"),td=g.forwardRef(tr(function(e,i){let{__scopePopper:s,virtualRef:r,...n}=e,o=th("PopperAnchor",s),a=g.useRef(null),l=o.onAnchorChange,h=g.useCallback(e=>{a.current=e,e&&l(e)},[l]),c=(0,H.useComposedRefs)(i,h),d=g.useRef(null);g.useEffect(()=>{if(!r)return;let e=d.current;d.current=r.current,e!==d.current&&l(d.current)});let u=o.placementState&&tx(o.placementState),f=u?.[0],_=u?.[1];return r?null:(0,p.jsx)(A.Primitive.div,{"data-radix-popper-side":f,"data-radix-popper-align":_,...n,ref:c})},"PopperAnchor")),tu="PopperContent",[tf,t_]=to(tu),tp=g.forwardRef(tr(function(e,i){var s,r,n,o,a,l,h,c,d,u,f,_,m;let v,b,x,S,y,w,{__scopePopper:C,side:k="bottom",sideOffset:E=0,align:M="center",alignOffset:D=0,arrowPadding:R=0,avoidCollisions:L=!0,collisionBoundary:B=[],collisionPadding:P=0,sticky:T="partial",hideWhenDetached:N=!1,updatePositionStrategy:I="optimized",onPlaced:j,...O}=e,z=th(tu,C),[W,F]=g.useState(null),$=(0,H.useComposedRefs)(i,F),[K,U]=g.useState(null),Y=ti(K),G=Y?.width??0,J=Y?.height??0,ec="number"==typeof P?P:{top:0,right:0,bottom:0,left:0,...P},ed=Array.isArray(B)?B:[B],eu=ed.length>0,ef={padding:ec,boundary:ed.filter(tv),altBoundary:eu},{refs:eb,floatingStyles:ex,placement:ew,isPositioned:eC,middlewareData:ek}=function(e){void 0===e&&(e={});let{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:n,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:h,open:c}=e,[d,u]=g.useState({x:0,y:0,strategy:s,placement:i,middlewareData:{},isPositioned:!1}),[f,_]=g.useState(r);e3(f,r)||_(r);let[p,m]=g.useState(null),[v,b]=g.useState(null),x=g.useCallback(e=>{e!==C.current&&(C.current=e,m(e))},[]),S=g.useCallback(e=>{e!==k.current&&(k.current=e,b(e))},[]),y=o||p,w=a||v,C=g.useRef(null),k=g.useRef(null),E=g.useRef(d),M=null!=h,D=e8(h),R=e8(n),L=e8(c),B=g.useCallback(()=>{var e,r;let n,o,a;if(!C.current||!k.current)return;let l={placement:i,strategy:s,middleware:f};R.current&&(l.platform=R.current),(e=C.current,r=k.current,n=new Map,o=null!=l?l:{},a={...eQ,...o.platform,_c:n},e_(e,r,{...o,platform:a})).then(e=>{let i={...e,isPositioned:!1!==L.current};P.current&&!e3(E.current,i)&&(E.current=i,e2.flushSync(()=>{u(i)}))})},[f,i,s,R,L]);e5(()=>{!1===c&&E.current.isPositioned&&(E.current.isPositioned=!1,u(e=>({...e,isPositioned:!1})))},[c]);let P=g.useRef(!1);e5(()=>(P.current=!0,()=>{P.current=!1}),[]),e5(()=>{if(y&&(C.current=y),w&&(k.current=w),y&&w){if(D.current)return D.current(y,w,B);B()}},[y,w,B,D,M]);let T=g.useMemo(()=>({reference:C,floating:k,setReference:x,setFloating:S}),[x,S]),N=g.useMemo(()=>({reference:y,floating:w}),[y,w]),I=g.useMemo(()=>{let e={position:s,left:0,top:0};if(!N.floating)return e;let i=e6(N.floating,d.x),r=e6(N.floating,d.y);return l?{...e,transform:"translate("+i+"px, "+r+"px)",...e4(N.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:i,top:r}},[s,l,N.floating,d.x,d.y]);return g.useMemo(()=>({...d,update:B,refs:T,elements:N,floatingStyles:I}),[d,B,T,N,I])}({strategy:"fixed",placement:k+("center"!==M?"-"+M:""),whileElementsMounted:tr((...e)=>(function(e,i,s,r){let n;void 0===r&&(r={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:h="function"==typeof IntersectionObserver,animationFrame:c=!1}=r,d=eW(e),u=o||a?[...d?eO(d):[],...i?eO(i):[]]:[];u.forEach(e=>{o&&e.addEventListener("scroll",s),a&&e.addEventListener("resize",s)});let f=d&&h?function(e,i,s){let r,n=null,o=ey(e);function a(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}function l(s,h){void 0===s&&(s=!1),void 0===h&&(h=1),a();let c=e.getBoundingClientRect(),{left:d,top:u,width:f,height:_}=c;if(s||i(),!f||!_)return;let p={rootMargin:-X(u)+"px "+-X(o.clientWidth-(d+f))+"px "+-X(o.clientHeight-(u+_))+"px "+-X(d)+"px",threshold:V(0,q(1,h))||1},g=!0;function m(i){let s=i[0].intersectionRatio;if(!e0(c,e.getBoundingClientRect()))return l();if(s!==h){if(!g)return l();s?l(!1,s):r=setTimeout(()=>{l(!1,1e-7)},1e3)}g=!1}try{n=new IntersectionObserver(m,{...p,root:o.ownerDocument})}catch(e){n=new IntersectionObserver(m,p)}n.observe(e)}let h=eS(e),c=()=>l(s);return h.addEventListener("resize",c),l(!0),()=>{h.removeEventListener("resize",c),a()}}(d,s,a):null,_=-1,p=null;l&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===d&&p&&i&&(p.unobserve(i),cancelAnimationFrame(_),_=requestAnimationFrame(()=>{var e;null==(e=p)||e.observe(i)})),s()}),d&&!c&&p.observe(d),i&&p.observe(i));let g=c?eU(e):null;return c&&function i(){let r=eU(e);g&&!e0(g,r)&&s(),g=r,n=requestAnimationFrame(i)}(),s(),()=>{var e;u.forEach(e=>{o&&e.removeEventListener("scroll",s),a&&e.removeEventListener("resize",s)}),null==f||f(),null==(e=p)||e.disconnect(),p=null,c&&cancelAnimationFrame(n)}})(...e,{animationFrame:"always"===I}),"whileElementsMounted"),elements:{reference:z.anchor},middleware:[{name:(v={name:"offset",options:r=s={mainAxis:E+J,alignmentAxis:D},async fn(e){var i,s;let{x:n,y:o,placement:a,middlewareData:l}=e,h=await ev(e,r);return a===(null==(i=l.offset)?void 0:i.placement)&&null!=(s=l.arrow)&&s.alignmentOffset?{}:{x:n+h.x,y:o+h.y,data:{...h,placement:a}}}}).name,fn:v.fn,options:[s,void 0]},L&&{name:(b={name:"shift",options:a=o={mainAxis:!0,crossAxis:!1,limiter:"partial"===T?{fn:(n=void 0,{options:n={},fn(e){var i,s,r,o;let{x:a,y:l,placement:h,rects:c,middlewareData:d}=e,{offset:u=0,mainAxis:f=!0,crossAxis:_=!0}=Z(n,e),p={x:a,y:l},g=es(h),m=et(g),v=p[m],b=p[g],x=Z(u,e),S="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:null!=(i=x.mainAxis)?i:0,crossAxis:null!=(s=x.crossAxis)?s:0};if(f){let e="y"===m?"height":"width",i=c.reference[m]-c.floating[e]+S.mainAxis,s=c.reference[m]+c.reference[e]-S.mainAxis;v<i?v=i:v>s&&(v=s)}if(_){let e="y"===m?"width":"height",i=em.has(Q(h)),s=c.reference[g]-c.floating[e]+(i&&(null==(r=d.offset)?void 0:r[g])||0)+(i?0:S.crossAxis),n=c.reference[g]+c.reference[e]+(i?0:(null==(o=d.offset)?void 0:o[g])||0)-(i?S.crossAxis:0);b<s?b=s:b>n&&(b=n)}return{[m]:v,[g]:b}}}).fn,options:[void 0,void 0]}:void 0,...ef},async fn(e){let{x:i,y:s,placement:r,platform:n}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:h={fn:e=>{let{x:i,y:s}=e;return{x:i,y:s}}},...c}=Z(a,e),d={x:i,y:s},u=await n.detectOverflow(e,c),f=es(r),_=et(f),p=d[_],g=d[f],m=(e,i)=>V(i+u["y"===e?"top":"left"],q(i,i-u["y"===e?"bottom":"right"]));o&&(p=m(_,p)),l&&(g=m(f,g));let v=h.fn({...e,[_]:p,[f]:g});return{...v,data:{x:v.x-i,y:v.y-s,enabled:{[_]:o,[f]:l}}}}}).name,fn:b.fn,options:[o,void 0]},L&&{name:(x={name:"flip",options:h=l={...ef},async fn(e){var i,s,r,n,o,a,l,c;let d,u,f,{placement:_,middlewareData:p,rects:g,initialPlacement:m,platform:v,elements:b}=e,{mainAxis:x=!0,crossAxis:S=!0,fallbackPlacements:y,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:k=!0,...E}=Z(h,e);if(null!=(i=p.arrow)&&i.alignmentOffset)return{};let M=Q(_),D=es(m),R=Q(m)===m,L=await (null==v.isRTL?void 0:v.isRTL(b.floating)),B=y||(R||!k?[eh(m)]:(d=eh(m),[er(m),d,er(d)])),P="none"!==C;!y&&P&&B.push(...(u=ee(m),f=function(e,i,s){switch(e){case"top":case"bottom":if(s)return i?eo:en;return i?en:eo;case"left":case"right":return i?ea:el;default:return[]}}(Q(m),"start"===C,L),u&&(f=f.map(e=>e+"-"+u),k&&(f=f.concat(f.map(er)))),f));let T=[m,...B],N=await v.detectOverflow(e,E),I=[],j=(null==(s=p.flip)?void 0:s.overflows)||[];if(x&&I.push(N[M]),S){let e,i,s,r,n=(a=_,l=g,void 0===(c=L)&&(c=!1),e=ee(a),s=ei(i=et(es(a))),r="x"===i?e===(c?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[s]>l.floating[s]&&(r=eh(r)),[r,eh(r)]);I.push(N[n[0]],N[n[1]])}if(j=[...j,{placement:_,overflows:I}],!I.every(e=>e<=0)){let e=((null==(r=p.flip)?void 0:r.index)||0)+1,i=T[e];if(i&&("alignment"!==S||D===es(i)||j.every(e=>es(e.placement)!==D||e.overflows[0]>0)))return{data:{index:e,overflows:j},reset:{placement:i}};let s=null==(n=j.filter(e=>e.overflows[0]<=0).sort((e,i)=>e.overflows[1]-i.overflows[1])[0])?void 0:n.placement;if(!s)switch(w){case"bestFit":{let e=null==(o=j.filter(e=>{if(P){let i=es(e.placement);return i===D||"y"===i}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,i)=>e+i,0)]).sort((e,i)=>e[1]-i[1])[0])?void 0:o[0];e&&(s=e);break}case"initialPlacement":s=m}if(_!==s)return{reset:{placement:s}}}return{}}}).name,fn:x.fn,options:[l,void 0]},{name:(S={name:"size",options:d=c={...ef,apply:tr(({elements:e,rects:i,availableWidth:s,availableHeight:r})=>{let{width:n,height:o}=i.reference,a=e.floating.style;a.setProperty("--radix-popper-available-width",`${s}px`),a.setProperty("--radix-popper-available-height",`${r}px`),a.setProperty("--radix-popper-anchor-width",`${n}px`),a.setProperty("--radix-popper-anchor-height",`${o}px`)},"apply")},async fn(e){let i,s,{placement:r,rects:n,platform:o,elements:a}=e,{apply:l=()=>{},...h}=Z(d,e),c=await o.detectOverflow(e,h),u=Q(r),f=ee(r),_="y"===es(r),{width:p,height:g}=n.floating;"top"===u||"bottom"===u?(i=u,s=f===(await (null==o.isRTL?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(s=u,i="end"===f?"top":"bottom");let m=g-c.top-c.bottom,v=p-c.left-c.right,b=q(g-c[i],m),x=q(p-c[s],v),S=e.middlewareData.shift,y=!S,w=b,C=x;null!=S&&S.enabled.x&&(C=v),null!=S&&S.enabled.y&&(w=m),y&&!f&&(_?C=p-2*V(c.left,c.right):w=g-2*V(c.top,c.bottom)),await l({...e,availableWidth:C,availableHeight:w});let k=await o.getDimensions(a.floating);return p!==k.width||g!==k.height?{reset:{rects:!0}}:{}}}).name,fn:S.fn,options:[c,void 0]},K&&{name:(y={name:"arrow",options:f=u={element:K,padding:R},fn(e){let{element:i,padding:s}="function"==typeof f?f(e):f;return i&&({}).hasOwnProperty.call(i,"current")?null!=i.current?e1({element:i.current,padding:s}).fn(e):{}:i?e1({element:i,padding:s}).fn(e):{}}}).name,fn:y.fn,options:[u,void 0]},tb({arrowWidth:G,arrowHeight:J}),N&&{name:(w={name:"hide",options:m=_={strategy:"referenceHidden",...ef,boundary:eu?ef.boundary:void 0},async fn(e){let{rects:i,platform:s}=e,{strategy:r="referenceHidden",...n}=Z(m,e);switch(r){case"referenceHidden":{let r=ep(await s.detectOverflow(e,{...n,elementContext:"reference"}),i.reference);return{data:{referenceHiddenOffsets:r,referenceHidden:eg(r)}}}case"escaped":{let r=ep(await s.detectOverflow(e,{...n,altBoundary:!0}),i.floating);return{data:{escapedOffsets:r,escaped:eg(r)}}}default:return{}}}}).name,fn:w.fn,options:[_,void 0]}]}),eE=z.setPlacementState;(0,tt.useLayoutEffect)(()=>(eE(ew),()=>{eE(void 0)}),[ew,eE]);let[eM,eD]=tx(ew),eR=(0,te.useCallbackRef)(j);(0,tt.useLayoutEffect)(()=>{eC&&eR?.()},[eC,eR]);let eL=ek.arrow?.x,eB=ek.arrow?.y,eP=ek.arrow?.centerOffset!==0,[eT,eN]=g.useState();return(0,tt.useLayoutEffect)(()=>{W&&eN(window.getComputedStyle(W).zIndex)},[W]),(0,p.jsx)("div",{ref:eb.setFloating,"data-radix-popper-content-wrapper":"",style:{...ex,transform:eC?ex.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:eT,"--radix-popper-transform-origin":[ek.transformOrigin?.x,ek.transformOrigin?.y].join(" "),...ek.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,p.jsx)(tf,{scope:C,placedSide:eM,placedAlign:eD,onArrowChange:U,arrowX:eL,arrowY:eB,shouldHideArrow:eP,children:(0,p.jsx)(A.Primitive.div,{"data-side":eM,"data-align":eD,...O,ref:$,style:{...O.style,animation:eC?O.style?.animation:"none"}})})})},"PopperContent")),tg={top:"bottom",right:"left",bottom:"top",left:"right"},tm=g.forwardRef(tr(function(e,i){let{__scopePopper:s,...r}=e,n=t_("PopperArrow",s),o=tg[n.placedSide];return(0,p.jsx)("span",{ref:n.onArrowChange,style:{position:"absolute",left:n.arrowX,top:n.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[n.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[n.placedSide],visibility:n.shouldHideArrow?"hidden":void 0},children:(0,p.jsx)(e9,{...r,ref:i,style:{...r.style,display:"block"}})})},"PopperArrow"));function tv(e){return null!==e}tr(tv,"isNotNull");var tb=tr(e=>({name:"transformOrigin",options:e,fn(i){let{placement:s,rects:r,middlewareData:n}=i,o=n.arrow?.centerOffset!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[h,c]=tx(s),d={start:"0%",center:"50%",end:"100%"}[c],u=(n.arrow?.x??0)+a/2,f=(n.arrow?.y??0)+l/2,_="",p="";return"bottom"===h?(_=o?d:`${u}px`,p=`${-l}px`):"top"===h?(_=o?d:`${u}px`,p=`${r.floating.height+l}px`):"right"===h?(_=`${-l}px`,p=o?d:`${f}px`):"left"===h&&(_=`${r.floating.width+l}px`,p=o?d:`${f}px`),{data:{x:_,y:p}}}}),"transformOrigin");function tx(e){let[i,s="center"]=e.split("-");return[i,s]}tr(tx,"getSideAndAlignFromPlacement");var tS=e.i(23416),ty=e.i(11681),tw=e.i(51147),tC=e.i(50700),tk=e.i(73772),tE=e.i(80962),tM=Object.defineProperty,tD=(e,i)=>tM(e,"name",{value:i,configurable:!0}),tR=["Enter"," "],tL=["ArrowUp","PageDown","End"],tB=["ArrowDown","PageUp","Home",...tL],tP={ltr:[...tR,"ArrowRight"],rtl:[...tR,"ArrowLeft"]},tT={ltr:["ArrowLeft"],rtl:["ArrowRight"]},tN="Menu",[tI,tj,tA]=(0,O.createCollection)(tN),[tO,tH]=(0,j.createContextScope)(tN,[tA,ta,tw.createRovingFocusGroupScope]),tz=ta(),tW=(0,tw.createRovingFocusGroupScope)(),[tF,t$]=tO(tN),[tK,tU]=tO(tN),tq=tD(e=>{let{__scopeMenu:i,open:s=!1,children:r,dir:n,onOpenChange:o,modal:a=!0}=e,l=tz(i),[h,c]=g.useState(null),d=g.useRef(!1),u=(0,te.useCallbackRef)(o),f=(0,z.useDirection)(n);return g.useEffect(()=>{let e=tD(()=>{d.current=!0,document.addEventListener("pointerdown",i,{capture:!0,once:!0}),document.addEventListener("pointermove",i,{capture:!0,once:!0})},"handleKeyDown"),i=tD(()=>d.current=!1,"handlePointer");return document.addEventListener("keydown",e,{capture:!0}),()=>{document.removeEventListener("keydown",e,{capture:!0}),document.removeEventListener("pointerdown",i,{capture:!0}),document.removeEventListener("pointermove",i,{capture:!0})}},[]),g.useEffect(()=>{if(!s)return;let e=tD(()=>u(!1),"handleBlur");return window.addEventListener("blur",e),()=>window.removeEventListener("blur",e)},[s,u]),(0,p.jsx)(tc,{...l,children:(0,p.jsx)(tF,{scope:i,open:s,onOpenChange:u,content:h,onContentChange:c,children:(0,p.jsx)(tK,{scope:i,onClose:g.useCallback(()=>u(!1),[u]),isUsingKeyboardRef:d,dir:f,modal:a,children:r})})})},"Menu"),tV=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,...r}=e,n=tz(s);return(0,p.jsx)(td,{...n,...r,ref:i})},"MenuAnchor")),tY="MenuPortal",[tX,tG]=tO(tY,{forceMount:void 0}),tJ=tD(e=>{let{__scopeMenu:i,forceMount:s,children:r,container:n}=e,o=t$(tY,i);return(0,p.jsx)(tX,{scope:i,forceMount:s,children:(0,p.jsx)(ty.Presence,{present:s||o.open,children:(0,p.jsx)(tS.Portal,{asChild:!0,container:n,children:r})})})},"MenuPortal"),tZ="MenuContent",[tQ,t0]=tO(tZ),t1=g.forwardRef(tD(function(e,i){let s=tG(tZ,e.__scopeMenu),{forceMount:r=s.forceMount,...n}=e,o=t$(tZ,e.__scopeMenu),a=tU(tZ,e.__scopeMenu);return(0,p.jsx)(tI.Provider,{scope:e.__scopeMenu,children:(0,p.jsx)(ty.Presence,{present:r||o.open,children:(0,p.jsx)(tI.Slot,{scope:e.__scopeMenu,children:a.modal?(0,p.jsx)(t2,{...n,ref:i}):(0,p.jsx)(t5,{...n,ref:i})})})})},"MenuContent")),t2=g.forwardRef(tD(function(e,i){let s=t$(tZ,e.__scopeMenu),r=g.useRef(null),n=(0,H.useComposedRefs)(i,r);return g.useEffect(()=>{let e=r.current;if(e)return(0,tk.hideOthers)(e)},[]),(0,p.jsx)(t4,{...e,ref:n,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:(0,I.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentModal")),t5=g.forwardRef(tD(function(e,i){let s=t$(tZ,e.__scopeMenu);return(0,p.jsx)(t4,{...e,ref:i,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})},"MenuRootContentNonModal")),t3=(0,tC.createSlot)("MenuContent.ScrollLock"),t4=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,loop:r=!1,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:l,onEntryFocus:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,onDismiss:_,disableOutsideScroll:m,...v}=e,b=t$(tZ,s),x=tU(tZ,s),S=tz(s),y=tW(s),w=tj(s),[C,k]=g.useState(null),E=g.useRef(null),M=(0,H.useComposedRefs)(i,E,b.onContentChange),D=g.useRef(0),R=g.useRef(""),L=g.useRef(0),B=g.useRef(null),P=g.useRef("right"),T=g.useRef(0),N=m?tE.RemoveScroll:g.Fragment,j=tD(e=>{let i=R.current+e,s=w().filter(e=>!e.disabled),r=document.activeElement,n=s.find(e=>e.ref.current===r)?.textValue,o=iM(s.map(e=>e.textValue),i,n),a=s.find(e=>e.textValue===o)?.ref.current;a&&setTimeout(()=>a.focus())},"handleTypeaheadSearch");g.useEffect(()=>()=>window.clearTimeout(D.current),[]),(0,F.useFocusGuards)();let A=g.useCallback(e=>P.current===B.current?.side&&iR(e,B.current?.area),[]);return(0,p.jsx)(tQ,{scope:s,searchRef:R,onItemEnter:g.useCallback(e=>{A(e)&&e.preventDefault()},[A]),onItemLeave:g.useCallback(e=>{A(e)||(E.current?.focus(),k(null))},[A]),onTriggerLeave:g.useCallback(e=>{A(e)&&e.preventDefault()},[A]),pointerGraceTimerRef:L,onPointerGraceIntentChange:g.useCallback(e=>{B.current=e},[]),children:(0,p.jsx)(N,{...m?{as:t3,allowPinchZoom:!0}:void 0,children:(0,p.jsx)($.FocusScope,{asChild:!0,trapped:n,onMountAutoFocus:(0,I.composeEventHandlers)(o,e=>{e.preventDefault(),E.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:(0,p.jsx)(W.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:u,onInteractOutside:f,onDismiss:_,children:(0,p.jsx)(tw.Root,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:(0,I.composeEventHandlers)(h,e=>{x.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,p.jsx)(tp,{role:"menu","aria-orientation":"vertical","data-state":iy(b.open),"data-radix-menu-content":"",dir:x.dir,...S,...v,ref:M,style:{outline:"none",...v.style},onKeyDown:(0,I.composeEventHandlers)(v.onKeyDown,e=>{let i=e.target.closest("[data-radix-menu-content]")===e.currentTarget,s=e.ctrlKey||e.altKey||e.metaKey,r=1===e.key.length;i&&("Tab"===e.key&&e.preventDefault(),!s&&r&&j(e.key));let n=E.current;if(e.target!==n||!tB.includes(e.key))return;e.preventDefault();let o=w().filter(e=>!e.disabled).map(e=>e.ref.current);tL.includes(e.key)&&o.reverse(),ik(o)}),onBlur:(0,I.composeEventHandlers)(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(D.current),R.current="")}),onPointerMove:(0,I.composeEventHandlers)(e.onPointerMove,iL(e=>{let i=e.target,s=T.current!==e.clientX;e.currentTarget.contains(i)&&s&&(P.current=e.clientX>T.current?"right":"left",T.current=e.clientX)}))})})})})})})},"MenuContentImpl")),t6=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,...r}=e;return(0,p.jsx)(A.Primitive.div,{role:"group",...r,ref:i})},"MenuGroup")),t8=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,...r}=e;return(0,p.jsx)(A.Primitive.div,{...r,ref:i})},"MenuLabel")),t7="MenuItem",t9="menu.itemSelect",ie=g.forwardRef(tD(function(e,i){let{disabled:s=!1,onSelect:r,...n}=e,o=g.useRef(null),a=tU(t7,e.__scopeMenu),l=t0(t7,e.__scopeMenu),h=(0,H.useComposedRefs)(i,o),c=g.useRef(!1),d=tD(()=>{let e=o.current;if(!s&&e){let i=new CustomEvent(t9,{bubbles:!0,cancelable:!0});e.addEventListener(t9,e=>r?.(e),{once:!0}),(0,A.dispatchDiscreteCustomEvent)(e,i),i.defaultPrevented?c.current=!1:a.onClose()}},"handleSelect");return(0,p.jsx)(it,{...n,ref:h,disabled:s,onClick:(0,I.composeEventHandlers)(e.onClick,d),onPointerDown:i=>{e.onPointerDown?.(i),c.current=!0},onPointerUp:(0,I.composeEventHandlers)(e.onPointerUp,e=>{c.current||e.currentTarget?.click()}),onKeyDown:(0,I.composeEventHandlers)(e.onKeyDown,e=>{s||e.target!==e.currentTarget||(""===l.searchRef.current||" "!==e.key)&&tR.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},"MenuItem")),it=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,disabled:r=!1,textValue:n,...o}=e,a=t0(t7,s),l=tW(s),h=g.useRef(null),c=(0,H.useComposedRefs)(i,h),[d,u]=g.useState(!1),[f,_]=g.useState("");return g.useEffect(()=>{let e=h.current;e&&_((e.textContent??"").trim())},[o.children]),(0,p.jsx)(tI.ItemSlot,{scope:s,disabled:r,textValue:n??f,children:(0,p.jsx)(tw.Item,{asChild:!0,...l,focusable:!r,children:(0,p.jsx)(A.Primitive.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:c,onPointerMove:(0,I.composeEventHandlers)(e.onPointerMove,iL(e=>{r?a.onItemLeave(e):(a.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:(0,I.composeEventHandlers)(e.onPointerLeave,iL(e=>a.onItemLeave(e))),onFocus:(0,I.composeEventHandlers)(e.onFocus,()=>u(!0)),onBlur:(0,I.composeEventHandlers)(e.onBlur,()=>u(!1))})})})},"MenuItemImpl")),ii=g.forwardRef(tD(function(e,i){let{checked:s=!1,onCheckedChange:r,...n}=e;return(0,p.jsx)(ih,{scope:e.__scopeMenu,checked:s,children:(0,p.jsx)(ie,{role:"menuitemcheckbox","aria-checked":iw(s)?"mixed":s,...n,ref:i,"data-state":iC(s),onSelect:(0,I.composeEventHandlers)(n.onSelect,()=>r?.(!!iw(s)||!s),{checkForDefaultPrevented:!1})})})},"MenuCheckboxItem")),[is,ir]=tO("MenuRadioGroup",{value:void 0,onValueChange:tD(()=>{},"onValueChange")}),io=g.forwardRef(tD(function(e,i){let{value:s,onValueChange:r,...n}=e,o=(0,te.useCallbackRef)(r);return(0,p.jsx)(is,{scope:e.__scopeMenu,value:s,onValueChange:o,children:(0,p.jsx)(t6,{...n,ref:i})})},"MenuRadioGroup")),ia=g.forwardRef(tD(function(e,i){let{value:s,...r}=e,n=ir("MenuRadioItem",e.__scopeMenu),o=s===n.value;return(0,p.jsx)(ih,{scope:e.__scopeMenu,checked:o,children:(0,p.jsx)(ie,{role:"menuitemradio","aria-checked":o,...r,ref:i,"data-state":iC(o),onSelect:(0,I.composeEventHandlers)(r.onSelect,()=>n.onValueChange?.(s),{checkForDefaultPrevented:!1})})})},"MenuRadioItem")),il="MenuItemIndicator",[ih,ic]=tO(il,{checked:!1}),id=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,forceMount:r,...n}=e,o=ic(il,s);return(0,p.jsx)(ty.Presence,{present:r||iw(o.checked)||!0===o.checked,children:(0,p.jsx)(A.Primitive.span,{...n,ref:i,"data-state":iC(o.checked)})})},"MenuItemIndicator")),iu=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,...r}=e;return(0,p.jsx)(A.Primitive.div,{role:"separator","aria-orientation":"horizontal",...r,ref:i})},"MenuSeparator")),i_=g.forwardRef(tD(function(e,i){let{__scopeMenu:s,...r}=e,n=tz(s);return(0,p.jsx)(tm,{...n,...r,ref:i})},"MenuArrow")),ip="MenuSub",[ig,im]=tO(ip),iv=tD(e=>{let{__scopeMenu:i,children:s,open:r=!1,onOpenChange:n}=e,o=t$(ip,i),a=tz(i),[l,h]=g.useState(null),[c,d]=g.useState(null),u=(0,te.useCallbackRef)(n);return g.useEffect(()=>(!1===o.open&&u(!1),()=>u(!1)),[o.open,u]),(0,p.jsx)(tc,{...a,children:(0,p.jsx)(tF,{scope:i,open:r,onOpenChange:u,content:c,onContentChange:d,children:(0,p.jsx)(ig,{scope:i,contentId:(0,K.useId)(),triggerId:(0,K.useId)(),trigger:l,onTriggerChange:h,children:s})})})},"MenuSub"),ib="MenuSubTrigger",ix=g.forwardRef(tD(function(e,i){let s=t$(ib,e.__scopeMenu),r=tU(ib,e.__scopeMenu),n=im(ib,e.__scopeMenu),o=t0(ib,e.__scopeMenu),a=g.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:h}=o,c={__scopeMenu:e.__scopeMenu},d=g.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);g.useEffect(()=>d,[d]),g.useEffect(()=>{let e=l.current;return()=>{window.clearTimeout(e),h(null)}},[l,h]);let u=(0,H.useComposedRefs)(i,n.onTriggerChange);return(0,p.jsx)(tV,{asChild:!0,...c,children:(0,p.jsx)(it,{id:n.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?n.contentId:void 0,"data-state":iy(s.open),...e,ref:u,onClick:i=>{e.onClick?.(i),e.disabled||i.defaultPrevented||(i.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:(0,I.composeEventHandlers)(e.onPointerMove,iL(i=>{o.onItemEnter(i),!i.defaultPrevented&&(e.disabled||s.open||a.current||(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{s.onOpenChange(!0),d()},100)))})),onPointerLeave:(0,I.composeEventHandlers)(e.onPointerLeave,iL(e=>{d();let i=s.content?.getBoundingClientRect();if(i){let r=s.content?.dataset.side,n="right"===r,a=i[n?"left":"right"],h=i[n?"right":"left"];o.onPointerGraceIntentChange({area:[{x:e.clientX+(n?-5:5),y:e.clientY},{x:a,y:i.top},{x:h,y:i.top},{x:h,y:i.bottom},{x:a,y:i.bottom}],side:r}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(e),e.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:(0,I.composeEventHandlers)(e.onKeyDown,i=>{e.disabled||i.target!==i.currentTarget||(""===o.searchRef.current||" "!==i.key)&&tP[r.dir].includes(i.key)&&(s.onOpenChange(!0),s.content?.focus(),i.preventDefault())})})})},"MenuSubTrigger")),iS=g.forwardRef(tD(function(e,i){let s=tG(tZ,e.__scopeMenu),{forceMount:r=s.forceMount,align:n="start",...o}=e,a=t$(tZ,e.__scopeMenu),l=tU(tZ,e.__scopeMenu),h=im("MenuSubContent",e.__scopeMenu),c=g.useRef(null),d=(0,H.useComposedRefs)(i,c);return(0,p.jsx)(tI.Provider,{scope:e.__scopeMenu,children:(0,p.jsx)(ty.Presence,{present:r||a.open,children:(0,p.jsx)(tI.Slot,{scope:e.__scopeMenu,children:(0,p.jsx)(t4,{id:h.contentId,"aria-labelledby":h.triggerId,...o,ref:d,align:n,side:"rtl"===l.dir?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{l.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:(0,I.composeEventHandlers)(e.onFocusOutside,e=>{e.target!==h.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:(0,I.composeEventHandlers)(e.onEscapeKeyDown,e=>{l.onClose(),e.preventDefault()}),onKeyDown:(0,I.composeEventHandlers)(e.onKeyDown,e=>{let i=e.currentTarget.contains(e.target),s=tT[l.dir].includes(e.key);i&&s&&(a.onOpenChange(!1),h.trigger?.focus(),e.preventDefault())})})})})})},"MenuSubContent"));function iy(e){return e?"open":"closed"}function iw(e){return"indeterminate"===e}function iC(e){return iw(e)?"indeterminate":e?"checked":"unchecked"}function ik(e){let i=document.activeElement;for(let s of e)if(s===i||(s.focus(),document.activeElement!==i))return}function iE(e,i){return e.map((s,r)=>e[(i+r)%e.length])}function iM(e,i,s){let r=i.length>1&&Array.from(i).every(e=>e===i[0])?i[0]:i,n=s?e.indexOf(s):-1,o=iE(e,Math.max(n,0));1===r.length&&(o=o.filter(e=>e!==s));let a=o.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return a!==s?a:void 0}function iD(e,i){let{x:s,y:r}=e,n=!1;for(let e=0,o=i.length-1;e<i.length;o=e++){let a=i[e],l=i[o],h=a.x,c=a.y,d=l.x,u=l.y;c>r!=u>r&&s<(d-h)*(r-c)/(u-c)+h&&(n=!n)}return n}function iR(e,i){return!!i&&iD({x:e.clientX,y:e.clientY},i)}function iL(e){return i=>"mouse"===i.pointerType?e(i):void 0}tD(iy,"getOpenState"),tD(iw,"isIndeterminate"),tD(iC,"getCheckedState"),tD(ik,"focusFirst"),tD(iE,"wrapArray"),tD(iM,"getNextMatch"),tD(iD,"isPointInPolygon"),tD(iR,"isPointerInGraceArea"),tD(iL,"whenMouse");var iB=e.i(76440),iP=Object.defineProperty,iT=(e,i)=>iP(e,"name",{value:i,configurable:!0}),iN="ContextMenu",[iI,ij]=(0,j.createContextScope)(iN,[tH]),iA=tH(),[iO,iH]=iI(iN),iz=iT(e=>{let{__scopeContextMenu:i,children:s,onOpenChange:r,open:n,dir:o,modal:a=!0}=e,l=g.useRef(!1);if(N.IS_DEVELOPMENT){let e=g.useRef(!1);g.useEffect(()=>{!0!==n||l.current||e.current||(e.current=!0,console.warn("ContextMenu: The `open` prop has been set to `true` before the user has interacted with the trigger, so its position is indeterminate. This is likely unintended and will result in the menu being anchored to the top-left corner of the viewport."))},[n])}let[h,c]=(0,iB.useControllableState)({prop:n,defaultProp:!1,onChange:r,caller:iN}),d=iA(i);return(0,p.jsx)(iO,{scope:i,open:h,onOpenChange:c,modal:a,hasInteractedRef:l,children:(0,p.jsx)(tq,{...d,dir:o,open:h,onOpenChange:c,modal:a,children:s})})},"ContextMenu"),iW=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,disabled:r=!1,...n}=e,o=iH("ContextMenuTrigger",s),a=iA(s),[l,h]=g.useState({x:0,y:0}),c=g.useMemo(()=>({current:{getBoundingClientRect:iT(()=>DOMRect.fromRect({width:0,height:0,...l}),"getBoundingClientRect")}}),[l]),d=g.useRef(0),u=g.useCallback(()=>window.clearTimeout(d.current),[]),f=iT(e=>{o.hasInteractedRef.current=!0,h({x:e.clientX,y:e.clientY}),o.onOpenChange(!0)},"handleOpen");return g.useEffect(()=>u,[u]),g.useEffect(()=>void(r&&u()),[r,u]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(tV,{...a,virtualRef:c}),(0,p.jsx)(A.Primitive.span,{"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,...n,ref:i,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:(0,I.composeEventHandlers)(e.onContextMenu,e=>{u(),f(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:(0,I.composeEventHandlers)(e.onPointerDown,i2(e=>{u(),o.open&&o.onOpenChange(!1),d.current=window.setTimeout(()=>f(e),700)})),onPointerMove:r?e.onPointerMove:(0,I.composeEventHandlers)(e.onPointerMove,i2(u)),onPointerCancel:r?e.onPointerCancel:(0,I.composeEventHandlers)(e.onPointerCancel,i2(u)),onPointerUp:r?e.onPointerUp:(0,I.composeEventHandlers)(e.onPointerUp,i2(u))})]})},"ContextMenuTrigger")),iF=iT(e=>{let{__scopeContextMenu:i,...s}=e,r=iA(i);return(0,p.jsx)(tJ,{...r,...s})},"ContextMenuPortal"),i$=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iH("ContextMenuContent",s),o=iA(s),a=g.useRef(!1);return(0,p.jsx)(t1,{...o,...r,ref:i,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),!i.defaultPrevented&&a.current&&i.preventDefault(),a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||n.modal||(a.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"ContextMenuContent")),iK=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(t6,{...n,...r,ref:i})},"ContextMenuGroup")),iU=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(t8,{...n,...r,ref:i})},"ContextMenuLabel")),iq=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(ie,{...n,...r,ref:i})},"ContextMenuItem")),iV=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(ii,{...n,...r,ref:i})},"ContextMenuCheckboxItem")),iY=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(io,{...n,...r,ref:i})},"ContextMenuRadioGroup")),iX=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(ia,{...n,...r,ref:i})},"ContextMenuRadioItem")),iG=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(id,{...n,...r,ref:i})},"ContextMenuItemIndicator")),iJ=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(iu,{...n,...r,ref:i})},"ContextMenuSeparator")),iZ=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(i_,{...n,...r,ref:i})},"ContextMenuArrow")),iQ=iT(e=>{let{__scopeContextMenu:i,children:s,onOpenChange:r,open:n,defaultOpen:o}=e,a=iA(i),[l,h]=(0,iB.useControllableState)({prop:n,defaultProp:o??!1,onChange:r,caller:"ContextMenuSub"});return(0,p.jsx)(iv,{...a,open:l,onOpenChange:h,children:s})},"ContextMenuSub"),i0=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(ix,{...n,...r,ref:i})},"ContextMenuSubTrigger")),i1=g.forwardRef(iT(function(e,i){let{__scopeContextMenu:s,...r}=e,n=iA(s);return(0,p.jsx)(iS,{...n,...r,ref:i,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"ContextMenuSubContent"));function i2(e){return i=>"mouse"!==i.pointerType?e(i):void 0}iT(i2,"whenTouchOrPen"),e.s(["Arrow",0,iZ,"CheckboxItem",0,iV,"Content",0,i$,"ContextMenu",0,iz,"ContextMenuArrow",0,iZ,"ContextMenuCheckboxItem",0,iV,"ContextMenuContent",0,i$,"ContextMenuGroup",0,iK,"ContextMenuItem",0,iq,"ContextMenuItemIndicator",0,iG,"ContextMenuLabel",0,iU,"ContextMenuPortal",0,iF,"ContextMenuRadioGroup",0,iY,"ContextMenuRadioItem",0,iX,"ContextMenuSeparator",0,iJ,"ContextMenuSub",0,iQ,"ContextMenuSubContent",0,i1,"ContextMenuSubTrigger",0,i0,"ContextMenuTrigger",0,iW,"Group",0,iK,"Item",0,iq,"ItemIndicator",0,iG,"Label",0,iU,"Portal",0,iF,"RadioGroup",0,iY,"RadioItem",0,iX,"Root",0,iz,"Separator",0,iJ,"Sub",0,iQ,"SubContent",0,i1,"SubTrigger",0,i0,"Trigger",0,iW,"createContextMenuScope",0,ij],83960);var i5=e.i(83960),i5=i5,i3=e.i(65458);function i4({...e}){return(0,p.jsx)(i5.Root,{"data-slot":"context-menu",...e})}function i6({...e}){return(0,p.jsx)(i5.Trigger,{"data-slot":"context-menu-trigger",...e})}function i8({className:e,...i}){return(0,p.jsx)(i5.Portal,{children:(0,p.jsx)(i5.Content,{"data-slot":"context-menu-content",className:(0,i3.cn)("z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),...i})})}function i7({className:e,inset:i,variant:s="default",...r}){return(0,p.jsx)(i5.Item,{"data-slot":"context-menu-item","data-inset":i,"data-variant":s,className:(0,i3.cn)("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",e),...r})}function i9({className:e,...i}){return(0,p.jsx)(i5.Separator,{"data-slot":"context-menu-separator",className:(0,i3.cn)("-mx-1 my-1 h-px bg-border",e),...i})}var se=Object.defineProperty,st=(e,i)=>se(e,"name",{value:i,configurable:!0}),si="DropdownMenu",[ss,sr]=(0,j.createContextScope)(si,[tH]),sn=tH(),[so,sa]=ss(si),sl=st(e=>{let{__scopeDropdownMenu:i,children:s,dir:r,open:n,defaultOpen:o,onOpenChange:a,modal:l=!0}=e,h=sn(i),c=g.useRef(null),[d,u]=(0,iB.useControllableState)({prop:n,defaultProp:o??!1,onChange:a,caller:si});return(0,p.jsx)(so,{scope:i,triggerId:(0,K.useId)(),triggerRef:c,contentId:(0,K.useId)(),open:d,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(e=>!e),[u]),modal:l,children:(0,p.jsx)(tq,{...h,open:d,onOpenChange:u,dir:r,modal:l,children:s})})},"DropdownMenu"),sh=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,disabled:r=!1,...n}=e,o=sa("DropdownMenuTrigger",s),a=sn(s),l=(0,H.useComposedRefs)(i,o.triggerRef);return(0,p.jsx)(tV,{asChild:!0,...a,children:(0,p.jsx)(A.Primitive.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...n,ref:l,onPointerDown:(0,I.composeEventHandlers)(e.onPointerDown,e=>{!r&&0===e.button&&!1===e.ctrlKey&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:(0,I.composeEventHandlers)(e.onKeyDown,e=>{!r&&(["Enter"," "].includes(e.key)&&o.onOpenToggle(),"ArrowDown"===e.key&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(e.key)&&e.preventDefault())})})})},"DropdownMenuTrigger")),sc=st(e=>{let{__scopeDropdownMenu:i,...s}=e,r=sn(i);return(0,p.jsx)(tJ,{...r,...s})},"DropdownMenuPortal"),sd=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sa("DropdownMenuContent",s),o=sn(s),a=g.useRef(!1);return(0,p.jsx)(t1,{id:n.contentId,"aria-labelledby":n.triggerId,...o,...r,ref:i,onCloseAutoFocus:(0,I.composeEventHandlers)(e.onCloseAutoFocus,e=>{a.current||n.triggerRef.current?.focus(),a.current=!1,e.preventDefault()}),onInteractOutside:(0,I.composeEventHandlers)(e.onInteractOutside,e=>{let i=e.detail.originalEvent,s=0===i.button&&!0===i.ctrlKey,r=2===i.button||s;(!n.modal||r)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuContent")),su=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(t6,{...n,...r,ref:i})},"DropdownMenuGroup")),sf=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(t8,{...n,...r,ref:i})},"DropdownMenuLabel")),s_=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(ie,{...n,...r,ref:i})},"DropdownMenuItem")),sp=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(ii,{...n,...r,ref:i})},"DropdownMenuCheckboxItem")),sg=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(io,{...n,...r,ref:i})},"DropdownMenuRadioGroup")),sm=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(ia,{...n,...r,ref:i})},"DropdownMenuRadioItem")),sv=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(id,{...n,...r,ref:i})},"DropdownMenuItemIndicator")),sb=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(iu,{...n,...r,ref:i})},"DropdownMenuSeparator")),sx=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(i_,{...n,...r,ref:i})},"DropdownMenuArrow")),sS=st(e=>{let{__scopeDropdownMenu:i,children:s,open:r,onOpenChange:n,defaultOpen:o}=e,a=sn(i),[l,h]=(0,iB.useControllableState)({prop:r,defaultProp:o??!1,onChange:n,caller:"DropdownMenuSub"});return(0,p.jsx)(iv,{...a,open:l,onOpenChange:h,children:s})},"DropdownMenuSub"),sy=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(ix,{...n,...r,ref:i})},"DropdownMenuSubTrigger")),sw=g.forwardRef(st(function(e,i){let{__scopeDropdownMenu:s,...r}=e,n=sn(s);return(0,p.jsx)(iS,{...n,...r,ref:i,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})},"DropdownMenuSubContent"));e.s(["Arrow",0,sx,"CheckboxItem",0,sp,"Content",0,sd,"DropdownMenu",0,sl,"DropdownMenuArrow",0,sx,"DropdownMenuCheckboxItem",0,sp,"DropdownMenuContent",0,sd,"DropdownMenuGroup",0,su,"DropdownMenuItem",0,s_,"DropdownMenuItemIndicator",0,sv,"DropdownMenuLabel",0,sf,"DropdownMenuPortal",0,sc,"DropdownMenuRadioGroup",0,sg,"DropdownMenuRadioItem",0,sm,"DropdownMenuSeparator",0,sb,"DropdownMenuSub",0,sS,"DropdownMenuSubContent",0,sw,"DropdownMenuSubTrigger",0,sy,"DropdownMenuTrigger",0,sh,"Group",0,su,"Item",0,s_,"ItemIndicator",0,sv,"Label",0,sf,"Portal",0,sc,"RadioGroup",0,sg,"RadioItem",0,sm,"Root",0,sl,"Separator",0,sb,"Sub",0,sS,"SubContent",0,sw,"SubTrigger",0,sy,"Trigger",0,sh,"createDropdownMenuScope",0,sr],40466);var sC=e.i(40466),sC=sC;function sk({...e}){return(0,p.jsx)(sC.Root,{"data-slot":"dropdown-menu",...e})}function sE({...e}){return(0,p.jsx)(sC.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function sM({className:e,sideOffset:i=4,...s}){return(0,p.jsx)(sC.Portal,{children:(0,p.jsx)(sC.Content,{"data-slot":"dropdown-menu-content",sideOffset:i,className:(0,i3.cn)("z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",e),...s})})}function sD({className:e,inset:i,variant:s="default",...r}){return(0,p.jsx)(sC.Item,{"data-slot":"dropdown-menu-item","data-inset":i,"data-variant":s,className:(0,i3.cn)("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",e),...r})}function sR({className:e,...i}){return(0,p.jsx)(sC.Separator,{"data-slot":"dropdown-menu-separator",className:(0,i3.cn)("-mx-1 my-1 h-px bg-border",e),...i})}var sL=e.i(60218),sB=e.i(9988);let sP="jinn-sidebar-collapsed",sT="jinn-sidebar-expanded",sN="jinn-pinned-sessions";function sI(e){if(!e)return"";let i=new Date(e),s=Date.now()-i.getTime();return s<6e4?"now":s<36e5?`${Math.floor(s/6e4)}m`:s<864e5?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0}):s<1728e5?"yesterday":new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function sj(){try{let e=localStorage.getItem("jinn-read-sessions");return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}function sA(e){try{localStorage.setItem(sN,JSON.stringify(Array.from(e)))}catch{}}function sO(e){return"cron"===e.source||(e.sourceRef||"").startsWith("cron:")}function sH(e){return e.lastActivity||e.createdAt||""}function sz(e){return[...e].sort((e,i)=>sH(i).localeCompare(sH(e)))}function sW(e,i){return"running"===e.status?"var(--system-blue)":"error"===e.status?"var(--system-red)":i.has(e.id)?"var(--text-quaternary)":"var(--system-green)"}function sF({color:e,pulse:i=!1,className:s}){return(0,p.jsx)("span",{className:(0,i3.cn)("shrink-0 rounded-full",s),style:{background:e,animation:i?"sidebar-pulse 2s ease-in-out infinite":"none",boxShadow:i?`0 0 8px ${e}`:"none"}})}function s$({selectedId:e,onSelect:i,onNewChat:s,onDelete:r,onDuplicate:n,onSessionsLoaded:o,onEmployeeSessionsAvailable:a,onOrderComputed:l}){let{settings:h}=(0,B.useSettings)(),c=h.portalName??"Ryoko",d=c.toLowerCase(),{data:u,isLoading:f,fetchNextPage:_,hasNextPage:m,isFetchingNextPage:b}=(0,T.useSessions)(),x=(0,T.useUpdateSession)(),y=(0,T.useDeleteSession)(),N=(0,T.useBulkDeleteSessions)(),I=(0,T.useDuplicateSession)(),j=(0,g.useMemo)(()=>{if(!u)return[];let e=u.filter(e=>"web"===e.source||"cron"===e.source||"whatsapp"===e.source||"discord"===e.source||!e.source);return e.sort((e,i)=>{let s=e.lastActivity||e.createdAt||"";return(i.lastActivity||i.createdAt||"").localeCompare(s)}),e},[u]),[A,O]=(0,g.useState)(""),[H,z]=(0,g.useState)(null),W=(0,g.useRef)(!1),[F,$]=(0,g.useState)(new Set),[K,U]=(0,g.useState)(new Set),[q,V]=(0,g.useState)(new Set),[Y,X]=(0,g.useState)({}),[G,J]=(0,g.useState)({}),[Z,Q]=(0,g.useState)(null),ee=(0,g.useRef)(null),[et,ei]=(0,g.useState)(new Map),es=(0,g.useRef)(o);(0,g.useEffect)(()=>{es.current=o},[o]),(0,g.useEffect)(()=>{j.length>0&&(0,g.startTransition)(()=>{es.current?.(j)})},[j]),(0,g.useEffect)(()=>{$(sj()),U(function(){try{let e=localStorage.getItem(sN);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}()),V(function(){try{let e=localStorage.getItem(sP);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}()),X(function(){try{let e=localStorage.getItem(sT);return e?JSON.parse(e):{}}catch{return{}}}())},[]),(0,g.useEffect)(()=>{if(e){let i,s;(i=sj()).add(e),(s=Array.from(i)).length>500&&s.splice(0,s.length-500),localStorage.setItem("jinn-read-sessions",JSON.stringify(s)),$(i=>{let s=new Set(i);return s.add(e),s})}},[e]),(0,g.useEffect)(()=>{v.api.getOrg().then(e=>{let i=new Map;for(let s of e.employees)i.set(s.name,s);ei(i)}).catch(()=>{})},[]);let er=(0,g.useCallback)(()=>{V(e=>{let i=new Set(e);i.has("cron")?i.delete("cron"):i.add("cron");try{localStorage.setItem(sP,JSON.stringify(Array.from(i)))}catch{}return i})},[]),en=(0,g.useCallback)(e=>{X(i=>{let s={...i,[e]:!i[e]};try{localStorage.setItem(sT,JSON.stringify(s))}catch{}return s[e]||J(i=>{if(!i[e])return i;let{[e]:s,...r}=i;return r}),s})},[]),eo=(0,g.useCallback)(e=>{U(i=>{let s=new Set(i);return s.has(e)?s.delete(e):s.add(e),sA(s),s})},[]),ea=(0,g.useCallback)(e=>{let i=sj();for(let s of e)i.add(s.id);let s=Array.from(i);s.length>500&&s.splice(0,s.length-500),localStorage.setItem("jinn-read-sessions",JSON.stringify(s)),$(i=>{let s=new Set(i);for(let i of e)s.add(i.id);return s})},[]);async function el(i,r){let n=r.map(e=>e.id);try{await N.mutateAsync(n),U(e=>{let s=new Set(e);for(let e of(s.delete(`emp:${i}`),n))s.delete(e);return sA(s),s}),(0,g.startTransition)(()=>{e&&n.includes(e)&&s()})}catch{}}async function eh(n){let o=null;if(e===n){let e=[],i=i=>{for(let s of i){let i=s.employeeName,r=s.sessions||[];if(1===r.length)e.push(r[0].id);else if(Y[i])for(let s of G[i]?r:r.slice(0,5))e.push(s.id);else r.length>0&&e.push(r[0].id)}};for(let s of(i(eg),i(em),eb))e.push(s.id);let s=e.indexOf(n);-1!==s&&(s+1<e.length?o=e[s+1]:s-1>=0&&(o=e[s-1]))}try{await y.mutateAsync(n),U(e=>{if(!e.has(n))return e;let i=new Set(e);return i.delete(n),sA(i),i}),(0,g.startTransition)(()=>{o?i(o):r?r(n):e===n&&s()})}catch{}}async function ec(e){try{let s=await I.mutateAsync(e);s?.id&&(n?.(s.id),i(s.id),z(s.id),W.current=!1)}catch(e){window.alert(`Duplicate failed: ${e.message||"Unknown error"}`)}}let ed=A.trim()?j.filter(e=>{let i=A.toLowerCase(),s=e.employee?et.get(e.employee):void 0;return e.id.toLowerCase().includes(i)||e.employee&&e.employee.toLowerCase().includes(i)||s?.displayName&&s.displayName.toLowerCase().includes(i)||e.title&&e.title.toLowerCase().includes(i)}):j,eu=[],ef=[],e_=new Map;for(let e of ed)if(sO(e))eu.push(e);else if(sO(e)||e.employee&&e.employee!==d){let i=e.employee;e_.has(i)||e_.set(i,[]),e_.get(i).push(e)}else ef.push(e);let ep=[];for(let[e,i]of e_){let s=sz(i);ep.push({type:"employee",employeeName:e,employeeData:et.get(e),sessions:s,sortKey:sH(s[0]),pinKey:`emp:${e}`})}if(ef.length>0){let e=sz(ef);ep.push({type:"employee",employeeName:d,employeeData:{name:d,displayName:c,emoji:"💬",department:"direct",role:"",rank:"manager",engine:"",model:"",persona:""},sessions:e,sortKey:sH(e[0]),pinKey:`emp:${d}`})}let eg=ep.filter(e=>K.has(e.pinKey)).sort((e,i)=>i.sortKey.localeCompare(e.sortKey)),em=ep.filter(e=>!K.has(e.pinKey)).sort((e,i)=>i.sortKey.localeCompare(e.sortKey)),ev=q.has("cron"),eb=sz(eu),ex=(0,g.useRef)(""),eS=(0,g.useMemo)(()=>{let e=[],i=[],s={};for(let r of[...eg,...em]){let n=r.employeeName;i.push(n);let o=r.sessions.map(e=>e.id);s[n]=o,e.push(...o)}for(let i of eb)e.push(i.id);return{sessionIds:e,employeeNames:i,employeeSessionMap:s}},[eg,em,eb]);function ey(s,r){var n,o;let l=s.id===e,h=sW(s,F),d="running"===s.status,u=(n=s.title,o=s.employee,n?"Jinn"!==c&&n.startsWith("Jinn - ")?c+n.slice(4):n:o||c),f=P(u)||u,_=sI(sH(s)),g=K.has(s.id),m=H===s.id;return(0,p.jsxs)(i4,{children:[(0,p.jsx)(i6,{asChild:!0,children:(0,p.jsxs)(m?"div":"button",{...!m&&{onClick:()=>{i(s.id),a?.(r??[s])}},className:(0,i3.cn)("group/session relative flex w-full items-center gap-2.5 border-l-2 px-4 py-2 text-left transition-colors",r?"pl-11":"pl-6",l?"border-l-[var(--accent)] bg-[var(--fill-secondary)]":"border-l-transparent hover:bg-accent"),children:[(0,p.jsx)(sF,{color:h,pulse:d,className:"size-1.5"}),m?(0,p.jsx)("input",{autoFocus:!0,maxLength:200,defaultValue:f,className:(0,i3.cn)("min-w-0 flex-1 truncate border-none bg-transparent text-xs outline-none ring-1 ring-[var(--accent)] rounded px-0.5",l?"font-semibold text-foreground":"text-[var(--text-secondary)]"),onFocus:e=>e.target.select(),onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Enter"===e.key?e.currentTarget.blur():"Escape"===e.key&&(W.current=!0,z(null))},onBlur:e=>{if(W.current){W.current=!1;return}let i=e.target.value.trim();i&&i!==f&&x.mutate({id:s.id,data:{title:i}}),z(null)}}):(0,p.jsx)("span",{className:(0,i3.cn)("min-w-0 flex-1 truncate text-xs",l?"font-semibold text-foreground":"text-[var(--text-secondary)]"),children:P(u)||"Untitled"}),g?(0,p.jsx)(E,{className:"size-3 shrink-0 text-[var(--accent)] group-hover/session:lg:hidden group-has-[[data-state=open]]/session:lg:hidden"}):null,(0,p.jsx)("span",{className:"shrink-0 text-[10px] text-[var(--text-quaternary)] group-hover/session:lg:hidden group-has-[[data-state=open]]/session:lg:hidden",children:_}),(0,p.jsxs)(sk,{children:[(0,p.jsx)(sE,{asChild:!0,children:(0,p.jsx)("button",{onClick:e=>e.stopPropagation(),className:"hidden shrink-0 text-muted-foreground transition-colors hover:text-foreground group-hover/session:lg:block group-has-[[data-state=open]]/session:lg:block",children:(0,p.jsx)(k,{className:"size-3.5"})})}),(0,p.jsxs)(sM,{align:"end",children:[(0,p.jsx)(sD,{onClick:()=>{W.current=!1,z(s.id)},children:"Rename"}),(0,p.jsx)(sD,{onClick:()=>eo(s.id),children:g?"Unpin":"Pin"}),(0,p.jsx)(sD,{onClick:()=>ec(s.id),children:"Duplicate..."}),(0,p.jsx)(sR,{}),(0,p.jsx)(sD,{variant:"destructive",onClick:()=>Q({type:"session",id:s.id,label:P(u)||"Untitled"}),children:"Delete session"})]})]})]})}),(0,p.jsxs)(i8,{children:[(0,p.jsx)(i7,{onClick:()=>{W.current=!1,z(s.id)},children:"Rename"}),(0,p.jsx)(i7,{onClick:()=>eo(s.id),children:g?"Unpin":"Pin"}),(0,p.jsx)(i7,{onClick:()=>ec(s.id),children:"Duplicate..."}),(0,p.jsx)(i9,{}),(0,p.jsxs)(i7,{variant:"destructive",onClick:()=>Q({type:"session",id:s.id,label:P(u)||"Untitled"}),children:[(0,p.jsx)("span",{className:"flex-1",children:"Delete session"}),(0,p.jsx)("kbd",{className:"ml-auto pl-3 font-mono text-[10px] text-[var(--text-quaternary)]",children:"⌫"})]})]})]},s.id)}function ew(s){let r=s.employeeName,n=s.sessions,o=n[0],l=s.employeeData,h=l?.displayName||r.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),c=l?.department||"",d=sI(sH(o)),u=sW(o,F),f="running"===o.status,_=n.some(i=>i.id===e),g=K.has(s.pinKey),m=n.length,v=Y[r]||!1,b=n.some(e=>!F.has(e.id)&&"running"!==e.status&&"error"!==e.status);return(0,p.jsxs)("div",{children:[(0,p.jsxs)(i4,{children:[(0,p.jsx)(i6,{asChild:!0,children:(0,p.jsxs)("button",{onClick:()=>(function(e){let s=e.employeeName,r=e.sessions;if(r.length>1){let e=Y[s]||!1;en(s),e||(i(r[0].id),a?.(r))}else i(r[0].id),a?.(r)})(s),className:(0,i3.cn)("group/emp relative flex w-full items-center gap-3 border-l-2 px-4 py-3 text-left transition-colors",_?"border-l-[var(--accent)] bg-[var(--fill-secondary)]":"border-l-transparent hover:bg-accent"),children:[(0,p.jsxs)("div",{className:"relative flex size-9 shrink-0 items-center justify-center",children:[(0,p.jsx)(L.EmployeeAvatar,{name:r,size:36}),(0,p.jsx)(sF,{color:u,pulse:f,className:"absolute -bottom-0.5 -right-0 size-2.5 border-2 border-[var(--sidebar-bg)]"})]}),(0,p.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,p.jsxs)("div",{className:"mb-0.5 flex items-baseline gap-2",children:[(0,p.jsx)("span",{className:(0,i3.cn)("min-w-0 flex-1 truncate text-[13px] tracking-[-0.2px] text-foreground",b||_?"font-semibold":"font-medium"),children:h}),(0,p.jsx)("span",{className:"shrink-0 text-[10px] text-[var(--text-tertiary)] group-hover/emp:lg:hidden group-has-[[data-state=open]]/emp:lg:hidden",children:d}),(0,p.jsxs)(sk,{children:[(0,p.jsx)(sE,{asChild:!0,children:(0,p.jsx)("button",{onClick:e=>e.stopPropagation(),className:"hidden shrink-0 text-muted-foreground transition-colors hover:text-foreground group-hover/emp:lg:block group-has-[[data-state=open]]/emp:lg:block",children:(0,p.jsx)(k,{className:"size-3.5"})})}),(0,p.jsxs)(sM,{align:"end",children:[(0,p.jsx)(sD,{onClick:()=>eo(s.pinKey),children:g?"Unpin":"Pin"}),(0,p.jsx)(sD,{onClick:()=>ea(n),children:"Mark all as read"}),(0,p.jsx)(sR,{}),(0,p.jsx)(sD,{variant:"destructive",onClick:()=>Q({type:"employee",id:r,label:h,sessions:n}),children:"Delete all chats"})]})]})]}),(0,p.jsxs)("div",{className:"flex items-center gap-1.5 overflow-hidden text-[11px] text-[var(--text-tertiary)]",children:[c?(0,p.jsx)("span",{className:"truncate",children:c}):null,m>1?(0,p.jsxs)("span",{className:"shrink-0 rounded bg-[var(--fill-tertiary)] px-1.5 py-0.5 text-[10px]",children:[m," chats"]}):null,g?(0,p.jsx)(E,{className:"size-3 shrink-0 text-[var(--accent)]"}):null]})]})]})}),(0,p.jsxs)(i8,{children:[(0,p.jsx)(i7,{onClick:()=>eo(s.pinKey),children:g?"Unpin":"Pin"}),(0,p.jsx)(i7,{onClick:()=>ea(n),children:"Mark all as read"}),(0,p.jsx)(i9,{}),(0,p.jsx)(i7,{variant:"destructive",onClick:()=>Q({type:"employee",id:r,label:h,sessions:n}),children:"Delete all chats"})]})]}),v&&m>1?G[r]?n.map(e=>ey(e,n)):n.slice(0,5).map(e=>ey(e,n)):null,v&&m>5&&!G[r]?(0,p.jsxs)("button",{onClick:()=>J(e=>({...e,[r]:!0})),className:"w-full cursor-pointer px-4 pb-2 pl-11 text-left text-[10px] text-[var(--text-quaternary)] transition-colors hover:text-[var(--text-secondary)]",children:["+",m-5," more"]}):null]},s.pinKey)}return(0,g.useEffect)(()=>{let e=eS.sessionIds.join(",");e!==ex.current&&(ex.current=e,l?.(eS))},[eS,l]),(0,p.jsxs)("div",{className:"jsx-fb767975a1bed37e flex h-full flex-col border-r border-border bg-[var(--sidebar-bg)]",children:[(0,p.jsxs)("div",{className:"jsx-fb767975a1bed37e shrink-0 border-b border-border bg-[var(--material-thick)] px-4 pb-3 pt-3",children:[(0,p.jsxs)("div",{className:"jsx-fb767975a1bed37e mb-2 flex items-center justify-between gap-3",children:[(0,p.jsxs)("div",{className:"jsx-fb767975a1bed37e",children:[(0,p.jsx)("h2",{className:"jsx-fb767975a1bed37e text-xl font-bold tracking-[-0.03em] text-foreground",children:"Chats"}),(0,p.jsx)("p",{className:"jsx-fb767975a1bed37e text-xs text-muted-foreground",children:"All conversations"})]}),(0,p.jsx)("div",{className:"jsx-fb767975a1bed37e flex items-center gap-1.5",children:(0,p.jsxs)(sL.Button,{size:"sm",className:"gap-1.5",onClick:s,title:"New chat (N)",children:[(0,p.jsx)(M.Plus,{className:"size-3.5"}),"New"]})})]}),(0,p.jsxs)("div",{className:"jsx-fb767975a1bed37e flex items-center gap-2 rounded-[var(--radius-md)] bg-[var(--fill-tertiary)] px-3 py-2",children:[(0,p.jsx)(D.default,{className:"size-3.5 shrink-0 text-[var(--text-tertiary)]"}),(0,p.jsx)("input",{id:"chat-search",type:"text",value:A,onChange:e=>O(e.target.value),placeholder:"Search...","aria-label":"Search chats",className:"jsx-fb767975a1bed37e min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-[var(--text-tertiary)]"}),A.trim()?(0,p.jsx)("button",{onClick:()=>O(""),"aria-label":"Clear search",className:"jsx-fb767975a1bed37e rounded-full p-0.5 text-[var(--text-tertiary)] transition-colors hover:bg-[var(--fill-secondary)] hover:text-foreground",children:(0,p.jsx)(R.X,{className:"size-3"})}):null]})]}),(0,p.jsx)("div",{className:"jsx-fb767975a1bed37e flex-1 overflow-y-auto",children:f?(0,p.jsx)("div",{className:"jsx-fb767975a1bed37e px-4 py-8 text-center text-xs text-[var(--text-quaternary)]",children:"Loading sessions..."}):0===eg.length&&0===em.length&&0===eu.length?(0,p.jsx)("div",{className:"jsx-fb767975a1bed37e px-4 py-8 text-center text-xs text-[var(--text-quaternary)]",children:A.trim()?"No matching chats":"No conversations yet"}):(0,p.jsxs)(p.Fragment,{children:[eg.map(e=>ew(e)),em.map(e=>ew(e)),eu.length>0?(0,p.jsxs)("div",{className:"jsx-fb767975a1bed37e "+((0,i3.cn)("mt-2",0===eg.length&&0===em.length&&"mt-0")||""),children:[(0,p.jsxs)("button",{onClick:er,className:"jsx-fb767975a1bed37e flex w-full items-center gap-2 px-4 py-2 text-left transition-colors hover:bg-accent",children:[(0,p.jsx)(C,{className:"size-3.5 text-muted-foreground"}),(0,p.jsx)("span",{className:"jsx-fb767975a1bed37e text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:"Scheduled"}),(0,p.jsx)("span",{className:"jsx-fb767975a1bed37e ml-auto rounded bg-[var(--fill-tertiary)] px-1.5 py-0.5 text-[10px] text-[var(--text-secondary)]",children:eu.length}),(0,p.jsx)(w,{className:(0,i3.cn)("size-3.5 text-muted-foreground transition-transform",ev&&"-rotate-90")})]}),ev?null:eb.map(e=>ey(e))]}):null,m?(0,p.jsx)("div",{className:"jsx-fb767975a1bed37e px-4 py-3",children:(0,p.jsx)(sL.Button,{type:"button",variant:"outline",size:"sm",className:"w-full",disabled:b,onClick:()=>void _(),children:b?"Loading older chats...":"Load older chats"})}):null]})}),(0,p.jsx)(sB.Dialog,{open:!!Z,onOpenChange:e=>{e||Q(null)},children:(0,p.jsxs)(sB.DialogContent,{showCloseButton:!1,className:"max-w-sm",onOpenAutoFocus:e=>{e.preventDefault(),ee.current?.focus()},children:[(0,p.jsxs)(sB.DialogHeader,{children:[(0,p.jsx)(sB.DialogTitle,{children:Z?.type==="employee"?`Delete all chats with "${Z.label}"?`:`Delete "${Z?.label}"?`}),(0,p.jsx)(sB.DialogDescription,{children:Z?.type==="employee"?`This will permanently delete ${Z.sessions?.length??0} session(s) and all their messages. This cannot be undone.`:"This will permanently delete the session and all its messages. This cannot be undone."})]}),(0,p.jsxs)(sB.DialogFooter,{children:[(0,p.jsx)(sL.Button,{variant:"outline",onClick:()=>Q(null),children:"Cancel"}),(0,p.jsx)(sL.Button,{ref:ee,variant:"destructive",onClick:()=>{Z&&("employee"===Z.type&&Z.sessions?el(Z.id,Z.sessions):eh(Z.id),Q(null))},children:"Delete"})]})]})}),(0,p.jsx)(S.default,{id:"fb767975a1bed37e",children:"@keyframes sidebar-pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(.85)}}"})]})}let sK=(0,y.default)("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]),sU=(0,y.default)("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);var sq=e.i(43596);let sV={running:"bg-blue-500 animate-pulse",error:"bg-red-500",idle:"bg-zinc-500"};function sY({tabs:e,activeIndex:i,onSwitch:s,onClose:r,onNew:n,onPin:o,onMove:a,toolbarActions:l,sidebarCollapsed:h,onToggleSidebar:c}){let d=(0,g.useRef)(null),[u,f]=(0,g.useState)(null),[_,m]=(0,g.useState)(null),v=e=>{e.currentTarget instanceof HTMLElement&&(e.currentTarget.style.opacity="1"),f(null),m(null)};return(0,p.jsxs)("div",{className:"relative z-[100] flex h-10 shrink-0 items-center border-b border-border bg-[var(--bg-secondary)]",children:[c&&(0,p.jsx)("button",{onClick:c,"aria-label":h?"Show sidebar":"Hide sidebar",className:"flex size-10 shrink-0 items-center justify-center border-r border-border text-muted-foreground transition-colors hover:bg-[var(--fill-quaternary)] hover:text-foreground",children:h?(0,p.jsx)(sK,{size:15}):(0,p.jsx)(sU,{size:15})}),e.length>0&&(0,p.jsx)("div",{ref:d,className:"flex min-w-0 flex-1 items-center overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:e.map((e,n)=>(0,p.jsxs)("button",{onClick:()=>s(n),onDoubleClick:()=>{o?.(n)},onMouseDown:e=>{1===e.button&&(e.preventDefault(),r(n))},draggable:!0,onDragStart:e=>{f(n),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",String(n)),e.currentTarget instanceof HTMLElement&&(e.currentTarget.style.opacity="0.5")},onDragEnd:v,onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move",n!==u&&m(n)},onDrop:e=>(e.preventDefault(),void(f(null),m(null),null!==u&&u!==n&&a?.(u,n))),className:(0,i3.cn)("group flex h-10 max-w-[180px] shrink-0 items-center gap-1.5 border-r border-border px-3 text-xs whitespace-nowrap transition-colors",n===i?"border-b-2 border-b-[var(--accent)] bg-background text-foreground":"text-muted-foreground hover:bg-[var(--fill-quaternary)] hover:text-foreground",e.unread&&n!==i&&"font-bold",_===n&&null!==u&&u!==n&&"border-l-2 border-l-[var(--accent)]"),children:[(0,p.jsx)("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${sV[e.status]||sV.idle}`}),e.employeeName&&(0,p.jsx)(L.EmployeeAvatar,{name:e.employeeName,size:16}),(0,p.jsx)("span",{className:(0,i3.cn)("truncate",e.pinned?"font-medium":"font-normal italic"),children:P(e.label)}),(0,p.jsx)("span",{onClick:e=>{e.stopPropagation(),r(n)},className:"ml-auto rounded-sm p-0.5 opacity-0 transition-all hover:bg-accent hover:text-foreground group-hover:opacity-100",children:(0,p.jsx)(R.X,{size:12})})]},e.sessionId))}),0===e.length&&(0,p.jsx)("div",{className:"flex-1"}),(0,p.jsx)("button",{onClick:n,className:"flex size-10 shrink-0 items-center justify-center text-[var(--text-tertiary)] transition-colors hover:bg-[var(--fill-quaternary)] hover:text-foreground",title:"New Chat (N)",children:(0,p.jsx)(M.Plus,{size:14})}),l&&(0,p.jsxs)("div",{className:"hidden shrink-0 items-center gap-2 border-l border-border px-3 lg:flex",children:[l,(0,p.jsx)(sq.NotificationBell,{})]})]})}let sX="jinn-intermediate-";function sG(e){try{localStorage.removeItem(`${sX}${e}`)}catch{}}function sJ({name:e,size:i,mimeType:s,url:r,isUser:n}){let o,a,l,h,c;return(0,p.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg)",background:n?"var(--accent)":"var(--material-thin)",border:n?"none":"1px solid var(--separator)",maxWidth:280,minWidth:180},children:[(0,p.jsx)("div",{style:{width:36,height:36,borderRadius:"var(--radius-sm)",background:n?"rgba(0,0,0,0.15)":"var(--fill-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:n?"#000":"var(--text-secondary)"},children:(o=e?.split(".").pop()?.toLowerCase()||"",a="application/pdf"===s||"pdf"===o,l=["doc","docx"].includes(o)||s?.includes("wordprocessingml"),h=["txt","csv","json","md"].includes(o)||s?.startsWith("text/"),c=["zip","tar","gz","rar","7z"].includes(o),a?(0,p.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,p.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,p.jsx)("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]}):l?(0,p.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,p.jsx)("polyline",{points:"14 2 14 8 20 8"}),(0,p.jsx)("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),(0,p.jsx)("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),(0,p.jsx)("polyline",{points:"10 9 9 9 8 9"})]}):h?(0,p.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),(0,p.jsx)("polyline",{points:"14 2 14 8 20 8"})]}):c?(0,p.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M21 8v13H3V8"}),(0,p.jsx)("path",{d:"M1 3h22v5H1z"}),(0,p.jsx)("path",{d:"M10 12h4"})]}):(0,p.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,p.jsx)("polyline",{points:"13 2 13 9 20 9"})]}))}),(0,p.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,p.jsx)("div",{style:{fontSize:"var(--text-footnote)",fontWeight:"var(--weight-medium)",color:n?"#000":"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),null!=i&&(0,p.jsx)("div",{style:{fontSize:"var(--text-caption2)",color:n?"rgba(0,0,0,0.5)":"var(--text-tertiary)",marginTop:1},children:i<1024?`${i} B`:i<1048576?`${(i/1024).toFixed(0)} KB`:`${(i/1048576).toFixed(1)} MB`})]}),(0,p.jsx)("a",{href:r,download:e,"aria-label":`Download ${e}`,style:{width:28,height:28,borderRadius:"50%",background:n?"rgba(0,0,0,0.15)":"var(--fill-secondary)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:n?"#000":"var(--text-secondary)",textDecoration:"none"},children:(0,p.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,p.jsx)("polyline",{points:"7 10 12 15 17 10"}),(0,p.jsx)("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})})]})}function sZ({src:e,duration:i,waveform:s,isUser:r}){let n,o,a=(0,g.useRef)(null),[l,h]=(0,g.useState)(!1),[c,d]=(0,g.useState)(0),[u,f]=(0,g.useState)(0);(0,g.useEffect)(()=>{let i=new Audio(e);return a.current=i,i.addEventListener("timeupdate",()=>{i.duration&&isFinite(i.duration)&&(d(i.currentTime/i.duration),f(i.currentTime))}),i.addEventListener("ended",()=>{h(!1),d(0),f(0)}),i.addEventListener("pause",()=>h(!1)),i.addEventListener("play",()=>h(!0)),()=>{i.pause(),i.src=""}},[e]);let _=(0,g.useCallback)(()=>{let e=a.current;e&&(l?e.pause():e.play().catch(()=>{}))},[l]),m=s.length>0?s:Array(50).fill(.1),v=l?u:i;return(0,p.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-3)",padding:"var(--space-3) var(--space-4)",borderRadius:"var(--radius-lg)",background:r?"var(--accent)":"var(--material-thin)",border:r?"none":"1px solid var(--separator)",maxWidth:280,minWidth:200},children:[(0,p.jsx)("button",{onClick:_,"aria-label":l?"Pause":"Play",style:{width:28,height:28,borderRadius:"50%",background:r?"rgba(0,0,0,0.2)":"var(--fill-secondary)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,color:r?"#000":"var(--text-primary)"},children:l?(0,p.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,p.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,p.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}):(0,p.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)("polygon",{points:"6,4 20,12 6,20"})})}),(0,p.jsx)("div",{style:{flex:1,display:"flex",alignItems:"center",gap:2,height:28},children:m.map((e,i)=>{let s=i/m.length<=c;return(0,p.jsx)("div",{style:{width:3,borderRadius:1.5,height:`${Math.max(4,24*e)}px`,background:r?s?"rgba(0,0,0,0.7)":"rgba(0,0,0,0.25)":s?"var(--accent)":"var(--fill-primary)",transition:"background 100ms ease",flexShrink:0}},i)})}),(0,p.jsx)("span",{style:{fontSize:"var(--text-caption2)",color:r?"rgba(0,0,0,0.6)":"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",flexShrink:0,minWidth:28,textAlign:"right"},children:(n=Math.floor(v/60),o=Math.floor(v%60),`${n}:${o.toString().padStart(2,"0")}`)})]})}function sQ({msgs:e,isActive:i}){let[s,r]=(0,g.useState)(!1),n=e.every(e=>e.content.startsWith("Used ")),o=i&&!n?`${e.length} tool${1!==e.length?"s":""} running…`:`${e.length} tool${1!==e.length?"s":""} used`;return(0,p.jsxs)("div",{className:"px-[var(--space-4)] mb-[var(--space-1)]",children:[(0,p.jsxs)("button",{onClick:()=>r(e=>!e),className:"flex items-center gap-[var(--space-2)] py-[5px] px-[var(--space-3)] rounded-full bg-[var(--fill-secondary)] border border-[var(--separator)] text-[length:var(--text-caption1)] text-[var(--text-secondary)] cursor-pointer transition-[background] duration-150 ease-in-out hover:bg-[var(--fill-tertiary)]",children:[(0,p.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"opacity-60",children:(0,p.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),o,i&&!n&&(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--system-blue)] animate-[jinn-pulse_1.4s_infinite]"}),(0,p.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:`transition-transform duration-150 ease-in-out opacity-50 ${s?"rotate-180":"rotate-0"}`,children:(0,p.jsx)("polyline",{points:"6 9 12 15 18 9"})})]}),s&&(0,p.jsx)("div",{className:"flex flex-wrap gap-[var(--space-1)] mt-[var(--space-1)] pl-[var(--space-1)]",children:e.map(e=>(0,p.jsx)("span",{className:"inline-flex items-center gap-1 py-0.5 px-2 rounded-full bg-[var(--fill-tertiary)] border border-[var(--separator)] text-[length:var(--text-caption2)] text-[var(--text-tertiary)]",children:e.toolCall},e.id))})]})}function s0(e){let i,s=[],r=/\[([^\]]+)\]\(([^)]+)\)|(https?:\/\/[^\s<]+[^\s<.,;:!?)}\]'"])|(\*\*(.+?)\*\*)|(`([^`]+)`)|\*([^*]+)\*/g,n=0;for(;null!==(i=r.exec(e));)i.index>n&&s.push(e.slice(n,i.index)),i[1]&&i[2]?s.push((0,p.jsx)("a",{href:i[2],target:"_blank",rel:"noopener noreferrer",className:"text-[var(--system-blue)] underline underline-offset-2",children:i[1]},i.index)):i[3]?s.push((0,p.jsx)("a",{href:i[3],target:"_blank",rel:"noopener noreferrer",className:"text-[var(--system-blue)] underline underline-offset-2",children:i[3]},i.index)):i[4]?s.push((0,p.jsx)("strong",{className:"font-[var(--weight-bold)]",children:i[5]},i.index)):i[6]?s.push((0,p.jsx)("code",{className:"bg-[var(--fill-secondary)] border border-[var(--separator)] rounded-[5px] py-px px-[5px] text-[0.88em] font-['SF_Mono',Menlo,monospace] text-[var(--accent)]",children:i[7]},i.index)):i[8]&&s.push((0,p.jsx)("em",{className:"italic opacity-[0.85]",children:i[8]},i.index)),n=i.index+i[0].length;return n<e.length&&s.push(e.slice(n)),1===s.length?s[0]:(0,p.jsx)(p.Fragment,{children:s})}function s1({code:e,keyProp:i}){let[s,r]=(0,g.useState)(!1);return(0,p.jsxs)("div",{className:"relative my-2",children:[(0,p.jsx)("button",{onClick:function(){navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)})},"aria-label":"Copy code",className:"absolute top-2 right-2 py-0.5 px-2 text-[11px] rounded-[var(--radius-sm)] bg-[var(--fill-secondary)] text-[var(--text-secondary)] border border-[var(--separator)] cursor-pointer",children:s?"Copied!":"Copy"}),(0,p.jsx)("pre",{className:"code-block bg-[var(--fill-tertiary)] border border-[var(--separator)] rounded-[var(--radius-md)] py-[var(--space-3)] px-[var(--space-4)] overflow-x-auto text-[13px] leading-normal font-['SF_Mono',Menlo,monospace] text-[var(--text-primary)]",children:(0,p.jsx)("code",{children:e})})]},i)}function s2(e){return/^\|[\s:|-]+\|$/.test(e.trim())}function s5(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(e=>e.trim())}function s3({headerLine:e,rows:i,keyProp:s}){let r=s5(e),n=i.map(s5);return(0,p.jsx)("div",{className:"my-2.5 rounded-[10px] border border-[var(--separator)] overflow-hidden",children:(0,p.jsx)("div",{className:"overflow-x-auto [WebkitOverflowScrolling:touch]",children:(0,p.jsxs)("table",{className:"border-collapse text-[length:var(--text-footnote)] leading-[1.6] w-full min-w-max",children:[(0,p.jsx)("thead",{children:(0,p.jsx)("tr",{className:"bg-[var(--fill-tertiary)]",children:r.map((e,i)=>(0,p.jsx)("th",{className:"text-left py-2.5 px-4 font-semibold text-[var(--text-primary)] border-b border-[var(--separator)] max-w-[280px] break-words",children:s0(e)},i))})}),(0,p.jsx)("tbody",{children:n.map((e,i)=>(0,p.jsx)("tr",{className:i%2==1?"bg-[var(--fill-quaternary,transparent)]":"bg-transparent",children:e.map((e,s)=>(0,p.jsx)("td",{className:`py-2.5 px-4 text-[var(--text-primary)] max-w-[280px] break-words ${i<n.length-1?"border-b border-[var(--separator)]":""}`,children:s0(e)},s))},i))})]})})},s)}function s4(e){if(!e)return null;let i=e.split("\n"),s=[],r=!1,n=[];for(let e=0;e<i.length;e++){let o=i[e];if(o.startsWith("```")){r?(r=!1,s.push((0,p.jsx)(s1,{keyProp:e,code:n.join("\n")},e))):r=!0,n=[];continue}if(r){n.push(o);continue}if(o.trim().startsWith("|")&&o.trim().endsWith("|")&&e+1<i.length&&s2(i[e+1])){e++;let r=[];for(;e+1<i.length&&i[e+1].trim().startsWith("|")&&i[e+1].trim().endsWith("|")&&!s2(i[e+1]);)e++,r.push(i[e]);s.push((0,p.jsx)(s3,{keyProp:e,headerLine:o,rows:r},`table-${e}`));continue}if(""===o.trim()){s.push((0,p.jsx)("div",{className:"h-1.5"},`space-${e}`));continue}if(o.match(/^[-*] /)){s.push((0,p.jsxs)("div",{className:"flex gap-[var(--space-2)] mb-0.5",children:[(0,p.jsx)("span",{className:"text-[var(--accent)] shrink-0 mt-px",children:"•"}),(0,p.jsx)("span",{children:s0(o.slice(2))})]},e));continue}if(o.match(/^\d+\. /)){let i=o.match(/^(\d+)\. /)?.[1];s.push((0,p.jsxs)("div",{className:"flex gap-[var(--space-2)] mb-0.5",children:[(0,p.jsxs)("span",{className:"text-[var(--accent)] shrink-0 font-[var(--weight-semibold)] min-w-4",children:[i,"."]}),(0,p.jsx)("span",{children:s0(o.replace(/^\d+\. /,""))})]},e));continue}if(o.startsWith("### ")){s.push((0,p.jsx)("div",{className:"font-[var(--weight-semibold)] text-[length:var(--text-footnote)] mt-[var(--space-2)] mb-0.5",children:s0(o.slice(4))},e));continue}if(o.startsWith("## ")){s.push((0,p.jsx)("div",{className:"font-[var(--weight-bold)] text-[length:var(--text-subheadline)] mt-[var(--space-3)] mb-[3px]",children:s0(o.slice(3))},e));continue}if(o.startsWith("# ")){s.push((0,p.jsx)("div",{className:"font-[var(--weight-bold)] text-[length:var(--text-body)] mt-[var(--space-3)] mb-[var(--space-1)]",children:s0(o.slice(2))},e));continue}s.push((0,p.jsx)("div",{className:"mb-px",children:s0(o)},e))}return r&&n.length>0&&s.push((0,p.jsx)(s1,{keyProp:999,code:n.join("\n")},"trailing-code")),(0,p.jsx)(p.Fragment,{children:s})}function s6(e){let i=new Date,s=new Date(e),r=i.toDateString()===s.toDateString(),n=new Date(i);n.setDate(n.getDate()-1);let o=n.toDateString()===s.toDateString(),a=s.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0});return r?`Today ${a}`:o?`Yesterday ${a}`:s.toLocaleDateString("en-US",{month:"short",day:"numeric"})+` ${a}`}function s8(e,i){return 0===i||e[i].timestamp-e[i-1].timestamp>3e5}function s7(e,i){let s=e.filter(e=>"image"===e.type),r=e.filter(e=>"audio"===e.type),n=e.filter(e=>"file"===e.type);return(0,p.jsxs)(p.Fragment,{children:[s.map((e,i)=>(0,p.jsx)("div",{className:"mt-[var(--space-2)] rounded-[var(--radius-lg)] overflow-hidden max-w-[280px]",children:(0,p.jsx)("img",{src:e.url,alt:e.name||"Image",className:"w-full block rounded-[var(--radius-lg)] cursor-pointer",onClick:()=>window.open(e.url,"_blank")})},`img-${i}`)),r.map((e,s)=>(0,p.jsx)("div",{className:"mt-[var(--space-2)]",children:(0,p.jsx)(sZ,{src:e.url,duration:e.duration||0,waveform:e.waveform||[],isUser:i})},`audio-${s}`)),n.map((e,s)=>(0,p.jsx)("div",{className:"mt-[var(--space-2)]",children:(0,p.jsx)(sJ,{name:e.name||"File",size:e.size,mimeType:e.mimeType,url:e.url,isUser:i})},`file-${s}`))]})}function s9({messages:e,loading:i,streamingText:s,hasOlder:r,loadingOlder:n,onLoadOlder:o,focusMessageId:a,hasNewer:l,onJumpToLatest:h}){let c=(0,g.useRef)(null),d=(0,g.useRef)(null),u=(0,g.useRef)(null),f=(0,g.useRef)(null),_=(0,g.useRef)(0),m=(0,g.useRef)(0),v=(0,g.useRef)(!0),[b,x]=(0,g.useState)(!1),S=(0,g.useRef)(void 0),y=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=c.current,i=d.current;if(!e||!i)return;let s=new IntersectionObserver(([e])=>{v.current=e.isIntersecting,clearTimeout(S.current),S.current=setTimeout(()=>{x(!e.isIntersecting)},100)},{root:i,rootMargin:"0px 0px 80px 0px",threshold:0});return s.observe(e),()=>{s.disconnect(),clearTimeout(S.current)}},[]),(0,g.useEffect)(()=>{let e=u.current;if(!e)return;let i=new ResizeObserver(()=>{v.current&&c.current&&c.current.scrollIntoView({behavior:"auto"})});return i.observe(e),()=>i.disconnect()},[]),(0,g.useLayoutEffect)(()=>{if(0===e.length){_.current=0,f.current=null;return}let i=e[0]?.id||null,s=f.current,r=null!==s&&e.some(e=>e.id===s),n=null!==s&&i!==s&&r,o=0===_.current&&e.length>0;if(n&&d.current){let e=d.current.scrollHeight-m.current;d.current.scrollTop+=e}else(o||null!==s&&i!==s&&!n)&&(d.current&&(d.current.scrollTop=d.current.scrollHeight),v.current=!0,x(!1));_.current=e.length,f.current=i,m.current=d.current?.scrollHeight??0},[e]),(0,g.useLayoutEffect)(()=>{if(!a||y.current===a)return;let e=document.getElementById(`chat-message-${encodeURIComponent(a)}`);e&&(e.scrollIntoView({block:"center",behavior:"auto"}),y.current=a)},[a,e]);let w=(0,g.useCallback)(()=>{d.current&&(d.current.scrollTop=d.current.scrollHeight),v.current=!0,x(!1)},[]);return 0!==e.length||i?(0,p.jsxs)("div",{ref:d,className:"chat-messages-scroll relative flex-1 overflow-y-auto overflow-x-hidden [overflow-anchor:none] bg-[var(--bg)] min-h-0",children:[(0,p.jsxs)("div",{ref:u,className:"py-[var(--space-3)] pb-[var(--space-6)]",children:[r&&o?(0,p.jsx)("div",{className:"flex justify-center px-4 pb-3",children:(0,p.jsx)("button",{type:"button",disabled:n,onClick:o,className:"rounded-full border border-[var(--separator)] bg-[var(--fill-secondary)] px-3 py-1.5 text-[length:var(--text-caption1)] text-[var(--text-secondary)] transition-colors hover:bg-[var(--fill-tertiary)] disabled:opacity-60",children:n?"Loading older messages…":"Load older messages"})}):null,(function(e){let i=[],s=0;for(;s<e.length;)if("assistant"===e[s].role&&e[s].toolCall){let r=[],n=s;for(;s<e.length&&"assistant"===e[s].role&&e[s].toolCall;)r.push(e[s]),s++;i.push({kind:"tool-group",msgs:r,startIndex:n})}else i.push({kind:"message",msg:e[s],index:s}),s++;return i})(e).map(s=>{if("tool-group"===s.kind){let r=s.msgs[0],n=s8(e,s.startIndex),o=s.startIndex>0?e[s.startIndex-1]:null,a=i&&s.startIndex+s.msgs.length===e.length;return(0,p.jsxs)("div",{className:"[content-visibility:auto] [contain-intrinsic-size:auto_48px]",children:[n&&(0,p.jsx)("div",{className:"text-center py-[var(--space-3)] text-[length:var(--text-caption2)] text-[var(--text-tertiary)]",children:s6(r.timestamp)}),!n&&o&&(0,p.jsx)("div",{className:"assistant"!==o.role?"h-[var(--space-4)]":"h-[var(--space-1)]"}),(0,p.jsx)(sQ,{msgs:s.msgs,isActive:a})]},`tg-${s.startIndex}`)}let{msg:r,index:n}=s,o="user"===r.role,l="notification"===r.role,h=s8(e,n),c=r.media||function(e){let i,s=[],r=/!\[([^\]]*)\]\((https?:\/\/[^)]+\.(jpg|jpeg|png|gif|webp|svg)(\?[^)]*)?)\)/gi;for(;null!==(i=r.exec(e));)s.push({type:"image",url:i[2],name:i[1]||"Image"});let n=/(?<!\]\()https?:\/\/\S+\.(jpg|jpeg|png|gif|webp)(\?\S*)?\b/gi;for(;null!==(i=n.exec(e));){let e=i[0];s.find(i=>i.url===e)||s.push({type:"image",url:e})}let o=/https?:\/\/\S+\.(mp3|wav|ogg|m4a|aac)(\?\S*)?\b/gi;for(;null!==(i=o.exec(e));)s.push({type:"audio",url:i[0],name:i[0].split("/").pop()});return s}(r.content),d=r.content;return c.length>0&&!r.media&&(c.forEach(e=>{d=(d=d.replace(e.url,"")).replace(/!\[[^\]]*\]\([^)]+\)/g,"")}),d=d.trim()),r.media&&r.media.length>0&&d.startsWith("[")&&d.endsWith("]")&&(d=""),(0,p.jsxs)("div",{id:r.id?`chat-message-${encodeURIComponent(r.id)}`:void 0,className:`rounded-[var(--radius-md)] [content-visibility:auto] [contain-intrinsic-size:auto_120px] ${a===r.id?"ring-2 ring-[var(--accent)] ring-offset-2 ring-offset-[var(--bg)]":""}`,children:[h&&(0,p.jsx)("div",{className:"text-center py-[var(--space-3)] text-[length:var(--text-caption2)] text-[var(--text-tertiary)]",children:s6(r.timestamp)}),!h&&n>0&&(0,p.jsx)("div",{className:e[n-1].role!==r.role?"h-[var(--space-4)]":"h-[var(--space-1)]"}),l&&(0,p.jsx)("div",{className:"flex justify-center px-[var(--space-4)] mb-[var(--space-1)]",children:(0,p.jsxs)("div",{className:"notification-msg-bubble flex items-start gap-[var(--space-2)] py-[var(--space-3)] px-[var(--space-4)] rounded-[var(--radius-md)] bg-[var(--fill-secondary)] border border-dashed border-[var(--separator)] text-[var(--text-secondary)] text-[length:var(--text-caption1)] leading-[var(--leading-relaxed)] max-w-[85%]",children:[(0,p.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0 mt-0.5 opacity-60",children:[(0,p.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,p.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),(0,p.jsx)("span",{children:s4(d)})]})}),o&&(0,p.jsxs)("div",{className:"flex flex-col items-end px-[var(--space-4)] mb-[var(--space-1)]",children:[d&&(0,p.jsx)("div",{className:"user-msg-bubble py-[var(--space-3)] px-[var(--space-4)] rounded-[var(--radius-lg)_var(--radius-lg)_var(--radius-sm)_var(--radius-lg)] bg-[var(--accent)] text-[var(--accent-contrast)] text-[length:var(--text-subheadline)] leading-[var(--leading-relaxed)] font-[var(--weight-medium)] shadow-[var(--shadow-subtle)]",children:s4(d)}),c.length>0&&(0,p.jsx)("div",{className:"user-msg-bubble",children:s7(c,!0)})]}),!o&&!l&&(0,p.jsx)("div",{className:"assistant-msg-row flex justify-start px-[var(--space-4)] mb-[var(--space-1)]",children:(0,p.jsxs)("div",{className:"assistant-msg-bubble flex flex-col",children:[d&&(0,p.jsx)("div",{className:"py-[var(--space-3)] px-[var(--space-4)] rounded-[var(--radius-sm)_var(--radius-lg)_var(--radius-lg)_var(--radius-lg)] bg-[var(--material-thin)] border border-[var(--separator)] text-[var(--text-primary)] text-[length:var(--text-subheadline)] leading-[var(--leading-relaxed)]",children:s4(d)}),c.length>0&&s7(c,!1)]})})]},r.id||n)}),s&&(0,p.jsx)("div",{className:"assistant-msg-row flex justify-start px-[var(--space-4)] mb-[var(--space-1)]",children:(0,p.jsx)("div",{className:"assistant-msg-bubble flex flex-col",children:(0,p.jsx)("div",{className:"py-[var(--space-3)] px-[var(--space-4)] rounded-[var(--radius-sm)_var(--radius-lg)_var(--radius-lg)_var(--radius-lg)] bg-[var(--material-thin)] border border-[var(--separator)] text-[var(--text-primary)] text-[length:var(--text-subheadline)] leading-[var(--leading-relaxed)]",children:s4(function(e){let i=e,s=(i.match(/```/g)||[]).length;if(s%2!=0&&(i+="\n```"),s%2==0){let e=i.replace(/```[\s\S]*?```/g,"");(e.match(/`/g)||[]).length%2!=0&&(i+="`"),(e.match(/\*\*/g)||[]).length%2!=0&&(i+="**")}return i}(s))})})}),i&&!s&&e.length>0&&(0,p.jsxs)("div",{className:"flex items-center gap-1.5 py-1.5 px-[var(--space-4)] mt-[var(--space-1)]",children:[(0,p.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[var(--accent)] animate-[jinn-pulse_1.4s_infinite] shrink-0"}),(0,p.jsx)("span",{className:"text-[length:var(--text-caption1)] text-[var(--text-tertiary)] font-[var(--weight-medium)]",children:"Thinking"})]}),l&&h?(0,p.jsx)("div",{className:"flex justify-center px-4 pt-3",children:(0,p.jsx)("button",{type:"button",onClick:h,className:"rounded-full border border-[var(--separator)] bg-[var(--fill-secondary)] px-3 py-1.5 text-[length:var(--text-caption1)] text-[var(--text-secondary)] transition-colors hover:bg-[var(--fill-tertiary)]",children:"Jump to latest messages"})}):null,(0,p.jsx)("div",{ref:c})]}),b&&(0,p.jsxs)("button",{onClick:w,"aria-label":"Scroll to bottom",className:"absolute bottom-4 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 py-1.5 px-3 rounded-full bg-[var(--material-thick)] border border-[var(--separator)] text-[var(--text-secondary)] text-[length:var(--text-caption1)] shadow-[var(--shadow-elevated)] cursor-pointer transition-opacity duration-150 hover:bg-[var(--fill-secondary)]",children:[(0,p.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,p.jsx)("polyline",{points:"6 9 12 15 18 9"})}),"New messages"]}),(0,p.jsx)("style",{children:`
|
|
2
|
-
@keyframes jinn-pulse {
|
|
3
|
-
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
4
|
-
40% { opacity: 1; transform: scale(1); }
|
|
5
|
-
}
|
|
6
|
-
.assistant-msg-bubble { max-width: 100%; overflow-wrap: break-word; word-break: break-word; }
|
|
7
|
-
.user-msg-bubble { max-width: 90%; overflow-wrap: break-word; word-break: break-word; }
|
|
8
|
-
.notification-msg-bubble { overflow-wrap: break-word; word-break: break-word; }
|
|
9
|
-
.assistant-msg-row { padding: 0 var(--space-2) !important; }
|
|
10
|
-
@media (min-width: 1024px) {
|
|
11
|
-
.assistant-msg-bubble { max-width: 75%; }
|
|
12
|
-
.user-msg-bubble { max-width: 75%; }
|
|
13
|
-
.assistant-msg-row { padding: 0 var(--space-4) !important; }
|
|
14
|
-
}
|
|
15
|
-
/* User message contrast fixes — ensure all child elements are visible on accent background */
|
|
16
|
-
.user-msg-bubble code {
|
|
17
|
-
background: rgba(255,255,255,0.2) !important;
|
|
18
|
-
border-color: rgba(255,255,255,0.3) !important;
|
|
19
|
-
color: inherit !important;
|
|
20
|
-
}
|
|
21
|
-
.user-msg-bubble .code-block,
|
|
22
|
-
.user-msg-bubble pre {
|
|
23
|
-
background: rgba(0,0,0,0.2) !important;
|
|
24
|
-
border-color: rgba(255,255,255,0.15) !important;
|
|
25
|
-
color: rgba(255,255,255,0.95) !important;
|
|
26
|
-
}
|
|
27
|
-
.user-msg-bubble a {
|
|
28
|
-
color: inherit !important;
|
|
29
|
-
text-decoration-color: rgba(255,255,255,0.6) !important;
|
|
30
|
-
}
|
|
31
|
-
.user-msg-bubble strong { color: inherit !important; }
|
|
32
|
-
.user-msg-bubble em { color: inherit !important; opacity: 0.9; }
|
|
33
|
-
.user-msg-bubble span { color: inherit !important; }
|
|
34
|
-
.user-msg-bubble div { color: inherit !important; }
|
|
35
|
-
.user-msg-bubble th, .user-msg-bubble td { color: inherit !important; }
|
|
36
|
-
.user-msg-bubble table { border-color: rgba(255,255,255,0.2) !important; }
|
|
37
|
-
.user-msg-bubble th { border-color: rgba(255,255,255,0.2) !important; }
|
|
38
|
-
.user-msg-bubble td { border-color: rgba(255,255,255,0.15) !important; }
|
|
39
|
-
.user-msg-bubble tr { background: transparent !important; }
|
|
40
|
-
.user-msg-bubble thead tr { background: rgba(255,255,255,0.1) !important; }
|
|
41
|
-
/* Selection visibility for user messages */
|
|
42
|
-
.user-msg-bubble ::selection {
|
|
43
|
-
background: rgba(255,255,255,0.35);
|
|
44
|
-
color: inherit;
|
|
45
|
-
}
|
|
46
|
-
.user-msg-bubble ::-moz-selection {
|
|
47
|
-
background: rgba(255,255,255,0.35);
|
|
48
|
-
color: inherit;
|
|
49
|
-
}
|
|
50
|
-
`})]}):(0,p.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,p.jsxs)("div",{className:"text-center",children:[(0,p.jsx)("div",{className:"text-[length:var(--text-title3)] font-[var(--weight-semibold)] text-[var(--text-tertiary)]",children:"Start a conversation"}),(0,p.jsx)("div",{className:"text-[length:var(--text-footnote)] text-[var(--text-quaternary)] mt-[var(--space-2)]",children:"Send a message or use /new to begin"})]})})}function re({attachments:e,onRemove:i}){return 0===e.length?null:(0,p.jsx)("div",{style:{display:"flex",gap:"var(--space-2)",padding:"var(--space-2) var(--space-3)",overflowX:"auto",overflowY:"hidden"},children:e.map((e,s)=>(0,p.jsxs)("div",{style:{position:"relative",width:56,height:56,flexShrink:0,borderRadius:"var(--radius-sm)",overflow:"hidden",background:"var(--fill-tertiary)",border:"1px solid var(--separator)"},children:["image"===e.type?(0,p.jsx)("img",{src:e.url,alt:e.name||"Preview",style:{width:"100%",height:"100%",objectFit:"cover"}}):(0,p.jsxs)("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,padding:4},children:["audio"===e.type?(0,p.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M9 18V5l12-2v13"}),(0,p.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,p.jsx)("circle",{cx:"18",cy:"16",r:"3"})]}):(0,p.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,p.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),(0,p.jsx)("span",{style:{fontSize:8,color:"var(--text-quaternary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%",textAlign:"center"},children:e.name?.split(".").pop()?.toUpperCase()||e.type.toUpperCase()})]}),(0,p.jsx)("button",{onClick:()=>i(s),"aria-label":"Remove attachment",style:{position:"absolute",top:2,right:2,width:18,height:18,borderRadius:"50%",background:"rgba(0,0,0,0.6)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:11,lineHeight:1,padding:0},children:(0,p.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[(0,p.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,p.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},s))})}function rt({open:e,progress:i,onDownload:s,onCancel:r}){if(!e)return null;let n=null!==i;return(0,p.jsx)("div",{className:"fixed inset-0 bg-black/50 z-[60] flex items-center justify-center",onClick:n?void 0:r,children:(0,p.jsxs)("div",{className:"bg-[var(--bg)] rounded-[var(--radius-lg)] p-[var(--space-6)] max-w-[400px] w-[90%] shadow-[var(--shadow-overlay)]",onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("div",{className:"w-12 h-12 rounded-[var(--radius-md)] bg-[var(--fill-secondary)] flex items-center justify-center mb-[var(--space-4)]",children:(0,p.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),(0,p.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,p.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),(0,p.jsx)("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}),(0,p.jsx)("h3",{className:"text-[length:var(--text-headline)] font-[var(--weight-bold)] text-[var(--text-primary)] mb-[var(--space-2)]",children:"Enable voice input?"}),(0,p.jsx)("p",{className:"text-[length:var(--text-body)] text-[var(--text-secondary)] mb-[var(--space-5)] leading-[var(--leading-relaxed)]",children:"This will download a speech recognition model (~500MB). Transcription runs locally on your server — no data leaves your network."}),n&&(0,p.jsxs)("div",{className:"mb-[var(--space-5)]",children:[(0,p.jsxs)("div",{className:"flex justify-between mb-[var(--space-2)] text-[length:var(--text-footnote)] text-[var(--text-tertiary)]",children:[(0,p.jsx)("span",{children:"Downloading model…"}),(0,p.jsxs)("span",{children:[i,"%"]})]}),(0,p.jsx)("div",{className:"h-1.5 rounded-[3px] bg-[var(--fill-tertiary)] overflow-hidden",children:(0,p.jsx)("div",{className:"h-full rounded-[3px] bg-[var(--accent)] transition-[width] duration-300 ease-in-out",style:{width:`${i}%`}})})]}),(0,p.jsxs)("div",{className:"flex gap-[var(--space-3)] justify-end",children:[!n&&(0,p.jsx)("button",{onClick:r,className:"px-[var(--space-4)] py-[var(--space-2)] rounded-[var(--radius-md)] bg-[var(--fill-tertiary)] text-[var(--text-primary)] border-none cursor-pointer text-[length:var(--text-body)]",children:"Cancel"}),(0,p.jsx)("button",{onClick:s,disabled:n,className:`px-[var(--space-4)] py-[var(--space-2)] rounded-[var(--radius-md)] border-none text-[length:var(--text-body)] font-[var(--weight-semibold)] ${n?"bg-[var(--fill-tertiary)] text-[var(--text-tertiary)] cursor-default":"bg-[var(--accent)] text-black cursor-pointer"}`,children:n?"Downloading…":"Download"})]})]})})}function ri({analyser:e,width:i=64,height:s=32,color:r="var(--system-red)"}){let n=(0,g.useRef)(null),o=(0,g.useRef)(0);return(0,g.useEffect)(()=>{let a=n.current;if(!a||!e)return;let l=a.getContext("2d");if(!l)return;let h=e.frequencyBinCount,c=new Uint8Array(h),d=(i-22)/12;return!function n(){o.current=requestAnimationFrame(n),e.getByteFrequencyData(c),l.clearRect(0,0,i,s);for(let e=0;e<12;e++){let i=Math.max(3,c[Math.floor(e/12*(.6*h))]/255*s),n=e*(d+2),o=(s-i)/2;l.fillStyle=r,l.beginPath(),l.roundRect(n,o,d,i,1.5),l.fill()}}(),()=>{cancelAnimationFrame(o.current)}},[e,i,s,r]),(0,p.jsx)("canvas",{ref:n,width:i,height:s,style:{width:i,height:s,display:"block"}})}let rs=[{name:"new",description:"Start a new chat session"},{name:"status",description:"Show current session info"}];async function rr(e){let i,s=e.type.startsWith("image/"),r=e.type.startsWith("audio/");if(s)i=await new Promise((i,s)=>{let r=new Image,n=URL.createObjectURL(e);r.onload=()=>{URL.revokeObjectURL(n);let{width:o,height:a}=r;if(o>1200||a>1200){let e=1200/Math.max(o,a);o=Math.round(o*e),a=Math.round(a*e)}let l=document.createElement("canvas");l.width=o,l.height=a;let h=l.getContext("2d");if(!h)return void s(Error("no canvas context"));h.drawImage(r,0,0,o,a);let c=e.size>5e4?"image/jpeg":"image/png";i(l.toDataURL(c,"image/jpeg"===c?.85:void 0))},r.onerror=()=>{URL.revokeObjectURL(n),s(Error("image load failed"))},r.src=n});else i=await new Promise((i,s)=>{let r=new FileReader;r.onloadend=()=>i(r.result),r.onerror=s,r.readAsDataURL(e)});return{type:s?"image":r?"audio":"file",url:i,name:e.name,mimeType:e.type,size:e.size,file:e}}function rn({disabled:e,loading:i,onSend:s,onInterrupt:r,onNewSession:n,onStatusRequest:o,skillsVersion:a,events:l,droppedFiles:h,onDroppedFilesConsumed:c,focusTrigger:d,onShortcutsClick:u}){let[f,_]=(0,g.useState)(""),[m,b]=(0,g.useState)([]),[x,S]=(0,g.useState)(!1),[y,w]=(0,g.useState)(""),[C,k]=(0,g.useState)(0),[E,M]=(0,g.useState)(rs),[D,R]=(0,g.useState)(!1),[B,P]=(0,g.useState)(""),[T,N]=(0,g.useState)(0),[I,j]=(0,g.useState)([]),A=(0,g.useRef)(null),O=(0,g.useRef)(null);(0,g.useEffect)(()=>{d&&d>0&&A.current?.focus()},[d]);let H=(0,g.useRef)(new Map),z=function(e,i){let[s,r]=(0,g.useState)("idle"),[n,o]=(0,g.useState)(null),[a,l]=(0,g.useState)(null),[h,c]=(0,g.useState)(null),[d,u]=(0,g.useState)(["en"]),[f,_]=(0,g.useState)(null),[p,m]=(0,g.useState)(()=>localStorage.getItem("stt-language")||"en"),b=(0,g.useRef)(p);b.current=p;let x=(0,g.useRef)(null),S=(0,g.useRef)(null),y=(0,g.useRef)(null),w=(0,g.useRef)([]),C=(0,g.useRef)(null),k=(0,g.useRef)(null),E=(0,g.useRef)(i);E.current=i,(0,g.useEffect)(()=>{if(!e||0===e.length)return;let i=e[e.length-1];if(!i.event.startsWith("stt:"))return;let s=i.payload;"stt:download:progress"===i.event&&l(Number(s.progress)||0),"stt:download:complete"===i.event&&(l(null),o(!0),r("idle")),"stt:download:error"===i.event&&(l(null),r("idle"))},[e]);let M=(0,g.useCallback)(()=>{y.current?.getTracks().forEach(e=>e.stop()),y.current=null,S.current?.close().catch(()=>{}),S.current=null,c(null),x.current=null},[]);(0,g.useEffect)(()=>()=>{C.current&&clearTimeout(C.current),x.current?.state==="recording"&&x.current.stop(),y.current?.getTracks().forEach(e=>e.stop()),S.current?.close().catch(()=>{})},[]);let D=(0,g.useCallback)(async()=>{try{let e=await v.api.sttStatus();return o(e.available),e.downloading&&l(e.progress),e.languages?.length>0&&(u(e.languages),m(i=>{if(!e.languages.includes(i)){let i=e.languages[0];return localStorage.setItem("stt-language",i),i}return i})),e.available}catch{return o(!1),!1}},[]),R=(0,g.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});y.current=e;let i=new AudioContext;S.current=i;let s=i.createMediaStreamSource(e),n=i.createAnalyser();n.fftSize=128,s.connect(n),c(n);let o=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":MediaRecorder.isTypeSupported("audio/mp4")?"audio/mp4":"",a=new MediaRecorder(e,o?{mimeType:o}:void 0);x.current=a,w.current=[],a.ondataavailable=e=>{e.data.size>0&&w.current.push(e.data)},a.onstop=async()=>{M(),r("transcribing");let e=new Blob(w.current,{type:a.mimeType||"audio/webm"});if(w.current=[],0===e.size){r("idle"),k.current?.(null),k.current=null;return}try{let i=(await v.api.sttTranscribe(e,b.current)).text||null;r("idle"),_(null),k.current?(k.current(i),k.current=null):i&&E.current&&E.current(i)}catch(i){let e=i instanceof Error?i.message:"Transcription failed";_(e),r("error"),k.current&&(k.current(null),k.current=null)}},a.start(5e3),r("recording"),C.current=setTimeout(()=>{x.current?.state==="recording"&&x.current.stop()},18e5)}catch{M(),r("idle")}},[M]),L=(0,g.useCallback)(async()=>{"recording"===s||"transcribing"===s||("error"===s&&(_(null),r("idle")),await D()?await R():r("no-model"))},[s,D,R]),B=(0,g.useCallback)(async()=>{await R()},[R]),P=(0,g.useCallback)(async()=>x.current&&"inactive"!==x.current.state?(C.current&&(clearTimeout(C.current),C.current=null),new Promise(e=>{k.current=e,x.current?.state==="recording"?x.current.stop():(M(),r("idle"),k.current=null,e(null))})):(r("idle"),null),[M]),T=(0,g.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null),x.current?.state==="recording"&&x.current.stop(),M(),w.current=[],r("idle")},[M]),N=(0,g.useCallback)(()=>{l(0),v.api.sttDownload().catch(()=>{l(null)})},[]),I=(0,g.useCallback)(()=>{r("idle"),l(null)},[]),j=(0,g.useCallback)(()=>{r("idle"),_(null)},[]),A=(0,g.useCallback)(()=>{m(e=>{let i=d.indexOf(e),s=d[(i+1)%d.length];return localStorage.setItem("stt-language",s),s})},[d]);return{state:s,available:n,downloadProgress:a,analyser:h,languages:d,selectedLanguage:p,error:f,cycleLanguage:A,handleMicClick:L,startRecording:B,stopRecording:P,cancelRecording:T,startDownload:N,dismissDownload:I,dismissError:j}}(l,e=>{e&&_(i=>i?i+" "+e:e)}),W=(0,g.useRef)(void 0);(0,g.useEffect)(()=>{h&&0!==h.length&&W.current!==h&&(W.current=h,(async()=>{let e=[];for(let i of h)e.push(await rr(i));j(i=>[...i,...e]),c?.()})())},[h,c]),(0,g.useEffect)(()=>{v.api.getOrg().then(e=>{Array.isArray(e.employees)&&b(e.employees.map(e=>({name:e.name,displayName:e.displayName,department:e.department,rank:e.rank,engine:e.engine})))}).catch(()=>{})},[]),(0,g.useEffect)(()=>{v.api.getSkills().then(e=>{if(!Array.isArray(e))return;let i=e.filter(e=>!rs.some(i=>i.name===e.name)).map(e=>({name:e.name,description:e.description||"",needsEmployee:"sync"===e.name}));M([...rs,...i])}).catch(()=>{})},[a]);let F=(0,g.useCallback)(e=>{let i=f.lastIndexOf("@");-1!==i&&_(f.slice(0,i)+"@"+e+" "),S(!1),A.current?.focus()},[f]),$=(0,g.useCallback)(e=>{e.needsEmployee?(_("/"+e.name+" @"),R(!1),w(""),k(0),S(!0)):(_("/"+e.name),R(!1)),A.current?.focus()},[]);function K(){let i=f.trim(),r=I.length>0;if(!i&&!r||e)return;if("/new"===i){_(""),n();return}if("/status"===i){_(""),o();return}let a=r?[...I]:void 0;_(""),j([]),S(!1),R(!1),A.current&&(A.current.style.height="auto"),s(i,a,!1)}async function U(e){let i=e.target.files;if(!i||0===i.length)return;let s=[];for(let e=0;e<i.length;e++)s.push(await rr(i[e]));j(e=>[...e,...s]),e.target.value=""}async function q(e){let i=e.clipboardData?.items;if(i){for(let s=0;s<i.length;s++)if(i[s].type.startsWith("image/")){e.preventDefault();let r=i[s].getAsFile();if(r){let e=await rr(r);j(i=>[...i,e])}return}}}let V=(0,g.useCallback)(e=>{e&&_(i=>i?i+" "+e:e)},[]);async function Y(){"recording"===z.state?(V(await z.stopRecording()??""),A.current?.focus()):"transcribing"===z.state||z.handleMicClick()}(0,g.useEffect)(()=>{A.current&&(A.current.style.height="auto",A.current.style.height=Math.min(A.current.scrollHeight,120)+"px")},[f]);let X=E.filter(e=>e.name?.toLowerCase().startsWith(B)),G=m.filter(e=>e.name?.toLowerCase().includes(y)),J=f.trim().length>0||I.length>0;return(0,p.jsxs)("div",{className:"px-3 sm:px-4 pt-[var(--space-3)] pb-[var(--space-3)] border-t border-t-[var(--separator)] bg-[var(--material-regular)] shrink-0 relative",children:[D&&X.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-[var(--space-4)] right-[var(--space-4)] mb-1 bg-[var(--bg)] border border-[var(--separator)] rounded-[var(--radius-md)] shadow-[var(--shadow-lg)] max-h-60 overflow-y-auto z-10",children:X.map((e,i)=>{let s=i===T;return(0,p.jsxs)("button",{ref:e=>{s&&e&&e.scrollIntoView({block:"nearest"})},onClick:()=>$(e),className:`w-full text-left py-[var(--space-2)] px-[var(--space-3)] text-[length:var(--text-footnote)] ${s?"bg-[var(--fill-secondary)]":"bg-transparent"} border-none cursor-pointer flex items-center gap-[var(--space-2)] text-[var(--text-primary)]`,children:[(0,p.jsxs)("span",{className:"font-[family-name:var(--font-mono)] font-[var(--weight-semibold)] text-[var(--accent)] text-[length:var(--text-footnote)]",children:["/",e.name]}),(0,p.jsx)("span",{className:"text-[var(--text-tertiary)] text-[length:var(--text-caption1)]",children:e.description})]},e.name)})}),x&&G.length>0&&(0,p.jsx)("div",{className:"absolute bottom-full left-[var(--space-4)] right-[var(--space-4)] mb-1 bg-[var(--bg)] border border-[var(--separator)] rounded-[var(--radius-md)] shadow-[var(--shadow-lg)] max-h-40 overflow-y-auto z-10",children:G.slice(0,8).map((e,i)=>{let s=i===C;return(0,p.jsxs)("button",{ref:e=>{e?H.current.set(i,e):H.current.delete(i),s&&e&&e.scrollIntoView({block:"nearest"})},onClick:()=>F(e.name),className:`w-full text-left py-[var(--space-2)] px-[var(--space-3)] text-[length:var(--text-footnote)] ${s?"bg-[var(--fill-secondary)]":"bg-transparent"} border-none cursor-pointer flex items-center gap-[var(--space-2)] text-[var(--text-primary)]`,children:[(0,p.jsx)(L.EmployeeAvatar,{name:e.name,size:20}),(0,p.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,p.jsxs)("div",{className:"flex items-center gap-[var(--space-2)]",children:[(0,p.jsx)("span",{className:"font-[var(--weight-semibold)]",children:e.displayName||e.name}),(0,p.jsxs)("span",{className:"font-[family-name:var(--font-mono)] text-[length:var(--text-caption2)] text-[var(--text-tertiary)]",children:["@",e.name]})]}),e.department&&(0,p.jsxs)("div",{className:"text-[length:var(--text-caption2)] text-[var(--text-quaternary)] flex gap-[var(--space-2)] mt-px",children:[(0,p.jsx)("span",{children:e.department}),e.engine&&(0,p.jsx)("span",{className:"text-[var(--accent)] font-[var(--weight-medium)]",children:e.engine})]})]})]},e.name)})}),I.length>0&&(0,p.jsx)("div",{className:"mb-[var(--space-2)]",children:(0,p.jsx)(re,{attachments:I,onRemove:function(e){j(i=>i.filter((i,s)=>s!==e))}})}),(0,p.jsxs)("div",{className:`flex items-center gap-[var(--space-2)] bg-[var(--fill-secondary)] rounded-[var(--radius-lg)] py-1.5 px-[var(--space-3)] min-h-11 transition-[border-color] duration-200 ease-in-out border ${i?"border-[var(--accent)]":"border-[var(--separator)]"}`,children:[(0,p.jsx)("button",{"aria-label":"Attach file",onClick:()=>O.current?.click(),className:"w-8 h-8 shrink-0 rounded-[var(--radius-sm)] flex items-center justify-center bg-transparent border-none cursor-pointer text-[var(--text-secondary)] mb-0",children:(0,p.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,p.jsx)("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}),(0,p.jsx)("input",{ref:O,type:"file",accept:"image/*,audio/*,.pdf,.doc,.docx,.txt,.csv,.json,.zip",multiple:!0,className:"hidden",onChange:U}),(0,p.jsx)("textarea",{id:"chat-textarea",ref:A,value:f,onChange:function(e){let i=e.target.value;if(_(i),i.startsWith("/")&&!i.includes(" ")){P(i.slice(1).toLowerCase()),N(0),R(!0),S(!1);return}R(!1);let s=i.lastIndexOf("@");if(-1!==s){let e=i.slice(s+1);if(!e.includes(" ")&&!e.includes("\n")){w(e.toLowerCase()),k(0),S(!0);return}}S(!1)},onKeyDown:function(e){if(!e.nativeEvent.isComposing&&229!==e.keyCode){if(D&&X.length>0){let i=X.length;if("ArrowDown"===e.key){e.preventDefault(),N(e=>(e+1)%i);return}if("ArrowUp"===e.key){e.preventDefault(),N(e=>(e-1+i)%i);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),$(X[T]);return}if("Escape"===e.key){e.preventDefault(),R(!1);return}}if(x&&G.length>0){let i=Math.min(G.length,8);if("ArrowDown"===e.key){e.preventDefault(),k(e=>(e+1)%i);return}if("ArrowUp"===e.key){e.preventDefault(),k(e=>(e-1+i)%i);return}if("Tab"===e.key||"Enter"===e.key){e.preventDefault(),F(G[C].name);return}if("Escape"===e.key){e.preventDefault(),S(!1);return}}"Enter"!==e.key||e.shiftKey||(e.preventDefault(),K())}},onPaste:q,placeholder:e?"Waiting for response...":"Type a message...",rows:1,disabled:e,className:`flex-1 bg-transparent border-none outline-none resize-none text-[var(--text-primary)] text-[length:var(--text-subheadline)] leading-5 max-h-30 min-h-5 h-5 p-0 m-0 ${e?"opacity-50":"opacity-100"}`,onInput:e=>{let i=e.target;i.style.height="auto",i.style.height=Math.min(i.scrollHeight,120)+"px"}}),z.languages.length>1&&(0,p.jsx)("button",{"aria-label":`STT language: ${z.selectedLanguage.toUpperCase()}. Click to switch.`,onClick:z.cycleLanguage,className:"h-6 px-1.5 shrink-0 rounded-[var(--radius-sm)] flex items-center justify-center bg-[var(--fill-tertiary)] border-none cursor-pointer text-[var(--text-secondary)] text-[11px] font-semibold font-[family-name:var(--font-mono)] tracking-[0.5px] uppercase transition-all duration-150 ease-in-out",title:`Transcription language: ${z.selectedLanguage.toUpperCase()}. Click to cycle.`,children:z.selectedLanguage}),(0,p.jsx)("button",{"aria-label":"recording"===z.state?"Stop recording":"transcribing"===z.state?"Transcribing…":"Voice input",onClick:Y,disabled:"transcribing"===z.state,className:`w-8 h-8 shrink-0 flex items-center justify-center border-none transition-all duration-150 ease-in-out ${"recording"===z.state?"rounded-full bg-[var(--system-red)] text-white cursor-pointer":`rounded-[var(--radius-sm)] bg-transparent text-[var(--text-secondary)] ${"transcribing"===z.state?"cursor-wait":"cursor-pointer"}`}`,title:"recording"===z.state?"Stop recording":"transcribing"===z.state?"Transcribing…":"Voice input",children:"transcribing"===z.state?(0,p.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"animate-[stt-spin_1s_linear_infinite]",children:(0,p.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})}):(0,p.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),(0,p.jsx)("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),(0,p.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),(0,p.jsx)("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}),"recording"===z.state&&z.analyser&&(0,p.jsx)(ri,{analyser:z.analyser,width:64,height:28}),i&&r&&(0,p.jsx)("button",{onClick:r,"aria-label":"Stop",className:"w-8 h-8 rounded-full bg-[var(--system-red)] text-white border-none cursor-pointer flex items-center justify-center shrink-0 transition-all duration-150 ease-in-out",children:(0,p.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:(0,p.jsx)("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),(0,p.jsx)("button",{onClick:K,disabled:!J||e,"aria-label":"Send message",className:`w-8 h-8 rounded-full border-none flex items-center justify-center shrink-0 transition-all duration-150 ease-in-out ${J?"bg-[var(--accent)] text-[var(--accent-contrast)] cursor-pointer":"bg-[var(--fill-tertiary)] text-[var(--text-quaternary)] cursor-default"}`,children:(0,p.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),(0,p.jsx)("polyline",{points:"5 12 12 5 19 12"})]})})]}),(0,p.jsxs)("div",{className:"hidden sm:flex text-[length:var(--text-caption2)] text-[var(--text-quaternary)] text-center mt-[var(--space-1)] justify-center gap-[var(--space-3)]",children:[(0,p.jsx)("span",{children:"Enter to send"}),(0,p.jsx)("span",{children:"/ - commands"}),(0,p.jsx)("span",{children:"@name - mention"}),u&&(0,p.jsxs)("button",{onClick:u,className:"flex items-center gap-1 text-[length:var(--text-caption2)] text-[var(--text-quaternary)] hover:text-[var(--text-tertiary)] transition-colors bg-transparent border-none cursor-pointer p-0 font-[inherit]",children:[(0,p.jsx)("kbd",{className:"rounded bg-[var(--fill-tertiary)] px-1 py-0.5 font-mono text-[10px] leading-none",children:"?"}),(0,p.jsx)("span",{children:"shortcuts"})]})]}),"error"===z.state&&z.error&&(0,p.jsxs)("div",{className:"flex items-center gap-[var(--space-2)] mt-[var(--space-2)] py-[var(--space-2)] px-[var(--space-3)] rounded-[var(--radius-sm)] text-[length:var(--text-caption1)] text-[var(--system-red)]",style:{background:"color-mix(in srgb, var(--system-red) 12%, transparent)"},children:[(0,p.jsxs)("span",{className:"flex-1",children:["Voice input error: ",z.error]}),(0,p.jsx)("button",{onClick:z.dismissError,className:"bg-none border-none cursor-pointer text-[var(--system-red)] text-[length:var(--text-caption1)] font-semibold py-0.5 px-1.5",children:"Dismiss"})]}),(0,p.jsx)(rt,{open:"no-model"===z.state,progress:z.downloadProgress,onDownload:z.startDownload,onCancel:z.dismissDownload}),(0,p.jsx)("style",{children:`
|
|
51
|
-
@keyframes stt-spin {
|
|
52
|
-
from { transform: rotate(0deg); }
|
|
53
|
-
to { transform: rotate(360deg); }
|
|
54
|
-
}
|
|
55
|
-
`})]})}let ro={executive:"Exec",manager:"Mgr",senior:"Sr",employee:""};function ra({employees:e,selectedEmployee:i,onSelect:s,portalName:r}){let[n,o]=(0,g.useState)(""),[a,l]=(0,g.useState)(-1),h=(0,g.useRef)(null),c=(0,g.useRef)(null),d=(0,g.useMemo)(()=>{if(!n.trim())return e;let i=n.toLowerCase();return e.filter(e=>e.name?.toLowerCase().includes(i)||e.displayName?.toLowerCase().includes(i)||e.department?.toLowerCase().includes(i))},[e,n]),u=(0,g.useMemo)(()=>{let e=new Map;for(let i of d){let s=i.department||"other";e.has(s)||e.set(s,[]),e.get(s).push(i)}return e},[d]),f=(0,g.useMemo)(()=>{let e=[];for(let i of u.values())e.push(...i);return e},[u]);(0,g.useEffect)(()=>{l(-1)},[n]),(0,g.useEffect)(()=>{if(!h.current)return;let e=h.current.querySelectorAll("[data-picker-option]")[a+1];e&&"function"==typeof e.scrollIntoView&&e.scrollIntoView({block:"nearest"})},[a]);let _=(0,g.useCallback)(e=>{"ArrowDown"===e.key?(e.preventDefault(),l(e=>Math.min(e+1,f.length-1))):"ArrowUp"===e.key?(e.preventDefault(),l(e=>Math.max(e-1,-1))):"Enter"===e.key&&(e.preventDefault(),-1===a?s(null):f[a]&&s(f[a].name))},[a,f,s]);return(0,p.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 w-full max-w-md mx-auto",children:[(0,p.jsx)("p",{className:"text-sm text-[var(--text-secondary)]",children:"Who do you want to talk to?"}),(0,p.jsx)("div",{className:"w-full",children:(0,p.jsx)("input",{ref:c,type:"text",placeholder:"Search employees...",value:n,onChange:e=>o(e.target.value),className:"w-full py-2 px-3 text-[length:var(--text-footnote)] border border-[var(--separator)] rounded-[var(--radius-md)] bg-[var(--fill-tertiary)] text-[var(--text-primary)] outline-none font-[inherit] placeholder:text-[var(--text-tertiary)]"})}),(0,p.jsxs)("div",{ref:h,role:"listbox",tabIndex:0,onKeyDown:_,className:"w-full max-h-[360px] overflow-y-auto rounded-[var(--radius-md)] border border-[var(--separator)] bg-[var(--fill-quaternary)]",children:[(0,p.jsxs)("div",{role:"option","aria-selected":null===i,"aria-label":r,"data-picker-option":!0,onClick:()=>s(null),onMouseEnter:()=>l(-1),className:(0,i3.cn)("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors border-b border-[var(--separator)]",-1===a&&"bg-[var(--fill-secondary)]",null===i?"bg-[color-mix(in_srgb,var(--accent)_8%,transparent)]":""),children:[(0,p.jsx)("span",{className:"text-xl shrink-0",children:"🧞"}),(0,p.jsx)("div",{className:"flex-1 min-w-0",children:(0,p.jsx)("span",{className:"text-[length:var(--text-footnote)] font-[var(--weight-semibold)] text-[var(--text-primary)]",children:r})}),(0,p.jsx)("span",{className:"text-[length:var(--text-caption2)] text-[var(--accent)] bg-[color-mix(in_srgb,var(--accent)_12%,transparent)] rounded-[var(--radius-sm)] px-1.5 py-px font-[var(--weight-medium)] shrink-0",children:"COO"})]}),Array.from(u.entries()).map(([e,r])=>(0,p.jsxs)("div",{children:[(0,p.jsx)("div",{className:"px-3 py-1.5 text-[length:var(--text-caption2)] font-[var(--weight-semibold)] text-[var(--text-tertiary)] uppercase tracking-wider bg-[var(--fill-tertiary)]",children:e}),r.map(e=>{let r=f.indexOf(e),n=i===e.name,o=a===r;return(0,p.jsxs)("div",{role:"option","aria-selected":n,"data-picker-option":!0,onClick:()=>s(e.name),onMouseEnter:()=>l(r),className:(0,i3.cn)("flex items-center gap-3 px-3 py-2 cursor-pointer transition-colors",o&&"bg-[var(--fill-secondary)]",n&&"bg-[color-mix(in_srgb,var(--accent)_8%,transparent)]"),children:[(0,p.jsx)(L.EmployeeAvatar,{name:e.name,size:28}),(0,p.jsx)("div",{className:"flex-1 min-w-0",children:(0,p.jsx)("span",{className:"text-[length:var(--text-footnote)] font-[var(--weight-medium)] text-[var(--text-primary)] overflow-hidden text-ellipsis whitespace-nowrap block",children:e.displayName})}),ro[e.rank]&&(0,p.jsx)("span",{className:"text-[length:var(--text-caption2)] text-[var(--text-tertiary)] bg-[var(--fill-secondary)] rounded-[var(--radius-sm)] px-1.5 py-px shrink-0",children:ro[e.rank]}),n&&(0,p.jsx)("span",{className:"text-[var(--accent)] text-[13px] shrink-0",children:"✓"})]},e.name)})]},e)),0===d.length&&(0,p.jsxs)("div",{className:"p-4 text-center text-[length:var(--text-footnote)] text-[var(--text-tertiary)]",children:["No employees match “",n,"”"]})]})]})}let rl=(0,y.default)("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);var rh=e.i(39331),rc=e.i(77053);function rd({sessionId:e,events:i,paused:s=!1}){let[r,n]=(0,g.useState)([]),[o,a]=(0,g.useState)(s),l=(0,g.useCallback)(async()=>{if(e)try{let i=await v.api.getSessionQueue(e);n(i)}catch{}},[e]);(0,g.useEffect)(()=>{l()},[l]),(0,g.useEffect)(()=>{if(!i.length)return;let e=i[i.length-1];if("queue:updated"===e.event){l();let i=e.payload;"boolean"==typeof i?.paused&&a(i.paused)}},[i,l]);let h=r.filter(e=>"pending"===e.status);if(!e||0===h.length)return null;async function c(i){if(e)try{await v.api.cancelQueueItem(e,i),await l()}catch{}}async function d(){if(e)try{await v.api.clearSessionQueue(e),n([])}catch{}}async function u(){if(e)try{o?(await v.api.resumeSessionQueue(e),a(!1)):(await v.api.pauseSessionQueue(e),a(!0))}catch{}}return(0,p.jsxs)("div",{className:"border-t border-[var(--separator)] px-[var(--space-4)] py-[var(--space-2)] bg-[var(--fill-quaternary)] shrink-0",children:[(0,p.jsxs)("div",{className:"flex items-center justify-between mb-[var(--space-1)]",children:[(0,p.jsxs)("span",{className:"text-[length:var(--text-caption2)] font-semibold text-[var(--text-secondary)] uppercase tracking-[0.5px]",children:[h.length," queued ",o&&"· Paused"]}),(0,p.jsxs)("div",{className:"flex gap-[var(--space-1)]",children:[(0,p.jsx)("button",{onClick:u,title:o?"Resume queue":"Pause queue",className:"bg-transparent border-none cursor-pointer text-[var(--text-secondary)] p-0.5 flex items-center",children:o?(0,p.jsx)(rh.Play,{size:13}):(0,p.jsx)(rl,{size:13})}),(0,p.jsx)("button",{onClick:d,title:"Clear all queued messages",className:"bg-transparent border-none cursor-pointer text-[var(--text-secondary)] p-0.5 flex items-center",children:(0,p.jsx)(rc.Trash2,{size:13})})]})]}),(0,p.jsx)("div",{className:"flex flex-col gap-0.5",children:h.map(e=>(0,p.jsxs)("div",{className:"flex items-center gap-[var(--space-2)] px-[var(--space-2)] py-[3px] rounded-[var(--radius-sm)] bg-[var(--fill-tertiary)]",children:[(0,p.jsxs)("span",{className:"text-[length:var(--text-caption2)] text-[var(--text-tertiary)] min-w-4",children:[e.position,"."]}),(0,p.jsx)("span",{className:"flex-1 text-[length:var(--text-caption1)] text-[var(--text-secondary)] overflow-hidden text-ellipsis whitespace-nowrap",children:e.prompt.length>60?e.prompt.slice(0,57)+"...":e.prompt}),(0,p.jsx)("button",{onClick:()=>c(e.id),title:"Cancel this message",className:"bg-transparent border-none cursor-pointer text-[var(--text-tertiary)] p-px flex items-center shrink-0",children:(0,p.jsx)(R.X,{size:11})})]},e.id))})]})}function ru({input:e}){let[i,s]=(0,g.useState)(!1),r=JSON.stringify(e,null,2);return r.length>300?(0,p.jsxs)("div",{children:[(0,p.jsx)("button",{onClick:()=>s(e=>!e),className:"mt-1 px-2 py-0.5 text-[11px] rounded bg-white/[0.08] border border-white/[0.12] text-[var(--text-tertiary)] cursor-pointer font-[SF_Mono,Menlo,Cascadia_Code,monospace]",children:i?"collapse input":`show input (${r.length} chars)`}),i&&(0,p.jsx)("pre",{className:"mt-1 px-2.5 py-1.5 bg-white/5 rounded text-xs leading-normal whitespace-pre-wrap break-all text-[var(--text-secondary)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] overflow-x-auto max-h-[400px] overflow-y-auto",children:r})]}):(0,p.jsx)("pre",{className:"mt-1 px-2.5 py-1.5 bg-white/5 rounded text-xs leading-normal whitespace-pre-wrap break-all text-[var(--text-secondary)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] overflow-x-auto",children:r})}function rf({text:e}){let[i,s]=(0,g.useState)(!1);return(0,p.jsxs)("div",{className:"mb-1.5",children:[(0,p.jsx)("button",{onClick:()=>s(e=>!e),className:"px-2 py-0.5 text-[11px] rounded bg-white/[0.06] border border-white/10 text-[var(--text-quaternary,var(--text-tertiary))] cursor-pointer font-[SF_Mono,Menlo,Cascadia_Code,monospace] italic",children:i?"hide thinking":"show thinking"}),i&&(0,p.jsx)("div",{className:"mt-1 px-3 py-2 bg-white/[0.04] border-l-2 border-white/10 text-xs leading-relaxed text-[var(--text-quaternary,var(--text-tertiary))] italic whitespace-pre-wrap break-words font-[SF_Mono,Menlo,Cascadia_Code,monospace]",children:e})]})}function r_({text:e}){let[i,s]=(0,g.useState)(!1);return e.length>500?(0,p.jsxs)("div",{children:[(0,p.jsx)("button",{onClick:()=>s(e=>!e),className:"mt-1 px-2 py-0.5 text-[11px] rounded bg-white/[0.08] border border-white/[0.12] text-[var(--text-tertiary)] cursor-pointer font-[SF_Mono,Menlo,Cascadia_Code,monospace]",children:i?"collapse output":`show output (${e.length} chars)`}),i&&(0,p.jsx)("pre",{className:"mt-1 px-2.5 py-1.5 bg-white/[0.04] rounded text-xs leading-normal whitespace-pre-wrap break-all text-[var(--text-tertiary)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] overflow-x-auto max-h-[400px] overflow-y-auto",children:e})]}):(0,p.jsx)("pre",{className:"mt-1 px-2.5 py-1.5 bg-white/[0.04] rounded text-xs leading-normal whitespace-pre-wrap break-all text-[var(--text-tertiary)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] overflow-x-auto max-h-[300px] overflow-y-auto",children:e||"(empty)"})}function rp({block:e}){return"thinking"===e.type?(0,p.jsx)(rf,{text:e.text||""}):"tool_use"===e.type?(0,p.jsxs)("div",{className:"mb-2 px-2.5 py-1.5 bg-[rgba(99,179,237,0.08)] border border-[rgba(99,179,237,0.2)] rounded-md",children:[(0,p.jsxs)("div",{className:"text-[11px] font-semibold text-[rgba(99,179,237,0.9)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] mb-0.5 uppercase tracking-wide",children:["tool: ",e.name]}),e.input&&Object.keys(e.input).length>0&&(0,p.jsx)(ru,{input:e.input})]}):"tool_result"===e.type?(0,p.jsxs)("div",{className:"mb-2 px-2.5 py-1.5 bg-white/[0.03] border border-white/[0.08] rounded-md",children:[(0,p.jsx)("div",{className:"text-[11px] font-semibold text-[rgba(160,160,160,0.7)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] mb-0.5 uppercase tracking-wide",children:"result"}),(0,p.jsx)(r_,{text:e.text||""})]}):(0,p.jsx)("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[var(--text-primary)] mb-1",children:e.text})}function rg({entry:e}){let i="user"===e.role;return(0,p.jsxs)("div",{className:"flex gap-2.5 py-2.5 border-b border-white/[0.04]",children:[(0,p.jsx)("div",{className:"shrink-0 w-4 text-[13px] font-bold font-[SF_Mono,Menlo,Cascadia_Code,monospace] pt-px",style:{color:i?"var(--accent)":"rgba(110, 231, 183, 0.8)"},children:i?">":"$"}),(0,p.jsx)("div",{className:"flex-1 min-w-0",children:e.content.map((e,i)=>(0,p.jsx)(rp,{block:e},i))})]})}function rm({sessionId:e}){let[i,s]=(0,g.useState)([]),[r,n]=(0,g.useState)(!0),[o,a]=(0,g.useState)(null),l=(0,g.useRef)(null);return((0,g.useEffect)(()=>{e&&(n(!0),a(null),v.api.getSessionTranscript(e).then(e=>{s(e),n(!1)}).catch(e=>{a(e instanceof Error?e.message:"Failed to load transcript"),n(!1)}))},[e]),(0,g.useEffect)(()=>{l.current?.scrollIntoView({behavior:"instant"})},[i]),r)?(0,p.jsx)("div",{className:"flex-1 flex items-center justify-center bg-[var(--bg-primary,var(--bg))] text-[var(--text-tertiary)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] text-[13px]",children:"loading transcript..."}):o?(0,p.jsxs)("div",{className:"flex-1 flex items-center justify-center bg-[var(--bg-primary,var(--bg))] text-[var(--system-red)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] text-[13px]",children:["error: ",o]}):0===i.length?(0,p.jsx)("div",{className:"flex-1 flex items-center justify-center bg-[var(--bg-primary,var(--bg))] text-[var(--text-tertiary)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] text-[13px]",children:"no transcript available"}):(0,p.jsxs)("div",{className:"flex-1 overflow-y-auto overflow-x-hidden bg-[var(--bg-primary,var(--bg))] p-[var(--space-4)] font-[SF_Mono,Menlo,Cascadia_Code,monospace] text-[13px] leading-normal min-h-0",children:[i.map((e,i)=>(0,p.jsx)(rg,{entry:e},i)),(0,p.jsx)("div",{ref:l})]})}var rv=e.i(31791),rb=Object.defineProperty,rx=Object.getOwnPropertyDescriptor,rS=(e,i,s,r)=>{for(var n,o=r>1?void 0:r?rx(i,s):i,a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r?n(i,s,o):n(o))||o);return r&&o&&rb(i,s,o),o},ry=(e,i)=>(s,r)=>i(s,r,e),rw="Terminal input",rC="Too much output to announce, navigate to rows manually to read";function rk(e,i,s,r){var n;n=e=e.replace(/\r?\n/g,"\r"),e=s.decPrivateModes.bracketedPasteMode&&!0!==r.rawOptions.ignoreBracketedPasteMode?"\x1b[200~"+n+"\x1b[201~":n,s.triggerDataEvent(e,!0),i.value=""}function rE(e,i,s){let r=s.getBoundingClientRect(),n=e.clientX-r.left-10,o=e.clientY-r.top-10;i.style.width="20px",i.style.height="20px",i.style.left=`${n}px`,i.style.top=`${o}px`,i.style.zIndex="1000",i.focus()}function rM(e,i,s,r,n){rE(e,i,s),n&&r.rightClickSelect(e),i.value=r.selectionText,i.select()}function rD(e){return e>65535?String.fromCharCode(((e-=65536)>>10)+55296)+String.fromCharCode(e%1024+56320):String.fromCharCode(e)}function rR(e,i=0,s=e.length){let r="";for(let n=i;n<s;++n){let i=e[n];i>65535?(i-=65536,r+=String.fromCharCode((i>>10)+55296)+String.fromCharCode(i%1024+56320)):r+=String.fromCharCode(i)}return r}var rL=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,i){let s=e.length;if(!s)return 0;let r=0,n=0;if(this._interim){let s=e.charCodeAt(n++);56320<=s&&s<=57343?i[r++]=(this._interim-55296)*1024+s-56320+65536:(i[r++]=this._interim,i[r++]=s),this._interim=0}for(let o=n;o<s;++o){let n=e.charCodeAt(o);if(55296<=n&&n<=56319){if(++o>=s)return this._interim=n,r;let a=e.charCodeAt(o);56320<=a&&a<=57343?i[r++]=(n-55296)*1024+a-56320+65536:(i[r++]=n,i[r++]=a);continue}65279!==n&&(i[r++]=n)}return r}},rB=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,i){let s=e.length;if(!s)return 0;let r=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let n=!1,o=this.interim[0];o&=(224&o)==192?31:(240&o)==224?15:7;let a=0,l;for(;(l=63&this.interim[++a])&&a<4;)o<<=6,o|=l;let h=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,d=h-a;for(;c<d;){if(c>=s)return 0;if((192&(l=e[c++]))!=128){c--,n=!0;break}this.interim[a++]=l,o<<=6,o|=63&l}n||(2===h?o<128?c--:i[r++]=o:3===h?o<2048||o>=55296&&o<=57343||65279===o||(i[r++]=o):o<65536||o>1114111||(i[r++]=o)),this.interim.fill(0)}let d=s-4,u=c;for(;u<s;){for(;u<d&&!(128&(n=e[u]))&&!(128&(o=e[u+1]))&&!(128&(a=e[u+2]))&&!(128&(l=e[u+3]));)i[r++]=n,i[r++]=o,i[r++]=a,i[r++]=l,u+=4;if((n=e[u++])<128)i[r++]=n;else if((224&n)==192){if(u>=s)return this.interim[0]=n,r;if((192&(o=e[u++]))!=128||(h=(31&n)<<6|63&o)<128){u--;continue}i[r++]=h}else if((240&n)==224){if(u>=s)return this.interim[0]=n,r;if((192&(o=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,r;if((192&(a=e[u++]))!=128){u--;continue}if((h=(15&n)<<12|(63&o)<<6|63&a)<2048||h>=55296&&h<=57343||65279===h)continue;i[r++]=h}else if((248&n)==240){if(u>=s)return this.interim[0]=n,r;if((192&(o=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,r;if((192&(a=e[u++]))!=128){u--;continue}if(u>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,r;if((192&(l=e[u++]))!=128){u--;continue}if((h=(7&n)<<18|(63&o)<<12|(63&a)<<6|63&l)<65536||h>1114111)continue;i[r++]=h}}return r}},rP=class e{constructor(){this.fg=0,this.bg=0,this.extended=new rT}static toColorRGB(e){return[e>>>16&255,e>>>8&255,255&e]}static fromColorRGB(e){return(255&e[0])<<16|(255&e[1])<<8|255&e[2]}clone(){let i=new e;return i.fg=this.fg,i.bg=this.bg,i.extended=this.extended.clone(),i}isInverse(){return 0x4000000&this.fg}isBold(){return 0x8000000&this.fg}isUnderline(){return this.hasExtendedAttrs()&&0!==this.extended.underlineStyle?1:0x10000000&this.fg}isBlink(){return 0x20000000&this.fg}isInvisible(){return 0x40000000&this.fg}isItalic(){return 0x4000000&this.bg}isDim(){return 0x8000000&this.bg}isStrikethrough(){return 0x80000000&this.fg}isProtected(){return 0x20000000&this.bg}isOverline(){return 0x40000000&this.bg}getFgColorMode(){return 0x3000000&this.fg}getBgColorMode(){return 0x3000000&this.bg}isFgRGB(){return(0x3000000&this.fg)==0x3000000}isBgRGB(){return(0x3000000&this.bg)==0x3000000}isFgPalette(){return(0x3000000&this.fg)==0x1000000||(0x3000000&this.fg)==0x2000000}isBgPalette(){return(0x3000000&this.bg)==0x1000000||(0x3000000&this.bg)==0x2000000}isFgDefault(){return(0x3000000&this.fg)==0}isBgDefault(){return(0x3000000&this.bg)==0}isAttributeDefault(){return 0===this.fg&&0===this.bg}getFgColor(){switch(0x3000000&this.fg){case 0x1000000:case 0x2000000:return 255&this.fg;case 0x3000000:return 0xffffff&this.fg;default:return -1}}getBgColor(){switch(0x3000000&this.bg){case 0x1000000:case 0x2000000:return 255&this.bg;case 0x3000000:return 0xffffff&this.bg;default:return -1}}hasExtendedAttrs(){return 0x10000000&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-0x10000001:this.bg|=0x10000000}getUnderlineColor(){if(0x10000000&this.bg&&~this.extended.underlineColor)switch(0x3000000&this.extended.underlineColor){case 0x1000000:case 0x2000000:return 255&this.extended.underlineColor;case 0x3000000:return 0xffffff&this.extended.underlineColor}return this.getFgColor()}getUnderlineColorMode(){return 0x10000000&this.bg&&~this.extended.underlineColor?0x3000000&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x3000000:this.isFgRGB()}isUnderlineColorPalette(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0x1000000||(0x3000000&this.extended.underlineColor)==0x2000000:this.isFgPalette()}isUnderlineColorDefault(){return 0x10000000&this.bg&&~this.extended.underlineColor?(0x3000000&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 0x10000000&this.fg?0x10000000&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},rT=class e{constructor(e=0,i=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=i}get ext(){return this._urlId?-0x1c000001&this._ext|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(0x1c000000&this._ext)>>26}set underlineStyle(e){this._ext&=-0x1c000001,this._ext|=e<<26&0x1c000000}get underlineColor(){return 0x3ffffff&this._ext}set underlineColor(e){this._ext&=-0x4000000,this._ext|=0x3ffffff&e}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(0xe0000000&this._ext)>>29;return e<0?0xfffffff8^e:e}set underlineVariantOffset(e){this._ext&=0x1fffffff,this._ext|=e<<29&0xe0000000}clone(){return new e(this._ext,this._urlId)}isEmpty(){return 0===this.underlineStyle&&0===this._urlId}},rN=class e extends rP{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new rT,this.combinedData=""}static fromCharData(i){let s=new e;return s.setFromCharData(i),s}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?rD(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(e){this.fg=e[0],this.bg=0;let i=!1;if(e[1].length>2)i=!0;else if(2===e[1].length){let s=e[1].charCodeAt(0);if(55296<=s&&s<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(s-55296)*1024+r-56320+65536|e[2]<<22:i=!0}else i=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;i&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},rI="di$target",rj="di$dependencies",rA=new Map;function rO(e){if(rA.has(e))return rA.get(e);let i=function(e,s,r){var n,o,a;if(3!=arguments.length)throw Error("@IServiceName-decorator can only be used to decorate a parameter");n=i,o=e,a=r,o[rI]===o?o[rj].push({id:n,index:a}):(o[rj]=[{id:n,index:a}],o[rI]=o)};return i._id=e,rA.set(e,i),i}var rH=rO("BufferService"),rz=rO("CoreMouseService"),rW=rO("CoreService"),rF=rO("CharsetService"),r$=rO("InstantiationService"),rK=rO("LogService"),rU=rO("OptionsService"),rq=rO("OscLinkService"),rV=rO("UnicodeService"),rY=rO("DecorationService"),rX=class{constructor(e,i,s){this._bufferService=e,this._optionsService=i,this._oscLinkService=s}provideLinks(e,i){let s=this._bufferService.buffer.lines.get(e-1);if(!s)return void i(void 0);let r=[],n=this._optionsService.rawOptions.linkHandler,o=new rN,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let i=0;i<a;i++)if(!(-1===h&&!s.hasContent(i))){if(s.loadCell(i,o),o.hasExtendedAttrs()&&o.extended.urlId)if(-1===h){h=i,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else -1!==h&&(c=!0);if(c||-1!==h&&i===a-1){let s=this._oscLinkService.getLinkData(l)?.uri;if(s){let o={start:{x:h+1,y:e},end:{x:i+ +(!c&&i===a-1),y:e}},l=!1;if(!n?.allowNonHttpProtocols)try{let e=new URL(s);["http:","https:"].includes(e.protocol)||(l=!0)}catch{l=!0}l||r.push({text:s,range:o,activate:(e,i)=>n?n.activate(e,i,o):function(e){if(confirm(`Do you want to navigate to ${e}?
|
|
56
|
-
|
|
57
|
-
WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=e}else console.warn("Opening link blocked as opener could not be cleared")}}(i),hover:(e,i)=>n?.hover?.(e,i,o),leave:(e,i)=>n?.leave?.(e,i,o)})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=i,l=o.extended.urlId):(h=-1,l=-1)}}i(r)}};rX=rS([ry(0,rH),ry(1,rU),ry(2,rq)],rX);var rG=rO("CharSizeService"),rJ=rO("CoreBrowserService"),rZ=rO("MouseService"),rQ=rO("RenderService"),r0=rO("SelectionService"),r1=rO("CharacterJoinerService"),r2=rO("ThemeService"),r5=rO("LinkProviderService"),r3=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?r7.isErrorNoTelemetry(e)?new r7(e.message+`
|
|
58
|
-
|
|
59
|
-
`+e.stack):Error(e.message+`
|
|
60
|
-
|
|
61
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(i=>{i(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function r4(e){var i;(i=e)instanceof r8||i instanceof Error&&i.name===r6&&i.message===r6||r3.onUnexpectedError(e)}var r6="Canceled",r8=class extends Error{constructor(){super(r6),this.name=this.message}},r7=class e extends Error{constructor(e){super(e),this.name="CodeExpectedError"}static fromError(i){if(i instanceof e)return i;let s=new e;return s.message=i.message,s.stack=i.stack,s}static isErrorNoTelemetry(e){return"CodeExpectedError"===e.name}},r9=class e extends Error{constructor(i){super(i||"An unexpected bug occurred."),Object.setPrototypeOf(this,e.prototype)}};function ne(e,i=0){return e[e.length-(1+i)]}(nm=nv||={}).isLessThan=function(e){return e<0},nm.isLessThanOrEqual=function(e){return e<=0},nm.isGreaterThan=function(e){return e>0},nm.isNeitherLessOrGreaterThan=function(e){return 0===e},nm.greaterThan=1,nm.lessThan=-1,nm.neitherLessOrGreaterThan=0;var nt=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(i=>(e(i),!0))}toArray(){let e=[];return this.iterate(i=>(e.push(i),!0)),e}filter(i){return new e(e=>this.iterate(s=>!i(s)||e(s)))}map(i){return new e(e=>this.iterate(s=>e(i(s))))}some(e){let i=!1;return this.iterate(s=>!(i=e(s))),i}findFirst(e){let i;return this.iterate(s=>!e(s)||(i=s,!1)),i}findLast(e){let i;return this.iterate(s=>(e(s)&&(i=s),!0)),i}findLastMaxBy(e){let i,s=!0;return this.iterate(r=>((s||nv.isGreaterThan(e(r,i)))&&(s=!1,i=r),!0)),i}};nt.empty=new nt(e=>{});function ni(e){}function ns(e,i){}function nr(e){if(nb.is(e)){let i=[];for(let s of e)if(s)try{s.dispose()}catch(e){i.push(e)}if(1===i.length)throw i[0];if(i.length>1)throw AggregateError(i,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function nn(e){let i={dispose:function(e){let i=this,s=!1,r;return function(){return s?r:(s=!0,r=e.apply(i,arguments))}}(()=>{ni(i),e()})};return i}(e=>{function i(e){return e&&"object"==typeof e&&"function"==typeof e[Symbol.iterator]}e.is=i;let s=Object.freeze([]);function*r(e){yield e}e.empty=function(){return s},e.single=r,e.wrap=function(e){return i(e)?e:r(e)},e.from=function(e){return e||s},e.reverse=function*(e){for(let i=e.length-1;i>=0;i--)yield e[i]},e.isEmpty=function(e){return!e||!0===e[Symbol.iterator]().next().done},e.first=function(e){return e[Symbol.iterator]().next().value},e.some=function(e,i){let s=0;for(let r of e)if(i(r,s++))return!0;return!1},e.find=function(e,i){for(let s of e)if(i(s))return s},e.filter=function*(e,i){for(let s of e)i(s)&&(yield s)},e.map=function*(e,i){let s=0;for(let r of e)yield i(r,s++)},e.flatMap=function*(e,i){let s=0;for(let r of e)yield*i(r,s++)},e.concat=function*(...e){for(let i of e)yield*i},e.reduce=function(e,i,s){let r=s;for(let s of e)r=i(r,s);return r},e.slice=function*(e,i,s=e.length){for(i<0&&(i+=e.length),s<0?s+=e.length:s>e.length&&(s=e.length);i<s;i++)yield e[i]},e.consume=function(i,s=1/0){let r=[];if(0===s)return[r,i];let n=i[Symbol.iterator]();for(let i=0;i<s;i++){let i=n.next();if(i.done)return[r,e.empty()];r.push(i.value)}return[r,{[Symbol.iterator]:()=>n}]},e.asyncToArray=async function(e){let i=[];for await(let s of e)i.push(s);return Promise.resolve(i)}})(nb||={});var no=class e{constructor(){var e;this._toDispose=new Set,this._isDisposed=!1,e=this}dispose(){this._isDisposed||(ni(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(0!==this._toDispose.size)try{nr(this._toDispose)}finally{this._toDispose.clear()}}add(i){if(!i)return i;if(i===this)throw Error("Cannot register a disposable on itself!");return ns(i,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(i),i}delete(e){if(e){if(e===this)throw Error("Cannot dispose a disposable on itself!");this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),ns(e,null))}};no.DISABLE_DISPOSED_WARNING=!1;var na=no,nl=class{constructor(){var e;this._store=new na,e=this,ns(this._store,this)}dispose(){ni(this),this._store.dispose()}_register(e){if(e===this)throw Error("Cannot register a disposable on itself!");return this._store.add(e)}};nl.None=Object.freeze({dispose(){}});var nh=class{constructor(){var e;this._isDisposed=!1,e=this}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&ns(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,ni(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&ns(e,null),e}},nc="object"==typeof window?window:globalThis,nd=class e{constructor(i){this.element=i,this.next=e.Undefined,this.prev=e.Undefined}};nd.Undefined=new nd(void 0);var nu=class{constructor(){this._first=nd.Undefined,this._last=nd.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===nd.Undefined}clear(){let e=this._first;for(;e!==nd.Undefined;){let i=e.next;e.prev=nd.Undefined,e.next=nd.Undefined,e=i}this._first=nd.Undefined,this._last=nd.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,i){let s=new nd(e);if(this._first===nd.Undefined)this._first=s,this._last=s;else if(i){let e=this._last;this._last=s,s.prev=e,e.next=s}else{let e=this._first;this._first=s,s.next=e,e.prev=s}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(s))}}shift(){if(this._first!==nd.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==nd.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==nd.Undefined&&e.next!==nd.Undefined){let i=e.prev;i.next=e.next,e.next.prev=i}else e.prev===nd.Undefined&&e.next===nd.Undefined?(this._first=nd.Undefined,this._last=nd.Undefined):e.next===nd.Undefined?(this._last=this._last.prev,this._last.next=nd.Undefined):e.prev===nd.Undefined&&(this._first=this._first.next,this._first.prev=nd.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==nd.Undefined;)yield e.element,e=e.next}},nf=globalThis.performance&&"function"==typeof globalThis.performance.now,n_=class e{static create(i){return new e(i)}constructor(e){this._now=nf&&!1===e?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return -1!==this._stopTime?this._stopTime-this._startTime:this._now()-this._startTime}};(e=>{function i(e){}function s(e){return(i,s=null,r)=>{let n=!1,o;return o=e(e=>{if(!n)return o?o.dispose():n=!0,i.call(s,e)},null,r),n&&o.dispose(),o}}function r(e,i,s){return o((s,r=null,n)=>e(e=>s.call(r,i(e)),null,n),s)}function n(e,i,s){return o((s,r=null,n)=>e(e=>i(e)&&s.call(r,e),null,n),s)}function o(e,s){let r,n={onWillAddFirstListener(){r=e(o.fire,o)},onDidRemoveLastListener(){r?.dispose()}};s||i(n);let o=new nM(n);return s?.add(o),o.event}function a(e,s,r=100,n=!1,o=!1,l,h){let c,d,u,f=0,_,p={leakWarningThreshold:l,onWillAddFirstListener(){c=e(e=>{f++,d=s(d,e),n&&!u&&(g.fire(d),d=void 0),_=()=>{let e=d;d=void 0,u=void 0,(!n||f>1)&&g.fire(e),f=0},"number"==typeof r?(clearTimeout(u),u=setTimeout(_,r)):void 0===u&&(u=0,queueMicrotask(_))})},onWillRemoveListener(){o&&f>0&&_?.()},onDidRemoveLastListener(){_=void 0,c.dispose()}};h||i(p);let g=new nM(p);return h?.add(g),g.event}e.None=()=>nl.None,e.defer=function(e,i){return a(e,()=>{},0,void 0,!0,void 0,i)},e.once=s,e.map=r,e.forEach=function(e,i,s){return o((s,r=null,n)=>e(e=>{i(e),s.call(r,e)},null,n),s)},e.filter=n,e.signal=function(e){return e},e.any=function(...e){return(i,s=null,r)=>{var n,o;return n=function(...e){let i=nn(()=>nr(e));return i}(...e.map(e=>e(e=>i.call(s,e)))),(o=r)instanceof Array?o.push(n):o&&o.add(n),n}},e.reduce=function(e,i,s,n){let o=s;return r(e,e=>o=i(o,e),n)},e.debounce=a,e.accumulate=function(i,s=0,r){return e.debounce(i,(e,i)=>e?(e.push(i),e):[i],s,void 0,!0,void 0,r)},e.latch=function(e,i=(e,i)=>e===i,s){let r=!0,o;return n(e,e=>{let s=r||!i(e,o);return r=!1,o=e,s},s)},e.split=function(i,s,r){return[e.filter(i,s,r),e.filter(i,e=>!s(e),r)]},e.buffer=function(e,i=!1,s=[],r){let n=s.slice(),o=e(e=>{n?n.push(e):l.fire(e)});r&&r.add(o);let a=()=>{n?.forEach(e=>l.fire(e)),n=null},l=new nM({onWillAddFirstListener(){o||(o=e(e=>l.fire(e)),r&&r.add(o))},onDidAddFirstListener(){n&&(i?setTimeout(a):a())},onDidRemoveLastListener(){o&&o.dispose(),o=null}});return r&&r.add(l),l.event},e.chain=function(e,i){return(s,r,n)=>{let o=i(new h);return e(function(e){let i=o.evaluate(e);i!==l&&s.call(r,i)},void 0,n)}};let l=Symbol("HaltChainable");class h{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(i=>(e(i),i)),this}filter(e){return this.steps.push(i=>e(i)?i:l),this}reduce(e,i){let s=i;return this.steps.push(i=>s=e(s,i)),this}latch(e=(e,i)=>e===i){let i=!0,s;return this.steps.push(r=>{let n=i||!e(r,s);return i=!1,s=r,n?r:l}),this}evaluate(e){for(let i of this.steps)if((e=i(e))===l)break;return e}}e.fromNodeEventEmitter=function(e,i,s=e=>e){let r=(...e)=>n.fire(s(...e)),n=new nM({onWillAddFirstListener:()=>e.on(i,r),onDidRemoveLastListener:()=>e.removeListener(i,r)});return n.event},e.fromDOMEventEmitter=function(e,i,s=e=>e){let r=(...e)=>n.fire(s(...e)),n=new nM({onWillAddFirstListener:()=>e.addEventListener(i,r),onDidRemoveLastListener:()=>e.removeEventListener(i,r)});return n.event},e.toPromise=function(e){return new Promise(i=>s(e)(i))},e.fromPromise=function(e){let i=new nM;return e.then(e=>{i.fire(e)},()=>{i.fire(void 0)}).finally(()=>{i.dispose()}),i.event},e.forward=function(e,i){return e(e=>i.fire(e))},e.runAndSubscribe=function(e,i,s){return i(s),e(e=>i(e))};class c{constructor(e,s){this._observable=e,this._counter=0,this._hasChanged=!1;let r={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};s||i(r),this.emitter=new nM(r),s&&s.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,i){this._hasChanged=!0}endUpdate(e){this._counter--,0===this._counter&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}e.fromObservable=function(e,i){return new c(e,i).emitter.event},e.fromObservableLight=function(e){return(i,s,r)=>{let n=0,o=!1,a={beginUpdate(){n++},endUpdate(){0==--n&&(e.reportChanges(),o&&(o=!1,i.call(s)))},handlePossibleChange(){},handleChange(){o=!0}};e.addObserver(a),e.reportChanges();let l={dispose(){e.removeObserver(a)}};return r instanceof na?r.add(l):Array.isArray(r)&&r.push(l),l}}})(nx||={});var np=class e{constructor(i){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${i}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new n_,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};np.all=new Set,np._idPool=0;var ng=class e{constructor(i,s,r=(e._idPool++).toString(16).padStart(3,"0")){this._errorHandler=i,this.threshold=s,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(e.value)||0;if(this._stacks.set(e.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=.5*s;let[e,r]=this.getMostFrequentStack(),n=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${r}):`;console.warn(n),console.warn(e);let o=new nw(n,e);this._errorHandler(o)}return()=>{let i=this._stacks.get(e.value)||0;this._stacks.set(e.value,i-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,i=0;for(let[s,r]of this._stacks)(!e||i<r)&&(e=[s,r],i=r);return e}};ng._idPool=1;var nm,nv,nb,nx,nS,ny=class e{constructor(e){this.value=e}static create(){return new e(Error().stack??"")}print(){console.warn(this.value.split(`
|
|
62
|
-
`).slice(2).join(`
|
|
63
|
-
`))}},nw=class extends Error{constructor(e,i){super(e),this.name="ListenerLeakError",this.stack=i}},nC=class extends Error{constructor(e,i){super(e),this.name="ListenerRefusalError",this.stack=i}},nk=0,nE=class{constructor(e){this.value=e,this.id=nk++}},nM=class{constructor(e){this._size=0,this._options=e,this._leakageMon=this._options?.leakWarningThreshold?new ng(e?.onListenerError??r4,this._options?.leakWarningThreshold??-1):void 0,this._perfMon=this._options?._profName?new np(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,i,s)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let i=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],s=new nC(`${e}. HINT: Stack shows most frequent listener (${i[1]}-times)`,i[0]);return(this._options?.onListenerError||r4)(s),nl.None}if(this._disposed)return nl.None;i&&(e=e.bind(i));let r=new nE(e),n;this._leakageMon&&this._size>=Math.ceil(.2*this._leakageMon.threshold)&&(r.stack=ny.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof nE?(this._deliveryQueue??=new nD,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let o=nn(()=>{nS?.unregister(o),n?.(),this._removeListener(r)});if(s instanceof na?s.add(o):Array.isArray(s)&&s.push(o),nS){let e=Error().stack.split(`
|
|
64
|
-
`).slice(2,3).join(`
|
|
65
|
-
`).trim(),i=/(file:|vscode-file:\/\/vscode-app)?(\/[^:]*:\d+:\d+)/.exec(e);nS.register(o,i?.[2]??e,o)}return o},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(1===this._size){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let i=this._listeners,s=i.indexOf(e);if(-1===s)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let r=this._deliveryQueue.current===this;if(2*this._size<=i.length){let e=0;for(let s=0;s<i.length;s++)i[s]?i[e++]=i[s]:r&&(this._deliveryQueue.end--,e<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=e}}_deliver(e,i){if(!e)return;let s=this._options?.onListenerError||r4;try{e.value(i)}catch(e){s(e)}}_deliverQueue(e){let i=e.current._listeners;for(;e.i<e.end;)this._deliver(i[e.i++],e.value);e.reset()}fire(e){if(this._deliveryQueue?.current&&(this._deliverQueue(this._deliveryQueue),this._perfMon?.stop()),this._perfMon?.start(this._size),this._listeners)if(this._listeners instanceof nE)this._deliver(this._listeners,e);else{let i=this._deliveryQueue;i.enqueue(this,e,this._listeners.length),this._deliverQueue(i)}this._perfMon?.stop()}hasListeners(){return this._size>0}},nD=class{constructor(){this.i=-1,this.end=0}enqueue(e,i,s){this.i=0,this.end=s,this.current=e,this.value=i}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},nR=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new nM,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new nM,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,i){if(this.getZoomLevel(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,e),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),e)}setFullscreen(e,i){if(this.isFullscreen(i)===e)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,e),this._onDidChangeFullscreen.fire(s)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};nR.INSTANCE=new nR,nR.INSTANCE.onDidChangeZoomLevel,nR.INSTANCE.onDidChangeFullscreen;var nL="object"==typeof navigator?navigator.userAgent:"",nB=nL.indexOf("Firefox")>=0,nP=nL.indexOf("AppleWebKit")>=0,nT=nL.indexOf("Chrome")>=0,nN=!nT&&nL.indexOf("Safari")>=0;nL.indexOf("Electron/"),nL.indexOf("Android");var nI=!1;if("function"==typeof nc.matchMedia){let e=nc.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),i=nc.matchMedia("(display-mode: fullscreen)");nI=e.matches,nj=e,"string"==typeof nj&&(nj=nc.matchMedia(nj)),nj.addEventListener("change",({matches:e})=>{nI&&i.matches||(nI=e)})}var nj,nA,nO,nH=!1,nz=!1,nW=!1,nF=!1,n$=!1,nK="en",nU=globalThis;"u">typeof nU.vscode&&"u">typeof nU.vscode.process?nO=nU.vscode.process:"u">typeof rv.default&&"string"==typeof rv.default?.versions?.node&&(nO=rv.default);var nq="string"==typeof nO?.versions?.electron&&nO?.type==="renderer";if("object"==typeof nO){nH="win32"===nO.platform,nz="darwin"===nO.platform,(nW="linux"===nO.platform)&&nO.env.SNAP&&nO.env.SNAP_REVISION,nO.env.CI||nO.env.BUILD_ARTIFACTSTAGINGDIRECTORY,nK="en";let e=nO.env.VSCODE_NLS_CONFIG;if(e)try{let i=JSON.parse(e);i.userLocale,i.osLocale,nK=i.resolvedLanguage||"en",i.languagePack?.translationsConfigFile}catch{}nF=!0}else"object"!=typeof navigator||nq?console.error("Unable to resolve platform."):(nH=(nA=navigator.userAgent).indexOf("Windows")>=0,nz=nA.indexOf("Macintosh")>=0,(nA.indexOf("Macintosh")>=0||nA.indexOf("iPad")>=0||nA.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,nW=nA.indexOf("Linux")>=0,nA?.indexOf("Mobi"),n$=!0,nK=globalThis._VSCODE_NLS_LANGUAGE||"en",navigator.language.toLowerCase());var nV=nH,nY=nz,nX=nW,nG=nF;n$&&"function"==typeof nU.importScripts&&nU.origin;var nJ,nZ=nA,nQ=nK;(n9=nJ||={}).value=function(){return nQ},n9.isDefaultVariant=function(){return 2===nQ.length?"en"===nQ:nQ.length>=3&&"e"===nQ[0]&&"n"===nQ[1]&&"-"===nQ[2]},n9.isDefault=function(){return"en"===nQ};var n0="function"==typeof nU.postMessage&&!nU.importScripts,n1=(()=>{if(n0){let e=[];nU.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,r=e.length;s<r;s++){let r=e[s];if(r.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),r.callback();return}}});let i=0;return s=>{let r=++i;e.push({id:r,callback:s}),nU.postMessage({vscodeScheduleAsyncWork:r},"*")}}return e=>setTimeout(e)})(),n2=!!(nZ&&nZ.indexOf("Chrome")>=0);nZ&&nZ.indexOf("Firefox"),!n2&&nZ&&nZ.indexOf("Safari"),nZ&&nZ.indexOf("Edg/"),nZ&&nZ.indexOf("Android");var n5="object"==typeof navigator?navigator:{};nG||document.queryCommandSupported&&document.queryCommandSupported("copy")||n5&&n5.clipboard&&n5.clipboard.writeText,nG||n5&&n5.clipboard&&n5.clipboard.readText,nG||nI||n5.keyboard,"ontouchstart"in nc||n5.maxTouchPoints,nc.PointerEvent&&("ontouchstart"in nc||navigator.maxTouchPoints);var n3=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,i){this._keyCodeToStr[e]=i,this._strToKeyCode[i.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},n4=new n3,n6=new n3,n8=new n3,n7=Array(230);(oe=ot||={}).toString=function(e){return n4.keyCodeToStr(e)},oe.fromString=function(e){return n4.strToKeyCode(e)},oe.toUserSettingsUS=function(e){return n6.keyCodeToStr(e)},oe.toUserSettingsGeneral=function(e){return n8.keyCodeToStr(e)},oe.fromUserSettings=function(e){return n6.strToKeyCode(e)||n8.strToKeyCode(e)},oe.toElectronAccelerator=function(e){if(e>=98&&e<=113)return null;switch(e){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return n4.keyCodeToStr(e)};var n9,oe,ot,oi,os=class e{constructor(e,i,s,r,n){this.ctrlKey=e,this.shiftKey=i,this.altKey=s,this.metaKey=r,this.keyCode=n}equals(i){return i instanceof e&&this.ctrlKey===i.ctrlKey&&this.shiftKey===i.shiftKey&&this.altKey===i.altKey&&this.metaKey===i.metaKey&&this.keyCode===i.keyCode}getHashCode(){let e=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${e}${i}${s}${r}${this.keyCode}`}isModifierKey(){return 0===this.keyCode||5===this.keyCode||57===this.keyCode||6===this.keyCode||4===this.keyCode}toKeybinding(){return new or([this])}isDuplicateModifierCase(){return this.ctrlKey&&5===this.keyCode||this.shiftKey&&4===this.keyCode||this.altKey&&6===this.keyCode||this.metaKey&&57===this.keyCode}},or=class{constructor(e){if(0===e.length)throw function(e){return e?Error(`Illegal argument: ${e}`):Error("Illegal argument")}("chords");this.chords=e}getHashCode(){let e="";for(let i=0,s=this.chords.length;i<s;i++)0!==i&&(e+=";"),e+=this.chords[i].getHashCode();return e}equals(e){if(null===e||this.chords.length!==e.chords.length)return!1;for(let i=0;i<this.chords.length;i++)if(!this.chords[i].equals(e.chords[i]))return!1;return!0}},on=nY?256:2048,oo=nY?2048:256,oa=class{constructor(e){this._standardKeyboardEventBrand=!0,this.browserEvent=e,this.target=e.target,this.ctrlKey=e.ctrlKey,this.shiftKey=e.shiftKey,this.altKey=e.altKey,this.metaKey=e.metaKey,this.altGraphKey=e.getModifierState?.("AltGraph"),this.keyCode=function(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return ot.fromString(i)}let i=e.keyCode;if(3===i)return 7;if(nB)switch(i){case 59:return 85;case 60:if(nX)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(nY)return 57}else if(nP&&(nY&&93===i||!nY&&92===i))return 57;return n7[i]||0}(e),this.code=e.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let i=0;return this.ctrlKey&&(i|=on),this.altKey&&(i|=512),this.shiftKey&&(i|=1024),this.metaKey&&(i|=oo),i|=e}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new os(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},ol=new WeakMap,oh=class{static getSameOriginWindowChain(e){let i=ol.get(e);if(!i){i=[],ol.set(e,i);let s=e,r;do(r=function(e){if(!e.parent||e.parent===e)return null;try{let i=e.location,s=e.parent.location;if("null"!==i.origin&&"null"!==s.origin&&i.origin!==s.origin)return null}catch{return null}return e.parent}(s))?i.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):i.push({window:new WeakRef(s),iframeElement:null}),s=r;while(s)}return i.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,i){if(!i||e===i)return{top:0,left:0};let s=0,r=0;for(let n of this.getSameOriginWindowChain(e)){let e=n.window.deref();if(s+=e?.scrollY??0,r+=e?.scrollX??0,e===i||!n.iframeElement)break;let o=n.iframeElement.getBoundingClientRect();s+=o.top,r+=o.left}return{top:s,left:r}}},oc=class{constructor(e,i){this.timestamp=Date.now(),this.browserEvent=i,this.leftButton=0===i.button,this.middleButton=1===i.button,this.rightButton=2===i.button,this.buttons=i.buttons,this.target=i.target,this.detail=i.detail||1,"dblclick"===i.type&&(this.detail=2),this.ctrlKey=i.ctrlKey,this.shiftKey=i.shiftKey,this.altKey=i.altKey,this.metaKey=i.metaKey,"number"==typeof i.pageX?(this.posx=i.pageX,this.posy=i.pageY):(this.posx=i.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=i.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=oh.getPositionOfChildWindowRelativeToAncestorWindow(e,i.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},od=class{constructor(e,i=0,s=0){this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=i;let r=!1;if(nT){let e=navigator.userAgent.match(/Chrome\/(\d+)/);r=(e?parseInt(e[1]):123)<=122}if(e){let i=e.view?.devicePixelRatio||1;"u">typeof e.wheelDeltaY?r?this.deltaY=e.wheelDeltaY/(120*i):this.deltaY=e.wheelDeltaY/120:"u">typeof e.VERTICAL_AXIS&&e.axis===e.VERTICAL_AXIS?this.deltaY=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?nB&&!nY?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40),"u">typeof e.wheelDeltaX?nN&&nV?this.deltaX=-(e.wheelDeltaX/120):r?this.deltaX=e.wheelDeltaX/(120*i):this.deltaX=e.wheelDeltaX/120:"u">typeof e.HORIZONTAL_AXIS&&e.axis===e.HORIZONTAL_AXIS?this.deltaX=-e.detail/3:"wheel"===e.type&&(e.deltaMode===e.DOM_DELTA_LINE?nB&&!nY?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40),0===this.deltaY&&0===this.deltaX&&e.wheelDelta&&(r?this.deltaY=e.wheelDelta/(120*i):this.deltaY=e.wheelDelta/120)}}preventDefault(){this.browserEvent?.preventDefault()}stopPropagation(){this.browserEvent?.stopPropagation()}},ou=Object.freeze(function(e,i){let s=setTimeout(e.bind(i),0);return{dispose(){clearTimeout(s)}}});(ai=oi||={}).isCancellationToken=function(e){return e===ai.None||e===ai.Cancelled||e instanceof of||!!e&&"object"==typeof e&&"boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested},ai.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:nx.None}),ai.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ou});var of=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?ou:(this._emitter||(this._emitter=new nM),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}};Symbol("MicrotaskDelay");var o_=class{constructor(e,i){this._isDisposed=!1,this._token=-1,"function"==typeof e&&"number"==typeof i&&this.setIfNotSet(e,i)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){-1!==this._token&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,i){if(this._isDisposed)throw new r9("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},i)}setIfNotSet(e,i){if(this._isDisposed)throw new r9("Calling 'setIfNotSet' on a disposed TimeoutTimer");-1===this._token&&(this._token=setTimeout(()=>{this._token=-1,e()},i))}},op=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,i,s=globalThis){if(this.isDisposed)throw new r9("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let r=s.setInterval(()=>{e()},i);this.disposable=nn(()=>{s.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(as=ar||={}).settled=async function(e){let i,s=await Promise.all(e.map(e=>e.then(e=>e,e=>{i||(i=e)})));if("u">typeof i)throw i;return s},as.withAsyncBody=function(e){return new Promise(async(i,s)=>{try{await e(i,s)}catch(e){s(e)}})};var og=class e{static fromArray(i){return new e(e=>{e.emitMany(i)})}static fromPromise(i){return new e(async e=>{e.emitMany(await i)})}static fromPromises(i){return new e(async e=>{await Promise.all(i.map(async i=>e.emitOne(await i)))})}static merge(i){return new e(async e=>{await Promise.all(i.map(async i=>{for await(let s of i)e.emitOne(s)}))})}constructor(e,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new nM,queueMicrotask(async()=>{let i={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(i)),this.resolve()}catch(e){this.reject(e)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{for(;;){if(2===this._state)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(1===this._state)return{done:!0,value:void 0};await nx.toPromise(this._onStateChanged.event)}},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(i,s){return new e(async e=>{for await(let r of i)e.emitOne(s(r))})}map(i){return e.map(this,i)}static filter(i,s){return new e(async e=>{for await(let r of i)s(r)&&e.emitOne(r)})}filter(i){return e.filter(this,i)}static coalesce(i){return e.filter(i,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let i=[];for await(let s of e)i.push(s);return i}toPromise(){return e.toPromise(this)}emitOne(e){0===this._state&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){0===this._state&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){0===this._state&&(this._state=1,this._onStateChanged.fire())}reject(e){0===this._state&&(this._state=2,this._error=e,this._onStateChanged.fire())}};og.EMPTY=og.fromArray([]);function om(e,i){return(i<<5)-i+e|0}function ov(e,i){i=om(149417,i);for(let s=0,r=e.length;s<r;s++)i=om(e.charCodeAt(s),i);return i}new DataView(new ArrayBuffer(320));var{registerWindow:ob,getWindow:ox,getDocument:oS,getWindows:oy,getWindowsCount:ow,getWindowId:oC,getWindowById:ok,hasWindow:oE,onDidRegisterWindow:oM,onWillUnregisterWindow:oD,onDidUnregisterWindow:oR}=(s=new Map,r={window:nc,disposables:new na},s.set(nc.vscodeWindowId,r),n=new nM,o=new nM,a=new nM,{onDidRegisterWindow:n.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:o.event,registerWindow(e){if(s.has(e.vscodeWindowId))return nl.None;let i=new na,r={window:e,disposables:i.add(new na)};return s.set(e.vscodeWindowId,r),i.add(nn(()=>{s.delete(e.vscodeWindowId),o.fire(e)})),i.add(oB(e,oj.BEFORE_UNLOAD,()=>{a.fire(e)})),n.fire(r),i},getWindows:()=>s.values(),getWindowsCount:()=>s.size,getWindowId:e=>e.vscodeWindowId,hasWindow:e=>s.has(e),getWindowById:function(e,i){return("number"==typeof e?s.get(e):void 0)??(i?r:void 0)},getWindow:e=>e?.ownerDocument?.defaultView?e.ownerDocument.defaultView.window:e?.view?e.view.window:nc,getDocument:e=>ox(e).document}),oL=class{constructor(e,i,s,r){this._node=e,this._type=i,this._handler=s,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function oB(e,i,s,r){return new oL(e,i,s,r)}var oP=function(e,i,s,r){var n;let o=s;return"click"===i||"mousedown"===i||"contextmenu"===i?(n=ox(e),o=function(e){return s(new oc(n,e))}):("keydown"===i||"keypress"===i||"keyup"===i)&&(o=function(e){return s(new oa(e))}),oB(e,i,o,r)},oT=class extends op{constructor(e){super(),this.defaultTarget=e&&ox(e)}cancelAndSet(e,i,s){return super.cancelAndSet(e,i,s??this.defaultTarget)}},oN=class{constructor(e,i=0){this._runner=e,this.priority=i,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){r4(e)}}static sort(e,i){return i.priority-e.priority}};l=new Map,h=new Map,c=new Map,d=new Map,an=(e,i,s=0)=>{let r=oC(e),n=new oN(i,s),o=l.get(r);return o||(o=[],l.set(r,o)),o.push(n),c.get(r)||(c.set(r,!0),e.requestAnimationFrame(()=>(e=>{c.set(e,!1);let i=l.get(e)??[];for(h.set(e,i),l.set(e,[]),d.set(e,!0);i.length>0;)i.sort(oN.sort),i.shift().execute();d.set(e,!1)})(r))),n};var oI=class e{constructor(e,i){this.width=e,this.height=i}with(i=this.width,s=this.height){return i!==this.width||s!==this.height?new e(i,s):this}static is(e){return"object"==typeof e&&"number"==typeof e.height&&"number"==typeof e.width}static lift(i){return i instanceof e?i:new e(i.width,i.height)}static equals(e,i){return e===i||!!e&&!!i&&e.width===i.width&&e.height===i.height}};oI.None=new oI(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,i,s){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let n=function e(i,s){switch(typeof i){case"object":var r,n,o,a;return null===i?om(349,s):Array.isArray(i)?(r=i,n=om(104579,n=s),r.reduce((i,s)=>e(s,i),n)):(o=i,a=om(181387,a=s),Object.keys(o).sort().reduce((i,s)=>(i=ov(s,i),e(o[s],i)),a));case"string":return ov(i,s);case"boolean":return om(i?433:863,s);case"number":return om(i,s);case"undefined":return om(937,s);default:return om(617,s)}}(s,0),o=r.get(n);if(o)o.users+=1;else{let a=new nM,l=new MutationObserver(e=>a.fire(e));l.observe(e,s);let h=o={users:1,observer:l,onDidMutate:a.event};i.add(nn(()=>{h.users-=1,0===h.users&&(a.dispose(),l.disconnect(),r?.delete(n),r?.size===0&&this.mutationObservers.delete(e))})),r.set(n,o)}return o.onDidMutate}};var oj={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},oA=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let i=oO(e);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let i=oO(e);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(e){let i=oO(e);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(e){let i=oO(e);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(e){let i=oO(e);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(e){let i=oO(e);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(e){let i=oO(e);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingTop(e){let i=oO(e);this._paddingTop!==i&&(this._paddingTop=i,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let i=oO(e);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let i=oO(e);this._paddingBottom!==i&&(this._paddingBottom=i,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let i=oO(e);this._paddingRight!==i&&(this._paddingRight=i,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let i=oO(e);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let i=oO(e);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let i=oO(e);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,i){this.domNode.classList.toggle(e,i),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,i){this.domNode.setAttribute(e,i)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function oO(e){return"number"==typeof e?`${e}px`:e}function oH(e){return new oA(e)}var oz=class{constructor(){this._hooks=new na,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,i){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(i)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,i,s,r,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=n;let o=e;try{e.setPointerCapture(i),this._hooks.add(nn(()=>{try{e.releasePointerCapture(i)}catch{}}))}catch{o=ox(e)}this._hooks.add(oB(o,oj.POINTER_MOVE,e=>{e.buttons!==s?this.stopMonitoring(!0):(e.preventDefault(),this._pointerMoveCallback(e))})),this._hooks.add(oB(o,oj.POINTER_UP,e=>this.stopMonitoring(!0)))}};(u=ao||={}).Tap="-xterm-gesturetap",u.Change="-xterm-gesturechange",u.Start="-xterm-gesturestart",u.End="-xterm-gesturesend",u.Contextmenu="-xterm-gesturecontextmenu";var oW=class e extends nl{constructor(){super(),this.dispatched=!1,this.targets=new nu,this.ignoreTargets=new nu,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(nx.runAndSubscribe(oM,({window:e,disposables:i})=>{i.add(oB(e.document,"touchstart",e=>this.onTouchStart(e),{passive:!1})),i.add(oB(e.document,"touchend",i=>this.onTouchEnd(e,i))),i.add(oB(e.document,"touchmove",e=>this.onTouchMove(e),{passive:!1}))},{window:nc,disposables:this._store}))}static addTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),nn(e.INSTANCE.targets.push(i))):nl.None}static ignoreTarget(i){return e.isTouchDevice()?(e.INSTANCE||(e.INSTANCE=new e),nn(e.INSTANCE.ignoreTargets.push(i))):nl.None}static isTouchDevice(){return"ontouchstart"in nc||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(e){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,r=e.targetTouches.length;s<r;s++){let r=e.targetTouches.item(s);this.activeTouches[r.identifier]={id:r.identifier,initialTarget:r.target,initialTimeStamp:i,initialPageX:r.pageX,initialPageY:r.pageY,rollingTimestamps:[i],rollingPageX:[r.pageX],rollingPageY:[r.pageY]};let n=this.newGestureEvent(ao.Start,r.target);n.pageX=r.pageX,n.pageY=r.pageY,this.dispatchEvent(n)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}onTouchEnd(i,s){let r=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let a=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(a.identifier))){console.warn("move of an UNKNOWN touch",a);continue}let l=this.activeTouches[a.identifier],h=Date.now()-l.initialTimeStamp;if(h<e.HOLD_DELAY&&30>Math.abs(l.initialPageX-ne(l.rollingPageX))&&30>Math.abs(l.initialPageY-ne(l.rollingPageY))){let e=this.newGestureEvent(ao.Tap,l.initialTarget);e.pageX=ne(l.rollingPageX),e.pageY=ne(l.rollingPageY),this.dispatchEvent(e)}else if(h>=e.HOLD_DELAY&&30>Math.abs(l.initialPageX-ne(l.rollingPageX))&&30>Math.abs(l.initialPageY-ne(l.rollingPageY))){let e=this.newGestureEvent(ao.Contextmenu,l.initialTarget);e.pageX=ne(l.rollingPageX),e.pageY=ne(l.rollingPageY),this.dispatchEvent(e)}else if(1===n){let e=ne(l.rollingPageX),s=ne(l.rollingPageY),n=ne(l.rollingTimestamps)-l.rollingTimestamps[0],o=e-l.rollingPageX[0],a=s-l.rollingPageY[0],h=[...this.targets].filter(e=>l.initialTarget instanceof Node&&e.contains(l.initialTarget));this.inertia(i,h,r,Math.abs(o)/n,o>0?1:-1,e,Math.abs(a)/n,a>0?1:-1,s)}this.dispatchEvent(this.newGestureEvent(ao.End,l.initialTarget)),delete this.activeTouches[a.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(e,i){let s=document.createEvent("CustomEvent");return s.initEvent(e,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(i){if(i.type===ao.Tap){let s=new Date().getTime(),r=0;r=s-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=s,i.tapCount=r}else(i.type===ao.Change||i.type===ao.Contextmenu)&&(this._lastSetTapCountTime=0);if(i.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(i.initialTarget))return;let e=[];for(let s of this.targets)if(s.contains(i.initialTarget)){let r=0,n=i.initialTarget;for(;n&&n!==s;)r++,n=n.parentElement;e.push([r,s])}for(let[s,r]of(e.sort((e,i)=>e[0]-i[0]),e))r.dispatchEvent(i),this.dispatched=!0}}inertia(i,s,r,n,o,a,l,h,c){this.handle=an(i,()=>{let d=Date.now(),u=d-r,f=0,_=0,p=!0;n+=e.SCROLL_FRICTION*u,l+=e.SCROLL_FRICTION*u,n>0&&(p=!1,f=o*n*u),l>0&&(p=!1,_=h*l*u);let g=this.newGestureEvent(ao.Change);g.translationX=f,g.translationY=_,s.forEach(e=>e.dispatchEvent(g)),p||this.inertia(i,s,d,n,o,a+f,l,h,c+_)})}onTouchMove(e){let i=Date.now();for(let s=0,r=e.changedTouches.length;s<r;s++){let r=e.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(r.identifier))){console.warn("end of an UNKNOWN touch",r);continue}let n=this.activeTouches[r.identifier],o=this.newGestureEvent(ao.Change,n.initialTarget);o.translationX=r.pageX-ne(n.rollingPageX),o.translationY=r.pageY-ne(n.rollingPageY),o.pageX=r.pageX,o.pageY=r.pageY,this.dispatchEvent(o),n.rollingPageX.length>3&&(n.rollingPageX.shift(),n.rollingPageY.shift(),n.rollingTimestamps.shift()),n.rollingPageX.push(r.pageX),n.rollingPageY.push(r.pageY),n.rollingTimestamps.push(i)}this.dispatched&&(e.preventDefault(),e.stopPropagation(),this.dispatched=!1)}};oW.SCROLL_FRICTION=-.005,oW.HOLD_DELAY=700,oW.CLEAR_TAP_COUNT_TIME=400,rS([function(e,i,s){let r=null,n=null;if("function"==typeof s.value?(r="value",0!==(n=s.value).length&&console.warn("Memoize should only be used in functions with zero parameters")):"function"==typeof s.get&&(r="get",n=s.get),!n)throw Error("not supported");let o=`$memoize$${i}`;s[r]=function(...e){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,e)}),this[o]}}],oW,"isTouchDevice",1);var oF=class extends nl{onclick(e,i){this._register(oB(e,oj.CLICK,s=>i(new oc(ox(e),s))))}onmousedown(e,i){this._register(oB(e,oj.MOUSE_DOWN,s=>i(new oc(ox(e),s))))}onmouseover(e,i){this._register(oB(e,oj.MOUSE_OVER,s=>i(new oc(ox(e),s))))}onmouseleave(e,i){this._register(oB(e,oj.MOUSE_LEAVE,s=>i(new oc(ox(e),s))))}onkeydown(e,i){this._register(oB(e,oj.KEY_DOWN,e=>i(new oa(e))))}onkeyup(e,i){this._register(oB(e,oj.KEY_UP,e=>i(new oa(e))))}oninput(e,i){this._register(oB(e,oj.INPUT,i))}onblur(e,i){this._register(oB(e,oj.BLUR,i))}onfocus(e,i){this._register(oB(e,oj.FOCUS,i))}onchange(e,i){this._register(oB(e,oj.CHANGE,i))}ignoreGesture(e){return oW.ignoreTarget(e)}},o$=class extends oF{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px","u">typeof e.top&&(this.bgDomNode.style.top="0px"),"u">typeof e.left&&(this.bgDomNode.style.left="0px"),"u">typeof e.bottom&&(this.bgDomNode.style.bottom="0px"),"u">typeof e.right&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width="11px",this.domNode.style.height="11px","u">typeof e.top&&(this.domNode.style.top=e.top+"px"),"u">typeof e.left&&(this.domNode.style.left=e.left+"px"),"u">typeof e.bottom&&(this.domNode.style.bottom=e.bottom+"px"),"u">typeof e.right&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new oz),this._register(oP(this.bgDomNode,oj.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(oP(this.domNode,oj.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new oT),this._pointerdownScheduleRepeatTimer=this._register(new o_)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ox(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(i,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},oK=class e{constructor(e,i,s,r,n,o,a){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i|=0,s|=0,r|=0,n|=0,o|=0,a|=0),this.rawScrollLeft=r,this.rawScrollTop=a,i<0&&(i=0),r+i>s&&(r=s-i),r<0&&(r=0),n<0&&(n=0),a+n>o&&(a=o-n),a<0&&(a=0),this.width=i,this.scrollWidth=s,this.scrollLeft=r,this.height=n,this.scrollHeight=o,this.scrollTop=a}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(i,s){return new e(this._forceIntegerValues,"u">typeof i.width?i.width:this.width,"u">typeof i.scrollWidth?i.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,"u">typeof i.height?i.height:this.height,"u">typeof i.scrollHeight?i.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(i){return new e(this._forceIntegerValues,this.width,this.scrollWidth,"u">typeof i.scrollLeft?i.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,"u">typeof i.scrollTop?i.scrollTop:this.rawScrollTop)}createScrollEvent(e,i){let s=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,n=this.scrollLeft!==e.scrollLeft,o=this.height!==e.height,a=this.scrollHeight!==e.scrollHeight,l=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:i,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:o,scrollHeightChanged:a,scrollTopChanged:l}}},oU=class extends nl{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new nM),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new oK(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,i){let s=this._state.withScrollDimensions(e,i);this._setState(s,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let i=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(i,!1)}setScrollPositionSmooth(e,i){if(0===this._smoothScrollDuration)return this.setScrollPositionNow(e);if(this._smoothScrolling){let s;e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;s=i?new oY(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=oY.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),i=this._state.withScrollPosition(e);if(this._setState(i,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,i){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,i)))}},oq=class{constructor(e,i,s){this.scrollLeft=e,this.scrollTop=i,this.isDone=s}};function oV(e,i){let s=i-e;return function(i){return e+s*(1-Math.pow(1-i,3))}}var oY=class e{constructor(e,i,s,r){this.from=e,this.to=i,this.duration=r,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(e,i,s){if(Math.abs(e-i)>2.5*s){var r,n;let o,a;return e<i?(o=e+.75*s,a=i-.75*s):(o=e-.75*s,a=i+.75*s),r=oV(e,o),n=oV(a,i),function(e){return e<.33?r(e/.33):n((e-.33)/(1-.33))}}return oV(e,i)}dispose(){null!==this.animationFrameDisposable&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(e){this.to=e.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(e){let i=(e-this.startTime)/this.duration;return i<1?new oq(this.scrollLeft(i),this.scrollTop(i),!1):new oq(this.to.scrollLeft,this.to.scrollTop,!0)}combine(i,s,r){return e.start(i,s,r)}static start(i,s,r){return r+=10,new e(i,s,Date.now()-10,r)}},oX=class extends nl{constructor(e,i,s){super(),this._visibility=e,this._visibleClassName=i,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new o_)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return 2!==this._visibility&&(3===this._visibility||this._rawShouldBeVisible)}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){this._isNeeded?this._shouldBeVisible?this._reveal():this._hide(!0):this._hide(!1)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?" fade":"")))}},oG=class extends oF{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new oX(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new oz),this._shouldRender=!0,this.domNode=oH(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(oB(this.domNode.domNode,oj.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let i=this._register(new o$(e));this.domNode.domNode.appendChild(i.bgDomNode),this.domNode.domNode.appendChild(i.domNode)}_createSlider(e,i,s,r){this.slider=oH(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(i),"number"==typeof s&&this.slider.setWidth(s),"number"==typeof r&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(oB(this.slider.domNode,oj.POINTER_DOWN,e=>{0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let i=this.domNode.domNode.getClientRects()[0].top,s=i+this._scrollbarState.getSliderPosition(),r=i+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=r?0===e.button&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let i,s;if(e.target===this.domNode.domNode&&"number"==typeof e.offsetX&&"number"==typeof e.offsetY)i=e.offsetX,s=e.offsetY;else{var r;let n,o,a=(n=(r=this.domNode.domNode).getBoundingClientRect(),o=ox(r),{left:n.left+o.scrollX,top:n.top+o.scrollY,width:n.width,height:n.height});i=e.pageX-a.left,s=e.pageY-a.top}let n=this._pointerDownRelativePosition(i,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(n):this._scrollbarState.getDesiredScrollPositionFromOffset(n)),0===e.button&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let i=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let n=Math.abs(this._sliderOrthogonalPointerPosition(e)-s);if(nV&&n>140)return void this._setDesiredScrollPositionNow(r.getScrollPosition());let o=this._sliderPointerPosition(e)-i;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let i={};this.writeScrollPosition(i,e),this._scrollable.setScrollPositionNow(i)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},oJ=class e{constructor(e,i,s,r,n,o){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=o,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let i=Math.round(e);return this._visibleSize!==i&&(this._visibleSize=i,this._refreshComputedValues(),!0)}setScrollSize(e){let i=Math.round(e);return this._scrollSize!==i&&(this._scrollSize=i,this._refreshComputedValues(),!0)}setScrollPosition(e){let i=Math.round(e);return this._scrollPosition!==i&&(this._scrollPosition=i,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,i,s,r,n){let o=Math.max(0,s-e),a=Math.max(0,o-2*i),l=r>0&&r>s;if(!l)return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(a),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(s*a/r))),c=(a-h)/(r-s);return{computedAvailableSize:Math.round(o),computedIsNeeded:l,computedSliderSize:Math.round(h),computedSliderRatio:c,computedSliderPosition:Math.round(n*c)}}_refreshComputedValues(){let i=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=i.computedAvailableSize,this._computedIsNeeded=i.computedIsNeeded,this._computedSliderSize=i.computedSliderSize,this._computedSliderRatio=i.computedSliderRatio,this._computedSliderPosition=i.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){return this._computedIsNeeded?Math.round((e-this._arrowSize-this._computedSliderSize/2)/this._computedSliderRatio):0}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let i=e-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(e){return this._computedIsNeeded?Math.round((this._computedSliderPosition+e)/this._computedSliderRatio):0}},oZ=class extends oG{constructor(e,i,s){let r=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new oJ(i.horizontalHasArrows?i.arrowSize:0,2===i.horizontal?0:i.horizontalScrollbarSize,2===i.vertical?0:i.verticalScrollbarSize,r.width,r.scrollWidth,n.scrollLeft),visibility:i.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:i.scrollByPage}),i.horizontalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((i.horizontalScrollbarSize-i.horizontalSliderSize)/2),0,void 0,i.horizontalSliderSize)}_updateSlider(e,i){this.slider.setWidth(e),this.slider.setLeft(i)}_renderDomNode(e,i){this.domNode.setWidth(e),this.domNode.setHeight(i),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,i){e.scrollLeft=i}updateOptions(e){this.updateScrollbarSize(2===e.horizontal?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},oQ=class extends oG{constructor(e,i,s){let r=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:i.lazyRender,host:s,scrollbarState:new oJ(i.verticalHasArrows?i.arrowSize:0,2===i.vertical?0:i.verticalScrollbarSize,0,r.height,r.scrollHeight,n.scrollTop),visibility:i.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:i.scrollByPage}),i.verticalHasArrows)throw Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((i.verticalScrollbarSize-i.verticalSliderSize)/2),i.verticalSliderSize,void 0)}_updateSlider(e,i){this.slider.setHeight(e),this.slider.setTop(i)}_renderDomNode(e,i){this.domNode.setWidth(i),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,i){return i}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,i){e.scrollTop=i}updateOptions(e){this.updateScrollbarSize(2===e.vertical?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},o0=class{constructor(e,i,s){this.timestamp=e,this.deltaX=i,this.deltaY=s,this.score=0}},o1=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(-1===this._front&&-1===this._rear)return!1;let e=1,i=0,s=1,r=this._rear;for(;;){let n=r===this._front?e:Math.pow(2,-s);if(e-=n,i+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,s++}return i<=.5}acceptStandardWheelEvent(e){if(nT){var i;let s=(i=ox(e.browserEvent),nR.INSTANCE.getZoomFactor(i));this.accept(Date.now(),e.deltaX*s,e.deltaY*s)}else this.accept(Date.now(),e.deltaX,e.deltaY)}accept(e,i,s){let r=null,n=new o0(e,i,s);-1===this._front&&-1===this._rear?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(e,i){if(Math.abs(e.deltaX)>0&&Math.abs(e.deltaY)>0)return 1;let s=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(s+=.25),i){let r=Math.abs(e.deltaX),n=Math.abs(e.deltaY),o=Math.abs(i.deltaX),a=Math.abs(i.deltaY),l=Math.max(Math.min(r,o),1),h=Math.max(Math.min(n,a),1),c=Math.max(n,a);Math.max(r,o)%l==0&&c%h==0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(e){return .01>Math.abs(Math.round(e)-e)}};o1.INSTANCE=new o1;var o2=class extends oF{constructor(e,i,s){super(),this._onScroll=this._register(new nM),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new nM),this.onWillScroll=this._onWillScroll.event,this._options=function(e){let i={lazyRender:"u">typeof e.lazyRender&&e.lazyRender,className:"u">typeof e.className?e.className:"",useShadows:!("u">typeof e.useShadows)||e.useShadows,handleMouseWheel:!("u">typeof e.handleMouseWheel)||e.handleMouseWheel,flipAxes:"u">typeof e.flipAxes&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:"u">typeof e.consumeMouseWheelIfScrollbarIsNeeded&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:"u">typeof e.alwaysConsumeMouseWheel&&e.alwaysConsumeMouseWheel,scrollYToX:"u">typeof e.scrollYToX&&e.scrollYToX,mouseWheelScrollSensitivity:"u">typeof e.mouseWheelScrollSensitivity?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:"u">typeof e.fastScrollSensitivity?e.fastScrollSensitivity:5,scrollPredominantAxis:!("u">typeof e.scrollPredominantAxis)||e.scrollPredominantAxis,mouseWheelSmoothScroll:!("u">typeof e.mouseWheelSmoothScroll)||e.mouseWheelSmoothScroll,arrowSize:"u">typeof e.arrowSize?e.arrowSize:11,listenOnDomNode:"u">typeof e.listenOnDomNode?e.listenOnDomNode:null,horizontal:"u">typeof e.horizontal?e.horizontal:1,horizontalScrollbarSize:"u">typeof e.horizontalScrollbarSize?e.horizontalScrollbarSize:10,horizontalSliderSize:"u">typeof e.horizontalSliderSize?e.horizontalSliderSize:0,horizontalHasArrows:"u">typeof e.horizontalHasArrows&&e.horizontalHasArrows,vertical:"u">typeof e.vertical?e.vertical:1,verticalScrollbarSize:"u">typeof e.verticalScrollbarSize?e.verticalScrollbarSize:10,verticalHasArrows:"u">typeof e.verticalHasArrows&&e.verticalHasArrows,verticalSliderSize:"u">typeof e.verticalSliderSize?e.verticalSliderSize:0,scrollByPage:"u">typeof e.scrollByPage&&e.scrollByPage};return i.horizontalSliderSize="u">typeof e.horizontalSliderSize?e.horizontalSliderSize:i.horizontalScrollbarSize,i.verticalSliderSize="u">typeof e.verticalSliderSize?e.verticalSliderSize:i.verticalScrollbarSize,nY&&(i.className+=" mac"),i}(i),this._scrollable=s,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new oQ(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new oZ(this._scrollable,this._options,r)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=oH(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=oH(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=oH(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new o_),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=nr(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,nY&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){"u">typeof e.handleMouseWheel&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),"u">typeof e.mouseWheelScrollSensitivity&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),"u">typeof e.fastScrollSensitivity&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),"u">typeof e.scrollPredominantAxis&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),"u">typeof e.horizontal&&(this._options.horizontal=e.horizontal),"u">typeof e.vertical&&(this._options.vertical=e.vertical),"u">typeof e.horizontalScrollbarSize&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),"u">typeof e.verticalScrollbarSize&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),"u">typeof e.scrollByPage&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new od(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=nr(this._mouseWheelToDispose),e)){let e=e=>{this._onMouseWheel(new od(e))};this._mouseWheelToDispose.push(oB(this._listenOnDomNode,oj.MOUSE_WHEEL,e,{passive:!1}))}}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let i=o1.INSTANCE;i.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,n=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&n+r===0?n=r=0:Math.abs(r)>=Math.abs(n)?n=0:r=0),this._options.flipAxes&&([r,n]=[n,r]);let o=!nY&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||o)&&!n&&(n=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(n*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let a=this._scrollable.getFutureScrollPosition(),l={};if(r){let e=50*r,i=a.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(l,i)}if(n){let e=50*n,i=a.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(l,i)}l=this._scrollable.validateScrollPosition(l),(a.scrollLeft!==l.scrollLeft||a.scrollTop!==l.scrollTop)&&(this._options.mouseWheelSmoothScroll&&i.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(l):this._scrollable.setScrollPositionNow(l),s=!0)}let r=s;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),i=e.scrollTop>0,s=e.scrollLeft>0,r=s?" left":"",n=i?" top":"";this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${s||i?" top-left-corner":""}${n}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){this._mouseIsOver||this._isDragging||(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){this._mouseIsOver||this._isDragging||this._hideTimeout.cancelAndSet(()=>this._hide(),500)}},o5=class extends o2{constructor(e,i,s){super(e,i,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}},o3=class extends nl{constructor(e,i,s,r,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new nM),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new oU({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>an(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new o5(i,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(16&e)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(nx.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(nn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement("style"),i.appendChild(this._styleElement),this._register(nn(()=>this._styleElement.remove())),this._register(nx.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
66
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let i=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:i.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,i){i&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!i,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){void 0!==e&&(this._latestYDisp=e),void 0===this._queuedAnimationFrame&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let i=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=i-this._bufferService.buffer.ydisp;0!==s&&(this._latestYDisp=i,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};o3=rS([ry(2,rH),ry(3,rJ),ry(4,rz),ry(5,r2),ry(6,rU),ry(7,rQ)],o3);var o4=class extends nl{constructor(e,i,s,r,n){super(),this._screenElement=e,this._bufferService=i,this._coreBrowserService=s,this._decorationService=r,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(nn(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){void 0===this._animationFrame&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let i=this._coreBrowserService.mainDocument.createElement("div");i.classList.add("xterm-decoration"),i.classList.toggle("xterm-decoration-top-layer",e?.options?.layer==="top"),i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(i.style.display="none"),this._refreshXPosition(e,i),i}_refreshStyle(e){let i=e.marker.line-this._bufferService.buffers.active.ydisp;if(i<0||i>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${i*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,i=e.element){if(!i)return;let s=e.options.x??0;"right"===(e.options.anchor||"left")?i.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":i.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};o4=rS([ry(1,rH),ry(2,rJ),ry(3,rY),ry(4,rQ)],o4);var o6=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let i of this._zones)if(i.color===e.options.overviewRulerOptions.color&&i.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(i,e.marker.line))return;if(this._lineAdjacentToZone(i,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(i,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,i){return i>=e.startBufferLine&&i<=e.endBufferLine}_lineAdjacentToZone(e,i,s){return i>=e.startBufferLine-this._linePadding[s||"full"]&&i<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,i){e.startBufferLine=Math.min(e.startBufferLine,i),e.endBufferLine=Math.max(e.endBufferLine,i)}},o8={full:0,left:0,center:0,right:0},o7={full:0,left:0,center:0,right:0},o9={full:0,left:0,center:0,right:0},ae=class extends nl{constructor(e,i,s,r,n,o,a,l){super(),this._viewportElement=e,this._screenElement=i,this._bufferService=s,this._decorationService=r,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new o6,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(nn(()=>this._canvas?.remove()));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),i=Math.ceil((this._canvas.width-1)/3);o7.full=this._canvas.width,o7.left=e,o7.center=i,o7.right=e,this._refreshDrawHeightConstants(),o9.full=1,o9.left=1,o9.center=1+o7.left,o9.right=1+o7.left+o7.center}_refreshDrawHeightConstants(){o8.full=Math.round(2*this._coreBrowserService.dpr);let e=Math.round(Math.max(Math.min(this._canvas.height/this._bufferService.buffer.lines.length,12),6)*this._coreBrowserService.dpr);o8.left=e,o8.center=e,o8.right=e}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o8.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o8.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o8.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o8.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){for(let e of(this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear(),this._decorationService.decorations))this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let i of e)"full"!==i.position&&this._renderColorZone(i);for(let i of e)"full"===i.position&&this._renderColorZone(i);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(o9[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-o8[e.position||"full"]/2),o7[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+o8[e.position||"full"]))}_queueRefresh(e,i){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=i||this._shouldUpdateAnchor,void 0===this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ae=rS([ry(2,rH),ry(3,rY),ry(4,rQ),ry(5,rU),ry(6,r2),ry(7,rJ)],ae),(f=aa||={}).NUL="\0",f.SOH="\x01",f.STX="\x02",f.ETX="\x03",f.EOT="\x04",f.ENQ="\x05",f.ACK="\x06",f.BEL="\x07",f.BS="\b",f.HT=" ",f.LF=`
|
|
67
|
-
`,f.VT="\v",f.FF="\f",f.CR="\r",f.SO="\x0e",f.SI="\x0f",f.DLE="\x10",f.DC1="\x11",f.DC2="\x12",f.DC3="\x13",f.DC4="\x14",f.NAK="\x15",f.SYN="\x16",f.ETB="\x17",f.CAN="\x18",f.EM="\x19",f.SUB="\x1a",f.ESC="\x1b",f.FS="\x1c",f.GS="\x1d",f.RS="\x1e",f.US="\x1f",f.SP=" ",f.DEL="",(_=al||={}).PAD="",_.HOP="",_.BPH="",_.NBH="",_.IND="",_.NEL="
",_.SSA="",_.ESA="",_.HTS="",_.HTJ="",_.VTS="",_.PLD="",_.PLU="",_.RI="",_.SS2="",_.SS3="",_.DCS="",_.PU1="",_.PU2="",_.STS="",_.CCH="",_.MW="",_.SPA="",_.EPA="",_.SOS="",_.SGCI="",_.SCI="",_.CSI="",_.ST="",_.OSC="",_.PM="",_.APC="",(ah||={}).ST=`${aa.ESC}\\`;var at=class{constructor(e,i,s,r,n,o){this._textarea=e,this._compositionView=i,this._bufferService=s,this._optionsService=r,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(20===e.keyCode||229===e.keyCode||16===e.keyCode||17===e.keyCode||18===e.keyCode)return!1;this._finalizeComposition(!1)}return 229!==e.keyCode||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){let i;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,(i=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start)).length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let i=this._textarea.value,s=i.replace(e,"");this._dataAlreadySent=s,i.length>e.length?this._coreService.triggerDataEvent(s,!0):i.length<e.length?this._coreService.triggerDataEvent(`${aa.DEL}`,!0):i.length===e.length&&i!==e&&this._coreService.triggerDataEvent(i,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};at=rS([ry(2,rH),ry(3,rU),ry(4,rW),ry(5,rQ)],at);var ai,as,ar,an,ao,aa,al,ah,ac,ad=0,au=0,af=0,a_=0,ap={css:"#00000000",rgba:0};(l0=ac||={}).toCss=function(e,i,s,r){return void 0!==r?`#${aw(e)}${aw(i)}${aw(s)}${aw(r)}`:`#${aw(e)}${aw(i)}${aw(s)}`},l0.toRgba=function(e,i,s,r=255){return(e<<24|i<<16|s<<8|r)>>>0},l0.toColor=function(e,i,s,r){return{css:l0.toCss(e,i,s,r),rgba:l0.toRgba(e,i,s,r)}};var ag=l1||={};function am(e,i){return a_=Math.round(255*i),[ad,au,af]=l3.toChannels(e.rgba),{css:ac.toCss(ad,au,af,a_),rgba:ac.toRgba(ad,au,af,a_)}}ag.blend=function(e,i){if(1==(a_=(255&i.rgba)/255))return{css:i.css,rgba:i.rgba};let s=i.rgba>>24&255,r=i.rgba>>16&255,n=i.rgba>>8&255,o=e.rgba>>24&255,a=e.rgba>>16&255,l=e.rgba>>8&255;return ad=o+Math.round((s-o)*a_),au=a+Math.round((r-a)*a_),af=l+Math.round((n-l)*a_),{css:ac.toCss(ad,au,af),rgba:ac.toRgba(ad,au,af)}},ag.isOpaque=function(e){return(255&e.rgba)==255},ag.ensureContrastRatio=function(e,i,s){let r=l3.ensureContrastRatio(e.rgba,i.rgba,s);if(r)return ac.toColor(r>>24&255,r>>16&255,r>>8&255)},ag.opaque=function(e){let i=(255|e.rgba)>>>0;return[ad,au,af]=l3.toChannels(i),{css:ac.toCss(ad,au,af),rgba:i}},ag.opacity=am,ag.multiplyOpacity=function(e,i){return a_=255&e.rgba,am(e,a_*i/255)},ag.toColorRGB=function(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]},(e=>{let i,s;try{let e=document.createElement("canvas");e.width=1,e.height=1;let r=e.getContext("2d",{willReadFrequently:!0});r&&((i=r).globalCompositeOperation="copy",s=i.createLinearGradient(0,0,1,1))}catch{}e.toColor=function(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return ad=parseInt(e.slice(1,2).repeat(2),16),au=parseInt(e.slice(2,3).repeat(2),16),af=parseInt(e.slice(3,4).repeat(2),16),ac.toColor(ad,au,af);case 5:return ad=parseInt(e.slice(1,2).repeat(2),16),au=parseInt(e.slice(2,3).repeat(2),16),af=parseInt(e.slice(3,4).repeat(2),16),a_=parseInt(e.slice(4,5).repeat(2),16),ac.toColor(ad,au,af,a_);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return ad=parseInt(r[1]),au=parseInt(r[2]),af=parseInt(r[3]),a_=Math.round((void 0===r[5]?1:parseFloat(r[5]))*255),ac.toColor(ad,au,af,a_);if(!i||!s||(i.fillStyle=s,i.fillStyle=e,"string"!=typeof i.fillStyle)||(i.fillRect(0,0,1,1),[ad,au,af,a_]=i.getImageData(0,0,1,1).data,255!==a_))throw Error("css.toColor: Unsupported css format");return{rgba:ac.toRgba(ad,au,af,a_),css:e}}})(l2||={});var av=l5||={};function ab(e,i,s){let r=e/255,n=i/255,o=s/255;return .2126*(r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}av.relativeLuminance=function(e){return ab(e>>16&255,e>>8&255,255&e)},av.relativeLuminance2=ab;var ax=l3||={};function aS(e,i,s){let r=e>>24&255,n=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,h=i>>8&255,c=aC(l5.relativeLuminance2(a,l,h),l5.relativeLuminance2(r,n,o));for(;c<s&&(a>0||l>0||h>0);)a-=Math.max(0,Math.ceil(.1*a)),l-=Math.max(0,Math.ceil(.1*l)),h-=Math.max(0,Math.ceil(.1*h)),c=aC(l5.relativeLuminance2(a,l,h),l5.relativeLuminance2(r,n,o));return(a<<24|l<<16|h<<8|255)>>>0}function ay(e,i,s){let r=e>>24&255,n=e>>16&255,o=e>>8&255,a=i>>24&255,l=i>>16&255,h=i>>8&255,c=aC(l5.relativeLuminance2(a,l,h),l5.relativeLuminance2(r,n,o));for(;c<s&&(a<255||l<255||h<255);)a=Math.min(255,a+Math.ceil((255-a)*.1)),l=Math.min(255,l+Math.ceil((255-l)*.1)),h=Math.min(255,h+Math.ceil((255-h)*.1)),c=aC(l5.relativeLuminance2(a,l,h),l5.relativeLuminance2(r,n,o));return(a<<24|l<<16|h<<8|255)>>>0}function aw(e){let i=e.toString(16);return i.length<2?"0"+i:i}function aC(e,i){return e<i?(i+.05)/(e+.05):(e+.05)/(i+.05)}ax.blend=function(e,i){if(1==(a_=(255&i)/255))return i;let s=e>>24&255,r=e>>16&255,n=e>>8&255;return ad=s+Math.round(((i>>24&255)-s)*a_),au=r+Math.round(((i>>16&255)-r)*a_),af=n+Math.round(((i>>8&255)-n)*a_),ac.toRgba(ad,au,af)},ax.ensureContrastRatio=function(e,i,s){let r=l5.relativeLuminance(e>>8),n=l5.relativeLuminance(i>>8);if(aC(r,n)<s){if(n<r){let n=aS(e,i,s),o=aC(r,l5.relativeLuminance(n>>8));if(o<s){let a=ay(e,i,s);return o>aC(r,l5.relativeLuminance(a>>8))?n:a}return n}let o=ay(e,i,s),a=aC(r,l5.relativeLuminance(o>>8));if(a<s){let n=aS(e,i,s);return a>aC(r,l5.relativeLuminance(n>>8))?o:n}return o}},ax.reduceLuminance=aS,ax.increaseLuminance=ay,ax.toChannels=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]};var ak=class extends rP{constructor(e,i,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=i,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},aE=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new rN}register(e){let i={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(i),i.id}deregister(e){for(let i=0;i<this._characterJoiners.length;i++)if(this._characterJoiners[i].id===e)return this._characterJoiners.splice(i,1),!0;return!1}getJoinedCharacters(e){if(0===this._characterJoiners.length)return[];let i=this._bufferService.buffer.lines.get(e);if(!i||0===i.length)return[];let s=[],r=i.translateToString(!0),n=0,o=0,a=0,l=i.getFg(0),h=i.getBg(0);for(let e=0;e<i.getTrimmedLength();e++)if(i.loadCell(e,this._workCell),0!==this._workCell.getWidth()){if(this._workCell.fg!==l||this._workCell.bg!==h){if(e-n>1){let e=this._getJoinedRanges(r,a,o,i,n);for(let i=0;i<e.length;i++)s.push(e[i])}n=e,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||1}if(this._bufferService.cols-n>1){let e=this._getJoinedRanges(r,a,o,i,n);for(let i=0;i<e.length;i++)s.push(e[i])}return s}_getJoinedRanges(e,i,s,r,n){let o=e.substring(i,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let e=1;e<this._characterJoiners.length;e++)try{let i=this._characterJoiners[e].handler(o);for(let e=0;e<i.length;e++)aE._mergeRanges(a,i[e])}catch(e){console.error(e)}return this._stringRangesToCellRanges(a,r,n),a}_stringRangesToCellRanges(e,i,s){let r=0,n=!1,o=0,a=e[0];if(a){for(let l=s;l<this._bufferService.cols;l++){let s=i.getWidth(l),h=i.getString(l).length||1;if(0!==s){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,!(a=e[++r]))break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,i){let s=!1;for(let r=0;r<e.length;r++){let n=e[r];if(s){if(i[1]<=n[0])return e[r-1][1]=i[1],e;if(i[1]<=n[1])return e[r-1][1]=Math.max(i[1],n[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(i[1]<=n[0])return e.splice(r,0,i),e;if(i[1]<=n[1])return n[0]=Math.min(i[0],n[0]),e;i[0]<n[1]&&(n[0]=Math.min(i[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=i[1]:e.push(i),e}};function aM(){return{width:0,height:0}}aE=rS([ry(0,rH)],aE);var aD=class{constructor(e,i,s,r,n,o,a){this._document=e,this._characterJoinerService=i,this._optionsService=s,this._coreBrowserService=r,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new rN,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,i,s){this._selectionStart=e,this._selectionEnd=i,this._columnSelectMode=s}createRow(e,i,s,r,n,o,a,l,h,c,d){let u=[],f=this._characterJoinerService.getJoinedCharacters(i),_=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<o+1&&(p=o+1);let g,m=0,v="",b=0,x=0,S=0,y=0,w=!1,C=0,k=!1,E=0,M=0,D=[],R=-1!==c&&-1!==d;for(let L=0;L<p;L++){let p;e.loadCell(L,this._workCell);let B=this._workCell.getWidth();if(0===B)continue;let P=!1,T=L>=M,N=L,I=this._workCell;if(f.length>0&&L===f[0][0]&&T){let r=f.shift(),n=this._isCellInSelection(r[0],i);for(b=r[0]+1;b<r[1];b++)T&&=n===this._isCellInSelection(b,i);(T&&=!s||o<r[0]||o>=r[1])?(P=!0,I=new ak(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),N=r[1]-1,B=I.getWidth()):M=r[1]}let j=this._isCellInSelection(L,i),A=s&&L===o,O=R&&L>=c&&L<=d,H=!1;this._decorationService.forEachDecorationAtCell(L,i,void 0,e=>{H=!0});let z=I.getChars()||" ";if(" "===z&&(I.isUnderline()||I.isOverline())&&(z=" "),E=B*l-h.get(z,I.isBold(),I.isItalic()),g)if(m&&(j&&k||!j&&!k&&I.bg===x)&&(j&&k&&_.selectionForeground||I.fg===S)&&I.extended.ext===y&&O===w&&E===C&&!A&&!P&&!H&&T){I.isInvisible()?v+=" ":v+=z,m++;continue}else m&&(g.textContent=v),g=this._document.createElement("span"),m=0,v="";else g=this._document.createElement("span");if(x=I.bg,S=I.fg,y=I.extended.ext,w=O,C=E,k=j,P&&o>=L&&o<=N&&(o=L),!this._coreService.isCursorHidden&&A&&this._coreService.isCursorInitialized){if(D.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&D.push("xterm-cursor-blink"),D.push("bar"===r?"xterm-cursor-bar":"underline"===r?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":D.push("xterm-cursor-outline");break;case"block":D.push("xterm-cursor-block");break;case"bar":D.push("xterm-cursor-bar");break;case"underline":D.push("xterm-cursor-underline")}}if(I.isBold()&&D.push("xterm-bold"),I.isItalic()&&D.push("xterm-italic"),I.isDim()&&D.push("xterm-dim"),v=I.isInvisible()?" ":I.getChars()||" ",I.isUnderline()&&(D.push(`xterm-underline-${I.extended.underlineStyle}`)," "===v&&(v=" "),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())g.style.textDecorationColor=`rgb(${rP.toColorRGB(I.getUnderlineColor()).join(",")})`;else{let e=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&e<8&&(e+=8),g.style.textDecorationColor=_.ansi[e].css}I.isOverline()&&(D.push("xterm-overline")," "===v&&(v=" ")),I.isStrikethrough()&&D.push("xterm-strikethrough"),O&&(g.style.textDecoration="underline");let W=I.getFgColor(),F=I.getFgColorMode(),$=I.getBgColor(),K=I.getBgColorMode(),U=!!I.isInverse();if(U){let e=W;W=$,$=e;let i=F;F=K,K=i}let q,V,Y=!1;switch(this._decorationService.forEachDecorationAtCell(L,i,void 0,e=>{"top"!==e.options.layer&&Y||(e.backgroundColorRGB&&(K=0x3000000,$=e.backgroundColorRGB.rgba>>8&0xffffff,q=e.backgroundColorRGB),e.foregroundColorRGB&&(F=0x3000000,W=e.foregroundColorRGB.rgba>>8&0xffffff,V=e.foregroundColorRGB),Y="top"===e.options.layer)}),!Y&&j&&($=(q=this._coreBrowserService.isFocused?_.selectionBackgroundOpaque:_.selectionInactiveBackgroundOpaque).rgba>>8&0xffffff,K=0x3000000,Y=!0,_.selectionForeground&&(F=0x3000000,W=_.selectionForeground.rgba>>8&0xffffff,V=_.selectionForeground)),Y&&D.push("xterm-decoration-top"),K){case 0x1000000:case 0x2000000:p=_.ansi[$],D.push(`xterm-bg-${$}`);break;case 0x3000000:p=ac.toColor($>>16,$>>8&255,255&$),this._addStyle(g,`background-color:#${aR(($>>>0).toString(16),"0",6)}`);break;default:U?(p=_.foreground,D.push("xterm-bg-257")):p=_.background}switch(q||I.isDim()&&(q=l1.multiplyOpacity(p,.5)),F){case 0x1000000:case 0x2000000:I.isBold()&&W<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(W+=8),this._applyMinimumContrast(g,p,_.ansi[W],I,q,void 0)||D.push(`xterm-fg-${W}`);break;case 0x3000000:let X=ac.toColor(W>>16&255,W>>8&255,255&W);this._applyMinimumContrast(g,p,X,I,q,V)||this._addStyle(g,`color:#${aR(W.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(g,p,_.foreground,I,q,V)||U&&D.push("xterm-fg-257")}D.length&&(g.className=D.join(" "),D.length=0),A||P||H||!T?g.textContent=v:m++,E!==this.defaultSpacing&&(g.style.letterSpacing=`${E}px`),u.push(g),L=N}return g&&m&&(g.textContent=v),u}_applyMinimumContrast(e,i,s,r,n,o){var a,l,h;if(1===this._optionsService.rawOptions.minimumContrastRatio||57508<=(l=a=r.getCode())&&l<=57558||9472<=(h=a)&&h<=9631)return!1;let c=this._getContrastCache(r),d;if(n||o||(d=c.getColor(i.rgba,s.rgba)),void 0===d){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);d=l1.ensureContrastRatio(n||i,o||s,e),c.setColor((n||i).rgba,(o||s).rgba,d??null)}return!!d&&(this._addStyle(e,`color:${d.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,i){e.setAttribute("style",`${e.getAttribute("style")||""}${i};`)}_isCellInSelection(e,i){let s=this._selectionStart,r=this._selectionEnd;return!!s&&!!r&&(this._columnSelectMode?s[0]<=r[0]?e>=s[0]&&i>=s[1]&&e<r[0]&&i<=r[1]:e<s[0]&&i>=s[1]&&e>=r[0]&&i<=r[1]:i>s[1]&&i<r[1]||s[1]===r[1]&&i===s[1]&&e>=s[0]&&e<r[0]||s[1]<r[1]&&i===r[1]&&e<r[0]||s[1]<r[1]&&i===s[1]&&e>=s[0])}};function aR(e,i,s){for(;e.length<s;)e=i+e;return e}aD=rS([ry(1,r1),ry(2,rU),ry(3,rJ),ry(4,rW),ry(5,rY),ry(6,r2)],aD);var aL=class{constructor(e,i){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,r,n,o],this._container.appendChild(s),this._container.appendChild(r),this._container.appendChild(n),this._container.appendChild(o),i.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,i,s,r){e===this._font&&i===this._fontSize&&s===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=i,this._weight=s,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,i,s){let r=0;if(!i&&!s&&1===e.length&&(r=e.charCodeAt(0))<256){if(-9999!==this._flat[r])return this._flat[r];let i=this._measure(e,0);return i>0&&(this._flat[r]=i),i}let n=e;i&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(void 0===o){let r=0;i&&(r|=1),s&&(r|=2),(o=this._measure(e,r))>0&&this._holey.set(n,o)}return o}_measure(e,i){let s=this._measureElements[i];return s.textContent=e.repeat(32),s.offsetWidth/32}},aB=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,i,s,r=!1){if(this.selectionStart=i,this.selectionEnd=s,!i||!s||i[0]===s[0]&&i[1]===s[1])return void this.clear();let n=e.buffers.active.ydisp,o=i[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);l>=e.rows||h<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=i[0],this.endCol=s[0])}isCellSelected(e,i,s){return!!this.hasSelection&&(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?i>=this.startCol&&s>=this.viewportCappedStartRow&&i<this.endCol&&s<=this.viewportCappedEndRow:i<this.startCol&&s>=this.viewportCappedStartRow&&i>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&i>=this.startCol&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&i<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&i>=this.startCol)}},aP="xterm-dom-renderer-owner-",aT="xterm-rows",aN="xterm-fg-",aI="xterm-bg-",aj="xterm-focus",aA="xterm-selection",aO=1,aH=class extends nl{constructor(e,i,s,r,n,o,a,l,h,c,d,u,f,_){super(),this._terminal=e,this._document=i,this._element=s,this._screenElement=r,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=u,this._coreBrowserService=f,this._themeService=_,this._terminalClass=aO++,this._rowElements=[],this._selectionRenderModel=new aB,this.onRequestRedraw=this._register(new nM).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(aT),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(aA),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions={css:{canvas:aM(),cell:aM()},device:{canvas:aM(),cell:aM(),char:{width:0,height:0,left:0,top:0}}},this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(aD,document),this._element.classList.add(aP+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(nn(()=>{this._element.classList.remove(aP+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new aL(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;for(let i of(this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows,this._rowElements))i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let i=`${this._terminalSelector} .${aT} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=i,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let i=`${this._terminalSelector} .${aT} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;i+=`${this._terminalSelector} .${aT} .xterm-dim { color: ${l1.multiplyOpacity(e.foreground,.5).css};}${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;for(let[o,a]of(i+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}@keyframes ${r} { 50% { box-shadow: none; }}@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}${this._terminalSelector} .${aT}.${aj} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${aT}.${aj} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${aT}.${aj} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${aT} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${aT} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${aT} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${aT} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${aT} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}${this._terminalSelector} .${aA} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${aA} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${aA} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`,e.ansi.entries()))i+=`${this._terminalSelector} .${aN}${o} { color: ${a.css}; }${this._terminalSelector} .${aN}${o}.xterm-dim { color: ${l1.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${aI}${o} { background-color: ${a.css}; }`;i+=`${this._terminalSelector} .${aN}257 { color: ${l1.opaque(e.background).css}; }${this._terminalSelector} .${aN}257.xterm-dim { color: ${l1.multiplyOpacity(l1.opaque(e.background),.5).css}; }${this._terminalSelector} .${aI}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=i}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,i){for(let e=this._rowElements.length;e<=i;e++){let e=this._document.createElement("div");this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>i;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,i){this._refreshRowElements(e,i),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(aj),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(aj),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,i,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,i,s),this.renderRows(0,this._bufferService.rows-1),!e||!i||(this._selectionRenderModel.update(this._terminal,e,i,s),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let s=e[0]>i[0];l.appendChild(this._createSelectionElement(o,s?i[0]:e[0],s?e[0]:i[0],a-o+1))}else{let s=r===o?e[0]:0,h=o===n?i[0]:this._bufferService.cols;if(l.appendChild(this._createSelectionElement(o,s,h)),l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,a-o-1)),o!==a){let e=n===a?i[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,e))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,i,s,r=1){let n=this._document.createElement("div"),o=i*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-i);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${r*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,i){let s=this._bufferService.buffer,r=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=i;h++){let e=h+s.ydisp,i=this._rowElements[h],c=s.lines.get(e);if(!i||!c)break;i.replaceChildren(...this._rowFactory.createRow(c,e,e===r,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${aP}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,i,s,r,n,o){s<0&&(e=0),r<0&&(i=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),r=Math.max(Math.min(r,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),d=this._optionsService.rawOptions.cursorBlink,u=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let a=s;a<=r;++a){let _=a+l.ydisp,p=this._rowElements[a],g=l.lines.get(_);if(!p||!g)break;p.replaceChildren(...this._rowFactory.createRow(g,_,_===h,u,f,c,d,this.dimensions.css.cell.width,this._widthCache,o?a===s?e:0:-1,o?(a===r?i:n)-1:-1))}}};aH=rS([ry(7,r$),ry(8,rG),ry(9,rU),ry(10,rH),ry(11,rW),ry(12,rJ),ry(13,r2)],aH);var az=class extends nl{constructor(e,i,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new nM),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new a$(this._optionsService))}catch{this._measureStrategy=this._register(new aF(e,i,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};az=rS([ry(2,rU)],az);var aW=class extends nl{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,i){void 0!==e&&e>0&&void 0!==i&&i>0&&(this._result.width=e,this._result.height=i)}},aF=class extends aW{constructor(e,i,s){super(),this._document=e,this._parentElement=i,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},a$=class extends aW{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let i=this._ctx.measureText("W");if(!("width"in i&&"fontBoundingBoxAscent"in i&&"fontBoundingBoxDescent"in i))throw Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},aK=class extends nl{constructor(e,i,s){super(),this._textarea=e,this._window=i,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new aU(this._window)),this._onDprChange=this._register(new nM),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new nM),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(nx.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(oB(this._textarea,"focus",()=>this._isFocused=!0)),this._register(oB(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return void 0===this._cachedIsFocused&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},aU=class extends nl{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new nh),this._onDprChange=this._register(new nM),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(nn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=oB(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},aq=class extends nl{constructor(){super(),this.linkProviders=[],this._register(nn(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let i=this.linkProviders.indexOf(e);-1!==i&&this.linkProviders.splice(i,1)}}}};function aV(e,i,s){let r=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[i.clientX-r.left-o,i.clientY-r.top-a]}var aY=class{constructor(e,i){this._renderService=e,this._charSizeService=i}getCoords(e,i,s,r,n){return function(e,i,s,r,n,o,a,l,h){if(!o)return;let c=aV(e,i,s);return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),r+ +!!h),c[1]=Math.min(Math.max(c[1],1),n),c}(window,e,i,s,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,i){let s=aV(window,e,i);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};aY=rS([ry(0,rQ),ry(1,rG)],aY);var aX=class{constructor(e,i){this._renderCallback=e,this._coreBrowserService=i,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,i,s){this._rowCount=s,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return void this._runRefreshCallbacks();let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},aG={},aJ={getSafariVersion:()=>a4,isChromeOS:()=>lt,isFirefox:()=>a2,isIpad:()=>a8,isIphone:()=>a7,isLegacyEdge:()=>a5,isLinux:()=>le,isMac:()=>a6,isNode:()=>aQ,isSafari:()=>a3,isWindows:()=>a9};for(var aZ in aJ)rb(aG,aZ,{get:aJ[aZ],enumerable:!0});var aQ="u">typeof rv.default&&"title"in rv.default,a0=aQ?"node":navigator.userAgent,a1=aQ?"node":navigator.platform,a2=a0.includes("Firefox"),a5=a0.includes("Edge"),a3=/^((?!chrome|android).)*safari/i.test(a0);function a4(){if(!a3)return 0;let e=a0.match(/Version\/(\d+)/);return null===e||e.length<2?0:parseInt(e[1])}var a6=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(a1),a8="iPad"===a1,a7="iPhone"===a1,a9=["Windows","Win16","Win32","WinCE"].includes(a1),le=a1.indexOf("Linux")>=0,lt=/\bCrOS\b/.test(a0),li=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let i=0,s=0,r=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(i=performance.now(),this._tasks[this._i]()||this._i++,1.5*(s=Math.max(i=Math.max(1,performance.now()-i),s))>(n=e.timeRemaining())){r-i<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-i))}ms`),this._start();return}r=n}this.clear()}},ls=class extends li{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let i=performance.now()+e;return{timeRemaining:()=>Math.max(0,i-performance.now())}}},lr=class extends li{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ln=!aQ&&"requestIdleCallback"in window?lr:ls,lo=class{constructor(){this._queue=new ln}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},la=class extends nl{constructor(e,i,s,r,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=r,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new nh),this._pausedResizeTask=new lo,this._observerDisposable=this._register(new nh),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new nM),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new nM),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new nM),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new nM),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new aX((e,i)=>this._renderRows(e,i),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new ll(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(nn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,i),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,i)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,i){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});s.observe(i),this._observerDisposable.value=nn(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=void 0===e.isIntersecting?0===e.intersectionRatio:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,i,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),i=Math.max(i,r.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,i,this._rowCount)}_renderRows(e,i){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput)return void this._syncOutputHandler.bufferRows(e,i);e=Math.min(e,this._rowCount-1),i=Math.min(i,this._rowCount-1),this._renderer.value.renderRows(e,i),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:i}),this._onRender.fire({start:e,end:i}),this._isNextRenderRedrawOnly=!0}}resize(e,i){this._rowCount=i,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,i){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,i)):this._renderer.value.handleResize(e,i),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,i,s){this._selectionState.start=e,this._selectionState.end=i,this._selectionState.columnSelectMode=s,this._renderer.value?.handleSelectionChanged(e,i,s)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};la=rS([ry(2,rU),ry(3,rG),ry(4,rW),ry(5,rY),ry(6,rH),ry(7,rJ),ry(8,r2)],la);var ll=class{constructor(e,i,s){this._coreBrowserService=e,this._coreService=i,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,i){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,i)):(this._start=e,this._end=i,this._isBuffering=!0),void 0===this._timeout&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){void 0!==this._timeout&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function lh(e,i,s,r){return lf(Math.abs(e-lc(e,s)-(i-lc(i,s)))-function(e,i,s){let r=0,n=e-lc(e,s),o=i-lc(i,s);for(let a=0;a<Math.abs(n-o);a++){let o="A"===function(e,i){return e>i?"A":"B"}(e,i)?-1:1;s.buffer.lines.get(n+o*a)?.isWrapped&&r++}return r}(e,i,s),lu(e>i?"A":"B",r))}function lc(e,i){let s=0,r=i.buffer.lines.get(e),n=r?.isWrapped;for(;n&&e>=0&&e<i.rows;)s++,r=i.buffer.lines.get(--e),n=r?.isWrapped;return s}function ld(e,i,s,r,n,o){let a=e,l=i,h="";for(;(a!==s||l!==r)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),e=a=o.cols-1,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function lu(e,i){return aa.ESC+(i?"O":"[")+e}function lf(e,i){e=Math.floor(e);let s="";for(let r=0;r<e;r++)s+=i;return s}var l_=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,i=this.selectionEnd;return!!e&&!!i&&(e[1]>i[1]||e[1]===i[1]&&e[0]>i[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function lp(e,i){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return i*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var lg=RegExp(" ","g"),lm=class extends nl{constructor(e,i,s,r,n,o,a,l,h){super(),this._element=e,this._screenElement=i,this._linkifier=s,this._bufferService=r,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new rN,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new nM),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new nM),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new nM),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new nM),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new l_(this._bufferService),this._activeSelectionMode=0,this._register(nn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1])}get selectionText(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;if(!e||!i)return"";let s=this._bufferService.buffer,r=[];if(3===this._activeSelectionMode){if(e[0]===i[0])return"";let n=e[0]<i[0]?e[0]:i[0],o=e[0]<i[0]?i[0]:e[0];for(let a=e[1];a<=i[1];a++){let e=s.translateBufferLineToString(a,!0,n,o);r.push(e)}}else{let n=e[1]===i[1]?i[0]:void 0;r.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let n=e[1]+1;n<=i[1]-1;n++){let e=s.lines.get(n),i=s.translateBufferLineToString(n,!0);e?.isWrapped?r[r.length-1]+=i:r.push(i)}if(e[1]!==i[1]){let e=s.lines.get(i[1]),n=s.translateBufferLineToString(i[1],!0,0,i[0]);e&&e.isWrapped?r[r.length-1]+=n:r.push(n)}}return r.map(e=>e.replace(lg," ")).join(a9?`\r
|
|
68
|
-
`:`
|
|
69
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),le&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:3===this._activeSelectionMode})}_isClickInSelection(e){let i=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!s&&!!r&&!!i&&this._areCoordsInSelection(i,s,r)}isCellInSelection(e,i){let s=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!!s&&!!r&&this._areCoordsInSelection([e,i],s,r)}_areCoordsInSelection(e,i,s){return e[1]>i[1]&&e[1]<s[1]||i[1]===s[1]&&e[1]===i[1]&&e[0]>=i[0]&&e[0]<s[0]||i[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||i[1]<s[1]&&e[1]===i[1]&&e[0]>=i[0]}_selectWordAtCursor(e,i){let s=this._linkifier.currentLink?.link?.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=lp(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return!!r&&(this._selectWordAt(r,i),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,i){this._model.clearSelection(),e=Math.max(e,0),i=Math.min(i,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,i],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let i=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(i)return i[0]--,i[1]--,i[1]+=this._bufferService.buffer.ydisp,i}_getMouseEventScrollAmount(e){let i=aV(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return i>=0&&i<=s?0:(i>s&&(i-=s),(i=Math.min(Math.max(i,-50),50)/50)/Math.abs(i)+Math.round(14*i))}shouldForceSelection(e){return a6?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(2===e.button&&this.hasSelection)&&0===e.button){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):1===e.detail?this._handleSingleClick(e):2===e.detail?this._handleDoubleClick(e):3===e.detail&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=3*!!this.shouldColumnSelect(e),this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let i=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);i&&i.length!==this._model.selectionStart[0]&&0===i.hasWidth(this._model.selectionStart[0])&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let i=this._getMouseBufferCoords(e);i&&(this._activeSelectionMode=2,this._selectLineAt(i[1]))}shouldColumnSelect(e){return e.altKey&&!(a6&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let i=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd)return void this.refresh(!0);2===this._activeSelectionMode?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:1===this._activeSelectionMode&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),3!==this._activeSelectionMode&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let e=s.lines.get(this._model.selectionEnd[1]);e&&0===e.hasWidth(this._model.selectionEnd[0])&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}i&&i[0]===this._model.selectionEnd[0]&&i[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(3!==this._activeSelectionMode&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let i=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&i<500&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&void 0!==i[0]&&void 0!==i[1]){let e=function(e,i,s,r){var n,o,a,l,h,c,d,u,f,_,p,g,m,v,b,x;let S,y=s.buffer.x,w=s.buffer.y;if(!s.buffer.hasScrollback){let x,S,C;return n=y,(0===lh(o=w,i,a=s,l=r).length?"":lf(ld(n,o,n,o-lc(o,a),!1,a).length,lu("D",l)))+lh(w,i,s,r)+(h=y,c=w,d=e,x=lh(c,u=i,f=s,_=r).length>0?u-lc(u,f):c,C=(p=h,g=c,S=lh(m=d,v=u,b=f,_).length>0?v-lc(v,b):g,p<m&&S<=v||p>=m&&S<v?"C":"D"),lf(ld(h,x,d,u,"C"===C,f).length,lu(C,_)))}if(w===i)return S=y>e?"D":"C",lf(Math.abs(y-e),lu(S,r));S=w>i?"D":"C";let C=Math.abs(w-i);return lf((x=w>i?e:y,s.cols-x+(C-1)*s.cols+1+((w>i?y:e)-1)),lu(S,r))}(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,i=this._model.finalSelectionEnd,s=!!e&&!!i&&(e[0]!==i[0]||e[1]!==i[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,i,s);return}!e||!i||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&i[0]===this._oldSelectionEnd[0]&&i[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,i,s)}_fireOnSelectionChange(e,i,s){this._oldSelectionStart=e,this._oldSelectionEnd=i,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,i){let s=i;for(let r=0;i>=r;r++){let n=e.loadCell(r,this._workCell).getChars().length;0===this._workCell.getWidth()?s--:n>1&&i!==r&&(s+=n-1)}return s}setSelection(e,i,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,i],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,i,s=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,d=0,u=0,f=0,_=0;if(" "===a.charAt(l)){for(;l>0&&" "===a.charAt(l-1);)l--;for(;h<a.length&&" "===a.charAt(h+1);)h++}else{let i=e[0],s=e[0];0===o.getWidth(i)&&(d++,i--),2===o.getWidth(s)&&(u++,s++);let r=o.getString(s).length;for(r>1&&(_+=r-1,h+=r-1);i>0&&l>0&&!this._isCharWordSeparator(o.loadCell(i-1,this._workCell));){o.loadCell(i-1,this._workCell);let e=this._workCell.getChars().length;0===this._workCell.getWidth()?(d++,i--):e>1&&(f+=e-1,l-=e-1),l--,i--}for(;s<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(s+1,this._workCell));){o.loadCell(s+1,this._workCell);let e=this._workCell.getChars().length;2===this._workCell.getWidth()?(u++,s++):e>1&&(_+=e-1,h+=e-1),h++,s++}}h++;let p=l+c-d+f,g=Math.min(this._bufferService.cols,h-l+d+u-f-_);if(!(!i&&""===a.slice(l,h).trim())){if(s&&0===p&&32!==o.getCodePoint(0)){let i=n.lines.get(e[1]-1);if(i&&o.isWrapped&&32!==i.getCodePoint(this._bufferService.cols-1)){let i=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(i){let e=this._bufferService.cols-i.start;p-=e,g+=e}}}if(r&&p+g===this._bufferService.cols&&32!==o.getCodePoint(this._bufferService.cols-1)){let i=n.lines.get(e[1]+1);if(i?.isWrapped&&32!==i.getCodePoint(0)){let i=this._getWordAt([0,e[1]+1],!1,!1,!0);i&&(g+=i.length)}}return{start:p,length:g}}}_selectWordAt(e,i){let s=this._getWordAt(e,i);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let i=this._getWordAt(e,!0);if(i){let s=e[1];for(;i.start<0;)i.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;i.start+i.length>this._bufferService.cols;)i.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?i.start:i.start+i.length,s]}}_isCharWordSeparator(e){return 0!==e.getWidth()&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let i=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:i.first},end:{x:this._bufferService.cols-1,y:i.last}};this._model.selectionStart=[0,i.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=lp(s,this._bufferService.cols)}};lm=rS([ry(3,rH),ry(4,rW),ry(5,rZ),ry(6,rU),ry(7,rQ),ry(8,rJ)],lm);var lv=class{constructor(){this._data={}}set(e,i,s){this._data[e]||(this._data[e]={}),this._data[e][i]=s}get(e,i){return this._data[e]?this._data[e][i]:void 0}clear(){this._data={}}},lb=class{constructor(){this._color=new lv,this._css=new lv}setCss(e,i,s){this._css.set(e,i,s)}getCss(e,i){return this._css.get(e,i)}setColor(e,i,s){this._color.set(e,i,s)}getColor(e,i){return this._color.get(e,i)}clear(){this._color.clear(),this._css.clear()}},lx=Object.freeze((()=>{let e=[l2.toColor("#2e3436"),l2.toColor("#cc0000"),l2.toColor("#4e9a06"),l2.toColor("#c4a000"),l2.toColor("#3465a4"),l2.toColor("#75507b"),l2.toColor("#06989a"),l2.toColor("#d3d7cf"),l2.toColor("#555753"),l2.toColor("#ef2929"),l2.toColor("#8ae234"),l2.toColor("#fce94f"),l2.toColor("#729fcf"),l2.toColor("#ad7fa8"),l2.toColor("#34e2e2"),l2.toColor("#eeeeec")],i=[0,95,135,175,215,255];for(let s=0;s<216;s++){let r=i[s/36%6|0],n=i[s/6%6|0],o=i[s%6];e.push({css:ac.toCss(r,n,o),rgba:ac.toRgba(r,n,o)})}for(let i=0;i<24;i++){let s=8+10*i;e.push({css:ac.toCss(s,s,s),rgba:ac.toRgba(s,s,s)})}return e})()),lS=l2.toColor("#ffffff"),ly=l2.toColor("#000000"),lw=l2.toColor("#ffffff"),lC={css:"rgba(255, 255, 255, 0.3)",rgba:0xffffff4d},lk=class extends nl{constructor(e){super(),this._optionsService=e,this._contrastCache=new lb,this._halfContrastCache=new lb,this._onChangeColors=this._register(new nM),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:lS,background:ly,cursor:lw,cursorAccent:ly,selectionForeground:void 0,selectionBackgroundTransparent:lC,selectionBackgroundOpaque:l1.blend(ly,lC),selectionInactiveBackgroundTransparent:lC,selectionInactiveBackgroundOpaque:l1.blend(ly,lC),scrollbarSliderBackground:l1.opacity(lS,.2),scrollbarSliderHoverBackground:l1.opacity(lS,.4),scrollbarSliderActiveBackground:l1.opacity(lS,.5),overviewRulerBorder:lS,ansi:lx.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let i=this._colors;if(i.foreground=lE(e.foreground,lS),i.background=lE(e.background,ly),i.cursor=l1.blend(i.background,lE(e.cursor,lw)),i.cursorAccent=l1.blend(i.background,lE(e.cursorAccent,ly)),i.selectionBackgroundTransparent=lE(e.selectionBackground,lC),i.selectionBackgroundOpaque=l1.blend(i.background,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundTransparent=lE(e.selectionInactiveBackground,i.selectionBackgroundTransparent),i.selectionInactiveBackgroundOpaque=l1.blend(i.background,i.selectionInactiveBackgroundTransparent),i.selectionForeground=e.selectionForeground?lE(e.selectionForeground,ap):void 0,i.selectionForeground===ap&&(i.selectionForeground=void 0),l1.isOpaque(i.selectionBackgroundTransparent)&&(i.selectionBackgroundTransparent=l1.opacity(i.selectionBackgroundTransparent,.3)),l1.isOpaque(i.selectionInactiveBackgroundTransparent)&&(i.selectionInactiveBackgroundTransparent=l1.opacity(i.selectionInactiveBackgroundTransparent,.3)),i.scrollbarSliderBackground=lE(e.scrollbarSliderBackground,l1.opacity(i.foreground,.2)),i.scrollbarSliderHoverBackground=lE(e.scrollbarSliderHoverBackground,l1.opacity(i.foreground,.4)),i.scrollbarSliderActiveBackground=lE(e.scrollbarSliderActiveBackground,l1.opacity(i.foreground,.5)),i.overviewRulerBorder=lE(e.overviewRulerBorder,lS),i.ansi=lx.slice(),i.ansi[0]=lE(e.black,lx[0]),i.ansi[1]=lE(e.red,lx[1]),i.ansi[2]=lE(e.green,lx[2]),i.ansi[3]=lE(e.yellow,lx[3]),i.ansi[4]=lE(e.blue,lx[4]),i.ansi[5]=lE(e.magenta,lx[5]),i.ansi[6]=lE(e.cyan,lx[6]),i.ansi[7]=lE(e.white,lx[7]),i.ansi[8]=lE(e.brightBlack,lx[8]),i.ansi[9]=lE(e.brightRed,lx[9]),i.ansi[10]=lE(e.brightGreen,lx[10]),i.ansi[11]=lE(e.brightYellow,lx[11]),i.ansi[12]=lE(e.brightBlue,lx[12]),i.ansi[13]=lE(e.brightMagenta,lx[13]),i.ansi[14]=lE(e.brightCyan,lx[14]),i.ansi[15]=lE(e.brightWhite,lx[15]),e.extendedAnsi){let s=Math.min(i.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<s;r++)i.ansi[r+16]=lE(e.extendedAnsi[r],lx[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(void 0===e){for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function lE(e,i){if(void 0!==e)try{return l2.toColor(e)}catch{}return i}lk=rS([ry(0,rU)],lk);var lM=class{constructor(...e){for(let[i,s]of(this._entries=new Map,e))this.set(i,s)}set(e,i){let s=this._entries.get(e);return this._entries.set(e,i),s}forEach(e){for(let[i,s]of this._entries.entries())e(i,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},lD=class{constructor(){this._services=new lM,this._services.set(r$,this)}setService(e,i){this._services.set(e,i)}getService(e){return this._services.get(e)}createInstance(e,...i){let s=(e[rj]||[]).sort((e,i)=>e.index-i.index),r=[];for(let i of s){let s=this._services.get(i.id);if(!s)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${i.id._id}.`);r.push(s)}let n=s.length>0?s[0].index:i.length;if(i.length!==n)throw Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${i.length} static arguments`);return new e(...i,...r)}},lR={trace:0,debug:1,info:2,warn:3,error:4,off:5},lL=class extends nl{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=lR[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let i=0;i<e.length;i++)"function"==typeof e[i]&&(e[i]=e[i]())}_log(e,i,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+i,...s)}trace(e,...i){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,i)}debug(e,...i){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,i)}info(e,...i){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,i)}warn(e,...i){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,i)}error(e,...i){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,i)}};lL=rS([ry(0,rU)],lL);var lB=class extends nl{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new nM),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new nM),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new nM),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let i=Array(e);for(let s=0;s<Math.min(e,this.length);s++)i[s]=this._array[this._getCyclicIndex(s)];this._array=i,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let i=this._length;i<e;i++)this._array[i]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,i){this._array[this._getCyclicIndex(e)]=i}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,i,...s){if(i){for(let s=e;s<this._length-i;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+i)];this._length-=i,this.onDeleteEmitter.fire({index:e,amount:i})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let e=this._length+s.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,i,s){if(!(i<=0)){if(e<0||e>=this._length)throw Error("start argument out of range");if(e+s<0)throw Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=i-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let r=e+i+s-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<i;r++)this.set(e+r+s,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},lP=Object.freeze(new rP),lT=0,lN=class e{constructor(e,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*e);let r=i||rN.fromCharData([0,"",1,0]);for(let i=0;i<e;++i)this.setCell(i,r);this.length=e}get(e){let i=this._data[3*e+0],s=2097151&i;return[this._data[3*e+1],2097152&i?this._combined[e]:s?rD(s):"",i>>22,2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):s]}set(e,i){this._data[3*e+1]=i[0],i[1].length>1?(this._combined[e]=i[1],this._data[3*e+0]=2097152|e|i[2]<<22):this._data[3*e+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(e){return this._data[3*e+0]>>22}hasWidth(e){return 0xc00000&this._data[3*e+0]}getFg(e){return this._data[3*e+1]}getBg(e){return this._data[3*e+2]}hasContent(e){return 4194303&this._data[3*e+0]}getCodePoint(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e].charCodeAt(this._combined[e].length-1):2097151&i}isCombined(e){return 2097152&this._data[3*e+0]}getString(e){let i=this._data[3*e+0];return 2097152&i?this._combined[e]:2097151&i?rD(2097151&i):""}isProtected(e){return 0x20000000&this._data[3*e+2]}loadCell(e,i){return lT=3*e,i.content=this._data[lT+0],i.fg=this._data[lT+1],i.bg=this._data[lT+2],2097152&i.content&&(i.combinedData=this._combined[e]),0x10000000&i.bg&&(i.extended=this._extendedAttrs[e]),i}setCell(e,i){2097152&i.content&&(this._combined[e]=i.combinedData),0x10000000&i.bg&&(this._extendedAttrs[e]=i.extended),this._data[3*e+0]=i.content,this._data[3*e+1]=i.fg,this._data[3*e+2]=i.bg}setCellFromCodepoint(e,i,s,r){0x10000000&r.bg&&(this._extendedAttrs[e]=r.extended),this._data[3*e+0]=i|s<<22,this._data[3*e+1]=r.fg,this._data[3*e+2]=r.bg}addCodepointToCell(e,i,s){let r=this._data[3*e+0];2097152&r?this._combined[e]+=rD(i):2097151&r?(this._combined[e]=rD(2097151&r)+rD(i),r&=-2097152,r|=2097152):r=4194304|i,s&&(r&=-0xc00001,r|=s<<22),this._data[3*e+0]=r}insertCells(e,i,s){if((e%=this.length)&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length-e){let r=new rN;for(let s=this.length-e-i-1;s>=0;--s)this.setCell(e+i+s,this.loadCell(e+s,r));for(let r=0;r<i;++r)this.setCell(e+r,s)}else for(let i=e;i<this.length;++i)this.setCell(i,s);2===this.getWidth(this.length-1)&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(e,i,s){if(e%=this.length,i<this.length-e){let r=new rN;for(let s=0;s<this.length-e-i;++s)this.setCell(e+s,this.loadCell(e+i+s,r));for(let e=this.length-i;e<this.length;++e)this.setCell(e,s)}else for(let i=e;i<this.length;++i)this.setCell(i,s);e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),0!==this.getWidth(e)||this.hasContent(e)||this.setCellFromCodepoint(e,0,1,s)}replaceCells(e,i,s,r=!1){if(r){for(e&&2===this.getWidth(e-1)&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&2===this.getWidth(i-1)&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.isProtected(e)||this.setCell(e,s),e++;return}for(e&&2===this.getWidth(e-1)&&this.setCellFromCodepoint(e-1,0,1,s),i<this.length&&2===this.getWidth(i-1)&&this.setCellFromCodepoint(i,0,1,s);e<i&&e<this.length;)this.setCell(e++,s)}resize(e,i){if(e===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;let s=3*e;if(e>this.length){if(this._data.buffer.byteLength>=4*s)this._data=new Uint32Array(this._data.buffer,0,s);else{let e=new Uint32Array(s);e.set(this._data),this._data=e}for(let s=this.length;s<e;++s)this.setCell(s,i)}else{this._data=this._data.subarray(0,s);let i=Object.keys(this._combined);for(let s=0;s<i.length;s++){let r=parseInt(i[s],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let i=0;i<r.length;i++){let s=parseInt(r[i],10);s>=e&&delete this._extendedAttrs[s]}}return this.length=e,4*s*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,i=!1){if(i){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,e);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,e)}copyFrom(e){for(let i in this.length!==e.length?this._data=new Uint32Array(e._data):this._data.set(e._data),this.length=e.length,this._combined={},e._combined)this._combined[i]=e._combined[i];for(let i in this._extendedAttrs={},e._extendedAttrs)this._extendedAttrs[i]=e._extendedAttrs[i];this.isWrapped=e.isWrapped}clone(){let i=new e(0);for(let e in i._data=new Uint32Array(this._data),i.length=this.length,this._combined)i._combined[e]=this._combined[e];for(let e in this._extendedAttrs)i._extendedAttrs[e]=this._extendedAttrs[e];return i.isWrapped=this.isWrapped,i}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0])return e+(this._data[3*e+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(4194303&this._data[3*e+0]||0x3000000&this._data[3*e+2])return e+(this._data[3*e+0]>>22);return 0}copyCellsFrom(e,i,s,r,n){let o=e._data;if(n)for(let n=r-1;n>=0;n--){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=o[(i+n)*3+e];0x10000000&o[(i+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[i+n])}else for(let n=0;n<r;n++){for(let e=0;e<3;e++)this._data[(s+n)*3+e]=o[(i+n)*3+e];0x10000000&o[(i+n)*3+2]&&(this._extendedAttrs[s+n]=e._extendedAttrs[i+n])}let a=Object.keys(e._combined);for(let r=0;r<a.length;r++){let n=parseInt(a[r],10);n>=i&&(this._combined[n-i+s]=e._combined[n])}}translateToString(e,i,s,r){i=i??0,s=s??this.length,e&&(s=Math.min(s,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;i<s;){let e=this._data[3*i+0],s=2097151&e,o=2097152&e?this._combined[i]:s?rD(s):" ";if(n+=o,r)for(let e=0;e<o.length;++e)r.push(i);i+=e>>22||1}return r&&r.push(i),n}};function lI(e,i,s){if(i===e.length-1)return e[i].getTrimmedLength();let r=!e[i].hasContent(s-1)&&1===e[i].getWidth(s-1),n=2===e[i+1].getWidth(0);return r&&n?s-1:s}var lj=class e{constructor(i){this.line=i,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new nM),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),nr(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};lj._nextId=1;var lA={},lO=lA.B;lA[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},lA.A={"#":"£"},lA.B=void 0,lA[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},lA.C=lA[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},lA.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},lA.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},lA.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},lA.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},lA.E=lA[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},lA.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},lA.H=lA[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},lA["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var lH=class{constructor(e,i,s){this._hasScrollback=e,this._optionsService=i,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=lP.clone(),this.savedCharset=lO,this.markers=[],this._nullCell=rN.fromCharData([0,"",1,0]),this._whitespaceCell=rN.fromCharData([0," ",1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ln,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new lB(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new rT),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new rT),this._whitespaceCell}getBlankLine(e,i){return new lN(this._bufferService.cols,this.getNullCell(e),i)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let i=e+this._optionsService.rawOptions.scrollback;return i>0xffffffff?0xffffffff:i}fillViewportRows(e){if(0===this.lines.length){void 0===e&&(e=lP);let i=this._rows;for(;i--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new lB(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,i){let s=this.getNullCell(lP),r=0,n=this._getCorrectBufferLength(i);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let i=0;i<this.lines.length;i++)r+=+this.lines.get(i).resize(e,s);let o=0;if(this._rows<i)for(let r=this._rows;r<i;r++)this.lines.length<i+this.ybase&&(this._optionsService.rawOptions.windowsMode||void 0!==this._optionsService.rawOptions.windowsPty.backend||void 0!==this._optionsService.rawOptions.windowsPty.buildNumber?this.lines.push(new lN(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new lN(e,s)));else for(let e=this._rows;e>i;e--)this.lines.length>i+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let e=this.lines.length-n;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,i-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=i-1,this._isReflowEnabled&&(this._reflow(e,i),this._cols>e))for(let i=0;i<this.lines.length;i++)r+=+this.lines.get(i).resize(e,s);this._cols=e,this._rows=i,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let i=0;for(;this._memoryCleanupPosition<this.lines.length;)if((i+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory())>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&"conpty"===e.backend&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,i){this._cols!==e&&(e>this._cols?this._reflowLarger(e,i):this._reflowSmaller(e,i))}_reflowLarger(e,i){let s=this._optionsService.rawOptions.reflowCursorLine,r=function(e,i,s,r,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let d=[e.get(l)];for(;h<e.length&&c.isWrapped;)d.push(c),c=e.get(++h);if(!o&&r>=l&&r<h){l+=d.length-1;continue}let u=0,f=lI(d,0,i),_=1,p=0;for(;_<d.length;){let e=lI(d,_,i),r=Math.min(e-p,s-f);d[u].copyCellsFrom(d[_],p,f,r,!1),(f+=r)===s&&(u++,f=0),(p+=r)===e&&(_++,p=0),0===f&&0!==u&&2===d[u-1].getWidth(s-1)&&(d[u].copyCellsFrom(d[u-1],s-1,f++,1,!1),d[u-1].setCell(s-1,n))}d[u].replaceCells(f,s,n);let g=0;for(let e=d.length-1;e>0&&(e>u||0===d[e].getTrimmedLength());e--)g++;g>0&&(a.push(l+d.length-g),a.push(g)),l+=d.length-1}return a}(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(lP),s);if(r.length>0){let s=function(e,i){let s=[],r=0,n=i[0],o=0;for(let a=0;a<e.length;a++)if(n===a){let s=i[++r];e.onDeleteEmitter.fire({index:a-o,amount:s}),a+=s-1,o+=s,n=i[++r]}else s.push(a);return{layout:s,countRemoved:o}}(this.lines,r);(function(e,i){let s=[];for(let r=0;r<i.length;r++)s.push(e.get(i[r]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=i.length})(this.lines,s.layout),this._reflowLargerAdjustViewport(e,i,s.countRemoved)}}_reflowLargerAdjustViewport(e,i,s){let r=this.getNullCell(lP),n=s;for(;n-- >0;)0===this.ybase?(this.y>0&&this.y--,this.lines.length<i&&this.lines.push(new lN(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,i){let s=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(lP),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let e=this.ybase+this.y;if(e>=a&&e<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=function(e,i,s){let r=[],n=e.map((s,r)=>lI(e,r,i)).reduce((e,i)=>e+i),o=0,a=0,l=0;for(;l<n;){if(n-l<s){r.push(n-l);break}o+=s;let h=lI(e,a,i);o>h&&(o-=h,a++);let c=2===e[a].getWidth(o-1);c&&o--;let d=c?s-1:s;r.push(d),l+=d}return r}(h,this._cols,e),u=d.length-h.length,f;f=0===this.ybase&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+u):Math.max(0,this.lines.length-this.lines.maxLength+u);let _=[];for(let e=0;e<u;e++){let e=this.getBlankLine(lP,!0);_.push(e)}_.length>0&&(n.push({start:a+h.length+o,newLines:_}),o+=_.length),h.push(..._);let p=d.length-1,g=d[p];0===g&&(g=d[--p]);let m=h.length-u-1,v=c;for(;m>=0;){let e=Math.min(v,g);if(void 0===h[p])break;h[p].copyCellsFrom(h[m],v-e,g-e,e,!0),0==(g-=e)&&(g=d[--p]),0==(v-=e)&&(v=lI(h,Math.max(--m,0),this._cols))}for(let i=0;i<h.length;i++)d[i]<e&&h[i].setCell(d[i],r);let b=u-f;for(;b-- >0;)0===this.ybase?this.y<i-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-i&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+u,this.ybase+i-1)}if(n.length>0){let e=[],i=[];for(let e=0;e<this.lines.length;e++)i.push(this.lines.get(e));let s=this.lines.length,r=s-1,a=0,l=n[0];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let h=0;for(let c=Math.min(this.lines.maxLength-1,s+o-1);c>=0;c--)if(l&&l.start>r+h){for(let e=l.newLines.length-1;e>=0;e--)this.lines.set(c--,l.newLines[e]);c++,e.push({index:r+1,amount:l.newLines.length}),h+=l.newLines.length,l=n[++a]}else this.lines.set(c,i[r--]);let c=0;for(let i=e.length-1;i>=0;i--)e[i].index+=c,this.lines.onInsertEmitter.fire(e[i]),c+=e[i].amount;let d=Math.max(0,s+o-this.lines.maxLength);d>0&&this.lines.onTrimEmitter.fire(d)}}translateBufferLineToString(e,i,s=0,r){let n=this.lines.get(e);return n?n.translateToString(i,s,r):""}getWrappedRangeForLine(e){let i=e,s=e;for(;i>0&&this.lines.get(i).isWrapped;)i--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:i,last:s}}setupTabStops(e){for(null!=e?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(null==e&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(null==e&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let i=0;i<this.markers.length;i++)this.markers[i].line===e&&(this.markers[i].dispose(),this.markers.splice(i--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let i=new lj(e);return this.markers.push(i),i.register(this.lines.onTrim(e=>{i.line-=e,i.line<0&&i.dispose()})),i.register(this.lines.onInsert(e=>{i.line>=e.index&&(i.line+=e.amount)})),i.register(this.lines.onDelete(e=>{i.line>=e.index&&i.line<e.index+e.amount&&i.dispose(),i.line>e.index&&(i.line-=e.amount)})),i.register(i.onDispose(()=>this._removeMarker(i))),i}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},lz=class extends nl{constructor(e,i){super(),this._optionsService=e,this._bufferService=i,this._onBufferActivate=this._register(new nM),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new lH(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new lH(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,i){this._normal.resize(e,i),this._alt.resize(e,i),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},lW=class extends nl{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new nM),this.onResize=this._onResize.event,this._onScroll=this._register(new nM),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,2),this.rows=Math.max(e.rawOptions.rows||0,1),this.buffers=this._register(new lz(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,i){let s=this.cols!==e,r=this.rows!==i;this.cols=e,this.rows=i,this.buffers.resize(e,i),this._onResize.fire({cols:e,rows:i,colsChanged:s,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,i=!1){let s=this.buffer,r;(r=this._cachedBlankLine)&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=s.getBlankLine(e,i),this._cachedBlankLine=r),r.isWrapped=i;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(0===s.scrollTop){let e=s.lines.isFull;o===s.lines.length-1?e?s.lines.recycle().copyFrom(r):s.lines.push(r.clone()):s.lines.splice(o+1,0,r.clone()),e?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let e=o-n+1;s.lines.shiftElements(n+1,e-1,-1),s.lines.set(o,r.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,i){let s=this.buffer;if(e<0){if(0===s.ydisp)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let r=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),r!==s.ydisp&&(i||this._onScroll.fire(s.ydisp))}};lW=rS([ry(0,rU)],lW);var lF={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:a6,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},l$=["normal","bold","100","200","300","400","500","600","700","800","900"],lK=class extends nl{constructor(e){super(),this._onOptionChange=this._register(new nM),this.onOptionChange=this._onOptionChange.event;let i={...lF};for(let s in e)if(s in i)try{let r=e[s];i[s]=this._sanitizeAndValidateOption(s,r)}catch(e){console.error(e)}this.rawOptions=i,this.options={...i},this._setupOptions(),this._register(nn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,i){return this.onOptionChange(s=>{s===e&&i(this.rawOptions[e])})}onMultipleOptionChange(e,i){return this.onOptionChange(s=>{-1!==e.indexOf(s)&&i()})}_setupOptions(){let e=e=>{if(!(e in lF))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},i=(e,i)=>{if(!(e in lF))throw Error(`No option with key "${e}"`);i=this._sanitizeAndValidateOption(e,i),this.rawOptions[e]!==i&&(this.rawOptions[e]=i,this._onOptionChange.fire(e))};for(let s in this.rawOptions){let r={get:e.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this.options,s,r)}}_sanitizeAndValidateOption(e,i){switch(e){case"cursorStyle":var s;if(i||(i=lF[e]),"block"!==(s=i)&&"underline"!==s&&"bar"!==s)throw Error(`"${i}" is not a valid value for ${e}`);break;case"wordSeparator":i||(i=lF[e]);break;case"fontWeight":case"fontWeightBold":if("number"==typeof i&&1<=i&&i<=1e3)break;i=l$.includes(i)?i:lF[e];break;case"cursorWidth":i=Math.floor(i);case"lineHeight":case"tabStopWidth":if(i<1)throw Error(`${e} cannot be less than 1, value: ${i}`);break;case"minimumContrastRatio":i=Math.max(1,Math.min(21,Math.round(10*i)/10));break;case"scrollback":if((i=Math.min(i,0xffffffff))<0)throw Error(`${e} cannot be less than 0, value: ${i}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(i<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${i}`);break;case"rows":case"cols":if(!i&&0!==i)throw Error(`${e} must be numeric, value: ${i}`);break;case"windowsPty":i=i??{}}return i}};function lU(e,i=5){if("object"!=typeof e)return e;let s=Array.isArray(e)?[]:{};for(let r in e)s[r]=i<=1?e[r]:e[r]&&lU(e[r],i-1);return s}var lq=Object.freeze({insertMode:!1}),lV=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),lY=class extends nl{constructor(e,i,s){super(),this._bufferService=e,this._logService=i,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new nM),this.onData=this._onData.event,this._onUserInput=this._register(new nM),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new nM),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new nM),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=lU(lq),this.decPrivateModes=lU(lV)}reset(){this.modes=lU(lq),this.decPrivateModes=lU(lV)}triggerDataEvent(e,i=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;i&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),i&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};lY=rS([ry(0,rH),ry(1,rK),ry(2,rU)],lY);var lX={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>4!==e.button&&1===e.action&&(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>32!==e.action},DRAG:{events:23,restrict:e=>32!==e.action||3!==e.button},ANY:{events:31,restrict:e=>!0}};function lG(e,i){let s=16*!!e.ctrl|4*!!e.shift|8*!!e.alt;return 4===e.button?(s|=64,s|=e.action):(s|=3&e.button,4&e.button&&(s|=64),8&e.button&&(s|=128),32===e.action?s|=32:0!==e.action||i||(s|=3)),s}var lJ=String.fromCharCode,lZ={DEFAULT:e=>{let i=[lG(e,!1)+32,e.col+32,e.row+32];return i[0]>255||i[1]>255||i[2]>255?"":`\x1b[M${lJ(i[0])}${lJ(i[1])}${lJ(i[2])}`},SGR:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${lG(e,!0)};${e.col};${e.row}${i}`},SGR_PIXELS:e=>{let i=0===e.action&&4!==e.button?"m":"M";return`\x1b[<${lG(e,!0)};${e.x};${e.y}${i}`}},lQ=class extends nl{constructor(e,i,s){for(let r of(super(),this._bufferService=e,this._coreService=i,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new nM),this.onProtocolChange=this._onProtocolChange.event,Object.keys(lX)))this.addProtocol(r,lX[r]);for(let e of Object.keys(lZ))this.addEncoding(e,lZ[e]);this.reset()}addProtocol(e,i){this._protocols[e]=i}addEncoding(e,i){this._encodings[e]=i}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return 0!==this._protocols[this._activeProtocol].events}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,i,s){if(0===e.deltaY||e.shiftKey||void 0===i||void 0===s)return 0;let r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i/s+0,50>Math.abs(e.deltaY)&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,i){return i.altKey||i.ctrlKey||i.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||4===e.button&&32===e.action||3===e.button&&32!==e.action||4!==e.button&&(2===e.action||3===e.action)||(e.col++,e.row++,32===e.action&&this._lastEvent&&this._equalEvents(this._lastEvent,e,"SGR_PIXELS"===this._activeEncoding))||!this._protocols[this._activeProtocol].restrict(e))return!1;let i=this._encodings[this._activeEncoding](e);return i&&("DEFAULT"===this._activeEncoding?this._coreService.triggerBinaryEvent(i):this._coreService.triggerDataEvent(i,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(1&e),up:!!(2&e),drag:!!(4&e),move:!!(8&e),wheel:!!(16&e)}}_equalEvents(e,i,s){if(s){if(e.x!==i.x||e.y!==i.y)return!1}else if(e.col!==i.col||e.row!==i.row)return!1;return e.button===i.button&&e.action===i.action&&e.ctrl===i.ctrl&&e.alt===i.alt&&e.shift===i.shift}};lQ=rS([ry(0,rH),ry(1,rW),ry(2,rU)],lQ);var l0,l1,l2,l5,l3,l4,l6=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],l8=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],l7=class{constructor(){if(this.version="6",!l4){(l4=new Uint8Array(65536)).fill(1),l4[0]=0,l4.fill(0,1,32),l4.fill(0,127,160),l4.fill(2,4352,4448),l4[9001]=2,l4[9002]=2,l4.fill(2,11904,42192),l4[12351]=1,l4.fill(2,44032,55204),l4.fill(2,63744,64256),l4.fill(2,65040,65050),l4.fill(2,65072,65136),l4.fill(2,65280,65377),l4.fill(2,65504,65511);for(let e=0;e<l6.length;++e)l4.fill(0,l6[e][0],l6[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?l4[e]:!function(e,i){let s=0,r=i.length-1,n;if(e<i[0][0]||e>i[r][1])return!1;for(;r>=s;)if(e>i[n=s+r>>1][1])s=n+1;else{if(!(e<i[n][0]))return!0;r=n-1}return!1}(e,l8)?e>=131072&&e<=196605||e>=196608&&e<=262141?2:1:0}charProperties(e,i){let s=this.wcwidth(e),r=0===s&&0!==i;if(r){let e=l9.extractWidth(i);0===e?r=!1:e>s&&(s=e)}return l9.createPropertyValue(0,s,r)}},l9=class e{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new nM,this.onChange=this._onChange.event;let e=new l7;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return(1&e)!=0}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,i,s=!1){return(0xffffff&e)<<3|(3&i)<<1|!!s}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(i){let s=0,r=0,n=i.length;for(let o=0;o<n;++o){let a=i.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let e=i.charCodeAt(o);56320<=e&&e<=57343?a=(a-55296)*1024+e-56320+65536:s+=this.wcwidth(e)}let l=this.charProperties(a,r),h=e.extractWidth(l);e.extractShouldJoin(l)&&(h-=e.extractWidth(r)),s+=h,r=l}return s}charProperties(e,i){return this._activeProvider.charProperties(e,i)}},he=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,i){this._charsets[e]=i,this.glevel===e&&(this.charset=i)}};function ht(e){let i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&i&&(s.isWrapped=0!==i[3]&&32!==i[3])}var hi=class e{constructor(e=32,i=32){if(this.maxLength=e,this.maxSubParamsLength=i,i>256)throw Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(i){let s=new e;if(!i.length)return s;for(let e=+!!Array.isArray(i[0]);e<i.length;++e){let r=i[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)s.addSubParam(r[e]);else s.addParam(r)}return s}clone(){let i=new e(this.maxLength,this.maxSubParamsLength);return i.params.set(this.params),i.length=this.length,i._subParams.set(this._subParams),i._subParamsLength=this._subParamsLength,i._subParamsIdx.set(this._subParamsIdx),i._rejectDigits=this._rejectDigits,i._rejectSubDigits=this._rejectSubDigits,i._digitIsSub=this._digitIsSub,i}toArray(){let e=[];for(let i=0;i<this.length;++i){e.push(this.params[i]);let s=this._subParamsIdx[i]>>8,r=255&this._subParamsIdx[i];r-s>0&&e.push(Array.prototype.slice.call(this._subParams,s,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>0x7fffffff?0x7fffffff:e}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=e>0x7fffffff?0x7fffffff:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(255&this._subParamsIdx[e])-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let i=this._subParamsIdx[e]>>8,s=255&this._subParamsIdx[e];return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let e={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,r=255&this._subParamsIdx[i];r-s>0&&(e[i]=this._subParams.slice(s,r))}return e}addDigit(e){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,r=s[i-1];s[i-1]=~r?Math.min(10*r+e,0x7fffffff):e}},hs=[],hr=class{constructor(){this._state=0,this._active=hs,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(i),{dispose:()=>{let e=s.indexOf(i);-1!==e&&s.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=hs}reset(){if(2===this._state)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=hs,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||hs,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].start();else this._handlerFb(this._id,"START")}_put(e,i,s){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,s);else this._handlerFb(this._id,"PUT",rR(e,i,s))}start(){this.reset(),this._state=1}put(e,i,s){if(3!==this._state){if(1===this._state)for(;i<s;){let s=e[i++];if(59===s){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}-1===this._id&&(this._id=0),this._id=10*this._id+s-48}2===this._state&&s-i>0&&this._put(e,i,s)}}end(e,i=!0){if(0!==this._state){if(3!==this._state)if(1===this._state&&this._start(),this._active.length){let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;r>=0&&!0!==(s=this._active[r].end(e));r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if((s=this._active[r].end(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}else this._handlerFb(this._id,"END",e);this._active=hs,this._id=-1,this._state=0}}},hn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,i,s){this._hitLimit||(this._data+=rR(e,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data))instanceof Promise)return i.then(e=>(this._data="",this._hitLimit=!1,e));return this._data="",this._hitLimit=!1,i}},ho=[],ha=class{constructor(){this._handlers=Object.create(null),this._active=ho,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ho}registerHandler(e,i){void 0===this._handlers[e]&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(i),{dispose:()=>{let e=s.indexOf(i);-1!==e&&s.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=ho,this._ident=0}hook(e,i){if(this.reset(),this._ident=e,this._active=this._handlers[e]||ho,this._active.length)for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(i);else this._handlerFb(this._ident,"HOOK",i)}put(e,i,s){if(this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,i,s);else this._handlerFb(this._ident,"PUT",rR(e,i,s))}unhook(e,i=!0){if(this._active.length){let s=!1,r=this._active.length-1,n=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,s=i,n=this._stack.fallThrough,this._stack.paused=!1),!n&&!1===s){for(;r>=0&&!0!==(s=this._active[r].unhook(e));r--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,s;r--}for(;r>=0;r--)if((s=this._active[r].unhook(!1))instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,s}else this._handlerFb(this._ident,"UNHOOK",e);this._active=ho,this._ident=0}},hl=new hi;hl.addParam(0);var hh=class{constructor(e){this._handler=e,this._data="",this._params=hl,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():hl,this._data="",this._hitLimit=!1}put(e,i,s){this._hitLimit||(this._data+=rR(e,i,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let i=!1;if(this._hitLimit)i=!1;else if(e&&(i=this._handler(this._data,this._params))instanceof Promise)return i.then(e=>(this._params=hl,this._data="",this._hitLimit=!1,e));return this._params=hl,this._data="",this._hitLimit=!1,i}},hc=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,i){this.table.fill(e<<4|i)}add(e,i,s,r){this.table[i<<8|e]=s<<4|r}addMany(e,i,s,r){for(let n=0;n<e.length;n++)this.table[i<<8|e[n]]=s<<4|r}},hd=function(){let e=new hc(4095),i=Array.apply(null,Array(256)).map((e,i)=>i),s=(e,s)=>i.slice(e,s),r=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;for(a in e.setDefault(1,0),e.addMany(r,0,2,0),o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(160,0,2,0),e.add(160,8,5,8),e.add(160,6,0,6),e.add(160,11,0,11),e.add(160,13,13,13),e}(),hu=class extends nl{constructor(e=hd){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new hi,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,i,s)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,i)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(nn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new hr),this._dcsParser=this._register(new ha),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,i=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw Error("only one byte as prefix supported");if((s=e.prefix.charCodeAt(0))&&60>s||s>63)throw Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw Error("only two bytes as intermediates are supported");for(let i=0;i<e.intermediates.length;++i){let r=e.intermediates.charCodeAt(i);if(32>r||r>47)throw Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=r}}if(1!==e.final.length)throw Error("final must be a single byte");let r=e.final.charCodeAt(0);if(i[0]>r||r>i[1])throw Error(`final must be in range ${i[0]} .. ${i[1]}`);return s<<=8,s|=r}identToString(e){let i=[];for(;e;)i.push(String.fromCharCode(255&e)),e>>=8;return i.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,i){let s=this._identifier(e,[48,126]);void 0===this._escHandlers[s]&&(this._escHandlers[s]=[]);let r=this._escHandlers[s];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,i){this._executeHandlers[e.charCodeAt(0)]=i}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,i){let s=this._identifier(e);void 0===this._csiHandlers[s]&&(this._csiHandlers[s]=[]);let r=this._csiHandlers[s];return r.push(i),{dispose:()=>{let e=r.indexOf(i);-1!==e&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,i){return this._dcsParser.registerHandler(this._identifier(e),i)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,i){return this._oscParser.registerHandler(e,i)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,0!==this._parseStack.state&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,i,s,r,n){this._parseStack.state=e,this._parseStack.handlers=i,this._parseStack.handlerPos=s,this._parseStack.transition=r,this._parseStack.chunkPos=n}parse(e,i,s){let r=0,n=0,o=0,a;if(this._parseStack.state)if(2===this._parseStack.state)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(void 0===s||1===this._parseStack.state)throw this._parseStack.state=1,Error("improper continuation due to previous async handler, giving up parsing");let i=this._parseStack.handlers,n=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(!1===s&&n>-1){for(;n>=0&&!0!==(a=i[n](this._params));n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 4:if(!1===s&&n>-1){for(;n>=0&&!0!==(a=i[n]());n--)if(a instanceof Promise)return this._parseStack.handlerPos=n,a}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(24!==r&&26!==r,s))return a;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],a=this._oscParser.end(24!==r&&26!==r,s))return a;27===r&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let s=o;s<i;++s){switch(r=e[s],(n=this._transitions.table[this.currentState<<8|(r<160?r:160)])>>4){case 2:for(let n=s+1;;++n)if(n>=i||(r=e[n])<32||r>126&&r<160||++n>=i||(r=e[n])<32||r>126&&r<160||++n>=i||(r=e[n])<32||r>126&&r<160||++n>=i||(r=e[n])<32||r>126&&r<160){this._printHandler(e,s,n),s=n-1;break}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:s,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let o=this._csiHandlers[this._collect<<8|r],l=o?o.length-1:-1;for(;l>=0&&!0!==(a=o[l](this._params));l--)if(a instanceof Promise)return this._preserveStack(3,o,l,n,s),a;l<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++s<i&&(r=e[s])>47&&r<60)s--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let h=this._escHandlers[this._collect<<8|r],c=h?h.length-1:-1;for(;c>=0&&!0!==(a=h[c]());c--)if(a instanceof Promise)return this._preserveStack(4,h,c,n,s),a;c<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let n=s+1;;++n)if(n>=i||24===(r=e[n])||26===r||27===r||r>127&&r<160){this._dcsParser.put(e,s,n),s=n-1;break}break;case 14:if(a=this._dcsParser.unhook(24!==r&&26!==r))return this._preserveStack(6,[],0,n,s),a;27===r&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let n=s+1;;n++)if(n>=i||(r=e[n])<32||r>127&&r<160){this._oscParser.put(e,s,n),s=n-1;break}break;case 6:if(a=this._oscParser.end(24!==r&&26!==r))return this._preserveStack(5,[],0,n,s),a;27===r&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&n}}},hf=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,h_=/^[\da-f]+$/;function hp(e){if(!e)return;let i=e.toLowerCase();if(0===i.indexOf("rgb:")){i=i.slice(4);let e=hf.exec(i);if(e){let i=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/i*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/i*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/i*255)]}}else if(0===i.indexOf("#")&&(i=i.slice(1),h_.exec(i)&&[3,6,9,12].includes(i.length))){let e=i.length/3,s=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(i.slice(e*r,e*r+e),16);s[r]=1===e?n<<4:2===e?n:3===e?n>>4:n>>8}return s}}function hg(e,i){let s=e.toString(16),r=s.length<2?"0"+s:s;switch(i){case 4:return s[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}var hm={"(":0,")":1,"*":2,"+":3,"-":1,".":2};function hv(e,i){if(e>24)return i.setWinLines||!1;switch(e){case 1:return!!i.restoreWin;case 2:return!!i.minimizeWin;case 3:return!!i.setWinPosition;case 4:return!!i.setWinSizePixels;case 5:return!!i.raiseWin;case 6:return!!i.lowerWin;case 7:return!!i.refreshWin;case 8:return!!i.setWinSizeChars;case 9:return!!i.maximizeWin;case 10:return!!i.fullscreenWin;case 11:return!!i.getWinState;case 13:return!!i.getWinPosition;case 14:return!!i.getWinSizePixels;case 15:return!!i.getScreenSizePixels;case 16:return!!i.getCellSizePixels;case 18:return!!i.getWinSizeChars;case 19:return!!i.getScreenSizeChars;case 20:return!!i.getIconTitle;case 21:return!!i.getWinTitle;case 22:return!!i.pushTitle;case 23:return!!i.popTitle;case 24:return!!i.setWinLines}return!1}var hb=0,hx=class extends nl{constructor(e,i,s,r,n,o,a,l,h=new hu){for(let c in super(),this._bufferService=e,this._charsetService=i,this._coreService=s,this._logService=r,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new rL,this._utf8Decoder=new rB,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=lP.clone(),this._eraseAttrDataInternal=lP.clone(),this._onRequestBell=this._register(new nM),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new nM),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new nM),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new nM),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new nM),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new nM),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new nM),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new nM),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new nM),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new nM),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new nM),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new nM),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new nM),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new hS(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,i)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(e),params:i.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug("Unknown EXECUTE code: ",{code:e})}),this._parser.setOscHandlerFallback((e,i,s)=>{this._logService.debug("Unknown OSC code: ",{identifier:e,action:i,data:s})}),this._parser.setDcsHandlerFallback((e,i,s)=>{"HOOK"===i&&(s=s.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(e),action:i,payload:s})}),this._parser.setPrintHandler((e,i,s)=>this.print(e,i,s)),this._parser.registerCsiHandler({final:"@"},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:"A"},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:"B"},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:"C"},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:"D"},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:"E"},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:"F"},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:"G"},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:"H"},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:"I"},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:"J"},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:"K"},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:"L"},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:"M"},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:"P"},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:"S"},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:"T"},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:"X"},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:"Z"},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:"a"},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:"b"},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:"c"},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:">",final:"c"},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:"d"},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:"e"},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:"f"},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:"g"},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:"h"},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"h"},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:"l"},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:"?",final:"l"},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:"m"},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:"n"},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:"?",final:"n"},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:"r"},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:"s"},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:"t"},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:"u"},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(aa.BEL,()=>this.bell()),this._parser.setExecuteHandler(aa.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(aa.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(aa.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(aa.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(aa.BS,()=>this.backspace()),this._parser.setExecuteHandler(aa.HT,()=>this.tab()),this._parser.setExecuteHandler(aa.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(aa.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(al.IND,()=>this.index()),this._parser.setExecuteHandler(al.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(al.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new hn(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new hn(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new hn(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new hn(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new hn(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new hn(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new hn(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new hn(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new hn(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new hn(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new hn(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new hn(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset()),lA)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error("Parsing error: ",e),e)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new hh((e,i)=>this.requestStatusString(e,i)))}getAttrData(){return this._curAttrData}_preserveStack(e,i,s,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=i,this._parseStack.decodedLength=s,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),5e3))]).catch(e=>{if("#SLOW_TIMEOUT"!==e)throw e;console.warn("async parser handler taking longer than 5000 ms")})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,i){let s,r=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,i))return this._logSlowResolvingAsync(s),s;r=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>131072&&(o=this._parseStack.position+131072)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${"string"==typeof e?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join("")}"`}`),0===this._logService.logLevel&&this._logService.trace("parsing data (codes)","string"==typeof e?e.split("").map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<131072&&(this._parseBuffer=new Uint32Array(Math.min(e.length,131072))),a||this._dirtyRowTracker.clearRange(),e.length>131072)for(let i=o;i<e.length;i+=131072){let o=i+131072<e.length?i+131072:e.length,a="string"==typeof e?this._stringDecoder.decode(e.substring(i,o),this._parseBuffer):this._utf8Decoder.decode(e.subarray(i,o),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,a))return this._preserveStack(r,n,a,i),this._logSlowResolvingAsync(s),s}else if(!a){let i="string"==typeof e?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,i))return this._preserveStack(r,n,i,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==r||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,i,s){let r,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=this._curAttrData,u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-i>0&&2===u.getWidth(this._activeBuffer.x-1)&&u.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let f=this._parser.precedingJoinState;for(let _=i;_<s;++_){if((r=e[_])<127&&o){let e=o[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let i=this._unicodeService.charProperties(r,f);n=l9.extractWidth(i);let s=l9.extractShouldJoin(i),p=s?l9.extractWidth(f):0;if(f=i,a&&this._onA11yChar.fire(rD(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-p>l){if(h){let e=u,i=this._activeBuffer.x-p;for(this._activeBuffer.x=p,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),u=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),p>0&&u instanceof lN&&u.copyCellsFrom(e,i,0,p,!1);i<l;)e.setCellFromCodepoint(i++,0,1,d)}else if(this._activeBuffer.x=l-1,2===n)continue}if(s&&this._activeBuffer.x){let e=u.getWidth(this._activeBuffer.x-1)?1:2;u.addCodepointToCell(this._activeBuffer.x-e,r,n);for(let e=n-p;--e>=0;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(u.insertCells(this._activeBuffer.x,n-p,this._activeBuffer.getNullCell(d)),2===u.getWidth(l-1)&&u.setCellFromCodepoint(l-1,0,1,d)),u.setCellFromCodepoint(this._activeBuffer.x++,r,n,d),n>0)for(;--n;)u.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=f,this._activeBuffer.x<l&&s-i>0&&0===u.getWidth(this._activeBuffer.x)&&!u.hasContent(this._activeBuffer.x)&&u.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,i){return"t"!==e.final||e.prefix||e.intermediates?this._parser.registerCsiHandler(e,i):this._parser.registerCsiHandler(e,e=>!hv(e.params[0],this._optionsService.rawOptions.windowOptions)||i(e))}registerDcsHandler(e,i){return this._parser.registerDcsHandler(e,new hh(i))}registerEscHandler(e,i){return this._parser.registerEscHandler(e,i)}registerOscHandler(e,i){return this._parser.registerOscHandler(e,new hn(i))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(0===this._activeBuffer.x&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,i){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+i):(this._activeBuffer.x=e,this._activeBuffer.y=i),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,i){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+i)}cursorUp(e){let i=this._activeBuffer.y-this._activeBuffer.scrollTop;return i>=0?this._moveCursor(0,-Math.min(i,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let i=this._activeBuffer.scrollBottom-this._activeBuffer.y;return i>=0?this._moveCursor(0,Math.min(i,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let i=e.params[0];return 0===i?delete this._activeBuffer.tabs[this._activeBuffer.x]:3===i&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let i=e.params[0]||1;for(;i--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let i=e.params[0];return 1===i&&(this._curAttrData.bg|=0x20000000),(2===i||0===i)&&(this._curAttrData.bg&=-0x20000001),!0}_eraseInBufferLine(e,i,s,r=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(i,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),r&&(o.isWrapped=!1)}_resetBufferLine(e,i=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),i),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,i=!1){let s;switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);s<this._bufferService.rows;s++)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,i),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+s)?.getTrimmedLength(););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,i);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0))}return!0}eraseInLine(e,i=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,0===this._activeBuffer.x,i);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,i);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,i)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;i--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let i=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;i--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let i=e.params[0]||1;for(;i--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let i=e.params[0]||1;for(;i--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(lP));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(0,i,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.insertCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s.deleteCells(this._activeBuffer.x,i,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return i&&(i.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let i=this._parser.precedingJoinState;if(!i)return!0;let s=e.params[0]||1,r=l9.extractWidth(i),n=this._activeBuffer.x-r,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let e=0;e<o.length;){let i=o.codePointAt(e)||0;a[l++]=i,e+=i>65535?2:1}let h=l;for(let e=1;e<s;++e)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(aa.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(aa.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(aa.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(aa.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(aa.ESC+"[>83;40003;0c")),!0}_is(e){return 0===(this._optionsService.rawOptions.termName+"").indexOf(e)}setMode(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,lO),this._charsetService.setgCharset(1,lO),this._charsetService.setgCharset(2,lO),this._charsetService.setgCharset(3,lO);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let i=0;i<e.length;i++)switch(e.params[i]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),1049===e.params[i]&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,i){let s,r,n,o;(r=s||={})[r.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",r[r.SET=1]="SET",r[r.RESET=2]="RESET",r[r.PERMANENTLY_SET=3]="PERMANENTLY_SET",r[r.PERMANENTLY_RESET=4]="PERMANENTLY_RESET";let a=this._coreService.decPrivateModes,{activeProtocol:l,activeEncoding:h}=this._coreMouseService,c=this._coreService,{buffers:d,cols:u}=this._bufferService,{active:f,alt:_}=d,p=this._optionsService.rawOptions,g=e=>e?1:2,m=e.params[0];return n=m,o=i?2===m?4:4===m?g(c.modes.insertMode):12===m?3:20===m?g(p.convertEol):0:1===m?g(a.applicationCursorKeys):3===m?p.windowOptions.setWinLines?80===u?2:+(132===u):0:6===m?g(a.origin):7===m?g(a.wraparound):8===m?3:9===m?g("X10"===l):12===m?g(p.cursorBlink):25===m?g(!c.isCursorHidden):45===m?g(a.reverseWraparound):66===m?g(a.applicationKeypad):67===m?4:1e3===m?g("VT200"===l):1002===m?g("DRAG"===l):1003===m?g("ANY"===l):1004===m?g(a.sendFocus):1005===m?4:1006===m?g("SGR"===h):1015===m?4:1016===m?g("SGR_PIXELS"===h):1048===m?1:47===m||1047===m||1049===m?g(f===_):2004===m?g(a.bracketedPasteMode):2026===m?g(a.synchronizedOutput):0,c.triggerDataEvent(`${aa.ESC}[${i?"":"?"}${n};${o}$y`),!0}_updateAttrColor(e,i,s,r,n){return 2===i?(e|=0x3000000,e&=-0x1000000,e|=rP.fromColorRGB([s,r,n])):5===i&&(e&=-0x3000100,e|=0x2000000|255&s),e}_extractColor(e,i,s){let r=[0,0,-1,0,0,0],n=0,o=0;do{if(r[o+n]=e.params[i+o],e.hasSubParams(i+o)){let s=e.getSubParams(i+o),a=0;do 5===r[1]&&(n=1),r[o+a+1+n]=s[a];while(++a<s.length&&a+o+1+n<r.length)break}if(5===r[1]&&o+n>=2||2===r[1]&&o+n>=5)break;r[1]&&(n=1)}while(++o+i<e.length&&o+n<r.length)for(let e=2;e<r.length;++e)-1===r[e]&&(r[e]=0);switch(r[0]){case 38:s.fg=this._updateAttrColor(s.fg,r[1],r[3],r[4],r[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,r[1],r[3],r[4],r[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,r[1],r[3],r[4],r[5])}return o}_processUnderline(e,i){i.extended=i.extended.clone(),(!~e||e>5)&&(e=1),i.extended.underlineStyle=e,i.fg|=0x10000000,0===e&&(i.fg&=-0x10000001),i.updateExtended()}_processSGR0(e){e.fg=lP.fg,e.bg=lP.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-0x4000000,e.updateExtended()}charAttributes(e){if(1===e.length&&0===e.params[0])return this._processSGR0(this._curAttrData),!0;let i=e.length,s,r=this._curAttrData;for(let n=0;n<i;n++)(s=e.params[n])>=30&&s<=37?(r.fg&=-0x3000100,r.fg|=0x1000000|s-30):s>=40&&s<=47?(r.bg&=-0x3000100,r.bg|=0x1000000|s-40):s>=90&&s<=97?(r.fg&=-0x3000100,r.fg|=0x1000000|s-90|8):s>=100&&s<=107?(r.bg&=-0x3000100,r.bg|=0x1000000|s-100|8):0===s?this._processSGR0(r):1===s?r.fg|=0x8000000:3===s?r.bg|=0x4000000:4===s?(r.fg|=0x10000000,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,r)):5===s?r.fg|=0x20000000:7===s?r.fg|=0x4000000:8===s?r.fg|=0x40000000:9===s?r.fg|=0x80000000:2===s?r.bg|=0x8000000:21===s?this._processUnderline(2,r):22===s?(r.fg&=-0x8000001,r.bg&=-0x8000001):23===s?r.bg&=-0x4000001:24===s?(r.fg&=-0x10000001,this._processUnderline(0,r)):25===s?r.fg&=-0x20000001:27===s?r.fg&=-0x4000001:28===s?r.fg&=-0x40000001:29===s?r.fg&=0x7fffffff:39===s?(r.fg&=-0x4000000,r.fg|=0xffffff&lP.fg):49===s?(r.bg&=-0x4000000,r.bg|=0xffffff&lP.bg):38===s||48===s||58===s?n+=this._extractColor(e,n,r):53===s?r.bg|=0x40000000:55===s?r.bg&=-0x40000001:59===s?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):100===s?(r.fg&=-0x4000000,r.fg|=0xffffff&lP.fg,r.bg&=-0x4000000,r.bg|=0xffffff&lP.bg):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${aa.ESC}[0n`);break;case 6:let i=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${aa.ESC}[${i};${s}R`)}return!0}deviceStatusPrivate(e){if(6===e.params[0]){let e=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${aa.ESC}[?${e};${i}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=lP.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let i=0===e.length?1:e.params[0];if(0===i)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(i){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar"}this._coreService.decPrivateModes.cursorBlink=i%2==1}return!0}setScrollRegion(e){let i=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||0===s)&&(s=this._bufferService.rows),s>i&&(this._activeBuffer.scrollTop=i-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!hv(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let i=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:2!==i&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${aa.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(0===i||2===i)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),(0===i||1===i)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:(0===i||2===i)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(0===i||1===i)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let i=[],s=e.split(";");for(;s.length>1;){let e=s.shift(),r=s.shift();if(/^\d+$/.exec(e)){let s=parseInt(e);if(hy(s))if("?"===r)i.push({type:0,index:s});else{let e=hp(r);e&&i.push({type:1,index:s,color:e})}}}return i.length&&this._onColor.fire(i),!0}setHyperlink(e){let i=e.indexOf(";");if(-1===i)return!0;let s=e.slice(0,i).trim(),r=e.slice(i+1);return r?this._createHyperlink(s,r):!s.trim()&&this._finishHyperlink()}_createHyperlink(e,i){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),r,n=s.findIndex(e=>e.startsWith("id="));return -1!==n&&(r=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:i}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,i){let s=e.split(";");for(let e=0;e<s.length&&!(i>=this._specialColors.length);++e,++i)if("?"===s[e])this._onColor.fire([{type:0,index:this._specialColors[i]}]);else{let r=hp(s[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[i],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let i=[],s=e.split(";");for(let e=0;e<s.length;++e)if(/^\d+$/.exec(s[e])){let r=parseInt(s[e]);hy(r)&&i.push({type:2,index:r})}return i.length&&this._onColor.fire(i),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,lO),!0}selectCharset(e){return 2!==e.length?this.selectDefaultCharset():"/"===e[0]||this._charsetService.setgCharset(hm[e[0]],lA[e[1]]||lO),!0}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=lP.clone(),this._eraseAttrDataInternal=lP.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-0x4000000,this._eraseAttrDataInternal.bg|=0x3ffffff&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new rN;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let i=0;i<this._bufferService.rows;++i){let s=this._activeBuffer.ybase+this._activeBuffer.y+i,r=this._activeBuffer.lines.get(s);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,i){let s=e=>(this._coreService.triggerDataEvent(`${aa.ESC}${e}${aa.ESC}\\`),!0),r=this._bufferService.buffer,n=this._optionsService.rawOptions;return s('"q'===e?`P1$r${+!!this._curAttrData.isProtected()}"q`:'"p'===e?'P1$r61;1"p':"r"===e?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:"m"===e?"P1$r0m":" q"===e?`P1$r${({block:2,underline:4,bar:6})[n.cursorStyle]-!!n.cursorBlink} q`:"P0$r")}markRangeDirty(e,i){this._dirtyRowTracker.markRangeDirty(e,i)}},hS=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,i){e>i&&(hb=e,e=i,i=hb),e<this.start&&(this.start=e),i>this.end&&(this.end=i)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function hy(e){return 0<=e&&e<256}hS=rS([ry(0,rH)],hS);var hw=class extends nl{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new nM),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,i){let s;if(void 0!==i&&this._syncCalls>i){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,!this._isSyncWriting){for(this._isSyncWriting=!0;s=this._writeBuffer.shift();){this._action(s);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=0x7fffffff,this._isSyncWriting=!1,this._syncCalls=0}}write(e,i){if(this._pendingData>5e7)throw Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(i)}_innerWrite(e=0,i=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,i);if(r){let e=e=>performance.now()-s>=12?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(s,e);r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-s>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},hC=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let i=this._bufferService.buffer;if(void 0===e.id){let s=i.addMarker(i.ybase+i.y),r={data:e,id:this._nextId++,lines:[s]};return s.onDispose(()=>this._removeMarkerFromLink(r,s)),this._dataByLinkId.set(r.id,r),r.id}let s=this._getEntryIdKey(e),r=this._entriesWithId.get(s);if(r)return this.addLineToLink(r.id,i.ybase+i.y),r.id;let n=i.addMarker(i.ybase+i.y),o={id:this._nextId++,key:this._getEntryIdKey(e),data:e,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(o,n)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,i){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(e=>e.line!==i)){let e=this._bufferService.buffer.addMarker(i);s.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(s,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,i){let s=e.lines.indexOf(i);-1!==s&&(e.lines.splice(s,1),0===e.lines.length&&(void 0!==e.data.id&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};hC=rS([ry(0,rH)],hC);var hk=!1,hE=class extends nl{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new nh),this._onBinary=this._register(new nM),this.onBinary=this._onBinary.event,this._onData=this._register(new nM),this.onData=this._onData.event,this._onLineFeed=this._register(new nM),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new nM),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new nM),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new nM),this._instantiationService=new lD,this.optionsService=this._register(new lK(e)),this._instantiationService.setService(rU,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(lW)),this._instantiationService.setService(rH,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(lL)),this._instantiationService.setService(rK,this._logService),this.coreService=this._register(this._instantiationService.createInstance(lY)),this._instantiationService.setService(rW,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(lQ)),this._instantiationService.setService(rz,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(l9)),this._instantiationService.setService(rV,this.unicodeService),this._charsetService=this._instantiationService.createInstance(he),this._instantiationService.setService(rF,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(hC),this._instantiationService.setService(rq,this._oscLinkService),this._inputHandler=this._register(new hx(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(nx.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(nx.forward(this._bufferService.onResize,this._onResize)),this._register(nx.forward(this.coreService.onData,this._onData)),this._register(nx.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new hw((e,i)=>this._inputHandler.parse(e,i))),this._register(nx.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new nM),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let i in e)this.optionsService.options[i]=e[i]}write(e,i){this._writeBuffer.write(e,i)}writeSync(e,i){this._logService.logLevel<=3&&!hk&&(this._logService.warn("writeSync is unreliable and will be removed soon."),hk=!0),this._writeBuffer.writeSync(e,i)}input(e,i=!0){this.coreService.triggerDataEvent(e,i)}resize(e,i){isNaN(e)||isNaN(i)||(e=Math.max(e,2),i=Math.max(i,1),this._bufferService.resize(e,i))}scroll(e,i=!1){this._bufferService.scroll(e,i)}scrollLines(e,i){this._bufferService.scrollLines(e,i)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}registerEscHandler(e,i){return this._inputHandler.registerEscHandler(e,i)}registerDcsHandler(e,i){return this._inputHandler.registerDcsHandler(e,i)}registerCsiHandler(e,i){return this._inputHandler.registerCsiHandler(e,i)}registerOscHandler(e,i){return this._inputHandler.registerOscHandler(e,i)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,i=this.optionsService.rawOptions.windowsPty;i&&void 0!==i.buildNumber&&void 0!==i.buildNumber?e="conpty"===i.backend&&i.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(ht.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ht(this._bufferService),!1))),this._windowsWrappingHeuristics.value=nn(()=>{for(let i of e)i.dispose()})}}},hM={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']},hD=0,hR=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ln,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ln,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),0===this._insertedValues.length&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,i)=>this._getKey(e)-this._getKey(i)),i=0,s=0,r=Array(this._array.length+this._insertedValues.length);for(let n=0;n<r.length;n++)s>=this._array.length||this._getKey(e[i])<=this._getKey(this._array[s])?(r[n]=e[i],i++):r[n]=this._array[s++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),0===this._array.length)return!1;let i=this._getKey(e);if(void 0===i||-1===(hD=this._search(i))||this._getKey(this._array[hD])!==i)return!1;do if(this._array[hD]===e)return 0===this._deletedIndices.length&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(hD),!0;while(++hD<this._array.length&&this._getKey(this._array[hD])===i)return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,i)=>e-i),i=0,s=Array(this._array.length-e.length),r=0;for(let n=0;n<this._array.length;n++)e[i]===n?i++:s[r++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((hD=this._search(e))<0||hD>=this._array.length)&&this._getKey(this._array[hD])===e)do yield this._array[hD];while(++hD<this._array.length&&this._getKey(this._array[hD])===e)}forEachByKey(e,i){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),0!==this._array.length&&!((hD=this._search(e))<0||hD>=this._array.length)&&this._getKey(this._array[hD])===e)do i(this._array[hD]);while(++hD<this._array.length&&this._getKey(this._array[hD])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let i=0,s=this._array.length-1;for(;s>=i;){let r=i+s>>1,n=this._getKey(this._array[r]);if(n>e)s=r-1;else if(n<e)i=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return i}},hL=0,hB=0,hP=class extends nl{constructor(){super(),this._decorations=new hR(e=>e?.marker.line),this._onDecorationRegistered=this._register(new nM),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new nM),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(nn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let i=new hT(e);if(i){let e=i.marker.onDispose(()=>i.dispose()),s=i.onDispose(()=>{s.dispose(),i&&(this._decorations.delete(i)&&this._onDecorationRemoved.fire(i),e.dispose())});this._decorations.insert(i),this._onDecorationRegistered.fire(i)}return i}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,i,s){let r=0,n=0;for(let o of this._decorations.getKeyIterator(i))n=(r=o.options.x??0)+(o.options.width??1),e>=r&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,i,s,r){this._decorations.forEachByKey(i,i=>{hB=(hL=i.options.x??0)+(i.options.width??1),e>=hL&&e<hB&&(!s||(i.options.layer??"bottom")===s)&&r(i)})}},hT=class extends na{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new nM),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new nM),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return null===this._cachedBg&&(this.options.backgroundColor?this._cachedBg=l2.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return null===this._cachedFg&&(this.options.foregroundColor?this._cachedFg=l2.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},hN=class{constructor(e,i=1e3){this._renderCallback=e,this._debounceThresholdMS=i,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,i,s){this._rowCount=s,e=void 0!==e?e:0,i=void 0!==i?i:this._rowCount-1,this._rowStart=void 0!==this._rowStart?Math.min(this._rowStart,e):e,this._rowEnd=void 0!==this._rowEnd?Math.max(this._rowEnd,i):i;let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,i=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},i)}}_innerRefresh(){if(void 0===this._rowStart||void 0===this._rowEnd||void 0===this._rowCount)return;let e=Math.max(this._rowStart,0),i=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,i)}},hI=class extends nl{constructor(e,i,s,r){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new hN(this._renderRows.bind(this))),!this._terminal.element)throw Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
70
|
-
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(oB(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(nn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let i=0;i<e;i++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
71
|
-
`&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=rC)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,i){this._liveRegionDebouncer.refresh(e,i,this._terminal.rows)}_renderRows(e,i){let s=this._terminal.buffer,r=s.lines.length.toString();for(let n=e;n<=i;n++){let e=s.lines.get(s.ydisp+n),i=[],o=e?.translateToString(!0,void 0,void 0,i)||"",a=(s.ydisp+n+1).toString(),l=this._rowElements[n];l&&(0===o.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=o,this._rowColumns.set(l,i)),l.setAttribute("aria-posinset",a),l.setAttribute("aria-setsize",r),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,i){let s,r,n=e.target,o=this._rowElements[0===i?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===i?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===i?(s=n,r=this._rowElements.pop(),this._rowContainer.removeChild(r)):(s=this._rowElements.shift(),r=n,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),r.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((i.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===s.node&&i.offset>s.offset)&&([i,s]=[s,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:i})=>{let s=e instanceof Text?e.parentNode:e,r=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(r))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(s);if(!n)return console.warn("columns is null. Race condition?"),null;let o=i<n.length?n[i]:n.slice(-1)[0]+1;return o>=this._terminal.cols&&(++r,o=0),{row:r,column:o}},o=n(i),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let i=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let r=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/i})`}};hI=rS([ry(1,r$),ry(2,rJ),ry(3,rQ)],hI);var hj=class extends nl{constructor(e,i,s,r,n){super(),this._element=e,this._mouseService=i,this._renderService=s,this._bufferService=r,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new nM),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new nM),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(nn(()=>{nr(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(oB(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(oB(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(oB(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(oB(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let s=e.composedPath();for(let e=0;e<s.length;e++){let i=s[e];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}this._lastBufferCell&&i.x===this._lastBufferCell.x&&i.y===this._lastBufferCell.y||(this._handleHover(i),this._lastBufferCell=i)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,i){this._activeProviderReplies&&i||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[r,n]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(r)&&(s=this._checkLinkProviderResult(r,e,s)):n.provideLinks(e.y,i=>{if(this._isMouseOut)return;let n=i?.map(e=>({link:e}));this._activeProviderReplies?.set(r,n),s=this._checkLinkProviderResult(r,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,i){let s=new Set;for(let r=0;r<i.size;r++){let n=i.get(r);if(n)for(let i=0;i<n.length;i++){let r=n[i],o=r.link.range.start.y<e?0:r.link.range.start.x,a=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=o;e<=a;e++){if(s.has(e)){n.splice(i--,1);break}s.add(e)}}}}_checkLinkProviderResult(e,i,s){if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),n=!1;for(let i=0;i<e;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(n=!0);if(!n&&r){let e=r.find(e=>this._linkAtPosition(e.link,i));e&&(s=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,i));if(r){s=!0,this._handleNewLink(r);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var i,s;if(!this._currentLink)return;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);r&&this._mouseDownLink&&(i=this._mouseDownLink.link,s=this._currentLink.link,i.text===s.text&&i.range.start.x===s.range.start.x&&i.range.start.y===s.range.start.y&&i.range.end.x===s.range.end.x&&i.range.end.y===s.range.end.y)&&this._linkAtPosition(this._currentLink.link,r)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,i){this._currentLink&&this._lastMouseEvent&&(!e||!i||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,nr(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(e.link,i)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let i=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(s,i.text)}_fireUnderlineEvent(e,i){let s=e.range,r=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(s,i.text)}_linkAtPosition(e,i){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,n=i.y*this._bufferService.cols+i.x;return s<=n&&n<=r}_positionFromMouseEvent(e,i,s){let r=s.getCoords(e,i,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,i,s,r,n){return{x1:e,y1:i,x2:s,y2:r,cols:this._bufferService.cols,fg:n}}};hj=rS([ry(1,rZ),ry(2,rQ),ry(3,rH),ry(4,r5)],hj);var hA=class extends hE{constructor(e={}){super(e),this._linkifier=this._register(new nh),this.browser=aG,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new nh),this._onCursorMove=this._register(new nM),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new nM),this.onKey=this._onKey.event,this._onRender=this._register(new nM),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new nM),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new nM),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new nM),this.onBell=this._onBell.event,this._onFocus=this._register(new nM),this._onBlur=this._register(new nM),this._onA11yCharEmitter=this._register(new nM),this._onA11yTabEmitter=this._register(new nM),this._onWillOpen=this._register(new nM),this._setup(),this._decorationService=this._instantiationService.createInstance(hP),this._instantiationService.setService(rY,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(aq),this._instantiationService.setService(r5,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(rX)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(nx.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(nx.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(nx.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(nx.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(nn(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let i of e){let e,s="";switch(i.index){case 256:e="foreground",s="10";break;case 257:e="background",s="11";break;case 258:e="cursor",s="12";break;default:e="ansi",s="4;"+i.index}switch(i.type){case 0:let r=l1.toColorRGB("ansi"===e?this._themeService.colors.ansi[i.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${aa.ESC}]${s};${function(e,i=16){let[s,r,n]=e;return`rgb:${hg(s,i)}/${hg(r,i)}/${hg(n,i)}`}(r)}${ah.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[i.index]=ac.toColor(...i.color));else{let s=e;this._themeService.modifyColors(e=>e[s]=ac.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(hI,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(aa.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(aa.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,i=this.buffer.lines.get(e);if(!i)return;let s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,n=i.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(oB(this.element,"copy",e=>{var i;this.hasSelection()&&(i=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault())}));let e=e=>{var i,s,r;return i=this.textarea,s=this.coreService,r=this.optionsService,void(e.stopPropagation(),e.clipboardData&&rk(e.clipboardData.getData("text/plain"),i,s,r))};this._register(oB(this.textarea,"paste",e)),this._register(oB(this.element,"paste",e)),a2?this._register(oB(this.element,"mousedown",e=>{2===e.button&&rM(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(oB(this.element,"contextmenu",e=>{rM(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),le&&this._register(oB(this.element,"auxclick",e=>{1===e.button&&rE(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(oB(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(oB(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(oB(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(oB(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(oB(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(oB(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(oB(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(oB(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",rw),lt||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(aK,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(rJ,this._coreBrowserService),this._register(oB(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(oB(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(az,this._document,this._helperContainer),this._instantiationService.setService(rG,this._charSizeService),this._themeService=this._instantiationService.createInstance(lk),this._instantiationService.setService(r2,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(aE),this._instantiationService.setService(r1,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(la,this.rows,this.screenElement)),this._instantiationService.setService(rQ,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(at,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(aY),this._instantiationService.setService(rZ,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(hj,this.screenElement));this.element.appendChild(i);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(o3,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(lm,this.element,this.screenElement,r)),this._instantiationService.setService(r0,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(nx.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(o4,this.screenElement)),this._register(oB(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(hI,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ae,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ae,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(aH,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function s(i){let s,r,n=e._mouseService.getMouseReportCoords(i,e.screenElement);if(!n)return!1;switch(i.overrideType||i.type){case"mousemove":r=32,void 0===i.buttons?(s=3,void 0!==i.button&&(s=i.button<3?i.button:3)):s=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":r=0,s=i.button<3?i.button:3;break;case"mousedown":r=1,s=i.button<3?i.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(i))return!1;let o=i.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;r=o<0?0:1,s=4;break;default:return!1}return void 0!==r&&void 0!==s&&!(s>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:s,action:r,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(s(e),e.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(e)),o=e=>(s(e),this.cancel(e,!0)),a=e=>{e.buttons&&s(e)},l=e=>{e.buttons||s(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?r.mousemove||(i.addEventListener("mousemove",l),r.mousemove=l):(i.removeEventListener("mousemove",r.mousemove),r.mousemove=null),16&e?r.wheel||(i.addEventListener("wheel",o,{passive:!1}),r.wheel=o):(i.removeEventListener("wheel",r.wheel),r.wheel=null),2&e?r.mouseup||(r.mouseup=n):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),4&e?r.mousedrag||(r.mousedrag=a):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(oB(i,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return s(e),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(e)})),this._register(oB(i,"wheel",i=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback){if(0===i.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(i,!0);let s=aa.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(i,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(e){rk(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,i,s){this._selectionService.setSelection(e,i,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;i||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let s=function(e,i,s,r){let n={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?i?n.key=aa.ESC+"OA":n.key=aa.ESC+"[A":"UIKeyInputLeftArrow"===e.key?i?n.key=aa.ESC+"OD":n.key=aa.ESC+"[D":"UIKeyInputRightArrow"===e.key?i?n.key=aa.ESC+"OC":n.key=aa.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(i?n.key=aa.ESC+"OB":n.key=aa.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":aa.DEL,e.altKey&&(n.key=aa.ESC+n.key);break;case 9:if(e.shiftKey){n.key=aa.ESC+"[Z";break}n.key=aa.HT,n.cancel=!0;break;case 13:n.key=e.altKey?aa.ESC+aa.CR:aa.CR,n.cancel=!0;break;case 27:n.key=aa.ESC,e.altKey&&(n.key=aa.ESC+aa.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=aa.ESC+"[1;"+(o+1)+"D":i?n.key=aa.ESC+"OD":n.key=aa.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=aa.ESC+"[1;"+(o+1)+"C":i?n.key=aa.ESC+"OC":n.key=aa.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=aa.ESC+"[1;"+(o+1)+"A":i?n.key=aa.ESC+"OA":n.key=aa.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=aa.ESC+"[1;"+(o+1)+"B":i?n.key=aa.ESC+"OB":n.key=aa.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=aa.ESC+"[2~");break;case 46:o?n.key=aa.ESC+"[3;"+(o+1)+"~":n.key=aa.ESC+"[3~";break;case 36:o?n.key=aa.ESC+"[1;"+(o+1)+"H":i?n.key=aa.ESC+"OH":n.key=aa.ESC+"[H";break;case 35:o?n.key=aa.ESC+"[1;"+(o+1)+"F":i?n.key=aa.ESC+"OF":n.key=aa.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=aa.ESC+"[5;"+(o+1)+"~":n.key=aa.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=aa.ESC+"[6;"+(o+1)+"~":n.key=aa.ESC+"[6~";break;case 112:o?n.key=aa.ESC+"[1;"+(o+1)+"P":n.key=aa.ESC+"OP";break;case 113:o?n.key=aa.ESC+"[1;"+(o+1)+"Q":n.key=aa.ESC+"OQ";break;case 114:o?n.key=aa.ESC+"[1;"+(o+1)+"R":n.key=aa.ESC+"OR";break;case 115:o?n.key=aa.ESC+"[1;"+(o+1)+"S":n.key=aa.ESC+"OS";break;case 116:o?n.key=aa.ESC+"[15;"+(o+1)+"~":n.key=aa.ESC+"[15~";break;case 117:o?n.key=aa.ESC+"[17;"+(o+1)+"~":n.key=aa.ESC+"[17~";break;case 118:o?n.key=aa.ESC+"[18;"+(o+1)+"~":n.key=aa.ESC+"[18~";break;case 119:o?n.key=aa.ESC+"[19;"+(o+1)+"~":n.key=aa.ESC+"[19~";break;case 120:o?n.key=aa.ESC+"[20;"+(o+1)+"~":n.key=aa.ESC+"[20~";break;case 121:o?n.key=aa.ESC+"[21;"+(o+1)+"~":n.key=aa.ESC+"[21~";break;case 122:o?n.key=aa.ESC+"[23;"+(o+1)+"~":n.key=aa.ESC+"[23~";break;case 123:o?n.key=aa.ESC+"[24;"+(o+1)+"~":n.key=aa.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!s||r)&&e.altKey&&!e.metaKey){let i=hM[e.keyCode]?.[+!!e.shiftKey];if(i)n.key=aa.ESC+i;else if(e.keyCode>=65&&e.keyCode<=90){let i=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(i=i.toUpperCase()),n.key=aa.ESC+i}else if(32===e.keyCode)n.key=aa.ESC+(e.ctrlKey?aa.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let i=e.code.slice(3,4);e.shiftKey||(i=i.toLowerCase()),n.key=aa.ESC+i,n.cancel=!0}}else!s||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=aa.US),"@"===e.key&&(n.key=aa.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=aa.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=aa.DEL:219===e.keyCode?n.key=aa.ESC:220===e.keyCode?n.key=aa.FS:221===e.keyCode&&(n.key=aa.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===s.type||2===s.type){let i=this.rows-1;return this.scrollLines(2===s.type?-i:i),this.cancel(e,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===aa.ETX||s.key===aa.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,i){let s=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?s:s&&(!i.keyCode||i.keyCode>47)}_keyUp(e){var i;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(i=e).keyCode||17===i.keyCode||18===i.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(null===e.which||void 0===e.which)i=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;i=e.which}return!!i&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(lP));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(aa.ESC+"[I"):this.coreService.triggerDataEvent(aa.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${aa.ESC}[4;${s};${i}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${aa.ESC}[6;${n};${r}t`)}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}},hO=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let s={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(s),i.dispose=()=>this._wrappedAddonDispose(s),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){i=s;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},hH=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new rN)}translateToString(e,i,s){return this._line.translateToString(e,i,s)}},hz=class{constructor(e,i){this._buffer=e,this.type=i}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let i=this._buffer.lines.get(e);if(i)return new hH(i)}getNullCell(){return new rN}},hW=class extends nl{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new nM),this.onBufferChange=this._onBufferChange.event,this._normal=new hz(this._core.buffers.normal,"normal"),this._alternate=new hz(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},hF=class{constructor(e){this._core=e}registerCsiHandler(e,i){return this._core.registerCsiHandler(e,e=>i(e.toArray()))}addCsiHandler(e,i){return this.registerCsiHandler(e,i)}registerDcsHandler(e,i){return this._core.registerDcsHandler(e,(e,s)=>i(e,s.toArray()))}addDcsHandler(e,i){return this.registerDcsHandler(e,i)}registerEscHandler(e,i){return this._core.registerEscHandler(e,i)}addEscHandler(e,i){return this.registerEscHandler(e,i)}registerOscHandler(e,i){return this._core.registerOscHandler(e,i)}addOscHandler(e,i){return this.registerOscHandler(e,i)}},h$=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},hK=["cols","rows"],hU=0,hq=class extends nl{constructor(e){super(),this._core=this._register(new hA(e)),this._addonManager=this._register(new hO),this._publicOptions={...this._core.options};let i=e=>this._core.options[e],s=(e,i)=>{this._checkReadonlyOptions(e),this._core.options[e]=i};for(let e in this._core.options){let r={get:i.bind(this,e),set:s.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(hK.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new hF(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new h$(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new hW(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let i in e)this._publicOptions[i]=e[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,i=!0){this._core.input(e,i)}resize(e,i){this._verifyIntegers(e,i),this._core.resize(e,i)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,i,s){this._verifyIntegers(e,i,s),this._core.select(e,i,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,i){this._verifyIntegers(e,i),this._core.selectLines(e,i)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,i){this._core.write(e,i)}writeln(e,i){this._core.write(e),this._core.write(`\r
|
|
72
|
-
`,i)}paste(e){this._core.paste(e)}refresh(e,i){this._verifyIntegers(e,i),this._core.refresh(e,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return rw},set promptLabel(t){rw=t},get tooMuchOutput(){return rC},set tooMuchOutput(t){rC=t}}}_verifyIntegers(...e){for(hU of e)if(hU===1/0||isNaN(hU)||hU%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(hU of e)if(hU&&(hU===1/0||isNaN(hU)||hU%1!=0||hU<0))throw Error("This API only accepts positive integers")}},hV=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom;return{cols:Math.max(2,Math.floor((n-(a.right+a.left)-i)/e.css.cell.width)),rows:Math.max(1,Math.floor((r-l)/e.css.cell.height))}}};function hY({sessionId:e}){let i=(0,g.useRef)(null),s=(0,g.useRef)(null),r=function(){let[e,i]=(0,g.useState)("u"<typeof document||"visible"===document.visibilityState);return(0,g.useEffect)(()=>{let e=()=>i("visible"===document.visibilityState);return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]),e}(),[n,o]=(0,g.useState)(!1),a=(0,g.useRef)(!1),l=e=>{a.current=e,o(e)};return(0,g.useEffect)(()=>{if(!e||!i.current)return;let r=new hq({convertEol:!0,fontSize:13,theme:{background:"#0b0b0c"},scrollback:5e3,scrollOnUserInput:!0,disableStdin:!0}),n=new hV;r.loadAddon(n),r.open(i.current);let o=new WebSocket(function(e){let i=rv.default.env.NEXT_PUBLIC_GATEWAY_URL;if(i)return`${i.replace(/^http/,"ws")}/ws/pty/${e}`;{let i="https:"===window.location.protocol?"wss:":"ws:";return`${i}//${window.location.host}/ws/pty/${e}`}}(e));o.binaryType="arraybuffer",s.current=o;let h=/[⏰-⏿■-◿☀-⛿]/g,c=new TextDecoder("utf-8"),d=e=>e.replace(h,e=>e+"︎");o.onmessage=e=>{if("string"==typeof e.data){try{let i=JSON.parse(e.data);if(i?.type==="reset"){r.reset(),l(!1);return}}catch{}r.write(d(e.data)),!a.current&&e.data.length>0&&l(!0)}else{let i=new Uint8Array(e.data);r.write(d(c.decode(i,{stream:!0}))),!a.current&&i.byteLength>0&&l(!0)}};let u=null,f=()=>{null!==u&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=null;let e=i.current?.getBoundingClientRect();if(e&&!(e.width<50)&&!(e.height<30)){try{n.fit()}catch{}r.cols>0&&r.rows>0&&o.readyState===WebSocket.OPEN&&o.send(JSON.stringify({type:"resize",cols:r.cols,rows:r.rows}))}})};o.onopen=()=>{o.send(JSON.stringify({type:"viewing",viewing:"visible"===document.visibilityState})),f()},window.addEventListener("resize",f),f();let _=new ResizeObserver(()=>f());_.observe(i.current);let p=i.current,g=0,m=0,v=e=>{1===e.touches.length&&(g=e.touches[0].clientY,m=0)},b=e=>{if(1!==e.touches.length)return;let i=Math.trunc((g-e.touches[0].clientY)/17),s=i-m;0!==s&&(r.scrollLines(s),m=i)};return p.addEventListener("touchstart",v,{passive:!0}),p.addEventListener("touchmove",b,{passive:!0}),()=>{if(window.removeEventListener("resize",f),_.disconnect(),p.removeEventListener("touchstart",v),p.removeEventListener("touchmove",b),null!==u&&cancelAnimationFrame(u),o.readyState===WebSocket.OPEN)try{o.send(JSON.stringify({type:"viewing",viewing:!1}))}catch{}o.close(),s.current=null,r.dispose()}},[e]),(0,g.useEffect)(()=>{let e=s.current;if(e&&e.readyState===WebSocket.OPEN){try{e.send(JSON.stringify({type:"viewing",viewing:r}))}catch{}r&&window.dispatchEvent(new Event("resize"))}},[r]),(0,p.jsxs)("div",{style:{position:"relative",flex:1,minHeight:0,width:"100%",overflow:"hidden",background:"#0b0b0c",paddingTop:"1rem",boxSizing:"border-box"},children:[(0,p.jsx)("div",{ref:i,tabIndex:-1,style:{height:"100%",width:"100%",overflow:"hidden",background:"#0b0b0c"}}),!n&&(0,p.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,padding:"1rem",color:"#888",fontFamily:"monospace",fontSize:12,pointerEvents:"none",textAlign:"center"},children:"Waiting for the interactive claude PTY… send a message below to spawn it."})]})}let hX=[["claude-fable-5-1",1e6],["gpt-6-astra",105e4],["gpt-5",4e5],["gpt-4.1",1e6],["o3",2e5],["opus",2e5],["sonnet",1e6],["haiku",2e5],["gemini",1e6]];function hG(e){if(!e)return 2e5;let i=e.toLowerCase(),s=2e5,r=-1;for(let[e,n]of hX)i.includes(e)&&e.length>r&&(s=n,r=e.length);return s}function hJ(e){return!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(Math.round(e))}let hZ={ok:"var(--accent)",warn:"#e6a23c",critical:"#e05252"};function hQ({tokens:e,model:i}){let s;if("number"!=typeof e||e<=0)return null;let r=(s=hG(i))<=0?0:Math.max(0,Math.min(1,e/s)),n=hZ[r>=.9?"critical":r>=.7?"warn":"ok"],o=hG(i),a=Math.round(100*r);return(0,p.jsxs)("div",{title:`Context: ${hJ(e)} / ${hJ(o)} (${a}%)`,style:{display:"inline-flex",alignItems:"center",gap:"6px",fontSize:"var(--text-caption, 12px)",color:"var(--text-secondary)"},children:[(0,p.jsx)("span",{"aria-hidden":!0,style:{position:"relative",width:"56px",height:"4px",borderRadius:"2px",background:"var(--surface-2, rgba(127,127,127,0.2))",overflow:"hidden"},children:(0,p.jsx)("span",{style:{position:"absolute",inset:0,width:`${a}%`,background:n,transition:"width 200ms ease"}})}),(0,p.jsxs)("span",{style:{color:n},children:[hJ(e)," (",a,"%)"]})]})}function h0({sessionId:e,isActive:i,onFocus:s,onSessionCreated:r,onSessionMetaChange:n,onRefresh:o,portalName:a="Jinn",subscribe:l,connectionSeq:h,skillsVersion:c,events:d,viewMode:u="chat",getOnboardingPrompt:f,isStubSession:_,onStubCleared:m,focusTrigger:b,onShortcutsClick:x,focusMessageId:S,onFocusDismissed:y}){let[w,C]=(0,g.useState)([]),[k,E]=(0,g.useState)(!1),[M,D]=(0,g.useState)(!1),[R,L]=(0,g.useState)(!1),[B,P]=(0,g.useState)(!1),T=(0,g.useRef)(""),[N,I]=(0,g.useState)(""),j=(0,g.useRef)(-1),[A,O]=(0,g.useState)(null),[H,z]=(0,g.useState)(!1),W=(0,g.useRef)(e),F=(0,g.useRef)(0),[$,K]=(0,g.useState)(null),[U,q]=(0,g.useState)([]),V=(0,g.useRef)(!1);(0,g.useEffect)(()=>{e||V.current&&U.length>0||v.api.getOrg().then(e=>{Array.isArray(e.employees)&&(q(e.employees.map(e=>({name:e.name,displayName:e.displayName,department:e.department,rank:e.rank}))),V.current=!0)}).catch(()=>{})},[e,U.length]),(0,g.useEffect)(()=>{W.current=e},[e]);let Y=(0,g.useCallback)((e,i)=>{if(!i)return;let s=j.current;if(s<0)return;let r=e.slice(s);r.length>0&&function(e,i){try{localStorage.setItem(`${sX}${e}`,JSON.stringify(i))}catch{}}(i,r)},[]);(0,g.useEffect)(()=>l((e,i)=>{let s=W.current;if(s&&i.sessionId===s){if("session:delta"===e){let e=String(i.type||"text");if("text"===e){let e=String(i.content||"");T.current+=e,I(T.current)}else if("text_snapshot"===e){let e=String(i.content||"");e.length>=T.current.length&&(T.current=e,I(e))}else if("tool_use"===e){if(T.current){let e=T.current;T.current="",I(""),C(i=>{j.current<0&&(j.current=i.length);let r=[...i,{id:crypto.randomUUID(),role:"assistant",content:e,timestamp:Date.now()}];return Y(r,s),r})}let e=String(i.toolName||"tool");C(i=>{j.current<0&&(j.current=i.length);let r=[...i,{id:crypto.randomUUID(),role:"assistant",content:`Using ${e}`,timestamp:Date.now(),toolCall:e}];return Y(r,s),r})}else if("tool_result"===e)C(e=>{let i=[...e],r=i[i.length-1];return r&&"assistant"===r.role&&r.toolCall&&(i[i.length-1]={...r,content:`Used ${r.toolCall}`}),Y(i,s),i});else if("permission"===e){let e=String(i.content||"Claude is waiting for approval in the CLI view.");C(i=>[...i,{id:crypto.randomUUID(),role:"notification",content:e,timestamp:Date.now()}])}}if("session:notification"===e){let e=String(i.message||"");e&&C(i=>[...i,{id:crypto.randomUUID(),role:"notification",content:e,timestamp:Date.now()}])}if("session:interrupted"===e&&(T.current="",I("")),"session:stopped"===e&&(E(!1),I("")),"session:completed"===e){T.current="",I(""),E(!1),j.current=-1;let e=s||(i.sessionId?String(i.sessionId):null);e&&sG(e),i.result&&C(e=>{let s=[...e],r=s[s.length-1];return r&&"assistant"===r.role&&!r.toolCall&&s.pop(),[...s,{id:crypto.randomUUID(),role:"assistant",content:String(i.result),timestamp:Date.now()}]}),i.error&&!i.result&&C(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:`Error: ${i.error}`,timestamp:Date.now()}]),e&&v.api.getSession(e,{messages:!1}).then(i=>{W.current===e&&O(i)}).catch(()=>{}),o?.()}}}),[l,Y,o]),(0,g.useEffect)(()=>{let e=!1;return v.api.getStatus().then(i=>{let s=i?.engines;e||z(s?.claude?.interactive===!0)}).catch(()=>{}),()=>{e=!0}},[]);let X=(0,g.useCallback)(async(e,i)=>{let s=++F.current;try{let r=!i?.latest&&S?S:null,o=await v.api.getSession(e,r?{messages:!1}:{last:100}),a=r?await v.api.getSessionMessageWindow(e,r,50):null;if(r&&!a?.anchorFound&&(o=await v.api.getSession(e,{last:100}),a=null),s!==F.current||W.current!==e)return;O(o);let l={engine:o.engine?String(o.engine):void 0,engineSessionId:o.engineSessionId?String(o.engineSessionId):void 0,model:o.model?String(o.model):void 0,title:o.title?String(o.title):void 0,employee:o.employee?String(o.employee):void 0};n?.(l);let h=a?.messages||o.messages||o.history||[],c=Array.isArray(h)?h.map(e=>({id:"string"==typeof e.id?e.id:crypto.randomUUID(),role:e.role||"assistant",content:String(e.content||e.text||""),timestamp:e.timestamp?Number(e.timestamp):Date.now()})):[];if("error"===o.status&&o.lastError){let e=c[c.length-1],i=`Error: ${String(o.lastError)}`;e&&"assistant"===e.role&&e.content===i||c.push({id:crypto.randomUUID(),role:"assistant",content:i,timestamp:Date.now()})}let d="running"===o.status,u=o.messagesPage;if(D(a?.hasOlder??u?.hasOlder===!0),P(a?.hasNewer===!0),d){let i=function(e){try{let i=localStorage.getItem(`${sX}${e}`);return i?JSON.parse(i):[]}catch{return[]}}(e);i.length>0?(j.current=c.length,C([...c,...i])):(j.current=c.length,C(c)),E(!0)}else sG(e),j.current=-1,C(c)}catch{if(s!==F.current||W.current!==e)return;C([]),O(null),D(!1),P(!1),j.current=-1}},[n,S]),G=(0,g.useCallback)(async()=>{if(!e||R||!M)return;let i=w[0]?.id;if(!i)return;let s=F.current;L(!0);try{let r=await v.api.getSessionMessages(e,i,100);if(W.current!==e||s!==F.current)return;C(e=>{let i=new Set(e.map(e=>e.id)),s=r.messages.filter(e=>!i.has(e.id)).map(e=>({...e,role:e.role}));return j.current>=0&&(j.current+=s.length),[...s,...e]}),D(r.hasOlder)}finally{L(!1)}},[e,R,M,w]);(0,g.useEffect)(()=>{if(!e){F.current++,C([]),E(!1),O(null),D(!1),P(!1),T.current="",I(""),j.current=-1,K(null);return}T.current="",I(""),E(!1),L(!1),X(e)},[e,X]),(0,g.useEffect)(()=>{h&&e&&X(e)},[h,e,X]);let J=(0,g.useCallback)(()=>{e&&(y?.(),X(e,{latest:!0}))},[e,y,X]);(0,g.useEffect)(()=>{if(!e||!k)return;let i=setInterval(async()=>{try{let i=await v.api.getSession(e,{messages:!1});"running"!==i.status&&(await X(e),E(!1))}catch{}},5e3);return()=>clearInterval(i)},[e,k,X]);let Z=(0,g.useCallback)(async()=>{if(e)try{await v.api.stopSession(e)}catch{}},[e]),Q=(0,g.useCallback)(async(i,s,n)=>{let a={id:crypto.randomUUID(),role:"user",content:i,timestamp:Date.now(),media:s};C(e=>(j.current=e.length+1,[...e,a])),E(!0);try{let a;if(s&&s.length>0){let e=s.filter(e=>e.file).map(e=>v.api.uploadFile(e.file));e.length>0&&(a=(await Promise.all(e)).map(e=>e.id))}let h=e;if(h&&_&&f){m?.();let e=f(i);await v.api.sendMessage(h,{message:e,attachments:a}),o?.()}else if(h)await v.api.sendMessage(h,{message:i,interrupt:n||void 0,attachments:a}),o?.();else{var l;let e,s=(l={message:i,selectedEmployee:$,attachmentIds:a},e={source:"web",prompt:l.message},l.selectedEmployee&&(e.employee=l.selectedEmployee),l.attachmentIds&&l.attachmentIds.length>0&&(e.attachments=l.attachmentIds),e),n=await v.api.createSession(s);h=String(n.id),r?.(h),o?.()}}catch(e){E(!1),C(i=>[...i,{id:crypto.randomUUID(),role:"assistant",content:`Error: ${e instanceof Error?e.message:"Failed to send message"}`,timestamp:Date.now()}])}},[e,$,_,f,m,r,o]),ee=(0,g.useCallback)(async()=>{if(!e)return void C(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"No active session. Send a message to start one.",timestamp:Date.now()}]);try{let i=await v.api.getSession(e,{messages:!1}),s=["**Session Info**",`ID: \`${i.id}\``,`Status: ${i.status||"unknown"}`,i.employee?`Employee: ${i.employee}`:null,i.engine?`Engine: ${i.engine}`:null,i.model?`Model: ${i.model}`:null,"number"==typeof i.lastContextTokens?`Context: ${hJ(i.lastContextTokens)}`:null,i.createdAt?`Created: ${i.createdAt}`:null].filter(Boolean).join("\n");C(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:s,timestamp:Date.now()}])}catch{C(e=>[...e,{id:crypto.randomUUID(),role:"assistant",content:"Failed to fetch session status.",timestamp:Date.now()}])}},[e]),et=(0,g.useCallback)(()=>{C([]),E(!1),O(null),D(!1),P(!1),T.current="",I(""),j.current=-1},[]),[ei,es]=(0,g.useState)(!1),[er,en]=(0,g.useState)(),eo=(0,g.useRef)(0),ea=(0,g.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),eo.current++,e.dataTransfer.types.includes("Files")&&es(!0)},[]),el=(0,g.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),eo.current--,0===eo.current&&es(!1)},[]),eh=(0,g.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),ec=(0,g.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),eo.current=0,es(!1);let i=Array.from(e.dataTransfer.files);i.length>0&&en(i)},[]);return(0,p.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",background:"var(--bg)",position:"relative"},onClick:s,onDragEnter:ea,onDragLeave:el,onDragOver:eh,onDrop:ec,children:[ei&&(0,p.jsx)("div",{style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--bg) 85%, transparent)",backdropFilter:"blur(4px)",transition:"opacity 150ms ease-in-out"},children:(0,p.jsxs)("div",{style:{border:"2px dashed var(--accent)",borderRadius:"var(--radius-lg)",padding:"48px 64px",display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[(0,p.jsxs)("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,p.jsx)("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),(0,p.jsx)("polyline",{points:"17 8 12 3 7 8"}),(0,p.jsx)("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),(0,p.jsx)("span",{style:{color:"var(--text-secondary)",fontSize:"var(--text-body)"},children:"Drop files here"})]})}),!e&&0===w.length&&"chat"===u&&(0,p.jsx)("div",{className:"flex flex-1 items-center justify-center",children:(0,p.jsx)(ra,{employees:U,selectedEmployee:$,onSelect:K,portalName:a})}),"cli"===u&&e?H&&A?.engine==="claude"?(0,p.jsx)(hY,{sessionId:e}):(0,p.jsx)(rm,{sessionId:e}):e||w.length>0?(0,p.jsx)(s9,{messages:w,loading:k,streamingText:N,hasOlder:M,loadingOlder:R,onLoadOlder:()=>void G(),focusMessageId:S,hasNewer:B,onJumpToLatest:J}):null,"chat"===u&&e&&"number"==typeof A?.lastContextTokens&&(0,p.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",padding:"4px 12px 0"},children:(0,p.jsx)(hQ,{tokens:A.lastContextTokens,model:A.model})}),"chat"===u&&(0,p.jsx)(rd,{sessionId:e,events:d,paused:A?.paused??!1}),"chat"===u&&(0,p.jsx)(rn,{disabled:!1,loading:k,onSend:Q,onInterrupt:Z,onNewSession:et,onStatusRequest:ee,skillsVersion:c,events:d,droppedFiles:er,onDroppedFilesConsumed:()=>en(void 0),focusTrigger:b,onShortcutsClick:x})]})}let h1={meta:"⌘",shift:"⇧",alt:"⌥"},h2=["Navigation","Actions","Help"];function h5({shortcuts:e,onClose:i}){let s=(0,g.useRef)(null),[r,n]=(0,g.useState)(!1),o=(0,g.useCallback)(()=>{n(!0),setTimeout(()=>i(),150)},[i]);(0,g.useEffect)(()=>{function e(e){s.current&&!s.current.contains(e.target)&&o()}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]);let a=e.filter(e=>!1!==e.enabled),l=h2.map(e=>({category:e,items:a.filter(i=>i.category===e)})).filter(e=>e.items.length>0);return(0,p.jsxs)("div",{ref:s,role:"complementary","aria-label":"Keyboard shortcuts",className:`fixed bottom-4 right-4 z-40 w-[280px] overflow-hidden rounded-[var(--radius-lg)] border border-border bg-[var(--material-thick)] shadow-[var(--shadow-overlay)] backdrop-blur-xl transition-opacity duration-150 ${r?"opacity-0":"animate-fade-in"}`,children:[(0,p.jsxs)("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-border",children:[(0,p.jsx)("span",{className:"text-sm font-semibold text-foreground",children:"Keyboard Shortcuts"}),(0,p.jsx)("button",{onClick:o,className:"rounded-sm p-0.5 text-muted-foreground transition-colors hover:text-foreground","aria-label":"Close",children:(0,p.jsx)(R.X,{className:"size-3.5"})})]}),(0,p.jsx)("div",{className:"px-3 py-2 max-h-[60vh] overflow-y-auto",children:l.map((e,i)=>(0,p.jsxs)("div",{className:i>0?"mt-3":"",children:[(0,p.jsx)("div",{className:"mb-1.5 text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:e.category}),(0,p.jsx)("div",{className:"space-y-1",children:e.items.map(e=>(0,p.jsxs)("div",{className:"flex items-center gap-2 py-0.5",children:[(0,p.jsx)("kbd",{className:"inline-flex min-w-[24px] items-center justify-center rounded-[var(--radius-sm)] bg-[var(--fill-tertiary)] px-1.5 py-0.5 font-mono text-xs font-medium text-foreground",children:function(e){let i=[];for(let s of e.modifiers??[])i.push(h1[s]??s);let s=1===e.key.length?e.key.toUpperCase():e.key;return i.push(s),i.join("")}(e)}),(0,p.jsx)("span",{className:"text-xs text-muted-foreground",children:e.description})]},e.key+(e.modifiers?.join("")??"")))})]},e.category))})]})}let h3="jinn-chat-tabs",h4="jinn-chat-draft-";var h6=e.i(38181),h8=e.i(23880),h7=e.i(42095),h9=e.i(34549);class ce extends g.default.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,i){console.error("[ChatErrorBoundary]",e.message,"\nComponent stack:",i.componentStack)}render(){return this.state.error?(0,p.jsx)(x.PageLayout,{children:(0,p.jsxs)("div",{className:"flex h-full flex-col items-center justify-center gap-4 p-8 text-center",children:[(0,p.jsx)("p",{className:"text-lg font-semibold text-[var(--system-red)]",children:"チャットがクラッシュしました"}),(0,p.jsxs)("pre",{className:"max-w-lg overflow-auto rounded-lg bg-[var(--bg-tertiary)] p-4 text-left text-xs text-muted-foreground",children:[this.state.error.message,"\n",this.state.error.stack?.split("\n").slice(0,5).join("\n")]}),(0,p.jsx)("button",{onClick:()=>{this.setState({error:null}),window.location.reload()},className:"rounded-md bg-[var(--accent)] px-4 py-2 text-sm font-medium text-white",children:"再読み込み"})]})}):this.props.children}}function ct(){let{settings:e}=(0,B.useSettings)(),i=e.portalName??"Ryoko",[s,r]=(0,g.useState)(null),[n,o]=(0,g.useState)("sidebar"),[a,l]=(0,g.useState)(null),[h,c]=(0,g.useState)([]),d=(0,g.useRef)(!1),[u,f]=(0,g.useState)(()=>"true"===localStorage.getItem("jinn-chat-sidebar-collapsed")),_=(0,g.useCallback)(()=>{window.innerWidth<1024?o(e=>"sidebar"===e?"chat":"sidebar"):f(e=>{let i=!e;return localStorage.setItem("jinn-chat-sidebar-collapsed",String(i)),i})},[]),[S,y]=(0,g.useState)("chat"),[w,C]=(0,g.useState)(!1),[E,M]=(0,g.useState)(!1),[D,R]=(0,g.useState)(null),[L,P]=(0,g.useState)(0),N=(0,g.useRef)(null),I=(0,g.useRef)(null),{events:j,connectionSeq:A,skillsVersion:O,subscribe:H}=(0,b.useGateway)(),z=function(){let[{tabs:e,activeIndex:i},s]=(0,g.useState)({tabs:[],activeIndex:-1});(0,g.useEffect)(()=>{s(function(){try{let i=localStorage.getItem(h3);if(i){var e;return e=JSON.parse(i),0===e.tabs.length?{tabs:[],activeIndex:-1}:e.activeIndex<0||e.activeIndex>=e.tabs.length?{tabs:e.tabs,activeIndex:0}:e}}catch{}return{tabs:[],activeIndex:-1}}())},[]),(0,g.useEffect)(()=>{localStorage.setItem(h3,JSON.stringify({tabs:e,activeIndex:i}))},[e,i]);let r=i>=0?e[i]:null,n=(0,g.useCallback)(e=>{s(i=>{let s=i.tabs.findIndex(i=>i.sessionId===e.sessionId);if(s>=0)return{...i,activeIndex:s};if(!e.pinned){let s=i.tabs.findIndex(e=>!e.pinned);if(s>=0){let r=[...i.tabs];return r[s]={...e,pinned:!1},{tabs:r,activeIndex:s}}}if(i.tabs.length>=12){let s=i.tabs.findIndex(e=>!e.pinned);if(s>=0){let r=[...i.tabs];return r[s]=e,{tabs:r,activeIndex:s}}}return{tabs:[...i.tabs,e],activeIndex:i.tabs.length}})},[]),o=(0,g.useCallback)(e=>{s(i=>{if(e<0||e>=i.tabs.length||i.tabs[e].pinned)return i;let s=i.tabs.map((i,s)=>s===e?{...i,pinned:!0}:i);return{...i,tabs:s}})},[]),a=(0,g.useCallback)(e=>{s(i=>{let s=i.tabs[e]?.sessionId;s&&localStorage.removeItem(h4+s);let r=i.tabs.filter((i,s)=>s!==e);if(0===r.length)return{tabs:[],activeIndex:-1};let n=i.activeIndex;return i.activeIndex===e?n=Math.min(e,r.length-1):i.activeIndex>e&&(n=i.activeIndex-1),{tabs:r,activeIndex:n}})},[]),l=(0,g.useCallback)(e=>{s(i=>e<0||e>=i.tabs.length?i:{...i,activeIndex:e})},[e.length]),h=(0,g.useCallback)((e,i)=>{s(s=>{if(e===i||e<0||e>=s.tabs.length||i<0||i>=s.tabs.length)return s;let r=[...s.tabs],[n]=r.splice(e,1);r.splice(i,0,n);let o=s.activeIndex;return s.activeIndex===e?o=i:e<s.activeIndex&&i>=s.activeIndex?o=s.activeIndex-1:e>s.activeIndex&&i<=s.activeIndex&&(o=s.activeIndex+1),{tabs:r,activeIndex:o}})},[]),c=(0,g.useCallback)(()=>{s(e=>0===e.tabs.length?e:{...e,activeIndex:(e.activeIndex+1+e.tabs.length)%e.tabs.length})},[e.length]),d=(0,g.useCallback)(()=>{s(e=>0===e.tabs.length?e:{...e,activeIndex:(e.activeIndex-1+e.tabs.length)%e.tabs.length})},[e.length]),u=(0,g.useCallback)(()=>{s(e=>({...e,activeIndex:-1}))},[]),f=(0,g.useCallback)((e,i)=>{i.trim()?localStorage.setItem(h4+e,i):localStorage.removeItem(h4+e)},[]),_=(0,g.useCallback)(e=>localStorage.getItem(h4+e)||"",[]),p=(0,g.useCallback)((e,i)=>{s(s=>{let r=s.tabs.findIndex(i=>i.sessionId===e);if(r<0)return s;let n=s.tabs[r];if(Object.keys(i).every(e=>n[e]===i[e]))return s;let o=s.tabs.map((e,s)=>s===r?{...e,...i}:e);return{...s,tabs:o}})},[]);return(0,g.useMemo)(()=>({tabs:e,activeTab:r,activeIndex:i,openTab:n,closeTab:a,switchTab:l,nextTab:c,prevTab:d,pinTab:o,moveTab:h,clearActiveTab:u,saveDraft:f,loadDraft:_,updateTabStatus:p}),[e,r,i,n,a,l,c,d,o,h,u,f,_,p])}(),W=(0,m.useSearchParams)(),F=(0,m.useRouter)(),$=(0,g.useRef)(null),K=(0,g.useRef)(!1),U=(0,g.useRef)(!1),q=(0,T.useDeleteSession)(),V=(0,T.useDuplicateSession)(),Y=(0,h6.useQueryClient)(),[X,G]=(0,g.useState)(!1),J=(0,g.useRef)({sessionIds:[],employeeNames:[],employeeSessionMap:{}}),Z=(0,g.useCallback)(e=>{J.current=e},[]);(0,g.useEffect)(()=>{if(w||E)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){w&&N.current&&!N.current.contains(e.target)&&C(!1),E&&I.current&&!I.current.contains(e.target)&&M(!1)}},[w,E]);let Q=(0,g.useCallback)((e,i)=>{navigator.clipboard.writeText(e),R(i),C(!1),setTimeout(()=>R(null),1500)},[]);function ee(){v.api.createStubSession({greeting:"Hey! 👋 Say hi when you're ready to get started.",title:"Welcome"}).then(e=>{let i=String(e.id);U.current=!0,r(i),Y.invalidateQueries({queryKey:h8.queryKeys.sessions.all})}).catch(()=>{})}(0,g.useEffect)(()=>{K.current||("1"===W.get("onboarding")?(K.current=!0,ee()):v.api.getOnboarding().then(e=>{e.needed&&!K.current&&(K.current=!0,ee())}).catch(()=>{}))},[W]);let{updateTabStatus:et}=z;(0,g.useEffect)(()=>{s&&a&&et(s,{label:a.title||a.employee||i,employeeName:a.employee||void 0})},[s,a,i,et]);let ei=(0,g.useCallback)(e=>{c(e.length>1?e:[])},[]),es=(0,g.useCallback)(e=>{d.current=!1,U.current=!1,r(e),o("chat"),y("chat"),z.openTab({sessionId:e,label:"Loading...",status:"idle",unread:!1})},[z]);(0,g.useEffect)(()=>{var e,i;let r=(e=W.get("session"),i=$.current,e?e===i?{appliedMarker:i,sessionIdToSelect:null}:{appliedMarker:e,sessionIdToSelect:e===s?null:e}:{appliedMarker:null,sessionIdToSelect:null});$.current=r.appliedMarker,r.sessionIdToSelect&&es(r.sessionIdToSelect)},[W,s,es]);let er=(0,g.useCallback)(()=>{d.current=!0,r(null),l(null),o("chat"),c([]),z.clearActiveTab(),P(e=>e+1)},[z]),en=(0,g.useCallback)(()=>{let e=new URLSearchParams(W.toString());e.delete("message"),F.replace(`/chat${e.size?`?${e}`:""}`,{scroll:!1})},[F,W]),eo=(0,g.useCallback)(e=>{s||K.current||d.current||!(e.length>0)||es(e[0].id)},[s,es]),ea=(0,g.useCallback)(async e=>{try{await q.mutateAsync(e)}catch{}s===e&&(r(null),l(null)),sG(e),z.closeTab(z.tabs.findIndex(i=>i.sessionId===e)),C(!1),Y.invalidateQueries({queryKey:h8.queryKeys.sessions.all})},[s,z,q,Y]),el=(0,g.useCallback)(async e=>{try{let i=await V.mutateAsync(e);i?.id&&(r(i.id),z.openTab({sessionId:i.id,label:i.title||"Duplicated Chat",status:"idle",unread:!1,pinned:!0,employeeName:i.employee||void 0}),C(!1),Y.invalidateQueries({queryKey:h8.queryKeys.sessions.all}))}catch(e){window.alert(`Duplicate failed: ${e.message||"Unknown error"}`)}},[z,V,Y]),eh=(0,g.useCallback)(e=>{z.openTab({sessionId:e,label:"Duplicated Chat",status:"idle",unread:!1,pinned:!0}),Y.invalidateQueries({queryKey:h8.queryKeys.sessions.all})},[z,Y]),ec=(0,g.useCallback)(e=>{r(e),z.openTab({sessionId:e,label:"New Chat",status:"running",unread:!1,pinned:!0}),Y.invalidateQueries({queryKey:h8.queryKeys.sessions.all})},[z,Y]),ed=(0,g.useCallback)(e=>{l(e)},[]),eu=(0,g.useCallback)(()=>{Y.invalidateQueries({queryKey:h8.queryKeys.sessions.all})},[Y]),ef=(0,g.useCallback)(e=>`This is your first time being activated. The user just set up ${i} and opened the web dashboard for the first time.
|
|
73
|
-
|
|
74
|
-
Read your CLAUDE.md instructions and the onboarding skill at ./skills/onboarding/SKILL.md (relative to your home directory, which is your working directory), then follow the onboarding flow:
|
|
75
|
-
- Greet the user warmly and introduce yourself as ${i}
|
|
76
|
-
- Briefly explain what you can do (manage cron jobs, hire AI employees, connect to Slack, etc.)
|
|
77
|
-
- Ask the user what they'd like to set up first
|
|
78
|
-
|
|
79
|
-
The user said: "${e}"`,[i]),e_=(0,g.useCallback)(()=>{U.current=!1},[]),ep=(0,g.useCallback)(e=>{let{sessionIds:i}=J.current;if(0===i.length)return;if(!s)return void es(1===e?i[0]:i[i.length-1]);let r=i.indexOf(s);if(-1===r)return void es(1===e?i[0]:i[i.length-1]);let n=(r+e+i.length)%i.length;es(i[n])},[s,es]),eg=(0,g.useCallback)(()=>{let{employeeNames:e,employeeSessionMap:i}=J.current;if(0===e.length)return;let s=a?.employee??null,r=((s?e.indexOf(s):-1)+1)%e.length,n=e[r],o=i[n]?.[0];o&&es(o)},[a,es]),em=(0,g.useCallback)(async()=>{if(s)try{let e=await v.api.getSessionMessages(s,void 0,200),i=[...e.messages];for(;e.hasOlder&&i.length<1e4;)i=[...(e=await v.api.getSessionMessages(s,i[0]?.id,200)).messages,...i];let r=i.filter(e=>"user"===e.role||"assistant"===e.role).map(e=>`[${e.role}]: ${e.content}`).join("\n\n");await navigator.clipboard.writeText(r),R("chat"),setTimeout(()=>R(null),1500)}catch{}},[s]),ev=(0,g.useMemo)(()=>[{key:"n",category:"Actions",description:"New chat",action:er},{key:"j",category:"Navigation",description:"Next session",action:()=>ep(1)},{key:"k",category:"Navigation",description:"Previous session",action:()=>ep(-1)},{key:"e",category:"Navigation",description:"Next employee",action:eg},{key:"Backspace",category:"Actions",description:"Delete session",action:()=>{s&&window.confirm("Delete this session?")&&ea(s)},enabled:!!s},{key:"Delete",category:"Actions",description:"Delete session",action:()=>{s&&window.confirm("Delete this session?")&&ea(s)},enabled:!!s},{key:"c",category:"Actions",description:"Copy chat",action:em,enabled:!!s},{key:"Escape",category:"Navigation",description:"Close overlay",action:()=>{X?G(!1):w&&C(!1)}},{key:"/",category:"Actions",description:"Focus chat",action:()=>{let e=document.getElementById("chat-textarea");e&&e.focus()}},{key:"?",category:"Help",description:"Keyboard shortcuts",action:()=>G(e=>!e)},{key:"w",modifiers:["meta"],category:"Actions",description:"Close tab",action:()=>{z.activeIndex>=0&&z.closeTab(z.activeIndex)}},{key:"[",modifiers:["meta","shift"],category:"Navigation",description:"Previous tab",action:()=>z.prevTab()},{key:"]",modifiers:["meta","shift"],category:"Navigation",description:"Next tab",action:()=>z.nextTab()},...Array.from({length:9},(e,i)=>({key:String(i+1),modifiers:["meta","alt"],category:"Navigation",description:`Tab ${i+1}`,action:()=>z.switchTab(i)}))],[er,ep,eg,em,s,X,w,z]);!function(e,i={}){(0,g.useEffect)(()=>{function s(s){s.key;let r=document.activeElement,n=r?.tagName?.toLowerCase()??"",o="input"===n||"textarea"===n||r?.isContentEditable===!0;for(let r of e){if(!1===r.enabled||!function(e,i){let s=i.modifiers??[],r=s.includes("meta"),n=s.includes("shift"),o=s.includes("alt");return"?"===i.key?"?"===e.key&&!e.metaKey&&!e.altKey&&!e.ctrlKey:(1===e.key.length?e.key.toLowerCase():e.key)===(1===i.key.length?i.key.toLowerCase():i.key)&&r===e.metaKey&&n===e.shiftKey&&o===e.altKey&&(!e.ctrlKey||!!r)}(s,r))continue;let e=(r.modifiers??[]).length>0,n="Escape"===r.key;if((!i.isModalOpen||n)&&(!o||e||n)){s.preventDefault(),r.action();return}}}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,i.isModalOpen])}(ev),(0,g.useEffect)(()=>{if(z.activeTab&&z.activeTab.sessionId!==s){r(z.activeTab.sessionId),y("chat");return}z.activeTab||!s||d.current||(r(null),l(null),c([]))},[z.activeTab,s]);let eb=s?(0,p.jsxs)("div",{ref:N,className:"relative",children:[(0,p.jsx)("button",{onClick:()=>C(e=>!e),"aria-label":"More options",className:"flex items-center rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",children:(0,p.jsx)(k,{className:"size-[18px]"})}),w&&(0,p.jsxs)("div",{className:"absolute right-0 top-full z-[200] mt-1 min-w-[220px] overflow-hidden rounded-[var(--radius-md)] border border-border bg-[var(--material-thick)] shadow-[var(--shadow-overlay)] backdrop-blur-xl",children:[(0,p.jsx)("button",{onClick:()=>Q(s,"id"),className:"block w-full px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent",children:"Copy Session ID"}),a?.engineSessionId&&(0,p.jsx)("button",{onClick:()=>{let e="codex"===a.engine?"codex":"claude";Q(`${e} --resume ${a.engineSessionId}`,"cli")},className:"block w-full px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent",children:"Copy CLI Resume Command"}),(0,p.jsxs)("button",{onClick:()=>{s&&el(s)},disabled:V.isPending,className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-accent disabled:opacity-50",children:[(0,p.jsx)(h9.Copy,{className:"size-3.5"}),(0,p.jsx)("span",{className:"flex-1",children:V.isPending?"Duplicating...":"Duplicate..."})]}),(0,p.jsx)("div",{className:"my-0.5 border-t border-border"}),(0,p.jsxs)("button",{onClick:()=>{C(!1),s&&window.confirm("このセッションを削除しますか?")&&ea(s)},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-sm text-[var(--system-red)] transition-colors hover:bg-accent",children:[(0,p.jsx)(rc.Trash2,{className:"size-3.5"}),(0,p.jsx)("span",{className:"flex-1",children:"セッションを削除"}),(0,p.jsx)("kbd",{className:"font-mono text-[10px] text-[var(--text-quaternary)]",children:"⌫"})]})]})]}):null,ex=(0,p.jsxs)(p.Fragment,{children:[s&&(0,p.jsxs)("div",{className:"flex items-center gap-0.5 rounded-full bg-[var(--fill-tertiary)] p-0.5",children:[(0,p.jsx)("button",{onClick:()=>y("chat"),className:(0,i3.cn)("rounded-full px-2.5 py-1 text-[11px] font-medium transition-all","chat"===S?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"Chat"}),(0,p.jsx)("button",{onClick:()=>y("cli"),className:(0,i3.cn)("rounded-full px-2.5 py-1 font-mono text-[11px] font-medium transition-all","cli"===S?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:"CLI"})]}),(0,p.jsx)("div",{className:"hidden lg:block",children:eb}),D&&(0,p.jsxs)("div",{className:"flex items-center gap-1 whitespace-nowrap text-xs font-medium text-[var(--accent)]",children:[(0,p.jsx)(h7.Check,{className:"size-3"}),"Copied!"]})]});return(0,p.jsxs)(x.PageLayout,{mobileHeaderActions:eb,children:[(0,p.jsxs)("div",{className:"flex overflow-hidden h-full",children:[(0,p.jsx)("div",{className:"hidden h-full shrink-0 overflow-hidden lg:block",style:{width:280*!u,transition:"width 200ms ease-in-out"},children:(0,p.jsx)("div",{className:"h-full w-[280px]",children:(0,p.jsx)(s$,{selectedId:s,onSelect:es,onNewChat:er,onDelete:ea,onDuplicate:eh,onSessionsLoaded:eo,onEmployeeSessionsAvailable:ei,onOrderComputed:Z})})}),(0,p.jsxs)("div",{className:"min-w-0 flex-1 flex-col overflow-hidden bg-background flex",children:[(0,p.jsx)(sY,{tabs:z.tabs,activeIndex:z.activeIndex,onSwitch:z.switchTab,onClose:z.closeTab,onNew:er,onPin:z.pinTab,onMove:z.moveTab,toolbarActions:ex,sidebarCollapsed:"chat"===n||u,onToggleSidebar:_}),(0,p.jsx)("div",{className:"sidebar"===n?"flex-1 overflow-hidden lg:hidden":"hidden",children:(0,p.jsx)(s$,{selectedId:s,onSelect:es,onNewChat:er,onDelete:ea,onDuplicate:eh,onSessionsLoaded:eo,onEmployeeSessionsAvailable:ei,onOrderComputed:Z})}),(0,p.jsx)("div",{className:(0,i3.cn)("flex-1 overflow-hidden flex flex-col","sidebar"===n?"hidden lg:flex":"flex"),children:(0,p.jsx)(h0,{sessionId:s,isActive:!0,onFocus:()=>{},onSessionCreated:ec,onSessionMetaChange:ed,onRefresh:eu,portalName:i,subscribe:H,connectionSeq:A,skillsVersion:O,events:j,viewMode:S,getOnboardingPrompt:U.current?ef:void 0,isStubSession:U.current,onStubCleared:e_,focusTrigger:L,onShortcutsClick:()=>G(!0),focusMessageId:W.get("message"),onFocusDismissed:en})})]})]}),X&&(0,p.jsx)(h5,{shortcuts:ev,onClose:()=>G(!1)})]})}e.s(["default",0,function(){return(0,p.jsx)(ce,{children:(0,p.jsx)(g.Suspense,{fallback:(0,p.jsx)(x.PageLayout,{children:(0,p.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Loading..."})}),children:(0,p.jsx)(ct,{})})})}],59794)}]);
|