@cortex-agent/server 2026.10.6 → 2026.10.15-2
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/README.md +200 -170
- package/defaults/AGENTS.md +2 -1
- package/defaults/board/board.css +111 -0
- package/defaults/board/scaffold.html +76 -0
- package/defaults/config/environments/creative.json +0 -2
- package/defaults/config/environments/main.json +2 -9
- package/defaults/config/hooks/05-memory-ref-tracker.json +1 -2
- package/defaults/config/hooks/06-rules-loader.json +1 -2
- package/defaults/config/hooks/07-session-activity-tracker.json +1 -2
- package/defaults/config/hooks/08-agents-md-injector-post-tool.json +1 -2
- package/defaults/config/hooks/10-agents-md-injector-session-start.json +1 -2
- package/defaults/config/hooks/12-session-new-hook.json +1 -2
- package/defaults/config/hooks/13-status-md-guard.json +1 -2
- package/defaults/gitignore +5 -3
- package/defaults/hooks/agents-md-injector.mjs +22 -137
- package/defaults/hooks/cortex-context-lib.d.mts +53 -0
- package/defaults/hooks/cortex-context-lib.mjs +269 -0
- package/defaults/hooks/cortex-hook-api.mjs +0 -1
- package/defaults/hooks/git-support.mjs +33 -0
- package/defaults/hooks/memory-ref-tracker.mjs +2 -1
- package/defaults/hooks/new-session-hook.mjs +3 -17
- package/defaults/hooks/overlay/register.mjs +14 -0
- package/defaults/hooks/overlay/resolve.mjs +26 -0
- package/defaults/hooks/rules-loader.mjs +22 -99
- package/defaults/hooks/session-activity-tracker.mjs +0 -1
- package/defaults/hooks/status-md-guard.mjs +0 -1
- package/defaults/plugins/cortex-board/plugin.json +6 -0
- package/defaults/plugins/cortex-board/skills/board/SKILL.md +92 -0
- package/defaults/plugins/cortex-system/plugin.json +2 -2
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +4 -12
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +37 -172
- package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +2 -8
- package/defaults/rules/experiment-format.md +4 -10
- package/defaults/rules/meta-conventions.md +6 -6
- package/dist/agent-adapter/browser-mcp-server.d.ts +3 -4
- package/dist/agent-adapter/browser-mcp-server.js +3 -4
- package/dist/agent-adapter/claude/adapter.d.ts +18 -119
- package/dist/agent-adapter/claude/adapter.js +41 -322
- package/dist/agent-adapter/claude/compact-window.d.ts +1 -0
- package/dist/agent-adapter/claude/compact-window.js +4 -6
- package/dist/agent-adapter/claude/defaults.d.ts +3 -14
- package/dist/agent-adapter/claude/defaults.js +4 -18
- package/dist/agent-adapter/claude/engine.d.ts +2 -5
- package/dist/agent-adapter/claude/engine.js +11 -69
- package/dist/agent-adapter/claude/event-translator.d.ts +1 -1
- package/dist/agent-adapter/claude/event-translator.js +10 -20
- package/dist/agent-adapter/claude/hooks-builder.d.ts +0 -8
- package/dist/agent-adapter/claude/hooks-builder.js +3 -29
- package/dist/agent-adapter/claude/mcp-config.js +4 -4
- package/dist/agent-adapter/claude/session-options.d.ts +74 -0
- package/dist/agent-adapter/claude/session-options.js +157 -0
- package/dist/agent-adapter/claude/spawn-args.d.ts +10 -23
- package/dist/agent-adapter/claude/spawn-args.js +39 -29
- package/dist/agent-adapter/claude/transcript-path.d.ts +2 -1
- package/dist/agent-adapter/claude/transcript-path.js +4 -3
- package/dist/agent-adapter/claude/turn-machine.d.ts +0 -3
- package/dist/agent-adapter/claude/turn-machine.js +6 -19
- package/dist/agent-adapter/continuation-phase.d.ts +18 -15
- package/dist/agent-adapter/continuation-phase.js +31 -61
- package/dist/agent-adapter/engine-injections.d.ts +47 -0
- package/dist/agent-adapter/engine-injections.js +80 -0
- package/dist/agent-adapter/normalize/event-types.d.ts +2 -45
- package/dist/agent-adapter/normalize/event-types.js +1 -56
- package/dist/agent-adapter/pi/adapter.d.ts +3 -1
- package/dist/agent-adapter/pi/adapter.js +8 -13
- package/dist/agent-adapter/pi/agent-dir.d.ts +1 -1
- package/dist/agent-adapter/pi/agent-dir.js +3 -3
- package/dist/agent-adapter/pi/background-subagent.d.ts +7 -2
- package/dist/agent-adapter/pi/child-runner.d.ts +4 -11
- package/dist/agent-adapter/pi/child-runner.js +4 -14
- package/dist/agent-adapter/pi/child-session.d.ts +2 -0
- package/dist/agent-adapter/pi/child-session.js +13 -6
- package/dist/agent-adapter/pi/engine.d.ts +2 -5
- package/dist/agent-adapter/pi/engine.js +8 -63
- package/dist/agent-adapter/pi/event-parser.js +1 -1
- package/dist/agent-adapter/pi/extensions.d.ts +2 -0
- package/dist/agent-adapter/pi/extensions.js +16 -2
- package/dist/agent-adapter/pi/hook-bridge.js +6 -5
- package/dist/agent-adapter/pi/mcp-bridge.js +13 -8
- package/dist/agent-adapter/pi/native-tool-policy.d.ts +3 -0
- package/dist/agent-adapter/pi/native-tool-policy.js +11 -0
- package/dist/agent-adapter/pi/pi-session.d.ts +3 -0
- package/dist/agent-adapter/pi/pi-session.js +8 -4
- package/dist/agent-adapter/pi/providers-config.d.ts +2 -2
- package/dist/agent-adapter/pi/providers-config.js +1 -1
- package/dist/agent-adapter/pi/quota-sink.d.ts +3 -3
- package/dist/agent-adapter/pi/quota-sink.js +3 -3
- package/dist/agent-adapter/pi/runtime-settings.js +13 -0
- package/dist/agent-adapter/pi/runtime.d.ts +2 -0
- package/dist/agent-adapter/pi/runtime.js +7 -1
- package/dist/agent-adapter/pi/session-options.d.ts +10 -7
- package/dist/agent-adapter/pi/session-options.js +17 -16
- package/dist/agent-adapter/pi/subagent.d.ts +2 -0
- package/dist/agent-adapter/pi/subagent.js +15 -10
- package/dist/agent-adapter/pi/tool-shims.js +14 -26
- package/dist/agent-adapter/pi/web-fetch.js +2 -3
- package/dist/agent-adapter/pi/web-search.js +5 -25
- package/dist/agent-adapter/run-events.d.ts +1 -15
- package/dist/agent-adapter/run-events.js +0 -2
- package/dist/agent-adapter/types.d.ts +13 -20
- package/dist/client-bundle/client.mjs +4859 -0
- package/dist/client-bundle/cortex-run-watcher.mjs +4 -0
- package/dist/client-bundle/manifest.json +5 -0
- package/dist/core/agents/roles.d.ts +14 -11
- package/dist/core/agents/roles.js +43 -37
- package/dist/core/agents/subagent/catalog.d.ts +15 -6
- package/dist/core/agents/subagent/catalog.js +23 -61
- package/dist/core/agents/subagent/model-spec.d.ts +28 -0
- package/dist/core/agents/subagent/model-spec.js +39 -0
- package/dist/core/agents/subagent/schema.d.ts +2 -2
- package/dist/core/agents/subagent/schema.js +4 -6
- package/dist/core/atomic-write.js +6 -127
- package/dist/core/board-action.d.ts +19 -0
- package/dist/core/board-action.js +24 -0
- package/dist/core/builtin-layer.d.ts +22 -0
- package/dist/core/builtin-layer.js +45 -0
- package/dist/core/claude-credentials.d.ts +46 -9
- package/dist/core/claude-credentials.js +117 -64
- package/dist/core/codex-quota.d.ts +1 -1
- package/dist/core/codex-quota.js +1 -1
- package/dist/core/codex-token.d.ts +4 -0
- package/dist/core/codex-token.js +26 -0
- package/dist/core/debug-mode.d.ts +1 -1
- package/dist/core/debug-mode.js +2 -2
- package/dist/core/exec-async.d.ts +3 -1
- package/dist/core/exec-async.js +2 -1
- package/dist/core/file-lock.d.ts +15 -0
- package/dist/core/file-lock.js +164 -0
- package/dist/core/format-duration.d.ts +7 -0
- package/dist/core/format-duration.js +23 -0
- package/dist/core/gateway-generator.d.ts +27 -21
- package/dist/core/gateway-generator.js +116 -120
- package/dist/core/git-availability.d.ts +2 -0
- package/dist/core/git-availability.js +43 -0
- package/dist/core/hook-bus.d.ts +3 -1
- package/dist/core/hook-bus.js +7 -8
- package/dist/core/hook-scripts.d.ts +19 -0
- package/dist/core/hook-scripts.js +30 -0
- package/dist/core/json-repository.d.ts +25 -2
- package/dist/core/json-repository.js +68 -42
- package/dist/core/locales/en.d.ts +102 -106
- package/dist/core/locales/slices/commands.d.ts +47 -34
- package/dist/core/locales/slices/commands.js +96 -70
- package/dist/core/locales/slices/init.d.ts +12 -20
- package/dist/core/locales/slices/init.js +25 -55
- package/dist/core/locales/slices/interactions.d.ts +3 -3
- package/dist/core/locales/slices/interactions.js +6 -6
- package/dist/core/locales/slices/notices.d.ts +4 -4
- package/dist/core/locales/slices/notices.js +8 -8
- package/dist/core/locales/slices/scheduling.d.ts +9 -10
- package/dist/core/locales/slices/scheduling.js +18 -20
- package/dist/core/locales/slices/startup.d.ts +2 -0
- package/dist/core/locales/slices/startup.js +4 -0
- package/dist/core/locales/slices/status.d.ts +6 -4
- package/dist/core/locales/slices/status.js +12 -8
- package/dist/core/locales/slices/tui.d.ts +0 -1
- package/dist/core/locales/slices/tui.js +0 -2
- package/dist/core/locales/slices/uiextra.d.ts +12 -8
- package/dist/core/locales/slices/uiextra.js +24 -16
- package/dist/core/locales/slices/uimsg.d.ts +7 -22
- package/dist/core/locales/slices/uimsg.js +16 -46
- package/dist/core/mcp-bundles.d.ts +1 -1
- package/dist/core/mcp-bundles.js +1 -0
- package/dist/core/mcp-tool-gate.d.ts +3 -0
- package/dist/core/mcp-tool-gate.js +8 -6
- package/dist/core/media-types.d.ts +5 -0
- package/dist/core/media-types.js +24 -0
- package/dist/core/models-generator.d.ts +29 -0
- package/dist/core/models-generator.js +82 -0
- package/dist/core/paths.d.ts +21 -4
- package/dist/core/paths.js +21 -4
- package/dist/core/pi-sdk.d.ts +9 -0
- package/dist/core/pi-sdk.js +28 -0
- package/dist/core/private-dir.d.ts +13 -0
- package/dist/core/private-dir.js +48 -0
- package/dist/core/process-command-line.d.ts +6 -0
- package/dist/core/process-command-line.js +39 -0
- package/dist/core/run-registry.d.ts +2 -0
- package/dist/core/run-registry.js +1 -1
- package/dist/core/settings-spec.d.ts +5 -14
- package/dist/core/settings-spec.js +6 -18
- package/dist/core/short-session-id.d.ts +2 -0
- package/dist/core/short-session-id.js +4 -0
- package/dist/core/singleton-lock.d.ts +19 -3
- package/dist/core/singleton-lock.js +91 -15
- package/dist/core/status-format.d.ts +6 -7
- package/dist/core/status-format.js +9 -15
- package/dist/core/subagent-spawn.d.ts +40 -0
- package/dist/core/subagent-spawn.js +47 -0
- package/dist/core/team-action.d.ts +28 -0
- package/dist/core/team-action.js +65 -0
- package/dist/{agent-adapter/normalize → core}/todo.d.ts +1 -2
- package/dist/{agent-adapter/normalize → core}/todo.js +1 -1
- package/dist/core/types/agent-types.d.ts +0 -2
- package/dist/core/types/environment-types.d.ts +7 -21
- package/dist/core/utils.d.ts +6 -0
- package/dist/core/utils.js +14 -0
- package/dist/core/workspace-filenames.d.ts +9 -0
- package/dist/core/workspace-filenames.js +61 -0
- package/dist/domain/agents/agent-state.d.ts +11 -56
- package/dist/domain/agents/agent-state.js +48 -123
- package/dist/domain/agents/agent-switch.d.ts +2 -24
- package/dist/domain/agents/agent-switch.js +12 -75
- package/dist/domain/agents/config.d.ts +12 -111
- package/dist/domain/agents/config.js +56 -443
- package/dist/domain/agents/engine-selection.d.ts +21 -0
- package/dist/domain/agents/engine-selection.js +37 -0
- package/dist/domain/agents/environments/entities.d.ts +1 -0
- package/dist/domain/agents/environments/entities.js +1 -1
- package/dist/domain/agents/environments/file-refs.d.ts +4 -3
- package/dist/domain/agents/environments/file-refs.js +14 -11
- package/dist/domain/agents/environments/index.d.ts +2 -1
- package/dist/domain/agents/environments/index.js +2 -1
- package/dist/domain/agents/environments/registry.d.ts +3 -3
- package/dist/domain/agents/environments/registry.js +10 -7
- package/dist/domain/agents/environments/resolve.d.ts +11 -0
- package/dist/domain/agents/environments/resolve.js +36 -0
- package/dist/domain/agents/environments/schema.d.ts +2 -2
- package/dist/domain/agents/environments/schema.js +7 -4
- package/dist/domain/agents/environments/system-prompt.d.ts +37 -0
- package/dist/domain/agents/environments/system-prompt.js +110 -0
- package/dist/domain/agents/index.d.ts +2 -1
- package/dist/domain/agents/index.js +3 -7
- package/dist/domain/agents/model-selection.d.ts +18 -70
- package/dist/domain/agents/model-selection.js +100 -150
- package/dist/domain/agents/models.d.ts +12 -0
- package/dist/domain/agents/models.js +94 -0
- package/dist/domain/agents/subagent/background-spend.d.ts +17 -0
- package/dist/domain/agents/subagent/background-spend.js +42 -0
- package/dist/domain/agents/subagent/runner.d.ts +6 -18
- package/dist/domain/agents/subagent/runner.js +20 -81
- package/dist/domain/auth/anthropic-env.d.ts +20 -0
- package/dist/domain/auth/anthropic-env.js +132 -0
- package/dist/domain/auth/auth-status.d.ts +4 -5
- package/dist/domain/auth/auth-status.js +26 -64
- package/dist/domain/auth/auth-watch.js +36 -21
- package/dist/domain/auth/cc-auth-cli.d.ts +1 -0
- package/dist/domain/auth/cc-auth-cli.js +42 -20
- package/dist/domain/auth/cc-login.d.ts +1 -1
- package/dist/domain/auth/cc-login.js +9 -2
- package/dist/domain/auth/cc-subscription.js +8 -7
- package/dist/domain/auth/claude-account-credentials.d.ts +13 -0
- package/dist/domain/auth/claude-account-credentials.js +22 -0
- package/dist/domain/auth/claude-user-settings.d.ts +17 -20
- package/dist/domain/auth/claude-user-settings.js +68 -163
- package/dist/domain/auth/codex-credentials.d.ts +13 -0
- package/dist/domain/auth/codex-credentials.js +25 -0
- package/dist/domain/auth/gateway-sync.d.ts +6 -26
- package/dist/domain/auth/gateway-sync.js +31 -43
- package/dist/domain/auth/login-flow.d.ts +14 -2
- package/dist/domain/auth/login-flow.js +86 -20
- package/dist/domain/auth/login-service.d.ts +6 -5
- package/dist/domain/auth/login-service.js +14 -42
- package/dist/domain/auth/logout.d.ts +1 -1
- package/dist/domain/auth/logout.js +67 -34
- package/dist/domain/auth/pi-login.d.ts +2 -0
- package/dist/domain/auth/pi-login.js +19 -11
- package/dist/domain/auth/pi-oauth.d.ts +2 -0
- package/dist/domain/auth/pi-oauth.js +24 -13
- package/dist/domain/auth/pi-runtime.d.ts +6 -0
- package/dist/{core/types → domain/benchmark}/benchmark-types.d.ts +1 -1
- package/dist/domain/benchmark/identity.d.ts +3 -5
- package/dist/domain/benchmark/identity.js +0 -1
- package/dist/domain/benchmark/production-attempt-identity.d.ts +6 -5
- package/dist/domain/benchmark/production-attempt-identity.js +33 -36
- package/dist/{core → domain/benchmark}/production-benchmark-evidence.d.ts +1 -1
- package/dist/domain/benchmark/session-evidence.d.ts +3 -2
- package/dist/domain/benchmark/session-evidence.js +8 -1
- package/dist/domain/boards/board-context.d.ts +17 -0
- package/dist/domain/boards/board-context.js +11 -0
- package/dist/domain/boards/board-paths.d.ts +18 -0
- package/dist/domain/boards/board-paths.js +32 -0
- package/dist/domain/boards/board-service.d.ts +50 -0
- package/dist/domain/boards/board-service.js +146 -0
- package/dist/domain/boards/board-watcher.d.ts +36 -0
- package/dist/domain/boards/board-watcher.js +284 -0
- package/dist/domain/{commissions → boards}/decision-projection.d.ts +11 -9
- package/dist/domain/boards/decision-projection.js +44 -0
- package/dist/domain/costs/account-reset.d.ts +30 -0
- package/dist/domain/costs/account-reset.js +98 -0
- package/dist/domain/costs/aistatus-config.d.ts +27 -0
- package/dist/domain/costs/aistatus-config.js +56 -0
- package/dist/domain/costs/claude-account.d.ts +34 -0
- package/dist/domain/costs/claude-account.js +149 -0
- package/dist/domain/costs/codex-account.d.ts +55 -0
- package/dist/domain/costs/codex-account.js +155 -0
- package/dist/domain/costs/cost-tracker.d.ts +2 -0
- package/dist/domain/costs/cost-tracker.js +4 -0
- package/dist/domain/costs/gateway-manager.js +2 -3
- package/dist/domain/costs/rate-limit-throttle.d.ts +14 -10
- package/dist/domain/costs/rate-limit-throttle.js +66 -25
- package/dist/domain/costs/reset-account.d.ts +34 -0
- package/dist/domain/costs/reset-account.js +5 -0
- package/dist/domain/costs/resume-registry.d.ts +1 -1
- package/dist/domain/costs/resume-registry.js +1 -8
- package/dist/domain/costs/usage-service.d.ts +24 -0
- package/dist/domain/costs/usage-service.js +206 -45
- package/dist/domain/costs/usage-store.d.ts +27 -0
- package/dist/domain/costs/usage-store.js +18 -1
- package/dist/domain/executions/registry.d.ts +18 -3
- package/dist/domain/executions/registry.js +40 -9
- package/dist/domain/mcp/bundled-server.js +15 -14
- package/dist/domain/mcp/feishu/file.js +2 -2
- package/dist/domain/mcp/tools/catalog-owner.d.ts +3 -0
- package/dist/domain/mcp/tools/catalog-owner.js +23 -0
- package/dist/domain/mcp/tools/context.d.ts +20 -13
- package/dist/domain/mcp/tools/context.js +42 -14
- package/dist/domain/mcp/tools/cost.js +1 -1
- package/dist/domain/mcp/tools/executions.js +2 -8
- package/dist/domain/mcp/tools/interaction-ask.js +7 -8
- package/dist/domain/mcp/tools/interaction-plan.js +2 -2
- package/dist/domain/mcp/tools/remote-devices.d.ts +9 -0
- package/dist/domain/mcp/tools/remote-devices.js +28 -0
- package/dist/domain/mcp/tools/remote-ops.js +19 -14
- package/dist/domain/mcp/tools/slack.js +2 -2
- package/dist/domain/mcp/tools/subagent.d.ts +0 -4
- package/dist/domain/mcp/tools/subagent.js +11 -21
- package/dist/domain/mcp/tools/time.js +2 -2
- package/dist/domain/mcp/tools/ui-board.d.ts +12 -0
- package/dist/domain/mcp/tools/ui-board.js +48 -0
- package/dist/domain/mcp/tools/ui-decision.js +8 -20
- package/dist/domain/mcp/tools/ui-file.js +6 -6
- package/dist/domain/mcp/tools/ui-view.js +7 -17
- package/dist/domain/mcp/tools/waitpoint.d.ts +25 -0
- package/dist/domain/mcp/tools/waitpoint.js +33 -45
- package/dist/domain/mcp/tools/workers.d.ts +2 -0
- package/dist/domain/mcp/tools/workers.js +33 -40
- package/dist/domain/memory/agents-md-injector.d.ts +4 -2
- package/dist/domain/memory/agents-md-injector.js +30 -128
- package/dist/domain/memory/consolidate.d.ts +2 -0
- package/dist/domain/memory/consolidate.js +36 -78
- package/dist/domain/memory/index-regen.d.ts +24 -7
- package/dist/domain/memory/index-regen.js +201 -265
- package/dist/domain/memory/rules-loader.d.ts +4 -3
- package/dist/domain/memory/rules-loader.js +7 -46
- package/dist/domain/memory/watcher.d.ts +8 -1
- package/dist/domain/memory/watcher.js +108 -34
- package/dist/domain/pi-providers/custom-provider-model.d.ts +1 -1
- package/dist/domain/pi-providers/custom-provider-model.js +1 -1
- package/dist/domain/pi-providers/custom-provider-service.js +15 -1
- package/dist/domain/pi-providers/gateway-route-store.js +5 -5
- package/dist/domain/plugins/authoring.d.ts +8 -8
- package/dist/domain/plugins/authoring.js +154 -43
- package/dist/domain/plugins/builtin.d.ts +25 -0
- package/dist/domain/plugins/builtin.js +44 -0
- package/dist/domain/plugins/catalog-types.d.ts +16 -2
- package/dist/domain/plugins/catalog-types.js +18 -1
- package/dist/domain/plugins/catalog.d.ts +36 -2
- package/dist/domain/plugins/catalog.js +165 -8
- package/dist/domain/plugins/conversation-skills.d.ts +10 -0
- package/dist/domain/plugins/conversation-skills.js +22 -0
- package/dist/domain/plugins/runtime-gc.d.ts +10 -0
- package/dist/domain/plugins/runtime-gc.js +68 -0
- package/dist/domain/plugins/runtime.d.ts +5 -0
- package/dist/domain/plugins/runtime.js +129 -82
- package/dist/domain/plugins/skill.d.ts +6 -2
- package/dist/domain/plugins/skill.js +4 -2
- package/dist/domain/remote/client-bootstrap.js +8 -14
- package/dist/domain/remote/client-hot-reload.d.ts +2 -1
- package/dist/domain/remote/client-hot-reload.js +53 -24
- package/dist/domain/remote/client-lifecycle.d.ts +32 -0
- package/dist/domain/remote/client-lifecycle.js +382 -0
- package/dist/domain/remote/client-manager.d.ts +22 -43
- package/dist/domain/remote/client-manager.js +189 -570
- package/dist/domain/remote/client-pids.d.ts +13 -0
- package/dist/domain/remote/client-pids.js +43 -0
- package/dist/domain/remote/client-protocol.d.ts +1 -0
- package/dist/domain/remote/client-protocol.js +1 -0
- package/dist/domain/remote/client-remove.js +2 -10
- package/dist/domain/remote/client-ssh-tunnel.d.ts +2 -0
- package/dist/domain/remote/client-ssh-tunnel.js +79 -13
- package/dist/domain/remote/device-port.d.ts +2 -1
- package/dist/domain/remote/local-client-install.d.ts +32 -0
- package/dist/domain/remote/local-client-install.js +168 -0
- package/dist/domain/remote/local-client-stop.d.ts +37 -0
- package/dist/domain/remote/local-client-stop.js +101 -0
- package/dist/domain/remote/owned-local-launch.d.ts +22 -0
- package/dist/domain/remote/owned-local-launch.js +75 -0
- package/dist/domain/remote/package-client-bundle.d.ts +14 -0
- package/dist/domain/remote/package-client-bundle.js +37 -0
- package/dist/domain/remote/reverse-stream.d.ts +3 -12
- package/dist/domain/remote/ssh-exec.d.ts +10 -0
- package/dist/domain/remote/ssh-exec.js +25 -0
- package/dist/domain/runs/adapters.js +2 -0
- package/dist/domain/runs/attempt.d.ts +4 -4
- package/dist/domain/runs/attempt.js +26 -20
- package/dist/domain/runs/builders.d.ts +3 -8
- package/dist/domain/runs/builders.js +11 -13
- package/dist/domain/runs/compact.d.ts +9 -18
- package/dist/domain/runs/compact.js +20 -75
- package/dist/domain/runs/config-resolver.d.ts +20 -78
- package/dist/domain/runs/config-resolver.js +27 -138
- package/dist/domain/runs/engine-spec.d.ts +4 -22
- package/dist/domain/runs/engine-spec.js +18 -44
- package/dist/domain/runs/engines.d.ts +14 -5
- package/dist/domain/runs/engines.js +30 -12
- package/dist/domain/runs/events.d.ts +1 -1
- package/dist/domain/runs/fallback.d.ts +7 -36
- package/dist/domain/runs/fallback.js +12 -68
- package/dist/domain/runs/mode-env.d.ts +16 -0
- package/dist/domain/runs/mode-env.js +48 -0
- package/dist/domain/runs/notices.d.ts +1 -6
- package/dist/domain/runs/notices.js +3 -16
- package/dist/domain/runs/prompt.d.ts +13 -19
- package/dist/domain/runs/prompt.js +37 -93
- package/dist/domain/runs/request.d.ts +13 -7
- package/dist/domain/runs/retryable-errors.d.ts +5 -0
- package/dist/domain/runs/retryable-errors.js +22 -0
- package/dist/domain/runs/run.d.ts +52 -31
- package/dist/domain/runs/run.js +117 -117
- package/dist/domain/runs/service.d.ts +1 -1
- package/dist/domain/runs/service.js +11 -10
- package/dist/domain/runs/spec-loader.d.ts +8 -10
- package/dist/domain/runs/spec-loader.js +5 -7
- package/dist/domain/runs/spend.d.ts +16 -0
- package/dist/domain/runs/spend.js +31 -0
- package/dist/domain/scheduling/builtin-job-migration.js +4 -5
- package/dist/domain/scheduling/builtin-jobs.d.ts +1 -2
- package/dist/domain/scheduling/builtin-jobs.js +5 -5
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +3 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +37 -30
- package/dist/domain/scheduling/runner.d.ts +11 -2
- package/dist/domain/scheduling/runner.js +7 -2
- package/dist/domain/scheduling/schedule-ops.d.ts +15 -0
- package/dist/domain/scheduling/schedule-ops.js +43 -0
- package/dist/domain/scheduling/schedule-selection.d.ts +3 -0
- package/dist/domain/scheduling/schedule-selection.js +16 -0
- package/dist/domain/scheduling/schedule-spec.d.ts +79 -0
- package/dist/domain/scheduling/schedule-spec.js +169 -0
- package/dist/domain/scheduling/scheduler.d.ts +30 -13
- package/dist/domain/scheduling/scheduler.js +165 -373
- package/dist/domain/sessions/session-backup.d.ts +3 -2
- package/dist/domain/sessions/session-backup.js +8 -7
- package/dist/domain/sessions/session-hooks.d.ts +28 -10
- package/dist/domain/sessions/session-hooks.js +71 -66
- package/dist/domain/sessions/session-lifecycle.d.ts +28 -65
- package/dist/domain/sessions/session-lifecycle.js +41 -119
- package/dist/domain/sessions/session-retention.d.ts +3 -2
- package/dist/domain/sessions/session-retention.js +69 -76
- package/dist/domain/sessions/team.d.ts +8 -0
- package/dist/domain/sessions/team.js +9 -0
- package/dist/domain/system/doctor.d.ts +9 -1
- package/dist/domain/system/doctor.js +55 -57
- package/dist/domain/system/rebuild-hold.d.ts +2 -0
- package/dist/domain/system/rebuild-hold.js +10 -5
- package/dist/domain/system/server-update-check.d.ts +5 -1
- package/dist/domain/system/server-update-check.js +17 -19
- package/dist/domain/system/server-update-coordinator.d.ts +4 -1
- package/dist/domain/system/server-update-coordinator.js +21 -3
- package/dist/domain/system/server-update-install.d.ts +16 -0
- package/dist/domain/system/server-update-install.js +65 -0
- package/dist/domain/system/update-ui-state.d.ts +8 -1
- package/dist/domain/system/update-ui-state.js +16 -2
- package/dist/domain/tui-session/tui-session-service.js +14 -15
- package/dist/domain/tui-session/types.d.ts +3 -7
- package/dist/domain/ui-service/app-router.d.ts +99 -117
- package/dist/domain/ui-service/app-router.js +31 -24
- package/dist/domain/ui-service/contract.parity.d.ts +19 -0
- package/dist/domain/ui-service/contract.parity.js +1 -0
- package/dist/domain/ui-service/input-schemas.d.ts +106 -212
- package/dist/domain/ui-service/input-schemas.js +106 -107
- package/dist/domain/ui-service/mutate/approvals.d.ts +5 -5
- package/dist/domain/ui-service/mutate/auth.d.ts +7 -7
- package/dist/domain/ui-service/mutate/auth.js +21 -20
- package/dist/domain/ui-service/mutate/config.d.ts +3 -11
- package/dist/domain/ui-service/mutate/config.js +0 -22
- package/dist/domain/ui-service/mutate/custom-providers.d.ts +3 -3
- package/dist/domain/ui-service/mutate/environments.d.ts +8 -4
- package/dist/domain/ui-service/mutate/environments.js +16 -1
- package/dist/domain/ui-service/mutate/executions.js +2 -0
- package/dist/domain/ui-service/mutate/hooks.d.ts +6 -6
- package/dist/domain/ui-service/mutate/hooks.js +4 -4
- package/dist/domain/ui-service/mutate/issues.d.ts +3 -3
- package/dist/domain/ui-service/mutate/models.d.ts +10 -0
- package/dist/domain/ui-service/mutate/models.js +118 -0
- package/dist/domain/ui-service/mutate/notes.d.ts +6 -6
- package/dist/domain/ui-service/mutate/plugin-packages.d.ts +10 -9
- package/dist/domain/ui-service/mutate/plugin-packages.js +20 -4
- package/dist/domain/ui-service/mutate/plugins.d.ts +2 -2
- package/dist/domain/ui-service/mutate/plugins.js +3 -8
- package/dist/domain/ui-service/mutate/schedules.d.ts +3 -3
- package/dist/domain/ui-service/mutate/schedules.js +14 -61
- package/dist/domain/ui-service/mutate/session-metadata.js +0 -6
- package/dist/domain/ui-service/mutate/sessions.d.ts +16 -28
- package/dist/domain/ui-service/mutate/sessions.js +37 -241
- package/dist/domain/ui-service/mutate/system.d.ts +10 -7
- package/dist/domain/ui-service/mutate/system.js +19 -17
- package/dist/domain/ui-service/mutate/usage-sharing.d.ts +8 -0
- package/dist/domain/ui-service/mutate/usage-sharing.js +16 -0
- package/dist/domain/ui-service/mutate/waitpoints.d.ts +2 -2
- package/dist/domain/ui-service/mutate/waitpoints.js +0 -3
- package/dist/domain/ui-service/plugins-shared.d.ts +11 -8
- package/dist/domain/ui-service/plugins-shared.js +55 -29
- package/dist/domain/ui-service/query/approvals.d.ts +2 -2
- package/dist/domain/ui-service/query/auth.d.ts +3 -3
- package/dist/domain/ui-service/query/boards.d.ts +14 -0
- package/dist/domain/ui-service/query/{commissions.js → boards.js} +39 -26
- package/dist/domain/ui-service/query/config.d.ts +6 -5
- package/dist/domain/ui-service/query/config.js +34 -51
- package/dist/domain/ui-service/query/cost.d.ts +2 -2
- package/dist/domain/ui-service/query/custom-providers.d.ts +2 -2
- package/dist/domain/ui-service/query/environments.d.ts +3 -3
- package/dist/domain/ui-service/query/environments.js +2 -1
- package/dist/domain/ui-service/query/executions.d.ts +3 -3
- package/dist/domain/ui-service/query/executions.js +0 -14
- package/dist/domain/ui-service/query/hooks.d.ts +5 -3
- package/dist/domain/ui-service/query/hooks.js +19 -22
- package/dist/domain/ui-service/query/issues.d.ts +2 -2
- package/dist/domain/ui-service/query/machine-detail.d.ts +2 -2
- package/dist/domain/ui-service/query/machine-detail.js +6 -24
- package/dist/domain/ui-service/query/machines.d.ts +2 -2
- package/dist/domain/ui-service/query/machines.js +0 -10
- package/dist/domain/ui-service/query/memory.d.ts +3 -3
- package/dist/domain/ui-service/query/memory.js +5 -4
- package/dist/domain/ui-service/query/models.d.ts +2 -2
- package/dist/domain/ui-service/query/models.js +2 -2
- package/dist/domain/ui-service/query/notes.d.ts +2 -2
- package/dist/domain/ui-service/query/plugin-source.d.ts +3 -3
- package/dist/domain/ui-service/query/plugin-source.js +2 -2
- package/dist/domain/ui-service/query/plugins.d.ts +2 -2
- package/dist/domain/ui-service/query/plugins.js +2 -2
- package/dist/domain/ui-service/query/schedules.d.ts +2 -2
- package/dist/domain/ui-service/query/schedules.js +1 -2
- package/dist/domain/ui-service/query/sessions.d.ts +6 -6
- package/dist/domain/ui-service/query/sessions.js +41 -52
- package/dist/domain/ui-service/query/skills.d.ts +5 -2
- package/dist/domain/ui-service/query/skills.js +14 -4
- package/dist/domain/ui-service/query/system.d.ts +6 -7
- package/dist/domain/ui-service/query/system.js +6 -33
- package/dist/domain/ui-service/query/usage-sharing.d.ts +4 -0
- package/dist/domain/ui-service/query/usage-sharing.js +5 -0
- package/dist/domain/ui-service/query/waitpoints.d.ts +4 -24
- package/dist/domain/ui-service/query/waitpoints.js +7 -80
- package/dist/domain/ui-service/query-input-schemas.d.ts +8 -10
- package/dist/domain/ui-service/query-input-schemas.js +13 -6
- package/dist/domain/ui-service/types.d.ts +228 -944
- package/dist/domain/ui-service/ui-service.d.ts +507 -1
- package/dist/domain/ui-service/ui-service.js +35 -31
- package/dist/domain/waitpoints/notices.d.ts +9 -5
- package/dist/domain/waitpoints/notices.js +49 -34
- package/dist/domain/waitpoints/service.d.ts +23 -7
- package/dist/domain/waitpoints/service.js +88 -50
- package/dist/domain/waitpoints/view.d.ts +29 -0
- package/dist/domain/waitpoints/view.js +97 -0
- package/dist/entry/admin-channel-hot-reload.js +5 -6
- package/dist/entry/app.js +92 -317
- package/dist/entry/auth-login-cli.js +1 -2
- package/dist/entry/cli-help.d.ts +2 -0
- package/dist/entry/cli-help.js +73 -5
- package/dist/entry/cli.js +89 -185
- package/dist/entry/daemon.d.ts +9 -0
- package/dist/entry/daemon.js +17 -19
- package/dist/entry/feishu-login.d.ts +1 -0
- package/dist/entry/feishu-login.js +3 -3
- package/dist/entry/hook-cli.d.ts +4 -2
- package/dist/entry/hook-cli.js +8 -17
- package/dist/entry/init-auth.js +1 -1
- package/dist/entry/init-git.d.ts +6 -0
- package/dist/entry/init-git.js +36 -0
- package/dist/entry/init-local-client.d.ts +11 -0
- package/dist/entry/init-local-client.js +34 -0
- package/dist/entry/init.d.ts +24 -28
- package/dist/entry/init.js +154 -459
- package/dist/entry/local-ui.js +10 -7
- package/dist/entry/memory-cli.d.ts +3 -0
- package/dist/entry/memory-cli.js +79 -0
- package/dist/entry/schedule-cli.d.ts +10 -0
- package/dist/entry/schedule-cli.js +166 -0
- package/dist/entry/shutdown.d.ts +32 -0
- package/dist/entry/shutdown.js +74 -0
- package/dist/entry/signal-cli.js +4 -3
- package/dist/entry/start-ui-http.js +10 -261
- package/dist/entry/ui-service-wiring.d.ts +12 -0
- package/dist/entry/ui-service-wiring.js +142 -0
- package/dist/events/event-types.d.ts +15 -23
- package/dist/orchestration/agent-decision-send.d.ts +2 -1
- package/dist/orchestration/agent-decision-send.js +7 -6
- package/dist/orchestration/agent-file-send.d.ts +0 -2
- package/dist/orchestration/agent-file-send.js +2 -17
- package/dist/orchestration/agent-runner.d.ts +0 -6
- package/dist/orchestration/agent-runner.js +68 -99
- package/dist/orchestration/agent-view-send.js +2 -1
- package/dist/orchestration/attachments-store.js +4 -4
- package/dist/orchestration/benchmark-session-webhook.js +14 -2
- package/dist/orchestration/board-webhook.d.ts +7 -0
- package/dist/orchestration/board-webhook.js +38 -0
- package/dist/orchestration/busy-tracker.d.ts +3 -0
- package/dist/orchestration/busy-tracker.js +12 -5
- package/dist/orchestration/conversation-request.d.ts +65 -69
- package/dist/orchestration/conversation-request.js +130 -171
- package/dist/orchestration/edit-retry.d.ts +7 -6
- package/dist/orchestration/edit-retry.js +53 -63
- package/dist/orchestration/injection-ledger.d.ts +56 -0
- package/dist/orchestration/injection-ledger.js +270 -0
- package/dist/orchestration/interactions/ask-user-resume.js +33 -50
- package/dist/orchestration/interactions/interaction-handlers.js +11 -10
- package/dist/orchestration/mid-turn-inject.d.ts +4 -4
- package/dist/orchestration/mid-turn-inject.js +3 -4
- package/dist/orchestration/outputs-store.d.ts +0 -9
- package/dist/orchestration/outputs-store.js +1 -57
- package/dist/orchestration/pending-injection-recovery.d.ts +2 -2
- package/dist/orchestration/pending-injection-recovery.js +1 -2
- package/dist/orchestration/pi-background-subagent.js +3 -1
- package/dist/orchestration/resume-target-sink.d.ts +3 -3
- package/dist/orchestration/resume-target-sink.js +6 -4
- package/dist/orchestration/routing/commands/cancel.d.ts +4 -1
- package/dist/orchestration/routing/commands/cancel.js +14 -11
- package/dist/orchestration/routing/commands/index.d.ts +5 -1
- package/dist/orchestration/routing/commands/index.js +5 -5
- package/dist/orchestration/routing/commands/login-notice.d.ts +2 -0
- package/dist/orchestration/routing/commands/login-notice.js +10 -19
- package/dist/orchestration/routing/commands/login.js +4 -4
- package/dist/orchestration/routing/commands/mode.d.ts +5 -40
- package/dist/orchestration/routing/commands/mode.js +112 -272
- package/dist/orchestration/routing/commands/restart.d.ts +3 -7
- package/dist/orchestration/routing/commands/restart.js +6 -21
- package/dist/orchestration/routing/commands/schedule.d.ts +3 -1
- package/dist/orchestration/routing/commands/schedule.js +174 -100
- package/dist/orchestration/routing/commands/session.d.ts +11 -0
- package/dist/orchestration/routing/commands/session.js +42 -21
- package/dist/orchestration/routing/commands/status.js +1 -1
- package/dist/orchestration/routing/commands/usage-format.d.ts +5 -0
- package/dist/orchestration/routing/commands/usage-format.js +104 -0
- package/dist/orchestration/routing/commands/usage-reset.d.ts +20 -0
- package/dist/orchestration/routing/commands/usage-reset.js +123 -0
- package/dist/orchestration/routing/commands/usage.d.ts +2 -2
- package/dist/orchestration/routing/commands/usage.js +17 -101
- package/dist/orchestration/routing/edit-handler.d.ts +0 -1
- package/dist/orchestration/routing/edit-handler.js +4 -5
- package/dist/orchestration/routing/message-router.js +2 -4
- package/dist/orchestration/routing/webhook.d.ts +7 -1
- package/dist/orchestration/routing/webhook.js +304 -503
- package/dist/orchestration/session-compact.d.ts +7 -18
- package/dist/orchestration/session-compact.js +24 -14
- package/dist/orchestration/session-events.d.ts +17 -7
- package/dist/orchestration/session-events.js +6 -4
- package/dist/{core → orchestration}/session-retention-liveness.d.ts +3 -3
- package/dist/orchestration/session-rewind.d.ts +1 -1
- package/dist/orchestration/session-rewind.js +1 -1
- package/dist/orchestration/status-helpers.d.ts +1 -5
- package/dist/orchestration/status-helpers.js +3 -20
- package/dist/orchestration/subagent-attribution.js +0 -1
- package/dist/orchestration/subagent-webhook.js +9 -34
- package/dist/orchestration/team-delivery.d.ts +22 -5
- package/dist/orchestration/team-delivery.js +88 -28
- package/dist/orchestration/team-inbox.d.ts +18 -0
- package/dist/orchestration/team-inbox.js +49 -0
- package/dist/orchestration/team-state.d.ts +32 -6
- package/dist/orchestration/team-state.js +88 -15
- package/dist/orchestration/team-webhook.d.ts +21 -12
- package/dist/orchestration/team-webhook.js +63 -65
- package/dist/orchestration/transcript-sink.d.ts +6 -102
- package/dist/orchestration/transcript-sink.js +61 -317
- package/dist/orchestration/turn/background-hold.d.ts +15 -9
- package/dist/orchestration/turn/background-hold.js +39 -53
- package/dist/orchestration/turn/hold-render-platform.d.ts +5 -11
- package/dist/orchestration/turn/hold-render-platform.js +16 -51
- package/dist/orchestration/turn/hold-render-web.d.ts +3 -18
- package/dist/orchestration/turn/hold-render-web.js +2 -19
- package/dist/orchestration/turn/terminal.d.ts +12 -8
- package/dist/orchestration/turn/terminal.js +46 -44
- package/dist/orchestration/turn/turn-prep.d.ts +4 -13
- package/dist/orchestration/turn/turn-prep.js +13 -2
- package/dist/orchestration/turn/turn-tracking.d.ts +3 -3
- package/dist/orchestration/turn/turn-tracking.js +11 -8
- package/dist/orchestration/turn/turn.d.ts +1 -7
- package/dist/orchestration/turn/turn.js +49 -117
- package/dist/orchestration/turn-notify.d.ts +0 -1
- package/dist/orchestration/turn-notify.js +2 -2
- package/dist/orchestration/waitpoint-ingress.d.ts +10 -5
- package/dist/orchestration/waitpoint-ingress.js +47 -23
- package/dist/orchestration/waitpoint-notifier.d.ts +11 -0
- package/dist/orchestration/waitpoint-notifier.js +40 -12
- package/dist/orchestration/waitpoint-remote-drain.js +22 -30
- package/dist/orchestration/waitpoint-sweep.d.ts +6 -4
- package/dist/orchestration/waitpoint-sweep.js +13 -9
- package/dist/platform/adapter.d.ts +4 -0
- package/dist/platform/adapters/composite-adapter.d.ts +7 -6
- package/dist/platform/adapters/composite-adapter.js +16 -34
- package/dist/platform/adapters/feishu.d.ts +1 -0
- package/dist/platform/adapters/feishu.js +1 -0
- package/dist/platform/adapters/index.js +1 -5
- package/dist/platform/adapters/slack.d.ts +1 -0
- package/dist/platform/adapters/slack.js +1 -0
- package/dist/platform/adapters/tui/ports.d.ts +0 -2
- package/dist/platform/adapters/tui/tui-gateway.d.ts +2 -1
- package/dist/platform/adapters/tui/tui-gateway.js +30 -81
- package/dist/platform/browser/display.d.ts +8 -5
- package/dist/platform/browser/display.js +63 -44
- package/dist/platform/browser/managed-browser.d.ts +1 -1
- package/dist/platform/browser/managed-browser.js +127 -41
- package/dist/platform/index.d.ts +2 -2
- package/dist/platform/index.js +1 -1
- package/dist/platform/output-stream-helpers.d.ts +3 -1
- package/dist/platform/output-stream-helpers.js +11 -0
- package/dist/platform/testing.d.ts +3 -1
- package/dist/platform/testing.js +3 -1
- package/dist/platform/tool-trace.d.ts +1 -1
- package/dist/platform/tool-trace.js +2 -2
- package/dist/platform/tui/protocol.d.ts +0 -1
- package/dist/platform/tui/protocol.js +1 -1
- package/dist/platform/ui-http/device-ports.d.ts +7 -2
- package/dist/platform/ui-http/device-ports.js +68 -40
- package/dist/platform/ui-http/file-routes.d.ts +23 -0
- package/dist/platform/ui-http/file-routes.js +224 -0
- package/dist/platform/ui-http/http-json.d.ts +18 -2
- package/dist/platform/ui-http/http-json.js +96 -20
- package/dist/platform/ui-http/listening-ports.d.ts +13 -9
- package/dist/platform/ui-http/listening-ports.js +23 -9
- package/dist/platform/ui-http/port-forward.js +7 -17
- package/dist/platform/ui-http/ui-auth-routes.d.ts +0 -7
- package/dist/platform/ui-http/ui-auth-routes.js +14 -35
- package/dist/platform/ui-http/ui-http-server.d.ts +4 -12
- package/dist/platform/ui-http/ui-http-server.js +53 -28
- package/dist/platform/ui-http/ui-ota.d.ts +4 -2
- package/dist/platform/ui-http/ui-ota.js +49 -3
- package/dist/store/board-migration.d.ts +21 -0
- package/dist/store/board-migration.js +217 -0
- package/dist/store/board-repo.d.ts +35 -0
- package/dist/store/{commission-repo.js → board-repo.js} +19 -19
- package/dist/store/builtin-overlay-migration.d.ts +11 -0
- package/dist/store/builtin-overlay-migration.js +308 -0
- package/dist/store/claude-transcript-migration.d.ts +32 -0
- package/dist/store/claude-transcript-migration.js +119 -0
- package/dist/store/conversation-history-reader.js +12 -0
- package/dist/store/conversation-history-repo.d.ts +25 -2
- package/dist/store/conversation-history-repo.js +12 -1
- package/dist/store/conversation-ledger-repo.d.ts +6 -11
- package/dist/store/conversation-ledger-repo.js +4 -11
- package/dist/store/cost-repo.js +2 -1
- package/dist/store/execution-repo.d.ts +0 -1
- package/dist/store/execution-repo.js +12 -3
- package/dist/store/hook-registry.d.ts +33 -9
- package/dist/store/hook-registry.js +69 -34
- package/dist/store/hook-writer.d.ts +8 -12
- package/dist/store/hook-writer.js +40 -35
- package/dist/store/models-repo.d.ts +18 -0
- package/dist/store/models-repo.js +74 -0
- package/dist/store/pending-injection-repo.d.ts +2 -2
- package/dist/store/pending-injection-repo.js +6 -1
- package/dist/store/provider-state-repo.d.ts +3 -3
- package/dist/store/retention-candidate-repo.d.ts +1 -1
- package/dist/store/retire-profiles-migration.d.ts +28 -0
- package/dist/store/retire-profiles-migration.js +335 -0
- package/dist/store/schedule-repo.d.ts +7 -15
- package/dist/store/schedule-repo.js +9 -18
- package/dist/store/session-registry-import.js +4 -4
- package/dist/store/session-registry-journal.d.ts +21 -29
- package/dist/store/session-registry-journal.js +87 -58
- package/dist/store/session-registry-repo.d.ts +26 -39
- package/dist/store/session-registry-repo.js +60 -107
- package/dist/store/session-totals-repo.d.ts +1 -1
- package/dist/store/team-inbox-repo.d.ts +34 -0
- package/dist/store/team-inbox-repo.js +72 -0
- package/dist/store/version-migrations.d.ts +5 -6
- package/dist/store/version-migrations.js +67 -35
- package/dist/store/waitpoint-repo.d.ts +13 -5
- package/dist/store/waitpoint-repo.js +5 -0
- package/dist/tui/App.d.ts +2 -2
- package/dist/tui/App.js +12 -8
- package/dist/tui/components/SessionPicker.d.ts +0 -1
- package/dist/tui/components/SessionPicker.js +2 -1
- package/dist/tui/index.js +3 -4
- package/dist/tui/logic.d.ts +0 -1
- package/dist/tui/logic.js +5 -10
- package/dist/tui/slash-commands.js +2 -2
- package/dist/tui/turn-status.js +1 -1
- package/package.json +5 -5
- package/web/dist/assets/index-Cgx3gdHV.css +1 -0
- package/web/dist/assets/index-CpZWBVHr.js +494 -0
- package/web/dist/assets/{index-CDjsmgsy.js → index-DaViXAg-.js} +1 -1
- package/web/dist/assets/pdf-worker-Hp15W1QJ.js +57 -0
- package/web/dist/assets/pdf.worker.min-DnhTvCwe.js +55 -0
- package/web/dist/index.html +2 -2
- package/web/dist/theme.css +0 -8
- package/defaults/plugins/cortex-commission/.claude-plugin/plugin.json +0 -5
- package/defaults/plugins/cortex-commission/plugin.json +0 -6
- package/defaults/plugins/cortex-commission/skills/commission/SKILL.md +0 -62
- package/defaults/plugins/cortex-feishu/.claude-plugin/plugin.json +0 -5
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +0 -5
- package/dist/agent-adapter/claude/tmux-control.d.ts +0 -31
- package/dist/agent-adapter/claude/tmux-control.js +0 -46
- package/dist/agent-adapter/mcp-private-dir.d.ts +0 -1
- package/dist/agent-adapter/mcp-private-dir.js +0 -24
- package/dist/core/profile-generator.d.ts +0 -70
- package/dist/core/profile-generator.js +0 -210
- package/dist/domain/agents/environments/slot-config.d.ts +0 -14
- package/dist/domain/agents/environments/slot-config.js +0 -78
- package/dist/domain/agents/profile-manager.d.ts +0 -120
- package/dist/domain/agents/profile-manager.js +0 -303
- package/dist/domain/agents/profile-switch.d.ts +0 -53
- package/dist/domain/agents/profile-switch.js +0 -66
- package/dist/domain/commissions/commission-context.d.ts +0 -45
- package/dist/domain/commissions/commission-context.js +0 -45
- package/dist/domain/commissions/commission-draft.d.ts +0 -88
- package/dist/domain/commissions/commission-draft.js +0 -115
- package/dist/domain/commissions/commission-finalize.d.ts +0 -51
- package/dist/domain/commissions/commission-finalize.js +0 -104
- package/dist/domain/commissions/commission-paths.d.ts +0 -10
- package/dist/domain/commissions/commission-paths.js +0 -32
- package/dist/domain/commissions/decision-projection.js +0 -43
- package/dist/domain/mcp/tools/commission-tools.d.ts +0 -31
- package/dist/domain/mcp/tools/commission-tools.js +0 -234
- package/dist/domain/mcp/tools/schedule.d.ts +0 -9
- package/dist/domain/mcp/tools/schedule.js +0 -202
- package/dist/domain/memory/skill-scanner.d.ts +0 -6
- package/dist/domain/memory/skill-scanner.js +0 -116
- package/dist/domain/scheduling/jobs/memory-index-regen.d.ts +0 -2
- package/dist/domain/scheduling/jobs/memory-index-regen.js +0 -17
- package/dist/domain/scheduling/schedule-cli.d.ts +0 -13
- package/dist/domain/scheduling/schedule-cli.js +0 -260
- package/dist/domain/scheduling/schedule-command.d.ts +0 -4
- package/dist/domain/scheduling/schedule-command.js +0 -243
- package/dist/domain/ui-service/mutate/commissions.d.ts +0 -4
- package/dist/domain/ui-service/mutate/commissions.js +0 -26
- package/dist/domain/ui-service/mutate/profiles.d.ts +0 -36
- package/dist/domain/ui-service/mutate/profiles.js +0 -153
- package/dist/domain/ui-service/query/commissions.d.ts +0 -12
- package/dist/hooks/agents-md-injector.mjs +0 -392
- package/dist/hooks/cortex-hook-api.mjs +0 -78
- package/dist/hooks/memory-ref-tracker.mjs +0 -152
- package/dist/hooks/new-session-hook.mjs +0 -77
- package/dist/hooks/rules-loader.mjs +0 -204
- package/dist/hooks/session-activity-tracker.mjs +0 -142
- package/dist/hooks/status-md-guard.mjs +0 -182
- package/dist/platform/adapters/tui/tui-conduit-state.d.ts +0 -8
- package/dist/platform/adapters/tui/tui-conduit-state.js +0 -10
- package/dist/platform/ui-http/browser-status.d.ts +0 -17
- package/dist/platform/ui-http/browser-status.js +0 -38
- package/dist/store/commission-repo.d.ts +0 -34
- package/dist/store/hook-sync.d.ts +0 -14
- package/dist/store/hook-sync.js +0 -180
- package/dist/store/plugin-sync.d.ts +0 -30
- package/dist/store/plugin-sync.js +0 -151
- package/dist/store/profile-repo.d.ts +0 -18
- package/dist/store/profile-repo.js +0 -86
- package/web/dist/assets/index-BU_kY1rV.js +0 -449
- package/web/dist/assets/index-DzPDbcY1.css +0 -1
- package/web/dist/assets/pdf-worker-DIEXcFxP.js +0 -55
- package/web/dist/assets/pdf.worker.min-DqNZU1-t.js +0 -53
- /package/dist/{core/types → domain/benchmark}/benchmark-types.js +0 -0
- /package/dist/{core → domain/benchmark}/production-benchmark-evidence.js +0 -0
- /package/dist/{core → orchestration}/session-retention-liveness.js +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var Ob=Object.defineProperty;var vm=d=>{throw TypeError(d)};var Rb=(d,e,t)=>e in d?Ob(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var P=(d,e,t)=>Rb(d,typeof e!="symbol"?e+"":e,t),pp=(d,e,t)=>e.has(d)||vm("Cannot "+t);var n=(d,e,t)=>(pp(d,e,"read from private field"),t?t.call(d):e.get(d)),y=(d,e,t)=>e.has(d)?vm("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(d):e.set(d,t),g=(d,e,t,s)=>(pp(d,e,"write to private field"),s?s.call(d,t):e.set(d,t),t),b=(d,e,t)=>(pp(d,e,"access private method"),t);var $t=(d,e,t,s)=>({set _(i){g(d,e,i,t)},get _(){return n(d,e,s)}});function Db(d){return new Worker("/assets/pdf.worker.min-DnhTvCwe.js",{name:d==null?void 0:d.name})}var kb={9306(d,e,t){var s=t(4901),i=t(6823),r=TypeError;d.exports=function(a){if(s(a))return a;throw new r(i(a)+" is not a function")}},3506(d,e,t){var s=t(3925),i=String,r=TypeError;d.exports=function(a){if(s(a))return a;throw new r("Can't set "+i(a)+" as a prototype")}},7080(d,e,t){var s=t(4402).has;d.exports=function(i){return s(i),i}},3463(d){var e=TypeError;d.exports=function(t){if(typeof t=="string")return t;throw new e("Argument is not a string")}},4328(d,e,t){var s=t(4995),i=new s.WeakMap,r=s.set,a=s.remove;d.exports=function(o){return r(i,o,1),a(i,o),o}},6557(d,e,t){var s=t(4995).has;d.exports=function(i){return s(i),i}},6469(d,e,t){var s=t(8227),i=t(2360),r=t(4913).f,a=s("unscopables"),o=Array.prototype;o[a]===void 0&&r(o,a,{configurable:!0,value:i(null)}),d.exports=function(l){o[a][l]=!0}},679(d,e,t){var s=t(1625),i=TypeError;d.exports=function(r,a){if(s(a,r))return r;throw new i("Incorrect invocation")}},3972(d,e,t){var s=t(34),i=String,r=TypeError;d.exports=function(a){if(a===void 0||s(a))return a;throw new r(i(a)+" is not an object or undefined")}},8551(d,e,t){var s=t(34),i=String,r=TypeError;d.exports=function(a){if(s(a))return a;throw new r(i(a)+" is not an object")}},4154(d,e,t){var s=t(6955),i=TypeError;d.exports=function(r){if(s(r)==="Uint8Array")return r;throw new i("Argument is not an Uint8Array")}},7811(d){d.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"},7394(d,e,t){var s=t(4576),i=t(6706),r=t(2195),a=s.ArrayBuffer,o=s.TypeError;d.exports=a&&i(a.prototype,"byteLength","get")||function(l){if(r(l)!=="ArrayBuffer")throw new o("ArrayBuffer expected");return l.byteLength}},3238(d,e,t){var s=t(4576),i=t(7811),r=t(7394),a=s.DataView;d.exports=function(o){if(!i||r(o)!==0)return!1;try{return new a(o),!1}catch{return!0}}},5169(d,e,t){var s=t(3238),i=TypeError;d.exports=function(r){if(s(r))throw new i("ArrayBuffer is detached");return r}},4644(d,e,t){var s=t(7811),i=t(3724),r=t(4576),a=t(4901),o=t(34),l=t(9297),h=t(6955),c=t(6823),u=t(6699),f=t(6840),p=t(2106),m=t(1625),v=t(2787),A=t(2967),w=t(8227),E=t(3392),S=t(1181),T=S.enforce,x=S.get,C=r.Int8Array,I=C&&C.prototype,O=r.Uint8ClampedArray,M=O&&O.prototype,R=C&&v(C),D=I&&v(I),j=Object.prototype,F=r.TypeError,U=w("toStringTag"),Z=E("TYPED_ARRAY_TAG"),L="TypedArrayConstructor",B=s&&!!A&&h(r.opera)!=="Opera",q=!1,W,dt,yt,ct={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},X={BigInt64Array:8,BigUint64Array:8},ft=function(rt){if(!o(rt))return!1;var Pt=h(rt);return Pt==="DataView"||l(ct,Pt)||l(X,Pt)},Ft=function(J){var rt=v(J);if(o(rt)){var Pt=x(rt);return Pt&&l(Pt,L)?Pt[L]:Ft(rt)}},N=function(J){if(!o(J))return!1;var rt=h(J);return l(ct,rt)||l(X,rt)},k=function(J){if(N(J))return J;throw new F("Target is not a typed array")},$=function(J){if(a(J)&&(!A||m(R,J)))return J;throw new F(c(J)+" is not a typed array constructor")},K=function(J,rt,Pt,pe){if(i){if(Pt)for(var ce in ct){var ae=r[ce];if(ae&&l(ae.prototype,J))try{delete ae.prototype[J]}catch{try{ae.prototype[J]=rt}catch{}}}(!D[J]||Pt)&&f(D,J,Pt?rt:B&&I[J]||rt,pe)}},gt=function(J,rt,Pt){var pe,ce;if(i){if(A){if(Pt){for(pe in ct)if(ce=r[pe],ce&&l(ce,J))try{delete ce[J]}catch{}}if(!R[J]||Pt)try{return f(R,J,Pt?rt:B&&R[J]||rt)}catch{}else return}for(pe in ct)ce=r[pe],ce&&(!ce[J]||Pt)&&f(ce,J,rt)}};for(W in ct)dt=r[W],yt=dt&&dt.prototype,yt?T(yt)[L]=dt:B=!1;for(W in X)dt=r[W],yt=dt&&dt.prototype,yt&&(T(yt)[L]=dt);if((!B||!a(R)||R===Function.prototype)&&(R=function(){throw new F("Incorrect invocation")},B))for(W in ct)r[W]&&A(r[W],R);if((!B||!D||D===j)&&(D=R.prototype,B))for(W in ct)r[W]&&A(r[W].prototype,D);if(B&&v(M)!==D&&A(M,D),i&&!l(D,U)){q=!0,p(D,U,{configurable:!0,get:function(){return o(this)?this[Z]:void 0}});for(W in ct)r[W]&&u(r[W].prototype,Z,W)}d.exports={NATIVE_ARRAY_BUFFER_VIEWS:B,TYPED_ARRAY_TAG:q&&Z,aTypedArray:k,aTypedArrayConstructor:$,exportTypedArrayMethod:K,exportTypedArrayStaticMethod:gt,getTypedArrayConstructor:Ft,isView:ft,isTypedArray:N,TypedArray:R,TypedArrayPrototype:D}},5370(d,e,t){var s=t(6198);d.exports=function(i,r,a){for(var o=0,l=arguments.length>2?a:s(r),h=new i(l);l>o;)h[o]=r[o++];return h}},9617(d,e,t){var s=t(5397),i=t(5610),r=t(6198),a=function(o){return function(l,h,c){var u=s(l),f=r(u);if(f===0)return!o&&-1;var p=i(c,f),m;if(o&&h!==h){for(;f>p;)if(m=u[p++],m!==m)return!0}else for(;f>p;p++)if((o||p in u)&&u[p]===h)return o||p||0;return!o&&-1}};d.exports={includes:a(!0),indexOf:a(!1)}},4527(d,e,t){var s=t(3724),i=t(4376),r=TypeError,a=Object.getOwnPropertyDescriptor,o=s&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(l){return l instanceof TypeError}}();d.exports=o?function(l,h){if(i(l)&&!a(l,"length").writable)throw new r("Cannot set read only .length");return l.length=h}:function(l,h){return l.length=h}},7680(d,e,t){var s=t(9504);d.exports=s([].slice)},2804(d){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=e+"+/",s=e+"-_",i=function(r){for(var a={},o=0;o<64;o++)a[r.charAt(o)]=o;return a};d.exports={i2c:t,c2i:i(t),i2cUrl:s,c2iUrl:i(s)}},6319(d,e,t){var s=t(8551),i=t(9539);d.exports=function(r,a,o,l){try{return l?a(s(o)[0],o[1]):a(o)}catch(h){i(r,"throw",h)}}},2195(d,e,t){var s=t(9504),i=s({}.toString),r=s("".slice);d.exports=function(a){return r(i(a),8,-1)}},6955(d,e,t){var s=t(2140),i=t(4901),r=t(2195),a=t(8227),o=a("toStringTag"),l=Object,h=r(function(){return arguments}())==="Arguments",c=function(u,f){try{return u[f]}catch{}};d.exports=s?r:function(u){var f,p,m;return u===void 0?"Undefined":u===null?"Null":typeof(p=c(f=l(u),o))=="string"?p:h?r(f):(m=r(f))==="Object"&&i(f.callee)?"Arguments":m}},7740(d,e,t){var s=t(9297),i=t(5031),r=t(7347),a=t(4913);d.exports=function(o,l,h){for(var c=i(l),u=a.f,f=r.f,p=0;p<c.length;p++){var m=c[p];!s(o,m)&&!(h&&s(h,m))&&u(o,m,f(l,m))}}},2211(d,e,t){var s=t(9039);d.exports=!s(function(){function i(){}return i.prototype.constructor=null,Object.getPrototypeOf(new i)!==i.prototype})},2529(d){d.exports=function(e,t){return{value:e,done:t}}},6699(d,e,t){var s=t(3724),i=t(4913),r=t(6980);d.exports=s?function(a,o,l){return i.f(a,o,r(1,l))}:function(a,o,l){return a[o]=l,a}},6980(d){d.exports=function(e,t){return{enumerable:!(e&1),configurable:!(e&2),writable:!(e&4),value:t}}},4659(d,e,t){var s=t(3724),i=t(4913),r=t(6980);d.exports=function(a,o,l){s?i.f(a,o,r(0,l)):a[o]=l}},2106(d,e,t){var s=t(283),i=t(4913);d.exports=function(r,a,o){return o.get&&s(o.get,a,{getter:!0}),o.set&&s(o.set,a,{setter:!0}),i.f(r,a,o)}},6840(d,e,t){var s=t(4901),i=t(4913),r=t(283),a=t(9433);d.exports=function(o,l,h,c){c||(c={});var u=c.enumerable,f=c.name!==void 0?c.name:l;if(s(h)&&r(h,f,c),c.global)u?o[l]=h:a(l,h);else{try{c.unsafe?o[l]&&(u=!0):delete o[l]}catch{}u?o[l]=h:i.f(o,l,{value:h,enumerable:!1,configurable:!c.nonConfigurable,writable:!c.nonWritable})}return o}},6279(d,e,t){var s=t(6840);d.exports=function(i,r,a){for(var o in r)s(i,o,r[o],a);return i}},9433(d,e,t){var s=t(4576),i=Object.defineProperty;d.exports=function(r,a){try{i(s,r,{value:a,configurable:!0,writable:!0})}catch{s[r]=a}return a}},3724(d,e,t){var s=t(9039);d.exports=!s(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})},4055(d,e,t){var s=t(4576),i=t(34),r=s.document,a=i(r)&&i(r.createElement);d.exports=function(o){return a?r.createElement(o):{}}},6837(d){var e=TypeError,t=9007199254740991;d.exports=function(s){if(s>t)throw new e("Maximum allowed index exceeded");return s}},5002(d){d.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8727(d){d.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2839(d,e,t){var s=t(4576),i=s.navigator,r=i&&i.userAgent;d.exports=r?String(r):""},9519(d,e,t){var s=t(4576),i=t(2839),r=s.process,a=s.Deno,o=r&&r.versions||a&&a.version,l=o&&o.v8,h,c;l&&(h=l.split("."),c=h[0]>0&&h[0]<4?1:+(h[0]+h[1])),!c&&i&&(h=i.match(/Edge\/(\d+)/),(!h||h[1]>=74)&&(h=i.match(/Chrome\/(\d+)/),h&&(c=+h[1]))),d.exports=c},6193(d,e,t){var s=t(9504),i=Error,r=s("".replace),a=function(h){return String(new i(h).stack)}("zxcasd"),o=/\n\s*at [^:]*:[^\n]*/,l=o.test(a);d.exports=function(h,c){if(l&&typeof h=="string"&&!i.prepareStackTrace)for(;c--;)h=r(h,o,"");return h}},6518(d,e,t){var s=t(4576),i=t(7347).f,r=t(6699),a=t(6840),o=t(9433),l=t(7740),h=t(2796);d.exports=function(c,u){var f=c.target,p=c.global,m=c.stat,v,A,w,E,S,T;if(p?A=s:m?A=s[f]||o(f,{}):A=s[f]&&s[f].prototype,A)for(w in u){if(S=u[w],c.dontCallGetSet?(T=i(A,w),E=T&&T.value):E=A[w],v=h(p?w:f+(m?".":"#")+w,c.forced),!v&&E!==void 0){if(typeof S==typeof E)continue;l(S,E)}(c.sham||E&&E.sham)&&r(S,"sham",!0),a(A,w,S,c)}}},9039(d){d.exports=function(e){try{return!!e()}catch{return!0}}},8745(d,e,t){var s=t(616),i=Function.prototype,r=i.apply,a=i.call;d.exports=typeof Reflect=="object"&&Reflect.apply||(s?a.bind(r):function(){return a.apply(r,arguments)})},6080(d,e,t){var s=t(7476),i=t(9306),r=t(616),a=s(s.bind);d.exports=function(o,l){return i(o),l===void 0?o:r?a(o,l):function(){return o.apply(l,arguments)}}},616(d,e,t){var s=t(9039);d.exports=!s(function(){var i=(function(){}).bind();return typeof i!="function"||i.hasOwnProperty("prototype")})},9565(d,e,t){var s=t(616),i=Function.prototype.call;d.exports=s?i.bind(i):function(){return i.apply(i,arguments)}},350(d,e,t){var s=t(3724),i=t(9297),r=Function.prototype,a=s&&Object.getOwnPropertyDescriptor,o=i(r,"name"),l=o&&(function(){}).name==="something",h=o&&(!s||s&&a(r,"name").configurable);d.exports={EXISTS:o,PROPER:l,CONFIGURABLE:h}},6706(d,e,t){var s=t(9504),i=t(9306);d.exports=function(r,a,o){try{return s(i(Object.getOwnPropertyDescriptor(r,a)[o]))}catch{}}},7476(d,e,t){var s=t(2195),i=t(9504);d.exports=function(r){if(s(r)==="Function")return i(r)}},9504(d,e,t){var s=t(616),i=Function.prototype,r=i.call,a=s&&i.bind.bind(r,r);d.exports=s?a:function(o){return function(){return r.apply(o,arguments)}}},944(d){var e=TypeError;d.exports=function(t){var s=t&&t.alphabet;if(s===void 0||s==="base64"||s==="base64url")return s||"base64";throw new e("Incorrect `alphabet` option")}},7751(d,e,t){var s=t(4576),i=t(4901),r=function(a){return i(a)?a:void 0};d.exports=function(a,o){return arguments.length<2?r(s[a]):s[a]&&s[a][o]}},1767(d){d.exports=function(e){return{iterator:e,next:e.next,done:!1}}},8646(d,e,t){var s=t(9565),i=t(8551),r=t(1767),a=t(851);d.exports=function(o,l){(!l||typeof o!="string")&&i(o);var h=a(o);return r(i(h!==void 0?s(h,o):o))}},851(d,e,t){var s=t(6955),i=t(5966),r=t(4117),a=t(6269),o=t(8227),l=o("iterator");d.exports=function(h){if(!r(h))return i(h,l)||i(h,"@@iterator")||a[s(h)]}},81(d,e,t){var s=t(9565),i=t(9306),r=t(8551),a=t(6823),o=t(851),l=TypeError;d.exports=function(h,c){var u=arguments.length<2?o(h):c;if(i(u))return r(s(u,h));throw new l(a(h)+" is not iterable")}},5966(d,e,t){var s=t(9306),i=t(4117);d.exports=function(r,a){var o=r[a];return i(o)?void 0:s(o)}},3789(d,e,t){var s=t(9306),i=t(8551),r=t(9565),a=t(1291),o=t(1767),l="Invalid size",h=RangeError,c=TypeError,u=Math.max,f=function(p,m){this.set=p,this.size=u(m,0),this.has=s(p.has),this.keys=s(p.keys)};f.prototype={getIterator:function(){return o(i(r(this.keys,this.set)))},includes:function(p){return r(this.has,this.set,p)}},d.exports=function(p){i(p);var m=+p.size;if(m!==m)throw new c(l);var v=a(m);if(v<0)throw new h(l);return new f(p,v)}},4576(d){var e=function(t){return t&&t.Math===Math&&t};d.exports=e(typeof globalThis=="object"&&globalThis)||e(typeof window=="object"&&window)||e(typeof self=="object"&&self)||e(typeof global=="object"&&global)||e(typeof this=="object"&&this)||function(){return this}()||Function("return this")()},9297(d,e,t){var s=t(9504),i=t(8981),r=s({}.hasOwnProperty);d.exports=Object.hasOwn||function(o,l){return r(i(o),l)}},421(d){d.exports={}},397(d,e,t){var s=t(7751);d.exports=s("document","documentElement")},5917(d,e,t){var s=t(3724),i=t(9039),r=t(4055);d.exports=!s&&!i(function(){return Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a!==7})},7055(d,e,t){var s=t(9504),i=t(9039),r=t(2195),a=Object,o=s("".split);d.exports=i(function(){return!a("z").propertyIsEnumerable(0)})?function(l){return r(l)==="String"?o(l,""):a(l)}:a},3167(d,e,t){var s=t(4901),i=t(34),r=t(2967);d.exports=function(a,o,l){var h,c;return r&&s(h=o.constructor)&&h!==l&&i(c=h.prototype)&&c!==l.prototype&&r(a,c),a}},3706(d,e,t){var s=t(9504),i=t(4901),r=t(7629),a=s(Function.toString);i(r.inspectSource)||(r.inspectSource=function(o){return a(o)}),d.exports=r.inspectSource},1181(d,e,t){var s=t(8622),i=t(4576),r=t(34),a=t(6699),o=t(9297),l=t(7629),h=t(6119),c=t(421),u="Object already initialized",f=i.TypeError,p=i.WeakMap,m,v,A,w=function(x){return A(x)?v(x):m(x,{})},E=function(x){return function(C){var I;if(!r(C)||(I=v(C)).type!==x)throw new f("Incompatible receiver, "+x+" required");return I}};if(s||l.state){var S=l.state||(l.state=new p);S.get=S.get,S.has=S.has,S.set=S.set,m=function(x,C){if(S.has(x))throw new f(u);return C.facade=x,S.set(x,C),C},v=function(x){return S.get(x)||{}},A=function(x){return S.has(x)}}else{var T=h("state");c[T]=!0,m=function(x,C){if(o(x,T))throw new f(u);return C.facade=x,a(x,T,C),C},v=function(x){return o(x,T)?x[T]:{}},A=function(x){return o(x,T)}}d.exports={set:m,get:v,has:A,enforce:w,getterFor:E}},4209(d,e,t){var s=t(8227),i=t(6269),r=s("iterator"),a=Array.prototype;d.exports=function(o){return o!==void 0&&(i.Array===o||a[r]===o)}},4376(d,e,t){var s=t(2195);d.exports=Array.isArray||function(r){return s(r)==="Array"}},1108(d,e,t){var s=t(6955);d.exports=function(i){var r=s(i);return r==="BigInt64Array"||r==="BigUint64Array"}},4901(d){var e=typeof document=="object"&&document.all;d.exports=typeof e>"u"&&e!==void 0?function(t){return typeof t=="function"||t===e}:function(t){return typeof t=="function"}},2796(d,e,t){var s=t(9039),i=t(4901),r=/#|\.prototype\./,a=function(u,f){var p=l[o(u)];return p===c?!0:p===h?!1:i(f)?s(f):!!f},o=a.normalize=function(u){return String(u).replace(r,".").toLowerCase()},l=a.data={},h=a.NATIVE="N",c=a.POLYFILL="P";d.exports=a},4117(d){d.exports=function(e){return e==null}},34(d,e,t){var s=t(4901);d.exports=function(i){return typeof i=="object"?i!==null:s(i)}},3925(d,e,t){var s=t(34);d.exports=function(i){return s(i)||i===null}},6395(d){d.exports=!1},5810(d,e,t){var s=t(34),i=t(1181).get;d.exports=function(a){if(!s(a))return!1;var o=i(a);return!!o&&o.type==="RawJSON"}},757(d,e,t){var s=t(7751),i=t(4901),r=t(1625),a=t(7040),o=Object;d.exports=a?function(l){return typeof l=="symbol"}:function(l){var h=s("Symbol");return i(h)&&r(h.prototype,o(l))}},507(d,e,t){var s=t(9565);d.exports=function(i,r,a){for(var o=a?i:i.iterator,l=i.next,h,c;!(h=s(l,o)).done;)if(c=r(h.value),c!==void 0)return c}},2652(d,e,t){var s=t(6080),i=t(9565),r=t(8551),a=t(6823),o=t(4209),l=t(6198),h=t(1625),c=t(81),u=t(851),f=t(9539),p=TypeError,m=function(A,w){this.stopped=A,this.result=w},v=m.prototype;d.exports=function(A,w,E){var S=E&&E.that,T=!!(E&&E.AS_ENTRIES),x=!!(E&&E.IS_RECORD),C=!!(E&&E.IS_ITERATOR),I=!!(E&&E.INTERRUPTED),O=s(w,S),M,R,D,j,F,U,Z,L=function(W){var dt=M;return M=void 0,dt&&f(dt,"normal"),new m(!0,W)},B=function(W){return T?(r(W),I?O(W[0],W[1],L):O(W[0],W[1])):I?O(W,L):O(W)};if(x)M=A.iterator;else if(C)M=A;else{if(R=u(A),!R)throw new p(a(A)+" is not iterable");if(o(R)){for(D=0,j=l(A);j>D;D++)if(F=B(A[D]),F&&h(v,F))return F;return new m(!1)}M=c(A,R)}for(U=x?A.next:M.next;!(Z=i(U,M)).done;){var q=Z.value;try{F=B(q)}catch(W){if(M)f(M,"throw",W);else throw W}if(typeof F=="object"&&F&&h(v,F))return F}return new m(!1)}},1385(d,e,t){var s=t(9539);d.exports=function(i,r,a){for(var o=i.length-1;o>=0;o--)if(i[o]!==void 0)try{a=s(i[o].iterator,r,a)}catch(l){r="throw",a=l}if(r==="throw")throw a;return a}},9539(d,e,t){var s=t(9565),i=t(8551),r=t(5966);d.exports=function(a,o,l){var h,c;i(a);try{if(h=r(a,"return"),!h){if(o==="throw")throw l;return l}h=s(h,a)}catch(u){c=!0,h=u}if(o==="throw")throw l;if(c)throw h;return i(h),l}},9462(d,e,t){var s=t(9565),i=t(2360),r=t(6699),a=t(6279),o=t(8227),l=t(1181),h=t(5966),c=t(7657).IteratorPrototype,u=t(2529),f=t(9539),p=t(1385),m=o("toStringTag"),v="IteratorHelper",A="WrapForValidIterator",w="normal",E="throw",S=l.set,T=function(I){var O=l.getterFor(I?A:v);return a(i(c),{next:function(){var R=O(this);if(I)return R.nextHandler();if(R.done)return u(void 0,!0);try{var D=R.nextHandler();return R.returnHandlerResult?D:u(D,R.done)}catch(j){throw R.done=!0,j}},return:function(){var M=O(this),R=M.iterator,D=M.done;if(M.done=!0,I){var j=h(R,"return");return j?s(j,R):u(void 0,!0)}if(D)return u(void 0,!0);if(M.inner)try{f(M.inner.iterator,w)}catch(F){return f(R,E,F)}if(M.openIters)try{p(M.openIters,w)}catch(F){if(R)return f(R,E,F);throw F}return R&&f(R,w),u(void 0,!0)}})},x=T(!0),C=T(!1);r(C,m,"Iterator Helper"),d.exports=function(I,O,M){var R=function(j,F){F?(F.iterator=j.iterator,F.next=j.next):F=j,F.type=O?A:v,F.returnHandlerResult=!!M,F.nextHandler=I,F.counter=0,F.done=!1,S(this,F)};return R.prototype=O?x:C,R}},684(d){d.exports=function(e,t){var s=typeof Iterator=="function"&&Iterator.prototype[e];if(s)try{s.call({next:null},t).next()}catch{return!0}}},4549(d,e,t){var s=t(4576);d.exports=function(i,r){var a=s.Iterator,o=a&&a.prototype,l=o&&o[i],h=!1;if(l)try{l.call({next:function(){return{done:!0}},return:function(){h=!0}},-1)}catch(c){c instanceof r||(h=!1)}if(!h)return l}},7657(d,e,t){var s=t(9039),i=t(4901),r=t(34),a=t(2360),o=t(2787),l=t(6840),h=t(8227),c=t(6395),u=h("iterator"),f=!1,p,m,v;[].keys&&(v=[].keys(),"next"in v?(m=o(o(v)),m!==Object.prototype&&(p=m)):f=!0);var A=!r(p)||s(function(){var w={};return p[u].call(w)!==w});A?p={}:c&&(p=a(p)),i(p[u])||l(p,u,function(){return this}),d.exports={IteratorPrototype:p,BUGGY_SAFARI_ITERATORS:f}},6269(d){d.exports={}},6198(d,e,t){var s=t(8014);d.exports=function(i){return s(i.length)}},283(d,e,t){var s=t(9504),i=t(9039),r=t(4901),a=t(9297),o=t(3724),l=t(350).CONFIGURABLE,h=t(3706),c=t(1181),u=c.enforce,f=c.get,p=String,m=Object.defineProperty,v=s("".slice),A=s("".replace),w=s([].join),E=o&&!i(function(){return m(function(){},"length",{value:8}).length!==8}),S=String(String).split("String"),T=d.exports=function(x,C,I){v(p(C),0,7)==="Symbol("&&(C="["+A(p(C),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),I&&I.getter&&(C="get "+C),I&&I.setter&&(C="set "+C),(!a(x,"name")||l&&x.name!==C)&&(o?m(x,"name",{value:C,configurable:!0}):x.name=C),E&&I&&a(I,"arity")&&x.length!==I.arity&&m(x,"length",{value:I.arity});try{I&&a(I,"constructor")&&I.constructor?o&&m(x,"prototype",{writable:!1}):x.prototype&&(x.prototype=void 0)}catch{}var O=u(x);return a(O,"source")||(O.source=w(S,typeof C=="string"?C:"")),x};Function.prototype.toString=T(function(){return r(this)&&f(this).source||h(this)},"toString")},2248(d,e,t){var s=t(9504),i=Map.prototype;d.exports={Map,set:s(i.set),get:s(i.get),has:s(i.has),remove:s(i.delete),proto:i}},741(d){var e=Math.ceil,t=Math.floor;d.exports=Math.trunc||function(i){var r=+i;return(r>0?t:e)(r)}},7819(d,e,t){var s=t(9039);d.exports=!s(function(){var i="9007199254740993",r=JSON.rawJSON(i);return!JSON.isRawJSON(r)||JSON.stringify(r)!==i})},6043(d,e,t){var s=t(9306),i=TypeError,r=function(a){var o,l;this.promise=new a(function(h,c){if(o!==void 0||l!==void 0)throw new i("Bad Promise constructor");o=h,l=c}),this.resolve=s(o),this.reject=s(l)};d.exports.f=function(a){return new r(a)}},2603(d,e,t){var s=t(655);d.exports=function(i,r){return i===void 0?arguments.length<2?"":r:s(i)}},4149(d){var e=RangeError;d.exports=function(t){if(t===t)return t;throw new e("NaN is not allowed")}},2360(d,e,t){var s=t(8551),i=t(6801),r=t(8727),a=t(421),o=t(397),l=t(4055),h=t(6119),c=">",u="<",f="prototype",p="script",m=h("IE_PROTO"),v=function(){},A=function(x){return u+p+c+x+u+"/"+p+c},w=function(x){x.write(A("")),x.close();var C=x.parentWindow.Object;return x=null,C},E=function(){var x=l("iframe"),C="java"+p+":",I;return x.style.display="none",o.appendChild(x),x.src=String(C),I=x.contentWindow.document,I.open(),I.write(A("document.F=Object")),I.close(),I.F},S,T=function(){try{S=new ActiveXObject("htmlfile")}catch{}T=typeof document<"u"?document.domain&&S?w(S):E():w(S);for(var x=r.length;x--;)delete T[f][r[x]];return T()};a[m]=!0,d.exports=Object.create||function(C,I){var O;return C!==null?(v[f]=s(C),O=new v,v[f]=null,O[m]=C):O=T(),I===void 0?O:i.f(O,I)}},6801(d,e,t){var s=t(3724),i=t(8686),r=t(4913),a=t(8551),o=t(5397),l=t(1072);e.f=s&&!i?Object.defineProperties:function(c,u){a(c);for(var f=o(u),p=l(u),m=p.length,v=0,A;m>v;)r.f(c,A=p[v++],f[A]);return c}},4913(d,e,t){var s=t(3724),i=t(5917),r=t(8686),a=t(8551),o=t(6969),l=TypeError,h=Object.defineProperty,c=Object.getOwnPropertyDescriptor,u="enumerable",f="configurable",p="writable";e.f=s?r?function(v,A,w){if(a(v),A=o(A),a(w),typeof v=="function"&&A==="prototype"&&"value"in w&&p in w&&!w[p]){var E=c(v,A);E&&E[p]&&(v[A]=w.value,w={configurable:f in w?w[f]:E[f],enumerable:u in w?w[u]:E[u],writable:!1})}return h(v,A,w)}:h:function(v,A,w){if(a(v),A=o(A),a(w),i)try{return h(v,A,w)}catch{}if("get"in w||"set"in w)throw new l("Accessors not supported");return"value"in w&&(v[A]=w.value),v}},7347(d,e,t){var s=t(3724),i=t(9565),r=t(8773),a=t(6980),o=t(5397),l=t(6969),h=t(9297),c=t(5917),u=Object.getOwnPropertyDescriptor;e.f=s?u:function(p,m){if(p=o(p),m=l(m),c)try{return u(p,m)}catch{}if(h(p,m))return a(!i(r.f,p,m),p[m])}},8480(d,e,t){var s=t(1828),i=t(8727),r=i.concat("length","prototype");e.f=Object.getOwnPropertyNames||function(o){return s(o,r)}},3717(d,e){e.f=Object.getOwnPropertySymbols},2787(d,e,t){var s=t(9297),i=t(4901),r=t(8981),a=t(6119),o=t(2211),l=a("IE_PROTO"),h=Object,c=h.prototype;d.exports=o?h.getPrototypeOf:function(u){var f=r(u);if(s(f,l))return f[l];var p=f.constructor;return i(p)&&f instanceof p?p.prototype:f instanceof h?c:null}},1625(d,e,t){var s=t(9504);d.exports=s({}.isPrototypeOf)},1828(d,e,t){var s=t(9504),i=t(9297),r=t(5397),a=t(9617).indexOf,o=t(421),l=s([].push);d.exports=function(h,c){var u=r(h),f=0,p=[],m;for(m in u)!i(o,m)&&i(u,m)&&l(p,m);for(;c.length>f;)i(u,m=c[f++])&&(~a(p,m)||l(p,m));return p}},1072(d,e,t){var s=t(1828),i=t(8727);d.exports=Object.keys||function(a){return s(a,i)}},8773(d,e){var t={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,i=s&&!t.call({1:2},1);e.f=i?function(a){var o=s(this,a);return!!o&&o.enumerable}:t},2967(d,e,t){var s=t(6706),i=t(34),r=t(7750),a=t(3506);d.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var o=!1,l={},h;try{h=s(Object.prototype,"__proto__","set"),h(l,[]),o=l instanceof Array}catch{}return function(u,f){return r(u),a(f),i(u)&&(o?h(u,f):u.__proto__=f),u}}():void 0)},4270(d,e,t){var s=t(9565),i=t(4901),r=t(34),a=TypeError;d.exports=function(o,l){var h,c;if(l==="string"&&i(h=o.toString)&&!r(c=s(h,o))||i(h=o.valueOf)&&!r(c=s(h,o))||l!=="string"&&i(h=o.toString)&&!r(c=s(h,o)))return c;throw new a("Can't convert object to primitive value")}},5031(d,e,t){var s=t(7751),i=t(9504),r=t(8480),a=t(3717),o=t(8551),l=i([].concat);d.exports=s("Reflect","ownKeys")||function(c){var u=r.f(o(c)),f=a.f;return f?l(u,f(c)):u}},8235(d,e,t){var s=t(9504),i=t(9297),r=SyntaxError,a=parseInt,o=String.fromCharCode,l=s("".charAt),h=s("".slice),c=s(/./.exec),u={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
|
|
2
|
+
`,"\\r":"\r","\\t":" "},f=/^[\da-f]{4}$/i,p=/^[\u0000-\u001F]$/;d.exports=function(m,v){for(var A=!0,w="";v<m.length;){var E=l(m,v);if(E==="\\"){var S=h(m,v,v+2);if(i(u,S))w+=u[S],v+=2;else if(S==="\\u"){v+=2;var T=h(m,v,v+4);if(!c(f,T))throw new r("Bad Unicode escape at: "+v);w+=o(a(T,16)),v+=4}else throw new r('Unknown escape sequence: "'+S+'"')}else if(E==='"'){A=!1,v++;break}else{if(c(p,E))throw new r("Bad control character in string literal at: "+v);w+=E,v++}}if(A)throw new r("Unterminated string at: "+v);return{value:w,end:v}}},1103(d){d.exports=function(e){try{return{error:!1,value:e()}}catch(t){return{error:!0,value:t}}}},7750(d,e,t){var s=t(4117),i=TypeError;d.exports=function(r){if(s(r))throw new i("Can't call method on "+r);return r}},9286(d,e,t){var s=t(4402),i=t(8469),r=s.Set,a=s.add;d.exports=function(o){var l=new r;return i(o,function(h){a(l,h)}),l}},3440(d,e,t){var s=t(7080),i=t(4402),r=t(9286),a=t(5170),o=t(3789),l=t(8469),h=t(507),c=i.has,u=i.remove;d.exports=function(p){var m=s(this),v=o(p),A=r(m);return a(A)<=v.size?l(A,function(w){v.includes(w)&&u(A,w)}):h(v.getIterator(),function(w){c(A,w)&&u(A,w)}),A}},4402(d,e,t){var s=t(9504),i=Set.prototype;d.exports={Set,add:s(i.add),has:s(i.has),remove:s(i.delete),proto:i}},8750(d,e,t){var s=t(7080),i=t(4402),r=t(5170),a=t(3789),o=t(8469),l=t(507),h=i.Set,c=i.add,u=i.has;d.exports=function(p){var m=s(this),v=a(p),A=new h;return r(m)>v.size?l(v.getIterator(),function(w){u(m,w)&&c(A,w)}):o(m,function(w){v.includes(w)&&c(A,w)}),A}},4449(d,e,t){var s=t(7080),i=t(4402).has,r=t(5170),a=t(3789),o=t(8469),l=t(507),h=t(9539);d.exports=function(u){var f=s(this),p=a(u);if(r(f)<=p.size)return o(f,function(v){if(p.includes(v))return!1},!0)!==!1;var m=p.getIterator();return l(m,function(v){if(i(f,v))return h(m.iterator,"normal",!1)})!==!1}},3838(d,e,t){var s=t(7080),i=t(5170),r=t(8469),a=t(3789);d.exports=function(l){var h=s(this),c=a(l);return i(h)>c.size?!1:r(h,function(u){if(!c.includes(u))return!1},!0)!==!1}},8527(d,e,t){var s=t(7080),i=t(4402).has,r=t(5170),a=t(3789),o=t(507),l=t(9539);d.exports=function(c){var u=s(this),f=a(c);if(r(u)<f.size)return!1;var p=f.getIterator();return o(p,function(m){if(!i(u,m))return l(p.iterator,"normal",!1)})!==!1}},8469(d,e,t){var s=t(9504),i=t(507),r=t(4402),a=r.Set,o=r.proto,l=s(o.forEach),h=s(o.keys),c=h(new a).next;d.exports=function(u,f,p){return p?i({iterator:h(u),next:c},f):l(u,f)}},4916(d,e,t){var s=t(7751),i=function(a){return{size:a,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},r=function(a){return{size:a,has:function(){return!0},keys:function(){throw new Error("e")}}};d.exports=function(a,o){var l=s("Set");try{new l()[a](i(0));try{return new l()[a](i(-1)),!1}catch{if(!o)return!0;try{return new l()[a](r(-1/0)),!1}catch{var h=new l([1,2]);return o(h[a](r(1/0)))}}}catch{return!1}}},9835(d){d.exports=function(e){try{var t=new Set,s={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return t.clear(),t.add(4),function(){return{done:!0}}}})}},i=t[e](s);return i.size===1&&i.values().next().value===4}catch{return!1}}},5170(d,e,t){var s=t(6706),i=t(4402);d.exports=s(i.proto,"size","get")||function(r){return r.size}},3650(d,e,t){var s=t(7080),i=t(4402),r=t(9286),a=t(3789),o=t(507),l=i.add,h=i.has,c=i.remove;d.exports=function(f){var p=s(this),m=a(f).getIterator(),v=r(p);return o(m,function(A){h(p,A)?c(v,A):l(v,A)}),v}},4204(d,e,t){var s=t(7080),i=t(4402).add,r=t(9286),a=t(3789),o=t(507);d.exports=function(h){var c=s(this),u=a(h).getIterator(),f=r(c);return o(u,function(p){i(f,p)}),f}},6119(d,e,t){var s=t(5745),i=t(3392),r=s("keys");d.exports=function(a){return r[a]||(r[a]=i(a))}},7629(d,e,t){var s=t(6395),i=t(4576),r=t(9433),a="__core-js_shared__",o=d.exports=i[a]||r(a,{});(o.versions||(o.versions=[])).push({version:"3.49.0",mode:s?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745(d,e,t){var s=t(7629);d.exports=function(i,r){return s[i]||(s[i]=r||{})}},4495(d,e,t){var s=t(9519),i=t(9039),r=t(4576),a=r.String;d.exports=!!Object.getOwnPropertySymbols&&!i(function(){var o=Symbol("symbol detection");return!a(o)||!(Object(o)instanceof Symbol)||!Symbol.sham&&s&&s<41})},5610(d,e,t){var s=t(1291),i=Math.max,r=Math.min;d.exports=function(a,o){var l=s(a);return l<0?i(l+o,0):r(l,o)}},5854(d,e,t){var s=t(2777),i=TypeError;d.exports=function(r){var a=s(r,"number");if(typeof a=="number")throw new i("Can't convert number to bigint");return BigInt(a)}},5397(d,e,t){var s=t(7055),i=t(7750);d.exports=function(r){return s(i(r))}},1291(d,e,t){var s=t(741);d.exports=function(i){var r=+i;return r!==r||r===0?0:s(r)}},8014(d,e,t){var s=t(1291),i=Math.min;d.exports=function(r){var a=s(r);return a>0?i(a,9007199254740991):0}},8981(d,e,t){var s=t(7750),i=Object;d.exports=function(r){return i(s(r))}},9590(d,e,t){var s=t(1291),i=RangeError;d.exports=function(r){var a=s(r);if(a<0)throw new i("The argument can't be less than 0");return a}},2777(d,e,t){var s=t(9565),i=t(34),r=t(757),a=t(5966),o=t(4270),l=t(8227),h=TypeError,c=l("toPrimitive");d.exports=function(u,f){if(!i(u)||r(u))return u;var p=a(u,c),m;if(p){if(f===void 0&&(f="default"),m=s(p,u,f),!i(m)||r(m))return m;throw new h("Can't convert object to primitive value")}return f===void 0&&(f="number"),o(u,f)}},6969(d,e,t){var s=t(2777),i=t(757);d.exports=function(r){var a=s(r,"string");return i(a)?a:a+""}},2140(d,e,t){var s=t(8227),i=s("toStringTag"),r={};r[i]="z",d.exports=String(r)==="[object z]"},655(d,e,t){var s=t(6955),i=String;d.exports=function(r){if(s(r)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return i(r)}},6823(d){var e=String;d.exports=function(t){try{return e(t)}catch{return"Object"}}},3392(d,e,t){var s=t(9504),i=0,r=Math.random(),a=s(1.1.toString);d.exports=function(o){return"Symbol("+(o===void 0?"":o)+")_"+a(++i+r,36)}},9143(d,e,t){var s=t(4576),i=t(9504),r=t(3972),a=t(3463),o=t(9297),l=t(2804),h=t(944),c=t(5169),u=l.c2i,f=l.c2iUrl,p=s.SyntaxError,m=s.TypeError,v=i("".charAt),A=function(S,T){for(var x=S.length;T<x;T++){var C=v(S,T);if(C!==" "&&C!==" "&&C!==`
|
|
3
|
+
`&&C!=="\f"&&C!=="\r")break}return T},w=function(S,T,x){var C=S.length;C<4&&(S+=C===2?"AA":"A");var I=(T[v(S,0)]<<18)+(T[v(S,1)]<<12)+(T[v(S,2)]<<6)+T[v(S,3)],O=[I>>16&255,I>>8&255,I&255];if(C===2){if(x&&O[1]!==0)throw new p("Extra bits");return[O[0]]}if(C===3){if(x&&O[2]!==0)throw new p("Extra bits");return[O[0],O[1]]}return O},E=function(S,T,x){for(var C=T.length,I=0;I<C;I++)S[x+I]=T[I];return x+C};d.exports=function(S,T,x,C){a(S),r(T);var I=h(T)==="base64"?u:f,O=T?T.lastChunkHandling:void 0;if(O===void 0&&(O="loose"),O!=="loose"&&O!=="strict"&&O!=="stop-before-partial")throw new m("Incorrect `lastChunkHandling` option");x&&c(x.buffer);var M=S.length,R=x||[],D=0,j=0,F="",U=0;if(C)for(;;){if(U=A(S,U),U===M){if(F.length>0){if(O==="stop-before-partial")break;if(O==="loose"){if(F.length===1)throw new p("Malformed padding: exactly one additional character");D=E(R,w(F,I,!1),D)}else throw new p("Missing padding")}j=M;break}var Z=v(S,U);if(++U,Z==="="){if(F.length<2)throw new p("Padding is too early");if(U=A(S,U),F.length===2){if(U===M){if(O==="stop-before-partial")break;throw new p("Malformed padding: only one =")}v(S,U)==="="&&(++U,U=A(S,U))}if(U<M)throw new p("Unexpected character after padding");D=E(R,w(F,I,O==="strict"),D),j=M;break}if(!o(I,Z))throw new p("Unexpected character");var L=C-D;if(L===1&&F.length===2||L===2&&F.length===3||(F+=Z,F.length===4&&(D=E(R,w(F,I,!1),D),F="",j=U,D===C)))break}return{bytes:R,read:j,written:D}}},2303(d,e,t){var s=t(4576),i=t(9504),r=s.Uint8Array,a=s.SyntaxError,o=Math.min,l=i("".match);d.exports=function(h,c){var u=h.length;if(u%2!==0)throw new a("String should be an even number of characters");for(var f=c?o(c.length,u/2):u/2,p=c||new r(f),m=l(h,/.{2}/g),v=0;v<f;v++){var A=+("0x"+m[v]+"0");if(A!==A)throw new a("String should only contain hex characters");p[v]=A>>4}return{bytes:p,read:v<<1}}},7416(d,e,t){var s=t(9039),i=t(8227),r=t(3724),a=t(6395),o=i("iterator");d.exports=!s(function(){var l=new URL("b?a=1&b=2&c=3","https://a"),h=l.searchParams,c=new URLSearchParams("a=1&a=2&b=3"),u="";return l.pathname="c%20d",h.forEach(function(f,p){h.delete("b"),u+=p+f}),c.delete("a",2),c.delete("b",void 0),a&&(!l.toJSON||!c.has("a",1)||c.has("a",2)||!c.has("a",void 0)||c.has("b"))||!h.size&&(a||!r)||!h.sort||l.href!=="https://a/c%20d?a=1&c=3"||h.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!h[o]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||u!=="a1c3"||new URL("https://x",void 0).host!=="x"})},7040(d,e,t){var s=t(4495);d.exports=s&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},8686(d,e,t){var s=t(3724),i=t(9039);d.exports=s&&i(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})},2812(d){var e=TypeError;d.exports=function(t,s){if(t<s)throw new e("Not enough arguments");return t}},8622(d,e,t){var s=t(4576),i=t(4901),r=s.WeakMap;d.exports=i(r)&&/native code/.test(String(r))},4995(d,e,t){var s=t(9504),i=WeakMap.prototype;d.exports={WeakMap,set:s(i.set),get:s(i.get),has:s(i.has),remove:s(i.delete)}},8227(d,e,t){var s=t(4576),i=t(5745),r=t(9297),a=t(3392),o=t(4495),l=t(7040),h=s.Symbol,c=i("wks"),u=l?h.for||h:h&&h.withoutSetter||a;d.exports=function(f){return r(c,f)||(c[f]=o&&r(h,f)?h[f]:u("Symbol."+f)),c[f]}},4423(d,e,t){var s=t(6518),i=t(9617).includes,r=t(9039),a=t(6469),o=r(function(){return!Array(1).includes()}),l=r(function(){return[,1].includes(void 0,1)});s({target:"Array",proto:!0,forced:o||l},{includes:function(c){return i(this,c,arguments.length>1?arguments[1]:void 0)}}),a("includes")},4114(d,e,t){var s=t(6518),i=t(8981),r=t(6198),a=t(4527),o=t(6837),l=t(9039),h=l(function(){return[].push.call({length:4294967296},1)!==4294967297}),c=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(f){return f instanceof TypeError}},u=h||!c();s({target:"Array",proto:!0,arity:1,forced:u},{push:function(p){var m=i(this),v=r(m),A=arguments.length;o(v+A);for(var w=0;w<A;w++)m[v]=arguments[w],v++;return a(m,v),v}})},8111(d,e,t){var s=t(6518),i=t(4576),r=t(679),a=t(8551),o=t(4901),l=t(2787),h=t(2106),c=t(4659),u=t(9039),f=t(9297),p=t(8227),m=t(7657).IteratorPrototype,v=t(3724),A=t(6395),w="constructor",E="Iterator",S=p("toStringTag"),T=TypeError,x=i[E],C=A||!o(x)||x.prototype!==m||!u(function(){x({})}),I=function(){if(r(this,m),l(this)===m)throw new T("Abstract class Iterator not directly constructable")},O=function(M,R){v?h(m,M,{configurable:!0,get:function(){return R},set:function(D){if(a(this),this===m)throw new T("You can't redefine this property");f(this,M)?this[M]=D:c(this,M,D)}}):m[M]=R};f(m,S)||O(S,E),(C||!f(m,w)||m[w]===Object)&&O(w,I),I.prototype=m,s({global:!0,constructor:!0,forced:C},{Iterator:I})},9314(d,e,t){var s=t(6518),i=t(9565),r=t(8551),a=t(1767),o=t(4149),l=t(9590),h=t(9539),c=t(9462),u=t(684),f=t(4549),p=t(6395),m=!p&&!u("drop",0),v=!p&&!m&&f("drop",RangeError),A=p||m||v,w=c(function(){for(var E=this.iterator,S=this.next,T,x;this.remaining;)if(this.remaining--,T=r(i(S,E)),x=this.done=!!T.done,x)return;if(T=r(i(S,E)),x=this.done=!!T.done,!x)return T.value});s({target:"Iterator",proto:!0,real:!0,forced:A},{drop:function(S){r(this);var T;try{T=l(o(+S))}catch(x){h(this,"throw",x)}return v?i(v,this,T):new w(a(this),{remaining:T})}})},1148(d,e,t){var s=t(6518),i=t(9565),r=t(2652),a=t(9306),o=t(8551),l=t(1767),h=t(9539),c=t(4549),u=c("every",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:u},{every:function(p){o(this);try{a(p)}catch(A){h(this,"throw",A)}if(u)return i(u,this,p);var m=l(this),v=0;return!r(m,function(A,w){if(!p(A,v++))return w()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},2489(d,e,t){var s=t(6518),i=t(9565),r=t(9306),a=t(8551),o=t(1767),l=t(9462),h=t(6319),c=t(6395),u=t(9539),f=t(684),p=t(4549),m=!c&&!f("filter",function(){}),v=!c&&!m&&p("filter",TypeError),A=c||m||v,w=l(function(){for(var E=this.iterator,S=this.predicate,T=this.next,x,C,I;;){if(x=a(i(T,E)),C=this.done=!!x.done,C)return;if(I=x.value,h(E,S,[I,this.counter++],!0))return I}});s({target:"Iterator",proto:!0,real:!0,forced:A},{filter:function(S){a(this);try{r(S)}catch(T){u(this,"throw",T)}return v?i(v,this,S):new w(o(this),{predicate:S})}})},116(d,e,t){var s=t(6518),i=t(9565),r=t(2652),a=t(9306),o=t(8551),l=t(1767),h=t(9539),c=t(4549),u=c("find",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:u},{find:function(p){o(this);try{a(p)}catch(A){h(this,"throw",A)}if(u)return i(u,this,p);var m=l(this),v=0;return r(m,function(A,w){if(p(A,v++))return w(A)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},531(d,e,t){var s=t(6518),i=t(9565),r=t(9306),a=t(8551),o=t(1767),l=t(8646),h=t(9462),c=t(9539),u=t(6395),f=t(684),p=t(4549);function m(){try{var S=Iterator.prototype.flatMap.call(new Map([[4,5]]).entries(),function(T){return T});S.next(),S.return()}catch{return!0}}var v=!u&&!f("flatMap",function(){}),A=!u&&!v&&p("flatMap",TypeError),w=u||v||A||m(),E=h(function(){for(var S=this.iterator,T=this.mapper,x,C;;){if(C=this.inner)try{if(x=a(i(C.next,C.iterator)),!x.done)return x.value;this.inner=null}catch(I){c(S,"throw",I)}if(x=a(i(this.next,S)),this.done=!!x.done)return;try{this.inner=l(T(x.value,this.counter++),!1)}catch(I){c(S,"throw",I)}}});s({target:"Iterator",proto:!0,real:!0,forced:w},{flatMap:function(T){a(this);try{r(T)}catch(x){c(this,"throw",x)}return A?i(A,this,T):new E(o(this),{mapper:T,inner:null})}})},7588(d,e,t){var s=t(6518),i=t(9565),r=t(2652),a=t(9306),o=t(8551),l=t(1767),h=t(9539),c=t(4549),u=c("forEach",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:u},{forEach:function(p){o(this);try{a(p)}catch(A){h(this,"throw",A)}if(u)return i(u,this,p);var m=l(this),v=0;r(m,function(A){p(A,v++)},{IS_RECORD:!0})}})},1701(d,e,t){var s=t(6518),i=t(9565),r=t(9306),a=t(8551),o=t(1767),l=t(9462),h=t(6319),c=t(9539),u=t(684),f=t(4549),p=t(6395),m=!p&&!u("map",function(){}),v=!p&&!m&&f("map",TypeError),A=p||m||v,w=l(function(){var E=this.iterator,S=a(i(this.next,E)),T=this.done=!!S.done;if(!T)return h(E,this.mapper,[S.value,this.counter++],!0)});s({target:"Iterator",proto:!0,real:!0,forced:A},{map:function(S){a(this);try{r(S)}catch(T){c(this,"throw",T)}return v?i(v,this,S):new w(o(this),{mapper:S})}})},3579(d,e,t){var s=t(6518),i=t(9565),r=t(2652),a=t(9306),o=t(8551),l=t(1767),h=t(9539),c=t(4549),u=c("some",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:u},{some:function(p){o(this);try{a(p)}catch(A){h(this,"throw",A)}if(u)return i(u,this,p);var m=l(this),v=0;return r(m,function(A,w){if(p(A,v++))return w()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})},4972(d,e,t){var s=t(6518),i=t(9565),r=t(8551),a=t(1767),o=t(4149),l=t(9590),h=t(9462),c=t(9539),u=t(684),f=t(4549),p=t(6395),m=!p&&!u("take",1),v=!p&&!m&&f("take",RangeError),A=p||m||v,w=h(function(){var E=this.iterator;if(!this.remaining--)return this.done=!0,c(E,"normal",void 0);var S=r(i(this.next,E)),T=this.done=!!S.done;if(!T)return S.value});s({target:"Iterator",proto:!0,real:!0,forced:A},{take:function(S){r(this);var T;try{T=l(o(+S))}catch(x){c(this,"throw",x)}return v?i(v,this,T):new w(a(this),{remaining:T})}})},9112(d,e,t){var s=t(6518),i=t(3724),r=t(4576),a=t(7751),o=t(9504),l=t(9565),h=t(4901),c=t(34),u=t(4376),f=t(9297),p=t(655),m=t(6198),v=t(4659),A=t(9039),w=t(8235),E=t(4495),S=r.JSON,T=r.Number,x=r.SyntaxError,C=S&&S.parse,I=a("Object","keys"),O=Object.getOwnPropertyDescriptor,M=o("".charAt),R=o("".slice),D=o(/./.exec),j=o([].push),F=/^\d$/,U=/^[1-9]$/,Z=/^[\d-]$/,L=/^[\t\n\r ]$/,B=0,q=1,W=function(N,k){N=p(N);var $=new X(N,0),K=$.parse(),gt=K.value,J=$.skip(L,K.end);if(J<N.length)throw new x('Unexpected extra character: "'+M(N,J)+'" after the parsed data at: '+J);return h(k)?dt({"":gt},"",k,K):gt},dt=function(N,k,$,K){var gt=N[k],J=K&>===K.value,rt=J&&typeof K.source=="string"?{source:K.source}:{},Pt,pe,ce,ae,tn;if(c(gt)){var ia=u(gt),mu=J?K.nodes:ia?[]:{};if(ia)for(Pt=mu.length,ce=m(gt),ae=0;ae<ce;ae++)yt(gt,ae,dt(gt,""+ae,$,ae<Pt?mu[ae]:void 0));else for(pe=I(gt),ce=m(pe),ae=0;ae<ce;ae++)tn=pe[ae],yt(gt,tn,dt(gt,tn,$,f(mu,tn)?mu[tn]:void 0))}return l($,N,k,gt,rt)},yt=function(N,k,$){if(i){var K=O(N,k);if(K&&!K.configurable)return}$===void 0?delete N[k]:v(N,k,$)},ct=function(N,k,$,K){this.value=N,this.end=k,this.source=$,this.nodes=K},X=function(N,k){this.source=N,this.index=k};X.prototype={fork:function(N){return new X(this.source,N)},parse:function(){var N=this.source,k=this.skip(L,this.index),$=this.fork(k),K=M(N,k);if(D(Z,K))return $.number();switch(K){case"{":return $.object();case"[":return $.array();case'"':return $.string();case"t":return $.keyword(!0);case"f":return $.keyword(!1);case"n":return $.keyword(null)}throw new x('Unexpected character: "'+K+'" at: '+k)},node:function(N,k,$,K,gt){return new ct(k,K,N?null:R(this.source,$,K),gt)},object:function(){for(var N=this.source,k=this.index+1,$=!1,K={},gt={},J=!1;k<N.length;){if(k=this.until(['"',"}"],k),M(N,k)==="}"&&!$){k++,J=!0;break}var rt=this.fork(k).string(),Pt=rt.value;k=rt.end,k=this.until([":"],k)+1,k=this.skip(L,k),rt=this.fork(k).parse(),v(gt,Pt,rt),v(K,Pt,rt.value),k=this.until([",","}"],rt.end);var pe=M(N,k);if(pe===",")$=!0,k++;else if(pe==="}"){k++,J=!0;break}}if(!J)throw new x("Unterminated object at: "+k);return this.node(q,K,this.index,k,gt)},array:function(){for(var N=this.source,k=this.index+1,$=!1,K=[],gt=[],J=!1;k<N.length;){if(k=this.skip(L,k),M(N,k)==="]"&&!$){k++,J=!0;break}var rt=this.fork(k).parse();if(j(gt,rt),j(K,rt.value),k=this.until([",","]"],rt.end),M(N,k)===",")$=!0,k++;else if(M(N,k)==="]"){k++,J=!0;break}}if(!J)throw new x("Unterminated array at: "+k);return this.node(q,K,this.index,k,gt)},string:function(){var N=this.index,k=w(this.source,this.index+1);return this.node(B,k.value,N,k.end)},number:function(){var N=this.source,k=this.index,$=k;if(M(N,$)==="-"&&$++,M(N,$)==="0")$++;else if(D(U,M(N,$)))$=this.skip(F,$+1);else throw new x("Failed to parse number at: "+$);if(M(N,$)==="."){var K=$+1;if($=this.skip(F,K),K===$)throw new x("Failed to parse number's fraction at: "+$)}if(M(N,$)==="e"||M(N,$)==="E"){$++,(M(N,$)==="+"||M(N,$)==="-")&&$++;var gt=$;if($=this.skip(F,$),gt===$)throw new x("Failed to parse number's exponent value at: "+$)}return this.node(B,T(R(N,k,$)),k,$)},keyword:function(N){var k=""+N,$=this.index,K=$+k.length;if(R(this.source,$,K)!==k)throw new x("Failed to parse value at: "+$);return this.node(B,N,$,K)},skip:function(N,k){for(var $=this.source;k<$.length&&D(N,M($,k));k++);return k},until:function(N,k){k=this.skip(L,k);for(var $=M(this.source,k),K=0;K<N.length;K++)if(N[K]===$)return k;throw new x('Unexpected character: "'+$+'" at: '+k)}};var ft=A(function(){var N="9007199254740993",k;return C(N,function($,K,gt){k=gt.source}),k!==N}),Ft=E&&!A(function(){return 1/C("-0 ")!==-1/0});s({target:"JSON",stat:!0,forced:ft},{parse:function(k,$){return Ft&&!h($)?C(k):W(k,$)}})},3110(d,e,t){var s=t(6518),i=t(7751),r=t(8745),a=t(9565),o=t(9504),l=t(9039),h=t(4376),c=t(4901),u=t(5810),f=t(757),p=t(2195),m=t(655),v=t(7680),A=t(8235),w=t(3392),E=t(4495),S=t(7819),T=String,x=i("JSON","stringify"),C=o(/./.exec),I=o("".charAt),O=o("".charCodeAt),M=o("".replace),R=o("".slice),D=o([].push),j=o(1.1.toString),F=/[\uD800-\uDFFF]/g,U=/^[\uD800-\uDBFF]$/,Z=/^[\uDC00-\uDFFF]$/,L=w(),B=L.length,q=!E||l(function(){var X=i("Symbol")("stringify detection");return x([X])!=="[null]"||x({a:X})!=="{}"||x(Object(X))!=="{}"}),W=l(function(){return x("\uDF06\uD834")!=='"\\udf06\\ud834"'||x("\uDEAD")!=='"\\udead"'}),dt=q?function(X,ft){var Ft=v(arguments),N=ct(ft);if(!(!c(N)&&(X===void 0||f(X))))return Ft[1]=function(k,$){if(c(N)&&($=a(N,this,T(k),$)),!f($))return $},r(x,null,Ft)}:x,yt=function(X,ft,Ft){var N=I(Ft,ft-1),k=I(Ft,ft+1);return C(U,X)&&!C(Z,k)||C(Z,X)&&!C(U,N)?"\\u"+j(O(X,0),16):X},ct=function(X){if(c(X))return X;if(h(X)){for(var ft=X.length,Ft=[],N=0;N<ft;N++){var k=X[N];typeof k=="string"?D(Ft,k):(typeof k=="number"||p(k)==="Number"||p(k)==="String")&&D(Ft,m(k))}var $=Ft.length,K=!0;return function(gt,J){if(K)return K=!1,J;if(h(this))return J;for(var rt=0;rt<$;rt++)if(Ft[rt]===gt)return J}}};x&&s({target:"JSON",stat:!0,arity:3,forced:q||W||!S},{stringify:function(ft,Ft,N){var k=ct(Ft),$=[],K=dt(ft,function(ae,tn){var ia=c(k)?a(k,this,T(ae),tn):tn;return!S&&u(ia)?L+(D($,ia.rawJSON)-1):ia},N);if(typeof K!="string"||(W&&(K=M(K,F,yt)),S))return K;for(var gt="",J=K.length,rt=0;rt<J;rt++){var Pt=I(K,rt);if(Pt==='"'){var pe=A(K,++rt).end-1,ce=R(K,rt,pe);gt+=R(ce,0,B)===L?$[R(ce,B)]:'"'+ce+'"',rt=pe}else gt+=Pt}return gt}})},2731(d,e,t){var s=t(6518),i=t(9306),r=t(2248),a=t(6395),o=r.get,l=r.has,h=r.set;s({target:"Map",proto:!0,real:!0,forced:a},{getOrInsertComputed:function(u,f){var p=l(this,u);if(i(f),p)return o(this,u);u===0&&1/u===-1/0&&(u=0);var m=f(u);return h(this,u,m),m}})},5367(d,e,t){var s=t(6518),i=t(2248),r=t(6395),a=i.get,o=i.has,l=i.set;s({target:"Map",proto:!0,real:!0,forced:r},{getOrInsert:function(c,u){return o(this,c)?a(this,c):(l(this,c,u),u)}})},3068(d,e,t){var s=t(6518),i=t(9504),r=t(2652),a=RangeError,o=TypeError,l=1/0,h=NaN,c=Math.abs,u=Math.pow,f=i([].push),p=u(2,1023),m=u(2,53)-1,v=Number.MAX_VALUE,A=u(2,971),w={},E={},S={},T={},x={},C=function(I,O){var M=I+O,R=O-(M-I);return{hi:M,lo:R}};s({target:"Math",stat:!0},{sumPrecise:function(O){var M=[],R=0,D=T;switch(r(O,function(N){if(++R>m)throw new a("Maximum allowed index exceeded");if(typeof N!="number")throw new o("Value is not a number");D!==w&&(N!==N?D=w:N===l?D=D===E?w:S:N===-l?D=D===S?w:E:(N!==0||1/N===l)&&(D===T||D===x)&&(D=x,f(M,N)))}),D){case w:return h;case E:return-l;case S:return l;case T:return-0}for(var j=[],F=0,U,Z,L,B,q,W,dt=0;dt<M.length;dt++){U=M[dt];for(var yt=0,ct=0;ct<j.length;ct++){if(Z=j[ct],c(U)<c(Z)&&(W=U,U=Z,Z=W),L=C(U,Z),B=L.hi,q=L.lo,c(B)===l){var X=B===l?1:-1;F+=X,U=U-X*p-X*p,c(U)<c(Z)&&(W=U,U=Z,Z=W),L=C(U,Z),B=L.hi,q=L.lo}q!==0&&(j[yt++]=q),U=B}j.length=yt,U!==0&&f(j,U)}var ft=j.length-1;if(B=0,q=0,F!==0){var Ft=ft>=0?j[ft]:0;if(ft--,c(F)>1||F>0&&Ft>0||F<0&&Ft<0)return F>0?l:-l;if(L=C(F*p,Ft/2),B=L.hi,q=L.lo,q*=2,c(2*B)===l)return B>0?B===p&&q===-(A/2)&&ft>=0&&j[ft]<0?v:l:B===-p&&q===A/2&&ft>=0&&j[ft]>0?-v:-l;q!==0&&(j[++ft]=q,q=0),B*=2}for(;ft>=0&&(L=C(B,j[ft--]),B=L.hi,q=L.lo,q===0););return ft>=0&&(q<0&&j[ft]<0||q>0&&j[ft]>0)&&(Z=q*2,U=B+Z,Z===U-B&&(B=U)),B}})},1689(d,e,t){var s=t(6518),i=t(4576),r=t(8745),a=t(7680),o=t(6043),l=t(9306),h=t(1103),c=i.Promise,u=!1,f=!c||!c.try||h(function(){c.try(function(p){u=p===8},8)}).error||!u;s({target:"Promise",stat:!0,forced:f},{try:function(p){var m=arguments.length>1?a(arguments,1):[],v=o.f(this),A=h(function(){return r(l(p),void 0,m)});return(A.error?v.reject:v.resolve)(A.value),v.promise}})},4628(d,e,t){var s=t(6518),i=t(6043);s({target:"Promise",stat:!0},{withResolvers:function(){var a=i.f(this);return{promise:a.promise,resolve:a.resolve,reject:a.reject}}})},7642(d,e,t){var s=t(6518),i=t(3440),r=t(9039),a=t(4916),o=!a("difference",function(h){return h.size===0}),l=o||r(function(){var h={size:1,has:function(){return!0},keys:function(){var u=0;return{next:function(){var f=u++>1;return c.has(1)&&c.clear(),{done:f,value:2}}}}},c=new Set([1,2,3,4]);return c.difference(h).size!==3});s({target:"Set",proto:!0,real:!0,forced:l},{difference:i})},8004(d,e,t){var s=t(6518),i=t(9039),r=t(8750),a=t(4916),o=!a("intersection",function(l){return l.size===2&&l.has(1)&&l.has(2)})||i(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});s({target:"Set",proto:!0,real:!0,forced:o},{intersection:r})},3853(d,e,t){var s=t(6518),i=t(4449),r=t(4916),a=!r("isDisjointFrom",function(o){return!o});s({target:"Set",proto:!0,real:!0,forced:a},{isDisjointFrom:i})},5876(d,e,t){var s=t(6518),i=t(3838),r=t(4916),a=!r("isSubsetOf",function(o){return o});s({target:"Set",proto:!0,real:!0,forced:a},{isSubsetOf:i})},2475(d,e,t){var s=t(6518),i=t(8527),r=t(4916),a=!r("isSupersetOf",function(o){return!o});s({target:"Set",proto:!0,real:!0,forced:a},{isSupersetOf:i})},5024(d,e,t){var s=t(6518),i=t(3650),r=t(9835),a=t(4916),o=!a("symmetricDifference")||!r("symmetricDifference");s({target:"Set",proto:!0,real:!0,forced:o},{symmetricDifference:i})},1698(d,e,t){var s=t(6518),i=t(4204),r=t(9835),a=t(4916),o=!a("union")||!r("union");s({target:"Set",proto:!0,real:!0,forced:o},{union:i})},9577(d,e,t){var s=t(4644),i=t(1108),r=t(6198),a=t(1291),o=t(5854),l=s.aTypedArray,h=s.getTypedArrayConstructor,c=s.exportTypedArrayMethod,u=RangeError,f=function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(m){return m===8}}(),p=f&&function(){try{new Int8Array(1).with(-.5,1)}catch{return!0}}();c("with",function(m,v){var A=l(this),w=r(A),E=a(m),S=E<0?w+E:E,T=i(A)?o(v):+v;if(S>=w||S<0)throw new u("Incorrect index");for(var x=new(h(A))(w),C=0;C<w;C++)x[C]=C===S?T:A[C];return x},!f||p)},5213(d,e,t){var s=t(6518),i=t(4576),r=t(5370),a=t(9143),o=i.Uint8Array,l=!o||!o.fromBase64||!function(){try{o.fromBase64("a");return}catch{}try{o.fromBase64("",null)}catch{return!0}}();o&&s({target:"Uint8Array",stat:!0,forced:l},{fromBase64:function(c){var u=a(c,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return r(o,u.bytes)}})},6632(d,e,t){var s=t(6518),i=t(4576),r=t(9143),a=t(4154),o=i.Uint8Array,l=!o||!o.prototype.setFromBase64||!function(){var h=new o([255,255,255,255,255]);try{h.setFromBase64("",null);return}catch{}try{h.setFromBase64("a");return}catch{}try{h.setFromBase64("MjYyZg===")}catch{return h[0]===50&&h[1]===54&&h[2]===50&&h[3]===255&&h[4]===255}}();o&&s({target:"Uint8Array",proto:!0,forced:l},{setFromBase64:function(c){a(this);var u=r(c,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:u.read,written:u.written}}})},4226(d,e,t){var s=t(6518),i=t(4576),r=t(3463),a=t(4154),o=t(5169),l=t(2303);function h(){try{var c=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(c).setFromHex("cafed00d")}catch{return!0}}i.Uint8Array&&s({target:"Uint8Array",proto:!0,forced:h()},{setFromHex:function(u){a(this),r(u),o(this.buffer);var f=l(u,this).read;return{read:f,written:f/2}}})},9486(d,e,t){var s=t(6518),i=t(4576),r=t(9504),a=t(3972),o=t(4154),l=t(5169),h=t(2804),c=t(944),u=h.i2c,f=h.i2cUrl,p=r("".charAt),m=i.Uint8Array,v=!m||!m.prototype.toBase64||!function(){try{var A=new m;A.toBase64(null)}catch{return!0}}();m&&s({target:"Uint8Array",proto:!0,forced:v},{toBase64:function(){var w=o(this),E=arguments.length?a(arguments[0]):void 0,S=c(E)==="base64"?u:f,T=!!E&&!!E.omitPadding;l(this.buffer);for(var x="",C=0,I=w.length,O,M=function(R){return p(S,O>>6*R&63)};C+2<I;C+=3)O=(w[C]<<16)+(w[C+1]<<8)+w[C+2],x+=M(3)+M(2)+M(1)+M(0);return C+2===I?(O=(w[C]<<16)+(w[C+1]<<8),x+=M(3)+M(2)+M(1)+(T?"":"=")):C+1===I&&(O=w[C]<<16,x+=M(3)+M(2)+(T?"":"==")),x}})},456(d,e,t){var s=t(6518),i=t(4576),r=t(9504),a=t(4154),o=t(5169),l=r(1.1.toString),h=r([].join),c=Array,u=i.Uint8Array,f=!u||!u.prototype.toHex||!function(){try{var p=new u([255,255,255,255,255,255,255,255]);return p.toHex()==="ffffffffffffffff"}catch{return!1}}();u&&s({target:"Uint8Array",proto:!0,forced:f},{toHex:function(){a(this),o(this.buffer);for(var m=c(this.length),v=0,A=this.length;v<A;v++){var w=l(this[v],16);m[v]=w.length===1?"0"+w:w}return h(m,"")}})},9452(d,e,t){var s=t(6518),i=t(9306),r=t(6557),a=t(4328),o=t(4995),l=t(6395),h=o.get,c=o.has,u=o.set,f=l||!function(){try{WeakMap.prototype.getOrInsertComputed&&new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(p){return p instanceof TypeError}}();s({target:"WeakMap",proto:!0,real:!0,forced:f},{getOrInsertComputed:function(m,v){if(l||r(this),a(m),i(v),c(this,m))return h(this,m);var A=v(m);return u(this,m,A),A}})},8454(d,e,t){var s=t(6518),i=t(4995),r=t(6395),a=i.get,o=i.has,l=i.set;s({target:"WeakMap",proto:!0,real:!0,forced:r},{getOrInsert:function(c,u){return o(this,c)?a(this,c):(l(this,c,u),u)}})},4979(d,e,t){var s=t(6518),i=t(4576),r=t(7751),a=t(6980),o=t(4913).f,l=t(9297),h=t(679),c=t(3167),u=t(2603),f=t(5002),p=t(6193),m=t(3724),v=t(6395),A="DOMException",w=r("Error"),E=r(A),S=function(){h(this,T);var L=arguments.length,B=u(L<1?void 0:arguments[0]),q=u(L<2?void 0:arguments[1],"Error"),W=new E(B,q),dt=new w(B);return dt.name=A,o(W,"stack",a(1,p(dt.stack,1))),c(W,this,S),W},T=S.prototype=E.prototype,x="stack"in new w(A),C="stack"in new E(1,2),I=E&&m&&Object.getOwnPropertyDescriptor(i,A),O=!!I&&!(I.writable&&I.configurable),M=x&&!O&&!C;s({global:!0,constructor:!0,forced:v||M},{DOMException:M?S:E});var R=r(A),D=R.prototype;if(D.constructor!==R){v||o(D,"constructor",a(1,R));for(var j in f)if(l(f,j)){var F=f[j],U=F.s;l(R,U)||o(R,U,a(6,F.c))}}},5781(d,e,t){var s=t(6518),i=t(7751),r=t(2812),a=t(655),o=t(7416),l=i("URL");s({target:"URL",stat:!0,forced:!o},{parse:function(c){var u=r(arguments.length,1),f=a(c),p=u<2||arguments[1]===void 0?void 0:a(arguments[1]);try{return new l(f,p)}catch{return null}}})}},ym={};function lt(d){var e=ym[d];if(e!==void 0)return e.exports;var t=ym[d]={exports:{}};return kb[d].call(t.exports,t,t.exports,lt),t.exports}lt.d=(d,e)=>{for(var t in e)lt.o(e,t)&&!lt.o(d,t)&&Object.defineProperty(d,t,{enumerable:!0,get:e[t]})};lt.o=(d,e)=>Object.prototype.hasOwnProperty.call(d,e);lt(4423);lt(4114);lt(8111);lt(2489);lt(5367);lt(2731);lt(9577);lt(6632);lt(4226);lt(9486);lt(456);lt(5781);const ks=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),zn=[1/0,1/0,-1/0,-1/0],pa=new Float32Array(zn),Sp=[.001,0,0,.001,0,0],gp=1.35,ps="http://www.w3.org/2000/svg",Ds={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},_n={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},il="pdfjs_internal_id_",vc="pdfjs_internal_editor_",nt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},at={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},Jm={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},de={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},uc={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Xt={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26,RICHMEDIA:27},Zo={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},uu={ERRORS:0,WARNINGS:1,INFOS:5},yi={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},jh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},Qm={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Zf=uu.WARNINGS;function Lb(d){Number.isInteger(d)&&(Zf=d)}function Fb(){return Zf}function qf(d){Zf>=uu.INFOS&&console.info(`Info: ${d}`)}function it(d){Zf>=uu.WARNINGS&&console.warn(`Warning: ${d}`)}function bt(d){throw new Error(d)}function Jt(d,e){d||bt(e)}function Nb(d){switch(d==null?void 0:d.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Qg(d,e=null,t=null){if(!d)return null;if(t&&typeof d=="string"){if(t.addDefaultProtocol&&d.startsWith("www.")){const i=d.match(/\./g);(i==null?void 0:i.length)>=2&&(d=`http://${d}`)}if(t.tryConvertEncoding)try{d=Hb(d)}catch{}}const s=e?URL.parse(d,e):URL.parse(d);return Nb(s)?s:null}function Zg(d,e,t=!1){const s=URL.parse(d);return s?(s.hash=e,s.href):t&&Qg(d,"http://example.com")?d.split("#",1)[0]+`${e?`#${e}`:""}`:""}function xp(d){return d.substring(d.lastIndexOf("/")+1)}function st(d,e,t,s=!1){return Object.defineProperty(d,e,{value:t,enumerable:!s,configurable:!0,writable:!1}),t}const Ko=function(){function e(t,s){this.message=t,this.name=s}return e.prototype=new Error,e.constructor=e,e}();class ff extends Ko{constructor(e,t){super(e,"PasswordException"),this.code=t}}class mp extends Ko{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class pf extends Ko{constructor(e){super(e,"InvalidPDFException")}}class yc extends Ko{constructor(e,t,s){super(e,"ResponseException"),this.status=t,this.missing=s}}class Bb extends Ko{constructor(e){super(e,"FormatError")}}class Xn extends Ko{constructor(e){super(e,"AbortException")}}function Ub(d){(typeof d!="object"||(d==null?void 0:d.length)===void 0)&&bt("Invalid argument for bytesToString");const e=d.length,t=8192;if(e<t)return String.fromCharCode.apply(null,d);const s=[];for(let i=0;i<e;i+=t){const r=Math.min(i+t,e),a=d.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function tp(d){typeof d!="string"&&bt("Invalid argument for stringToBytes");const e=d.length,t=new Uint8Array(e);for(let s=0;s<e;++s)t[s]=d.charCodeAt(s)&255;return t}class It{static get isLittleEndian(){const e=new Uint8Array(4);e[0]=1;const t=new Uint32Array(e.buffer,0,1);return st(this,"isLittleEndian",t[0]===1)}static get isOffscreenCanvasSupported(){return st(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return st(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return st(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return st(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:e,userAgent:t}=navigator;return st(this,"platform",{isAndroid:t.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:t.includes("Firefox")})}static get isCanvasFilterSupported(){let e;return this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(e=document.createElement("canvas").getContext("2d")),st(this,"isCanvasFilterSupported",(e==null?void 0:e.filter)!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return st(this,"isAlphaColorInputSupported",!1);const e=document.createElement("input");return e.type="color",e.setAttribute("alpha",""),e.value="#ff000080",st(this,"isAlphaColorInputSupported",e.value!=="#ff0000")}static get isBackdropFilterSupported(){return st(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}var Wn,Cu,Tp;class H{static get hexNums(){return st(this,"hexNums",Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0")))}static makeHexColor(e,t,s){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[s]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,s=0){const i=e[s],r=e[s+1];e[s]=i*t[0]+r*t[2]+t[4],e[s+1]=i*t[1]+r*t[3]+t[5]}static applyTransformToBezier(e,t,s=0){const i=t[0],r=t[1],a=t[2],o=t[3],l=t[4],h=t[5];for(let c=0;c<6;c+=2){const u=e[s+c],f=e[s+c+1];e[s+c]=u*i+f*a+l,e[s+c+1]=u*r+f*o+h}}static applyInverseTransform(e,t){const s=e[0],i=e[1],r=t[0]*t[3]-t[1]*t[2];e[0]=(s*t[3]-i*t[2]+t[2]*t[5]-t[4]*t[3])/r,e[1]=(-s*t[1]+i*t[0]+t[4]*t[1]-t[5]*t[0])/r}static axialAlignedBoundingBox(e,t,s){const i=t[0],r=t[1],a=t[2],o=t[3],l=t[4],h=t[5],c=e[0],u=e[1],f=e[2],p=e[3];let m=i*c+l,v=m,A=i*f+l,w=A,E=o*u+h,S=E,T=o*p+h,x=T;if(r!==0||a!==0){const C=r*c,I=r*f,O=a*u,M=a*p;m+=O,w+=O,A+=M,v+=M,E+=C,x+=C,T+=I,S+=I}s[0]=Math.min(s[0],m,A,v,w),s[1]=Math.min(s[1],E,T,S,x),s[2]=Math.max(s[2],m,A,v,w),s[3]=Math.max(s[3],E,T,S,x)}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){const s=e[0],i=e[1],r=e[2],a=e[3],o=s**2+i**2,l=s*r+i*a,h=r**2+a**2,c=(o+h)/2,u=Math.sqrt(c**2-(o*h-l**2));t[0]=Math.sqrt(c+u||1),t[1]=Math.sqrt(c-u||1)}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const s=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(s>i)return null;const r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>a?null:[s,r,i,a]}static pointBoundingBox(e,t,s){s[0]=Math.min(s[0],e),s[1]=Math.min(s[1],t),s[2]=Math.max(s[2],e),s[3]=Math.max(s[3],t)}static rectBoundingBox(e,t,s,i,r){r[0]=Math.min(r[0],e,s),r[1]=Math.min(r[1],t,i),r[2]=Math.max(r[2],e,s),r[3]=Math.max(r[3],t,i)}static bezierBoundingBox(e,t,s,i,r,a,o,l,h){h[0]=Math.min(h[0],e,o),h[1]=Math.min(h[1],t,l),h[2]=Math.max(h[2],e,o),h[3]=Math.max(h[3],t,l),b(this,Wn,Tp).call(this,e,s,r,o,t,i,a,l,3*(-e+3*(s-r)+o),6*(e-2*s+r),3*(s-e),h),b(this,Wn,Tp).call(this,e,s,r,o,t,i,a,l,3*(-t+3*(i-a)+l),6*(t-2*i+a),3*(i-t),h)}}Wn=new WeakSet,Cu=function(e,t,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const u=1-h,f=h*h,p=f*h,m=u*(u*(u*e+3*h*t)+3*f*s)+p*i,v=u*(u*(u*r+3*h*a)+3*f*o)+p*l;c[0]=Math.min(c[0],m),c[1]=Math.min(c[1],v),c[2]=Math.max(c[2],m),c[3]=Math.max(c[3],v)},Tp=function(e,t,s,i,r,a,o,l,h,c,u,f){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,Wn,Cu).call(this,e,t,s,i,r,a,o,l,-u/c,f);return}const p=c**2-4*u*h;if(p<0)return;const m=Math.sqrt(p),v=2*h;b(this,Wn,Cu).call(this,e,t,s,i,r,a,o,l,(-c+m)/v,f),b(this,Wn,Cu).call(this,e,t,s,i,r,a,o,l,(-c-m)/v,f)},y(H,Wn);function Hb(d){return decodeURIComponent(escape(d))}let vp=null,bm=null;function Zm(d){return vp||(vp=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,bm=new Map([["ſt","ſt"]])),d.replaceAll(vp,(e,t,s)=>t?t.normalize("NFKC"):bm.get(s))}function qg(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const d=new Uint8Array(32);return crypto.getRandomValues(d),Ub(d)}function $b(d,e,t){if(!Array.isArray(t)||t.length<2)return!1;const[s,i,...r]=t;if(!d(s)&&!Number.isInteger(s)||!e(i))return!1;const a=r.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}const Uh=()=>[],ep=()=>new Map,gf=()=>Object.create(null);typeof Blob.prototype.bytes!="function"&&(Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});typeof Response.prototype.bytes!="function"&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});lt(1701);function Ht(d,e,t){return Math.min(Math.max(d,e),t)}class fu{constructor({viewBox:e,userUnit:t,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=t,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=t;const l=(e[2]+e[0])/2,h=(e[3]+e[1])/2;let c,u,f,p;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,u=0,f=0,p=1;break;case 90:c=0,u=1,f=1,p=0;break;case 270:c=0,u=-1,f=-1,p=0;break;case 0:c=1,u=0,f=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(f=-f,p=-p);let m,v,A,w;c===0?(m=Math.abs(h-e[1])*s+r,v=Math.abs(l-e[0])*s+a,A=(e[3]-e[1])*s,w=(e[2]-e[0])*s):(m=Math.abs(l-e[0])*s+r,v=Math.abs(h-e[1])*s+a,A=(e[2]-e[0])*s,w=(e[3]-e[1])*s),this.transform=[c*s,u*s,f*s,p*s,m-c*s*l-f*s*h,v-u*s*l-p*s*h],this.width=A,this.height=w}get rawDims(){const e=this.viewBox;return st(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new fu({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){const s=[e,t];return H.applyTransform(s,this.transform),s}convertToPdfPoint(e,t){const s=[e,t];return H.applyInverseTransform(s,this.transform),s}}class bc{static textContent(e){const t=[],s={items:t,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(bc.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&t.push({str:a}),!!r.children)for(const h of r.children)i(h)}return i(e),s}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}class tm{static setupStorage(e,t,s,i,r){const a=i.getValue(t,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(e.textContent=a.value),r==="print")break;e.addEventListener("input",o=>{i.setValue(t,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?e.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&e.removeAttribute("checked"),r==="print")break;e.addEventListener("change",o=>{i.setValue(t,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&e.setAttribute("value",a.value),r==="print")break;e.addEventListener("input",o=>{i.setValue(t,{value:o.target.value})})}break;case"select":if(a.value!==null){e.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:Object.hasOwn(o.attributes,"selected")&&delete o.attributes.selected}e.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(t,{value:h})});break}}static setAttributes({html:e,element:t,storage:s=null,intent:i,linkService:r}){const{attributes:a}=t,o=e instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&e.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",h);break;case"style":Object.assign(e.style,h);break;case"textContent":e.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,h)}o&&r.addLinkAttributes(e,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(e,a.dataId,t,s)}static render(e){var u,f;const t=e.annotationStorage,s=e.linkService,i=e.xfaHtml,r=e.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=e.div;if(l.append(a),e.viewport){const p=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=p}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const p=document.createTextNode(i.value);a.append(p),o&&bc.shouldBuildText(i.name)&&h.push(p)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[p,m,v]=c.at(-1);if(m+1===p.children.length){c.pop();continue}const A=p.children[++c.at(-1)[1]];if(A===null)continue;const{name:w}=A;if(w==="#text"){const S=document.createTextNode(A.value);h.push(S),v.append(S);continue}const E=(u=A==null?void 0:A.attributes)!=null&&u.xmlns?document.createElementNS(A.attributes.xmlns,w):document.createElement(w);if(v.append(E),A.attributes&&this.setAttributes({html:E,element:A,storage:t,intent:r,linkService:s}),((f=A.children)==null?void 0:f.length)>0)c.push([A,-1,E]);else if(A.value){const S=document.createTextNode(A.value);o&&bc.shouldBuildText(w)&&h.push(S),E.append(S)}}for(const p of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.setAttribute("readOnly",!0);return{textDivs:h}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:s=0}){const{width:i,height:r}=e.attributes.style;return new fu({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:t,rotation:s})}}const da=class da{};P(da,"CSS",96),P(da,"PDF",72),P(da,"PDF_TO_CSS_UNITS",da.CSS/da.PDF);let Yn=da;async function sp(d,e="text"){if(fc(d,document.baseURI)){const t=await fetch(d);if(!t.ok)throw new Error(t.statusText);switch(e){case"blob":return t.blob();case"bytes":return t.bytes();case"json":return t.json()}return t.text()}return new Promise((t,s)=>{const i=new XMLHttpRequest;i.open("GET",d,!0),i.responseType=e==="bytes"?"arraybuffer":e,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(e){case"bytes":t(new Uint8Array(i.response));return;case"blob":case"json":t(i.response);return}t(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class ip extends Ko{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function pu(d){const e=d.length;let t=0;for(;t<e&&d[t].trim()==="";)t++;return d.substring(t,t+5).toLowerCase()==="data:"}function np(d){return typeof d=="string"&&/\.pdf$/i.test(d)}function qm(d){return[d]=d.split(/[#?]/,1),xp(d)}function tv(d,e="document.pdf"){if(typeof d!="string")return e;if(pu(d))return it('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const s=(o=>{try{return new URL(o)}catch{}try{return new URL(decodeURIComponent(o))}catch{}try{return new URL(o,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{}return null})(d);if(!s)return e;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")&&(l=xp(l),l.length===4&&r.test(l))?o:l}catch{return o}},r=/\.pdf$/i,a=xp(s.pathname);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=h=>[...h].findLast(c=>r.test(c)),l=o(s.searchParams.values())??o(s.searchParams.keys());if(l)return i(l)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return e}var tr;class Am{constructor(){y(this,tr,new Map);P(this,"times",[])}time(e){n(this,tr).has(e)&&it(`Timer is already running for ${e}`),n(this,tr).set(e,Date.now())}timeEnd(e){n(this,tr).has(e)||it(`Timer has not been started for ${e}`),this.times.push({name:e,start:n(this,tr).get(e),end:Date.now()}),n(this,tr).delete(e)}toString(){const e=Math.max(...this.times.map(t=>t.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms
|
|
4
|
+
`).join("")}}tr=new WeakMap;function fc(d,e){const t=e?URL.parse(d,e):URL.parse(d);return/https?:/.test((t==null?void 0:t.protocol)??"")}function Bs(d){d.preventDefault()}function Wt(d){d.preventDefault(),d.stopPropagation()}var Cc;class Ac{static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;n(this,Cc)||g(this,Cc,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?"));const t=n(this,Cc).exec(e);if(!t)return null;const s=parseInt(t[1],10);let i=parseInt(t[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;const h=t[7]||"Z";let c=parseInt(t[8],10);c=c>=0&&c<=23?c:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,h==="-"?(a+=c,o+=u):h==="+"&&(a-=c,o-=u),new Date(Date.UTC(s,i,r,a,o,l))}}Cc=new WeakMap,y(Ac,Cc);function Hh(d){if(d.startsWith("#")){const t=d.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(d.startsWith("rgb(")){const[t,s,i]=d.slice(4,-1).split(",").map(r=>parseInt(r,10));return[t,s,i,1]}if(d.startsWith("rgba(")){const t=d.slice(5,-1).split(",");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}const e=d.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return e?[Math.round(parseFloat(e[1])*255),Math.round(parseFloat(e[2])*255),Math.round(parseFloat(e[3])*255),e[4]!==void 0&&e[4]!=="none"?parseFloat(e[4]):1]:null}function $h(d){const e=Hh(d);return e?e.slice(0,3):(it(`Not a valid color format: "${d}"`),[0,0,0])}function jb(d){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const t of d.keys()){e.style.color=t;const s=window.getComputedStyle(e).color;d.set(t,$h(s))}e.remove()}function Ut(d){const{a:e,b:t,c:s,d:i,e:r,f:a}=d.getTransform();return[e,t,s,i,r,a]}function Si(d){const{a:e,b:t,c:s,d:i,e:r,f:a}=d.getTransform().invertSelf();return[e,t,s,i,r,a]}function ta(d,e,t=!1,s=!0){if(e instanceof fu){const{pageWidth:i,pageHeight:r}=e.rawDims,{style:a}=d,o=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,l=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;!t||e.rotation%180===0?(a.width=o,a.height=l):(a.width=l,a.height=o)}s&&d.setAttribute("data-main-rotation",e.rotation)}class Ei{constructor(){const{pixelRatio:e}=Ei;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,t,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=Ei.capPixels(s,r),s>0&&(a=Math.sqrt(s/(e*t))),i!==-1&&(o=i/e,l=i/t);const h=Math.min(a,o,l);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,s):s}return e}}const mf=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Gb{static get isDarkMode(){var e;return st(this,"isDarkMode",!!((e=window==null?void 0:window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches))}}class ev{static get commentForegroundColor(){const e=document.createElement("span");e.classList.add("comment","sidebar");const{style:t}=e;t.width=t.height="0",t.display="none",t.color="var(--comment-fg-color)",document.body.append(e);const{color:s}=window.getComputedStyle(e);return e.remove(),st(this,"commentForegroundColor",$h(s))}}function sv(d,e){e=Ht(e??1,0,1);const t=255*(1-e);return d.map(s=>Math.round(s*e+t))}function wm(d,e){const t=d[0]/255,s=d[1]/255,i=d[2]/255,r=Math.max(t,s,i),a=Math.min(t,s,i),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{const l=r-a;switch(e[1]=o<.5?l/(r+a):l/(2-r-a),r){case t:e[0]=((s-i)/l+(s<i?6:0))*60;break;case s:e[0]=((i-t)/l+2)*60;break;case i:e[0]=((t-s)/l+4)*60;break}}e[2]=o}function Cp(d,e){const t=d[0],s=d[1],i=d[2],r=(1-Math.abs(2*i-1))*s,a=r*(1-Math.abs(t/60%2-1)),o=i-r/2;switch(Math.floor(t/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o;break}}function Em(d){return d<=.03928?d/12.92:((d+.055)/1.055)**2.4}function Sm(d,e,t){Cp(d,t),t.map(Em);const s=.2126*t[0]+.7152*t[1]+.0722*t[2];Cp(e,t),t.map(Em);const i=.2126*t[0]+.7152*t[1]+.0722*t[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const xm=new Map;function iv(d,e){const t=d[0]+d[1]*256+d[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776;let s=xm.get(t);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),a=i.subarray(3,6);wm(d,a);const o=i.subarray(6,9);wm(e,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),Sm(a,o,r)<h){let c,u;l?(c=a[2],u=1):(c=0,u=a[2]);const f=.005;for(;u-c>f;){const p=a[2]=(c+u)/2;l===Sm(a,o,r)<h?c=p:u=p}a[2]=l?u:c}return Cp(a,r),s=H.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),xm.set(t,s),s}function em({html:d,dir:e,className:t},s){const i=document.createDocumentFragment();if(typeof d=="string"){const r=document.createElement("p");r.dir=e||"auto";const a=d.split(/\r\n?|\n/);for(let o=0,l=a.length;o<l;++o){const h=a[o];r.append(document.createTextNode(h)),o<l-1&&r.append(document.createElement("br"))}i.append(r)}else tm.render({xfaHtml:d,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",t),s.append(i)}function nv(d){const e=new Path2D;if(!d)return e;for(let t=0,s=d.length;t<s;)switch(d[t++]){case jh.moveTo:e.moveTo(d[t++],d[t++]);break;case jh.lineTo:e.lineTo(d[t++],d[t++]);break;case jh.curveTo:e.bezierCurveTo(d[t++],d[t++],d[t++],d[t++],d[t++],d[t++]);break;case jh.quadraticCurveTo:e.quadraticCurveTo(d[t++],d[t++],d[t++],d[t++]);break;case jh.closePath:e.closePath();break;default:it(`Unrecognized drawing path operator: ${d[t-1]}`);break}return e}lt(4972);lt(4628);lt(7642);lt(8004);lt(3853);lt(5876);lt(2475);lt(5024);lt(1698);lt(8454);lt(9452);lt(4979);lt(3579);lt(3110);lt(9314);lt(1148);lt(116);lt(9112);var er,sr,$s,js,Ic,ir,ol,ll,Pc,Cf,rv,Le,av,ov,qo,zh;const nn=class nn{constructor(e){y(this,Le);y(this,er,null);y(this,sr,null);y(this,$s);y(this,js,null);y(this,Ic,null);y(this,ir,null);y(this,ol,null);y(this,ll,null);g(this,$s,e),n(nn,Pc)||g(nn,Pc,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=g(this,er,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const t=n(this,$s)._uiManager._signal;t instanceof AbortSignal&&!t.aborted&&(e.addEventListener("contextmenu",Bs,{signal:t}),e.addEventListener("pointerdown",b(nn,Cf,rv),{signal:t}));const s=g(this,js,document.createElement("div"));s.className="buttons",e.append(s);const i=n(this,$s).toolbarPosition;if(i){const{style:r}=e,a=n(this,$s)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return n(this,er)}hide(){var e;n(this,er).classList.add("hidden"),(e=n(this,sr))==null||e.hideDropdown()}show(){var e,t;n(this,er).classList.remove("hidden"),(e=n(this,Ic))==null||e.shown(),(t=n(this,ir))==null||t.shown()}addDeleteButton(){const{editorType:e,_uiManager:t}=n(this,$s),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(nn,Pc)[e]),b(this,Le,qo).call(this,s)&&s.addEventListener("click",i=>{t.delete()},{signal:t._signal}),n(this,js).append(s)}async addAltText(e){const t=await e.render();b(this,Le,qo).call(this,t),n(this,js).append(t,n(this,Le,zh)),g(this,Ic,e)}addComment(e,t=null){if(n(this,ir))return;const s=e.renderForToolbar();if(!s)return;b(this,Le,qo).call(this,s);const i=g(this,ol,n(this,Le,zh));t?(n(this,js).insertBefore(s,t),n(this,js).insertBefore(i,t)):n(this,js).append(s,i),g(this,ir,e),e.toolbar=this}addColorPicker(e){if(n(this,sr))return;g(this,sr,e);const t=e.renderButton();b(this,Le,qo).call(this,t),n(this,js).append(t,n(this,Le,zh))}async addEditSignatureButton(e){const t=g(this,ll,await e.renderEditButton(n(this,$s)));b(this,Le,qo).call(this,t),n(this,js).append(t,n(this,Le,zh))}removeButton(e){var t,s;switch(e){case"comment":(t=n(this,ir))==null||t.removeToolbarCommentButton(),g(this,ir,null),(s=n(this,ol))==null||s.remove(),g(this,ol,null);break}}async addButton(e,t){switch(e){case"colorPicker":t&&this.addColorPicker(t);break;case"altText":t&&await this.addAltText(t);break;case"editSignature":t&&await this.addEditSignatureButton(t);break;case"delete":this.addDeleteButton();break;case"comment":t&&this.addComment(t);break}}async addButtonBefore(e,t,s){if(!t&&e==="comment")return;const i=n(this,js).querySelector(s);i&&e==="comment"&&this.addComment(t,i)}updateEditSignatureButton(e){n(this,ll)&&(n(this,ll).title=e)}remove(){var e;n(this,er).remove(),(e=n(this,sr))==null||e.destroy(),g(this,sr,null)}};er=new WeakMap,sr=new WeakMap,$s=new WeakMap,js=new WeakMap,Ic=new WeakMap,ir=new WeakMap,ol=new WeakMap,ll=new WeakMap,Pc=new WeakMap,Cf=new WeakSet,rv=function(e){e.stopPropagation()},Le=new WeakSet,av=function(e){n(this,$s)._focusEventsAllowed=!1,Wt(e)},ov=function(e){n(this,$s)._focusEventsAllowed=!0,Wt(e)},qo=function(e){const t=n(this,$s)._uiManager._signal;return!(t instanceof AbortSignal)||t.aborted?!1:(e.addEventListener("focusin",b(this,Le,av).bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",b(this,Le,ov).bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",Bs,{signal:t}),!0)},zh=function(){const e=document.createElement("div");return e.className="divider",e},y(nn,Cf),y(nn,Pc,null);let Ip=nn;var Mc,ga,an,Kn,lv,hv,Pp;class _b{constructor(e){y(this,Kn);y(this,Mc,null);y(this,ga,null);y(this,an);g(this,an,e)}show(e,t,s){const[i,r]=b(this,Kn,hv).call(this,t,s),{style:a}=n(this,ga)||g(this,ga,b(this,Kn,lv).call(this));e.append(n(this,ga)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,ga).remove()}}Mc=new WeakMap,ga=new WeakMap,an=new WeakMap,Kn=new WeakSet,lv=function(){const e=g(this,ga,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar");const t=n(this,an)._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener("contextmenu",Bs,{signal:t});const s=g(this,Mc,document.createElement("div"));return s.className="buttons",e.append(s),n(this,an).hasCommentManager()&&b(this,Kn,Pp).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,an).commentSelection("floating_button")}),b(this,Kn,Pp).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,an).highlightSelection("floating_button")}),e},hv=function(e,t){let s=0,i=0;for(const r of e){const a=r.y+r.height;if(a<s)continue;const o=r.x+(t?r.width:0);if(a>s){i=o,s=a;continue}t?o>i&&(i=o):o<i&&(i=o)}return[t?1-i:i,s]},Pp=function(e,t,s,i){const r=document.createElement("button");r.classList.add("basic",e),r.tabIndex=0,r.setAttribute("data-l10n-id",t);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=n(this,an)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",Bs,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,Mc).append(r)};const zb="068f09d6-5b37-4f77-a97a-f8ff4f253b68",yp=Object.freeze({internal:zb});function cv(d,e,t){for(const s of t)e.addEventListener(s,d[s].bind(d))}var ma,va,hl,ya;const Mt=class Mt{static initializeAndAddPointerId(e){(n(Mt,va)||g(Mt,va,new Set)).add(e)}static setPointer(e,t){n(Mt,ma)||g(Mt,ma,t),n(Mt,ya)??g(Mt,ya,e)}static setTimeStamp(e){g(Mt,hl,e)}static isSamePointerId(e){return n(Mt,ma)===e}static isSamePointerIdOrRemove(e){var t;return n(Mt,ma)===e?!0:((t=n(Mt,va))==null||t.delete(e),!1)}static isSamePointerType(e){return n(Mt,ya)===e}static isInitializedAndDifferentPointerType(e){return n(Mt,ya)!==null&&!Mt.isSamePointerType(e)}static isSameTimeStamp(e){return n(Mt,hl)===e}static isUsingMultiplePointers(){var e;return((e=n(Mt,va))==null?void 0:e.size)>=1}static clearPointerType(){g(Mt,ya,null)}static clearPointerIds(){g(Mt,ma,NaN),g(Mt,va,null)}static clearTimeStamp(){g(Mt,hl,NaN)}};ma=new WeakMap,va=new WeakMap,hl=new WeakMap,ya=new WeakMap,y(Mt,ma,NaN),y(Mt,va,null),y(Mt,hl,NaN),y(Mt,ya,null);let Be=Mt;var If;class Wb{constructor(){y(this,If,0)}get id(){return`${vc}${$t(this,If)._++}`}}If=new WeakMap;var cl,Oc,Ue,dl,Iu;const hm=class hm{constructor(){y(this,dl);y(this,cl,qg());y(this,Oc,0);y(this,Ue,null)}static get _isSVGFittingCanvas(){const e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${ps}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return st(this,"_isSVGFittingCanvas",r)}async getFromFile(e){const{lastModified:t,name:s,size:i,type:r}=e;return b(this,dl,Iu).call(this,`${t}_${s}_${i}_${r}`,e)}async getFromUrl(e){return b(this,dl,Iu).call(this,e,e)}async getFromBlob(e,t){const s=await t;return b(this,dl,Iu).call(this,e,s)}async getFromId(e){n(this,Ue)||g(this,Ue,new Map);const t=n(this,Ue).get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:s}=t;return delete t.blobPromise,this.getFromBlob(t.id,s)}return this.getFromUrl(t.url)}getFromCanvas(e,t){n(this,Ue)||g(this,Ue,new Map);let s=n(this,Ue).get(e);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(t.width,t.height);return i.getContext("2d").drawImage(t,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,cl)}_${$t(this,Oc)._++}`,refCounter:1,isSvg:!1},n(this,Ue).set(e,s),n(this,Ue).set(s.id,s),s}getSvgUrl(e){const t=n(this,Ue).get(e);return t!=null&&t.isSvg?t.svgUrl:null}deleteId(e){var i;n(this,Ue)||g(this,Ue,new Map);const t=n(this,Ue).get(e);if(!t||(t.refCounter-=1,t.refCounter!==0))return;const{bitmap:s}=t;if(!t.url&&!t.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),t.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),t.bitmap=null}isValidId(e){return e.startsWith(`image_${n(this,cl)}_`)}};cl=new WeakMap,Oc=new WeakMap,Ue=new WeakMap,dl=new WeakSet,Iu=async function(e,t){n(this,Ue)||g(this,Ue,new Map);let s=n(this,Ue).get(e);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,cl)}_${$t(this,Oc)._++}`,refCounter:0,isSvg:!1});let i;if(typeof t=="string"?(s.url=t,i=await sp(t,"blob")):t instanceof File?i=s.file=t:t instanceof Blob&&(i=t),i.type==="image/svg+xml"){const r=hm._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const u=s.svgUrl=a.result;o.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=c});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){it(i),s=null}return n(this,Ue).set(e,s),s&&n(this,Ue).set(s.id,s),s};let Mp=hm;var se,nr,Rc,Yt;class Vb{constructor(e=128){y(this,se,[]);y(this,nr,!1);y(this,Rc);y(this,Yt,-1);g(this,Rc,e)}add({cmd:e,undo:t,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&e(),n(this,nr))return;const l={cmd:e,undo:t,post:s,type:r};if(n(this,Yt)===-1){n(this,se).length>0&&(n(this,se).length=0),g(this,Yt,0),n(this,se).push(l);return}if(a&&n(this,se)[n(this,Yt)].type===r){o&&(l.undo=n(this,se)[n(this,Yt)].undo),n(this,se)[n(this,Yt)]=l;return}const h=n(this,Yt)+1;h===n(this,Rc)?n(this,se).splice(0,1):(g(this,Yt,h),h<n(this,se).length&&n(this,se).splice(h)),n(this,se).push(l)}undo(){if(n(this,Yt)===-1)return;g(this,nr,!0);const{undo:e,post:t}=n(this,se)[n(this,Yt)];e(),t==null||t(),g(this,nr,!1),g(this,Yt,n(this,Yt)-1)}redo(){if(n(this,Yt)<n(this,se).length-1){g(this,Yt,n(this,Yt)+1),g(this,nr,!0);const{cmd:e,post:t}=n(this,se)[n(this,Yt)];e(),t==null||t(),g(this,nr,!1)}}hasSomethingToUndo(){return n(this,Yt)!==-1}hasSomethingToRedo(){return n(this,Yt)<n(this,se).length-1}cleanType(e){if(n(this,Yt)!==-1){for(let t=n(this,Yt);t>=0;t--)if(n(this,se)[t].type!==e){n(this,se).splice(t+1,n(this,Yt)-t),g(this,Yt,t);return}n(this,se).length=0,g(this,Yt,-1)}}destroy(){g(this,se,null)}}se=new WeakMap,nr=new WeakMap,Rc=new WeakMap,Yt=new WeakMap;var Nh,dv,uv;const is=class is{constructor(e){var s;this.callbacks=new Map;const{isMac:t}=It.platform;for(const[i,r,a={}]of e){const o=i.some(l=>l.startsWith("mac+"));for(const l of i){let h=l;if(o){const f=l.startsWith("mac+");if(t!==f)continue;f&&(h=l.slice(4))}const[c,u]=b(s=is,Nh,dv).call(s,h);c!==null&&this.callbacks.getOrInsertComputed(c,Uh).push({callback:r,options:a,modifiers:u})}}}exec(e,t){var c;let s=this.callbacks.get(t.key);if(!s){if(/^[a-z]$/i.test(t.key))return;const u=b(c=is,Nh,uv).call(c,t.code);if(u===null||u===t.key||(s=this.callbacks.get(u),!s))return}const i=(t.altKey?is.ALT:0)|(t.ctrlKey?is.CTRL:0)|(t.metaKey?is.META:0)|(t.shiftKey?is.SHIFT:0),r=s.find(u=>u.modifiers===i);if(!r)return;const{callback:a,options:{bubbles:o=!1,args:l=[],checker:h=null}}=r;h&&!h(e,t)||(a.bind(e,...l,t)(),o||Wt(t))}};Nh=new WeakSet,dv=function(e){let t=null,s=0;for(let i of e.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),a=is[r];if(a){s|=a;continue}if(t!==null){it(`KeyboardManager: multiple keys in shortcut "${e}"`);break}t=r==="SPACE"?" ":i}return t===null&&it(`KeyboardManager: no key found in shortcut "${e}"`),[t,s]},uv=function(e){var s;const t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return t?((s=t[1])==null?void 0:s.toLowerCase())??t[2]:null},y(is,Nh),P(is,"ALT",1),P(is,"CTRL",2),P(is,"META",4),P(is,"SHIFT",8);let Vo=is;const Pf=class Pf{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return jb(e),st(this,"_colors",e)}convert(e){const t=$h(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[s,i]of this._colors)if(i.every((r,a)=>r===t[a]))return Pf._colorsMapping.get(s);return t}getHexCode(e){const t=this._colors.get(e);return t?H.makeHexColor(...t):e}};P(Pf,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Op=Pf;var ul,gs,fl,Zt,Kt,pl,gl,Ve,ml,Gs,me,rr,ar,or,lr,Ci,_s,ba,Dc,kc,vl,Lc,Ii,hr,yl,cr,Pi,Mf,on,bl,Fc,dr,Aa,Al,ur,Nc,le,Ot,ln,fr,pr,Bc,wl,Uc,gr,Mi,hn,Hc,$c,zs,_,Pu,Rp,fv,pv,gv,Wh,mv,vv,yv,Dp,bv,Av,wv,Ev,ze,en,Sv,xv,kp,Tv,Vh,Lp;const nl=class nl{constructor(e,t,s,i,r,a,o,l,h,c,u,f,p,m,v,A){y(this,_);y(this,ul,new AbortController);y(this,gs,null);y(this,fl,null);y(this,Zt,new Map);y(this,Kt,new Map);y(this,pl,null);y(this,gl,null);y(this,Ve,null);y(this,ml,null);y(this,Gs,new Vb);y(this,me,null);y(this,rr,null);y(this,ar,null);y(this,or,0);y(this,lr,new Set);y(this,Ci,null);y(this,_s,null);y(this,ba,new Set);P(this,"_editorUndoBar",null);y(this,Dc,!1);y(this,kc,!1);y(this,vl,!1);y(this,Lc,null);y(this,Ii,null);y(this,hr,null);y(this,yl,null);y(this,cr,!1);y(this,Pi,null);y(this,Mf,new Wb);y(this,on,!1);y(this,bl,!1);y(this,Fc,!1);y(this,dr,null);y(this,Aa,null);y(this,Al,null);y(this,ur,null);y(this,Nc,null);y(this,le,nt.NONE);y(this,Ot,new Set);y(this,ln,null);y(this,fr,null);y(this,pr,null);y(this,Bc,null);y(this,wl,null);y(this,Uc,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});y(this,gr,[0,0]);y(this,Mi,null);y(this,hn,null);y(this,Hc,null);y(this,$c,null);y(this,zs,null);const w=this._signal=n(this,ul).signal;g(this,hn,e),g(this,Hc,t),g(this,$c,s),g(this,gl,i),g(this,me,r),g(this,fr,a),g(this,wl,l),this._eventBus=o;const E={signal:w,...yp};o.on("editingaction",this.onEditingAction.bind(this),E),o.on("pagechanging",this.onPageChanging.bind(this),E),o.on("scalechanging",this.onScaleChanging.bind(this),E),o.on("rotationchanging",this.onRotationChanging.bind(this),E),o.on("setpreference",this.onSetPreference.bind(this),E),o.on("switchannotationeditorparams",S=>this.updateParams(S.type,S.value),E),window.addEventListener("pointerdown",()=>{g(this,bl,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{g(this,bl,!1)},{capture:!0,signal:w}),window.addEventListener("beforeunload",b(this,_,fv).bind(this),{capture:!0,signal:w}),b(this,_,mv).call(this),b(this,_,Ev).call(this),b(this,_,Dp).call(this),g(this,Ve,l.annotationStorage),g(this,Lc,l.filterFactory),g(this,pr,h),g(this,yl,c||null),g(this,Dc,u),g(this,kc,f),g(this,vl,p),g(this,Nc,m||null),this.viewParameters={realScale:Yn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=v||null,this._supportsPinchToZoom=A!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const e=nl.prototype,t=a=>n(a,hn).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return st(this,"_keyboardManager",new Vo([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter"],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,hn).contains(o)&&!a.isEnterHandled}],[["Space"],e.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,hn).contains(document.activeElement)}],[["Escape"],e.unselectAll],[["ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}]]))}destroy(){var e,t,s,i,r,a,o,l,h;(e=n(this,zs))==null||e.resolve(),g(this,zs,null),(t=n(this,ul))==null||t.abort(),g(this,ul,null),this._signal=null;for(const c of n(this,Kt).values())c.destroy();n(this,Kt).clear(),n(this,Zt).clear(),n(this,ba).clear(),(s=n(this,ur))==null||s.clear(),g(this,gs,null),n(this,Ot).clear(),n(this,Gs).destroy(),(i=n(this,gl))==null||i.destroy(),(r=n(this,me))==null||r.destroy(),(a=n(this,fr))==null||a.destroy(),(o=n(this,Pi))==null||o.hide(),g(this,Pi,null),(l=n(this,Al))==null||l.destroy(),g(this,Al,null),g(this,fl,null),n(this,Ii)&&(clearTimeout(n(this,Ii)),g(this,Ii,null)),n(this,Mi)&&(clearTimeout(n(this,Mi)),g(this,Mi,null)),(h=this._editorUndoBar)==null||h.destroy(),g(this,wl,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return n(this,Nc)}get useNewAltTextFlow(){return n(this,kc)}get useNewAltTextWhenAddingImage(){return n(this,vl)}get hcmFilter(){return st(this,"hcmFilter",n(this,pr)?n(this,Lc).addHCMFilter(n(this,pr).foreground,n(this,pr).background):"none")}get direction(){return st(this,"direction",getComputedStyle(n(this,hn)).direction)}get _highlightColors(){return st(this,"_highlightColors",n(this,yl)?new Map(n(this,yl).split(",").map(e=>(e=e.split("=").map(t=>t.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return st(this,"highlightColors",null);const t=new Map,s=!!n(this,pr);for(const[i,r]of e){const a=i.endsWith("_HCM");if(s&&a){t.set(i.replace("_HCM",""),r);continue}!s&&!a&&t.set(i,r)}return st(this,"highlightColors",t)}get highlightColorNames(){return st(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),g(this,ar,e)}setMainHighlightColorPicker(e){g(this,Al,e)}editAltText(e,t=!1){var s;(s=n(this,gl))==null||s.editAltText(this,e,t)}hasCommentManager(){return!!n(this,me)}editComment(e,t,s,i){var r;(r=n(this,me))==null||r.showDialog(this,e,t,s,i)}selectComment(e,t){const s=n(this,Kt).get(e),i=s==null?void 0:s.getEditorByUID(t);i==null||i.toggleComment(!0,!0)}updateComment(e){var t;(t=n(this,me))==null||t.updateComment(e.getData())}updatePopupColor(e){var t;(t=n(this,me))==null||t.updatePopupColor(e)}removeComment(e){var t;(t=n(this,me))==null||t.removeComments([e.uid])}deleteComment(e,t){const s=()=>{e.comment=t},i=()=>{var r;(r=this._editorUndoBar)==null||r.show(s,"comment"),this.toggleComment(null),e.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(e,t,s=void 0){var i;(i=n(this,me))==null||i.toggleCommentPopup(e,t,s)}makeCommentColor(e,t){var s;return e&&((s=n(this,me))==null?void 0:s.makeCommentColor(e,t))||null}getCommentDialogElement(){var e;return((e=n(this,me))==null?void 0:e.dialogElement)||null}async waitForEditorsRendered(e){if(n(this,Kt).has(e-1))return;const{resolve:t,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===e&&(this._eventBus.off("editorsrendered",i),t())};this._eventBus.on("editorsrendered",i,yp),await s}getSignature(e){var t;(t=n(this,fr))==null||t.getSignature({uiManager:this,editor:e})}get signatureManager(){return n(this,fr)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal,...yp}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){switch(e){case"enableNewAltTextWhenAddingImage":g(this,vl,t);break}}onPageChanging({pageNumber:e}){g(this,or,e-1)}deletePage(e){for(const t of this.getEditors(e))t.remove();n(this,Kt).delete(e),n(this,or)===e&&g(this,or,0)}focusMainContainer(){n(this,hn).focus()}findParent(e,t){for(const s of n(this,Kt).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(e>=i&&e<=i+a&&t>=r&&t<=r+o)return s}return null}disableUserSelect(e=!1){n(this,Hc).classList.toggle("noUserSelect",e)}addShouldRescale(e){n(this,ba).add(e)}removeShouldRescale(e){n(this,ba).delete(e)}onScaleChanging({scale:e}){var t;this.commitOrRemove(),this.viewParameters.realScale=e*Yn.PDF_TO_CSS_UNITS;for(const s of n(this,ba))s.onScaleChanging();(t=n(this,ar))==null||t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e="",t=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,_,Pu).call(this,s).closest(".textLayer"),u=this.getSelectionBoxes(c);if(!u)return;s.empty();const f=b(this,_,Rp).call(this,c),p=n(this,le)===nt.NONE,m=()=>{const v=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:u,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});p&&this.showAllEditors("highlight",!0,!0),t&&(v==null||v.editComment())};if(p){this.switchToMode(nt.HIGHLIGHT,m);return}m()}commentSelection(e=""){this.highlightSelection(e,!0)}getAndRemoveDataFromAnnotationStorage(e){if(!n(this,Ve))return null;const t=`${vc}${e}`,s=n(this,Ve).getRawValue(t);return s&&n(this,Ve).remove(t),s}addToAnnotationStorage(e){!e.isEmpty()&&n(this,Ve)&&!n(this,Ve).has(e.id)&&n(this,Ve).setValue(e.id,e)}a11yAlert(e,t=null){const s=n(this,$c);s&&(s.setAttribute("data-l10n-id",e),t?s.setAttribute("data-l10n-args",JSON.stringify(t)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,n(this,cr)&&(g(this,cr,!1),b(this,_,Wh).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of n(this,Ot))if(t.div.contains(e)){g(this,Aa,[t,e]),t._focusEventsAllowed=!1;break}}focus(){if(!n(this,Aa))return;const[e,t]=n(this,Aa);g(this,Aa,null),t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}addEditListeners(){b(this,_,Dp).call(this),this.setEditingState(!0)}removeEditListeners(){b(this,_,bv).call(this),this.setEditingState(!1)}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const s of n(this,_s))if(s.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const t of e.dataTransfer.items)for(const s of n(this,_s))if(s.isHandlingMimeForPasting(t.type)){s.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){var s;if(e.preventDefault(),(s=n(this,gs))==null||s.commitOrRemove(),!this.hasSelection)return;const t=[];for(const i of n(this,Ot)){const r=i.serialize(!0);r&&t.push(r)}t.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const r of t.items)for(const a of n(this,_s))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=t.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){it(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const h=await i.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)b(this,_,kp).call(this,l);b(this,_,Lp).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){it(`paste: "${r.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,le)!==nt.NONE&&!this.isEditorHandlingKeyboard&&nl._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,cr)&&(g(this,cr,!1),b(this,_,Wh).call(this,"main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}updatePageIndex(e,t){for(const i of this.getEditors(e))i.pageIndex=t;const s=n(this,pl).get(e);s&&(s.pageIndex=t,n(this,Kt).set(t,s),n(this,on)?s.enable():s.disable())}startUpdatePages(){g(this,pl,new Map(n(this,Kt))),n(this,Kt).clear()}endUpdatePages(){g(this,pl,null)}clonePage(e,t){for(const s of this.getEditors(e)){const i=s.serialize(s.mode!==nt.HIGHLIGHT);i&&(i.pageIndex=t,i.id=this.getId(),i.isClone=!0,delete i.popupRef,n(this,Ve).setValue(i.id,i))}}findClonesForPage(e){const t=[],{pageIndex:s}=e;for(const[i,r]of n(this,Ve))r.pageIndex===s&&r.isClone&&(n(this,Ve).remove(i),t.push(e.deserialize(r).then(a=>{a&&(a.isClone=!0,e.addOrRebuild(a))})));return Promise.all(t)}setEditingState(e){e?(b(this,_,vv).call(this),b(this,_,Av).call(this),b(this,_,ze).call(this,{isEditing:n(this,le)!==nt.NONE,isEmpty:b(this,_,Vh).call(this),hasSomethingToUndo:n(this,Gs).hasSomethingToUndo(),hasSomethingToRedo:n(this,Gs).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,_,yv).call(this),b(this,_,wv).call(this),b(this,_,ze).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!n(this,_s)){g(this,_s,e);for(const t of n(this,_s))b(this,_,en).call(this,t.defaultPropertiesToUpdate)}}getId(){return n(this,Mf).id}get currentLayer(){return n(this,Kt).get(n(this,or))}getLayer(e){return n(this,Kt).get(e)}get currentPageIndex(){return n(this,or)}addLayer(e){n(this,Kt).set(e.pageIndex,e),n(this,on)?e.enable():e.disable()}removeLayer(e){n(this,Kt).delete(e.pageIndex)}async updateMode(e,t=null,s=!1,i=!1,r=!1,a=!1){var o,l,h,c,u,f;if(n(this,le)!==e&&!(n(this,zs)&&(await n(this,zs).promise,!n(this,zs)))){if(g(this,zs,Promise.withResolvers()),(o=n(this,ar))==null||o.commitOrRemove(),n(this,le)===nt.POPUP&&((l=n(this,me))==null||l.hideSidebar()),(h=n(this,me))==null||h.destroyPopup(),g(this,le,e),e===nt.NONE){this.setEditingState(!1),b(this,_,xv).call(this);for(const p of n(this,Zt).values())p.hideStandaloneCommentButton();(c=this._editorUndoBar)==null||c.hide(),this.toggleComment(null),n(this,zs).resolve();return}for(const p of n(this,Zt).values())p.addStandaloneCommentButton();e===nt.SIGNATURE&&await((u=n(this,fr))==null?void 0:u.loadSignatures()),s&&Be.clearPointerType(),this.setEditingState(!0),await b(this,_,Sv).call(this),this.unselectAll();for(const p of n(this,Kt).values())p.updateMode(e);if(e===nt.POPUP){n(this,fl)||g(this,fl,await n(this,wl).getAnnotationsByType(new Set(n(this,_s).map(v=>v._editorType))));const p=new Set,m=[];for(const v of n(this,Zt).values()){const{annotationElementId:A,hasComment:w,deleted:E}=v;A&&p.add(A),w&&!E&&m.push(v.getData())}for(const v of n(this,fl)){const{id:A,popupRef:w,contentsObj:E}=v;w&&(E!=null&&E.str)&&!p.has(A)&&!n(this,lr).has(A)&&m.push(v)}(f=n(this,me))==null||f.showSidebar(m)}if(!t){i&&this.addNewEditorFromKeyboard(),n(this,zs).resolve();return}for(const p of n(this,Zt).values())p.uid===t?(this.setSelected(p),a?p.editComment():r?p.enterInEditMode():p.focus()):p.unselect();n(this,zs).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==n(this,le)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,t){if(n(this,_s)){switch(e){case at.CREATE:this.currentLayer.addNewEditor(t);return;case at.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,Bc)||g(this,Bc,new Map)).set(e,t),this.showAllEditors("highlight",t);break}if(this.hasSelection)for(const s of n(this,Ot))s.updateParams(e,t);else for(const s of n(this,_s))s.updateDefaultParams(e,t)}}showAllEditors(e,t,s=!1){var r;for(const a of n(this,Zt).values())a.editorType===e&&a.show(t);(((r=n(this,Bc))==null?void 0:r.get(at.HIGHLIGHT_SHOW_ALL))??!0)!==t&&b(this,_,en).call(this,[[at.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(n(this,Fc)!==e){g(this,Fc,e);for(const t of n(this,Kt).values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}*getEditors(e){for(const t of n(this,Zt).values())t.pageIndex===e&&(yield t)}getEditor(e){return n(this,Zt).get(e)}addEditor(e){n(this,Zt).set(e.id,e)}removeEditor(e){var t,s;e.div.contains(document.activeElement)&&(n(this,Ii)&&clearTimeout(n(this,Ii)),g(this,Ii,setTimeout(()=>{this.focusMainContainer(),g(this,Ii,null)},0))),n(this,Zt).delete(e.id),e.annotationElementId&&((t=n(this,ur))==null||t.delete(e.annotationElementId)),this.unselect(e),(!e.annotationElementId||!n(this,lr).has(e.annotationElementId))&&((s=n(this,Ve))==null||s.remove(e.id))}addDeletedAnnotationElement(e){n(this,lr).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return n(this,lr).has(e)}removeDeletedAnnotationElement(e){n(this,lr).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){n(this,gs)!==e&&(g(this,gs,e),e&&b(this,_,en).call(this,e.propertiesToUpdate))}updateUI(e){n(this,_,Tv)===e&&b(this,_,en).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){b(this,_,en).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(n(this,Ot).has(e)){n(this,Ot).delete(e),e.unselect(),b(this,_,ze).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,Ot).add(e),e.select(),b(this,_,en).call(this,e.propertiesToUpdate),b(this,_,ze).call(this,{hasSelectedEditor:!0})}setSelected(e){var t,s;this.updateToolbar({mode:e.mode,editId:e.uid}),(t=n(this,ar))==null||t.commitOrRemove();for(const i of n(this,Ot))i!==e&&i.unselect();(s=n(this,me))==null||s.destroyPopup(),n(this,Ot).clear(),n(this,Ot).add(e),e.select(),b(this,_,en).call(this,e.propertiesToUpdate),b(this,_,ze).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return n(this,Ot).values().next().value}unselect(e){e.unselect(),n(this,Ot).delete(e),b(this,_,ze).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,Ot).size!==0}get isEnterHandled(){return n(this,Ot).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;n(this,Gs).undo(),b(this,_,ze).call(this,{hasSomethingToUndo:n(this,Gs).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,_,Vh).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){n(this,Gs).redo(),b(this,_,ze).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,Gs).hasSomethingToRedo(),isEmpty:b(this,_,Vh).call(this)})}addCommands(e){n(this,Gs).add(e),b(this,_,ze).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,_,Vh).call(this)})}cleanUndoStack(e){n(this,Gs).cleanType(e)}delete(){var r;this.commitOrRemove();const e=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...n(this,Ot)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,t.length===1?t[0].editorType:t.length);for(const o of t)o.remove()},i=()=>{for(const a of t)b(this,_,kp).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var e;(e=n(this,gs))==null||e.commitOrRemove()}hasSomethingToControl(){return n(this,gs)||this.hasSelection}selectAll(){for(const e of n(this,Ot))e.commit();b(this,_,Lp).call(this,n(this,Zt).values())}unselectAll(){var e,t;if(!(n(this,gs)&&(n(this,gs).commitOrRemove(),n(this,le)!==nt.NONE))&&!((e=n(this,ar))!=null&&e.commitOrRemove())&&((t=n(this,me))==null||t.destroyPopup(),!!this.hasSelection)){for(const s of n(this,Ot))s.unselect();n(this,Ot).clear(),b(this,_,ze).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,t,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,gr)[0]+=e,n(this,gr)[1]+=t;const[i,r]=n(this,gr),a=[...n(this,Ot)],o=1e3;n(this,Mi)&&clearTimeout(n(this,Mi)),g(this,Mi,setTimeout(()=>{g(this,Mi,null),n(this,gr)[0]=n(this,gr)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,Zt).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,Zt).has(l.id)&&(l.translateInPage(-i,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(e,t),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),g(this,Ci,new Map);for(const e of n(this,Ot))n(this,Ci).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,Ci))return!1;this.disableUserSelect(!1);const e=n(this,Ci);g(this,Ci,null);let t=!1;for(const[{x:i,y:r,pageIndex:a},o]of e)o.newX=i,o.newY=r,o.newPageIndex=a,t||(t=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!t)return!1;const s=(i,r,a,o)=>{if(n(this,Zt).has(i.id)){const l=n(this,Kt).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of e)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of e)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(n(this,Ci))for(const s of n(this,Ci).keys())s.drag(e,t)}rebuild(e){if(e.parent===null){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||n(this,Ot).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return n(this,gs)===e}getActive(){return n(this,gs)}getMode(){return n(this,le)}isEditingMode(){return n(this,le)!==nt.NONE}get imageManager(){return st(this,"imageManager",new Mp)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let h=0,c=t.rangeCount;h<c;h++)if(!e.contains(t.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:a}=e.getBoundingClientRect();let o;switch(e.getAttribute("data-main-rotation")){case"90":o=(h,c,u,f)=>({x:(c-i)/a,y:1-(h+u-s)/r,width:f/a,height:u/r});break;case"180":o=(h,c,u,f)=>({x:1-(h+u-s)/r,y:1-(c+f-i)/a,width:u/r,height:f/a});break;case"270":o=(h,c,u,f)=>({x:1-(c+f-i)/a,y:(h-s)/r,width:f/a,height:u/r});break;default:o=(h,c,u,f)=>({x:(h-s)/r,y:(c-i)/a,width:u/r,height:f/a});break}const l=[];for(let h=0,c=t.rangeCount;h<c;h++){const u=t.getRangeAt(h);if(!u.collapsed)for(const{x:f,y:p,width:m,height:v}of u.getClientRects())m===0||v===0||l.push(o(f,p,m,v))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:t}){(n(this,ml)||g(this,ml,new Map)).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){var t;(t=n(this,ml))==null||t.delete(e)}renderAnnotationElement(e){var i;const t=(i=n(this,ml))==null?void 0:i.get(e.data.id);if(!t)return;const s=n(this,Ve).getRawValue(t);s&&(n(this,le)===nt.NONE&&!s.hasBeenModified||s.renderAnnotationElement(e))}setMissingCanvas(e,t,s){var r;const i=(r=n(this,ur))==null?void 0:r.get(e);i&&(i.setCanvas(t,s),n(this,ur).delete(e))}addMissingCanvas(e,t){(n(this,ur)||g(this,ur,new Map)).set(e,t)}};ul=new WeakMap,gs=new WeakMap,fl=new WeakMap,Zt=new WeakMap,Kt=new WeakMap,pl=new WeakMap,gl=new WeakMap,Ve=new WeakMap,ml=new WeakMap,Gs=new WeakMap,me=new WeakMap,rr=new WeakMap,ar=new WeakMap,or=new WeakMap,lr=new WeakMap,Ci=new WeakMap,_s=new WeakMap,ba=new WeakMap,Dc=new WeakMap,kc=new WeakMap,vl=new WeakMap,Lc=new WeakMap,Ii=new WeakMap,hr=new WeakMap,yl=new WeakMap,cr=new WeakMap,Pi=new WeakMap,Mf=new WeakMap,on=new WeakMap,bl=new WeakMap,Fc=new WeakMap,dr=new WeakMap,Aa=new WeakMap,Al=new WeakMap,ur=new WeakMap,Nc=new WeakMap,le=new WeakMap,Ot=new WeakMap,ln=new WeakMap,fr=new WeakMap,pr=new WeakMap,Bc=new WeakMap,wl=new WeakMap,Uc=new WeakMap,gr=new WeakMap,Mi=new WeakMap,hn=new WeakMap,Hc=new WeakMap,$c=new WeakMap,zs=new WeakMap,_=new WeakSet,Pu=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},Rp=function(e){const{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(const s of n(this,Kt).values())if(s.hasTextLayer(e))return s;return null},fv=function(e){var t;this.commitOrRemove(),(t=this.currentLayer)==null||t.endDrawingSession(!1)},pv=function(){const e=document.getSelection();if(!e||e.isCollapsed)return;const s=b(this,_,Pu).call(this,e).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,Pi)||g(this,Pi,new _b(this)),n(this,Pi).show(s,i,this.direction==="ltr"))},gv=function(){var r,a,o;const e=document.getSelection();if(!e||e.isCollapsed){n(this,ln)&&((r=n(this,Pi))==null||r.hide(),g(this,ln,null),b(this,_,ze).call(this,{hasSelectedText:!1}));return}const{anchorNode:t}=e;if(t===n(this,ln))return;const i=b(this,_,Pu).call(this,e).closest(".textLayer");if(!i){n(this,ln)&&((a=n(this,Pi))==null||a.hide(),g(this,ln,null),b(this,_,ze).call(this,{hasSelectedText:!1}));return}if((o=n(this,Pi))==null||o.hide(),g(this,ln,t),b(this,_,ze).call(this,{hasSelectedText:!0}),!(n(this,le)!==nt.HIGHLIGHT&&n(this,le)!==nt.NONE)&&(n(this,le)===nt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),g(this,cr,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,le)===nt.HIGHLIGHT?b(this,_,Rp).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,bl)){const h=new AbortController,c=this.combinedSignal(h),u=f=>{f.type==="pointerup"&&f.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&b(this,_,Wh).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:c}),window.addEventListener("blur",u,{signal:c})}else l==null||l.toggleDrawing(!0),b(this,_,Wh).call(this,"main_toolbar")}},Wh=function(e=""){n(this,le)===nt.HIGHLIGHT?this.highlightSelection(e):n(this,Dc)&&b(this,_,pv).call(this)},mv=function(){document.addEventListener("selectionchange",b(this,_,gv).bind(this),{signal:this._signal})},vv=function(){if(n(this,hr))return;g(this,hr,new AbortController);const e=this.combinedSignal(n(this,hr));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},yv=function(){var e;(e=n(this,hr))==null||e.abort(),g(this,hr,null)},Dp=function(){if(n(this,dr))return;g(this,dr,new AbortController);const e=this.combinedSignal(n(this,dr));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},bv=function(){var e;(e=n(this,dr))==null||e.abort(),g(this,dr,null)},Av=function(){if(n(this,rr))return;g(this,rr,new AbortController);const e=this.combinedSignal(n(this,rr));document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})},wv=function(){var e;(e=n(this,rr))==null||e.abort(),g(this,rr,null)},Ev=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},ze=function(e){Object.entries(e).some(([s,i])=>n(this,Uc)[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(n(this,Uc),e)}),n(this,le)===nt.HIGHLIGHT&&e.hasSelectedEditor===!1&&b(this,_,en).call(this,[[at.HIGHLIGHT_FREE,!0]]))},en=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},Sv=async function(){if(!n(this,on)){g(this,on,!0);const e=[];for(const t of n(this,Kt).values())e.push(t.enable());await Promise.all(e);for(const t of n(this,Zt).values())t.enable()}},xv=function(){if(this.unselectAll(),n(this,on)){g(this,on,!1);for(const e of n(this,Kt).values())e.disable();for(const e of n(this,Zt).values())e.disable()}},kp=function(e){const t=n(this,Kt).get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Tv=function(){let e=null;for(e of n(this,Ot));return e},Vh=function(){if(n(this,Zt).size===0)return!0;if(n(this,Zt).size===1)for(const e of n(this,Zt).values())return e.isEmpty();return!1},Lp=function(e){for(const t of n(this,Ot))t.unselect();n(this,Ot).clear();for(const t of e)t.isEmpty()||(n(this,Ot).add(t),t.select());b(this,_,ze).call(this,{hasSelectedEditor:this.hasSelection})},P(nl,"TRANSLATE_SMALL",1),P(nl,"TRANSLATE_BIG",10);let ea=nl;var ve,Oi,ni,El,Ri,ms,Sl,Di,rs,cn,wa,ki,mr,Ai,Xh,Mu;const We=class We{constructor(e){y(this,Ai);y(this,ve,null);y(this,Oi,!1);y(this,ni,null);y(this,El,null);y(this,Ri,null);y(this,ms,null);y(this,Sl,!1);y(this,Di,null);y(this,rs,null);y(this,cn,null);y(this,wa,null);y(this,ki,!1);g(this,rs,e),g(this,ki,e._uiManager.useNewAltTextFlow),n(We,mr)||g(We,mr,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){We._l10n??(We._l10n=e)}async render(){const e=g(this,ni,document.createElement("button"));e.className="altText",e.tabIndex="0";const t=g(this,El,document.createElement("span"));e.append(t),n(this,ki)?(e.classList.add("new"),e.setAttribute("data-l10n-id",n(We,mr).missing),t.setAttribute("data-l10n-id",n(We,mr)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,rs)._uiManager._signal;e.addEventListener("contextmenu",Bs,{signal:s}),e.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,rs)._uiManager.editAltText(n(this,rs)),n(this,ki)&&n(this,rs)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,Ai,Xh)}})};return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",r=>{r.target===e&&r.key==="Enter"&&(g(this,Sl,!0),i(r))},{signal:s}),await b(this,Ai,Mu).call(this),e}finish(){n(this,ni)&&(n(this,ni).focus({focusVisible:n(this,Sl)}),g(this,Sl,!1))}isEmpty(){return n(this,ki)?n(this,ve)===null:!n(this,ve)&&!n(this,Oi)}hasData(){return n(this,ki)?n(this,ve)!==null||!!n(this,cn):this.isEmpty()}get guessedText(){return n(this,cn)}async setGuessedText(e){n(this,ve)===null&&(g(this,cn,e),g(this,wa,await We._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),b(this,Ai,Mu).call(this))}toggleAltTextBadge(e=!1){var t;if(!n(this,ki)||n(this,ve)){(t=n(this,Di))==null||t.remove(),g(this,Di,null);return}if(!n(this,Di)){const s=g(this,Di,document.createElement("div"));s.className="noAltTextBadge",n(this,rs).div.append(s)}n(this,Di).classList.toggle("hidden",!e)}serialize(e){let t=n(this,ve);return!e&&n(this,cn)===t&&(t=n(this,wa)),{altText:t,decorative:n(this,Oi),guessedText:n(this,cn),textWithDisclaimer:n(this,wa)}}get data(){return{altText:n(this,ve),decorative:n(this,Oi)}}set data({altText:e,decorative:t,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(g(this,cn,s),g(this,wa,i)),!(n(this,ve)===e&&n(this,Oi)===t)&&(r||(g(this,ve,e),g(this,Oi,t)),b(this,Ai,Mu).call(this))}toggle(e=!1){n(this,ni)&&(!e&&n(this,ms)&&(clearTimeout(n(this,ms)),g(this,ms,null)),n(this,ni).disabled=!e)}shown(){n(this,rs)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,Ai,Xh)}})}destroy(){var e,t;(e=n(this,ni))==null||e.remove(),g(this,ni,null),g(this,El,null),g(this,Ri,null),(t=n(this,Di))==null||t.remove(),g(this,Di,null)}};ve=new WeakMap,Oi=new WeakMap,ni=new WeakMap,El=new WeakMap,Ri=new WeakMap,ms=new WeakMap,Sl=new WeakMap,Di=new WeakMap,rs=new WeakMap,cn=new WeakMap,wa=new WeakMap,ki=new WeakMap,mr=new WeakMap,Ai=new WeakSet,Xh=function(){return n(this,ve)&&"added"||n(this,ve)===null&&this.guessedText&&"review"||"missing"},Mu=async function(){var i,r,a;const e=n(this,ni);if(!e)return;if(n(this,ki)){if(e.classList.toggle("done",!!n(this,ve)),e.setAttribute("data-l10n-id",n(We,mr)[n(this,Ai,Xh)]),(i=n(this,El))==null||i.setAttribute("data-l10n-id",n(We,mr)[`${n(this,Ai,Xh)}-label`]),!n(this,ve)){(r=n(this,Ri))==null||r.remove();return}}else{if(!n(this,ve)&&!n(this,Oi)){e.classList.remove("done"),(a=n(this,Ri))==null||a.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=n(this,Ri);if(!t){g(this,Ri,t=document.createElement("span")),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${n(this,rs).id}`;const o=100,l=n(this,rs)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,ms)),g(this,ms,null)},{once:!0}),e.addEventListener("mouseenter",()=>{g(this,ms,setTimeout(()=>{g(this,ms,null),n(this,Ri).classList.add("show"),n(this,rs)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),e.addEventListener("mouseleave",()=>{var h;n(this,ms)&&(clearTimeout(n(this,ms)),g(this,ms,null)),(h=n(this,Ri))==null||h.classList.remove("show")},{signal:l})}n(this,Oi)?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=n(this,ve)),t.parentNode||e.append(t);const s=n(this,rs).getElementForAltText();s==null||s.setAttribute("aria-describedby",t.id)},y(We,mr,null),P(We,"_l10n",null);let vf=We;var Te,Ws,Ea,Bt,jc,vr,Vs,yr,br,Sa,Gc,Fp;class vu{constructor(e){y(this,Gc);y(this,Te,null);y(this,Ws,null);y(this,Ea,!1);y(this,Bt,null);y(this,jc,null);y(this,vr,null);y(this,Vs,null);y(this,yr,null);y(this,br,!1);y(this,Sa,null);g(this,Bt,e)}renderForToolbar(){const e=g(this,Ws,document.createElement("button"));return e.className="comment",b(this,Gc,Fp).call(this,e,!1)}renderForStandalone(){const e=g(this,Te,document.createElement("button"));e.className="annotationCommentButton";const t=n(this,Bt).commentButtonPosition;if(t){const{style:s}=e;s.insetInlineEnd=`calc(${100*(n(this,Bt)._uiManager.direction==="ltr"?1-t[0]:t[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;const i=n(this,Bt).commentButtonColor;i&&(s.backgroundColor=i)}return b(this,Gc,Fp).call(this,e,!0)}focusButton(){setTimeout(()=>{var e;(e=n(this,Te)??n(this,Ws))==null||e.focus()},0)}onUpdatedColor(){if(!n(this,Te))return;const e=n(this,Bt).commentButtonColor;e&&(n(this,Te).style.backgroundColor=e),n(this,Bt)._uiManager.updatePopupColor(n(this,Bt))}get commentButtonWidth(){var e;return(((e=n(this,Te))==null?void 0:e.getBoundingClientRect().width)??0)/n(this,Bt).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(n(this,Sa))return n(this,Sa);if(!n(this,Te))return null;const{x:e,y:t,height:s}=n(this,Te).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,Bt).parent.boundingClientRect;return[(e-i)/a,(t+s-r)/o]}set commentPopupPositionInLayer(e){g(this,Sa,e)}hasDefaultPopupPosition(){return n(this,Sa)===null}removeStandaloneCommentButton(){var e;(e=n(this,Te))==null||e.remove(),g(this,Te,null)}removeToolbarCommentButton(){var e;(e=n(this,Ws))==null||e.remove(),g(this,Ws,null)}setCommentButtonStates({selected:e,hasPopup:t}){n(this,Te)&&(n(this,Te).classList.toggle("selected",e),n(this,Te).ariaExpanded=t)}edit(e){const t=this.commentPopupPositionInLayer;let s,i;if(t)[s,i]=t;else{[s,i]=n(this,Bt).commentButtonPosition;const{width:c,height:u,x:f,y:p}=n(this,Bt);s=f+s*c,i=p+i*u}const r=n(this,Bt).parent.boundingClientRect,{x:a,y:o,width:l,height:h}=r;n(this,Bt)._uiManager.editComment(n(this,Bt),a+s*l,o+i*h,{...e,parentDimensions:r})}finish(){n(this,Ws)&&(n(this,Ws).focus({focusVisible:n(this,Ea)}),g(this,Ea,!1))}isDeleted(){return n(this,br)||n(this,Vs)===""}isEmpty(){return n(this,Vs)===null}hasBeenEdited(){return this.isDeleted()||n(this,Vs)!==n(this,jc)}serialize(){return this.data}get data(){return{text:n(this,Vs),richText:n(this,vr),date:n(this,yr),deleted:this.isDeleted()}}set data(e){if(e!==n(this,Vs)&&g(this,vr,null),e===null){g(this,Vs,""),g(this,br,!0);return}g(this,Vs,e),g(this,yr,new Date),g(this,br,!1)}restoreData({text:e,richText:t,date:s}){g(this,Vs,e),g(this,vr,t),g(this,yr,s),g(this,br,!1)}setInitialText(e,t=null){g(this,jc,e),this.data=e,g(this,yr,null),g(this,vr,t)}shown(){}destroy(){var e,t;(e=n(this,Ws))==null||e.remove(),g(this,Ws,null),(t=n(this,Te))==null||t.remove(),g(this,Te,null),g(this,Vs,""),g(this,vr,null),g(this,yr,null),g(this,Bt,null),g(this,Ea,!1),g(this,br,!1)}}Te=new WeakMap,Ws=new WeakMap,Ea=new WeakMap,Bt=new WeakMap,jc=new WeakMap,vr=new WeakMap,Vs=new WeakMap,yr=new WeakMap,br=new WeakMap,Sa=new WeakMap,Gc=new WeakSet,Fp=function(e,t){if(!n(this,Bt)._uiManager.hasCommentManager())return null;e.tabIndex="0",e.ariaHasPopup="dialog",t?(e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(e.ariaControlsElements=[n(this,Bt)._uiManager.getCommentDialogElement()],e.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=n(this,Bt)._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return e;e.addEventListener("contextmenu",Bs,{signal:s}),t&&(e.addEventListener("focusin",r=>{n(this,Bt)._focusEventsAllowed=!1,Wt(r)},{capture:!0,signal:s}),e.addEventListener("focusout",r=>{n(this,Bt)._focusEventsAllowed=!0,Wt(r)},{capture:!0,signal:s})),e.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),e===n(this,Ws)?this.edit():n(this,Bt).toggleComment(!0)};return e.addEventListener("click",i,{capture:!0,signal:s}),e.addEventListener("keydown",r=>{r.target===e&&r.key==="Enter"&&(g(this,Ea,!0),i(r))},{signal:s}),e.addEventListener("pointerenter",()=>{n(this,Bt).toggleComment(!1,!0)},{signal:s}),e.addEventListener("pointerleave",()=>{n(this,Bt).toggleComment(!1,!1)},{signal:s}),e};var xl,xa,_c,zc,Wc,Vc,Xc,dn,Ta,un,Ca,fn,sa,Cv,Iv,Pv;const cm=class cm{constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){y(this,sa);y(this,xl);y(this,xa,!1);y(this,_c,null);y(this,zc);y(this,Wc);y(this,Vc);y(this,Xc);y(this,dn,null);y(this,Ta);y(this,un,null);y(this,Ca);y(this,fn,null);g(this,xl,e),g(this,_c,s),g(this,zc,t),g(this,Wc,i),g(this,Vc,r),g(this,Xc,a),g(this,Ca,new AbortController),g(this,Ta,AbortSignal.any([o,n(this,Ca).signal])),e.addEventListener("touchstart",b(this,sa,Cv).bind(this),{passive:!1,signal:n(this,Ta)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ei.pixelRatio}destroy(){var e,t;(e=n(this,Ca))==null||e.abort(),g(this,Ca,null),(t=n(this,dn))==null||t.abort(),g(this,dn,null)}};xl=new WeakMap,xa=new WeakMap,_c=new WeakMap,zc=new WeakMap,Wc=new WeakMap,Vc=new WeakMap,Xc=new WeakMap,dn=new WeakMap,Ta=new WeakMap,un=new WeakMap,Ca=new WeakMap,fn=new WeakMap,sa=new WeakSet,Cv=function(e){var i,r,a;if((i=n(this,zc))!=null&&i.call(this))return;if(e.touches.length===1){if(n(this,dn))return;const o=g(this,dn,new AbortController),l=AbortSignal.any([n(this,Ta),o.signal]),h=n(this,xl),c={capture:!0,signal:l,passive:!1},u=f=>{var p;f.pointerType==="touch"&&((p=n(this,dn))==null||p.abort(),g(this,dn,null))};h.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(Wt(f),u(f))},c),h.addEventListener("pointerup",u,c),h.addEventListener("pointercancel",u,c);return}if(!n(this,fn)){g(this,fn,new AbortController);const o=AbortSignal.any([n(this,Ta),n(this,fn).signal]),l=n(this,xl),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",b(this,sa,Iv).bind(this),h);const c=b(this,sa,Pv).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",Wt,h),l.addEventListener("pointermove",Wt,h),l.addEventListener("pointercancel",Wt,h),l.addEventListener("pointerup",Wt,h),(r=n(this,Wc))==null||r.call(this)}if(Wt(e),e.touches.length!==2||(a=n(this,_c))!=null&&a.call(this)){g(this,un,null);return}let[t,s]=e.touches;t.identifier>s.identifier&&([t,s]=[s,t]),g(this,un,{touch0X:t.screenX,touch0Y:t.screenY,touch1X:s.screenX,touch1Y:s.screenY})},Iv=function(e){var T;if(!n(this,un)||e.touches.length!==2)return;Wt(e);let[t,s]=e.touches;t.identifier>s.identifier&&([t,s]=[s,t]);const{screenX:i,screenY:r}=t,{screenX:a,screenY:o}=s,l=n(this,un),{touch0X:h,touch0Y:c,touch1X:u,touch1Y:f}=l,p=u-h,m=f-c,v=a-i,A=o-r,w=Math.hypot(v,A)||1,E=Math.hypot(p,m)||1;if(!n(this,xa)&&Math.abs(E-w)<=cm.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,xa)){g(this,xa,!0);return}const S=[(i+a)/2,(r+o)/2];(T=n(this,Vc))==null||T.call(this,S,E,w)},Pv=function(e){var t;e.touches.length>=2||(n(this,fn)&&(n(this,fn).abort(),g(this,fn,null),(t=n(this,Xc))==null||t.call(this)),n(this,un)&&(Wt(e),g(this,un,null),g(this,xa,!1)))};let wc=cm;var Ia,ri,_t,Tt,pn,Tl,Ar,Yc,Ce,Pa,gn,Xs,wr,Kc,Ma,vs,Jc,Oa,mn,Li,Cl,Il,Ys,Ra,Qc,Of,tt,Np,Zc,Bp,Ou,Mv,Ov,Up,Ru,Hp,Rv,Dv,kv,$p,Lv,jp,Fv,Nv,Bv,Gp,Yh;const et=class et{constructor(e){y(this,tt);y(this,Ia,null);y(this,ri,null);y(this,_t,null);y(this,Tt,null);y(this,pn,null);y(this,Tl,!1);y(this,Ar,null);y(this,Yc,"");y(this,Ce,null);y(this,Pa,null);y(this,gn,null);y(this,Xs,null);y(this,wr,null);y(this,Kc,"");y(this,Ma,!1);y(this,vs,null);y(this,Jc,!1);y(this,Oa,!1);y(this,mn,!1);y(this,Li,null);y(this,Cl,0);y(this,Il,0);y(this,Ys,null);y(this,Ra,null);P(this,"isSelected",!1);P(this,"_isCopy",!1);P(this,"_editToolbar",null);P(this,"_initialOptions",Object.create(null));P(this,"_initialData",null);P(this,"_isVisible",!0);P(this,"_uiManager",null);P(this,"_focusEventsAllowed",!0);y(this,Qc,!1);y(this,Of,et._zIndex++);this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null,this.canAddComment=!0;const{rotation:t,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=et.prototype._resizeWithKeyboard,t=ea.TRANSLATE_SMALL,s=ea.TRANSLATE_BIG;return st(this,"_resizerKeyboardManager",new Vo([[["ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-s,0]}],[["ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[s,0]}],[["ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-s]}],[["ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,s]}],[["Escape"],et.prototype._stopResizingWithKeyboard]]))}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return st(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new Xb({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(et._l10n??(et._l10n=e),et._l10nAlert??(et._l10nAlert=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"})),et._l10nResizer??(et._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),et._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);et._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){bt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,Qc)}set _isDraggable(e){var t;g(this,Qc,e),(t=this.div)==null||t.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(e*2),this.y+=this.width*e/(t*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(e*2),this.y-=this.width*e/(t*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=n(this,Of)}setParent(e){var t;e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):(b(this,tt,Yh).call(this),(t=n(this,Xs))==null||t.remove(),g(this,Xs,null)),this.parent=e}focusin(e){this._focusEventsAllowed&&(n(this,Ma)?g(this,Ma,!1):this.parent.setSelected(this))}focusout(e){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const t=e.relatedTarget;t!=null&&t.closest(`#${this.id}`)||(e.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,s,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(e+s)/r,this.y=(t+i)/a,this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(e*s,t*i,this.width*s,this.height*i),this._onTranslated()}translate(e,t){b(this,tt,Np).call(this,this.parentDimensions,e,t)}translateInPage(e,t){n(this,vs)||g(this,vs,[this.x,this.y,this.width,this.height]),b(this,tt,Np).call(this,this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){n(this,vs)||g(this,vs,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=e/i,this.y+=t/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:u,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,u,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!n(this,vs)&&(n(this,vs)[0]!==this.x||n(this,vs)[1]!==this.y)}get _hasBeenResized(){return!!n(this,vs)&&(n(this,vs)[2]!==this.width||n(this,vs)[3]!==this.height)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:s}=et,i=s/e,r=s/t;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:t},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(e){case 0:r=Ht(r,0,s-o),a=Ht(a,0,i-l);break;case 90:r=Ht(r,0,s-l),a=Ht(a,o,i);break;case 180:r=Ht(r,o,s),a=Ht(a,l,i);break;case 270:r=Ht(r,l,s),a=Ht(a,0,i-o);break}this.x=r/=s,this.y=a/=i;const[h,c]=this.getBaseTranslation();r+=h,a+=c,t.left=`${(100*r).toFixed(2)}%`,t.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,t){var s;return b(s=et,Zc,Bp).call(s,e,t,this.parentRotation)}pageTranslationToScreen(e,t){var s;return b(s=et,Zc,Bp).call(s,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,s]}=this;return[t*e,s*e]}setDims(){const{div:{style:e},width:t,height:s}=this;e.width=`${(100*t).toFixed(2)}%`,e.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=n(this,_t))==null||e.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,Oa))return this._editToolbar;this._editToolbar=new Ip(this),this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[t,s]of e)await this._editToolbar.addButton(t,s);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var e;(e=this._editToolbar)==null||e.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var e;(e=this._editToolbar)==null||e.removeButton("comment")}removeEditToolbar(){var e,t;(e=this._editToolbar)==null||e.remove(),this._editToolbar=null,(t=n(this,_t))==null||t.destroy()}addContainer(e){var s;const t=(s=this._editToolbar)==null?void 0:s.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return n(this,_t)||(vf.initialize(et._l10n),g(this,_t,new vf(this)),n(this,Ia)&&(n(this,_t).data=n(this,Ia),g(this,Ia,null))),n(this,_t)}get altTextData(){var e;return(e=n(this,_t))==null?void 0:e.data}set altTextData(e){n(this,_t)&&(n(this,_t).data=e)}get guessedAltText(){var e;return(e=n(this,_t))==null?void 0:e.guessedText}async setGuessedAltText(e){var t;await((t=n(this,_t))==null?void 0:t.setGuessedText(e))}serializeAltText(e){var t;return(t=n(this,_t))==null?void 0:t.serialize(e)}hasAltText(){return!!n(this,_t)&&!n(this,_t).isEmpty()}hasAltTextData(){var e;return((e=n(this,_t))==null?void 0:e.hasData())??!1}focusCommentButton(){var e;(e=n(this,Tt))==null||e.focusButton()}addCommentButton(){return this.canAddComment?n(this,Tt)||g(this,Tt,new vu(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(n(this,pn)){this._uiManager.isEditingMode()&&n(this,pn).classList.remove("hidden");return}this.hasComment&&(g(this,pn,n(this,Tt).renderForStandalone()),this.div.append(n(this,pn)))}}removeStandaloneCommentButton(){n(this,Tt).removeStandaloneCommentButton(),g(this,pn,null)}hideStandaloneCommentButton(){var e;(e=n(this,pn))==null||e.classList.add("hidden")}get comment(){if(!n(this,Tt))return null;const{data:{richText:e,text:t,date:s,deleted:i}}=n(this,Tt);return{text:t,richText:e,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){n(this,Tt)||g(this,Tt,new vu(this)),typeof e=="object"&&e!==null?n(this,Tt).restoreData(e):n(this,Tt).data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:t,richText:s}){if(!t||(n(this,Tt)||g(this,Tt,new vu(this)),n(this,Tt).setInitialText(e,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){var e;return(e=n(this,Tt))==null?void 0:e.hasBeenEdited()}get hasDeletedComment(){var e;return(e=n(this,Tt))==null?void 0:e.isDeleted()}get hasComment(){return!!n(this,Tt)&&!n(this,Tt).isEmpty()&&!n(this,Tt).isDeleted()}async editComment(e){n(this,Tt)||g(this,Tt,new vu(this)),n(this,Tt).edit(e)}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){n(this,Tt).setSelectedButton(e)}addComment(e){if(this.hasEditedComment){const[,,,i]=e.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,h=o+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,h,i]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){n(this,Tt).data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var a;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=n(this,Tl)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),b(this,tt,jp).call(this);const[t,s]=this.parentDimensions;this.parentRotation%180!==0&&(e.style.maxWidth=`${(100*s/t).toFixed(2)}%`,e.style.maxHeight=`${(100*t/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),cv(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,Ra)||g(this,Ra,new wc({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,tt,Rv).bind(this),onPinching:b(this,tt,Dv).bind(this),onPinchEnd:b(this,tt,kv).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(a=this._uiManager._editorUndoBar)==null||a.hide(),e}pointerdown(e){const{isMac:t}=It.platform;if(e.button!==0||e.ctrlKey&&t){e.preventDefault();return}if(g(this,Ma,!0),this._isDraggable){b(this,tt,Lv).call(this,e);return}b(this,tt,$p).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,Li)&&clearTimeout(n(this,Li)),g(this,Li,setTimeout(()=>{var e;g(this,Li,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,s){e.changeParent(this),this.x=t,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=e/i,c=t/i,u=this.x*r,f=this.y*a,p=this.width*r,m=this.height*a;switch(s){case 0:return[u+h+o,a-f-c-m+l,u+h+p+o,a-f-c+l];case 90:return[u+c+o,a-f+h+l,u+c+m+o,a-f+h+p+l];case 180:return[u-h-p+o,a-f+c+l,u-h+o,a-f+c+m+l];case 270:return[u-c-m+o,a-f-h-p+l,u-c+o,a-f-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[s,i,r,a]=e,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,t-a,o,l];case 90:return[s,t-i,l,o];case 180:return[r,t-i,o,l];case 270:return[r,t-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&et._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var e;(e=n(this,Tt))==null||e.onUpdatedColor()}getData(){const{comment:{text:e,color:t,date:s,opacity:i,deleted:r,richText:a},uid:o,pageIndex:l,creationDate:h,modificationDate:c}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:a,contentsObj:{str:e},creationDate:h,modificationDate:s||c,popupRef:!r,color:t,opacity:i}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),g(this,Oa,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),g(this,Oa,!1),!0):!1}isInEditMode(){return n(this,Oa)}shouldGetKeyboardEvents(){return n(this,mn)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:t,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return t<a&&i>0&&e<r&&s>0}rebuild(){b(this,tt,jp).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,t=null){var s;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((s=this._initialData)==null?void 0:s.popupRef)||""}}static async deserialize(e,t,s){const i=new this.prototype.constructor({parent:t,id:s.getId(),uiManager:s,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});i.rotation=e.rotation,g(i,Ia,e.accessibilityData),i._isCopy=e.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(e.rect,a);return i.x=o/r,i.y=l/a,i.width=h/r,i.height=c/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,t,s;if((e=n(this,wr))==null||e.abort(),g(this,wr,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),n(this,Li)&&(clearTimeout(n(this,Li)),g(this,Li,null)),b(this,tt,Yh).call(this),this.removeEditToolbar(),n(this,Ys)){for(const i of n(this,Ys).values())clearTimeout(i);g(this,Ys,null)}this.parent=null,(t=n(this,Ra))==null||t.destroy(),g(this,Ra,null),(s=n(this,Xs))==null||s.remove(),g(this,Xs,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,tt,Mv).call(this),n(this,Ce).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,t]}=this,[s,i,r,a]=this.getPDFRect();return[et._round(s+(r-s)*e),et._round(i+(a-i)*(1-t))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return n(this,Tt).commentPopupPositionInLayer}set commentPopupPosition(e){n(this,Tt).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return n(this,Tt).hasDefaultPopupPosition()}get commentButtonWidth(){return n(this,Tt).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){var t;(t=n(this,Tt))==null||t.setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),g(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const t=n(this,Ce).children;if(!n(this,ri)){g(this,ri,Array.from(t));const a=b(this,tt,Fv).bind(this),o=b(this,tt,Nv).bind(this),l=this._uiManager._signal;for(const h of n(this,ri)){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",b(this,tt,Bv).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",et._l10nResizer[c])}}const s=n(this,ri)[0];let i=0;for(const a of t){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,ri).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,Ce).append(n(this,Ce).firstElementChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,Ce).firstElementChild.before(n(this,Ce).lastElementChild);let a=0;for(const o of t){const h=n(this,ri)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",et._l10nResizer[h])}}b(this,tt,Gp).call(this,0),g(this,mn,!0),n(this,Ce).firstElementChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,t){n(this,mn)&&b(this,tt,Hp).call(this,n(this,Kc),{deltaX:e,deltaY:t,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,tt,Yh).call(this),this.div.focus()}select(){var e,t,s;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(e=this.div)==null||e.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(t=this._editToolbar)==null||t.show(),(s=n(this,_t))==null||s.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var e;return(e=this.div)==null?void 0:e.focus({preventScroll:!0})},0)}unselect(){var e,t,s,i,r;this.isSelected&&(this.isSelected=!1,(e=n(this,Ce))==null||e.classList.add("hidden"),(t=this.div)==null||t.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=n(this,_t))==null||r.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,Jc)}set isEditing(e){g(this,Jc,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){n(this,Ys)||g(this,Ys,new Map);const{action:s}=e;let i=n(this,Ys).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),n(this,Ys).delete(s),n(this,Ys).size===0&&g(this,Ys,null)},et._telemetryTimeout),n(this,Ys).set(s,i);return}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),g(this,Tl,!1)}disable(){this.div&&(this.div.tabIndex=-1),g(this,Tl,!0)}updateFakeAnnotationElement(e){if(!n(this,Xs)&&!this.deleted){g(this,Xs,e.addFakeAnnotation(this));return}if(this.deleted){n(this,Xs).remove(),g(this,Xs,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&n(this,Xs).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let t=e.container.querySelector(".annotationContent");if(!t)t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);else if(t.nodeName==="CANVAS"){const s=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),s.before(t)}return t}resetAnnotationElement(e){const{firstElementChild:t}=e.container;(t==null?void 0:t.nodeName)==="DIV"&&t.classList.contains("annotationContent")&&t.remove()}};Ia=new WeakMap,ri=new WeakMap,_t=new WeakMap,Tt=new WeakMap,pn=new WeakMap,Tl=new WeakMap,Ar=new WeakMap,Yc=new WeakMap,Ce=new WeakMap,Pa=new WeakMap,gn=new WeakMap,Xs=new WeakMap,wr=new WeakMap,Kc=new WeakMap,Ma=new WeakMap,vs=new WeakMap,Jc=new WeakMap,Oa=new WeakMap,mn=new WeakMap,Li=new WeakMap,Cl=new WeakMap,Il=new WeakMap,Ys=new WeakMap,Ra=new WeakMap,Qc=new WeakMap,Of=new WeakMap,tt=new WeakSet,Np=function([e,t],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/e,this.y+=i/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},Zc=new WeakSet,Bp=function(e,t,s){switch(s){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}},Ou=function(e){switch(e){case 90:{const[t,s]=this.pageDimensions;return[0,-t/s,s/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,s]=this.pageDimensions;return[0,t/s,-s/t,0]}default:return[1,0,0,1]}},Mv=function(){if(n(this,Ce))return;g(this,Ce,document.createElement("div")),n(this,Ce).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const s of e){const i=document.createElement("div");n(this,Ce).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,tt,Ov).bind(this,s),{signal:t}),i.addEventListener("contextmenu",Bs,{signal:t}),i.tabIndex=-1}this.div.prepend(n(this,Ce))},Ov=function(e,t){var c;t.preventDefault();const{isMac:s}=It.platform;if(t.button!==0||t.ctrlKey&&s)return;(c=n(this,_t))==null||c.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,g(this,Pa,[t.screenX,t.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,tt,Hp).bind(this,e),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Wt,{passive:!1,signal:a}),window.addEventListener("contextmenu",Bs,{signal:a}),g(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const h=()=>{var u;r.abort(),this.parent.togglePointerEvents(!0),(u=n(this,_t))==null||u.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,tt,Ru).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},Up=function(e,t,s,i){this.width=s,this.height=i,this.x=e,this.y=t,this.setDims(),this.fixAndSetPosition(),this._onResized()},Ru=function(){if(!n(this,gn))return;const{savedX:e,savedY:t,savedWidth:s,savedHeight:i}=n(this,gn);g(this,gn,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===e&&a===t&&o===s&&l===i||this.addCommands({cmd:b(this,tt,Up).bind(this,r,a,o,l),undo:b(this,tt,Up).bind(this,e,t,s,i),mustExec:!0})},Hp=function(e,t){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=et.MIN_SIZE/s,c=et.MIN_SIZE/i,u=b(this,tt,Ou).call(this,this.rotation),f=(L,B)=>[u[0]*L+u[2]*B,u[1]*L+u[3]*B],p=b(this,tt,Ou).call(this,360-this.rotation),m=(L,B)=>[p[0]*L+p[2]*B,p[1]*L+p[3]*B];let v,A,w=!1,E=!1;switch(e){case"topLeft":w=!0,v=(L,B)=>[0,0],A=(L,B)=>[L,B];break;case"topMiddle":v=(L,B)=>[L/2,0],A=(L,B)=>[L/2,B];break;case"topRight":w=!0,v=(L,B)=>[L,0],A=(L,B)=>[0,B];break;case"middleRight":E=!0,v=(L,B)=>[L,B/2],A=(L,B)=>[0,B/2];break;case"bottomRight":w=!0,v=(L,B)=>[L,B],A=(L,B)=>[0,0];break;case"bottomMiddle":v=(L,B)=>[L/2,B],A=(L,B)=>[L/2,0];break;case"bottomLeft":w=!0,v=(L,B)=>[0,B],A=(L,B)=>[L,0];break;case"middleLeft":E=!0,v=(L,B)=>[0,B/2],A=(L,B)=>[L,B/2];break}const S=v(o,l),T=A(o,l);let x=f(...T);const C=et._round(r+x[0]),I=et._round(a+x[1]);let O=1,M=1,R,D;if(t.fromKeyboard)({deltaX:R,deltaY:D}=t);else{const{screenX:L,screenY:B}=t,[q,W]=n(this,Pa);[R,D]=this.screenToPageTranslation(L-q,B-W),n(this,Pa)[0]=L,n(this,Pa)[1]=B}if([R,D]=m(R/s,D/i),w){const L=Math.hypot(o,l);O=M=Math.max(Math.min(Math.hypot(T[0]-S[0]-R,T[1]-S[1]-D)/L,1/o,1/l),h/o,c/l)}else E?O=Ht(Math.abs(T[0]-S[0]-R),h,1)/o:M=Ht(Math.abs(T[1]-S[1]-D),c,1)/l;const j=et._round(o*O),F=et._round(l*M);x=f(...A(j,F));const U=C-x[0],Z=I-x[1];n(this,vs)||g(this,vs,[this.x,this.y,this.width,this.height]),this.width=j,this.height=F,this.x=U,this.y=Z,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Rv=function(){var e;g(this,gn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=n(this,_t))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)},Dv=function(e,t,s){let r=.7*(s/t)+1-.7;if(r===1)return;const a=b(this,tt,Ou).call(this,this.rotation),o=(C,I)=>[a[0]*C+a[2]*I,a[1]*C+a[3]*I],[l,h]=this.parentDimensions,c=this.x,u=this.y,f=this.width,p=this.height,m=et.MIN_SIZE/l,v=et.MIN_SIZE/h;r=Math.max(Math.min(r,1/f,1/p),m/f,v/p);const A=et._round(f*r),w=et._round(p*r);if(A===f&&w===p)return;n(this,vs)||g(this,vs,[c,u,f,p]);const E=o(f/2,p/2),S=et._round(c+E[0]),T=et._round(u+E[1]),x=o(A/2,w/2);this.x=S-x[0],this.y=T-x[1],this.width=A,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},kv=function(){var e;(e=n(this,_t))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),b(this,tt,Ru).call(this)},$p=function(e){const{isMac:t}=It.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)},Lv=function(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=h=>{i.abort(),g(this,Ar,null),g(this,Ma,!1),this._uiManager.endDragSession()||b(this,tt,$p).call(this,h),s&&this._onStopDragging()};t&&(g(this,Cl,e.clientX),g(this,Il,e.clientY),g(this,Ar,e.pointerId),g(this,Yc,e.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:u,pointerId:f}=h;if(f!==n(this,Ar)){Wt(h);return}const[p,m]=this.screenToPageTranslation(c-n(this,Cl),u-n(this,Il));g(this,Cl,c),g(this,Il,u),this._uiManager.dragSelectedEditors(p,m)},a),window.addEventListener("touchmove",Wt,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,Yc)&&(n(this,Ra)||h.isPrimary)&&o(h),Wt(h)},a));const l=h=>{if(!n(this,Ar)||n(this,Ar)===h.pointerId){o(h);return}Wt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},jp=function(){if(n(this,wr)||!this.div)return;g(this,wr,new AbortController);const e=this._uiManager.combinedSignal(n(this,wr));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},Fv=function(e){et._resizerKeyboardManager.exec(this,e)},Nv=function(e){var t;n(this,mn)&&((t=e.relatedTarget)==null?void 0:t.parentNode)!==n(this,Ce)&&b(this,tt,Yh).call(this)},Bv=function(e){g(this,Kc,n(this,mn)?e:"")},Gp=function(e){if(n(this,ri))for(const t of n(this,ri))t.tabIndex=e},Yh=function(){g(this,mn,!1),b(this,tt,Gp).call(this,-1),b(this,tt,Ru).call(this)},y(et,Zc),P(et,"_l10n",null),P(et,"_l10nAlert",null),P(et,"_l10nResizer",null),P(et,"_borderLineWidth",-1),P(et,"_colorManager",new Op),P(et,"_zIndex",1),P(et,"_telemetryTimeout",1e3);let St=et;class Xb extends St{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Tm=3285377520,Us=4294901760,xi=65535;class _p{constructor(e){this.h1=e?e&4294967295:Tm,this.h2=e?e&4294967295:Tm}update(e){let t,s;if(typeof e=="string"){t=new Uint8Array(e.length*2),s=0;for(let v=0,A=e.length;v<A;v++){const w=e.charCodeAt(v);w<=255?t[s++]=w:(t[s++]=w>>>8,t[s++]=w&255)}}else if(ArrayBuffer.isView(e))t=e.slice(),s=t.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,a=new Uint32Array(t.buffer,0,i);let o=0,l=0,h=this.h1,c=this.h2;const u=3432918353,f=461845907,p=u&xi,m=fξfor(let v=0;v<i;v++)v&1?(o=a[v],o=o*u&Us|o*p&xi,o=o<<15|o>>>17,o=o*f&Us|o*m&xi,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[v],l=l*u&Us|l*p&xi,l=l<<15|l>>>17,l=l*f&Us|l*m&xi,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=t[i*4+2]<<16;case 2:o^=t[i*4+1]<<8;case 1:o^=t[i*4],o=o*u&Us|o*p&xi,o=o<<15|o>>>17,o=o*f&Us|o*m&xi,i&1?h^=o:c^=o}this.h1=h,this.h2=c}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=e*3981806797&Us|e*36045&xi,t=t*4283543511&Us|((t<<16|e>>>16)*2950163797&Us)>>>16,e^=t>>>1,e=e*444984403&Us|e*60499&xi,t=t*3301882366&Us|((t<<16|e>>>16)*3120437893&Us)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const Ec=Object.freeze({map:null,hash:"",transfer:void 0});var Da,ka,vn,Ie,Rf,Uv;class sm{constructor(){y(this,Rf);y(this,Da,!1);y(this,ka,null);y(this,vn,null);y(this,Ie,new Map);P(this,"onSetModified",null);P(this,"onResetModified",null);P(this,"onAnnotationEditor",null)}getValue(e,t){const s=n(this,Ie).get(e);return s===void 0?t:Object.assign(t,s)}getRawValue(e){return n(this,Ie).get(e)}remove(e){var s;const t=n(this,Ie).get(e);t!==void 0&&(t instanceof St&&n(this,vn).delete(t.annotationElementId),n(this,Ie).delete(e),n(this,Ie).size===0&&this.resetModified(),!n(this,Ie).values().some(i=>i instanceof St)&&((s=this.onAnnotationEditor)==null||s.call(this,null)))}setValue(e,t){var r;const s=n(this,Ie).get(e);let i=!1;if(s!==void 0)for(const[a,o]of Object.entries(t))s[a]!==o&&(i=!0,s[a]=o);else i=!0,n(this,Ie).set(e,t);i&&b(this,Rf,Uv).call(this),t instanceof St&&((n(this,vn)||g(this,vn,new Map)).set(t.annotationElementId,t),(r=this.onAnnotationEditor)==null||r.call(this,t.constructor._type))}has(e){return n(this,Ie).has(e)}get size(){return n(this,Ie).size}resetModified(){var e;n(this,Da)&&(g(this,Da,!1),(e=this.onResetModified)==null||e.call(this))}get print(){return new Hv(this)}get serializable(){if(n(this,Ie).size===0)return Ec;const e=new Map,t=new _p,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,Ie)){const l=o instanceof St?o.serialize(!1,i):o;o.page&&(o.pageIndex=o.page._pageIndex,delete o.page),l&&(e.set(a,l),t.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of e.values())a.bitmap&&s.push(a.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:s}:Ec}get editorStats(){let e=null;const t=new Map;let s=0,i=0;for(const r of n(this,Ie).values()){if(!(r instanceof St)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const a=r.telemetryFinalData;if(!a)continue;const{type:o}=a;t.getOrInsertComputed(o,()=>Object.getPrototypeOf(r).constructor),e||(e=Object.create(null));const l=e[o]||(e[o]=new Map);for(const[h,c]of Object.entries(a)){if(h==="type")continue;const u=l.getOrInsertComputed(h,ep);u.set(c,(u.get(c)??0)+1)}}if((i>0||s>0)&&(e||(e=Object.create(null)),e.comments={deleted:i,edited:s}),!e)return null;for(const[r,a]of t)e[r]=a.computeTelemetryFinalData(e[r]);return e}resetModifiedIds(){g(this,ka,null)}updateEditor(e,t){var i;const s=(i=n(this,vn))==null?void 0:i.get(e);return s?(s.updateFromAnnotationLayer(t),!0):!1}getEditor(e){var t;return((t=n(this,vn))==null?void 0:t.get(e))||null}get modifiedIds(){if(n(this,ka))return n(this,ka);const e=[];if(n(this,vn))for(const s of n(this,vn).values())s.serialize()&&e.push(s.annotationElementId);let t="";if(e.length){const s=new _p;s.update(e.join(",")),t=s.hexdigest()}return g(this,ka,{ids:new Set(e),hash:t})}[Symbol.iterator](){return n(this,Ie).entries()}}Da=new WeakMap,ka=new WeakMap,vn=new WeakMap,Ie=new WeakMap,Rf=new WeakSet,Uv=function(){var e;n(this,Da)||(g(this,Da,!0),(e=this.onSetModified)==null||e.call(this))};var qc;class Hv extends sm{constructor(t){super();y(this,qc,Ec);const{serializable:s}=t;if(s===Ec)return;const{map:i,hash:r,transfer:a}=s,o=structuredClone(i,a?{transfer:a}:null);g(this,qc,{map:o,hash:r,transfer:[]})}get print(){bt("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,qc)}get modifiedIds(){return st(this,"modifiedIds",{ids:new Set,hash:""})}}qc=new WeakMap;lt(7588);const Qo="__forcedDependency",{floor:Cm,ceil:Im}=Math;function Pm(d,e,t,s,i,r){d[e*4+0]=Math.min(d[e*4+0],t),d[e*4+1]=Math.min(d[e*4+1],s),d[e*4+2]=Math.max(d[e*4+2],i),d[e*4+3]=Math.max(d[e*4+3],r)}function Yb(d,e,t,s,i){let r;d?(d<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=d,i[2]*=d,e<0&&(r=i[1],i[1]=i[3],i[3]=r),i[1]*=e,i[3]*=e):i.fill(0),i[0]+=t,i[1]+=s,i[2]+=t,i[3]+=s}const zp=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var Pl,Er;class Kb{constructor(e,t){y(this,Pl);y(this,Er);g(this,Pl,e),g(this,Er,t)}get length(){return n(this,Pl).length}isEmpty(e){return n(this,Pl)[e]===zp}minX(e){return n(this,Er)[e*4+0]/256}minY(e){return n(this,Er)[e*4+1]/256}maxX(e){return(n(this,Er)[e*4+2]+1)/256}maxY(e){return(n(this,Er)[e*4+3]+1)/256}}Pl=new WeakMap,Er=new WeakMap;const Mm=(d,e)=>d==null?void 0:d.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));var yn,Et,Gt,La,Fa,Na,He,td,Wp;class Jb{constructor(e,t){y(this,td);y(this,yn,[[1,0,0,1,0,0]]);y(this,Et,[-1/0,-1/0,1/0,1/0]);y(this,Gt,new Float64Array(zn));P(this,"_pendingBBoxIdx",-1);y(this,La);y(this,Fa);y(this,Na);y(this,He);P(this,"_savesStack",[]);P(this,"_markedContentStack",[]);g(this,La,e.width),g(this,Fa,e.height),b(this,td,Wp).call(this,t)}growOperationsCount(e){e>=n(this,He).length&&b(this,td,Wp).call(this,e,n(this,He))}get clipBox(){return n(this,Et)}save(e){return g(this,Et,{__proto__:n(this,Et)}),this._savesStack.push(e),this}restore(e,t){const s=Object.getPrototypeOf(n(this,Et));if(s===null)return this;g(this,Et,s);const i=this._savesStack.pop();return i!==void 0&&(t==null||t(i,e),n(this,He)[e]=n(this,He)[i]),this}recordOpenMarker(e){return this._savesStack.push(e),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(e,t){const s=this._savesStack.pop();return s!==void 0&&(t==null||t(s,e),n(this,He)[e]=n(this,He)[s]),this}beginMarkedContent(e){return this._markedContentStack.push(e),this}endMarkedContent(e,t){const s=this._markedContentStack.pop();return s!==void 0&&(t==null||t(s,e),n(this,He)[e]=n(this,He)[s]),this}pushBaseTransform(e){return n(this,yn).push(H.multiplyByDOMMatrix(n(this,yn).at(-1),e.getTransform())),this}popBaseTransform(){return n(this,yn).length>1&&n(this,yn).pop(),this}resetBBox(e){return this._pendingBBoxIdx!==e&&(this._pendingBBoxIdx=e,n(this,Gt).set(zn,0)),this}recordClipBox(e,t,s,i,r,a){const o=H.multiplyByDOMMatrix(n(this,yn).at(-1),t.getTransform()),l=zn.slice();H.axialAlignedBoundingBox([s,r,i,a],o,l);const h=H.intersect(n(this,Et),l);return h?(n(this,Et)[0]=h[0],n(this,Et)[1]=h[1],n(this,Et)[2]=h[2],n(this,Et)[3]=h[3]):(n(this,Et)[0]=n(this,Et)[1]=1/0,n(this,Et)[2]=n(this,Et)[3]=-1/0),this}recordBBox(e,t,s,i,r,a){const o=n(this,Et);if(o[0]===1/0)return this;const l=H.multiplyByDOMMatrix(n(this,yn).at(-1),t.getTransform());if(o[0]===-1/0)return H.axialAlignedBoundingBox([s,r,i,a],l,n(this,Gt)),this;const h=zn.slice();return H.axialAlignedBoundingBox([s,r,i,a],l,h),n(this,Gt)[0]=Ht(h[0],o[0],n(this,Gt)[0]),n(this,Gt)[1]=Ht(h[1],o[1],n(this,Gt)[1]),n(this,Gt)[2]=Ht(h[2],n(this,Gt)[2],o[2]),n(this,Gt)[3]=Ht(h[3],n(this,Gt)[3],o[3]),this}recordFullPageBBox(e){return n(this,Gt)[0]=Math.max(0,n(this,Et)[0]),n(this,Gt)[1]=Math.max(0,n(this,Et)[1]),n(this,Gt)[2]=Math.min(n(this,La),n(this,Et)[2]),n(this,Gt)[3]=Math.min(n(this,Fa),n(this,Et)[3]),this}recordOperation(e,t=!1,s){if(this._pendingBBoxIdx!==e)return this;const i=Cm(n(this,Gt)[0]*256/n(this,La)),r=Cm(n(this,Gt)[1]*256/n(this,Fa)),a=Im(n(this,Gt)[2]*256/n(this,La)),o=Im(n(this,Gt)[3]*256/n(this,Fa));if(Pm(n(this,Na),e,i,r,a,o),s)for(const l of s)for(const h of l)h!==e&&Pm(n(this,Na),h,i,r,a,o);return t||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(e){return this._pendingBBoxIdx===e&&(this._pendingBBoxIdx=-1,n(this,Et)[0]=Math.max(n(this,Et)[0],n(this,Gt)[0]),n(this,Et)[1]=Math.max(n(this,Et)[1],n(this,Gt)[1]),n(this,Et)[2]=Math.min(n(this,Et)[2],n(this,Gt)[2]),n(this,Et)[3]=Math.min(n(this,Et)[3],n(this,Gt)[3])),this}take(){return new Kb(n(this,He),n(this,Na))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,s){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,s,i=1,r=0,a=0,o){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}}yn=new WeakMap,Et=new WeakMap,Gt=new WeakMap,La=new WeakMap,Fa=new WeakMap,Na=new WeakMap,He=new WeakMap,td=new WeakSet,Wp=function(e,t){const s=new ArrayBuffer(e*4);g(this,Na,new Uint8ClampedArray(s)),g(this,He,new Uint32Array(s)),t&&t.length>0?(n(this,He).set(t),n(this,He).fill(zp,t.length)):n(this,He).fill(zp)};var as,os,Ba,ai,Ml,Sr,xr,Rt;class Qb{constructor(e,t=!1){y(this,as,{__proto__:null});y(this,os,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Qo]:[]});y(this,Ba,new Map);y(this,ai,new Set);y(this,Ml,new Map);y(this,Sr);y(this,xr);y(this,Rt);g(this,Rt,e),t&&(g(this,Sr,new Map),g(this,xr,(s,i)=>{Mm(n(this,Sr),i).dependencies.add(s)}))}get clipBox(){return n(this,Rt).clipBox}growOperationsCount(e){n(this,Rt).growOperationsCount(e)}save(e){return g(this,as,{__proto__:n(this,as)}),g(this,os,{__proto__:n(this,os),transform:{__proto__:n(this,os).transform},moveText:{__proto__:n(this,os).moveText},sameLineText:{__proto__:n(this,os).sameLineText},[Qo]:{__proto__:n(this,os)[Qo]}}),n(this,Rt).save(e),this}restore(e){n(this,Rt).restore(e,n(this,xr));const t=Object.getPrototypeOf(n(this,as));return t===null?this:(g(this,as,t),g(this,os,Object.getPrototypeOf(n(this,os))),this)}recordOpenMarker(e){return n(this,Rt).recordOpenMarker(e,n(this,xr)),this}getOpenMarker(){return n(this,Rt).getOpenMarker()}recordCloseMarker(e){return n(this,Rt).recordCloseMarker(e,n(this,xr)),this}beginMarkedContent(e){return n(this,Rt).beginMarkedContent(e),this}endMarkedContent(e){return n(this,Rt).endMarkedContent(e,n(this,xr)),this}pushBaseTransform(e){return n(this,Rt).pushBaseTransform(e),this}popBaseTransform(){return n(this,Rt).popBaseTransform(),this}recordSimpleData(e,t){return n(this,as)[e]=t,this}recordIncrementalData(e,t){return n(this,os)[e].push(t),this}resetIncrementalData(e,t){return n(this,os)[e].length=0,this}recordNamedData(e,t){return n(this,Ba).set(e,t),this}recordSimpleDataFromNamed(e,t,s){n(this,as)[e]=n(this,Ba).get(t)??s}recordFutureForcedDependency(e,t){return this.recordIncrementalData(Qo,t),this}inheritSimpleDataAsFutureForcedDependencies(e){for(const t of e)t in n(this,as)&&this.recordFutureForcedDependency(t,n(this,as)[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of n(this,ai))this.recordFutureForcedDependency(Qo,e);return this}resetBBox(e){return n(this,Rt).resetBBox(e),this}recordClipBox(e,t,s,i,r,a){return n(this,Rt).recordClipBox(e,t,s,i,r,a),this}recordBBox(e,t,s,i,r,a){return n(this,Rt).recordBBox(e,t,s,i,r,a),this}recordCharacterBBox(e,t,s,i=1,r=0,a=0,o){const l=s.bbox;let h,c;if(l&&(h=l[2]!==l[0]&&l[3]!==l[1]&&n(this,Ml).get(s),h!==!1&&(c=[0,0,0,0],H.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||r!==0||a!==0)&&Yb(i,-i,r,a,c),h)))return this.recordBBox(e,t,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(e);const u=o();return l&&c&&h===void 0&&(h=c[0]<=r-u.actualBoundingBoxLeft&&c[2]>=r+u.actualBoundingBoxRight&&c[1]<=a-u.actualBoundingBoxAscent&&c[3]>=a+u.actualBoundingBoxDescent,n(this,Ml).set(s,h),h)?this.recordBBox(e,t,c[0],c[2],c[1],c[3]):this.recordBBox(e,t,r-u.actualBoundingBoxLeft,r+u.actualBoundingBoxRight,a-u.actualBoundingBoxAscent,a+u.actualBoundingBoxDescent)}recordFullPageBBox(e){return n(this,Rt).recordFullPageBBox(e),this}getSimpleIndex(e){return n(this,as)[e]}recordDependencies(e,t){const s=n(this,ai),i=n(this,as),r=n(this,os);for(const a of t)a in n(this,as)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}recordNamedDependency(e,t){return n(this,Ba).has(t)&&n(this,ai).add(n(this,Ba).get(t)),this}recordOperation(e,t=!1){if(this.recordDependencies(e,[Qo]),n(this,Sr)){const i=Mm(n(this,Sr),e),{dependencies:r}=i;n(this,ai).forEach(r.add,r),n(this,Rt)._savesStack.forEach(r.add,r),n(this,Rt)._markedContentStack.forEach(r.add,r),r.delete(e),i.isRenderingOperation=!0}const s=!t&&e===n(this,Rt)._pendingBBoxIdx;return n(this,Rt).recordOperation(e,t,[n(this,ai),n(this,Rt)._savesStack,n(this,Rt)._markedContentStack]),s&&n(this,ai).clear(),this}recordShowTextOperation(e,t=!1){const s=Array.from(n(this,ai));this.recordOperation(e,t),this.recordIncrementalData("sameLineText",e);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(e,t=!1){const s=!t&&e===n(this,Rt)._pendingBBoxIdx;return n(this,Rt).bboxToClipBoxDropOperation(e),s&&n(this,ai).clear(),this}take(){return n(this,Ml).clear(),n(this,Rt).take()}takeDebugMetadata(){return n(this,Sr)}}as=new WeakMap,os=new WeakMap,Ba=new WeakMap,ai=new WeakMap,Ml=new WeakMap,Sr=new WeakMap,xr=new WeakMap,Rt=new WeakMap;var Dt,qt,oi,Ol,Rl;const dm=class dm{constructor(e,t,s){y(this,Dt);y(this,qt);y(this,oi);y(this,Ol,0);y(this,Rl,0);if(e instanceof dm&&n(e,oi)===!!s)return e;g(this,Dt,e),g(this,qt,t),g(this,oi,!!s)}get clipBox(){return n(this,Dt).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(e){return $t(this,Rl)._++,n(this,Dt).save(n(this,qt)),this}restore(e){return n(this,Rl)>0&&(n(this,Dt).restore(n(this,qt)),$t(this,Rl)._--),this}recordOpenMarker(e){return $t(this,Ol)._++,this}getOpenMarker(){return n(this,Ol)>0?n(this,qt):n(this,Dt).getOpenMarker()}recordCloseMarker(e){return $t(this,Ol)._--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return n(this,Dt).pushBaseTransform(e),this}popBaseTransform(){return n(this,Dt).popBaseTransform(),this}recordSimpleData(e,t){return n(this,Dt).recordSimpleData(e,n(this,qt)),this}recordIncrementalData(e,t){return n(this,Dt).recordIncrementalData(e,n(this,qt)),this}resetIncrementalData(e,t){return n(this,Dt).resetIncrementalData(e,n(this,qt)),this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,s){return n(this,Dt).recordSimpleDataFromNamed(e,t,n(this,qt)),this}recordFutureForcedDependency(e,t){return n(this,Dt).recordFutureForcedDependency(e,n(this,qt)),this}inheritSimpleDataAsFutureForcedDependencies(e){return n(this,Dt).inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,Dt).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return n(this,oi)||n(this,Dt).resetBBox(n(this,qt)),this}recordClipBox(e,t,s,i,r,a){return n(this,oi)||n(this,Dt).recordClipBox(n(this,qt),t,s,i,r,a),this}recordBBox(e,t,s,i,r,a){return n(this,oi)||n(this,Dt).recordBBox(n(this,qt),t,s,i,r,a),this}recordCharacterBBox(e,t,s,i,r,a,o){return n(this,oi)||n(this,Dt).recordCharacterBBox(n(this,qt),t,s,i,r,a,o),this}recordFullPageBBox(e){return n(this,oi)||n(this,Dt).recordFullPageBBox(n(this,qt)),this}getSimpleIndex(e){return n(this,Dt).getSimpleIndex(e)}recordDependencies(e,t){return n(this,Dt).recordDependencies(n(this,qt),t),this}recordNamedDependency(e,t){return n(this,Dt).recordNamedDependency(n(this,qt),t),this}recordOperation(e){return n(this,Dt).recordOperation(n(this,qt),!0),this}recordShowTextOperation(e){return n(this,Dt).recordShowTextOperation(n(this,qt),!0),this}bboxToClipBoxDropOperation(e){return n(this,oi)||n(this,Dt).bboxToClipBoxDropOperation(n(this,qt),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};Dt=new WeakMap,qt=new WeakMap,oi=new WeakMap,Ol=new WeakMap,Rl=new WeakMap;let Sc=dm;const Hs={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]};var Ua,Ha,$a,ja,Ga,ed;const gc=class gc{constructor(e){y(this,Ua);y(this,Ha);y(this,$a,4);y(this,ja,0);y(this,Ga,new(n(gc,ed))(n(this,$a)*6));g(this,Ua,e.width),g(this,Ha,e.height)}record(e,t,s,i){if(n(this,ja)===n(this,$a)){g(this,$a,n(this,$a)*2);const o=new(n(gc,ed))(n(this,$a)*6);o.set(n(this,Ga)),g(this,Ga,o)}const r=Ut(e);let a;if(i[0]!==1/0){const o=zn.slice();H.axialAlignedBoundingBox([0,-s,t,0],r,o);const l=H.intersect(i,o);if(!l)return;const[h,c,u,f]=l;if(h!==o[0]||c!==o[1]||u!==o[2]||f!==o[3]){const p=Math.atan2(r[1],r[0]),m=Math.abs(Math.sin(p)),v=Math.abs(Math.cos(p));if(m<1e-6||v<1e-6||Math.abs(m-v)<1e-6)a=[h,c,h,f,u,c];else{const A=u-h,w=f-c,E=m*m,S=v*v,T=v*m,x=S-E,C=(w*S-A*T)/x,I=(w*T-A*E)/x;a=[h+I,c,h,c+C,u,f-C]}}}a||(a=[0,-s,0,0,t,-s],H.applyTransform(a,r,0),H.applyTransform(a,r,2),H.applyTransform(a,r,4)),a[0]/=n(this,Ua),a[1]/=n(this,Ha),a[2]/=n(this,Ua),a[3]/=n(this,Ha),a[4]/=n(this,Ua),a[5]/=n(this,Ha),n(this,Ga).set(a,n(this,ja)*6),$t(this,ja)._++}take(){return n(this,Ga).subarray(0,n(this,ja)*6)}};Ua=new WeakMap,Ha=new WeakMap,$a=new WeakMap,ja=new WeakMap,Ga=new WeakMap,ed=new WeakMap,y(gc,ed,It.isFloat16ArraySupported?Float16Array:Float32Array);let Vp=gc;var Dl,li,Df,$v;class Zb{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){y(this,Df);y(this,Dl,new Set);y(this,li,null);this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){const t=b(this,Df,$v).call(this);t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);if(this.nativeFontFaces.clear(),n(this,Dl).clear(),n(this,li)){const{adoptedStyleSheets:e}=this._document;e!=null&&e.includes(n(this,li))&&(this._document.adoptedStyleSheets=e.filter(t=>t!==n(this,li))),g(this,li,null)}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:s}){if(!(!e||n(this,Dl).has(e.loadedName))){if(Jt(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=e,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,Dl).add(i),s==null||s(e)}catch{it(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}bt("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const s=e.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw it(`Failed to load font '${s.family}': '${i}'.`),e.disableFontFace=!0,i}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){var t;const e=!!((t=this._document)!=null&&t.fonts);return st(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return st(this,"isSyncFontLoadingSupported",ks||It.platform.isFirefox)}_queueLoadingCallback(e){function t(){for(Jt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:t,callback:e};return s.push(i),i}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return st(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function s(x,C){return x.charCodeAt(C)<<24|x.charCodeAt(C+1)<<16|x.charCodeAt(C+2)<<8|x.charCodeAt(C+3)&255}function i(x){return String.fromCharCode(x>>24&255,x>>16&255,x>>8&255,x&255)}function r(x,C,I,O){const M=x.substring(0,C),R=x.substring(C+I);return M+O+R}let a,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const h=l.getContext("2d");let c=0;function u(x,C){if(++c>30){it("Load test font never loaded."),C();return}if(h.font="30px "+x,h.fillText(".",0,20),h.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(u.bind(null,x,C))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let p=this._loadTestFont;p=r(p,976,f.length,f);const v=16,A=1482184792;let w=s(p,v);for(a=0,o=f.length-3;a<o;a+=4)w=w-A+s(f,a)|0;a<f.length&&(w=w-A+s(f+"XXX",a)|0),p=r(p,v,4,i(w));const E=`url(data:font/opentype;base64,${btoa(p)});`,S=`@font-face {font-family:"${f}";src:${E}}`;this.insertRule(S);const T=this._document.createElement("div");T.style.visibility="hidden",T.style.width=T.style.height="10px",T.style.position="absolute",T.style.top=T.style.left="0px";for(const x of[e.loadedName,f]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=x,T.append(C)}this._document.body.append(T),u(f,()=>{T.remove(),t.complete()})}}Dl=new WeakMap,li=new WeakMap,Df=new WeakSet,$v=function(){var t;if(n(this,li))return n(this,li);const e=((t=this._document.defaultView)==null?void 0:t.CSSStyleSheet)||globalThis.CSSStyleSheet;if(!this.styleElement&&e){const{adoptedStyleSheets:s}=this._document;if(s){const i=new e;return s.push(i),g(this,li,i)}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),g(this,li,this.styleElement.sheet)};var kt;class qb{constructor(e,t=null,s,i){P(this,"compiledGlyphs",Object.create(null));y(this,kt);g(this,kt,e),this._inspectFont=t,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(t=this._inspectFont)==null||t.call(this,this),e}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let t;if(!this.cssFontInfo)t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}return(s=this._inspectFont)==null||s.call(this,this,e),t}getPathGenerator(e,t){if(this.compiledGlyphs[t]!==void 0)return this.compiledGlyphs[t];const s=this.loadedName+"_path_"+t;let i;try{i=e.get(s)}catch(a){it(`getPathGenerator - ignoring character: "${a}".`)}const r=nv(i==null?void 0:i.path);return this.fontExtraProperties||e.delete(s),this.compiledGlyphs[t]=r}get black(){return n(this,kt).black}get bold(){return n(this,kt).bold}get disableFontFace(){return n(this,kt).disableFontFace}set disableFontFace(e){st(this,"disableFontFace",!!e)}get fontExtraProperties(){return n(this,kt).fontExtraProperties}get isInvalidPDFjsFont(){return n(this,kt).isInvalidPDFjsFont}get isType3Font(){return n(this,kt).isType3Font}get italic(){return n(this,kt).italic}get missingFile(){return n(this,kt).missingFile}get remeasure(){return n(this,kt).remeasure}get vertical(){return n(this,kt).vertical}get ascent(){return n(this,kt).ascent}get defaultWidth(){return n(this,kt).defaultWidth}get descent(){return n(this,kt).descent}get bbox(){return n(this,kt).bbox}get fontMatrix(){return n(this,kt).fontMatrix}get fallbackName(){return n(this,kt).fallbackName}get loadedName(){return n(this,kt).loadedName}get mimetype(){return n(this,kt).mimetype}get name(){return n(this,kt).name}get data(){return n(this,kt).data}clearData(){n(this,kt).clearData()}get cssFontInfo(){return n(this,kt).cssFontInfo}get systemFontInfo(){return n(this,kt).systemFontInfo}get defaultVMetrics(){return n(this,kt).defaultVMetrics}}kt=new WeakMap;class jv{}P(jv,"strings",["fontFamily","fontWeight","italicAngle"]);class Gv{}P(Gv,"strings",["css","loadedName","baseFontName","src"]);const Ne=class Ne{};P(Ne,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),P(Ne,"numbers",["ascent","defaultWidth","descent"]),P(Ne,"strings",["fallbackName","loadedName","mimetype","name"]),P(Ne,"OFFSET_NUMBERS",Math.ceil(Ne.bools.length*2/8)),P(Ne,"OFFSET_BBOX",Ne.OFFSET_NUMBERS+Ne.numbers.length*8),P(Ne,"OFFSET_FONT_MATRIX",Ne.OFFSET_BBOX+1+2*4),P(Ne,"OFFSET_DEFAULT_VMETRICS",Ne.OFFSET_FONT_MATRIX+1+8*6),P(Ne,"OFFSET_STRINGS",Ne.OFFSET_DEFAULT_VMETRICS+1+2*3);let us=Ne;class Ze{}P(Ze,"KIND",0),P(Ze,"HAS_BBOX",1),P(Ze,"HAS_BACKGROUND",2),P(Ze,"SHADING_TYPE",3),P(Ze,"N_COORD",4),P(Ze,"N_COLOR",8),P(Ze,"N_STOP",12),P(Ze,"N_FIGURES",16);var sd,kf,kl,Ll,Du;class tA{constructor(e){y(this,Ll);y(this,sd);y(this,kf,new TextDecoder);y(this,kl);g(this,sd,e),g(this,kl,new DataView(e))}get fontFamily(){return b(this,Ll,Du).call(this,0)}get fontWeight(){return b(this,Ll,Du).call(this,1)}get italicAngle(){return b(this,Ll,Du).call(this,2)}}sd=new WeakMap,kf=new WeakMap,kl=new WeakMap,Ll=new WeakSet,Du=function(e){Jt(e<jv.strings.length,"Invalid string index");let t=0;for(let i=0;i<e;i++)t+=n(this,kl).getUint32(t)+4;const s=n(this,kl).getUint32(t);return n(this,kf).decode(new Uint8Array(n(this,sd),t+4,s))};var _a,Fl,Fi,za,Kh;class eA{constructor(e){y(this,za);y(this,_a);y(this,Fl,new TextDecoder);y(this,Fi);g(this,_a,e),g(this,Fi,new DataView(e))}get guessFallback(){return n(this,Fi).getUint8(0)!==0}get css(){return b(this,za,Kh).call(this,0)}get loadedName(){return b(this,za,Kh).call(this,1)}get baseFontName(){return b(this,za,Kh).call(this,2)}get src(){return b(this,za,Kh).call(this,3)}get style(){let e=1;e+=4+n(this,Fi).getUint32(e);const t=n(this,Fi).getUint32(e),s=n(this,Fl).decode(new Uint8Array(n(this,_a),e+4,t));e+=4+t;const i=n(this,Fi).getUint32(e),r=n(this,Fl).decode(new Uint8Array(n(this,_a),e+4,i));return{style:s,weight:r}}}_a=new WeakMap,Fl=new WeakMap,Fi=new WeakMap,za=new WeakSet,Kh=function(e){Jt(e<Gv.strings.length,"Invalid string index");let t=5;for(let i=0;i<e;i++)t+=n(this,Fi).getUint32(t)+4;const s=n(this,Fi).getUint32(t);return n(this,Fl).decode(new Uint8Array(n(this,_a),t+4,s))};var hi,Lf,ie,Ct,si,ku,Lu,Jh,Xp;class sA{constructor({buffer:e,extra:t}){y(this,Ct);y(this,hi);y(this,Lf,new TextDecoder);y(this,ie);g(this,hi,e),g(this,ie,new DataView(e)),t&&Object.assign(this,t)}get black(){return b(this,Ct,si).call(this,0)}get bold(){return b(this,Ct,si).call(this,1)}get disableFontFace(){return b(this,Ct,si).call(this,2)}get fontExtraProperties(){return b(this,Ct,si).call(this,3)}get isInvalidPDFjsFont(){return b(this,Ct,si).call(this,4)}get isType3Font(){return b(this,Ct,si).call(this,5)}get italic(){return b(this,Ct,si).call(this,6)}get missingFile(){return b(this,Ct,si).call(this,7)}get remeasure(){return b(this,Ct,si).call(this,8)}get vertical(){return b(this,Ct,si).call(this,9)}get ascent(){return b(this,Ct,ku).call(this,0)}get defaultWidth(){return b(this,Ct,ku).call(this,1)}get descent(){return b(this,Ct,ku).call(this,2)}get bbox(){return b(this,Ct,Lu).call(this,us.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return b(this,Ct,Lu).call(this,us.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return b(this,Ct,Lu).call(this,us.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return b(this,Ct,Jh).call(this,0)}get loadedName(){return b(this,Ct,Jh).call(this,1)}get mimetype(){return b(this,Ct,Jh).call(this,2)}get name(){return b(this,Ct,Jh).call(this,3)}get data(){const{offset:e,length:t}=b(this,Ct,Xp).call(this);return t===0?void 0:new Uint8Array(n(this,hi),e+4,t)}clearData(){const{offset:e,length:t}=b(this,Ct,Xp).call(this);t!==0&&(n(this,ie).setUint32(e,0),g(this,hi,new Uint8Array(n(this,hi),0,e+4).slice().buffer),g(this,ie,new DataView(n(this,hi))))}get cssFontInfo(){let e=us.OFFSET_STRINGS;const t=n(this,ie).getUint32(e);e+=4+t;const s=n(this,ie).getUint32(e);e+=4+s;const i=n(this,ie).getUint32(e);if(i===0)return null;const r=new Uint8Array(i);return r.set(new Uint8Array(n(this,hi),e+4,i)),new tA(r.buffer)}get systemFontInfo(){let e=us.OFFSET_STRINGS;const t=n(this,ie).getUint32(e);e+=4+t;const s=n(this,ie).getUint32(e);if(s===0)return null;const i=new Uint8Array(s);return i.set(new Uint8Array(n(this,hi),e+4,s)),new eA(i.buffer)}}hi=new WeakMap,Lf=new WeakMap,ie=new WeakMap,Ct=new WeakSet,si=function(e){Jt(e<us.bools.length,"Invalid boolean index");const t=Math.floor(e/4),s=e*2%8,i=n(this,ie).getUint8(t)>>s&3;return i===0?void 0:i===2},ku=function(e){return Jt(e<us.numbers.length,"Invalid number index"),n(this,ie).getFloat64(us.OFFSET_NUMBERS+e*8)},Lu=function(e,t,s,i){const r=n(this,ie).getUint8(e);if(r===0)return;Jt(r===t,"Invalid array length."),e+=1;const a=new Array(r);for(let o=0;o<r;o++)a[o]=n(this,ie)[s](e,!0),e+=i;return a},Jh=function(e){Jt(e<us.strings.length,"Invalid string index");let t=us.OFFSET_STRINGS+4;for(let i=0;i<e;i++)t+=n(this,ie).getUint32(t)+4;const s=n(this,ie).getUint32(t);return n(this,Lf).decode(new Uint8Array(n(this,hi),t+4,s))},Xp=function(){let e=us.OFFSET_STRINGS;const t=n(this,ie).getUint32(e);e+=4+t;const s=n(this,ie).getUint32(e);e+=4+s;const i=n(this,ie).getUint32(e);e+=4+i;const r=n(this,ie).getUint32(e);return{offset:e,length:r}};class iA{constructor(e){this.buffer=e,this.view=new DataView(e),this.data=new Uint8Array(e)}getIR(){const e=this.view,t=this.data[Ze.KIND],s=!!this.data[Ze.HAS_BBOX],i=!!this.data[Ze.HAS_BACKGROUND],r=e.getUint32(Ze.N_COORD,!0),a=e.getUint32(Ze.N_COLOR,!0),o=e.getUint32(Ze.N_STOP,!0);let l=20;const h=new Float32Array(this.buffer,l,r*2);l+=r*8;const c=new Uint8Array(this.buffer,l,a*4);l+=a*4;const u=[];for(let m=0;m<o;++m){const v=e.getFloat32(l,!0);l+=4;const A=e.getUint32(l,!0);l+=4,u.push([v,`#${A.toString(16).padStart(6,"0")}`])}let f=null;if(s){f=[];for(let m=0;m<4;++m)f.push(e.getFloat32(l,!0)),l+=4}let p=null;if(i&&(p=new Uint8Array(this.buffer,l,3),l+=3),t===1)return["RadialAxial","axial",f,u,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(t===2)return["RadialAxial","radial",f,u,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(t===3){const m=this.data[Ze.SHADING_TYPE];let v=null;if(h.length>0){v=zn.slice();for(let A=0,w=h.length;A<w;A+=2)H.pointBoundingBox(h[A],h[A+1],v)}return["Mesh",m,h,c,r,v,f,p]}throw new Error(`Unsupported pattern kind: ${t}`)}}var Nl;class nA{constructor(e){y(this,Nl);g(this,Nl,e)}get path(){return It.isFloat16ArraySupported?new Float16Array(n(this,Nl)):new Float32Array(n(this,Nl))}}Nl=new WeakMap;function rA(d){if(d instanceof URL)return d;if(typeof d=="string"){if(ks){if(/^[a-z][a-z0-9\-+.]+:/i.test(d))return new URL(d);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(d))}const e=URL.parse(d,window.location);if(e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function aA(d){if(ks&&typeof Buffer<"u"&&d instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength)return d;if(typeof d=="string")return tp(d);if(d instanceof ArrayBuffer||ArrayBuffer.isView(d)||typeof d=="object"&&!isNaN(d==null?void 0:d.length))return new Uint8Array(d);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function yu(d){if(typeof d!="string")return null;if(d.endsWith("/"))return d;throw new Error(`Invalid factory url: "${d}" must include trailing slash.`)}const Yp=d=>typeof d=="object"&&Number.isInteger(d==null?void 0:d.num)&&d.num>=0&&Number.isInteger(d==null?void 0:d.gen)&&d.gen>=0,oA=d=>typeof d=="object"&&typeof(d==null?void 0:d.name)=="string",_v=$b.bind(null,Yp,oA);var bn,Ff;class lA{constructor(){y(this,bn,new Map);y(this,Ff,Promise.resolve())}postMessage(e,t){const s={data:structuredClone(e,t?{transfer:t}:null)};n(this,Ff).then(()=>{for(const[i]of n(this,bn))i.call(this,s)})}addEventListener(e,t,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){it("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(e,t);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,bn).set(t,i)}removeEventListener(e,t){const s=n(this,bn).get(t);s==null||s(),n(this,bn).delete(t)}terminate(){for(const[,e]of n(this,bn))e==null||e();n(this,bn).clear()}}bn=new WeakMap,Ff=new WeakMap;lt(1689);const bu={DATA:1,ERROR:2},oe={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Om(){}function ss(d){if(d instanceof Xn||d instanceof pf||d instanceof ff||d instanceof yc||d instanceof mp)return d;switch(d instanceof Error||typeof d=="object"&&d!==null||bt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),d.name){case"AbortException":return new Xn(d.message);case"InvalidPDFException":return new pf(d.message);case"PasswordException":return new ff(d.message,d.code);case"ResponseException":return new yc(d.message,d.status,d.missing);case"UnknownErrorException":return new mp(d.message,d.details)}return new mp(d.message,d.toString())}var Bl,ei,zv,Wv,Vv,Fu;class Qh{constructor(e,t,s){y(this,ei);y(this,Bl,new AbortController);this.sourceName=e,this.targetName=t,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",b(this,ei,zv).bind(this),{signal:n(this,Bl).signal})}on(e,t){const s=this.actionHandler;if(s[e])throw new Error(`There is already an actionName called "${e}"`);s[e]=t}send(e,t,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},s)}sendWithPromise(e,t,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(e,t,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:e,streamId:r,data:t,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:oe.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{Jt(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:oe.CANCEL,streamId:r,reason:ss(h)}),c.promise}},s)}destroy(){var e;(e=n(this,Bl))==null||e.abort(),g(this,Bl,null)}}Bl=new WeakMap,ei=new WeakSet,zv=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){b(this,ei,Vv).call(this,e);return}if(e.callback){const s=e.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],e.callback===bu.DATA)i.resolve(e.data);else if(e.callback===bu.ERROR)i.reject(ss(e.reason));else throw new Error("Unexpected callback case");return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const s=this.sourceName,i=e.sourceName,r=this.comObj;Promise.try(t,e.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:bu.DATA,callbackId:e.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:bu.ERROR,callbackId:e.callbackId,reason:ss(a)})});return}if(e.streamId){b(this,ei,Wv).call(this,e);return}t(e.data)},Wv=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,r=this.comObj,a=this,o=this.actionHandler[e.action],l={enqueue(h,c=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=c,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:oe.ENQUEUE,streamId:t,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:oe.CLOSE,streamId:t}),delete a.streamSinks[t])},error(h){Jt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:oe.ERROR,streamId:t,reason:ss(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[t]=l,Promise.try(o,e.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:oe.START_COMPLETE,streamId:t,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:oe.START_COMPLETE,streamId:t,reason:ss(h)})})},Vv=function(e){const t=e.streamId,s=this.sourceName,i=e.sourceName,r=this.comObj,a=this.streamControllers[t],o=this.streamSinks[t];switch(e.stream){case oe.START_COMPLETE:e.success?a.startCall.resolve():a.startCall.reject(ss(e.reason));break;case oe.PULL_COMPLETE:e.success?a.pullCall.resolve():a.pullCall.reject(ss(e.reason));break;case oe.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:oe.PULL_COMPLETE,streamId:t,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Om).then(function(){r.postMessage({sourceName:s,targetName:i,stream:oe.PULL_COMPLETE,streamId:t,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:oe.PULL_COMPLETE,streamId:t,reason:ss(h)})});break;case oe.ENQUEUE:if(Jt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(e.chunk);break;case oe.CLOSE:if(Jt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,ei,Fu).call(this,a,t);break;case oe.ERROR:Jt(a,"error should have stream controller"),a.controller.error(ss(e.reason)),b(this,ei,Fu).call(this,a,t);break;case oe.CANCEL_COMPLETE:e.success?a.cancelCall.resolve():a.cancelCall.reject(ss(e.reason)),b(this,ei,Fu).call(this,a,t);break;case oe.CANCEL:if(!o)break;const l=ss(e.reason);Promise.try(o.onCancel||Om,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:oe.CANCEL_COMPLETE,streamId:t,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:oe.CANCEL_COMPLETE,streamId:t,reason:ss(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},Fu=async function(e,t){var s,i,r;await Promise.allSettled([(s=e.startCall)==null?void 0:s.promise,(i=e.pullCall)==null?void 0:i.promise,(r=e.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[t]};var Nf;class Xv{constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:s=null}){y(this,Nf,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=e,this.standardFontDataUrl=t,this.wasmUrl=s}async fetch({kind:e,filename:t}){switch(e){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:bt(`Not implemented: ${e}`)}const s=this[e];if(!s)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const i=`${s}${t}`;return this._fetch(i,e).catch(r=>{throw new Error(`Unable to load ${n(this,Nf)[e]} data at: ${i}`)})}async _fetch(e,t){bt("Abstract method `_fetch` called.")}}Nf=new WeakMap;class Rm extends Xv{async _fetch(e,t){const s=t==="cMapUrl"&&!e.endsWith(".bcmap")?"text":"bytes",i=await sp(e,s);return i instanceof Uint8Array?i:tp(i)}}var id;class Yv{constructor({enableHWA:e=!1}){y(this,id,!1);g(this,id,e)}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(e,t);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,id)})}}reset({canvas:e},t,s){if(!e)throw new Error("Canvas is not specified");if(t<=0||s<=0)throw new Error("Invalid canvas size");e.width=t,e.height=s}destroy(e){const{canvas:t}=e;if(!t)throw new Error("Canvas is not specified");t.width=t.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){bt("Abstract method `_createCanvas` called.")}}id=new WeakMap;class hA extends Yv{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){const s=this._document.createElement("canvas");return s.width=e,s.height=t,s}}class Kv{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addKnockoutFilter(e=0){return"none"}addHighlightHCMFilter(e,t,s,i,r){return"none"}addSelectionHCMFilter(e,t){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(e=null){return null}destroy(e=!1){}}var Wa,Ul,An,Ni,ye,Va,Tr,G,ge,Zh,Zn,Nu,ra,Jv,Kp,aa,qh,tc,Jp,ec,Qv,Zv;class cA extends Kv{constructor({docId:t,ownerDocument:s=globalThis.document}){super();y(this,G);y(this,Wa);y(this,Ul);y(this,An);y(this,Ni);y(this,ye);y(this,Va);y(this,Tr,0);g(this,Ni,t),g(this,ye,s)}addFilter(t){if(!t)return"none";let s=n(this,G,ge).get(t);if(s)return s;const[i,r,a]=b(this,G,Nu).call(this,t),o=t.length===1?i:`${i}${r}${a}`;if(s=n(this,G,ge).get(o),s)return n(this,G,ge).set(t,s),s;const l=`g_${n(this,Ni)}_transfer_map_${$t(this,Tr)._++}`,h=b(this,G,ra).call(this,l);n(this,G,ge).set(t,h),n(this,G,ge).set(o,h);const c=b(this,G,aa).call(this,l);return b(this,G,tc).call(this,i,r,a,c),h}addHCMFilter(t,s){var m;const i=`${t}-${s}`,r="base";let a=n(this,G,Zh).get(r);if((a==null?void 0:a.key)===i||(a?((m=a.filter)==null||m.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,G,Zh).set(r,a)),!t||!s))return a.url;const o=b(this,G,ec).call(this,t);t=H.makeHexColor(...o);const l=b(this,G,ec).call(this,s);if(s=H.makeHexColor(...l),n(this,G,Zn).style.color="",t==="#000000"&&s==="#ffffff"||t===s)return a.url;const h=new Array(256);for(let v=0;v<=255;v++){const A=v/255;h[v]=A<=.03928?A/12.92:((A+.055)/1.055)**2.4}const c=h.join(","),u=`g_${n(this,Ni)}_hcm_filter`,f=a.filter=b(this,G,aa).call(this,u);b(this,G,tc).call(this,c,c,c,f),b(this,G,Kp).call(this,f);const p=(v,A)=>{const w=o[v]/255,E=l[v]/255,S=new Array(A+1);for(let T=0;T<=A;T++)S[T]=w+T/A*(E-w);return S.join(",")};return b(this,G,tc).call(this,p(0,5),p(1,5),p(2,5),f),a.url=b(this,G,ra).call(this,u),a.url}addSelectionHCMFilter(t,s){return this.addHighlightHCMFilter("selection",t,s,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){const s=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return s==="none"||!It.platform.isFirefox?null:{"backdrop-filter":s,"background-color":"transparent"}}addAlphaFilter(t){let s=n(this,G,ge).get(t);if(s)return s;const[i]=b(this,G,Nu).call(this,[t]),r=`alpha_${i}`;if(s=n(this,G,ge).get(r),s)return n(this,G,ge).set(t,s),s;const a=`g_${n(this,Ni)}_alpha_map_${$t(this,Tr)._++}`,o=b(this,G,ra).call(this,a);n(this,G,ge).set(t,o),n(this,G,ge).set(r,o);const l=b(this,G,aa).call(this,a);return b(this,G,Jp).call(this,i,l),o}addLuminosityFilter(t){let s=n(this,G,ge).get(t||"luminosity");if(s)return s;let i,r;if(t?([i]=b(this,G,Nu).call(this,[t]),r=`luminosity_${i}`):r="luminosity",s=n(this,G,ge).get(r),s)return n(this,G,ge).set(t,s),s;const a=`g_${n(this,Ni)}_luminosity_map_${$t(this,Tr)._++}`,o=b(this,G,ra).call(this,a);n(this,G,ge).set(t,o),n(this,G,ge).set(r,o);const l=b(this,G,aa).call(this,a);return b(this,G,Jv).call(this,l),t&&b(this,G,Jp).call(this,i,l),o}addKnockoutFilter(t=0){const s=t>0?Math.min(1/t,1e6):1e6,i=`knockout_${s}`,r=n(this,G,ge).get(i);if(r)return r;const a=`g_${n(this,Ni)}_knockout_filter_${$t(this,Tr)._++}`,o=b(this,G,ra).call(this,a);n(this,G,ge).set(i,o);const l=b(this,G,aa).call(this,a),h=n(this,ye).createElementNS(ps,"feComponentTransfer");l.append(h);const c=n(this,ye).createElementNS(ps,"feFuncA");return c.setAttribute("type","linear"),c.setAttribute("slope",`${s}`),c.setAttribute("intercept","0"),h.append(c),o}addHighlightHCMFilter(t,s,i,r,a){var E;const o=`${s}-${i}-${r}-${a}`;let l=n(this,G,Zh).get(t);if((l==null?void 0:l.key)===o||(l?((E=l.filter)==null||E.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,G,Zh).set(t,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,G,ec).bind(this));let u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[p,m]=[r,a].map(b(this,G,Zv).bind(this));f<u&&([u,f,p,m]=[f,u,m,p]),n(this,G,Zn).style.color="";const v=(S,T,x)=>{const C=new Array(256),I=(f-u)/x,O=S/255,M=(T-S)/(255*x);let R=0;for(let D=0;D<=x;D++){const j=Math.round(u+D*I),F=O+D*M;for(let U=R;U<=j;U++)C[U]=F;R=j+1}for(let D=R;D<256;D++)C[D]=C[R-1];return C.join(",")},A=`g_${n(this,Ni)}_hcm_${t}_filter`,w=l.filter=b(this,G,aa).call(this,A);return b(this,G,Kp).call(this,w),b(this,G,tc).call(this,v(p[0],m[0],5),v(p[1],m[1],5),v(p[2],m[2],5),w),l.url=b(this,G,ra).call(this,A),l.url}destroy(t=!1){var s,i,r,a;t&&((s=n(this,Va))!=null&&s.size)||((i=n(this,An))==null||i.parentNode.parentNode.remove(),g(this,An,null),(r=n(this,Ul))==null||r.clear(),g(this,Ul,null),(a=n(this,Va))==null||a.clear(),g(this,Va,null),g(this,Tr,0))}}Wa=new WeakMap,Ul=new WeakMap,An=new WeakMap,Ni=new WeakMap,ye=new WeakMap,Va=new WeakMap,Tr=new WeakMap,G=new WeakSet,ge=function(){return n(this,Ul)||g(this,Ul,new Map)},Zh=function(){return n(this,Va)||g(this,Va,new Map)},Zn=function(){if(!n(this,An)){const t=n(this,ye).createElement("div"),{style:s}=t;s.colorScheme="only light",s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=n(this,ye).createElementNS(ps,"svg");i.setAttribute("width",0),i.setAttribute("height",0),g(this,An,n(this,ye).createElementNS(ps,"defs")),t.append(i),i.append(n(this,An)),n(this,ye).body.append(t)}return n(this,An)},Nu=function(t){if(t.length===1){const h=t[0],c=new Array(256);for(let f=0;f<256;f++)c[f]=h[f]/255;const u=c.join(",");return[u,u,u]}const[s,i,r]=t,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=i[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},ra=function(t){if(n(this,Wa)===void 0){g(this,Wa,"");const s=n(this,ye).URL;s!==n(this,ye).baseURI&&(pu(s)?it('#createUrl: ignore "data:"-URL for performance reasons.'):g(this,Wa,Zg(s,"")))}return`url(${n(this,Wa)}#${t})`},Jv=function(t){const s=n(this,ye).createElementNS(ps,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(s)},Kp=function(t){const s=n(this,ye).createElementNS(ps,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(s)},aa=function(t){const s=n(this,ye).createElementNS(ps,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",t),n(this,G,Zn).append(s),s},qh=function(t,s,i){const r=n(this,ye).createElementNS(ps,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),t.append(r)},tc=function(t,s,i,r){const a=n(this,ye).createElementNS(ps,"feComponentTransfer");r.append(a),b(this,G,qh).call(this,a,"feFuncR",t),b(this,G,qh).call(this,a,"feFuncG",s),b(this,G,qh).call(this,a,"feFuncB",i)},Jp=function(t,s){const i=n(this,ye).createElementNS(ps,"feComponentTransfer");s.append(i),b(this,G,qh).call(this,i,"feFuncA",t)},ec=function(t){return n(this,G,Zn).style.color=t,$h(getComputedStyle(n(this,G,Zn)).getPropertyValue("color"))},Qv=function(t){return n(this,G,Zn).style.color=t,Hh(getComputedStyle(n(this,G,Zn)).getPropertyValue("color"))},Zv=function(t){const[s,i,r,a]=b(this,G,Qv).call(this,t);if(a===1)return[s,i,r];const[o,l,h]=b(this,G,ec).call(this,"Canvas");return[bp(s,o,a),bp(i,l,a),bp(r,h,a)]};function bp(d,e,t){return Math.round(t*d+(1-t)*e)}var Ym;if(ks){let d;try{const e=process.getBuiltinModule("module").createRequire(import.meta.url);try{d=e("@napi-rs/canvas")}catch(t){it(`Cannot load "@napi-rs/canvas" package: "${t}".`)}}catch(e){it(`Cannot access the \`require\` function: "${e}".`)}globalThis.DOMMatrix||(d!=null&&d.DOMMatrix?globalThis.DOMMatrix=d.DOMMatrix:it("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.Path2D||(d!=null&&d.Path2D?globalThis.Path2D=d.Path2D:it("Cannot polyfill `Path2D`, rendering may be broken.")),(Ym=globalThis.navigator)!=null&&Ym.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function dA(d){const t=await process.getBuiltinModule("fs/promises").readFile(d);return new Uint8Array(t)}class uA extends Kv{}class fA extends Yv{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}class pA extends Xv{async _fetch(e,t){return dA(e)}}function qv({src:d,srcPos:e=0,dest:t,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=It.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,u=s&7,f=l^h,p=d.length;t=new Uint32Array(t.buffer);let m=0;for(let v=0;v<i;++v){for(const w=e+c;e<w;++e,m+=8){const E=d[e];t[m]=l^-(E>>7&1)&f,t[m+1]=l^-(E>>6&1)&f,t[m+2]=l^-(E>>5&1)&f,t[m+3]=l^-(E>>4&1)&f,t[m+4]=l^-(E>>3&1)&f,t[m+5]=l^-(E>>2&1)&f,t[m+6]=l^-(E>>1&1)&f,t[m+7]=l^-(E&1)&f}if(u===0)continue;const A=e<p?d[e++]:255;for(let w=0;w<u;++w,++m)t[m]=l^-(A>>7-w&1)&f}return{srcPos:e,destPos:m}}function gA({src:d,srcPos:e=0,dest:t,destPos:s=0,width:i,height:r}){let a=0;const o=i*r*3,l=o>>2,h=new Uint32Array(d.buffer,e,l),c=It.isLittleEndian?4278190080:255;if(It.isLittleEndian){for(;a<l-2;a+=3,s+=4){const u=h[a],f=h[a+1],p=h[a+2];t[s]=u|c,t[s+1]=u>>>24|f<<8|c,t[s+2]=f>>>16|p<<16|c,t[s+3]=p>>>8|c}for(let u=a*4,f=e+o;u<f;u+=3)t[s++]=d[u]|d[u+1]<<8|d[u+2]<<16|c}else{for(;a<l-2;a+=3,s+=4){const u=h[a],f=h[a+1],p=h[a+2];t[s]=u|c,t[s+1]=u<<24|f>>>8|c,t[s+2]=f<<16|p>>>16|c,t[s+3]=p<<8|c}for(let u=a*4,f=e+o;u<f;u+=3)t[s++]=d[u]<<24|d[u+1]<<16|d[u+2]<<8|c}return{srcPos:e+o,destPos:s}}const mA=`
|
|
5
|
+
struct Uniforms {
|
|
6
|
+
offsetX : f32,
|
|
7
|
+
offsetY : f32,
|
|
8
|
+
scaleX : f32,
|
|
9
|
+
scaleY : f32,
|
|
10
|
+
paddedWidth : f32,
|
|
11
|
+
paddedHeight : f32,
|
|
12
|
+
borderSize : f32,
|
|
13
|
+
_pad : f32,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
@group(0) @binding(0) var<uniform> u : Uniforms;
|
|
17
|
+
|
|
18
|
+
struct VertexInput {
|
|
19
|
+
@location(0) position : vec2<f32>,
|
|
20
|
+
@location(1) color : vec4<f32>,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
struct VertexOutput {
|
|
24
|
+
@builtin(position) position : vec4<f32>,
|
|
25
|
+
@location(0) color : vec3<f32>,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
@vertex
|
|
29
|
+
fn vs_main(in : VertexInput) -> VertexOutput {
|
|
30
|
+
var out : VertexOutput;
|
|
31
|
+
let cx = (in.position.x + u.offsetX) * u.scaleX;
|
|
32
|
+
let cy = (in.position.y + u.offsetY) * u.scaleY;
|
|
33
|
+
out.position = vec4<f32>(
|
|
34
|
+
((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
|
|
35
|
+
1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
|
|
36
|
+
0.0,
|
|
37
|
+
1.0
|
|
38
|
+
);
|
|
39
|
+
out.color = in.color.rgb;
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@fragment
|
|
44
|
+
fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
|
|
45
|
+
return vec4<f32>(in.color, 1.0);
|
|
46
|
+
}
|
|
47
|
+
`;var Bf,wn,Xa,Hl,Uf,ty;class vA{constructor(){y(this,Uf);y(this,Bf,null);y(this,wn,null);y(this,Xa,null);y(this,Hl,null)}init(){return n(this,Bf)||g(this,Bf,b(this,Uf,ty).call(this))}get isReady(){return n(this,wn)!==null}loadMeshShader(){if(!n(this,wn)||n(this,Xa))return;const e=n(this,wn).createShaderModule({code:mA});g(this,Xa,n(this,wn).createRenderPipeline({layout:"auto",vertex:{module:e,entryPoint:"vs_main",buffers:[{arrayStride:2*4,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:e,entryPoint:"fs_main",targets:[{format:n(this,Hl)}]},primitive:{topology:"triangle-list"}}))}draw(e,t,s,i,r,a,o,l){this.loadMeshShader();const h=n(this,wn),{offsetX:c,offsetY:u,scaleX:f,scaleY:p}=i,m=h.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&h.queue.writeBuffer(m,0,e);const v=h.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&h.queue.writeBuffer(v,0,t);const A=h.createBuffer({size:8*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});h.queue.writeBuffer(A,0,new Float32Array([c,u,f,p,a,o,l,0]));const w=h.createBindGroup({layout:n(this,Xa).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:A}}]}),E=new OffscreenCanvas(a,o),S=E.getContext("webgpu");S.configure({device:h,format:n(this,Hl),alphaMode:r?"opaque":"premultiplied"});const T=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},x=h.createCommandEncoder(),C=x.beginRenderPass({colorAttachments:[{view:S.getCurrentTexture().createView(),clearValue:T,loadOp:"clear",storeOp:"store"}]});return s>0&&(C.setPipeline(n(this,Xa)),C.setBindGroup(0,w),C.setVertexBuffer(0,m),C.setVertexBuffer(1,v),C.draw(s)),C.end(),h.queue.submit([x.finish()]),m.destroy(),v.destroy(),A.destroy(),E.transferToImageBitmap()}}Bf=new WeakMap,wn=new WeakMap,Xa=new WeakMap,Hl=new WeakMap,Uf=new WeakSet,ty=async function(){var e;if(!((e=globalThis.navigator)!=null&&e.gpu))return!1;try{const t=await navigator.gpu.requestAdapter();return t?(g(this,Hl,navigator.gpu.getPreferredCanvasFormat()),g(this,wn,await t.requestDevice()),!0):!1}catch{return!1}};const rp=new vA;function yA(){return rp.init()}function bA(){return rp.isReady}function AA(){rp.loadMeshShader()}function wA(d,e,t,s,i,r,a,o){return rp.draw(d,e,t,s,i,r,a,o)}const De={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Bu(d,e){if(!e)return;const t=e[2]-e[0],s=e[3]-e[1],i=new Path2D;i.rect(e[0],e[1],t,s),d.clip(i)}class im{isModifyingCurrentTransform(){return!1}getPattern(){bt("Abstract method `getPattern` called.")}}class EA extends im{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const e=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return e+this._r1>this._r0&&e+this._r0>this._r1}_createGradient(e,t=null){let s,i=this._p0,r=this._p1;if(t&&(i=i.slice(),r=r.slice(),H.applyTransform(i,t),H.applyTransform(r,t)),this._type==="axial")s=e.createLinearGradient(i[0],i[1],r[0],r[1]);else if(this._type==="radial"){let a=this._r0,o=this._r1;if(t){const l=new Float32Array(2);H.singularValueDecompose2dScale(t,l),a*=l[0],o*=l[0]}s=e.createRadialGradient(i[0],i[1],a,r[0],r[1],o)}for(const a of this._colorStops)s.addColorStop(a[0],a[1]);return s}_createReversedGradient(e,t=null){let s=this._p1,i=this._p0;t&&(s=s.slice(),i=i.slice(),H.applyTransform(s,t),H.applyTransform(i,t));let r=this._r1,a=this._r0;if(t){const h=new Float32Array(2);H.singularValueDecompose2dScale(t,h),r*=h[0],a*=h[0]}const o=e.createRadialGradient(s[0],s[1],r,i[0],i[1],a),l=this._colorStops.map(([h,c])=>[1-h,c]).reverse();for(const[h,c]of l)o.addColorStop(h,c);return o}getPattern(e,t,s,i){let r;if(i===De.STROKE||i===De.FILL){if(this.isOriginBased()){let f=H.transform(s,t.baseTransform);this.matrix&&(f=H.transform(f,this.matrix));const p=.001,m=Math.hypot(f[0],f[1]),v=Math.hypot(f[2],f[3]),A=(f[0]*f[2]+f[1]*f[3])/(m*v);if(Math.abs(A)<p)if(this.isRadial()){if(Math.abs(m-v)<p)return this._createGradient(e,f)}else return this._createGradient(e,f)}const a=t.current.getClippedPathBoundingBox(i,Ut(e))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=t.canvasFactory.create(o,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-a[0],-a[1]),s=H.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...t.baseTransform),this.matrix&&c.transform(...this.matrix),Bu(c,this._bbox),this.areConic()&&(c.fillStyle=this._createReversedGradient(c),c.fill()),c.fillStyle=this._createGradient(c),c.fill(),r=e.createPattern(h.canvas,"no-repeat"),t.canvasFactory.destroy(h);const u=new DOMMatrix(s);r.setTransform(u)}else this.areConic()&&(e.save(),Bu(e,this._bbox),e.fillStyle=this._createReversedGradient(e),e.fillRect(-1e10,-1e10,2e10,2e10),e.restore()),Bu(e,this._bbox),r=this._createGradient(e);return r}}function SA(d,e,t,s,i,r,a,o){const l=e.coords,h=e.colors,c=d.data,u=d.width*4;let f;l[t*2+1]>l[s*2+1]&&(f=t,t=s,s=f,f=r,r=a,a=f),l[s*2+1]>l[i*2+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[t*2+1]>l[s*2+1]&&(f=t,t=s,s=f,f=r,r=a,a=f);const p=(l[t*2]+e.offsetX)*e.scaleX,m=(l[t*2+1]+e.offsetY)*e.scaleY,v=(l[s*2]+e.offsetX)*e.scaleX,A=(l[s*2+1]+e.offsetY)*e.scaleY,w=(l[i*2]+e.offsetX)*e.scaleX,E=(l[i*2+1]+e.offsetY)*e.scaleY;if(m>=E)return;const S=h[r*4],T=h[r*4+1],x=h[r*4+2],C=h[a*4],I=h[a*4+1],O=h[a*4+2],M=h[o*4],R=h[o*4+1],D=h[o*4+2],j=Math.round(m),F=Math.round(E);let U,Z,L,B,q,W,dt,yt;for(let ct=j;ct<=F;ct++){if(ct<A){const k=ct<m?0:(m-ct)/(m-A);U=p-(p-v)*k,Z=S-(S-C)*k,L=T-(T-I)*k,B=x-(x-O)*k}else{let k;ct>E?k=1:A===E?k=0:k=(A-ct)/(A-E),U=v-(v-w)*k,Z=C-(C-M)*k,L=I-(I-R)*k,B=O-(O-D)*k}let X;ct<m?X=0:ct>E?X=1:X=(m-ct)/(m-E),q=p-(p-w)*X,W=S-(S-M)*X,dt=T-(T-R)*X,yt=x-(x-D)*X;const ft=Math.round(Math.min(U,q)),Ft=Math.round(Math.max(U,q));let N=u*ct+ft*4;for(let k=ft;k<=Ft;k++)X=(U-k)/(U-q),X<0?X=0:X>1&&(X=1),c[N++]=Z-(Z-W)*X|0,c[N++]=L-(L-dt)*X|0,c[N++]=B-(B-yt)*X|0,c[N++]=255}}class xA extends im{constructor(e){super(),this._posData=e[2],this._colData=e[3],this._vertexCount=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null,AA()}_createMeshCanvas(e,t,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(h*e[0]*1.1)),3e3)||1,f=Math.min(Math.ceil(Math.abs(c*e[1]*1.1)),3e3)||1,p=h?h/u:1,m=c?c/f:1,v={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/p,scaleY:1/m},A=u+2*2,w=f+2*2,E=s.create(A,w);if(bA()&&this._vertexCount>48)E.context.drawImage(wA(this._posData,this._colData,this._vertexCount,v,t,A,w,2),0,0);else{const S=E.context.createImageData(u,f);if(t){const T=S.data;for(let x=0,C=T.length;x<C;x+=4)T[x]=t[0],T[x+1]=t[1],T[x+2]=t[2],T[x+3]=255}for(let T=0,x=this._vertexCount;T<x;T+=3)SA(S,v,T,T+1,T+2,T,T+1,T+2);E.context.putImageData(S,2,2)}return{canvas:E.canvas,offsetX:o-2*p,offsetY:l-2*m,scaleX:p,scaleY:m}}isModifyingCurrentTransform(){return!0}getPattern(e,t,s,i){Bu(e,this._bbox);const r=new Float32Array(2);if(i===De.SHADING)H.singularValueDecompose2dScale(Ut(e),r);else if(this.matrix){H.singularValueDecompose2dScale(this.matrix,r);const[l,h]=r;H.singularValueDecompose2dScale(t.baseTransform,r),r[0]*=l,r[1]*=h}else H.singularValueDecompose2dScale(t.baseTransform,r);const a=this._createMeshCanvas(r,i===De.SHADING?null:this._background,t.canvasFactory);i!==De.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(a.offsetX,a.offsetY),e.scale(a.scaleX,a.scaleY);const o=e.createPattern(a.canvas,"no-repeat");return t.canvasFactory.destroy(a),o}}class TA extends im{getPattern(){return"hotpink"}}function CA(d){switch(d[0]){case"RadialAxial":return new EA(d);case"Mesh":return new xA(d);case"Dummy":return new TA}throw new Error(`Unknown IR type: ${d[0]}`)}const Dm={COLORED:1,UNCOLORED:2},Hf=class Hf{constructor(e,t,s,i){this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.needsIsolation=e[9]??!0,this.ctx=t,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?H.transform(i,this.matrix):i}canSkipPatternCanvas([e,t,s,i]){const[r,a,o,l]=this.bbox,h=Math.abs(this.xstep),c=Math.abs(this.ystep);if(e>h+1e-6||t>c+1e-6)return null;const u=Math.floor((s-o)/h)+1,f=Math.ceil((s+e-r)/h)-1,p=Math.floor((i-l)/c)+1,m=Math.ceil((i+t-a)/c)-1;return f<=u&&m<=p?[u,p]:null}updatePatternDims(e,t){const s=H.inverseTransform(this.patternBaseMatrix),i=[e[0],e[1]],r=[e[2],e[3]];H.applyTransform(i,s),H.applyTransform(r,s),t[0]=Math.abs(r[0]-i[0]),t[1]=Math.abs(r[1]-i[1]),t[2]=Math.min(i[0],r[0]),t[3]=Math.min(i[1],r[1])}_renderTileCanvas(e,t,s,i){var f,p;const[r,a,o,l]=this.bbox,h=e.canvasFactory.create(s.size,i.size),c=h.context,u=this.canvasGraphicsFactory.createCanvasGraphics(c,t);return u.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(u,this.paintType,this.color),c.translate(-s.scale*r,-i.scale*a),u.transform(0,s.scale,0,0,i.scale,0,0),c.save(),(f=u.dependencyTracker)==null||f.save(),this.clipBbox(u,r,a,o,l),u.baseTransform=Ut(u.ctx),u.executeOperatorList(this.operatorList),u.endDrawing(),(p=u.dependencyTracker)==null||p.restore(),c.restore(),h}_getCombinedScales(){const e=new Float32Array(2);H.singularValueDecompose2dScale(this.matrix,e);const[t,s]=e;return H.singularValueDecompose2dScale(this.baseTransform,e),[t*e[0],s*e[1]]}drawPattern(e,t,s=!1,[i,r],a){const[o,l,h,c]=this.bbox,u=e.dependencyTracker;if(u&&(e.dependencyTracker=new Sc(u,a)),e.save(),s?e.ctx.clip(t,"evenodd"):e.ctx.clip(t),e.ctx.setTransform(...this.patternBaseMatrix),e.ctx.translate(i*this.xstep,r*this.ystep),this.needsIsolation||e.ctx.globalAlpha!==1||e.ctx.globalCompositeOperation!=="source-over"||e.inSMaskMode){const f=h-o,p=c-l,[m,v]=this._getCombinedScales(),A=this.getSizeAndScale(f,this.ctx.canvas.width,m),w=this.getSizeAndScale(p,this.ctx.canvas.height,v),E=this._renderTileCanvas(e,a,A,w);e.ctx.drawImage(E.canvas,o,l,f,p),e.canvasFactory.destroy(E)}else this.setFillAndStrokeStyleToContext(e,this.paintType,this.color),this.clipBbox(e,o,l,h,c),e.baseTransformStack.push(e.baseTransform),e.baseTransform=Ut(e.ctx),e.executeOperatorList(this.operatorList),e.baseTransform=e.baseTransformStack.pop();e.restore(),u&&(e.dependencyTracker=u)}createPatternCanvas(e,t){const[s,i,r,a]=this.bbox,o=r-s,l=a-i;let{xstep:h,ystep:c}=this;h=Math.abs(h),c=Math.abs(c),qf("TilingType: "+this.tilingType);const[u,f]=this._getCombinedScales();let p=o,m=l,v=!1,A=!1;Math.ceil(h*u)>=Math.ceil(o*u)?p=h:v=!0,Math.ceil(c*f)>=Math.ceil(l*f)?m=c:A=!0;const w=this.getSizeAndScale(p,this.ctx.canvas.width,u),E=this.getSizeAndScale(m,this.ctx.canvas.height,f),S=this._renderTileCanvas(e,t,w,E);if(v||A){const T=S.canvas;v&&(p=h),A&&(m=c);const x=this.getSizeAndScale(p,this.ctx.canvas.width,u),C=this.getSizeAndScale(m,this.ctx.canvas.height,f),I=x.size,O=C.size,M=e.canvasFactory.create(I,O),R=M.context,D=v?Math.floor(o/h):0,j=A?Math.floor(l/c):0;for(let F=0;F<=D;F++)for(let U=0;U<=j;U++)R.drawImage(T,I*F,O*U,I,O,0,0,I,O);return e.canvasFactory.destroy(S),{canvas:M.canvas,canvasEntry:M,scaleX:x.scale,scaleY:C.scale,offsetX:s,offsetY:i}}return{canvas:S.canvas,canvasEntry:S,scaleX:w.scale,scaleY:E.scale,offsetX:s,offsetY:i}}getSizeAndScale(e,t,s){const i=Math.max(Hf.MAX_PATTERN_SIZE,t);let r=Math.ceil(e*s);return r>=i?r=i:s=r/e,{scale:s,size:r}}clipBbox(e,t,s,i,r){const a=i-t,o=r-s,l=new Path2D;l.rect(t,s,a,o),H.axialAlignedBoundingBox([t,s,i,r],Ut(e.ctx),e.current.minMax),e.ctx.clip(l),e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,s){const i=e.ctx,r=e.current;switch(r.patternFill=r.patternStroke=!1,t){case Dm.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case Dm.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new Bb(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,s,i,r){const a=i!==De.SHADING?H.transform(s,this.patternBaseMatrix):s,o=this.createPatternCanvas(t,r);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const h=e.createPattern(o.canvas,"repeat");return t.canvasFactory.destroy(o.canvasEntry),h.setTransform(l),h}};P(Hf,"MAX_PATTERN_SIZE",3e3);let pc=Hf;const IA=16,PA=100,MA=15,km=10,ds=16,Ap=new DOMMatrix,Ls=new Float32Array(2);function Lm(d,e){if(d._removeMirroring)throw new Error("Context is already forwarding operations.");const t=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const i=d[s];typeof i!="function"||typeof e[s]!="function"||(t.set(s,i),d[s]=function(...r){return e[s](...r),i.apply(this,r)})}d._removeMirroring=()=>{for(const[s,i]of t)d[s]=i;delete d._removeMirroring}}function Au(d,e,t,s,i,r,a,o,l,h){const[c,u,f,p,m,v]=Ut(d);if(u===0&&f===0){const E=a*c+m,S=Math.round(E),T=o*p+v,x=Math.round(T),C=(a+l)*c+m,I=Math.abs(Math.round(C)-S)||1,O=(o+h)*p+v,M=Math.abs(Math.round(O)-x)||1;return d.setTransform(Math.sign(c),0,0,Math.sign(p),S,x),d.drawImage(e,t,s,i,r,0,0,I,M),d.setTransform(c,u,f,p,m,v),[I,M]}if(c===0&&p===0){const E=o*f+m,S=Math.round(E),T=a*u+v,x=Math.round(T),C=(o+h)*f+m,I=Math.abs(Math.round(C)-S)||1,O=(a+l)*u+v,M=Math.abs(Math.round(O)-x)||1;return d.setTransform(0,Math.sign(u),Math.sign(f),0,S,x),d.drawImage(e,t,s,i,r,0,0,M,I),d.setTransform(c,u,f,p,m,v),[M,I]}d.drawImage(e,t,s,i,r,a,o,l,h);const A=Math.hypot(c,u),w=Math.hypot(f,p);return[A*l,w*h]}class Fm{constructor(e,t){P(this,"alphaIsShape",!1);P(this,"fontSize",0);P(this,"fontSizeScale",1);P(this,"textMatrix",null);P(this,"textMatrixScale",1);P(this,"fontMatrix",Sp);P(this,"leading",0);P(this,"x",0);P(this,"y",0);P(this,"lineX",0);P(this,"lineY",0);P(this,"charSpacing",0);P(this,"wordSpacing",0);P(this,"textHScale",1);P(this,"textRenderingMode",de.FILL);P(this,"textRise",0);P(this,"fillColor","#000000");P(this,"strokeColor","#000000");P(this,"tilingPatternDims",null);P(this,"patternFill",!1);P(this,"patternStroke",!1);P(this,"fillAlpha",1);P(this,"strokeAlpha",1);P(this,"lineWidth",1);P(this,"activeSMask",null);P(this,"transferMaps","none");P(this,"minMax",pa.slice());this.clipBox=new Float32Array([0,0,e,t])}clone(){var t;const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e.minMax=this.minMax.slice(),e.tilingPatternDims=(t=this.tilingPatternDims)==null?void 0:t.slice(),e}getPathBoundingBox(e=De.FILL,t=null){const s=this.minMax.slice();if(e===De.STROKE){t||bt("Stroke bounding box must include transform."),H.singularValueDecompose2dScale(t,Ls);const i=Ls[0]*this.lineWidth/2,r=Ls[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const e=H.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(pa,0)}getClippedPathBoundingBox(e=De.FILL,t=null){return H.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function Nm(d,e){const{width:t,height:s,kind:i}=e,r=s%ds,a=(s-r)/ds,o=r===0?a:a+1,l=d.createImageData(t,ds);let h=0;const c=e.data,u=l.data;let f;if(i===uc.GRAYSCALE_1BPP)for(f=0;f<o;f++)({srcPos:h}=qv({src:c,srcPos:h,dest:u,width:t,height:f<a?ds:r})),d.putImageData(l,0,f*ds);else if(i===uc.RGBA_32BPP){let p=0,m=t*ds*4;for(f=0;f<a;f++)u.set(c.subarray(h,h+m)),h+=m,d.putImageData(l,0,p),p+=ds;f<o&&(m=t*r*4,u.set(c.subarray(h,h+m)),d.putImageData(l,0,p))}else if(i===uc.RGB_24BPP)for(f=0;f<o;f++)({srcPos:h}=gA({src:c,srcPos:h,dest:new Uint32Array(u.buffer),width:t,height:f<a?ds:r})),d.putImageData(l,0,f*ds);else throw new Error(`bad image kind: ${i}`)}function Bm(d,e){if(e.bitmap){d.drawImage(e.bitmap,0,0);return}const{width:t,height:s}=e,i=s%ds,r=(s-i)/ds,a=i===0?r:r+1,o=d.createImageData(t,ds);let l=0;const h=e.data,c=o.data;for(let u=0;u<a;u++)({srcPos:l}=qv({src:h,srcPos:l,dest:c,width:t,height:u<r?ds:i,nonBlackColor:0})),d.putImageData(o,0,u*ds)}function na(d,e){const t=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of t)d[s]!==void 0&&(e[s]=d[s]);d.setLineDash!==void 0&&(e.setLineDash(d.getLineDash()),e.lineDashOffset=d.lineDashOffset)}function wu(d){d.strokeStyle=d.fillStyle="#000000",d.fillRule="nonzero",d.globalAlpha=1,d.lineWidth=1,d.lineCap="butt",d.lineJoin="miter",d.miterLimit=10,d.globalCompositeOperation="source-over",d.font="10px sans-serif",d.setLineDash!==void 0&&(d.setLineDash([]),d.lineDashOffset=0);const{filter:e}=d;e!=="none"&&e!==""&&(d.filter="none")}function Um(d,e){if(e)return!0;H.singularValueDecompose2dScale(d,Ls);const t=Math.fround(Ei.pixelRatio*Yn.PDF_TO_CSS_UNITS);return Ls[0]<=t&&Ls[1]<=t}const OA=["butt","round","square"],RA=["miter","round","bevel"],DA={},Hm={};var ys,Cr,Ya,Ka,Ja,Qa,Za,qa,to,Bi,Y,Qp,Zp,qp,tg,eg,es,Fe,sg,ey,Uu;const um=class um{constructor(e,t,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c,u){y(this,Y);y(this,ys,0);y(this,Cr,0);y(this,Ya,null);y(this,Ka,null);y(this,Ja,null);y(this,Qa,null);y(this,Za,1);y(this,qa);y(this,to,null);y(this,Bi,[]);this.ctx=e,this.current=new Fm(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=t,this.objs=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=a,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null,this.imagesTracker=u??null}getObject(e,t,s=null){var i;return typeof t=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(e,t),t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t)):s}beginDrawing({transform:e,viewport:t,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.transparentCanvasEntry=this.canvasFactory.create(r,a);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=l,this.ctx.save(),this.ctx.transform(...Ut(this.compositeCtx))}this.ctx.save(),wu(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[3]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=Ut(this.ctx)}executeOperatorList(e,t,s,i,r){var w;const a=e.argsArray,o=e.fnArray;let l=t||0;const h=a.length;if(h===l)return l;const c=h-l>km&&typeof s=="function",u=c?Date.now()+MA:0;let f=0;const p=this.commonObjs,m=this.objs;let v,A;for(;;){if(i!==void 0){if(l===i.nextBreakPoint)return i.breakIt(l,s),l;if(i.shouldSkip(l)){if(++l===h)return l;continue}}if(!r||r(l))if(v=o[l],A=a[l]??null,v!==yi.dependency)A===null?this[v](l):this[v](l,...A);else for(const E of A){(w=this.dependencyTracker)==null||w.recordNamedData(E,l);const S=E.startsWith("g_")?p:m;if(!S.has(E))return S.get(E,s),l}if(l++,l===h)return l;if(c&&++f>km){if(Date.now()>u)return s(),l;f=0}}}endDrawing(){b(this,Y,Qp).call(this);for(const e of this.smaskGroupCanvases)this.canvasFactory.destroy(e);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const e of n(this,Bi))b(this,Y,Uu).call(this,e);n(this,Bi).length=0,g(this,Ya,null),g(this,Ka,null),g(this,Ja,null),g(this,Qa,null),g(this,Za,1),g(this,to,null),g(this,Cr,0),g(this,ys,0),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),b(this,Y,Zp).call(this)}_scaleImage(e,t){const s=e.width??e.displayWidth,i=e.height??e.displayHeight,r=Math.max(Math.hypot(t[0],t[1]),1),a=Math.max(Math.hypot(t[2],t[3]),1),o=[];let l=r,h=a,c=s,u=i;for(;l>2&&c>1||h>2&&u>1;){let w=c,E=u;l>2&&c>1&&(w=Math.ceil(c/2),l/=c/w),h>2&&u>1&&(E=Math.ceil(u/2),h/=u/E),o.push({newWidth:w,newHeight:E}),c=w,u=E}if(o.length===0)return{img:e,paintWidth:s,paintHeight:i,tmpCanvas:null};if(o.length===1){const{newWidth:w,newHeight:E}=o[0],S=this.canvasFactory.create(w,E);return S.context.drawImage(e,0,0,s,i,0,0,w,E),{img:S.canvas,paintWidth:w,paintHeight:E,tmpCanvas:S}}let f=this.canvasFactory.create(1,1),p=this.canvasFactory.create(1,1),m=s,v=i,A=e;for(const{newWidth:w,newHeight:E}of o)this.canvasFactory.reset(p,w,E),p.context.drawImage(A,0,0,m,v,0,0,w,E),[f,p]=[p,f],A=f.canvas,m=w,v=E;return this.canvasFactory.destroy(p),{img:f.canvas,paintWidth:m,paintHeight:v,tmpCanvas:f}}_createMaskCanvas(e,t){var D,j;const s=this.ctx,{width:i,height:r}=t,a=this.current.fillColor,o=this.current.patternFill,l=Ut(s);let h,c,u,f;if((t.bitmap||t.data)&&t.count>1){const F=t.bitmap||t.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.getOrInsertComputed(F,ep);const U=h.get(c);if(U&&!o){const Z=Math.round(Math.min(l[0],l[2])+l[4]),L=Math.round(Math.min(l[1],l[3])+l[5]);return(D=this.dependencyTracker)==null||D.recordDependencies(e,Hs.transformAndFill),{canvas:U,offsetX:Z,offsetY:L}}u=U}u||(f=this.canvasFactory.create(i,r),Bm(f.context,t));let p=H.transform(l,[1/i,0,0,-1/r,0,0]);p=H.transform(p,[1,0,0,1,0,-r]);const m=pa.slice();H.axialAlignedBoundingBox([0,0,i,r],p,m);const[v,A,w,E]=m,S=Math.round(w-v)||1,T=Math.round(E-A)||1,x=this.canvasFactory.create(S,T),C=x.context,I=v,O=A;C.translate(-I,-O),C.transform(...p);let M=null;if(!u){const F=this._scaleImage(f.canvas,Si(C));u=F.img,M=F.tmpCanvas,u!==f.canvas&&(this.canvasFactory.destroy(f),f=null),h&&o&&(h.set(c,u),M=null,f=null)}C.imageSmoothingEnabled=Um(Ut(C),t.interpolate),Au(C,u,0,0,u.width,u.height,0,0,i,r),M&&this.canvasFactory.destroy(M),f&&this.canvasFactory.destroy(f),C.globalCompositeOperation="source-in";const R=H.transform(Si(C),[1,0,0,1,-I,-O]);return C.fillStyle=o?a.getPattern(s,this,R,De.FILL,e):a,C.fillRect(0,0,i,r),h&&!o&&h.set(c,x.canvas),(j=this.dependencyTracker)==null||j.recordDependencies(e,Hs.transformAndFill),{canvas:x.canvas,canvasEntry:h&&!o?null:x,offsetX:Math.round(I),offsetY:Math.round(O)}}setLineWidth(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",e),t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",e),this.ctx.lineCap=OA[t]}setLineJoin(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",e),this.ctx.lineJoin=RA[t]}setMiterLimit(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",e),this.ctx.miterLimit=t}setDash(e,t,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",e);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(t),i.lineDashOffset=s)}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){var s,i,r,a,o;for(const[l,h]of t)switch(l){case"LW":this.setLineWidth(e,h);break;case"LC":this.setLineCap(e,h);break;case"LJ":this.setLineJoin(e,h);break;case"ML":this.setMiterLimit(e,h);break;case"D":this.setDash(e,h[0],h[1]);break;case"RI":this.setRenderingIntent(e,h);break;case"FL":this.setFlatness(e,h);break;case"Font":this.setFont(e,h[0],h[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",e),this.current.strokeAlpha=h;break;case"ca":(i=this.dependencyTracker)==null||i.recordSimpleData("fillAlpha",e),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",e),this.ctx.globalCompositeOperation=h;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",e),this.current.activeSMask=h?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(e);break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",e),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){e!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(e))}checkSMaskState(e){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode(e):!this.current.activeSMask&&t?this.endSMaskMode():this.current.activeSMask&&t&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){const{canvas:t,subtype:s,backdrop:i,transferMap:r}=e,a=s==="Luminosity"||s==="Alpha"&&r;if(!a&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=e;return}let o;if(s==="Luminosity"&&i){const[E,S,T]=Hh(i),x=Math.round(.3*E+.59*S+.11*T);o=(r==null?void 0:r[x])??x}else o=(r==null?void 0:r[0])??0;const l=4,{width:h,height:c}=this.ctx.canvas,u=t.width*t.height,f=h*c<l*u,p=a?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(r):this.filterFactory.addLuminosityFilter(r),subtype:s,transferMap:r}:null,m=s==="Luminosity"?i:null;let v,A,w;f?(v=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,h,c,m,p),A=0,w=0):(v=this._bakeSMaskCanvas(t,0,0,t.width,t.height,m,p),A=e.offsetX,w=e.offsetY),this.smaskPreparedEntry=v,this.smaskPreparedFor=e,this.smaskPreparedOffsetX=A,this.smaskPreparedOffsetY=w,this.smaskPreparedOOBAlpha=!f&&o!==0?o:null}_bakeSMaskCanvas(e,t,s,i,r,a,o){!a&&!o&&bt("_bakeSMaskCanvas with neither backdrop nor filter");const l=this.canvasFactory.create(i,r),h=l.context;if(h.drawImage(e,t,s),a&&(h.globalCompositeOperation="destination-atop",h.fillStyle=a,h.fillRect(0,0,i,r)),!o)return l;const c=this.canvasFactory.create(i,r),u=c.context;u.filter=o.url;const f=It.isCanvasFilterSupported&&u.filter!=="none"&&u.filter!=="";if(u.drawImage(l.canvas,0,0),It.isCanvasFilterSupported&&(u.filter="none"),!f){const p=u.getImageData(0,0,i,r),{data:m}=p,{transferMap:v}=o;if(o.subtype==="Luminosity")for(let A=0,w=m.length;A<w;A+=4){const E=.3*m[A]+.59*m[A+1]+.11*m[A+2]+.5|0;m[A]=m[A+1]=m[A+2]=0,m[A+3]=(v==null?void 0:v[E])??E}else for(let A=3,w=m.length;A<w;A+=4)m[A]=v[m[A]];u.putImageData(p,0,0)}return this.canvasFactory.destroy(l),c}beginSMaskMode(e){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:t,height:s}=this.ctx.canvas,i=this.canvasFactory.create(t,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;const r=this.ctx=i.context;r.setTransform(this.suspendedCtx.getTransform()),na(this.suspendedCtx,r),Lm(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(e,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),na(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}compose(e){if(!this.current.activeSMask)return;e=e?[Math.floor(e[0]),Math.floor(e[1]),Math.ceil(e[2]),Math.ceil(e[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,s=this.suspendedCtx,i=n(this,Cr)>0&&s===this.ctx;this.composeSMask(i?null:s,t,this.ctx,e),!i&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(e,t,s,i){const r=i[0],a=i[1],o=i[2]-r,l=i[3]-a;if(o===0||l===0)return;const h=this.smaskPreparedEntry;if(h){let c=r,u=a,f=o,p=l;const m=this.smaskPreparedOOBAlpha,v=m!==null;if(v){c=Math.max(r,t.offsetX),u=Math.max(a,t.offsetY);const A=Math.min(r+o,t.offsetX+t.canvas.width),w=Math.min(a+l,t.offsetY+t.canvas.height);f=A-c,p=w-u}if(f>0&&p>0){const A=c-this.smaskPreparedOffsetX,w=u-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const E=new Path2D;E.rect(c,u,f,p),s.clip(E),s.globalCompositeOperation="destination-in",s.drawImage(h.canvas,A,w,f,p,c,u,f,p),s.restore()}v&&m<255&&this._applySMaskOOBAlpha(s,r,a,o,l,c,u,c+f,u+p,m)}else this.genericComposeSMask(t,s,o,l,r,a);e&&(e.save(),e.globalAlpha=1,e.globalCompositeOperation=t.blendMode||"source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(s.canvas,r,a,o,l,r,a,o,l),e.restore())}_applySMaskOOBAlpha(e,t,s,i,r,a,o,l,h,c){const u=a<l&&o<h;if(u&&a===t&&o===s&&l===t+i&&h===s+r)return;const f=new Path2D;f.rect(t,s,i,r),u&&f.rect(a,o,l-a,h-o),e.save(),e.globalAlpha=c/255,e.setTransform(1,0,0,1,0,0),e.clip(f,"evenodd"),e.globalCompositeOperation="destination-in",e.fillStyle="#000000",e.fillRect(t,s,i,r),e.restore()}genericComposeSMask(e,t,s,i,r,a){const{context:o,offsetX:l,offsetY:h}=e;t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const c=new Path2D;c.rect(r,a,s,i),t.clip(c),t.globalCompositeOperation="destination-in",t.drawImage(o.canvas,r-l,a-h,s,i,r,a,s,i),t.restore()}save(e){var s;this.inSMaskMode&&na(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone(),(s=this.dependencyTracker)==null||s.save(e)}restore(e){var t;if((t=this.dependencyTracker)==null||t.restore(e),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(na(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(e),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,t,s,i,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",e),this.ctx.transform(t,s,i,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,s,i){let[r]=s;if(!i){r||(r=s[0]=new Path2D),t!==yi.stroke&&t!==yi.closeStroke&&(this.current.tilingPatternDims=null),this[t](e,r);return}if(this.dependencyTracker!==null){const o=t===yi.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,i[0]-o,i[2]+o,i[1]-o,i[3]+o).recordDependencies(e,["transform"])}r instanceof Path2D||(r=s[0]=nv(r)),H.axialAlignedBoundingBox(i,Ut(this.ctx),this.current.minMax);const a=this.current.tilingPatternDims;if(a&&t!==yi.stroke&&t!==yi.closeStroke&&this.current.fillColor instanceof pc){const o=H.intersect(this.current.clipBox,this.current.minMax);o?this.current.fillColor.updatePatternDims(o,a):this.current.tilingPatternDims=null}this[t](e,r),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t,s=!0){var o;const i=s&&b(this,Y,es).call(this,this.current.strokeAlpha),r=this.ctx,a=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof a=="object"&&(a!=null&&a.getPattern)){const l=a.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=a.getPattern(r,this,Si(r),De.STROKE,e),l){const h=new Path2D;h.addPath(t,r.getTransform().invertSelf().multiplySelf(l)),t=h}this.rescaleAndStroke(t,!1),r.restore()}else this.rescaleAndStroke(t,!0);(o=this.dependencyTracker)==null||o.recordDependencies(e,Hs.stroke),s&&this.consumePath(e,t,this.current.getClippedPathBoundingBox(De.STROKE,Ut(this.ctx))),r.globalAlpha=this.current.fillAlpha,b(this,Y,Fe).call(this,i)}closeStroke(e,t){this.stroke(e,t)}fill(e,t,s=!0){var c,u,f;const i=s&&b(this,Y,es).call(this,this.current.fillAlpha),r=this.ctx,a=this.current.fillColor,o=this.current.patternFill;let l=!1;const h=this.current.getClippedPathBoundingBox();if((c=this.dependencyTracker)==null||c.recordDependencies(e,Hs.fill),o){const p=this.current.tilingPatternDims,m=p&&a.canSkipPatternCanvas(p);if(m){a.drawPattern(this,t,this.pendingEOFill,m,e),this.pendingEOFill=!1,s&&this.consumePath(e,t,h),this.current.tilingPatternDims=null,b(this,Y,Fe).call(this,i);return}const v=a.isModifyingCurrentTransform()?r.getTransform():null;if((u=this.dependencyTracker)==null||u.save(e),r.save(),r.fillStyle=a.getPattern(r,this,Si(r),De.FILL,e),v){const A=new Path2D;A.addPath(t,r.getTransform().invertSelf().multiplySelf(v)),t=A}l=!0}this.contentVisible&&h!==null&&(this.pendingEOFill?(r.fill(t,"evenodd"),this.pendingEOFill=!1):r.fill(t)),l&&(r.restore(),(f=this.dependencyTracker)==null||f.restore(e)),s&&this.consumePath(e,t,h),b(this,Y,Fe).call(this,i)}eoFill(e,t){this.pendingEOFill=!0,this.fill(e,t)}fillStroke(e,t){const s=b(this,Y,es).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1),this.stroke(e,t,!1),this.consumePath(e,t),b(this,Y,Fe).call(this,s)}eoFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}closeFillStroke(e,t){this.fillStroke(e,t)}closeEOFillStroke(e,t){this.pendingEOFill=!0,this.fillStroke(e,t)}endPath(e,t){this.consumePath(e,t)}rawFillPath(e,t){var i;const s=b(this,Y,es).call(this,this.current.fillAlpha);this.ctx.fill(t),(i=this.dependencyTracker)==null||i.recordDependencies(e,Hs.rawFillPath).recordOperation(e),b(this,Y,Fe).call(this,s)}clip(e){var t;(t=this.dependencyTracker)==null||t.recordFutureForcedDependency("clipMode",e),this.pendingClip=DA}eoClip(e){var t;(t=this.dependencyTracker)==null||t.recordFutureForcedDependency("clipMode",e),this.pendingClip=Hm}beginText(e){var t;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(t=this.dependencyTracker)==null||t.recordOpenMarker(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){const t=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;t!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",e),i.recordCloseMarker(e)}if(t!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of t)c&&i.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",e),this.current.charSpacing=t}setWordSpacing(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",e),this.current.wordSpacing=t}setHScale(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",e),this.current.textHScale=t/100}setLeading(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",e),this.current.leading=-t}setFont(e,t,s){var u,f;(u=this.dependencyTracker)==null||u.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",t,e);const i=this.commonObjs.get(t),r=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(r.fontMatrix=i.fontMatrix||Sp,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&it("Invalid font matrix for font "+t),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((f=i.systemFontInfo)==null?void 0:f.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const h=i.italic?"italic":"normal",c=Ht(s,IA,PA);this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",e),this.current.textRenderingMode=t}setTextRise(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",e),this.current.textRise=t}moveText(e,t,s){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e),this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=s}setLeadingMoveText(e,t,s){this.setLeading(e,-s),this.moveText(e,t,s)}setTextMatrix(e,t){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",e);const{current:s}=this;s.textMatrix=t,s.textMatrixScale=Math.hypot(t[0],t[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(e){var t;this.moveText(e,0,this.current.leading),(t=this.dependencyTracker)==null||t.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}paintChar(e,t,s,i,r,a){var w,E,S,T;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,u=l.fontSize/l.fontSizeScale,f=c&de.FILL_STROKE_MASK,p=!!(c&de.ADD_TO_PATH_FLAG),m=l.patternFill&&!h.missingFile,v=l.patternStroke&&!h.missingFile;let A;if((h.disableFontFace||p||m||v)&&!h.missingFile&&(A=h.getPathGenerator(this.commonObjs,t)),A&&(h.disableFontFace||m||v)){o.save(),o.translate(s,i),o.scale(u,-u),(w=this.dependencyTracker)==null||w.recordCharacterBBox(e,o,h);let x;if(f===de.FILL||f===de.FILL_STROKE)if(r){x=o.getTransform(),o.setTransform(...r);const C=b(this,Y,sg).call(this,A,x,r);o.fill(C)}else o.fill(A);if(f===de.STROKE||f===de.FILL_STROKE)if(a){x||(x=o.getTransform()),o.setTransform(...a);const{a:C,b:I,c:O,d:M}=x,R=H.inverseTransform(a),D=H.transform([C,I,O,M,0,0],R);H.singularValueDecompose2dScale(D,Ls),o.lineWidth*=Math.max(Ls[0],Ls[1])/u,o.stroke(b(this,Y,sg).call(this,A,x,a))}else o.lineWidth/=u,o.stroke(A);o.restore()}else(f===de.FILL||f===de.FILL_STROKE)&&(o.fillText(t,s,i),(E=this.dependencyTracker)==null||E.recordCharacterBBox(e,o,h,u,s,i,()=>o.measureText(t))),(f===de.STROKE||f===de.FILL_STROKE)&&(this.dependencyTracker&&((S=this.dependencyTracker)==null||S.recordCharacterBBox(e,o,h,u,s,i,()=>o.measureText(t)).recordDependencies(e,Hs.stroke)),o.strokeText(t,s,i));p&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Ut(o),x:s,y:i,fontSize:u,path:A}),(T=this.dependencyTracker)==null||T.recordCharacterBBox(e,o,h,u,s,i))}get isFontSubpixelAAEnabled(){const e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1),t.fillText("I",0,10);const s=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let i=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){i=!0;break}return st(this,"isFontSubpixelAAEnabled",i)}showText(e,t){var j,F,U,Z;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(e,Hs.showText).resetBBox(e),this.current.textRenderingMode&de.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const L=b(this,Y,es).call(this,s.fillAlpha);this.showType3Text(e,t),(j=this.dependencyTracker)==null||j.recordShowTextOperation(e),b(this,Y,Fe).call(this,L);return}const r=s.fontSize;if(r===0){(F=this.dependencyTracker)==null||F.recordOperation(e);return}const a=b(this,Y,es).call(this,s.fillAlpha),o=this.ctx,l=s.fontSizeScale,h=s.charSpacing,c=s.wordSpacing,u=s.fontDirection,f=s.textHScale*u,p=t.length,m=i.vertical,v=m?1:-1,A=i.defaultVMetrics,w=r*s.fontMatrix[0],E=s.textRenderingMode===de.FILL&&!i.disableFontFace&&!s.patternFill;o.save(),s.textMatrix&&o.transform(...s.textMatrix),o.translate(s.x,s.y+s.textRise),u>0?o.scale(f,-1):o.scale(f,1);let S,T;const x=s.textRenderingMode&de.FILL_STROKE_MASK,C=x===de.FILL||x===de.FILL_STROKE,I=x===de.STROKE||x===de.FILL_STROKE;let O=s.lineWidth;const M=s.textMatrixScale;if(M===0||O===0?I&&(O=this.getSinglePixelWidth()):O/=M,l!==1&&(o.scale(l,l),O/=l),o.lineWidth=O,C&&s.patternFill){o.save();const L=s.fillColor.getPattern(o,this,Si(o),De.FILL,e);S=Ut(o),o.restore(),o.fillStyle=L}if(I&&s.patternStroke){o.save();const L=s.strokeColor.getPattern(o,this,Si(o),De.STROKE,e);T=Ut(o),o.restore(),o.strokeStyle=L}if(i.isInvalidPDFjsFont){const L=[];let B=0;for(const W of t)L.push(W.unicode),B+=W.width;const q=L.join("");if(o.fillText(q,0,0),this.dependencyTracker!==null){const W=o.measureText(q);this.dependencyTracker.recordBBox(e,this.ctx,-W.actualBoundingBoxLeft,W.actualBoundingBoxRight,-W.actualBoundingBoxAscent,W.actualBoundingBoxDescent).recordShowTextOperation(e)}s.x+=B*w*f,o.restore(),this.compose(),b(this,Y,Fe).call(this,a);return}let R=0,D;for(D=0;D<p;++D){const L=t[D];if(typeof L=="number"){R+=v*L*r/1e3;continue}let B=!1;const q=(L.isSpace?c:0)+h,W=L.fontChar,dt=L.accent;let yt,ct,X=L.width;if(m){const N=L.vmetric||A,k=-(L.vmetric?N[1]:X*.5)*w,$=N[2]*w;X=N?-N[0]:X,yt=k/l,ct=(R+$)/l}else yt=R/l,ct=0;let ft;if(i.remeasure&&X>0){ft=o.measureText(W);const N=ft.width*1e3/r*l;if(X<N&&this.isFontSubpixelAAEnabled){const k=X/N;B=!0,o.save(),o.scale(k,1),yt/=k}else X!==N&&(yt+=(X-N)/2e3*r/l)}if(this.contentVisible&&(L.isInFont||i.missingFile)){if(E&&!dt)o.fillText(W,yt,ct),(U=this.dependencyTracker)==null||U.recordCharacterBBox(e,o,ft?{bbox:null}:i,r/l,yt,ct,()=>ft??o.measureText(W));else if(this.paintChar(e,W,yt,ct,S,T),dt){const N=yt+r*dt.offset.x/l,k=ct-r*dt.offset.y/l;this.paintChar(e,dt.fontChar,N,k,S,T)}}const Ft=m?X*w-q*u:X*w+q*u;R+=Ft,B&&o.restore()}m?s.y-=R:s.x+=R*f,o.restore(),this.compose(),(Z=this.dependencyTracker)==null||Z.recordShowTextOperation(e),b(this,Y,Fe).call(this,a)}showType3Text(e,t){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,h=i.charSpacing,c=i.wordSpacing,u=i.textHScale*o,f=i.fontMatrix||Sp,p=t.length,m=i.textRenderingMode===de.INVISIBLE;let v,A,w,E;if(m||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(u,o);const S=this.dependencyTracker;for(this.dependencyTracker=S?new Sc(S,e):null,v=0;v<p;++v){if(A=t[v],typeof A=="number"){E=l*A*a/1e3,this.ctx.translate(E,0),i.x+=E*u;continue}const T=(A.isSpace?c:0)+h,x=r.charProcOperatorList[A.operatorListId];x?this.contentVisible&&(this.save(),x.fnArray[0]===yi.setCharWidth&&(i.fillAlpha=i.strokeAlpha=1,s.globalAlpha=1),s.scale(a,a),s.transform(...f),this.executeOperatorList(x),this.restore()):it(`Type3 character "${A.operatorListId}" is not available.`);const C=[A.width,0];H.applyTransform(C,f),w=C[0]*a+T,s.translate(w,0),i.x+=w*u}s.restore(),S&&(this.dependencyTracker=S)}setCharWidth(e,t,s){}setCharWidthAndBounds(e,t,s,i,r,a,o){var h;const l=new Path2D;l.rect(i,r,a-i,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(e,this.ctx,i,a,r,o).recordClipBox(e,this.ctx,i,a,r,o),this.endPath(e)}getColorN_Pattern(e,t){let s;if(t[0]==="TilingPattern"){const i=this.baseTransform||Ut(this.ctx),r={createCanvasGraphics:(a,o)=>new um(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Sc(this.dependencyTracker,o,!0):null)};s=new pc(t,this.ctx,r,i)}else s=this._getPattern(e,t[1],t[2]);return s}setStrokeColorN(e,...t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",e),this.current.strokeColor=this.getColorN_Pattern(e,t),this.current.patternStroke=!0}setFillColorN(e,...t){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",e);const s=this.current.fillColor=this.getColorN_Pattern(e,t);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof pc?[0,0,0,0]:null}setStrokeRGBColor(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(e){var t;(t=this.dependencyTracker)==null||t.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor=t,this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(e){var t;(t=this.dependencyTracker)==null||t.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(e,t,s=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=CA(this.getObject(e,t)),this.cachedPatterns.set(t,i)),s&&(i.matrix=s),i}shadingFill(e,t){var o;if(!this.contentVisible)return;const s=b(this,Y,es).call(this,this.current.fillAlpha),i=this.ctx;this.save(e);const r=this._getPattern(e,t);i.fillStyle=r.getPattern(i,this,Si(i),De.SHADING,e);const a=Si(i);if(a){const{width:l,height:h}=i.canvas,c=pa.slice();H.axialAlignedBoundingBox([0,0,l,h],a,c);const[u,f,p,m]=c;this.ctx.fillRect(u,f,p-u,m-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,Hs.transform).recordDependencies(e,Hs.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e),b(this,Y,Fe).call(this,s)}beginInlineImage(){bt("Should not call beginInlineImage")}beginImageData(){bt("Should not call beginImageData")}paintFormXObjectBegin(e,t,s){var i;if(this.contentVisible&&(this.save(e),this.baseTransformStack.push(this.baseTransform),t&&this.transform(e,...t),this.baseTransform=Ut(this.ctx),s)){H.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,h=new Path2D;h.rect(r,a,o-r,l-a),this.ctx.clip(h),(i=this.dependencyTracker)==null||i.recordClipBox(e,this.ctx,r,o,a,l),this.endPath(e)}}paintFormXObjectEnd(e){this.contentVisible&&(this.restore(e),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e,t){var E;if(!this.contentVisible)return;this.save(e);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;if((!t.needsIsolation||!t.isolated&&!t.hasSoftMask)&&!t.knockout&&!t.isGray&&n(this,ys)===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(t.bbox){let S=new Path2D;const[T,x,C,I]=t.bbox;if(S.rect(T,x,C-T,I-x),t.matrix){const O=new Path2D;O.addPath(S,new DOMMatrix(t.matrix)),S=O}i.clip(S)}this.groupStack.push(null),n(this,Bi).push(null),this.groupLevel++;return}!t.isolated&&!t.knockout&&n(this,ys)===0&&qf("TODO: Fully support non-isolated non-knockout groups.");const r=Ut(i);t.matrix&&i.transform(...t.matrix);const a=[0,0,i.canvas.width,i.canvas.height];let o;t.bbox?(o=pa.slice(),H.axialAlignedBoundingBox(t.bbox,Ut(i),o),o=H.intersect(o,a)||[0,0,0,0]):o=a;const l=Math.floor(o[0]),h=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-l,1),u=Math.max(Math.ceil(o[3])-h,1);this.current.startNewPathAndClipBox([0,0,c,u]);const f=this.canvasFactory.create(c,u);t.smask&&this.smaskGroupCanvases.push(f);const p=f.context,m=t.knockout&&!t.isolated?i:null,v=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&n(this,ys)>0,A=t.knockout?this.canvasFactory.create(c,u):null,w=n(this,ys);if(t.knockout?$t(this,ys)._++:g(this,ys,0),p.translate(-l,-h),p.transform(...r),!t.isolated&&!t.smask&&s&&t.needsIsolation&&(p.save(),p.setTransform(1,0,0,1,0,0),p.drawImage(i.canvas,-l,-h),p.restore()),t.bbox){let S=new Path2D;const[T,x,C,I]=t.bbox;if(S.rect(T,x,C-T,I-x),t.matrix){const O=new Path2D;O.addPath(S,new DOMMatrix(t.matrix)),S=O}p.clip(S)}t.smask&&this.smaskStack.push({canvas:f.canvas,context:p,offsetX:l,offsetY:h,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null}),(!t.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(l,h),i.save()),na(i,p),this.ctx=p,(E=this.dependencyTracker)==null||E.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(e,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),n(this,Bi).push({backdropCtx:m,savedKnockoutLevel:w,offsetX:l,offsetY:h,hasInnerBackdrop:v,knockoutMaskEntry:A,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(e,t){var a;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop(),r=n(this,Bi).pop();if(r&&g(this,ys,r.savedKnockoutLevel),i===null){this.restore(e);return}if(t.isGray&&b(this,Y,ey).call(this,s),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(a=this.dependencyTracker)==null||a.popBaseTransform(),t.smask)this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),b(this,Y,Uu).call(this,r);else{this.ctx.restore();const o=Ut(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...o);const l=pa.slice();H.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],o,l);const h=n(this,Bi).at(-1);if(n(this,ys)>0)if(r.hasInnerBackdrop){const{width:c,height:u}=s.canvas,f=this.canvasFactory.create(c,u),p=f.context;p.drawImage(i.canvas,r.offsetX,r.offsetY,c,u,0,0,c,u),p.globalCompositeOperation="source-over",p.drawImage(s.canvas,0,0);const m=b(this,Y,qp).call(this,s.canvas);p.globalCompositeOperation="destination-in",p.drawImage(m.canvas,0,0);const v=this.ctx.globalCompositeOperation,A=this.ctx.globalAlpha,w=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...o),this.ctx.globalAlpha=1,It.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(m.canvas,0,0),this.ctx.globalCompositeOperation=v,this.ctx.globalAlpha=A,It.isCanvasFilterSupported&&(this.ctx.filter=w??"none"),this.ctx.drawImage(f.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(m),this.canvasFactory.destroy(f)}else{const c=(h==null?void 0:h.backdropCtx)??null;b(this,Y,eg).call(this,this.ctx,s.canvas,{backdropCanvas:(c==null?void 0:c.canvas)??null,destTransform:o,backdropOffset:c?[h.offsetX+r.offsetX,h.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(s.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),b(this,Y,Uu).call(this,r),this.compose(l)}}beginAnnotation(e,t,s,i,r,a,o){if(b(this,Y,Qp).call(this),wu(this.ctx),this.ctx.save(),this.save(e),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const l=s[2]-s[0],h=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=l,s[3]=h,H.singularValueDecompose2dScale(Ut(this.ctx),Ls);const{viewportScale:c}=this,u=Math.ceil(l*this.outputScaleX*c),f=Math.ceil(h*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(u,f);const{canvas:p,context:m}=this.annotationCanvas;if(o){const v=this.annotationCanvasMap.getOrInsertComputed(t,Uh);p.setAttribute("data-canvas-name",o);const A=v.findIndex(w=>w.getAttribute("data-canvas-name")===o);A===-1?v.push(p):v[A]=p}else this.annotationCanvasMap.set(t,p);this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(Ls[0],0,0,-Ls[1],0,h*Ls[1]),wu(this.ctx)}else{wu(this.ctx),this.endPath(e);const c=new Path2D;c.rect(s[0],s[1],l,h),this.ctx.clip(c)}}this.current=new Fm(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(e,...i),this.transform(e,...r),this.baseTransform=Ut(this.ctx)}endAnnotation(e){this.annotationCanvas&&(this.ctx.restore(),b(this,Y,Zp).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(e,t){var l;if(!this.contentVisible)return;const s=t.count;t=this.getObject(e,t.data,t),t.count=s;const i=b(this,Y,es).call(this,this.current.fillAlpha),r=this.ctx,a=this._createMaskCanvas(e,t),o=a.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(o,a.offsetX,a.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(e).recordBBox(e,this.ctx,a.offsetX,a.offsetX+o.width,a.offsetY,a.offsetY+o.height).recordOperation(e),r.restore(),a.canvasEntry&&this.canvasFactory.destroy(a.canvasEntry),this.compose(),b(this,Y,Fe).call(this,i)}paintImageMaskXObjectRepeat(e,t,s,i=0,r=0,a,o){var f,p,m;if(!this.contentVisible)return;t=this.getObject(e,t.data,t);const l=b(this,Y,es).call(this,this.current.fillAlpha),h=this.ctx;h.save();const c=Ut(h);h.transform(s,i,r,a,0,0);const u=this._createMaskCanvas(e,t);h.setTransform(1,0,0,1,u.offsetX-c[4],u.offsetY-c[5]),(f=this.dependencyTracker)==null||f.resetBBox(e);for(let v=0,A=o.length;v<A;v+=2){const w=H.transform(c,[s,i,r,a,o[v],o[v+1]]);h.drawImage(u.canvas,w[4],w[5]),(p=this.dependencyTracker)==null||p.recordBBox(e,this.ctx,w[4],w[4]+u.canvas.width,w[5],w[5]+u.canvas.height)}h.restore(),u.canvasEntry&&this.canvasFactory.destroy(u.canvasEntry),this.compose(),(m=this.dependencyTracker)==null||m.recordOperation(e),b(this,Y,Fe).call(this,l)}paintImageMaskXObjectGroup(e,t){var o,l,h;if(!this.contentVisible)return;const s=b(this,Y,es).call(this,this.current.fillAlpha),i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(e).recordDependencies(e,Hs.transformAndFill);for(const c of t){const{data:u,width:f,height:p,transform:m}=c,v=this.canvasFactory.create(f,p),A=v.context;A.save();const w=this.getObject(e,u,c);Bm(A,w),A.globalCompositeOperation="source-in",A.fillStyle=a?r.getPattern(A,this,Si(i),De.FILL,e):r,A.fillRect(0,0,f,p),A.restore(),i.save(),i.transform(...m),i.scale(1,-1),Au(i,v.canvas,0,0,f,p,0,-1,1,1),this.canvasFactory.destroy(v),(l=this.dependencyTracker)==null||l.recordBBox(e,i,0,f,0,p),i.restore()}this.compose(),(h=this.dependencyTracker)==null||h.recordOperation(e),b(this,Y,Fe).call(this,s)}paintImageXObject(e,t){if(!this.contentVisible)return;const s=this.getObject(e,t);if(!s){it("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e,s)}paintImageXObjectRepeat(e,t,s,i,r){if(!this.contentVisible)return;const a=this.getObject(e,t);if(!a){it("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,u=r.length;c<u;c+=2)h.push({transform:[s,0,0,i,r[c],r[c+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(e,a,h)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return{img:e.bitmap,canvasEntry:null};const{bitmap:t,width:s,height:i}=e,r=this.canvasFactory.create(s,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(t,0,0),a.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(e,t){var u;if(!this.contentVisible)return;const s=t.width,i=t.height,r=b(this,Y,es).call(this,this.current.fillAlpha),a=this.ctx;this.save(e);const{filter:o}=a;o!=="none"&&o!==""&&(a.filter="none"),a.scale(1/s,-1/i);let l,h=null;if(t.bitmap){const f=this.applyTransferMapsToBitmap(t);l=f.img,h=f.canvasEntry}else{const f=this.canvasFactory.create(s,i);Nm(f.context,t),l=this.applyTransferMapsToCanvas(f.context),h=f}const c=this._scaleImage(l,Si(a));a.imageSmoothingEnabled=Um(Ut(a),t.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(e).recordBBox(e,a,0,s,-i,0).recordDependencies(e,Hs.imageXObject).recordOperation(e),(u=this.imagesTracker)==null||u.record(a,s,i,this.dependencyTracker.clipBox)),Au(a,c.img,0,0,c.paintWidth,c.paintHeight,0,-i,s,i),c.tmpCanvas&&this.canvasFactory.destroy(c.tmpCanvas),h&&this.canvasFactory.destroy(h),this.compose(),this.restore(e),b(this,Y,Fe).call(this,r)}paintInlineImageXObjectGroup(e,t,s){var l,h,c;if(!this.contentVisible)return;const i=b(this,Y,es).call(this,this.current.fillAlpha),r=this.ctx;let a,o=null;if(t.bitmap)a=t.bitmap;else{const u=t.width,f=t.height,p=this.canvasFactory.create(u,f);Nm(p.context,t),a=this.applyTransferMapsToCanvas(p.context),o=p}(l=this.dependencyTracker)==null||l.resetBBox(e);for(const u of s)r.save(),r.transform(...u.transform),r.scale(1,-1),Au(r,a,u.x,u.y,u.w,u.h,0,-1,1,1),(h=this.dependencyTracker)==null||h.recordBBox(e,r,0,1,-1,0),r.restore();o&&this.canvasFactory.destroy(o),(c=this.dependencyTracker)==null||c.recordOperation(e),this.compose(),b(this,Y,Fe).call(this,i)}paintSolidColorImageMask(e){var s;if(!this.contentVisible)return;const t=b(this,Y,es).call(this,this.current.fillAlpha);(s=this.dependencyTracker)==null||s.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,Hs.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose(),b(this,Y,Fe).call(this,t)}markPoint(e,t){}markPointProps(e,t,s){}beginMarkedContent(e,t){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,s){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(e),t==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(e){var t;(t=this.dependencyTracker)==null||t.endMarkedContent(e),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,t,s){var a,o;const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===Hm?r.clip(t,"evenodd"):r.clip(t)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)):(o=this.dependencyTracker)==null||o.recordOperation(e),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Ut(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),s=Math.hypot(e[0],e[2]),i=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:e}=this.current,{a:t,b:s,c:i,d:r}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(t),h=Math.abs(r);if(l===h)if(e===0)a=o=1/l;else{const c=l*e;a=o=c<1?1/c:1}else if(e===0)a=1/l,o=1/h;else{const c=l*e,u=h*e;a=c<1?1/c:1,o=u<1?1/u:1}}else{const l=Math.abs(t*r-s*i),h=Math.hypot(t,s),c=Math.hypot(i,r);if(e===0)a=c/l,o=h/l;else{const u=e*l;a=c>u?c/u:1,o=h>u?h/u:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,t){const{ctx:s,current:{lineWidth:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(e);return}const o=s.getLineDash();t&&s.save(),s.scale(r,a),Ap.a=1/r,Ap.d=1/a;const l=new Path2D;if(l.addPath(e,Ap),o.length>0){const h=Math.max(r,a);s.setLineDash(o.map(c=>c/h)),s.lineDashOffset/=h}s.lineWidth=i||1,s.stroke(l),t&&s.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};ys=new WeakMap,Cr=new WeakMap,Ya=new WeakMap,Ka=new WeakMap,Ja=new WeakMap,Qa=new WeakMap,Za=new WeakMap,qa=new WeakMap,to=new WeakMap,Bi=new WeakMap,Y=new WeakSet,Qp=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)},Zp=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}},qp=function(e,t=null,s=1){const{width:i,height:r}=e,a=t??this.canvasFactory.create(i,r),o=a.context;s=Math.round(s*255)/255;const l=s<1;l&&n(this,qa)===void 0&&g(this,qa,It.isCanvasFilterSupported?new Map:"none");let h="none";if(l&&n(this,qa)instanceof Map&&(h=n(this,qa).getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!l||h!=="none")return t&&(o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,i,r),o.restore()),o.filter=h,o.drawImage(e,0,0),o.filter="none",a;const c=e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,r),u=o.createImageData(i,r),f=c.data,p=u.data,m=s>0?1/s:1e6;for(let v=3,A=f.length;v<A;v+=4)p[v]=Math.min(Math.round(f[v]*m),255);return o.putImageData(u,0,0),a},tg=function(e,t,s,i){let r=(e==null?void 0:e[t])??null;if(r&&(r.canvas.width!==s||r.canvas.height!==i)&&(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(s,i),e&&(e[t]=r),r;const a=r.context;return a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,i),a.restore(),r},eg=function(e,t,s={}){const{backdropCanvas:i=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:a=[0,0],reuseMaskEntry:o=null,poolMeta:l=null,sourceAlpha:h=1,sourceFilter:c="none",knockoutAlpha:u=1}=s,{width:f,height:p}=t,m=b(this,Y,qp).call(this,t,o,u),v=e.globalCompositeOperation;if(e.save(),e.setTransform(...r),e.globalAlpha=1,It.isCanvasFilterSupported&&(e.filter="none"),e.globalCompositeOperation="destination-out",e.drawImage(m.canvas,0,0),i){const[A,w]=a,E=b(this,Y,tg).call(this,l,"knockoutBackdropEntry",f,p),S=E.context;S.drawImage(i,A,w,f,p,0,0,f,p),S.globalCompositeOperation="destination-in",S.drawImage(m.canvas,0,0),S.globalCompositeOperation="source-over",e.globalCompositeOperation="destination-over",e.drawImage(E.canvas,0,0),l||this.canvasFactory.destroy(E)}e.globalCompositeOperation=v,e.globalAlpha=h,It.isCanvasFilterSupported&&(e.filter=c??"none"),e.drawImage(t,0,0),e.restore(),o||this.canvasFactory.destroy(m)},es=function(e=1){if(n(this,ys)===0||n(this,Cr)>0||!this.contentVisible)return!1;$t(this,Cr)._++,g(this,Za,e);const t=n(this,Bi).at(-1),{canvas:s}=this.ctx,i=b(this,Y,tg).call(this,t,"knockoutTempEntry",s.width,s.height);g(this,Ya,i);const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),na(this.ctx,r),g(this,Qa,r.globalCompositeOperation),r.globalCompositeOperation="source-over",Lm(r,this.ctx),g(this,to,t),g(this,Ka,this.ctx),g(this,Ja,this.suspendedCtx),this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0},Fe=function(e){var l;if(!e)return;const t=n(this,Ya),s=n(this,Ka),i=n(this,Ja),r=t.context;g(this,Ya,null),g(this,Ka,null),g(this,Ja,null),this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=n(this,Qa),g(this,Qa,null),na(this.ctx,s),this.ctx=s;const a=n(this,to);g(this,to,null);const o=n(this,Za);g(this,Za,1);try{b(this,Y,eg).call(this,i??s,t.canvas,{backdropCanvas:((l=a==null?void 0:a.backdropCtx)==null?void 0:l.canvas)??null,backdropOffset:a!=null&&a.backdropCtx?[a.offsetX,a.offsetY]:[0,0],reuseMaskEntry:(a==null?void 0:a.knockoutMaskEntry)??null,poolMeta:a,knockoutAlpha:o})}finally{r.restore(),$t(this,Cr)._--,a||this.canvasFactory.destroy(t)}},sg=function(e,t,s){const i=new Path2D;return i.addPath(e,new DOMMatrix(s).invertSelf().multiplySelf(t)),i},ey=function(e){const{canvas:t}=e,{width:s,height:i}=t;if(It.isCanvasFilterSupported){e.save(),e.setTransform(1,0,0,1,0,0),e.filter="grayscale(1)",e.globalAlpha=1,e.globalCompositeOperation="copy",e.drawImage(t,0,0),e.restore();return}const r=e.getImageData(0,0,s,i),{data:a}=r;for(let o=0,l=a.length;o<l;o+=4){const h=a[o]*.2126+a[o+1]*.7152+a[o+2]*.0722+.5|0;a[o]=a[o+1]=a[o+2]=h}e.putImageData(r,0,0)},Uu=function(e){e&&(e.knockoutMaskEntry&&(this.canvasFactory.destroy(e.knockoutMaskEntry),e.knockoutMaskEntry=null),e.knockoutTempEntry&&(this.canvasFactory.destroy(e.knockoutTempEntry),e.knockoutTempEntry=null),e.knockoutBackdropEntry&&(this.canvasFactory.destroy(e.knockoutBackdropEntry),e.knockoutBackdropEntry=null))};let al=um;for(const d in yi)al.prototype[d]!==void 0&&(al.prototype[yi[d]]=al.prototype[d]);var nd,rd;class ap{constructor(e,t,s){y(this,nd,null);y(this,rd,null);P(this,"_fullReader",null);P(this,"_rangeReaders",new Set);P(this,"_source",null);this._source=e,g(this,nd,t),g(this,rd,s)}get _progressiveDataLength(){var e;return((e=this._fullReader)==null?void 0:e._loaded)??0}getFullReader(){return Jt(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new(n(this,nd))(this)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const s=new(n(this,rd))(this,e,t);return this._rangeReaders.add(s),s}cancelAllRequests(e){var t;(t=this._fullReader)==null||t.cancel(e);for(const s of new Set(this._rangeReaders))s.cancel(e)}}nd=new WeakMap,rd=new WeakMap;class op{constructor(e){P(this,"onProgress",null);P(this,"_contentLength",0);P(this,"_filename",null);P(this,"_headersCapability",Promise.withResolvers());P(this,"_isRangeSupported",!1);P(this,"_isStreamingSupported",!1);P(this,"_loaded",0);P(this,"_stream",null);this._stream=e}_callOnProgress(){var e;(e=this.onProgress)==null||e.call(this,{loaded:this._loaded,total:this._contentLength})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){bt("Abstract method `read` called")}cancel(e){bt("Abstract method `cancel` called")}}class lp{constructor(e,t,s){P(this,"_stream",null);this._stream=e}async read(){bt("Abstract method `read` called")}cancel(e){bt("Abstract method `cancel` called")}}function kA(d){let e=!0,t=s("filename\\*","i").exec(d);if(t){t=t[1];let c=o(t);return c=unescape(c),c=l(c),c=h(c),r(c)}if(t=a(d),t){const c=h(t);return r(c)}if(t=s("filename","i").exec(d),t){t=t[1];let c=o(t);return c=h(c),r(c)}function s(c,u){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(c,u){if(c){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(c,{fatal:!0}),p=tp(u);u=f.decode(p),e=!1}catch{}}return u}function r(c){return e&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),e&&(c=i("iso-8859-1",c))),c}function a(c){const u=[];let f;const p=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=p.exec(c))!==null;){let[,v,A,w]=f;if(v=parseInt(v,10),v in u){if(v===0)break;continue}u[v]=[A,w]}const m=[];for(let v=0;v<u.length&&v in u;++v){let[A,w]=u[v];w=o(w),A&&(w=unescape(w),v===0&&(w=l(w))),m.push(w)}return m.join("")}function o(c){if(c.startsWith('"')){const u=c.slice(1).split('\\"');for(let f=0;f<u.length;++f){const p=u[f].indexOf('"');p!==-1&&(u[f]=u[f].slice(0,p),u.length=f+1),u[f]=u[f].replaceAll(/\\(.)/g,"$1")}c=u.join('"')}return c}function l(c){const u=c.indexOf("'");if(u===-1)return c;const f=c.slice(0,u),m=c.slice(u+1).replace(/^[^']*'/,"");return i(f,m)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(u,f,p,m){if(p==="q"||p==="Q")return m=m.replaceAll("_"," "),m=m.replaceAll(/=([0-9a-f]{2})/gi,function(v,A){return String.fromCharCode(parseInt(A,16))}),i(f,m);try{m=atob(m)}catch{}return i(f,m)})}return""}function sy(d,e){const t=new Headers;if(!d||!e||typeof e!="object")return t;for(const s in e){const i=e[s];i!==void 0&&t.append(s,i)}return t}function hp(d){var e;return((e=URL.parse(d))==null?void 0:e.origin)??null}function iy({responseHeaders:d,isHttp:e,rangeChunkSize:t,disableRange:s}){const i={contentLength:0,isRangeSupported:!1},r=parseInt(d.get("Content-Length"),10);return!Number.isInteger(r)||(i.contentLength=r,r<=2*t)||s||!e||d.get("Accept-Ranges")!=="bytes"||(d.get("Content-Encoding")||"identity")==="identity"&&(i.isRangeSupported=!0),i}function ny(d){const e=d.get("Content-Disposition");if(e){let t=kA(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(np(t))return t}return null}function cp(d,e){return new yc(`Unexpected server response (${d}) while retrieving PDF "${e.href}".`,d,d===404||d===0&&e.protocol==="file:")}function ry(d,e){if(d!==e)throw new Error(`Expected range response-origin "${d}" to match "${e}".`)}function ay(d,e,t,s){return fetch(d,{method:"GET",headers:e,signal:s.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"})}function oy(d,e){if(d!==200&&d!==206)throw cp(d,e)}function dp(d){if(d instanceof Uint8Array)return d.buffer;if(d instanceof ArrayBuffer)return d;throw new Error(`getArrayBuffer - unexpected data: ${d}`)}class LA extends ap{constructor(t){super(t,FA,NA);P(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=t;Jt(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=sy(!0,s)}}class FA extends op{constructor(t){super(t);P(this,"_abortController",new AbortController);P(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a,withCredentials:o}=t._source;this._isStreamingSupported=!i;const l=new Headers(t.headers);ay(a,l,o,this._abortController).then(h=>{t._responseOrigin=hp(h.url),oy(h.status,a),this._reader=h.body.getReader();const c=h.headers,{contentLength:u,isRangeSupported:f}=iy({responseHeaders:c,isHttp:!0,rangeChunkSize:r,disableRange:s});this._contentLength=u,this._isRangeSupported=f,this._filename=ny(c),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Xn("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:t,done:s}=await this._reader.read();return s?{value:t,done:s}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:dp(t),done:!1})}cancel(t){var s;(s=this._reader)==null||s.cancel(t),this._abortController.abort()}}class NA extends lp{constructor(t,s,i){super(t,s,i);P(this,"_abortController",new AbortController);P(this,"_readCapability",Promise.withResolvers());P(this,"_reader",null);const{url:r,withCredentials:a}=t._source,o=new Headers(t.headers);o.append("Range",`bytes=${s}-${i-1}`),ay(r,o,a,this._abortController).then(l=>{const h=hp(l.url);ry(h,t._responseOrigin),oy(l.status,r),this._reader=l.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:t,done:s}=await this._reader.read();return s?{value:t,done:s}:{value:dp(t),done:!1}}cancel(t){var s;(s=this._reader)==null||s.cancel(t),this._abortController.abort()}}function $m(d){return d instanceof Uint8Array&&d.byteLength===d.buffer.byteLength?d.buffer:new Uint8Array(d).buffer}function up(){for(const d of this._requests)d.resolve({value:void 0,done:!0});this._requests.length=0}var $f,ly;class BA extends ap{constructor(t){super(t,UA,HA);y(this,$f);P(this,"_progressiveDone",!1);P(this,"_queuedChunks",[]);const{pdfDataRangeTransport:s}=t,{initialData:i,progressiveDone:r}=s;if((i==null?void 0:i.length)>0){const o=$m(i);this._queuedChunks.push(o)}this._progressiveDone=r;const a=o=>{var l;switch(o.type){case"range":case"progressiveRead":b(this,$f,ly).call(this,o.begin,o.chunk);break;case"progressiveDone":(l=this._fullReader)==null||l.progressiveDone(),this._progressiveDone=!0;break}};s.transportReady(a)}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,s){const i=super.getRangeReader(t,s);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,s)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}$f=new WeakSet,ly=function(t,s){const i=$m(s);if(t===void 0)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const r=this._rangeReaders.keys().find(a=>a._begin===t);Jt(r,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),r._enqueue(i)}};var ad;class UA extends op{constructor(t){super(t);y(this,ad,up.bind(this));P(this,"_done",!1);P(this,"_queuedChunks",null);P(this,"_requests",[]);const{pdfDataRangeTransport:s,disableRange:i,disableStream:r}=t._source,{length:a,contentDispositionFilename:o}=s;this._queuedChunks=t._queuedChunks||[];for(const h of this._queuedChunks)this._loaded+=h.byteLength;this._done=t._progressiveDone,this._contentLength=a,this._isStreamingSupported=!r,this._isRangeSupported=!i,np(o)&&(this._filename=o),this._headersCapability.resolve();const l=this._loaded;Promise.resolve().then(()=>{l>0&&this._loaded===l&&this._callOnProgress()})}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,n(this,ad).call(this)}progressiveDone(){this._done||(this._done=!0),this._queuedChunks.length===0&&n(this,ad).call(this)}}ad=new WeakMap;var od;class HA extends lp{constructor(t,s,i){super(t,s,i);y(this,od,up.bind(this));P(this,"onDone",null);P(this,"_begin",-1);P(this,"_done",!1);P(this,"_queuedChunk",null);P(this,"_requests",[]);this._begin=s}_enqueue(t){var s;this._done||(this._requests.length===0?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),n(this,od).call(this)),this._done=!0,(s=this.onDone)==null||s.call(this))}async read(){if(this._queuedChunk){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){var s;this._done=!0,n(this,od).call(this),(s=this.onDone)==null||s.call(this)}}od=new WeakMap;const wp=200,jm=206;function $A(d){return typeof d!="string"?d:tp(d).buffer}var Ui,Bh,hy,cy;class jA extends ap{constructor(t){super(t,GA,_A);y(this,Bh);y(this,Ui,new WeakMap);P(this,"_responseOrigin",null);const{httpHeaders:s,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=sy(this.isHttp,s)}_request(t){const s=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};n(this,Ui).set(s,i),s.open("GET",this.url),s.withCredentials=this._source.withCredentials;for(const[r,a]of this.headers)s.setRequestHeader(r,a);return this.isHttp&&"begin"in t&&"end"in t?(s.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.validateStatus=r=>r===jm||r===wp):i.validateStatus=r=>r===wp,s.responseType="arraybuffer",Jt(t.onError,"Expected `onError` callback to be provided."),s.onerror=()=>t.onError(s.status),s.onreadystatechange=b(this,Bh,cy).bind(this,s),s.onprogress=b(this,Bh,hy).bind(this,s),s.send(null),s}_abortRequest(t){n(this,Ui).has(t)&&(n(this,Ui).delete(t),t.abort())}getRangeReader(t,s){const i=super.getRangeReader(t,s);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}Ui=new WeakMap,Bh=new WeakSet,hy=function(t,s){var r;const i=n(this,Ui).get(t);(r=i==null?void 0:i.onProgress)==null||r.call(i,s)},cy=function(t,s){const i=n(this,Ui).get(t);if(!i||(t.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),t.readyState!==4)||!n(this,Ui).has(t))return;if(n(this,Ui).delete(t),t.status===0&&this.isHttp){i.onError(t.status);return}const r=t.status||wp;if(!i.validateStatus(r)){i.onError(t.status);return}const a=$A(t.response);if(r===jm){const o=t.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(o)?i.onDone(a):(it('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone(a):i.onError(t.status)};var ld,Zi,dy,uy,fy,py;class GA extends op{constructor(t){super(t);y(this,Zi);y(this,ld,up.bind(this));P(this,"_cachedChunks",[]);P(this,"_done",!1);P(this,"_requests",[]);P(this,"_storedError",null);this._fullRequestXhr=t._request({onHeadersReceived:b(this,Zi,dy).bind(this),onDone:b(this,Zi,uy).bind(this),onError:b(this,Zi,fy).bind(this),onProgress:b(this,Zi,py).bind(this)})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),n(this,ld).call(this),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}ld=new WeakMap,Zi=new WeakSet,dy=function(){const t=this._stream,{disableRange:s,rangeChunkSize:i}=t._source,r=this._fullRequestXhr;t._responseOrigin=hp(r.responseURL);const a=r.getAllResponseHeaders(),o=new Headers(a?a.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(c=>{const[u,...f]=c.split(": ");return[u,f.join(": ")]}):[]),{contentLength:l,isRangeSupported:h}=iy({responseHeaders:o,isHttp:t.isHttp,rangeChunkSize:i,disableRange:s});this._contentLength=l,this._isRangeSupported=h,this._filename=ny(o),this._isRangeSupported&&t._abortRequest(r),this._headersCapability.resolve()},uy=function(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,this._cachedChunks.length===0&&n(this,ld).call(this)},fy=function(t){this._storedError=cp(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0},py=function(t){var s;(s=this.onProgress)==null||s.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})};var hd,Jn,gy,my,ig;class _A extends lp{constructor(t,s,i){super(t,s,i);y(this,Jn);y(this,hd,up.bind(this));P(this,"onClosed",null);P(this,"_done",!1);P(this,"_queuedChunk",null);P(this,"_requests",[]);P(this,"_storedError",null);this._requestXhr=t._request({begin:s,end:i,onHeadersReceived:b(this,Jn,gy).bind(this),onDone:b(this,Jn,my).bind(this),onError:b(this,Jn,ig).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const s=this._queuedChunk;return this._queuedChunk=null,{value:s,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){var s;this._done=!0,n(this,hd).call(this),this._stream._abortRequest(this._requestXhr),(s=this.onClosed)==null||s.call(this)}}hd=new WeakMap,Jn=new WeakSet,gy=function(){var s;const t=hp((s=this._requestXhr)==null?void 0:s.responseURL);try{ry(t,this._stream._responseOrigin)}catch(i){this._storedError=i,b(this,Jn,ig).call(this,0)}},my=function(t){var s;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,n(this,hd).call(this),(s=this.onClosed)==null||s.call(this)},ig=function(t){this._storedError??(this._storedError=cp(t,this._stream.url));for(const s of this._requests)s.reject(this._storedError);this._requests.length=0,this._queuedChunk=null};function vy(d,e=null){const t=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=t.createReadStream(d,e);return s.toWeb(i)}class zA extends ap{constructor(e){super(e,WA,VA);const{url:t}=e;Jt(t.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class WA extends op{constructor(t){super(t);P(this,"_reader",null);const{disableRange:s,disableStream:i,rangeChunkSize:r,url:a}=t._source;this._isStreamingSupported=!i,process.getBuiltinModule("fs/promises").lstat(a).then(l=>{const h=vy(a);this._reader=h.getReader();const{size:c}=l;this._contentLength=c,this._isRangeSupported=!s&&c>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Xn("Streaming is disabled.")),this._headersCapability.resolve()}).catch(l=>{l.code==="ENOENT"&&(l=cp(0,a)),this._headersCapability.reject(l)})}async read(){await this._headersCapability.promise;const{value:t,done:s}=await this._reader.read();return s?{value:t,done:s}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:dp(t),done:!1})}cancel(t){var s;(s=this._reader)==null||s.cancel(t)}}class VA extends lp{constructor(t,s,i){super(t,s,i);P(this,"_readCapability",Promise.withResolvers());P(this,"_reader",null);const{url:r}=t._source;try{const a=vy(r,{start:s,end:i-1});this._reader=a.getReader(),this._readCapability.resolve()}catch(a){this._readCapability.reject(a)}}async read(){await this._readCapability.promise;const{value:t,done:s}=await this._reader.read();return s?{value:t,done:s}:{value:dp(t),done:!1}}cancel(t){var s;(s=this._reader)==null||s.cancel(t)}}function XA(d){return fc(d)?LA:ks?zA:jA}var cd,dd;class bi{static get workerPort(){return n(this,cd)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");g(this,cd,e)}static get workerSrc(){return n(this,dd)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");g(this,dd,e)}}cd=new WeakMap,dd=new WeakMap,y(bi,cd,null),y(bi,dd,"");var $l,ud;class YA{constructor({parsedData:e,rawData:t}){y(this,$l);y(this,ud);g(this,$l,e),g(this,ud,t)}getRaw(){return n(this,ud)}get(e){return n(this,$l).get(e)??null}[Symbol.iterator](){return n(this,$l).entries()}}$l=new WeakMap,ud=new WeakMap;const oa=Symbol("INTERNAL");var fd,pd,jl,eo;class KA{constructor(e,{name:t,intent:s,usage:i,rbGroups:r}){y(this,fd,!1);y(this,pd,!1);y(this,jl,!1);y(this,eo,!0);g(this,fd,!!(e&Ds.DISPLAY)),g(this,pd,!!(e&Ds.PRINT)),this.name=t,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,jl))return n(this,eo);if(!n(this,eo))return!1;const{print:e,view:t}=this.usage;return n(this,fd)?(t==null?void 0:t.viewState)!=="OFF":n(this,pd)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,t,s=!1){e!==oa&&bt("Internal method `_setVisible` called."),g(this,jl,s),g(this,eo,t)}get serializable(){return{userSet:n(this,jl),visible:n(this,eo)}}}fd=new WeakMap,pd=new WeakMap,jl=new WeakMap,eo=new WeakMap;var Ir,wt,Gl,_l,gd,md,rg;const fm=class fm{constructor(e,t=Ds.DISPLAY,s=null){y(this,md);y(this,Ir,null);y(this,wt,new Map);y(this,Gl,null);y(this,_l,null);y(this,gd);P(this,"creator",null);P(this,"name",null);if(g(this,gd,e),this.renderingIntent=t,e!==null){this.name=e.name,this.creator=e.creator,g(this,_l,e.order);for(const i of e.groups)n(this,wt).set(i.id,new KA(t,i));if(s){s.size!==n(this,wt).size&&bt("Incorrect serialized groupState.");for(const[i,r]of s)n(this,wt).get(i)._setVisible(oa,r.visible,r.userSet)}else{if(e.baseState==="OFF")for(const i of n(this,wt).values())i._setVisible(oa,!1);for(const i of e.on)n(this,wt).get(i)._setVisible(oa,!0);for(const i of e.off)n(this,wt).get(i)._setVisible(oa,!1)}g(this,Gl,this.getHash())}}isVisible(e){if(n(this,wt).size===0)return!0;if(!e)return qf("Optional content group not defined."),!0;if(e.type==="OCG")return n(this,wt).has(e.id)?n(this,wt).get(e.id).visible:(it(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return b(this,md,rg).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const t of e.ids){if(!n(this,wt).has(t))return it(`Optional content group not found: ${t}`),!0;if(n(this,wt).get(t).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const t of e.ids){if(!n(this,wt).has(t))return it(`Optional content group not found: ${t}`),!0;if(!n(this,wt).get(t).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const t of e.ids){if(!n(this,wt).has(t))return it(`Optional content group not found: ${t}`),!0;if(!n(this,wt).get(t).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const t of e.ids){if(!n(this,wt).has(t))return it(`Optional content group not found: ${t}`),!0;if(n(this,wt).get(t).visible)return!1}return!0}return it(`Unknown optional content policy ${e.policy}.`),!0}return it(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,s=!0){var r;const i=n(this,wt).get(e);if(!i){it(`Optional content group not found: ${e}`);return}if(s&&t&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==e&&((r=n(this,wt).get(o))==null||r._setVisible(oa,!1,!0));i._setVisible(oa,!!t,!0),g(this,Ir,null)}setOCGState({state:e,preserveRB:t}){let s;for(const i of e){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,wt).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,t);break;case"OFF":this.setVisibility(i,!1,t);break;case"Toggle":this.setVisibility(i,!r.visible,t);break}}g(this,Ir,null)}get hasInitialVisibility(){return n(this,Gl)===null||this.getHash()===n(this,Gl)}getOrder(){return n(this,wt).size?n(this,_l)?n(this,_l).slice():[...n(this,wt).keys()]:null}getGroup(e){return n(this,wt).get(e)||null}getHash(){if(n(this,Ir)!==null)return n(this,Ir);const e=new _p;for(const[t,s]of n(this,wt))e.update(`${t}:${s.visible}`);return g(this,Ir,e.hexdigest())}[Symbol.iterator](){return n(this,wt).entries()}get serializable(){const e=new Map;for(const[t,s]of n(this,wt))e.set(t,s.serializable);return{data:n(this,gd),renderingIntent:this.renderingIntent,groupState:e}}static fromSerializable({data:e,renderingIntent:t,groupState:s}){return new fm(e,t,s)}};Ir=new WeakMap,wt=new WeakMap,Gl=new WeakMap,_l=new WeakMap,gd=new WeakMap,md=new WeakSet,rg=function(e){const t=e.length;if(t<2)return!0;const s=e[0];for(let i=1;i<t;i++){const r=e[i];let a;if(Array.isArray(r))a=b(this,md,rg).call(this,r);else if(n(this,wt).has(r))a=n(this,wt).get(r).visible;else return it(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};let ng=fm;var ne,ci,Pe,so,Hi,Ge,sc,ic,Hu;class JA{constructor(){y(this,Ge);y(this,ne,null);y(this,ci,null);y(this,Pe,0);y(this,so,null);y(this,Hi,null)}get pagesNumber(){return n(this,Pe)}set pagesNumber(e){n(this,Pe)!==e&&(g(this,Pe,e),g(this,ne,null),g(this,ci,null))}movePages(e,t,s){b(this,Ge,sc).call(this);const i=n(this,ne),r=b(this,Ge,ic).call(this),a=t.length,o=new Uint32Array(a);let l=0;for(let f=0;f<a;f++){const p=t[f]-1;o[f]=i[p],p<s&&l++}const h=n(this,Pe),c=h-a,u=Ht(s-l,0,c);for(let f=0,p=0;f<h;f++)e.has(f+1)||(i[p++]=i[f]);i.copyWithin(u+a,u,c),i.set(o,u),b(this,Ge,Hu).call(this,r),i.every((f,p)=>f===p+1)&&g(this,ne,null)}deletePages(e){b(this,Ge,sc).call(this);const t=n(this,ne),s=b(this,Ge,ic).call(this);g(this,Hi,{pageNumberToId:t.slice(),pagesNumber:n(this,Pe),prevPageNumbers:n(this,ci).slice()});const i=n(this,Pe)-e.length;g(this,Pe,i);const r=g(this,ne,new Uint32Array(i));g(this,ci,new Int32Array(i));let a=0,o=0;for(const l of e){const h=l-1;h!==a&&(r.set(t.subarray(a,h),o),o+=h-a),a=h+1}a<t.length&&r.set(t.subarray(a),o),b(this,Ge,Hu).call(this,s,new Set(e))}cancelDelete(){n(this,Hi)&&(g(this,ne,n(this,Hi).pageNumberToId),g(this,Pe,n(this,Hi).pagesNumber),g(this,ci,n(this,Hi).prevPageNumbers),g(this,Hi,null))}cleanSavedData(){g(this,Hi,null)}copyPages(e){b(this,Ge,sc).call(this),g(this,so,{pageNumbers:e,pageIds:e.map(t=>n(this,ne)[t-1])})}cancelCopy(){g(this,so,null)}pastePages(e){b(this,Ge,sc).call(this);const t=n(this,ne),s=b(this,Ge,ic).call(this),{pageNumbers:i,pageIds:r}=n(this,so),a=n(this,Pe)+i.length;g(this,Pe,a);const o=g(this,ne,new Uint32Array(a));g(this,ci,new Int32Array(a)),o.set(t.subarray(0,e),0),o.set(r,e),o.set(t.subarray(e),e+i.length),b(this,Ge,Hu).call(this,s,null,e,i),g(this,so,null)}hasBeenAltered(){return n(this,ne)!==null}getPageMappingForSaving(e=null){e??(e=b(this,Ge,ic).call(this));let t=0;for(const i of e.values())t=Math.max(t,i.length);const s=new Array(t);for(let i=0;i<t;i++)s[i]={document:null,pageIndices:[],includePages:[]};for(const[i,r]of e)for(let a=0,o=r.length;a<o;a++)s[a].includePages.push([i-1,r[a]-1]);for(const{includePages:i,pageIndices:r}of s){i.sort((a,o)=>a[0]-o[0]);for(let a=0,o=i.length;a<o;a++)r.push(i[a][1]),i[a]=i[a][0]}return s}extractPages(e){e=Array.from(e).sort((s,i)=>s-i);const t=new Map;for(let s=0,i=e.length;s<i;s++){const r=this.getPageId(e[s]);t.getOrInsertComputed(r,Uh).push(s+1)}return this.getPageMappingForSaving(t)}getPrevPageNumber(e){var t;return((t=n(this,ci))==null?void 0:t[e-1])??0}getPageNumber(e){if(!n(this,ne))return e;const t=n(this,ne);for(let s=0,i=n(this,Pe);s<i;s++)if(t[s]===e)return s+1;return 0}getPageId(e){var t;return((t=n(this,ne))==null?void 0:t[e-1])??e}getMapping(){var e;return(e=n(this,ne))==null?void 0:e.subarray(0,this.pagesNumber)}}ne=new WeakMap,ci=new WeakMap,Pe=new WeakMap,so=new WeakMap,Hi=new WeakMap,Ge=new WeakSet,sc=function(){if(n(this,ne))return;const e=n(this,Pe),t=g(this,ne,new Uint32Array(e));for(let s=0;s<e;s++)t[s]=s+1;g(this,ci,new Int32Array(t))},ic=function(){const e=new Map,t=n(this,ne);for(let s=0,i=n(this,Pe);s<i;s++){const r=t[s],a=e.get(r);a?a.push(s+1):e.set(r,[s+1])}return e},Hu=function(e,t=null,s=-1,i=null){const r=n(this,ci),a=n(this,ne),o=s+((i==null?void 0:i.length)??0),l=new Map;for(let h=0,c=n(this,Pe);h<c;h++){if(h>=s&&h<o){r[h]=-i[h-s];continue}const u=a[h],f=e.get(u);let p=l.get(u)||0;if(t&&f)for(;p<f.length&&t.has(f[p]);)p++;r[h]=f==null?void 0:f[p],l.set(u,p+1)}};const tl=Symbol("INITIAL_DATA"),Gm=()=>({...Promise.withResolvers(),data:tl});var Ks;class yy{constructor(){y(this,Ks,new Map)}get(e,t=null){if(t){const i=n(this,Ks).getOrInsertComputed(e,Gm);return i.promise.then(()=>t(i.data)),null}const s=n(this,Ks).get(e);if(!s||s.data===tl)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return s.data}has(e){const t=n(this,Ks).get(e);return!!t&&t.data!==tl}delete(e){const t=n(this,Ks).get(e);return!t||t.data===tl?!1:(n(this,Ks).delete(e),!0)}resolve(e,t=null){const s=n(this,Ks).getOrInsertComputed(e,Gm);if(s.data!==tl)throw new Error(`Object already resolved ${e}.`);s.data=t,s.resolve()}clear(){var e;for(const{data:t}of n(this,Ks).values())(e=t==null?void 0:t.bitmap)==null||e.close();n(this,Ks).clear()}*[Symbol.iterator](){for(const[e,{data:t}]of n(this,Ks))t!==tl&&(yield[e,t])}}Ks=new WeakMap;const QA=1e5,_m=30;var Km,Pr,Xe,vd,yd,zl,io,En,bd,Ad,no,wd,Wl,Mr,Vl,Ed,Xl,ro,Sd,xd,Yl,ao,Td,Kl,Jl,Qn,by,Ay,ag,Ns,$u,og,wy,Ey;const xe=class xe{constructor({textContentSource:e,images:t,container:s,viewport:i}){y(this,Qn);y(this,Pr,Promise.withResolvers());y(this,Xe,null);y(this,vd,!1);y(this,yd,!!((Km=globalThis.FontInspector)!=null&&Km.enabled));y(this,zl,null);y(this,io,null);y(this,En,null);y(this,bd,0);y(this,Ad,0);y(this,no,null);y(this,wd,null);y(this,Wl,0);y(this,Mr,0);y(this,Vl,Object.create(null));y(this,Ed,[]);y(this,Xl,null);y(this,ro,[]);y(this,Sd,new WeakMap);y(this,xd,null);var h;if(e instanceof ReadableStream)g(this,Xl,e);else if(typeof e=="object")g(this,Xl,new ReadableStream({start(c){c.enqueue(e),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');g(this,Xe,g(this,wd,s)),g(this,zl,t),g(this,Mr,i.scale*Ei.pixelRatio),g(this,Wl,i.rotation),g(this,En,{div:null,properties:null,ctx:null});const{pageWidth:r,pageHeight:a,pageX:o,pageY:l}=i.rawDims;g(this,xd,[1,0,0,-1,-o,l+a]),g(this,Ad,r),g(this,bd,a),b(h=xe,Ns,wy).call(h),s.style.setProperty("--min-font-size",n(xe,Kl)),ta(s,i),n(this,Pr).promise.finally(()=>{n(xe,Jl).delete(this),g(this,En,null),g(this,Vl,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=It.platform;return st(this,"fontFamilyMap",new Map([["sans-serif",`${e&&t?"Calibri, ":""}sans-serif`],["monospace",`${e&&t?"Lucida Console, ":""}monospace`]]))}render(){n(this,zl)&&n(this,Xe).append(n(this,zl).render());const e=()=>{n(this,no).read().then(({value:t,done:s})=>{if(s){n(this,Pr).resolve();return}n(this,io)??g(this,io,t.lang),Object.assign(n(this,Vl),t.styles),b(this,Qn,by).call(this,t.items),e()},n(this,Pr).reject)};return g(this,no,n(this,Xl).getReader()),n(xe,Jl).add(this),e(),n(this,Pr).promise}update({viewport:e,onBefore:t=null}){var r;const s=e.scale*Ei.pixelRatio,i=e.rotation;if(i!==n(this,Wl)&&(t==null||t(),g(this,Wl,i),ta(n(this,wd),{rotation:i})),s!==n(this,Mr)){t==null||t(),g(this,Mr,s);const a={div:null,properties:null,ctx:b(r=xe,Ns,$u).call(r,n(this,io))};for(const o of n(this,ro))a.properties=n(this,Sd).get(o),a.div=o,b(this,Qn,ag).call(this,a)}}cancel(){var t;const e=new Xn("TextLayer task cancelled.");(t=n(this,no))==null||t.cancel(e).catch(()=>{}),g(this,no,null),n(this,Pr).reject(e)}get textDivs(){return n(this,ro)}get textContentItemsStr(){return n(this,Ed)}static cleanup(){if(!(n(this,Jl).size>0)){n(this,Yl).clear();for(const{canvas:e}of n(this,ao).values())e.remove();n(this,ao).clear()}}};Pr=new WeakMap,Xe=new WeakMap,vd=new WeakMap,yd=new WeakMap,zl=new WeakMap,io=new WeakMap,En=new WeakMap,bd=new WeakMap,Ad=new WeakMap,no=new WeakMap,wd=new WeakMap,Wl=new WeakMap,Mr=new WeakMap,Vl=new WeakMap,Ed=new WeakMap,Xl=new WeakMap,ro=new WeakMap,Sd=new WeakMap,xd=new WeakMap,Yl=new WeakMap,ao=new WeakMap,Td=new WeakMap,Kl=new WeakMap,Jl=new WeakMap,Qn=new WeakSet,by=function(e){var i,r;if(n(this,vd))return;(r=n(this,En)).ctx??(r.ctx=b(i=xe,Ns,$u).call(i,n(this,io)));const t=n(this,ro),s=n(this,Ed);for(const a of e){if(t.length>QA){it("Ignoring additional textDivs for performance reasons."),g(this,vd,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,Xe);g(this,Xe,document.createElement("span")),n(this,Xe).classList.add("markedContent"),a.id&&n(this,Xe).setAttribute("id",`${a.id}`),a.tag==="Artifact"&&(n(this,Xe).ariaHidden=!0),o.append(n(this,Xe))}else a.type==="endMarkedContent"&&g(this,Xe,n(this,Xe).parentNode);continue}s.push(a.str),b(this,Qn,Ay).call(this,a)}},Ay=function(e){var m;const t=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};n(this,ro).push(t);const i=H.transform(n(this,xd),e.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,Vl)[e.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,yd)&&a.fontSubstitution||a.fontFamily;o=xe.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*b(m=xe,Ns,Ey).call(m,o,a,n(this,io));let c,u;r===0?(c=i[4],u=i[5]-h):(c=i[4]+h*Math.sin(r),u=i[5]-h*Math.cos(r));const f=t.style;f.left=`${(100*c/n(this,Ad)).toFixed(2)}%`,f.top=`${(100*u/n(this,bd)).toFixed(2)}%`,f.setProperty("--font-height",`${l.toFixed(2)}px`),f.fontFamily=o,s.fontSize=l,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,n(this,yd)&&(t.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),r!==0&&(s.angle=r*(180/Math.PI));let p=!1;if(e.str.length>1)p=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const v=Math.abs(e.transform[0]),A=Math.abs(e.transform[3]);v!==A&&Math.max(v,A)/Math.min(v,A)>1.5&&(p=!0)}if(p&&(s.canvasWidth=a.vertical?e.height:e.width),n(this,Sd).set(t,s),n(this,En).div=t,n(this,En).properties=s,b(this,Qn,ag).call(this,n(this,En)),s.hasText&&n(this,Xe).append(t),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),n(this,Xe).append(v)}},ag=function(e){var a;const{div:t,properties:s,ctx:i}=e,{style:r}=t;if(s.canvasWidth!==0&&s.hasText){const{fontFamily:o}=r,{canvasWidth:l,fontSize:h}=s;b(a=xe,Ns,og).call(a,i,h*n(this,Mr),o);const{width:c}=i.measureText(t.textContent);c>0&&r.setProperty("--scale-x",l*n(this,Mr)/c)}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)},Ns=new WeakSet,$u=function(e=null){let t=n(this,ao).get(e||(e=""));if(!t){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=e,document.body.append(s),t=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,ao).set(e,t),n(this,Td).set(t,{size:0,family:""})}return t},og=function(e,t,s){const i=n(this,Td).get(e);t===i.size&&s===i.family||(e.font=`${t}px ${s}`,i.size=t,i.family=s)},wy=function(){if(n(this,Kl)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),g(this,Kl,e.getBoundingClientRect().height),e.remove()},Ey=function(e,t,s){const i=n(this,Yl).get(e);if(i)return i;const r=b(this,Ns,$u).call(this,s);r.canvas.width=r.canvas.height=_m,b(this,Ns,og).call(this,r,_m,e);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return o?h=o/(o+l):(It.platform.isFirefox&&it("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),t.ascent?h=t.ascent:t.descent&&(h=1+t.descent)),n(this,Yl).set(e,h),h},y(xe,Ns),y(xe,Yl,new Map),y(xe,ao,new Map),y(xe,Td,new WeakMap),y(xe,Kl,null),y(xe,Jl,new Set);let Lh=xe;const ZA=100;function Sy(d={}){const e=new lg,{docId:t}=e,s=d.url?rA(d.url):null,i=d.data?aA(d.data):null,r=d.httpHeaders||null,a=d.withCredentials===!0,o=d.password??null,l=d.range instanceof nm?d.range:null,h=Number.isInteger(d.rangeChunkSize)&&d.rangeChunkSize>0?d.rangeChunkSize:2**16;let c=d.worker instanceof Fh?d.worker:null;const u=d.verbosity,f=typeof d.docBaseUrl=="string"&&!pu(d.docBaseUrl)?d.docBaseUrl:null,p=yu(d.cMapUrl),m=d.cMapPacked!==!1,v=yu(d.iccUrl),A=yu(d.standardFontDataUrl),w=yu(d.wasmUrl),E=d.stopAtErrors!==!0,S=Number.isInteger(d.maxImageSize)&&d.maxImageSize>-1?d.maxImageSize:-1,T=typeof d.isOffscreenCanvasSupported=="boolean"?d.isOffscreenCanvasSupported:!ks,x=typeof d.isImageDecoderSupported=="boolean"?d.isImageDecoderSupported:!ks,C=Number.isInteger(d.canvasMaxAreaInBytes)?d.canvasMaxAreaInBytes:-1,I=typeof d.disableFontFace=="boolean"?d.disableFontFace:ks,O=d.fontExtraProperties===!0,M=d.enableXfa===!0,R=d.ownerDocument||globalThis.document,D=d.disableRange===!0,j=d.disableStream===!0,F=d.disableAutoFetch===!0,U=d.pdfBug===!0,Z=d.CanvasFactory||(ks?fA:hA),L=d.FilterFactory||(ks?uA:cA),B=d.BinaryDataFactory||(ks?pA:Rm),q=d.enableHWA===!0,dt=d.enableWebGPU===!0?yA():Promise.resolve(!1),yt=d.useWasm!==!1,ct=d.pagesMapper||new JA,X=typeof d.useSystemFonts=="boolean"?d.useSystemFonts:!ks&&!I,ft=typeof d.useWorkerFetch=="boolean"?d.useWorkerFetch:!!(B===Rm&&p&&m&&A&&w&&fc(p,document.baseURI)&&fc(A,document.baseURI)&&fc(w,document.baseURI)),Ft=null;Lb(u);const N={canvasFactory:new Z({ownerDocument:R,enableHWA:q}),filterFactory:new L({docId:t,ownerDocument:R}),binaryDataFactory:ft?null:new B({cMapUrl:p,standardFontDataUrl:A,wasmUrl:w})};c||(c=Fh.create({verbosity:u,port:bi.workerPort}),e._worker=c);const k={docId:t,apiVersion:"6.1.200",data:i,password:o,disableAutoFetch:F,rangeChunkSize:h,docBaseUrl:f,enableXfa:M,evaluatorOptions:{maxImageSize:S,disableFontFace:I,ignoreErrors:E,isOffscreenCanvasSupported:T,isImageDecoderSupported:x,canvasMaxAreaInBytes:C,fontExtraProperties:O,useSystemFonts:X,useWasm:yt,useWorkerFetch:ft,cMapUrl:p,cMapPacked:m,iccUrl:v,standardFontDataUrl:A,wasmUrl:w,hasGPU:!1}},$={ownerDocument:R,pdfBug:U,styleElement:Ft,enableHWA:q,loadingParams:{disableAutoFetch:F,enableXfa:M}};return Promise.all([c.promise,dt]).then(function([,K]){if(c.destroyed)throw new Error("Worker was destroyed");k.evaluatorOptions.hasGPU=K;const gt=c.messageHandler.sendWithPromise("GetDocRequest",k,i?[i.buffer]:null);let J;if(!i)if(l)J=new BA({pdfDataRangeTransport:l,disableRange:D,disableStream:j});else if(s){const rt=XA(s);J=new rt({url:s,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:D,disableStream:j})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return gt.then(rt=>{if(c.destroyed)throw new Error("Worker was destroyed");const Pt=new Qh(t,rt,c.port),pe=new t0(Pt,e,J,$,N,ct);if(e._transport=pe,e.destroyed)throw new Error("Loading aborted");Pt.send("Ready",null)})}).catch(e._capability.reject).finally(e._setupCapability.resolve),e}var jf;const Gf=class Gf{constructor(){P(this,"_capability",Promise.withResolvers());P(this,"_setupCapability",Promise.withResolvers());P(this,"_transport",null);P(this,"_worker",null);P(this,"docId",`d${$t(Gf,jf)._++}`);P(this,"destroyed",!1);P(this,"onPassword",null);P(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var e,t,s,i;this.destroyed=!0,this._capability.promise.catch(()=>{});try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await((t=this._transport)==null?void 0:t.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};jf=new WeakMap,y(Gf,jf,0);let lg=Gf;var Ql,oo;class nm{constructor(e,t,s=!1,i=null){y(this,Ql,Promise.withResolvers());y(this,oo,null);this.length=e,this.initialData=t,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(e,t){n(this,oo).call(this,{type:"range",begin:e,chunk:t})}onDataProgressiveRead(e){n(this,Ql).promise.then(()=>{n(this,oo).call(this,{type:"progressiveRead",chunk:e})})}onDataProgressiveDone(){n(this,Ql).promise.then(()=>{n(this,oo).call(this,{type:"progressiveDone"})})}transportReady(e){g(this,oo,e),n(this,Ql).resolve()}requestDataRange(e,t){bt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}Ql=new WeakMap,oo=new WeakMap;class qA{constructor(e,t){this._pdfInfo=e,this._transport=t}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return st(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(e){return this._transport.getAttachmentContent(e)}getAnnotationsByType(e,t){return this._transport.getAnnotationsByType(e,t)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(e){return this._transport.extractPages(e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(e){return this._transport.getRawData(e)}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var Sn,lo,ho,nc;const pm=class pm{constructor(e,t,s,i,r=!1){y(this,ho);y(this,Sn,!1);y(this,lo,null);this._pageIndex=e,this._pageInfo=t,this._transport=s,this._stats=r?new Am:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new yy,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,g(this,lo,i),this.imageCoordinates=null}clone(e){const t=new pm(e,this._pageInfo,this._transport,n(this,lo),this._pdfBug);return t.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(t),t}get pageNumber(){return this._pageIndex+1}set pageNumber(e){this._pageIndex=e-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new fu({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return st(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,canvas:t=e.canvas,viewport:s,intent:i="display",annotationMode:r=_n.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:u=null,isEditing:f=!1,recordImages:p=!1,recordOperations:m=!1,operationsFilter:v=null}){var F,U,Z;(F=this._stats)==null||F.time("Overall");const A=this._transport.getRenderingIntent(i,r,u,f),{renderingIntent:w,cacheKey:E}=A;g(this,Sn,!1),l||(l=this._transport.getOptionalContentConfig(w));const S=this._intentStates.getOrInsertComputed(E,gf);S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);const T=!!(w&Ds.PRINT);S.displayReadyCapability||(S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(U=this._stats)==null||U.time("Page Request"),this._pumpOperatorList(A));const x=!!(this._pdfBug&&((Z=globalThis.StepperManager)!=null&&Z.enabled)),C=!!t&&!this.recordedBBoxes&&(m||x),I=!!t&&!this.imageCoordinates&&p,O=L=>{var B,q,W,dt;if(S.renderTasks.delete(D),C){const yt=(B=D.gfx)==null?void 0:B.dependencyTracker.take();yt&&((q=D.stepper)==null||q.setOperatorBBoxes(yt,D.gfx.dependencyTracker.takeDebugMetadata()),m&&(this.recordedBBoxes=yt))}I&&!L&&(this.imageCoordinates=(W=D.gfx)==null?void 0:W.imagesTracker.take()),T&&g(this,Sn,!0),b(this,ho,nc).call(this),L?(D.capability.reject(L),this._abortOperatorList({intentState:S,reason:L instanceof Error?L:new Error(L)})):D.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(dt=globalThis.Stats)!=null&&dt.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))};let M=null,R=null;(C||I)&&(R=new Jb(t,S.operatorList.length)),C&&(M=new Qb(R,x));const D=new cg({callback:O,params:{canvas:t,canvasContext:e,dependencyTracker:M??R,imagesTracker:I?new Vp(t):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!T,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:v});(S.renderTasks||(S.renderTasks=new Set)).add(D);const j=D.task;return Promise.all([S.displayReadyCapability.promise,l]).then(([L,B])=>{var q;if(this.destroyed){O();return}if((q=this._stats)==null||q.time("Rendering"),!(B.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");D.initializeGraphics({transparency:L,optionalContentConfig:B}),D.operatorListChanged()}).catch(O),j}getOperatorList({intent:e="display",annotationMode:t=_n.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(e,t,s,i,!0),o=this._intentStates.getOrInsertComputed(a.cacheKey,gf);let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:n(this,lo).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:t===!0},{highWaterMark:100,size(i){return i.items.length}})}async getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>bc.textContent(i));const t=this.streamTextContent(e),s={items:[],styles:Object.create(null),lang:null};for await(const i of t)s.lang??(s.lang=i.lang),Object.assign(s.styles,i.styles),s.items.push(...i.items);return s}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const s of t.renderTasks)e.push(s.completed),s.cancel();return this.objs.clear(),g(this,Sn,!1),Promise.all(e)}cleanup(e=!1){g(this,Sn,!0);const t=b(this,ho,nc).call(this);return e&&t&&this._stats&&(this._stats=new Am),t}_startRenderPage(e,t){var i,r;const s=this._intentStates.get(t);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(e))}_renderPageChunk(e,t){for(let s=0,i=e.length;s<i;s++)t.operatorList.fnArray.push(e.fnArray[s]),t.operatorList.argsArray.push(e.argsArray[s]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(const s of t.renderTasks)s.operatorListChanged();e.lastChunk&&b(this,ho,nc).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:n(this,lo).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:r,modifiedIds:i},void 0,a).getReader(),h=this._intentStates.get(t);h.streamReader=l;const c=()=>{l.read().then(({value:u,done:f})=>{if(f){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,h),c())},u=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const f of h.renderTasks)f.operatorListChanged();b(this,ho,nc).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(u);else if(h.opListReadCapability)h.opListReadCapability.reject(u);else throw u}})};c()}_abortOperatorList({intentState:e,reason:t,force:s=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!s){if(e.renderTasks.size>0)return;if(t instanceof ip){let i=ZA;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},i);return}}if(e.streamReader.cancel(new Xn(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===e){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}};Sn=new WeakMap,lo=new WeakMap,ho=new WeakSet,nc=function(){if(!n(this,Sn)||this.destroyed)return!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),g(this,Sn,!1),!0};let hg=pm;var Or,di,xn,co,_f,uo,fo,qe,ju,xy,Ty,rc,Zl,Gu;const Qt=class Qt{constructor({name:e=null,port:t=null,verbosity:s=Fb()}={}){y(this,qe);y(this,Or,Promise.withResolvers());y(this,di,null);y(this,xn,null);y(this,co,null);if(this.name=e,this.destroyed=!1,this.verbosity=s,t){if(n(Qt,fo).has(t))throw new Error("Cannot use more than one PDFWorker per port.");n(Qt,fo).set(t,this),b(this,qe,xy).call(this,t)}else b(this,qe,Ty).call(this)}get promise(){return n(this,Or).promise}get port(){return n(this,xn)}get messageHandler(){return n(this,di)}destroy(){var e,t;this.destroyed=!0,(e=n(this,co))==null||e.terminate(),g(this,co,null),n(Qt,fo).delete(n(this,xn)),g(this,xn,null),(t=n(this,di))==null||t.destroy(),g(this,di,null)}static create(e){const t=n(this,fo).get(e==null?void 0:e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new Qt(e)}static get workerSrc(){if(bi.workerSrc)return bi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return st(this,"_setupFakeWorkerGlobal",(async()=>n(this,Zl,Gu)?n(this,Zl,Gu):(await import(this.workerSrc)).WorkerMessageHandler)())}};Or=new WeakMap,di=new WeakMap,xn=new WeakMap,co=new WeakMap,_f=new WeakMap,uo=new WeakMap,fo=new WeakMap,qe=new WeakSet,ju=function(){n(this,Or).resolve(),n(this,di).send("configure",{verbosity:this.verbosity})},xy=function(e){g(this,xn,e),g(this,di,new Qh("main","worker",e)),n(this,di).on("ready",()=>{}),b(this,qe,ju).call(this)},Ty=function(){if(n(Qt,uo)||n(Qt,Zl,Gu)){b(this,qe,rc).call(this);return}let{workerSrc:e}=Qt;try{Qt._isSameOrigin(window.location,e)||(e=Qt._createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),s=new Qh("main","worker",t),i=()=>{r.abort(),s.destroy(),t.terminate(),this.destroyed?n(this,Or).reject(new Error("Worker was destroyed")):b(this,qe,rc).call(this)},r=new AbortController;t.addEventListener("error",()=>{n(this,co)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}g(this,di,s),g(this,xn,t),g(this,co,t),b(this,qe,ju).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{b(this,qe,rc).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{qf("The worker has been disabled.")}b(this,qe,rc).call(this)},rc=function(){n(Qt,uo)||(it("Setting up fake worker."),g(Qt,uo,!0)),Qt._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){n(this,Or).reject(new Error("Worker was destroyed"));return}const t=new lA;g(this,xn,t);const s=`fake${$t(Qt,_f)._++}`,i=new Qh(s+"_worker",s,t);e.setup(i,t),g(this,di,new Qh(s,s+"_worker",t)),b(this,qe,ju).call(this)}).catch(e=>{n(this,Or).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})},Zl=new WeakSet,Gu=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},y(Qt,Zl),y(Qt,_f,0),y(Qt,uo,!1),y(Qt,fo,new WeakMap),ks&&(g(Qt,uo,!0),bi.workerSrc||(bi.workerSrc="./pdf.worker.mjs")),Qt._isSameOrigin=(e,t)=>{const s=URL.parse(e);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(t,s);return s.origin===i.origin},Qt._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};let Fh=Qt;var bs,po,Tn,ui,go,ql,Cn,wi,ac,_u;class t0{constructor(e,t,s,i,r,a){y(this,wi);P(this,"downloadInfoCapability",Promise.withResolvers());y(this,bs,null);y(this,po,new Map);y(this,Tn,null);y(this,ui,new Map);y(this,go,new Map);y(this,ql,new Map);y(this,Cn,null);this.messageHandler=e,this.loadingTask=t,g(this,Tn,s),this.commonObjs=new yy,this.fontLoader=new Zb({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.enableHWA=i.enableHWA,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=a,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(e){const{_pageIndex:t}=e;n(this,ui).set(t,e),n(this,go).set(t,Promise.resolve(e))}get annotationStorage(){return st(this,"annotationStorage",new sm)}getRenderingIntent(e,t=_n.ENABLE,s=null,i=!1,r=!1){let a=Ds.DISPLAY,o=Ec;switch(e){case"any":a=Ds.ANY;break;case"display":break;case"print":a=Ds.PRINT;break;default:it(`getRenderingIntent - invalid intent: ${e}`)}const l=a&Ds.PRINT&&s instanceof Hv?s:this.annotationStorage;switch(t){case _n.DISABLE:a+=Ds.ANNOTATIONS_DISABLE;break;case _n.ENABLE:break;case _n.ENABLE_FORMS:a+=Ds.ANNOTATIONS_FORMS;break;case _n.ENABLE_STORAGE:a+=Ds.ANNOTATIONS_STORAGE,o=l.serializable;break;default:it(`getRenderingIntent - invalid annotationMode: ${t}`)}i&&(a+=Ds.IS_EDITING),r&&(a+=Ds.OPLIST);const{ids:h,hash:c}=l.modifiedIds,u=[a,o.hash,c];return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,Cn))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const i of n(this,ui).values())e.push(i._destroy());n(this,ui).clear(),n(this,go).clear(),n(this,ql).clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,po).clear(),this.filterFactory.destroy(),Lh.cleanup(),(i=n(this,Tn))==null||i.cancelAllRequests(new Xn("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(s,i)=>{Jt(n(this,Tn),"GetReader - no `BasePDFStream` instance available."),g(this,bs,n(this,Tn).getFullReader()),n(this,bs).onProgress=r=>b(this,wi,_u).call(this,r),i.onPull=()=>{n(this,bs).read().then(function({value:r,done:a}){if(a){i.close();return}Jt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{n(this,bs).cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),e.on("ReaderHeadersReady",async s=>{await n(this,bs).headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=n(this,bs);return i&&r&&(n(this,bs).onProgress=null),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),e.on("GetRangeReader",(s,i)=>{Jt(n(this,Tn),"GetRangeReader - no `BasePDFStream` instance available.");const r=n(this,Tn).getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}Jt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("GetDoc",({pdfInfo:s})=>{this.pagesMapper.pagesNumber=s.numPages,this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,t._capability.resolve(new qA(s,this))}),e.on("DocException",s=>{t._capability.reject(ss(s))}),e.on("PasswordRequest",s=>{g(this,Cn,Promise.withResolvers());try{if(!t.onPassword)throw ss(s);const i=r=>{r instanceof Error?n(this,Cn).reject(r):n(this,Cn).resolve({password:r})};t.onPassword(i,s.code)}catch(i){n(this,Cn).reject(i)}return n(this,Cn).promise}),e.on("DataLoaded",s=>{b(this,wi,_u).call(this,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),e.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,ui).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),e.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const f=r.error;it(`Error during font loading: ${f}`),this.commonObjs.resolve(s,f);break}const o=new sA(r),l=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(f,p)=>globalThis.FontInspector.fontAdded(f,p):null,h=new qb(o,l,r.charProcOperatorList,r.extra);this.fontLoader.bind(h).catch(()=>e.sendWithPromise("FontFallback",{id:s})).finally(()=>{h.fontExtraProperties||h.clearData(),this.commonObjs.resolve(s,h)});break;case"CopyLocalImage":const{imageRef:c}=r;Jt(c,"The imageRef must be defined.");for(const f of n(this,ui).values())for(const[,p]of f.objs){if((p==null?void 0:p.ref)!==c)continue;if(!p.dataLen)return null;const m=structuredClone(p);return this.commonObjs.resolve(s,m),p.dataLen}break;case"FontPath":this.commonObjs.resolve(s,new nA(r));break;case"Image":this.commonObjs.resolve(s,r);break;case"Pattern":const u=new iA(r);this.commonObjs.resolve(s,u.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),e.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,ui).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),e.on("DocProgress",s=>{this.destroyed||b(this,wi,_u).call(this,s)}),e.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&it("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((s=n(this,bs))==null?void 0:s.filename)??null},t).finally(()=>{this.annotationStorage.resetModified()})}extractPages(e){var r;const t={pageInfos:e};let s;const i=globalThis.ImageBitmap;if(typeof i=="function"){const a=Array.isArray(e)?e:[e];for(const o of a)(o==null?void 0:o.image)instanceof i&&(s||(s=[])).push(o.image)}if(this.annotationStorage.size>0){const a=this.annotationStorage.serializable;let{map:o}=a;(r=a.transfer)!=null&&r.length&&(s?s.push(...a.transfer):s=a.transfer);const l=this.pagesMapper.getMapping();if(l){const h=new Map;for(const[c,u]of o){if((u==null?void 0:u.pageIndex)!==void 0&&u.pageIndex>=0&&u.pageIndex<l.length){const f=l[u.pageIndex]-1;if(f!==u.pageIndex){h.set(c,{...u,pageIndex:f});continue}}h.set(c,u)}o=h}t.annotationStorage=o}return this.messageHandler.sendWithPromise("ExtractPages",t,s).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const t=e-1,s=this.pagesMapper.getPageId(e)-1,i=n(this,go).get(t);if(i)return i;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(a=>{if(this.destroyed)throw new Error("Transport destroyed");a.refStr&&n(this,ql).set(a.refStr,s);const o=new hg(t,a,this,this.pagesMapper,this._params.pdfBug);return n(this,ui).set(t,o),o});return n(this,go).set(t,r),r}async getPageIndex(e){if(!Yp(e))throw new Error("Invalid pageIndex request.");const t=await this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}),s=this.pagesMapper.getPageNumber(t+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return b(this,wi,ac).call(this,"GetFieldObjects")}hasJSActions(){return b(this,wi,ac).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(e){return this.messageHandler.sendWithPromise("GetAttachmentContent",e)}getAnnotationsByType(e,t){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:t})}getDocJSActions(){return b(this,wi,ac).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return b(this,wi,ac).call(this,"GetOptionalContentConfig").then(t=>new ng(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata";return n(this,po).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).then(t=>{var s,i;return{info:t[0],metadata:t[1]?new YA(t[1]):null,contentDispositionFilename:((s=n(this,bs))==null?void 0:s.filename)??null,contentLength:((i=n(this,bs))==null?void 0:i.contentLength)??null,hasStructTree:t[2]}}))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(e){return this.messageHandler.sendWithPromise("GetRawData",e)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of n(this,ui).values())if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),n(this,po).clear(),this.filterFactory.destroy(!0),Lh.cleanup()}}cachedPageNumber(e){if(!Yp(e))return null;const t=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`,s=n(this,ql).get(t);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}bs=new WeakMap,po=new WeakMap,Tn=new WeakMap,ui=new WeakMap,go=new WeakMap,ql=new WeakMap,Cn=new WeakMap,wi=new WeakSet,ac=function(e,t=null){return n(this,po).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))},_u=function({loaded:e,total:t}){var s,i;(i=(s=this.loadingTask).onProgress)==null||i.call(s,{loaded:e,total:t,percent:t?Ht(Math.round(e/t*100),0,100):NaN})};class e0{constructor(e){P(this,"_internalRenderTask",null);P(this,"onContinue",null);P(this,"onError",null);this._internalRenderTask=e}get promise(){return this._internalRenderTask.capability.promise}cancel(e=0){this._internalRenderTask.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this._internalRenderTask.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this._internalRenderTask;return e.form||e.canvas&&(t==null?void 0:t.size)>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var Rr,mo;const ua=class ua{constructor({callback:e,params:t,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:u=!1,pageColors:f=null,enableHWA:p=!1,operationsFilter:m=null}){y(this,Rr,null);this.callback=e,this.params=t,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new e0(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvas,this._canvasContext=t.canvas?null:t.canvasContext,this._enableHWA=p,this._dependencyTracker=t.dependencyTracker,this._imagesTracker=t.imagesTracker,this._operationsFilter=m}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var h,c;if(this.cancelled)return;if(this._canvas){if(n(ua,mo).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");n(ua,mo).add(this._canvas)}this._pdfBug&&((h=globalThis.StepperManager)!=null&&h.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a,imagesTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new al(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors,a,o),this.gfx.beginDrawing({transform:i,viewport:s,transparency:e,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(c=this.graphicsReadyCallback)==null||c.call(this)}cancel(e=null,t=0){var s,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,Rr)&&(window.cancelAnimationFrame(n(this,Rr)),g(this,Rr,null)),n(ua,mo).delete(this._canvas),e||(e=new ip(`Rendering cancelled, page ${this._pageIndex+1}`,t)),this.callback(e),(r=(i=this.task).onError)==null||r.call(i,e)}operatorListChanged(){var e,t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.gfx.dependencyTracker)==null||e.growOperationsCount(this.operatorList.fnArray.length),(t=this.stepper)==null||t.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?g(this,Rr,window.requestAnimationFrame(()=>{g(this,Rr,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n(ua,mo).delete(this._canvas),this.callback())))}};Rr=new WeakMap,mo=new WeakMap,y(ua,mo,new WeakSet);let cg=ua;const Cy="6.1.200",Iy="6353acefe";lt(3068);var As,vo,th,ue,Cd,eh,In,Id,Dr,fi,Pd,Lt,dg,ug,fg,la,Py,qn;const ns=class ns{constructor({editor:e=null,uiManager:t=null}){y(this,Lt);y(this,As,null);y(this,vo,null);y(this,th);y(this,ue,null);y(this,Cd,!1);y(this,eh,!1);y(this,In,null);y(this,Id);y(this,Dr,null);y(this,fi,null);var s,i;e?(g(this,eh,!1),g(this,In,e)):g(this,eh,!0),g(this,fi,(e==null?void 0:e._uiManager)||t),g(this,Id,n(this,fi)._eventBus),g(this,th,((s=e==null?void 0:e.color)==null?void 0:s.toUpperCase())||((i=n(this,fi))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n(ns,Pd)||g(ns,Pd,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return st(this,"_keyboardManager",new Vo([[["Escape"],ns.prototype._hideDropdownFromKeyboard],[["Space"],ns.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],ns.prototype._moveToNext],[["ArrowUp","ArrowLeft"],ns.prototype._moveToPrevious],[["Home"],ns.prototype._moveToBeginning],[["End"],ns.prototype._moveToEnd]]))}renderButton(){const e=g(this,As,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.ariaHasPopup="true",n(this,In)&&(e.ariaControls=`${n(this,In).id}_colorpicker_dropdown`);const t=n(this,fi)._signal;e.addEventListener("click",b(this,Lt,la).bind(this),{signal:t}),e.addEventListener("keydown",b(this,Lt,fg).bind(this),{signal:t});const s=g(this,vo,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,th),e.append(s),e}renderMainDropdown(){const e=g(this,ue,b(this,Lt,dg).call(this));return e.ariaOrientation="horizontal",e.ariaLabelledBy="highlightColorPickerLabel",e}_colorSelectFromKeyboard(e){if(e.target===n(this,As)){b(this,Lt,la).call(this,e);return}const t=e.target.getAttribute("data-color");t&&b(this,Lt,ug).call(this,t,e)}_moveToNext(e){var t,s;if(!n(this,Lt,qn)){b(this,Lt,la).call(this,e);return}if(e.target===n(this,As)){(t=n(this,ue).firstElementChild)==null||t.focus();return}(s=e.target.nextSibling)==null||s.focus()}_moveToPrevious(e){var t,s;if(e.target===((t=n(this,ue))==null?void 0:t.firstElementChild)||e.target===n(this,As)){n(this,Lt,qn)&&this._hideDropdownFromKeyboard();return}n(this,Lt,qn)||b(this,Lt,la).call(this,e),(s=e.target.previousSibling)==null||s.focus()}_moveToBeginning(e){var t;if(!n(this,Lt,qn)){b(this,Lt,la).call(this,e);return}(t=n(this,ue).firstElementChild)==null||t.focus()}_moveToEnd(e){var t;if(!n(this,Lt,qn)){b(this,Lt,la).call(this,e);return}(t=n(this,ue).lastElementChild)==null||t.focus()}hideDropdown(){var e,t;(e=n(this,ue))==null||e.classList.add("hidden"),n(this,As).ariaExpanded="false",(t=n(this,Dr))==null||t.abort(),g(this,Dr,null)}_hideDropdownFromKeyboard(){var e;if(!n(this,eh)){if(!n(this,Lt,qn)){(e=n(this,In))==null||e.unselect();return}this.hideDropdown(),n(this,As).focus({preventScroll:!0,focusVisible:n(this,Cd)})}}updateColor(e){if(n(this,vo)&&(n(this,vo).style.backgroundColor=e),!n(this,ue))return;const t=n(this,fi).highlightColors.values();for(const s of n(this,ue).children)s.ariaSelected=t.next().value===e.toUpperCase()}destroy(){var e,t;(e=n(this,As))==null||e.remove(),g(this,As,null),g(this,vo,null),(t=n(this,ue))==null||t.remove(),g(this,ue,null)}};As=new WeakMap,vo=new WeakMap,th=new WeakMap,ue=new WeakMap,Cd=new WeakMap,eh=new WeakMap,In=new WeakMap,Id=new WeakMap,Dr=new WeakMap,fi=new WeakMap,Pd=new WeakMap,Lt=new WeakSet,dg=function(){const e=document.createElement("div"),t=n(this,fi)._signal;e.addEventListener("contextmenu",Bs,{signal:t}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,In)&&(e.id=`${n(this,In).id}_colorpicker_dropdown`);for(const[s,i]of n(this,fi).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n(ns,Pd)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,th),r.addEventListener("click",b(this,Lt,ug).bind(this,i),{signal:t}),e.append(r)}return e.addEventListener("keydown",b(this,Lt,fg).bind(this),{signal:t}),e},ug=function(e,t){t.stopPropagation(),n(this,Id).dispatch("switchannotationeditorparams",{source:this,type:at.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)},fg=function(e){ns._keyboardManager.exec(this,e)},la=function(e){if(n(this,Lt,qn)){this.hideDropdown();return}if(g(this,Cd,e.detail===0),n(this,Dr)||(g(this,Dr,new AbortController),window.addEventListener("pointerdown",b(this,Lt,Py).bind(this),{signal:n(this,fi).combinedSignal(n(this,Dr))})),n(this,As).ariaExpanded="true",n(this,ue)){n(this,ue).classList.remove("hidden");return}const t=g(this,ue,b(this,Lt,dg).call(this));n(this,As).append(t)},Py=function(e){var t;(t=n(this,ue))!=null&&t.contains(e.target)||this.hideDropdown()},qn=function(){return n(this,ue)&&!n(this,ue).classList.contains("hidden")},y(ns,Pd,null);let xc=ns;var ws,sh,yo,Pn,Md;const fa=class fa{constructor(e){y(this,ws,null);y(this,sh,!1);y(this,yo,null);y(this,Pn,null);g(this,yo,e),g(this,Pn,e._uiManager),n(fa,Md)||g(fa,Md,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,ws))return n(this,ws);const{editorType:e,colorType:t,colorAndOpacityType:s,opacityType:i,color:r,opacity:a}=n(this,yo),o=g(this,sh,It.isAlphaColorInputSupported&&i!==void 0),l=g(this,ws,document.createElement("input"));if(l.type="color",o){l.setAttribute("alpha","");const h=H.hexNums[Math.round((a??1)*255)];l.value=(r||"#000000")+h}else l.value=r||"#000000";return l.className="basicColorPicker",l.tabIndex=0,l.setAttribute("data-l10n-id",n(fa,Md)[e]),l.addEventListener("input",()=>{if(o){const h=Hh(l.value);if(!h)return;const[c,u,f,p]=h,m=H.makeHexColor(c,u,f);s!==void 0?n(this,Pn).updateParams(s,{color:m,opacity:p}):(n(this,Pn).updateParams(t,m),n(this,Pn).updateParams(i,p))}else n(this,Pn).updateParams(t,l.value)},{signal:n(this,Pn)._signal}),l}update(e){if(n(this,ws))if(n(this,sh)){const t=H.hexNums[Math.round(n(this,yo).opacity*255)];n(this,ws).value=e+t}else n(this,ws).value=e}updateOpacity(e){if(!n(this,ws)||!n(this,sh))return;const t=H.hexNums[Math.round(e*255)];n(this,ws).value=n(this,yo).color+t}destroy(){var e;(e=n(this,ws))==null||e.remove(),g(this,ws,null)}hideDropdown(){}};ws=new WeakMap,sh=new WeakMap,yo=new WeakMap,Pn=new WeakMap,Md=new WeakMap,y(fa,Md,null);let yf=fa;lt(531);function zm(d){return Math.floor(Ht(d,0,1)*255).toString(16).padStart(2,"0")}function Gh(d){return Ht(d,0,1)*255}class Wm{static CMYK_G([e,t,s,i]){return["G",1-Math.min(1,.3*e+.59*s+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=Gh(e),[e,e,e]}static G_HTML([e]){const t=zm(e);return`#${t}${t}${t}`}static RGB_G([e,t,s]){return["G",.3*e+.59*t+.11*s]}static RGB_rgb(e){return e.map(Gh)}static RGB_HTML(e){return`#${e.map(zm).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,s,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,s+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,s,i]){return[Gh(1-Math.min(1,e+i)),Gh(1-Math.min(1,s+i)),Gh(1-Math.min(1,t+i))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,s]){const i=1-e,r=1-t,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class s0{create(e,t,s=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){bt("Abstract method `_createSVG` called.")}}class Tc extends s0{_createSVG(e){return document.createElementNS(ps,e)}}const i0=9,Xo=new WeakSet,n0=new Date().getTimezoneOffset()*60*1e3;class Ep{static create(e){switch(e.data.annotationType){case Xt.LINK:return new rm(e);case Xt.TEXT:return new a0(e);case Xt.WIDGET:switch(e.data.fieldType){case"Tx":return new o0(e);case"Btn":return e.data.radioButton?new c0(e):e.data.checkBox?new h0(e):new d0(e);case"Ch":return new u0(e);case"Sig":return new l0(e)}return new Jo(e);case Xt.POPUP:return new gg(e);case Xt.FREETEXT:return new Fy(e);case Xt.LINE:return new p0(e);case Xt.SQUARE:return new g0(e);case Xt.CIRCLE:return new m0(e);case Xt.POLYLINE:return new Ny(e);case Xt.CARET:return new y0(e);case Xt.INK:return new am(e);case Xt.POLYGON:return new v0(e);case Xt.HIGHLIGHT:return new By(e);case Xt.UNDERLINE:return new b0(e);case Xt.SQUIGGLY:return new A0(e);case Xt.STRIKEOUT:return new w0(e);case Xt.STAMP:return new Uy(e);case Xt.FILEATTACHMENT:return new E0(e);case Xt.RICHMEDIA:case Xt.SCREEN:return new Hy(e);default:return new Vt(e)}}}var bo,ih,Js,Od,pg;const gm=class gm{constructor(e,{isRenderable:t=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){y(this,Od);y(this,bo,null);y(this,ih,!1);y(this,Js,null);this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableComment=e.enableComment,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,this.hasOwnCommentButton=!1,t&&(this.contentElement=this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:t}){return!!(e!=null&&e.str||t!=null&&t.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return gm._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var s;const{data:e}=this,t=(s=this.annotationStorage)==null?void 0:s.getEditor(e.id);return t?t.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const e=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:t,inkLists:s,rect:i}=this.data;let r=-1/0,a=-1/0;if((t==null?void 0:t.length)>=8){for(let l=0;l<t.length;l+=8)t[l+1]>a?(a=t[l+1],r=t[l+2]):t[l+1]===a&&(r=Math.max(r,t[l+2]));return[r,a]}if((s==null?void 0:s.length)>=1){for(const l of s)for(let h=0,c=l.length;h<c;h+=2)l[h+1]>a?(a=l[h+1],r=l[h]):l[h+1]===a&&(r=Math.max(r,l[h]));if(r!==1/0)return[r,a]}return i?[i[2],i[3]]:null}_normalizePoint(e){const{page:{view:t},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}}=this.parent;return e[1]=t[3]-e[1]+t[1],e[0]=100*(e[0]-r)/s,e[1]=100*(e[1]-a)/i,e}get commentText(){var t,s,i;const{data:e}=this;return((s=(t=this.annotationStorage.getRawValue(`${vc}${e.id}`))==null?void 0:t.popup)==null?void 0:s.contents)||((i=e.contentsObj)==null?void 0:i.str)||""}set commentText(e){const{data:t}=this,s={deleted:!e,contents:e||""};this.annotationStorage.updateEditor(t.id,{popup:s})||this.annotationStorage.setValue(`${vc}${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:s,popupRef:t.popupRef,modificationDate:new Date}),e||this.removePopup()}removePopup(){var e,t;(t=((e=n(this,Js))==null?void 0:e.popup)||this.popup)==null||t.remove(),g(this,Js,this.popup=null)}updateEdited(e){var r;if(!this.container)return;e.rect&&(n(this,bo)||g(this,bo,{rect:this.data.rect.slice(0)}));const{rect:t,popup:s}=e;t&&b(this,Od,pg).call(this,t);let i=((r=n(this,Js))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,Js).popup),i&&(i.updateEdited(e),s!=null&&s.deleted&&(i.remove(),g(this,Js,null),this.popup=null))}resetEdited(){var e;n(this,bo)&&(b(this,Od,pg).call(this,n(this,bo).rect),(e=n(this,Js))==null||e.popup.resetEdited(),g(this,bo,null))}_createContainer(e){const{data:t,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),!(this instanceof Jo)&&!(this instanceof rm)&&!(this instanceof Hy)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,t.alternativeText&&(r.title=t.alternativeText),t.noRotate&&r.classList.add("norotate"),!t.rect||this instanceof gg){const{rotation:v}=t;return!t.hasOwnCanvas&&v!==0&&this.setRotation(v,r),r}const{width:o,height:l}=this;if(!e&&t.borderStyle.width>0){a.borderWidth=`${t.borderStyle.width}px`;const v=t.borderStyle.horizontalCornerRadius,A=t.borderStyle.verticalCornerRadius;if(v>0||A>0){const E=`calc(${v}px * var(--total-scale-factor)) / calc(${A}px * var(--total-scale-factor))`;a.borderRadius=E}switch(t.borderStyle.style){case Zo.SOLID:a.borderStyle="solid";break;case Zo.DASHED:a.borderStyle="dashed";break;case Zo.BEVELED:it("Unimplemented border style: beveled");break;case Zo.INSET:it("Unimplemented border style: inset");break;case Zo.UNDERLINE:a.borderBottomStyle="solid";break}const w=t.borderColor||null;w?(g(this,ih,!0),a.borderColor=H.makeHexColor(...w)):a.borderWidth=0}const h=H.normalizeRect([t.rect[0],s.view[3]-t.rect[1]+s.view[1],t.rect[2],s.view[3]-t.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:u,pageX:f,pageY:p}=i.rawDims;a.left=`${100*(h[0]-f)/c}%`,a.top=`${100*(h[1]-p)/u}%`;const{rotation:m}=t;return t.hasOwnCanvas||m===0?(a.width=`${100*o/c}%`,a.height=`${100*l/u}%`):this.setRotation(m,r),r}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:a}=this;e%180!==0&&([r,a]=[a,r]),t.style.width=`${100*r/s}%`,t.style.height=`${100*a/i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(t,s,i)=>{const r=i.detail[t],a=r[0],o=r.slice(1);i.target.style[s]=Wm[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Wm[`${a}_rgb`](o)})};return st(this,"_commonActions",{display:t=>{const{display:s}=t.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:s}=t.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:t=>{const s=t.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(e,t){const s=this._commonActions;for(const i of Object.keys(t.detail)){const r=e[i]||s[i];r==null||r(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const s=this._commonActions;for(const[i,r]of Object.entries(t)){const a=s[i];if(a){const o={detail:{[i]:r},target:e};a(o),delete t[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,s,i,r]=this.data.rect.map(v=>Math.fround(v));if(e.length===8){const[v,A,w,E]=e.subarray(2,6);if(i===v&&r===A&&t===w&&s===E)return}const{style:a}=this.container;let o;if(n(this,ih)){const{borderColor:v,borderWidth:A}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${ps}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${v}" stroke-width="${A}">`],this.container.classList.add("hasBorder")}const l=i-t,h=r-s,{svgFactory:c}=this,u=c.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0),u.role="none";const f=c.createElement("defs");u.append(f);const p=c.createElement("clipPath"),m=`clippath_${this.data.id}`;p.setAttribute("id",m),p.setAttribute("clipPathUnits","objectBoundingBox"),f.append(p);for(let v=2,A=e.length;v<A;v+=8){const w=e[v],E=e[v+1],S=e[v+2],T=e[v+3],x=c.createElement("rect"),C=(S-t)/l,I=(r-E)/h,O=(w-S)/l,M=(E-T)/h;x.setAttribute("x",C),x.setAttribute("y",I),x.setAttribute("width",O),x.setAttribute("height",M),p.append(x),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${C}" y="${I}" width="${O}" height="${M}"/>`)}n(this,ih)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${m})`}_createPopup(e=null){const{data:t}=this;let s,i;e?(s={str:e.text},i=e.date):(s=t.contentsObj,i=t.modificationDate),g(this,Js,new gg({data:{color:t.color,titleObj:t.titleObj,modificationDate:i,contentsObj:s,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(n(this,Js)||this.popup||this.data.popupRef)}get extraPopupElement(){return n(this,Js)}render(){bt("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[e];if(i)for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===t)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!Xo.has(h)){it(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const i of document.getElementsByName(e)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==t&&Xo.has(i)&&s.push({id:a,exportValue:r,domElement:i})}return s}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{var s;(s=this.linkService.eventBus)==null||s.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t,mustEnterInEditMode:!0})})}updateOC(e){if(!this.data.oc||!e)return;e.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=t===null?"transparent":H.makeHexColor(...t)}};bo=new WeakMap,ih=new WeakMap,Js=new WeakMap,Od=new WeakSet,pg=function(e){const{container:{style:t},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...e),t.left=`${100*(e[0]-o)/r}%`,t.top=`${100*(a-e[3]+l)/a}%`,i===0?(t.width=`${100*(e[2]-e[0])/r}%`,t.height=`${100*(e[3]-e[1])/a}%`):this.setRotation(i)};let Vt=gm;class r0 extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.editor=e.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:e}=this;e.hasComment&&this._createPopup(e.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e,e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}var Fs,ha,My,Oy;class rm extends Vt{constructor(t,s=null){super(t,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});y(this,Fs);this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let r=!1;return t.url?(s.addLinkAttributes(i,t.url,t.newWindow),r=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),r=!0):t.attachment?(b(this,Fs,My).call(this,i,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),r=!0):t.setOCGState?(b(this,Fs,Oy).call(this,i,t.setOCGState,t.overlaidText),r=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),r=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),r=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=i,this.container.append(i)),this.container}_bindLink(t,s,i=""){t.href=this.linkService.getDestinationHash(s),t.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,Fs,ha).call(this),i&&(t.title=i)}_bindNamedAction(t,s,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(t.title=i),b(this,Fs,ha).call(this)}_bindJSAction(t,s){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(t[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(t.title=s.overlaidText),t.onclick||(t.onclick=()=>!1),b(this,Fs,ha).call(this)}_bindResetFormAction(t,s){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),b(this,Fs,ha).call(this),!this._fieldObjects){it('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{var u;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const f=new Set(a);for(const p of r){const m=this._fieldObjects[p]||[];for(const{id:v}of m)f.add(v)}for(const p of Object.values(this._fieldObjects))for(const m of p)f.has(m.id)===o&&l.push(m)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const h=this.annotationStorage,c=[];for(const f of l){const{id:p}=f;switch(c.push(p),f.type){case"text":{const v=f.defaultValue||"";h.setValue(p,{value:v});break}case"checkbox":case"radiobutton":{const v=f.defaultValue===f.exportValues;h.setValue(p,{value:v});break}case"combobox":case"listbox":{const v=f.defaultValue||"";h.setValue(p,{value:v});break}default:continue}const m=document.querySelector(`[data-element-id="${p}"]`);if(m){if(!Xo.has(m)){it(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;m.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}Fs=new WeakSet,ha=function(){this.container.setAttribute("data-internal-link","")},My=function(t,s,i,r="",a=null){t.href=this.linkService.getAnchorUrl(""),i.description?t.title=i.description:r&&(t.title=r);const o=async()=>{var h;const l=await this.linkService.getAttachmentContent(s);l&&((h=this.downloadManager)==null||h.openOrDownloadData(l,i.filename,a))};t.onclick=()=>(o(),!1),b(this,Fs,ha).call(this)},Oy=function(t,s,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(t.title=i),b(this,Fs,ha).call(this)};class a0 extends Vt{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(e),this.container}}class Jo extends Vt{render(){return this.container}_getKeyModifier(e){return It.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,s,i,r){s.includes("mouse")?e.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):e.addEventListener(s,a=>{var o;if(s==="blur"){if(!t.focused||!a.relatedTarget)return;t.focused=!1}else if(s==="focus"){if(t.focused)return;t.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a)}}))})}_setEventListeners(e,t,s,i){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(t||(t={focused:!1})),this._setEventListener(e,t,l,h,i),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(e,t,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(e,t,"focus","Focus",null))}_setTextStyle(e){const t=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||i0,r=e.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),c=Math.round(h/(gp*i))||1,u=h/c;a=Math.min(i,l(u/gp))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/gp))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=H.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(r.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class o0 extends Jo{constructor(e){const t=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:t})}setPropertyOnSiblings(e,t,s,i){const r=this.annotationStorage;for(const a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=e.getValue(t,{value:this.data.fieldValue});let o=a.value||"";const l=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
|
|
48
|
+
`))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),e.has(t)&&this.container.classList.add("sandboxModified")),Xo.add(s),this.contentElement=s,s.setAttribute("data-element-id",t),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:u,datetimeType:f,timeStep:p}=this.data,m=!!f&&this.enableScripting;u&&(s.title=u),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",A=>{e.setValue(t,{value:A.target.value}),this.setPropertyOnSiblings(s,"value",A.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",A=>{const w=this.data.defaultFieldValue??"";s.value=c.userValue=w,c.formattedValue=null});let v=A=>{const{formattedValue:w}=c;w!=null&&(A.target.value=w),A.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var S;if(c.focused)return;const{target:E}=w;if(m&&(E.type=f,p&&(E.step=p)),c.userValue){const T=c.userValue;if(m)if(f==="time"){const x=new Date(T),C=[x.getHours(),x.getMinutes(),x.getSeconds()];E.value=C.map(I=>I.toString().padStart(2,"0")).join(":")}else E.value=new Date(T-n0).toISOString().split(f==="date"?"T":".",1)[0];else E.value=T}c.lastCommittedValue=E.value,c.commitKey=1,(S=this.data.actions)!=null&&S.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.container.classList.add("sandboxModified");const E={value(S){c.userValue=S.detail.value??"",m||e.setValue(t,{value:c.userValue.toString()}),S.target.value=c.userValue},formattedValue(S){const{formattedValue:T}=S.detail;c.formattedValue=T,T!=null&&S.target!==document.activeElement&&(S.target.value=T);const x={formattedValue:T};m&&(x.value=T),e.setValue(t,x)},selRange(S){S.target.setSelectionRange(...S.detail.selRange)},charLimit:S=>{var I;const{charLimit:T}=S.detail,{target:x}=S;if(T===0){x.removeAttribute("maxLength");return}x.setAttribute("maxLength",T);let C=c.userValue;!C||C.length<=T||(C=C.slice(0,T),x.value=c.userValue=C,e.setValue(t,{value:C}),(I=this.linkService.eventBus)==null||I.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:C,willCommit:!0,commitKey:1,selStart:x.selectionStart,selEnd:x.selectionEnd}}))}};this._dispatchEventFromSandbox(E,w)}),s.addEventListener("keydown",w=>{var T;c.commitKey=1;let E=-1;if(w.key==="Escape"?E=0:w.key==="Enter"&&!this.data.multiLine?E=2:w.key==="Tab"&&(c.commitKey=3),E===-1)return;const{value:S}=w.target;c.lastCommittedValue!==S&&(c.lastCommittedValue=S,c.userValue=S,(T=this.linkService.eventBus)==null||T.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:S,willCommit:!0,commitKey:E,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const A=v;v=null,s.addEventListener("blur",w=>{var T,x;if(!c.focused||!w.relatedTarget)return;(T=this.data.actions)!=null&&T.Blur||(c.focused=!1);const{target:E}=w;let{value:S}=E;if(m){if(S&&f==="time"){const C=S.split(":").map(I=>parseInt(I,10));S=new Date(2e3,0,1,C[0],C[1],C[2]||0).valueOf(),E.step=""}else S.includes("T")||(S=`${S}T00:00`),S=new Date(S).valueOf();E.type="text"}c.userValue=S,c.lastCommittedValue!==S&&((x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:S,willCommit:!0,commitKey:c.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),A(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var M;c.lastCommittedValue=null;const{data:E,target:S}=w,{value:T,selectionStart:x,selectionEnd:C}=S;let I=x,O=C;switch(w.inputType){case"deleteWordBackward":{const R=T.substring(0,x).match(/\w*\W*$/);R&&(I-=R[0].length);break}case"deleteWordForward":{const R=T.substring(x).match(/^\W*\w*/);R&&(O+=R[0].length);break}case"deleteContentBackward":x===C&&(I-=1);break;case"deleteContentForward":x===C&&(O+=1);break}w.preventDefault(),(M=this.linkService.eventBus)==null||M.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:T,change:E||"",willCommit:!1,selStart:I,selEnd:O}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(v&&s.addEventListener("blur",v),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${w}px * var(--total-scale-factor))`);const E=this.data.textAlignment;if(E===1||E===2){const S=()=>{const T=l-s.value.length;s.style.setProperty("--comb-offset",`${E===1?T>>1:T}`)};S();for(const T of["input","blur","resetform","updatefromsandbox"])s.addEventListener(T,S)}}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class l0 extends Jo{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class h0 extends Jo{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.exportValue===t.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",e.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return Xo.add(r),r.setAttribute("data-element-id",s),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const c=l&&h.exportValue===t.exportValue;h.domElement&&(h.domElement.checked=c),e.setValue(h.id,{value:c})}e.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=t.defaultFieldValue||"Off";a.target.checked=o===t.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class c0 extends Jo{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,s=t.id;let i=e.getValue(s,{value:t.buttonValue!==null&&t.fieldValue===t.buttonValue}).value;if(typeof i=="string"&&(i=i!==t.buttonValue,e.setValue(s,{value:i})),i)for(const a of this._getElementsByName(t.fieldName,s))e.setValue(a.id,{value:!1});const r=document.createElement("input");if(Xo.add(r),r.setAttribute("data-element-id",s),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))e.setValue(h.id,{value:!1});e.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=t.defaultFieldValue;a.target.checked=o!=null&&o===t.buttonValue}),this.enableScripting&&this.hasJSActions){const a=t.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const c=a===h.detail.value;for(const u of this._getElementsByName(h.target.name)){const f=c&&u.id===s;u.domElement&&(u.domElement.checked=f),e.setValue(u.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class d0 extends rm{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),e}}class u0 extends Jo{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,s=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");Xo.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",u=>{const f=this.data.defaultFieldValue;for(const p of i.options)p.selected=p.value===f});const a=(u,f)=>{const p=f.replaceAll(" "," ");u.textContent=p,p!==f&&u.setAttribute("display-value",f)};for(const u of this.data.options){const f=document.createElement("option");a(f,u.displayValue),f.value=u.exportValue,s.value.includes(u.exportValue)&&(f.setAttribute("selected",!0),r=!1),i.append(f)}let o=null;if(r){const u=document.createElement("option");u.value=" ",u.setAttribute("hidden",!0),u.setAttribute("selected",!0),i.prepend(u),o=()=>{u.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}const l=u=>{const f=u?"value":"textContent",{options:p,multiple:m}=i;return m?Array.prototype.filter.call(p,v=>v.selected).map(v=>v[f]):p.selectedIndex===-1?null:p[p.selectedIndex][f]};let h=l(!1);const c=u=>{const f=u.target.options;return Array.prototype.map.call(f,p=>({displayValue:p.getAttribute("display-value")||p.textContent,exportValue:p.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",u=>{const f={value(p){o==null||o();const m=p.detail.value,v=new Set(Array.isArray(m)?m:[m]);for(const A of i.options)A.selected=v.has(A.value);e.setValue(t,{value:l(!0)}),h=l(!1)},multipleSelection(p){i.multiple=!0},remove(p){const m=i.options,v=p.detail.remove;m[v].selected=!1,i.remove(v),m.length>0&&Array.prototype.findIndex.call(m,w=>w.selected)===-1&&(m[0].selected=!0),e.setValue(t,{value:l(!0),items:c(p)}),h=l(!1)},clear(p){for(;i.length!==0;)i.remove(0);e.setValue(t,{value:null,items:[]}),h=l(!1)},insert(p){const{index:m,displayValue:v,exportValue:A}=p.detail.insert,w=i.children[m],E=document.createElement("option");a(E,v),E.value=A,w?w.before(E):i.append(E),e.setValue(t,{value:l(!0),items:c(p)}),h=l(!1)},items(p){const{items:m}=p.detail;for(;i.length!==0;)i.remove(0);for(const v of m){const{displayValue:A,exportValue:w}=v,E=document.createElement("option");a(E,A),E.value=w,i.append(E)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:l(!0),items:c(p)}),h=l(!1)},indices(p){const m=new Set(p.detail.indices);for(const v of p.target.options)v.selected=m.has(v.index);e.setValue(t,{value:l(!0)}),h=l(!1)},editable(p){p.target.disabled=!p.detail.editable}};this._dispatchEventFromSandbox(f,u)}),i.addEventListener("input",u=>{var m;const f=l(!0),p=l(!1);e.setValue(t,{value:f}),u.preventDefault(),(m=this.linkService.eventBus)==null||m.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:h,change:p,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],u=>u.target.value)):i.addEventListener("input",function(u){e.setValue(t,{value:l(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}var Rd,mg;class gg extends Vt{constructor(t){const{data:s,elements:i,parent:r}=t,a=!!r._commentManager;super(t,{isRenderable:!a&&Vt._hasPopupData(s)});y(this,Rd);if(this.elements=i,a&&Vt._hasPopupData(s)){const o=this.popup=b(this,Rd,mg).call(this);for(const l of i)l.popup=o}else this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const s=this.popup=b(this,Rd,mg).call(this),i=[];for(const r of this.elements)r.popup=s,r.container.ariaHasPopup="dialog",i.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(r=>`${il}${r}`).join(",")),this.container}}Rd=new WeakSet,mg=function(){return new f0({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};var Es,kr,zf,Wf,nh,rh,te,$i,Lr,Ao,ah,oh,ji,Ss,Mn,On,ee,Rn,Fr,Dd,Dn,lh,wo,Nr,be,Br,ht,zu,vg,yg,bg,Wu,Ag,Ry,Dy,ky,Ly,Vu,Xu,wg;class f0{constructor({container:e,color:t,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:u,commentManager:f=null}){y(this,ht);y(this,Es,null);y(this,kr,b(this,ht,ky).bind(this));y(this,zf,b(this,ht,wg).bind(this));y(this,Wf,b(this,ht,Xu).bind(this));y(this,nh,b(this,ht,Vu).bind(this));y(this,rh,null);y(this,te,null);y(this,$i,null);y(this,Lr,null);y(this,Ao,null);y(this,ah,null);y(this,oh,null);y(this,ji,!1);y(this,Ss,null);y(this,Mn,null);y(this,On,null);y(this,ee,null);y(this,Rn,null);y(this,Fr,null);y(this,Dd,null);y(this,Dn,null);y(this,lh,null);y(this,wo,null);y(this,Nr,!1);y(this,be,null);y(this,Br,null);g(this,te,e),g(this,lh,i),g(this,$i,a),g(this,Dn,o),g(this,ah,l),g(this,rh,t),g(this,Dd,h),g(this,oh,c),g(this,Ao,s),g(this,Es,f),g(this,be,s[0]),g(this,Lr,Ac.toDateObject(r)),this.trigger=s.flatMap(p=>p.getElementsToTriggerPopup()),f||(b(this,ht,zu).call(this),n(this,te).hidden=!0,u&&b(this,ht,Vu).call(this))}renderCommentButton(){if(n(this,ee)){n(this,ee).parentNode||n(this,be).container.after(n(this,ee));return}if(n(this,Rn)||b(this,ht,vg).call(this),!n(this,Rn))return;const{signal:e}=g(this,Mn,new AbortController),t=n(this,be).hasOwnCommentButton,s=()=>{n(this,Es).toggleCommentPopup(this,!0,void 0,!t)},i=()=>{n(this,Es).toggleCommentPopup(this,!1,!0,!t)},r=()=>{n(this,Es).toggleCommentPopup(this,!1,!1)};if(t){g(this,ee,n(this,be).container);for(const a of this.trigger)a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.addEventListener("keydown",n(this,kr),{signal:e}),a.addEventListener("click",s,{signal:e}),a.addEventListener("pointerenter",i,{signal:e}),a.addEventListener("pointerleave",r,{signal:e}),a.classList.add("popupTriggerArea")}else{const a=g(this,ee,document.createElement("button"));a.className="annotationCommentButton";const o=n(this,be).container;a.style.zIndex=parseInt(o.style.zIndex,10)+1,a.tabIndex=0,a.ariaHasPopup="dialog",a.ariaControls="commentPopup",a.setAttribute("data-l10n-id","pdfjs-show-comment-button"),b(this,ht,bg).call(this),b(this,ht,yg).call(this),a.addEventListener("keydown",n(this,kr),{signal:e}),a.addEventListener("click",s,{signal:e}),a.addEventListener("pointerenter",i,{signal:e}),a.addEventListener("pointerleave",r,{signal:e}),o.after(a)}}get commentButtonColor(){const{color:e,opacity:t}=n(this,be).commentData;return e?n(this,ah)._commentManager.makeCommentColor(e,t):null}focusCommentButton(){setTimeout(()=>{var e;(e=n(this,ee))==null||e.focus()},0)}getData(){const{richText:e,color:t,opacity:s,creationDate:i,modificationDate:r}=n(this,be).commentData;return{contentsObj:{str:this.comment},richText:e,color:t,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return n(this,ee)}get comment(){return n(this,Br)||g(this,Br,n(this,be).commentText),n(this,Br)}set comment(e){e!==this.comment&&(n(this,be).commentText=g(this,Br,e))}focus(){var e;(e=n(this,be).container)==null||e.focus()}get parentBoundingClientRect(){return n(this,be).layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:t}){n(this,ee)&&(n(this,ee).classList.toggle("selected",e),n(this,ee).ariaExpanded=t)}setSelectedCommentButton(e){n(this,ee).classList.toggle("selected",e)}get commentPopupPosition(){if(n(this,Fr))return n(this,Fr);const{x:e,y:t,height:s}=n(this,ee).getBoundingClientRect(),{x:i,y:r,width:a,height:o}=n(this,be).layer.getBoundingClientRect();return[(e-i)/a,(t+s-r)/o]}set commentPopupPosition(e){g(this,Fr,e)}hasDefaultPopupPosition(){return n(this,Fr)===null}get commentButtonPosition(){return n(this,Rn)}get commentButtonWidth(){return n(this,ee).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){const[t,s]=n(this,Fr)||this.commentButtonPosition.map(h=>h/100),i=this.parentBoundingClientRect,{x:r,y:a,width:o,height:l}=i;n(this,Es).showDialog(null,this,r+t*o,a+s*l,{...e,parentDimensions:i})}render(){var s,i;if(n(this,Ss))return;const e=g(this,Ss,document.createElement("div"));if(e.className="popup",n(this,rh)){const r=e.style.outlineColor=H.makeHexColor(...n(this,rh));e.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const t=document.createElement("span");if(t.className="header",(s=n(this,lh))!=null&&s.str){const r=document.createElement("span");r.className="title",t.append(r),{dir:r.dir,str:r.textContent}=n(this,lh)}if(e.append(t),n(this,Lr)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,Lr).valueOf()})),r.dateTime=n(this,Lr).toISOString(),t.append(r)}em({html:n(this,ht,Wu)||n(this,$i).str,dir:(i=n(this,$i))==null?void 0:i.dir,className:"popupContent"},e),n(this,te).append(e)}updateEdited({rect:e,popup:t,deleted:s}){var i;if(n(this,Es)){s?(this.remove(),g(this,Br,null)):t&&(t.deleted?this.remove():(b(this,ht,bg).call(this),g(this,Br,t.text))),e&&(g(this,Rn,null),b(this,ht,vg).call(this),b(this,ht,yg).call(this));return}if(s||t!=null&&t.deleted){this.remove();return}b(this,ht,zu).call(this),n(this,wo)||g(this,wo,{contentsObj:n(this,$i),richText:n(this,Dn)}),e&&g(this,On,null),t&&t.text&&(g(this,Dn,b(this,ht,Dy).call(this,t.text)),g(this,Lr,Ac.toDateObject(t.date)),g(this,$i,null)),(i=n(this,Ss))==null||i.remove(),g(this,Ss,null)}resetEdited(){var e;n(this,wo)&&({contentsObj:$t(this,$i)._,richText:$t(this,Dn)._}=n(this,wo),g(this,wo,null),(e=n(this,Ss))==null||e.remove(),g(this,Ss,null),g(this,On,null))}remove(){var e,t,s;if((e=n(this,Mn))==null||e.abort(),g(this,Mn,null),(t=n(this,Ss))==null||t.remove(),g(this,Ss,null),g(this,Nr,!1),g(this,ji,!1),(s=n(this,ee))==null||s.remove(),g(this,ee,null),this.trigger)for(const i of this.trigger)i.classList.remove("popupTriggerArea")}forceHide(){g(this,Nr,this.isVisible),n(this,Nr)&&(n(this,te).hidden=!0)}maybeShow(){n(this,Es)||(b(this,ht,zu).call(this),n(this,Nr)&&(n(this,Ss)||b(this,ht,Xu).call(this),g(this,Nr,!1),n(this,te).hidden=!1))}get isVisible(){return n(this,Es)?!1:n(this,te).hidden===!1}}Es=new WeakMap,kr=new WeakMap,zf=new WeakMap,Wf=new WeakMap,nh=new WeakMap,rh=new WeakMap,te=new WeakMap,$i=new WeakMap,Lr=new WeakMap,Ao=new WeakMap,ah=new WeakMap,oh=new WeakMap,ji=new WeakMap,Ss=new WeakMap,Mn=new WeakMap,On=new WeakMap,ee=new WeakMap,Rn=new WeakMap,Fr=new WeakMap,Dd=new WeakMap,Dn=new WeakMap,lh=new WeakMap,wo=new WeakMap,Nr=new WeakMap,be=new WeakMap,Br=new WeakMap,ht=new WeakSet,zu=function(){var t;if(n(this,Mn))return;g(this,Mn,new AbortController);const{signal:e}=n(this,Mn);for(const s of this.trigger)s.addEventListener("click",n(this,nh),{signal:e}),s.addEventListener("pointerenter",n(this,Wf),{signal:e}),s.addEventListener("pointerleave",n(this,zf),{signal:e}),s.classList.add("popupTriggerArea");for(const s of n(this,Ao))(t=s.container)==null||t.addEventListener("keydown",n(this,kr),{signal:e})},vg=function(){const e=n(this,Ao).find(t=>t.hasCommentButton);e&&g(this,Rn,e._normalizePoint(e.commentButtonPosition))},yg=function(){if(n(this,be).extraPopupElement&&!n(this,be).editor)return;n(this,ee)||this.renderCommentButton();const[e,t]=n(this,Rn),{style:s}=n(this,ee);s.left=`calc(${e}%)`,s.top=`calc(${t}% - var(--comment-button-dim))`},bg=function(){n(this,be).extraPopupElement||(n(this,ee)||this.renderCommentButton(),n(this,ee).style.backgroundColor=this.commentButtonColor||"")},Wu=function(){const e=n(this,Dn),t=n(this,$i);return e!=null&&e.str&&(!(t!=null&&t.str)||t.str===e.str)&&n(this,Dn).html||null},Ag=function(){var e,t,s;return((s=(t=(e=n(this,ht,Wu))==null?void 0:e.attributes)==null?void 0:t.style)==null?void 0:s.fontSize)||0},Ry=function(){var e,t,s;return((s=(t=(e=n(this,ht,Wu))==null?void 0:e.attributes)==null?void 0:t.style)==null?void 0:s.color)||null},Dy=function(e){const t=[],s={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},i={style:{color:n(this,ht,Ry),fontSize:n(this,ht,Ag)?`calc(${n(this,ht,Ag)}px * var(--total-scale-factor))`:""}};for(const r of e.split(`
|
|
49
|
+
`))t.push({name:"span",value:r,attributes:i});return s},ky=function(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&n(this,ji))&&b(this,ht,Vu).call(this)},Ly=function(){if(n(this,On)!==null)return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:s,pageX:i,pageY:r}}}=n(this,ah);let a=!!n(this,oh),o=a?n(this,oh):n(this,Dd);for(const m of n(this,Ao))if(!o||H.intersect(m.data.rect,o)!==null){o=m.data.rect,a=!0;break}const l=H.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),c=a?o[2]-o[0]+5:0,u=l[0]+c,f=l[1];g(this,On,[100*(u-i)/t,100*(f-r)/s]);const{style:p}=n(this,te);p.left=`${n(this,On)[0]}%`,p.top=`${n(this,On)[1]}%`},Vu=function(){if(n(this,Es)){n(this,Es).toggleCommentPopup(this,!1);return}g(this,ji,!n(this,ji)),n(this,ji)?(b(this,ht,Xu).call(this),n(this,te).addEventListener("click",n(this,nh)),n(this,te).addEventListener("keydown",n(this,kr))):(b(this,ht,wg).call(this),n(this,te).removeEventListener("click",n(this,nh)),n(this,te).removeEventListener("keydown",n(this,kr)))},Xu=function(){n(this,Ss)||this.render(),this.isVisible?n(this,ji)&&n(this,te).classList.add("focused"):(b(this,ht,Ly).call(this),n(this,te).hidden=!1,n(this,te).style.zIndex=parseInt(n(this,te).style.zIndex,10)+1e3)},wg=function(){n(this,te).classList.remove("focused"),!(n(this,ji)||!this.isVisible)&&(n(this,te).hidden=!0,n(this,te).style.zIndex=parseInt(n(this,te).style.zIndex,10)-1e3)};class Fy extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=nt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=this.contentElement=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const t of this.textContent){const s=document.createElement("span");s.textContent=t,e.append(s)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var kd;class p0 extends Vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});y(this,kd,null)}render(){this.container.classList.add("lineAnnotation");const{data:t,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=g(this,kd,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),a.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),a.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),a.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),a.setAttribute("stroke-width",t.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,kd)}addHighlightArea(){this.container.classList.add("highlightArea")}}kd=new WeakMap;var Ld;class g0 extends Vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});y(this,Ld,null)}render(){this.container.classList.add("squareAnnotation");const{data:t,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=t.borderStyle.width,o=g(this,Ld,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,Ld)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ld=new WeakMap;var Fd;class m0 extends Vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});y(this,Fd,null)}render(){this.container.classList.add("circleAnnotation");const{data:t,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=t.borderStyle.width,o=g(this,Fd,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,Fd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Fd=new WeakMap;var Nd;class Ny extends Vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});y(this,Nd,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:s,borderStyle:i,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let h=[];for(let u=0,f=s.length;u<f;u+=2){const p=s[u]-t[0],m=t[3]-s[u+1];h.push(`${p},${m}`)}h=h.join(" ");const c=g(this,Nd,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",h),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),l.append(c),this.container.append(l),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return n(this,Nd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Nd=new WeakMap;class v0 extends Ny{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class y0 extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}var Bd,Eo,Ud,Eg;class am extends Vt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0});y(this,Ud);y(this,Bd,null);y(this,Eo,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?nt.HIGHLIGHT:nt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:s,inkLists:i,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:h}=b(this,Ud,Eg).call(this,s,t),c=this.svgFactory.create(l,h,!0),u=g(this,Bd,this.svgFactory.createElement("svg:g"));c.append(u),u.setAttribute("stroke-width",r.width||1),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-miterlimit",10),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),u.setAttribute("transform",o);for(let f=0,p=i.length;f<p;f++){const m=this.svgFactory.createElement(this.svgElementName);n(this,Eo).push(m),m.setAttribute("points",i[f].join(",")),u.append(m)}return!a&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:s,points:i,rect:r}=t,a=n(this,Bd);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,Eo).length;o<l;o++)n(this,Eo)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,Ud,Eg).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,Eo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Bd=new WeakMap,Eo=new WeakMap,Ud=new WeakSet,Eg=function(t,s){switch(t){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class By extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=nt.HIGHLIGHT}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),e){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=e,this.container.append(s)}return this.container}}class b0 extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),e){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=e,this.container.append(s)}return this.container}}class A0 extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),e){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=e,this.container.append(s)}return this.container}}class w0 extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),e){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=e,this.container.append(s)}return this.container}}class Uy extends Vt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=nt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}var Hd,$d,Sg;class E0 extends Vt{constructor(t){var r;super(t,{isRenderable:!0});y(this,$d);y(this,Hd,null);const{fileId:s,file:i}=this.data;this.filename=i.filename,this.content=i.content,this.fileId=s,(r=this.linkService.eventBus)==null||r.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",b(this,$d,Sg).bind(this)),g(this,Hd,i);const{isMac:r}=It.platform;return t.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,$d,Sg).call(this)}),!s.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return n(this,Hd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Hd=new WeakMap,$d=new WeakSet,Sg=async function(){var a;const{fileId:t,filename:s,content:i}=this,r=await this.linkService.getAttachmentContent(t)||i;r&&((a=this.downloadManager)==null||a.openOrDownloadData(r,s))};var hh,So,kn,Yo,$y,xg;class Hy extends Vt{constructor(t){super(t,{isRenderable:!!t.data.richMedia});y(this,Yo);y(this,hh,new AbortController);y(this,So,null);y(this,kn,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:t}=this.data.richMedia,s=document.createElement("button");return s.className="mediaPlayButton",s.type="button",s.title=s.ariaLabel=t,s.addEventListener("click",()=>b(this,Yo,$y).call(this,s),{signal:n(this,hh).signal}),this.container.append(s),this.container}destroy(){n(this,hh).abort(),n(this,kn)&&(n(this,kn).pause(),n(this,kn).removeAttribute("src"),n(this,kn).load(),g(this,kn,null)),b(this,Yo,xg).call(this)}}hh=new WeakMap,So=new WeakMap,kn=new WeakMap,Yo=new WeakSet,$y=async function(t){const{fileId:s,filename:i,contentType:r}=this.data.richMedia;t.disabled=!0;let a;try{a=await this.linkService.getAttachmentContent(s)}catch{return}finally{t.disabled=!1}if(!a||!t.isConnected)return;const{signal:o}=n(this,hh),l=URL.createObjectURL(new Blob([a],{type:r}));g(this,So,l);const h=r.startsWith("audio/"),c=document.createElement(h?"audio":"video");if(g(this,kn,c),c.className="mediaContent",this._setBackgroundColor(c),c.src=l,c.title=i,c.controls=!0,c.autoplay=!0,c.tabIndex=0,h){let u=!1,f=!1;const p=()=>{c.controls=u||f};this.container.addEventListener("pointerenter",()=>{u=!0,p()},{signal:o}),this.container.addEventListener("pointerleave",()=>{u=!1,p()},{signal:o}),this.container.addEventListener("focusin",()=>{f=!0,p()},{signal:o}),this.container.addEventListener("focusout",()=>{f=!1,p()},{signal:o})}c.addEventListener("emptied",()=>b(this,Yo,xg).call(this,l),{once:!0,signal:o}),t.replaceWith(c),c.play().catch(()=>{})},xg=function(t=n(this,So)){t&&t===n(this,So)&&(URL.revokeObjectURL(t),g(this,So,null))};var Ur,xo,ch,Ln,jd,To,$e,Gd,Qi,Yu,Ku;const mm=class mm{constructor({div:e,accessibilityManager:t,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o,commentManager:l,linkService:h,annotationStorage:c}){y(this,Qi);y(this,Ur,null);y(this,xo,null);y(this,ch,null);y(this,Ln,new Map);y(this,jd,null);y(this,To,null);y(this,$e,[]);y(this,Gd,!1);P(this,"zIndex",0);this.div=e,g(this,Ur,t),g(this,xo,s),g(this,jd,o||null),g(this,To,h||null),g(this,ch,c||new sm),this.page=r,this.viewport=a,this._annotationEditorUIManager=i,this._commentManager=l||null}hasEditableAnnotations(){return n(this,Ln).size>0}async render(e){var l;const{annotations:t,optionalContentConfig:s}=e,i=this.div;ta(i,this.viewport);const r=new Map,a=[],o={data:null,layer:i,linkService:n(this,To),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new Tc,annotationStorage:n(this,ch),enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const h of t){if(h.noHTML)continue;const c=h.annotationType===Xt.POPUP;if(c){const p=r.get(h.id);if(!p)continue;if(!this._commentManager){a.push(h);continue}o.elements=p}else if(h.rect[2]===h.rect[0]||h.rect[3]===h.rect[1])continue;o.data=h;const u=Ep.create(o);if(!u.isRenderable)continue;c||(n(this,$e).push(u),h.popupRef&&r.getOrInsertComputed(h.popupRef,Uh).push(u));const f=u.render();h.hidden&&(f.style.visibility="hidden"),u.updateOC(s),u._isEditable&&(n(this,Ln).set(u.data.id,u),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(u))}await b(this,Qi,Yu).call(this);for(const h of a){const c=o.elements=r.get(h.id);o.data=h;const u=Ep.create(o);if(!u.isRenderable)continue;const f=u.render();u.contentElement.id=`${il}${h.id}`,h.hidden&&(f.style.visibility="hidden"),c.at(-1).container.after(f)}b(this,Qi,Ku).call(this)}async addLinkAnnotations(e){const t={data:null,layer:this.div,linkService:n(this,To),svgFactory:new Tc,parent:this};for(const s of e){s.borderStyle||(s.borderStyle=mm._defaultBorderStyle),t.data=s;const i=Ep.create(t);i.isRenderable&&(i.render(),i.contentElement.id=`${il}${s.id}`,n(this,$e).push(i))}await b(this,Qi,Yu).call(this)}update({viewport:e,optionalContentConfig:t}){const s=this.div;this.viewport=e,ta(s,{rotation:e.rotation});for(const i of n(this,$e))i.updateOC(t);b(this,Qi,Ku).call(this),s.hidden=!1}destroy(){var e,t;for(const s of n(this,$e))(e=s.destroy)==null||e.call(s),(t=n(this,Ur))==null||t.removePointerInTextLayer(s.contentElement);n(this,$e).length=0,n(this,Ln).clear(),this.div.replaceChildren()}refreshCanvases(){b(this,Qi,Ku).call(this)}getEditableAnnotations(){return n(this,Ln).values()}getEditableAnnotation(e){return n(this,Ln).get(e)}addFakeAnnotation(e){const{div:t}=this,{id:s,rotation:i}=e,r=new r0({data:{id:s,rect:e.getPDFRect(),rotation:i},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:n(this,To),annotationStorage:n(this,ch)});return r.render(),r.contentElement.id=`${il}${s}`,r.createOrUpdatePopup(),n(this,$e).push(r),r}removeAnnotation(e){var i;const t=n(this,$e).findIndex(r=>r.data.id===e);if(t<0)return;const[s]=n(this,$e).splice(t,1);(i=n(this,Ur))==null||i.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(e){if(e.length!==0){for(const t of e)t.updateFakeAnnotationElement(this);b(this,Qi,Yu).call(this)}}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}static get _defaultBorderStyle(){return st(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Zo.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};Ur=new WeakMap,xo=new WeakMap,ch=new WeakMap,Ln=new WeakMap,jd=new WeakMap,To=new WeakMap,$e=new WeakMap,Gd=new WeakMap,Qi=new WeakSet,Yu=async function(){var s,i,r;if(n(this,$e).length===0)return;this.div.replaceChildren();const e=[];if(!n(this,Gd)){g(this,Gd,!0);for(const{contentElement:a,data:{id:o}}of n(this,$e)){const l=a.id=`${il}${o}`;e.push((s=n(this,jd))==null?void 0:s.getAriaAttributes(l).then(h=>{if(h)for(const[c,u]of h)a.setAttribute(c,u)}))}}n(this,$e).sort(({data:{rect:[a,o,l,h]}},{data:{rect:[c,u,f,p]}})=>{if(a===l&&o===h)return 1;if(c===f&&u===p)return-1;const m=h,v=o,A=(o+h)/2,w=p,E=u,S=(u+p)/2;if(A>=w&&S<=v)return-1;if(S>=m&&A<=E)return 1;const T=(a+l)/2,x=(c+f)/2;return T-x});const t=document.createDocumentFragment();for(const a of n(this,$e))t.append(a.container),this._commentManager?(r=((i=a.extraPopupElement)==null?void 0:i.popup)||a.popup)==null||r.renderCommentButton():a.extraPopupElement&&t.append(a.extraPopupElement.render());if(this.div.append(t),await Promise.all(e),n(this,Ur))for(const a of n(this,$e))n(this,Ur).addPointerInTextLayer(a.contentElement,!1)},Ku=function(){var t;if(!n(this,xo))return;const e=this.div;for(const[s,i]of n(this,xo)){const r=e.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;if(Array.isArray(i))for(const c of i)c.className="annotationContent",c.ariaHidden=!0;else i.className="annotationContent",i.ariaHidden=!0;const a=[];for(const c of r.children)c.nodeName==="CANVAS"&&a.push(c);for(const c of a)c.remove();const o=Array.isArray(i)?i[0]:i,{firstChild:l}=r;if(l?l.classList.contains("annotationContent")?l.after(o):l.before(o):r.append(o),Array.isArray(i)){let c=o;for(let u=1,f=i.length;u<f;u++)c.after(i[u]),c=i[u]}n(this,xo).delete(s);const h=n(this,Ln).get(s);h&&(h._hasNoCanvas?((t=this._annotationEditorUIManager)==null||t.setMissingCanvas(s,r.id,i),h._hasNoCanvas=!1):h.canvas=i)}};let bf=mm;const Eu=/\r\n?|\n/g;var xs,_d,Co,Ts,he,jy,Gy,_y,Ju,Vn,Qu,Zu,zy,Cg,Wy;const jt=class jt extends St{constructor(t){super({...t,name:"freeTextEditor"});y(this,he);y(this,xs,"");y(this,_d,`${this.id}-editor`);y(this,Co,null);y(this,Ts);P(this,"_colorPicker",null);this.color=t.color||jt._defaultColor||St._defaultLineColor,g(this,Ts,t.fontSize||jt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert(St._l10nAlert.freetext),this.canAddComment=!1}static get _keyboardManager(){const t=jt.prototype,s=a=>a.isEmpty(),i=ea.TRANSLATE_SMALL,r=ea.TRANSLATE_BIG;return st(this,"_keyboardManager",new Vo([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],t.commitOrRemove],[["Escape"],t.commitOrRemove],[["ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight"],t._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp"],t._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown"],t._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(t,s){St.initialize(t,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,s){switch(t){case at.FREETEXT_SIZE:jt._defaultFontSize=s;break;case at.FREETEXT_COLOR:jt._defaultColor=s;break}}updateParams(t,s){switch(t){case at.FREETEXT_SIZE:b(this,he,jy).call(this,s);break;case at.FREETEXT_COLOR:b(this,he,Gy).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[at.FREETEXT_SIZE,jt._defaultFontSize],[at.FREETEXT_COLOR,jt._defaultColor||St._defaultLineColor]]}get propertiesToUpdate(){return[[at.FREETEXT_SIZE,n(this,Ts)],[at.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new yf(this)),[["colorPicker",this._colorPicker]]}get colorType(){return at.FREETEXT_COLOR}onUpdatedColor(){var t;this.editorDiv.style.color=this.color,(t=this._colorPicker)==null||t.update(this.color),super.onUpdatedColor()}_translateEmpty(t,s){this._uiManager.translateSelectedEditors(t,s,!0)}getInitialTranslation(){const t=this.parentScale;return[-jt._internalPadding*t,-(jt._internalPadding+n(this,Ts))*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),g(this,Co,new AbortController);const t=this._uiManager.combinedSignal(n(this,Co));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){var t;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,_d)),this._isDraggable=!0,(t=n(this,Co))==null||t.abort(),g(this,Co,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var s;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=n(this,xs),s=g(this,xs,b(this,he,_y).call(this).trimEnd());if(t===s)return;const i=r=>{if(g(this,xs,r),!r){this.remove();return}b(this,he,Zu).call(this),this._uiManager.rebuild(this),b(this,he,Ju).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(t)},mustExec:!1}),b(this,he,Ju).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){jt._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,s;(this._isCopy||this.annotationElementId)&&(t=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",n(this,_d)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${n(this,Ts)}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,u]=this.pageDimensions,[f,p]=this.pageTranslation;let m,v;switch(this.rotation){case 0:m=t+(o[0]-f)/c,v=s+this.height-(o[1]-p)/u;break;case 90:m=t+(o[0]-f)/c,v=s-(o[1]-p)/u,[l,h]=[h,-l];break;case 180:m=t-this.width+(o[0]-f)/c,v=s-(o[1]-p)/u,[l,h]=[-l,-h];break;case 270:m=t+(o[0]-f-this.height*u)/c,v=s+(o[1]-p-this.width*c)/u,[l,h]=[-h,l];break}this.setAt(m*r,v*a,l,h)}else this._moveAfterPaste(t,s);b(this,he,Zu).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(t){var m,v,A;const s=t.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;t.preventDefault();const r=b(m=jt,Vn,Cg).call(m,s.getData("text")||"").replaceAll(Eu,`
|
|
50
|
+
`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
|
|
51
|
+
`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,c=[],u=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(u.push(l.nodeValue.slice(h).replaceAll(Eu,"")),w!==this.editorDiv){let E=c;for(const S of this.editorDiv.childNodes){if(S===w){E=u;continue}E.push(b(v=jt,Vn,Qu).call(v,S))}}c.push(l.nodeValue.slice(0,h).replaceAll(Eu,""))}else if(l===this.editorDiv){let w=c,E=0;for(const S of this.editorDiv.childNodes)E++===h&&(w=u),w.push(b(A=jt,Vn,Qu).call(A,S))}g(this,xs,`${c.join(`
|
|
52
|
+
`)}${r}${u.join(`
|
|
53
|
+
`)}`),b(this,he,Zu).call(this);const f=new Range;let p=Math.sumPrecise(c.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const E=w.nodeValue.length;if(p<=E){f.setStart(w,p),f.setEnd(w,p);break}p-=E}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}getPDFRect(){const t=jt._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,s,i){var o;let r=null;if(t instanceof Fy){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:u,id:f,popupRef:p,richText:m,contentsObj:v,creationDate:A,modificationDate:w},textContent:E,textPosition:S,parent:{page:{pageNumber:T}}}=t;if(!(E!=null&&E.length))return null;r=t={annotationType:nt.FREETEXT,color:Array.from(h),fontSize:l,value:E.join(`
|
|
54
|
+
`),position:S,pageIndex:T-1,rect:c.slice(0),rotation:u,annotationElementId:f,id:f,deleted:!1,popupRef:p,comment:(v==null?void 0:v.str)||null,richText:m,creationDate:A,modificationDate:w}}const a=await super.deserialize(t,s,i);return g(a,Ts,t.fontSize),a.color=H.makeHexColor(...t.color),g(a,xs,b(o=jt,Vn,Cg).call(o,t.value)),a._initialData=r,t.comment&&a.setCommentData(t),a}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=St._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:s,fontSize:n(this,Ts),value:b(this,he,zy).call(this)});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!b(this,he,Wy).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){const s=super.renderAnnotationElement(t);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,Ts)}px * var(--total-scale-factor))`,i.color=this.color,s.replaceChildren();for(const r of n(this,xs).split(`
|
|
55
|
+
`)){const a=document.createElement("div");a.append(r?document.createTextNode(r):document.createElement("br")),s.append(a)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:n(this,xs)}}),s}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};xs=new WeakMap,_d=new WeakMap,Co=new WeakMap,Ts=new WeakMap,he=new WeakSet,jy=function(t){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,Ts))*this.parentScale),g(this,Ts,r),b(this,he,Ju).call(this)},i=n(this,Ts);this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:at.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Gy=function(t){const s=r=>{this.color=r,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:at.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},_y=function(){var i;const t=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(t.push(b(i=jt,Vn,Qu).call(i,r)),s=r);return t.join(`
|
|
56
|
+
`)},Ju=function(){const[t,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/t,this.height=i.height/s):(this.width=i.height/t,this.height=i.width/s),this.fixAndSetPosition()},Vn=new WeakSet,Qu=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Eu,"")},Zu=function(){if(this.editorDiv.replaceChildren(),!!n(this,xs))for(const t of n(this,xs).split(`
|
|
57
|
+
`)){const s=document.createElement("div");s.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(s)}},zy=function(){return n(this,xs).replaceAll(" "," ")},Cg=function(t){return t.replaceAll(" "," ")},Wy=function(t){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==s||t.fontSize!==i||t.color.some((o,l)=>o!==r[l])||t.pageIndex!==a},y(jt,Vn),P(jt,"_freeTextDefaultContent",""),P(jt,"_internalPadding",0),P(jt,"_defaultColor",null),P(jt,"_defaultFontSize",10),P(jt,"_type","freetext"),P(jt,"_editorType",nt.FREETEXT);let Tg=jt;class z{toSVGPath(){bt("Abstract method `toSVGPath` must be implemented.")}get box(){bt("Abstract getter `box` must be implemented.")}serialize(e,t){bt("Abstract method `serialize` must be implemented.")}static _rescale(e,t,s,i,r,a){a||(a=new Float32Array(e.length));for(let o=0,l=e.length;o<l;o+=2)a[o]=t+e[o]*i,a[o+1]=s+e[o+1]*r;return a}static _rescaleAndSwap(e,t,s,i,r,a){a||(a=new Float32Array(e.length));for(let o=0,l=e.length;o<l;o+=2)a[o]=t+e[o+1]*i,a[o+1]=s+e[o]*r;return a}static _translate(e,t,s,i){i||(i=new Float32Array(e.length));for(let r=0,a=e.length;r<a;r+=2)i[r]=t+e[r],i[r+1]=s+e[r+1];return i}static svgRound(e){return Math.round(e*1e4)}static _normalizePoint(e,t,s,i,r){switch(r){case 90:return[1-t/s,e/i];case 180:return[1-e/s,1-t/i];case 270:return[t/s,1-e/i];default:return[e/s,t/i]}}static createBezierPoints(e,t,s,i,r,a){return[(e+5*s)/6,(t+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}P(z,"PRECISION",1e-4);var Cs,pi,dh,uh,Gi,ut,Io,Po,zd,Wd,fh,ph,Hr,Vd,Vf,Xf,fe,oc,Vy,Xy,Yy,Ky,Jy,Qy;const rn=class rn{constructor({x:e,y:t},s,i,r,a,o=0){y(this,fe);y(this,Cs);y(this,pi,[]);y(this,dh);y(this,uh);y(this,Gi,[]);y(this,ut,new Float32Array(18));y(this,Io);y(this,Po);y(this,zd);y(this,Wd);y(this,fh);y(this,ph);y(this,Hr,[]);g(this,Cs,s),g(this,ph,r*i),g(this,uh,a),n(this,ut).set([NaN,NaN,NaN,NaN,e,t],6),g(this,dh,o),g(this,Wd,n(rn,Vd)*i),g(this,zd,n(rn,Xf)*i),g(this,fh,i),n(this,Hr).push(e,t)}isEmpty(){return isNaN(n(this,ut)[8])}add({x:e,y:t}){var M;g(this,Io,e),g(this,Po,t);const[s,i,r,a]=n(this,Cs);let[o,l,h,c]=n(this,ut).subarray(8,12);const u=e-h,f=t-c,p=Math.hypot(u,f);if(p<n(this,zd))return!1;const m=p-n(this,Wd),v=m/p,A=v*u,w=v*f;let E=o,S=l;o=h,l=c,h+=A,c+=w,(M=n(this,Hr))==null||M.push(e,t);const T=-w/m,x=A/m,C=T*n(this,ph),I=x*n(this,ph);return n(this,ut).set(n(this,ut).subarray(2,8),0),n(this,ut).set([h+C,c+I],4),n(this,ut).set(n(this,ut).subarray(14,18),12),n(this,ut).set([h-C,c-I],16),isNaN(n(this,ut)[6])?(n(this,Gi).length===0&&(n(this,ut).set([o+C,l+I],2),n(this,Gi).push(NaN,NaN,NaN,NaN,(o+C-s)/r,(l+I-i)/a),n(this,ut).set([o-C,l-I],14),n(this,pi).push(NaN,NaN,NaN,NaN,(o-C-s)/r,(l-I-i)/a)),n(this,ut).set([E,S,o,l,h,c],6),!this.isEmpty()):(n(this,ut).set([E,S,o,l,h,c],6),Math.abs(Math.atan2(S-l,E-o)-Math.atan2(w,A))<Math.PI/2?([o,l,h,c]=n(this,ut).subarray(2,6),n(this,Gi).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,E,S]=n(this,ut).subarray(14,18),n(this,pi).push(NaN,NaN,NaN,NaN,((E+o)/2-s)/r,((S+l)/2-i)/a),!0):([E,S,o,l,h,c]=n(this,ut).subarray(0,6),n(this,Gi).push(((E+5*o)/6-s)/r,((S+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),[h,c,o,l,E,S]=n(this,ut).subarray(12,18),n(this,pi).push(((E+5*o)/6-s)/r,((S+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const e=n(this,Gi),t=n(this,pi);if(isNaN(n(this,ut)[6])&&!this.isEmpty())return b(this,fe,Vy).call(this);const s=[];s.push(`M${e[4]} ${e[5]}`);for(let i=6;i<e.length;i+=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);b(this,fe,Yy).call(this,s);for(let i=t.length-6;i>=6;i-=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);return b(this,fe,Xy).call(this,s),s.join(" ")}newFreeDrawOutline(e,t,s,i,r,a){return new Zy(e,t,s,i,r,a)}getOutlines(){var u;const e=n(this,Gi),t=n(this,pi),s=n(this,ut),[i,r,a,o]=n(this,Cs),l=new Float32Array((((u=n(this,Hr))==null?void 0:u.length)??0)+2);for(let f=0,p=l.length-2;f<p;f+=2)l[f]=(n(this,Hr)[f]-i)/a,l[f+1]=(n(this,Hr)[f+1]-r)/o;if(l[l.length-2]=(n(this,Io)-i)/a,l[l.length-1]=(n(this,Po)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,fe,Ky).call(this,l);const h=new Float32Array(n(this,Gi).length+24+n(this,pi).length);let c=e.length;for(let f=0;f<c;f+=2){if(isNaN(e[f])){h[f]=h[f+1]=NaN;continue}h[f]=e[f],h[f+1]=e[f+1]}c=b(this,fe,Qy).call(this,h,c);for(let f=t.length-6;f>=6;f-=6)for(let p=0;p<6;p+=2){if(isNaN(t[f+p])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=t[f+p],h[c+1]=t[f+p+1],c+=2}return b(this,fe,Jy).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,Cs),n(this,fh),n(this,dh),n(this,uh))}};Cs=new WeakMap,pi=new WeakMap,dh=new WeakMap,uh=new WeakMap,Gi=new WeakMap,ut=new WeakMap,Io=new WeakMap,Po=new WeakMap,zd=new WeakMap,Wd=new WeakMap,fh=new WeakMap,ph=new WeakMap,Hr=new WeakMap,Vd=new WeakMap,Vf=new WeakMap,Xf=new WeakMap,fe=new WeakSet,oc=function(){const e=n(this,ut).subarray(4,6),t=n(this,ut).subarray(16,18),[s,i,r,a]=n(this,Cs);return[(n(this,Io)+(e[0]-t[0])/2-s)/r,(n(this,Po)+(e[1]-t[1])/2-i)/a,(n(this,Io)+(t[0]-e[0])/2-s)/r,(n(this,Po)+(t[1]-e[1])/2-i)/a]},Vy=function(){const[e,t,s,i]=n(this,Cs),[r,a,o,l]=b(this,fe,oc).call(this);return`M${(n(this,ut)[2]-e)/s} ${(n(this,ut)[3]-t)/i} L${(n(this,ut)[4]-e)/s} ${(n(this,ut)[5]-t)/i} L${r} ${a} L${o} ${l} L${(n(this,ut)[16]-e)/s} ${(n(this,ut)[17]-t)/i} L${(n(this,ut)[14]-e)/s} ${(n(this,ut)[15]-t)/i} Z`},Xy=function(e){const t=n(this,pi);e.push(`L${t[4]} ${t[5]} Z`)},Yy=function(e){const[t,s,i,r]=n(this,Cs),a=n(this,ut).subarray(4,6),o=n(this,ut).subarray(16,18),[l,h,c,u]=b(this,fe,oc).call(this);e.push(`L${(a[0]-t)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${u} L${(o[0]-t)/i} ${(o[1]-s)/r}`)},Ky=function(e){const t=n(this,ut),[s,i,r,a]=n(this,Cs),[o,l,h,c]=b(this,fe,oc).call(this),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(t[2]-s)/r,(t[3]-i)/a,NaN,NaN,NaN,NaN,(t[4]-s)/r,(t[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(t[16]-s)/r,(t[17]-i)/a,NaN,NaN,NaN,NaN,(t[14]-s)/r,(t[15]-i)/a],0),this.newFreeDrawOutline(u,e,n(this,Cs),n(this,fh),n(this,dh),n(this,uh))},Jy=function(e,t){const s=n(this,pi);return e.set([NaN,NaN,NaN,NaN,s[4],s[5]],t),t+=6},Qy=function(e,t){const s=n(this,ut).subarray(4,6),i=n(this,ut).subarray(16,18),[r,a,o,l]=n(this,Cs),[h,c,u,f]=b(this,fe,oc).call(this);return e.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],t),t+=24},y(rn,Vd,8),y(rn,Vf,2),y(rn,Xf,n(rn,Vd)+n(rn,Vf));let Af=rn;var gh,Mo,Fn,Xd,Is,Yd,re,Yf,qy;class Zy extends z{constructor(t,s,i,r,a,o){super();y(this,Yf);y(this,gh);y(this,Mo,new Float32Array(4));y(this,Fn);y(this,Xd);y(this,Is);y(this,Yd);y(this,re);g(this,re,t),g(this,Is,s),g(this,gh,i),g(this,Yd,r),g(this,Fn,a),g(this,Xd,o),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],b(this,Yf,qy).call(this,o);const[l,h,c,u]=n(this,Mo);for(let f=0,p=t.length;f<p;f+=2)t[f]=(t[f]-l)/c,t[f+1]=(t[f+1]-h)/u;for(let f=0,p=s.length;f<p;f+=2)s[f]=(s[f]-l)/c,s[f+1]=(s[f+1]-h)/u}toSVGPath(){const t=[`M${n(this,re)[4]} ${n(this,re)[5]}`];for(let s=6,i=n(this,re).length;s<i;s+=6){if(isNaN(n(this,re)[s])){t.push(`L${n(this,re)[s+4]} ${n(this,re)[s+5]}`);continue}t.push(`C${n(this,re)[s]} ${n(this,re)[s+1]} ${n(this,re)[s+2]} ${n(this,re)[s+3]} ${n(this,re)[s+4]} ${n(this,re)[s+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,s,i,r],a){const o=i-t,l=r-s;let h,c;switch(a){case 0:h=z._rescale(n(this,re),t,r,o,-l),c=z._rescale(n(this,Is),t,r,o,-l);break;case 90:h=z._rescaleAndSwap(n(this,re),t,s,o,l),c=z._rescaleAndSwap(n(this,Is),t,s,o,l);break;case 180:h=z._rescale(n(this,re),i,s,-o,l),c=z._rescale(n(this,Is),i,s,-o,l);break;case 270:h=z._rescaleAndSwap(n(this,re),i,r,-o,-l),c=z._rescaleAndSwap(n(this,Is),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,Mo)}newOutliner(t,s,i,r,a,o=0){return new Af(t,s,i,r,a,o)}getNewOutline(t,s){const[i,r,a,o]=n(this,Mo),[l,h,c,u]=n(this,gh),f=a*c,p=o*u,m=i*c+l,v=r*u+h,A=this.newOutliner({x:n(this,Is)[0]*f+m,y:n(this,Is)[1]*p+v},n(this,gh),n(this,Yd),t,n(this,Xd),s??n(this,Fn));for(let w=2;w<n(this,Is).length;w+=2)A.add({x:n(this,Is)[w]*f+m,y:n(this,Is)[w+1]*p+v});return A.getOutlines()}}gh=new WeakMap,Mo=new WeakMap,Fn=new WeakMap,Xd=new WeakMap,Is=new WeakMap,Yd=new WeakMap,re=new WeakMap,Yf=new WeakSet,qy=function(t){const s=n(this,re);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r,h=i,c=r;const u=t?Math.max:Math.min,f=new Float32Array(4);for(let m=6,v=s.length;m<v;m+=6){const A=s[m+4],w=s[m+5];isNaN(s[m])?(H.pointBoundingBox(A,w,a),l>w?(o=A,l=w):l===w&&(o=u(o,A)),c<w?(h=A,c=w):c===w&&(h=u(h,A))):(f.set(zn,0),H.bezierBoundingBox(i,r,...s.slice(m,m+6),f),H.rectBoundingBox(...f,a),l>f[1]?(o=f[0],l=f[1]):l===f[1]&&(o=u(o,f[0])),c<f[3]?(h=f[2],c=f[3]):c===f[3]&&(h=u(h,f[2]))),i=A,r=w}const p=n(this,Mo);p[0]=a[0]-n(this,Fn),p[1]=a[1]-n(this,Fn),p[2]=a[2]-a[0]+2*n(this,Fn),p[3]=a[3]-a[1]+2*n(this,Fn),this.firstPoint=[o,l],this.lastPoint=[h,c]};var Kd,Jd,Qd,$r,gi,ts,tb,qu,eb,sb,Pg;class Ig{constructor(e,t=0,s=0,i=!0){y(this,ts);y(this,Kd);y(this,Jd);y(this,Qd);y(this,$r,[]);y(this,gi,[]);const r=zn.slice(),a=10**-4;for(const{x:v,y:A,width:w,height:E}of e){const S=Math.floor((v-t)/a)*a,T=Math.ceil((v+w+t)/a)*a,x=Math.floor((A-t)/a)*a,C=Math.ceil((A+E+t)/a)*a,I=[S,x,C,!0],O=[T,x,C,!1];n(this,$r).push(I,O),H.rectBoundingBox(S,x,T,C,r)}const o=r[2]-r[0]+2*s,l=r[3]-r[1]+2*s,h=r[0]-s,c=r[1]-s;let u=i?-1/0:1/0,f=1/0;const p=n(this,$r).at(i?-1:-2),m=[p[0],p[2]];for(const v of n(this,$r)){const[A,w,E,S]=v;!S&&i?w<f?(f=w,u=A):w===f&&(u=Math.max(u,A)):S&&!i&&(w<f?(f=w,u=A):w===f&&(u=Math.min(u,A))),v[0]=(A-h)/o,v[1]=(w-c)/l,v[2]=(E-c)/l}g(this,Kd,new Float32Array([h,c,o,l])),g(this,Jd,[u,f]),g(this,Qd,m)}getOutlines(){n(this,$r).sort((t,s)=>t[0]-s[0]||t[1]-s[1]||t[2]-s[2]);const e=[];for(const t of n(this,$r))t[3]?(e.push(...b(this,ts,Pg).call(this,t)),b(this,ts,eb).call(this,t)):(b(this,ts,sb).call(this,t),e.push(...b(this,ts,Pg).call(this,t)));return b(this,ts,tb).call(this,e)}}Kd=new WeakMap,Jd=new WeakMap,Qd=new WeakMap,$r=new WeakMap,gi=new WeakMap,ts=new WeakSet,tb=function(e){const t=[],s=new Set;for(const a of e){const[o,l,h]=a;t.push([o,l,a],[o,h,a])}t.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=t.length;a<o;a+=2){const l=t[a][2],h=t[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,u]=a;s.delete(a);let f=o,p=l;for(r=[o,h],i.push(r);;){let m;if(s.has(c))m=c;else if(s.has(u))m=u;else break;s.delete(m),[o,l,h,c,u]=m,f!==o&&(r.push(f,p,o,p===l?l:h),f=o),p=p===l?h:l}r.push(f,p)}return new S0(i,n(this,Kd),n(this,Jd),n(this,Qd))},qu=function(e){const t=n(this,gi);let s=0,i=t.length-1;for(;s<=i;){const r=s+i>>1,a=t[r][0];if(a===e)return r;a<e?s=r+1:i=r-1}return i+1},eb=function([,e,t]){const s=b(this,ts,qu).call(this,e);n(this,gi).splice(s,0,[e,t])},sb=function([,e,t]){const s=b(this,ts,qu).call(this,e);for(let i=s;i<n(this,gi).length;i++){const[r,a]=n(this,gi)[i];if(r!==e)break;if(r===e&&a===t){n(this,gi).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,gi)[i];if(r!==e)break;if(r===e&&a===t){n(this,gi).splice(i,1);return}}},Pg=function(e){const[t,s,i]=e,r=[[t,s,i]],a=b(this,ts,qu).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,gi)[o];for(let c=0,u=r.length;c<u;c++){const[,f,p]=r[c];if(!(h<=f||p<=l)){if(f>=l){if(p>h)r[c][1]=h;else{if(u===1)return[];r.splice(c,1),c--,u--}continue}r[c][2]=l,p>h&&r.push([t,h,p])}}}return r};var Zd,mh;class S0 extends z{constructor(t,s,i,r){super();y(this,Zd);y(this,mh);g(this,mh,t),g(this,Zd,s),this.firstPoint=i,this.lastPoint=r}toSVGPath(){const t=[];for(const s of n(this,mh)){let[i,r]=s;t.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(t.push(`V${l}`),r=l):l===r&&(t.push(`H${o}`),i=o)}t.push("Z")}return t.join(" ")}serialize([t,s,i,r],a){const o=[],l=i-t,h=r-s;for(const c of n(this,mh)){const u=new Array(c.length);for(let f=0;f<c.length;f+=2)u[f]=t+c[f]*l,u[f+1]=r-c[f+1]*h;o.push(u)}return o}get box(){return n(this,Zd)}}Zd=new WeakMap,mh=new WeakMap;class Mg extends Af{newFreeDrawOutline(e,t,s,i,r,a){return new x0(e,t,s,i,r,a)}}class x0 extends Zy{newOutliner(e,t,s,i,r,a=0){return new Mg(e,t,s,i,r,a)}}var vh,qd,Nn,Oo,tu,ls,eu,su,Ro,Ps,Ms,Me,yh,bh,je,Ah,Qs,iu,ot,Og,tf,ib,nb,rb,Rg,ca,ti,el,ab,ef,sf,ob,lb,hb,cb,db;const At=class At extends St{constructor(t){super({...t,name:"highlightEditor"});y(this,ot);y(this,vh,null);y(this,qd,0);y(this,Nn);y(this,Oo,null);y(this,tu,null);y(this,ls,null);y(this,eu,null);y(this,su,0);y(this,Ro,null);y(this,Ps,null);y(this,Ms,null);y(this,Me,!1);y(this,yh,null);y(this,bh,null);y(this,je,null);y(this,Ah,"");y(this,Qs);y(this,iu,"");this.color=t.color||At._defaultColor,g(this,Qs,t.thickness||At._defaultThickness),this.opacity=t.opacity||At._defaultOpacity,g(this,Nn,t.boxes||null),g(this,iu,t.methodOfCreation||""),g(this,Ah,t.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(g(this,Me,!0),b(this,ot,tf).call(this,t),b(this,ot,ca).call(this)):n(this,Nn)&&(g(this,vh,t.anchorNode),g(this,qd,t.anchorOffset),g(this,eu,t.focusNode),g(this,su,t.focusOffset),b(this,ot,Og).call(this),b(this,ot,ca).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(St._l10nAlert.highlight)}static get _keyboardManager(){const t=At.prototype;return st(this,"_keyboardManager",new Vo([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,Me)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,Qs),methodOfCreation:n(this,iu)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(t,s){var i;St.initialize(t,s),At._defaultColor||(At._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(t,s){switch(t){case at.HIGHLIGHT_COLOR:At._defaultColor=s;break;case at.HIGHLIGHT_THICKNESS:At._defaultThickness=s;break}}translateInPage(t,s){}get toolbarPosition(){return n(this,bh)}get commentButtonPosition(){return n(this,yh)}updateParams(t,s){switch(t){case at.HIGHLIGHT_COLOR:b(this,ot,ib).call(this,s);break;case at.HIGHLIGHT_THICKNESS:b(this,ot,nb).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[at.HIGHLIGHT_COLOR,At._defaultColor],[at.HIGHLIGHT_THICKNESS,At._defaultThickness]]}get propertiesToUpdate(){return[[at.HIGHLIGHT_COLOR,this.color||At._defaultColor],[at.HIGHLIGHT_THICKNESS,n(this,Qs)||At._defaultThickness],[at.HIGHLIGHT_FREE,n(this,Me)]]}onUpdatedColor(){var t,s;(t=this.parent)==null||t.drawLayer.updateProperties(n(this,Ms),{root:{fill:this.color,"fill-opacity":this.opacity}}),(s=n(this,tu))==null||s.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",g(this,tu,new xc({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(b(this,ot,sf).call(this))}getBaseTranslation(){return[0,0]}getRect(t,s){return super.getRect(t,s,b(this,ot,sf).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){b(this,ot,Rg).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,ot,ca).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let s=!1;this.parent&&!t?b(this,ot,Rg).call(this):t&&(b(this,ot,ca).call(this,t),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),s&&this.select()}rotate(t){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,Me)?(t=(t-this.rotation+360)%360,i=b(r=At,ti,el).call(r,n(this,Ps).box,t)):i=b(a=At,ti,el).call(a,[this.x,this.y,this.width,this.height],t),s.updateProperties(n(this,Ms),{bbox:i,root:{"data-main-rotation":t}}),s.updateProperties(n(this,je),{bbox:b(o=At,ti,el).call(o,n(this,ls).box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();n(this,Ah)&&(t.setAttribute("aria-label",n(this,Ah)),t.setAttribute("role","mark")),n(this,Me)?t.classList.add("free"):this.div.addEventListener("keydown",b(this,ot,ab).bind(this),{signal:this._uiManager._signal});const s=g(this,Ro,document.createElement("div"));return t.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,Oo),this.setDims(),cv(this,n(this,Ro),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||(t=this.parent)==null||t.drawLayer.updateProperties(n(this,je),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||(t=this.parent)==null||t.drawLayer.updateProperties(n(this,je),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:b(this,ot,ef).call(this,!0);break;case 1:case 3:b(this,ot,ef).call(this,!1);break}}select(){var t;super.select(),n(this,je)&&((t=this.parent)==null||t.drawLayer.updateProperties(n(this,je),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),n(this,je)&&((t=this.parent)==null||t.drawLayer.updateProperties(n(this,je),{rootClass:{selected:!1}}),n(this,Me)||b(this,ot,ef).call(this,!1))}get _mustFixPosition(){return!n(this,Me)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Ms),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(n(this,je),{rootClass:{hidden:!t}}))}static startHighlighting(t,s,{target:i,x:r,y:a}){const{x:o,y:l,width:h,height:c}=i.getBoundingClientRect(),u=new AbortController,f=t.combinedSignal(u),p=m=>{u.abort(),b(this,ti,cb).call(this,t,m)};window.addEventListener("blur",p,{signal:f}),window.addEventListener("pointerup",p,{signal:f}),window.addEventListener("pointerdown",Wt,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Bs,{signal:f}),i.addEventListener("pointermove",b(this,ti,hb).bind(this,t),{signal:f}),this._freeHighlight=new Mg({x:r,y:a},[o,l,h,c],t.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(t,s,i){var A,w,E,S;let r=null;if(t instanceof By){const{data:{quadPoints:T,rect:x,rotation:C,id:I,color:O,opacity:M,popupRef:R,richText:D,contentsObj:j,creationDate:F,modificationDate:U},parent:{page:{pageNumber:Z}}}=t;r=t={annotationType:nt.HIGHLIGHT,color:Array.from(O),opacity:M,quadPoints:T,boxes:null,pageIndex:Z-1,rect:x.slice(0),rotation:C,annotationElementId:I,id:I,deleted:!1,popupRef:R,richText:D,comment:(j==null?void 0:j.str)||null,creationDate:F,modificationDate:U}}else if(t instanceof am){const{data:{inkLists:T,rect:x,rotation:C,id:I,color:O,borderStyle:{rawWidth:M},popupRef:R,richText:D,contentsObj:j,creationDate:F,modificationDate:U},parent:{page:{pageNumber:Z}}}=t;r=t={annotationType:nt.HIGHLIGHT,color:Array.from(O),thickness:M,inkLists:T,boxes:null,pageIndex:Z-1,rect:x.slice(0),rotation:C,annotationElementId:I,id:I,deleted:!1,popupRef:R,richText:D,comment:(j==null?void 0:j.str)||null,creationDate:F,modificationDate:U}}const{color:a,quadPoints:o,inkLists:l,outlines:h,opacity:c}=t,u=await super.deserialize(t,s,i);u.color=H.makeHexColor(...a),u.opacity=c||1,l&&g(u,Qs,t.thickness),u._initialData=r,t.comment&&u.setCommentData(t);const[f,p]=u.pageDimensions,[m,v]=u.pageTranslation;if(o){const T=g(u,Nn,[]);for(let x=0;x<o.length;x+=8)T.push({x:(o[x]-m)/f,y:1-(o[x+1]-v)/p,width:(o[x+2]-o[x])/f,height:(o[x+1]-o[x+5])/p});b(A=u,ot,Og).call(A),b(w=u,ot,ca).call(w),u.rotate(u.rotation)}else if(l||h){g(u,Me,!0);const T=(l||h.points)[0],x={x:T[0]-m,y:p-(T[1]-v)},C=new Mg(x,[0,0,f,p],1,n(u,Qs)/2,!0,.001);for(let M=0,R=T.length;M<R;M+=2)x.x=T[M]-m,x.y=p-(T[M+1]-v),C.add(x);const{id:I,clipPathId:O}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);b(E=u,ot,tf).call(E,{highlightOutlines:C.getOutlines(),highlightId:I,clipPathId:O}),b(S=u,ot,ca).call(S),u.rotate(u.parentRotation)}return u}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const s=St._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:s,opacity:this.opacity,thickness:n(this,Qs),quadPoints:b(this,ot,ob).call(this),outlines:b(this,ot,lb).call(this,i.rect)}),this.addComment(i),this.annotationElementId&&!b(this,ot,db).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};vh=new WeakMap,qd=new WeakMap,Nn=new WeakMap,Oo=new WeakMap,tu=new WeakMap,ls=new WeakMap,eu=new WeakMap,su=new WeakMap,Ro=new WeakMap,Ps=new WeakMap,Ms=new WeakMap,Me=new WeakMap,yh=new WeakMap,bh=new WeakMap,je=new WeakMap,Ah=new WeakMap,Qs=new WeakMap,iu=new WeakMap,ot=new WeakSet,Og=function(){const t=new Ig(n(this,Nn),.001);g(this,Ps,t.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,Ps).box;const s=new Ig(n(this,Nn),.0025,.001,this._uiManager.direction==="ltr");g(this,ls,s.getOutlines());const{firstPoint:i}=n(this,Ps);g(this,yh,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:r}=n(this,ls);g(this,bh,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},tf=function({highlightOutlines:t,highlightId:s,clipPathId:i}){var f,p;if(g(this,Ps,t),g(this,ls,t.getNewOutline(n(this,Qs)/2+1.5,.0025)),s>=0)g(this,Ms,s),g(this,Oo,i),this.parent.drawLayer.finalizeDraw(s,{bbox:t.box,path:{d:t.toSVGPath()}}),g(this,je,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,ls).box,path:{d:n(this,ls).toSVGPath()}},!0));else if(this.parent){const m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Ms),{bbox:b(f=At,ti,el).call(f,n(this,Ps).box,(m-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,je),{bbox:b(p=At,ti,el).call(p,n(this,ls).box,m),path:{d:n(this,ls).toSVGPath()}})}const[a,o,l,h]=t.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[m,v]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*v/m,this.height=h*m/v;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[m,v]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*v/m,this.height=h*m/v;break}}const{firstPoint:c}=t;g(this,yh,[(c[0]-a)/l,(c[1]-o)/h]);const{lastPoint:u}=n(this,ls);g(this,bh,[(u[0]-a)/l,(u[1]-o)/h])},ib=function(t){const s=(a,o)=>{this.color=a,this.opacity=o,this.onUpdatedColor()},i=this.color,r=this.opacity;this.addCommands({cmd:s.bind(this,t,At._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:at.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)},nb=function(t){const s=n(this,Qs),i=r=>{g(this,Qs,r),b(this,ot,rb).call(this,r)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:at.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},rb=function(t){n(this,Me)&&(b(this,ot,tf).call(this,{highlightOutlines:n(this,Ps).getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())},Rg=function(){n(this,Ms)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Ms)),g(this,Ms,null),this.parent.drawLayer.remove(n(this,je)),g(this,je,null))},ca=function(t=this.parent){n(this,Ms)===null&&({id:$t(this,Ms)._,clipPathId:$t(this,Oo)._}=t.drawLayer.draw({bbox:n(this,Ps).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:n(this,Me)},path:{d:n(this,Ps).toSVGPath()}},!1,!0),g(this,je,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Me)},bbox:n(this,ls).box,path:{d:n(this,ls).toSVGPath()}},n(this,Me))),n(this,Ro)&&(n(this,Ro).style.clipPath=n(this,Oo)))},ti=new WeakSet,el=function([t,s,i,r],a){switch(a){case 90:return[1-s-r,t,r,i];case 180:return[1-t-i,1-s-r,i,r];case 270:return[s,1-t-i,r,i]}return[t,s,i,r]},ab=function(t){At._keyboardManager.exec(this,t)},ef=function(t){if(!n(this,vh))return;const s=window.getSelection();t?s.setPosition(n(this,vh),n(this,qd)):s.setPosition(n(this,eu),n(this,su))},sf=function(){return n(this,Me)?this.rotation:0},ob=function(){if(n(this,Me))return null;const[t,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,Nn),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:u,height:f}of a){const p=h*t+i,m=(1-c)*s+r;o[l]=o[l+4]=p,o[l+1]=o[l+3]=m,o[l+2]=o[l+6]=p+u*t,o[l+5]=o[l+7]=m-f*s,l+=8}return o},lb=function(t){return n(this,Ps).serialize(t,b(this,ot,sf).call(this))},hb=function(t,s){this._freeHighlight.add(s)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},cb=function(t,s){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},db=function(t){const{color:s}=this._initialData;return this.hasEditedComment||t.color.some((i,r)=>i!==s[r])},y(At,ti),P(At,"_defaultColor",null),P(At,"_defaultOpacity",1),P(At,"_defaultThickness",12),P(At,"_type","highlight"),P(At,"_editorType",nt.HIGHLIGHT),P(At,"_freeHighlightId",-1),P(At,"_freeHighlight",null),P(At,"_freeHighlightClipId","");let wf=At;var Do;class ub{constructor(){y(this,Do,Object.create(null))}updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,s]of Object.entries(e))t.startsWith("_")||this.updateProperty(t,s)}updateSVGProperty(e,t){n(this,Do)[e]=t}toSVGProperties(){const e=n(this,Do);return g(this,Do,Object.create(null)),{root:e}}reset(){g(this,Do,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){bt("Not implemented")}}Do=new WeakMap;var Ye,wh,Ae,ko,Lo,mt,Dg,kg,Lg,lc,fb,nf,hc,sl;const pt=class pt extends St{constructor(t){super(t);y(this,mt);y(this,Ye,null);y(this,wh);P(this,"_colorPicker",null);P(this,"_drawId",null);g(this,wh,t.mustBeCommitted||!1),this._addOutlines(t)}onUpdatedColor(){var t;(t=this._colorPicker)==null||t.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){var t,s;(s=(t=this._colorPicker)==null?void 0:t.updateOpacity)==null||s.call(t,this.opacity)}_addOutlines(t){t.drawOutlines&&(b(this,mt,Dg).call(this,t),b(this,mt,lc).call(this))}static _mergeSVGProperties(t,s){const i=new Set(Object.keys(t));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(t[r],a):t[r]=a;return t}static getDefaultDrawingOptions(t){bt("Not implemented")}static get typesMap(){bt("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,s){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(pt,Ae).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,s){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,s)}static get defaultPropertiesToUpdate(){const t=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)t.push([i,s[r]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)t.push([i,s[r]]);return t}_updateProperty(t,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var c;r.updateProperty(s,l);const h=n(this,Ye).updateProperty(s,l);h&&b(this,mt,hc).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,s){const i=this.constructor.typesMap.get(this.colorType),r=this.constructor.typesMap.get(this.opacityType),a=this._drawingOptions,o=a[i],l=a[r],h=(c,u)=>{var f;a.updateProperty(i,c),a.updateProperty(r,u),n(this,Ye).updateProperty(i,c),n(this,Ye).updateProperty(r,u),(f=this.parent)==null||f.drawLayer.updateProperties(this._drawId,a.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:h.bind(this,t,s),undo:h.bind(this,o,l),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:at.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,pt._mergeSVGProperties(n(this,Ye).getPathResizingSVGProperties(b(this,mt,nf).call(this)),{bbox:b(this,mt,sl).call(this)}))}_onResized(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,pt._mergeSVGProperties(n(this,Ye).getPathResizedSVGProperties(b(this,mt,nf).call(this)),{bbox:b(this,mt,sl).call(this)}))}_onTranslating(t,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,mt,sl).call(this)})}_onTranslated(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,pt._mergeSVGProperties(n(this,Ye).getPathTranslatedSVGProperties(b(this,mt,nf).call(this),this.parentDimensions),{bbox:b(this,mt,sl).call(this)}))}_onStartDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;(t=this.parent)==null||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,wh)&&(g(this,wh,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){b(this,mt,Lg).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,mt,lc).call(this),b(this,mt,hc).call(this,n(this,Ye).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var i;let s=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),b(this,mt,Lg).call(this)):t&&(this._uiManager.addShouldRescale(this),b(this,mt,lc).call(this,t),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(t),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,pt._mergeSVGProperties({bbox:b(this,mt,sl).call(this)},n(this,Ye).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,mt,hc).call(this,n(this,Ye).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,s;this._isCopy&&(t=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");return i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,s),i}static createDrawerInstance(t,s,i,r,a){bt("Not implemented")}static startDrawing(t,s,i,r){var A;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(Be.isInitializedAndDifferentPointerType(c))return;const{viewport:{rotation:u}}=t,{width:f,height:p}=a.getBoundingClientRect(),m=g(pt,ko,new AbortController),v=t.combinedSignal(m);if(Be.setPointer(c,h),window.addEventListener("pointerup",w=>{Be.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:v}),window.addEventListener("pointercancel",w=>{Be.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:v}),window.addEventListener("pointerdown",w=>{Be.isSamePointerType(w.pointerType)&&(Be.initializeAndAddPointerId(w.pointerId),n(pt,Ae).isCancellable()&&(n(pt,Ae).removeLastElement(),n(pt,Ae).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:v}),window.addEventListener("contextmenu",Bs,{signal:v}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:v}),a.addEventListener("touchmove",w=>{Be.isSameTimeStamp(w.timeStamp)&&Wt(w)},{signal:v}),t.toggleDrawing(),(A=s._editorUndoBar)==null||A.hide(),n(pt,Ae)){t.drawLayer.updateProperties(this._currentDrawId,n(pt,Ae).startNew(o,l,f,p,u));return}s.updateUIForDefaultProperties(this),g(pt,Ae,this.createDrawerInstance(o,l,f,p,u)),g(pt,Lo,this.getDefaultDrawingOptions()),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(n(pt,Lo).toSVGProperties(),n(pt,Ae).defaultSVGProperties),!0,!1)}static _drawMove(t){if(Be.isSameTimeStamp(t.timeStamp),!n(pt,Ae))return;const{offsetX:s,offsetY:i,pointerId:r}=t;if(Be.isSamePointerId(r)){if(Be.isUsingMultiplePointers()){this._endDraw(t);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(pt,Ae).add(s,i)),Be.setTimeStamp(t.timeStamp),Wt(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,g(pt,Ae,null),g(pt,Lo,null),Be.clearTimeStamp()),n(pt,ko)&&(n(pt,ko).abort(),g(pt,ko,null),Be.clearPointerIds())}static _endDraw(t){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(t==null?void 0:t.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(pt,Ae).end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const i=n(pt,Ae),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:at.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(at.DRAW_STEP),!n(pt,Ae).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(pt,Ae).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(pt,Lo),mustBeCommitted:!t});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,s,i,r,a,o){bt("Not implemented")}static async deserialize(t,s,i){var u,f;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,t),c=await super.deserialize(t,s,i);return c.createDrawingOptions(t),b(u=c,mt,Dg).call(u,{drawOutlines:h}),b(f=c,mt,lc).call(f),c.onScaleChanging(),c.rotate(),c}serializeDraw(t){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,Ye).serialize([s,i,r,a],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Ye=new WeakMap,wh=new WeakMap,Ae=new WeakMap,ko=new WeakMap,Lo=new WeakMap,mt=new WeakSet,Dg=function({drawOutlines:t,drawId:s,drawingOptions:i}){g(this,Ye,t),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(St._l10nAlert[this.editorType]),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,t.defaultProperties)):this._drawId=b(this,mt,kg).call(this,t,this.parent),b(this,mt,hc).call(this,t.box)},kg=function(t,s){const{id:i}=s.drawLayer.draw(pt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i},Lg=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},lc=function(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,mt,kg).call(this,n(this,Ye),t)}},fb=function([t,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-t,i*(o/a),r*(a/o)];case 180:return[1-t,1-s,i,r];case 270:return[1-s,t,i*(o/a),r*(a/o)];default:return[t,s,i,r]}},nf=function(){const{x:t,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,t,i*(a/o),r*(o/a)];case 180:return[1-t,1-s,i,r];case 270:return[s,1-t,i*(a/o),r*(o/a)];default:return[t,s,i,r]}},hc=function(t){[this.x,this.y,this.width,this.height]=b(this,mt,fb).call(this,t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},sl=function(){const{x:t,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,t,r,i];case 2:return[1-t-i,1-s-r,i,r];case 3:return[s,1-t-i,r,i];case 4:return[t,s-i*(l/h),r*(h/l),i*(l/h)];case 5:return[1-s,t,i*(l/h),r*(h/l)];case 6:return[1-t-r*(h/l),1-s,r*(h/l),i*(l/h)];case 7:return[s-i*(l/h),1-t-r*(h/l),i*(l/h),r*(h/l)];case 8:return[t-i,s-r,i,r];case 9:return[1-s,t-i,r,i];case 10:return[1-t,1-s,i,r];case 11:return[s-r,1-t,r,i];case 12:return[t-r*(h/l),s,r*(h/l),i*(l/h)];case 13:return[1-s-i*(l/h),t-r*(h/l),i*(l/h),r*(h/l)];case 14:return[1-t,1-s-i*(l/h),r*(h/l),i*(l/h)];case 15:return[s,1-t,i*(l/h),r*(h/l)];default:return[t,s,i,r]}},P(pt,"_currentDrawId",-1),P(pt,"_currentParent",null),y(pt,Ae,null),y(pt,ko,null),y(pt,Lo,null),P(pt,"_INNER_MARGIN",3);let Ef=pt;var _i,we,Oe,Fo,Eh,Ke,Re,Zs,No,Bo,Uo,Sh,rf;class T0{constructor(e,t,s,i,r,a){y(this,Sh);y(this,_i,new Float64Array(6));y(this,we);y(this,Oe);y(this,Fo);y(this,Eh);y(this,Ke);y(this,Re,"");y(this,Zs,0);y(this,No,new gu);y(this,Bo);y(this,Uo);g(this,Bo,s),g(this,Uo,i),g(this,Fo,r),g(this,Eh,a),[e,t]=b(this,Sh,rf).call(this,e,t);const o=g(this,we,[NaN,NaN,NaN,NaN,e,t]);g(this,Ke,[e,t]),g(this,Oe,[{line:o,points:n(this,Ke)}]),n(this,_i).set(o,0)}updateProperty(e,t){e==="stroke-width"&&g(this,Eh,t)}isEmpty(){var e;return!((e=n(this,Oe))!=null&&e.length)}isCancellable(){return n(this,Ke).length<=10}add(e,t){[e,t]=b(this,Sh,rf).call(this,e,t);const[s,i,r,a]=n(this,_i).subarray(2,6),o=e-r,l=t-a;return Math.hypot(n(this,Bo)*o,n(this,Uo)*l)<=2?null:(n(this,Ke).push(e,t),isNaN(s)?(n(this,_i).set([r,a,e,t],2),n(this,we).push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(n(this,_i)[0])&&n(this,we).splice(6,6),n(this,_i).set([s,i,r,a,e,t],0),n(this,we).push(...z.createBezierPoints(s,i,r,a,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){const s=this.add(e,t);return s||(n(this,Ke).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,s,i,r){g(this,Bo,s),g(this,Uo,i),g(this,Fo,r),[e,t]=b(this,Sh,rf).call(this,e,t);const a=g(this,we,[NaN,NaN,NaN,NaN,e,t]);g(this,Ke,[e,t]);const o=n(this,Oe).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,Oe).push({line:a,points:n(this,Ke)}),n(this,_i).set(a,0),g(this,Zs,0),this.toSVGPath(),null}getLastElement(){return n(this,Oe).at(-1)}setLastElement(e){return n(this,Oe)?(n(this,Oe).push(e),g(this,we,e.line),g(this,Ke,e.points),g(this,Zs,0),{path:{d:this.toSVGPath()}}):n(this,No).setLastElement(e)}removeLastElement(){if(!n(this,Oe))return n(this,No).removeLastElement();n(this,Oe).pop(),g(this,Re,"");for(let e=0,t=n(this,Oe).length;e<t;e++){const{line:s,points:i}=n(this,Oe)[e];g(this,we,s),g(this,Ke,i),g(this,Zs,0),this.toSVGPath()}return{path:{d:n(this,Re)}}}toSVGPath(){const e=z.svgRound(n(this,we)[4]),t=z.svgRound(n(this,we)[5]);if(n(this,Ke).length===2)return g(this,Re,`${n(this,Re)} M ${e} ${t} Z`),n(this,Re);if(n(this,Ke).length<=6){const i=n(this,Re).lastIndexOf("M");g(this,Re,`${n(this,Re).slice(0,i)} M ${e} ${t}`),g(this,Zs,6)}if(n(this,Ke).length===4){const i=z.svgRound(n(this,we)[10]),r=z.svgRound(n(this,we)[11]);return g(this,Re,`${n(this,Re)} L ${i} ${r}`),g(this,Zs,12),n(this,Re)}const s=[];n(this,Zs)===0&&(s.push(`M ${e} ${t}`),g(this,Zs,6));for(let i=n(this,Zs),r=n(this,we).length;i<r;i+=6){const[a,o,l,h,c,u]=n(this,we).slice(i,i+6).map(z.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}return g(this,Re,n(this,Re)+s.join(" ")),g(this,Zs,n(this,we).length),n(this,Re)}getOutlines(e,t,s,i){const r=n(this,Oe).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,No).build(n(this,Oe),e,t,s,n(this,Fo),n(this,Eh),i),g(this,_i,null),g(this,we,null),g(this,Oe,null),g(this,Re,null),n(this,No)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}_i=new WeakMap,we=new WeakMap,Oe=new WeakMap,Fo=new WeakMap,Eh=new WeakMap,Ke=new WeakMap,Re=new WeakMap,Zs=new WeakMap,No=new WeakMap,Bo=new WeakMap,Uo=new WeakMap,Sh=new WeakSet,rf=function(e,t){return z._normalizePoint(e,t,n(this,Bo),n(this,Uo),n(this,Fo))};var Je,nu,ru,Os,zi,Wi,xh,Th,Ho,ke,sn,pb,gb,mb;class gu extends z{constructor(){super(...arguments);y(this,ke);y(this,Je);y(this,nu,0);y(this,ru);y(this,Os);y(this,zi);y(this,Wi);y(this,xh);y(this,Th);y(this,Ho)}build(t,s,i,r,a,o,l){g(this,zi,s),g(this,Wi,i),g(this,xh,r),g(this,Th,a),g(this,Ho,o),g(this,ru,l??0),g(this,Os,t),b(this,ke,gb).call(this)}get thickness(){return n(this,Ho)}setLastElement(t){return n(this,Os).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,Os).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:s}of n(this,Os)){if(t.push(`M${z.svgRound(s[4])} ${z.svgRound(s[5])}`),s.length===6){t.push("Z");continue}if(s.length===12&&isNaN(s[6])){t.push(`L${z.svgRound(s[10])} ${z.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,u]=s.subarray(i,i+6).map(z.svgRound);t.push(`C${a} ${o} ${l} ${h} ${c} ${u}`)}}return t.join("")}serialize([t,s,i,r],a){const o=[],l=[],[h,c,u,f]=b(this,ke,pb).call(this);let p,m,v,A,w,E,S,T,x;switch(n(this,Th)){case 0:x=z._rescale,p=t,m=s+r,v=i,A=-r,w=t+h*i,E=s+(1-c-f)*r,S=t+(h+u)*i,T=s+(1-c)*r;break;case 90:x=z._rescaleAndSwap,p=t,m=s,v=i,A=r,w=t+c*i,E=s+h*r,S=t+(c+f)*i,T=s+(h+u)*r;break;case 180:x=z._rescale,p=t+i,m=s,v=-i,A=r,w=t+(1-h-u)*i,E=s+c*r,S=t+(1-h)*i,T=s+(c+f)*r;break;case 270:x=z._rescaleAndSwap,p=t+i,m=s+r,v=-i,A=-r,w=t+(1-c-f)*i,E=s+(1-h-u)*r,S=t+(1-c)*i,T=s+(1-h)*r;break}for(const{line:C,points:I}of n(this,Os))o.push(x(C,p,m,v,A,a?new Array(C.length):null)),l.push(x(I,p,m,v,A,a?new Array(I.length):null));return{lines:o,points:l,rect:[w,E,S,T]}}static deserialize(t,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const u=[];let f,p,m,v,A;switch(h){case 0:A=z._rescale,f=-t/i,p=s/r+1,m=1/i,v=-1/r;break;case 90:A=z._rescaleAndSwap,f=-s/r,p=-t/i,m=1/r,v=1/i;break;case 180:A=z._rescale,f=t/i+1,p=-s/r,m=-1/i,v=1/r;break;case 270:A=z._rescaleAndSwap,f=s/r+1,p=t/i+1,m=-1/r,v=-1/i;break}if(!o){o=[];for(const E of l){const S=E.length;if(S===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,E[0],E[1]]));continue}if(S===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,E[0],E[1],NaN,NaN,NaN,NaN,E[2],E[3]]));continue}const T=new Float32Array(3*(S-2));o.push(T);let[x,C,I,O]=E.subarray(0,4);T.set([NaN,NaN,NaN,NaN,x,C],0);for(let M=4;M<S;M+=2){const R=E[M],D=E[M+1];T.set(z.createBezierPoints(x,C,I,O,R,D),(M-2)*3),[x,C,I,O]=[I,O,R,D]}}}for(let E=0,S=o.length;E<S;E++)u.push({line:A(o[E].map(T=>T??NaN),f,p,m,v),points:A(l[E].map(T=>T??NaN),f,p,m,v)});const w=new this.prototype.constructor;return w.build(u,i,r,1,h,c,a),w}get box(){return n(this,Je)}updateProperty(t,s){return t==="stroke-width"?b(this,ke,mb).call(this,s):null}updateParentDimensions([t,s],i){const[r,a]=b(this,ke,sn).call(this);g(this,zi,t),g(this,Wi,s),g(this,xh,i);const[o,l]=b(this,ke,sn).call(this),h=o-r,c=l-a,u=n(this,Je);return u[0]-=h,u[1]-=c,u[2]+=2*h,u[3]+=2*c,u}updateRotation(t){return g(this,nu,t),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,Je).map(z.svgRound).join(" ")}get defaultProperties(){const[t,s]=n(this,Je);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${z.svgRound(t)} ${z.svgRound(s)}`}}}get rotationTransform(){const[,,t,s]=n(this,Je);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,nu)){case 90:r=s/t,a=-t/s,l=t;break;case 180:i=-1,o=-1,l=t,h=s;break;case 270:r=-s/t,a=t/s,h=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${z.svgRound(l)} ${z.svgRound(h)})`}getPathResizingSVGProperties([t,s,i,r]){const[a,o]=b(this,ke,sn).call(this),[l,h,c,u]=n(this,Je);if(Math.abs(c-a)<=z.PRECISION||Math.abs(u-o)<=z.PRECISION){const A=t+i/2-(l+c/2),w=s+r/2-(h+u/2);return{path:{"transform-origin":`${z.svgRound(t)} ${z.svgRound(s)}`,transform:`${this.rotationTransform} translate(${A} ${w})`}}}const f=(i-2*a)/(c-2*a),p=(r-2*o)/(u-2*o),m=c/i,v=u/r;return{path:{"transform-origin":`${z.svgRound(l)} ${z.svgRound(h)}`,transform:`${this.rotationTransform} scale(${m} ${v}) translate(${z.svgRound(a)} ${z.svgRound(o)}) scale(${f} ${p}) translate(${z.svgRound(-a)} ${z.svgRound(-o)})`}}}getPathResizedSVGProperties([t,s,i,r]){const[a,o]=b(this,ke,sn).call(this),l=n(this,Je),[h,c,u,f]=l;if(l[0]=t,l[1]=s,l[2]=i,l[3]=r,Math.abs(u-a)<=z.PRECISION||Math.abs(f-o)<=z.PRECISION){const w=t+i/2-(h+u/2),E=s+r/2-(c+f/2);for(const{line:S,points:T}of n(this,Os))z._translate(S,w,E,S),z._translate(T,w,E,T);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${z.svgRound(t)} ${z.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(i-2*a)/(u-2*a),m=(r-2*o)/(f-2*o),v=-p*(h+a)+t+a,A=-m*(c+o)+s+o;if(p!==1||m!==1||v!==0||A!==0)for(const{line:w,points:E}of n(this,Os))z._rescale(w,v,A,p,m,w),z._rescale(E,v,A,p,m,E);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${z.svgRound(t)} ${z.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,s],i){const[r,a]=i,o=n(this,Je),l=t-o[0],h=s-o[1];if(n(this,zi)===r&&n(this,Wi)===a)for(const{line:c,points:u}of n(this,Os))z._translate(c,l,h,c),z._translate(u,l,h,u);else{const c=n(this,zi)/r,u=n(this,Wi)/a;g(this,zi,r),g(this,Wi,a);for(const{line:f,points:p}of n(this,Os))z._rescale(f,l,h,c,u,f),z._rescale(p,l,h,c,u,p);o[2]*=c,o[3]*=u}return o[0]=t,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${z.svgRound(t)} ${z.svgRound(s)}`}}}get defaultSVGProperties(){const t=n(this,Je);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${z.svgRound(t[0])} ${z.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}Je=new WeakMap,nu=new WeakMap,ru=new WeakMap,Os=new WeakMap,zi=new WeakMap,Wi=new WeakMap,xh=new WeakMap,Th=new WeakMap,Ho=new WeakMap,ke=new WeakSet,sn=function(t=n(this,Ho)){const s=n(this,ru)+t/2*n(this,xh);return n(this,Th)%180===0?[s/n(this,zi),s/n(this,Wi)]:[s/n(this,Wi),s/n(this,zi)]},pb=function(){const[t,s,i,r]=n(this,Je),[a,o]=b(this,ke,sn).call(this,0);return[t+a,s+o,i-2*a,r-2*o]},gb=function(){const t=g(this,Je,pa.slice());for(const{line:r}of n(this,Os)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)H.pointBoundingBox(r[l],r[l+1],t);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;l+=6){const[c,u,f,p,m,v]=r.subarray(l,l+6);H.bezierBoundingBox(a,o,c,u,f,p,m,v,t),a=m,o=v}}const[s,i]=b(this,ke,sn).call(this);t[0]=Ht(t[0]-s,0,1),t[1]=Ht(t[1]-i,0,1),t[2]=Ht(t[2]+s,0,1),t[3]=Ht(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]},mb=function(t){const[s,i]=b(this,ke,sn).call(this);g(this,Ho,t);const[r,a]=b(this,ke,sn).call(this),[o,l]=[r-s,a-i],h=n(this,Je);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class fp extends ub{constructor(e){super(),this._viewParameters=e,super.updateProperties({fill:"none",stroke:St._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){e==="stroke-width"&&(t??(t=this["stroke-width"]),t*=this._viewParameters.realScale),super.updateSVGProperty(e,t)}clone(){const e=new fp(this._viewParameters);return e.updateAll(this),e}}var Kf,vb;const rl=class rl extends Ef{constructor(t){super({...t,name:"inkEditor"});y(this,Kf);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,s){St.initialize(t,s),this._defaultDrawingOptions=new fp(s.viewParameters)}static getDefaultDrawingOptions(t){const s=this._defaultDrawingOptions.clone();return s.updateProperties(t),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return st(this,"typesMap",new Map([[at.INK_THICKNESS,"stroke-width"],[at.INK_COLOR,"stroke"],[at.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,s,i,r,a){return new T0(t,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,s,i,r,a,o){return gu.deserialize(t,s,i,r,a,o)}static async deserialize(t,s,i){let r=null;if(t instanceof am){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:u,opacity:f,borderStyle:{rawWidth:p},popupRef:m,richText:v,contentsObj:A,creationDate:w,modificationDate:E},parent:{page:{pageNumber:S}}}=t;r=t={annotationType:nt.INK,color:Array.from(u),thickness:p,opacity:f,paths:{points:o},boxes:null,pageIndex:S-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:m,richText:v,comment:(A==null?void 0:A.str)||null,creationDate:w,modificationDate:E}}const a=await super.deserialize(t,s,i);return a._initialData=r,t.comment&&a.setCommentData(t),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new yf(this)),[["colorPicker",this._colorPicker]]}get colorType(){return at.INK_COLOR}get colorAndOpacityType(){return at.INK_COLOR_AND_OPACITY}get opacityType(){return at.INK_OPACITY}updateParams(t,s){if(t===at.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(s.color,s.opacity);return}super.updateParams(t,s)}static updateDefaultParams(t,s){if(t===at.INK_COLOR_AND_OPACITY){super.updateDefaultParams(at.INK_COLOR,s.color),super.updateDefaultParams(at.INK_OPACITY,s.opacity);return}super.updateDefaultParams(t,s)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:s,opacity:i}){this._drawingOptions=rl.getDefaultDrawingOptions({stroke:H.makeHexColor(...t),"stroke-width":s,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:r,"stroke-opacity":a,"stroke-width":o}}=this,l=Object.assign(super.serialize(t),{color:St._colorManager.convert(r),opacity:a,thickness:o,paths:{lines:s,points:i}});return this.addComment(l),t?(l.isCopy=!0,l):this.annotationElementId&&!b(this,Kf,vb).call(this,l)?null:(l.id=this.annotationElementId,l)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:s,popup:this.comment}),null}};Kf=new WeakSet,vb=function(t){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((o,l)=>o!==s[l])||t.thickness!==i||t.opacity!==r||t.pageIndex!==a},P(rl,"_type","ink"),P(rl,"_editorType",nt.INK),P(rl,"_defaultDrawingOptions",null);let Fg=rl;class Ng extends gu{toSVGPath(){let e=super.toSVGPath();return e.endsWith("Z")||(e+="Z"),e}}lt(5213);const Su=8,_h=3;var $o,xt,Bg,mi,yb,bb,Ug,af,Ab,wb,Eb,Hg,$g,Sb;class Ji{static extractContoursFromText(e,{fontFamily:t,fontStyle:s,fontWeight:i},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const u=200,f=c.font=`${s} ${i} ${u}px ${t}`,{actualBoundingBoxLeft:p,actualBoundingBoxRight:m,actualBoundingBoxAscent:v,actualBoundingBoxDescent:A,fontBoundingBoxAscent:w,fontBoundingBoxDescent:E,width:S}=c.measureText(e),T=1.5,x=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||0,S)*T),C=Math.ceil(Math.max(Math.abs(v)+Math.abs(A)||u,Math.abs(w)+Math.abs(E)||u)*T);h=new OffscreenCanvas(x,C),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=f,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,x,C),c.fillStyle="black",c.fillText(e,x*(T-1)/2,C*(3-T)/2);const I=b(this,xt,Hg).call(this,c.getImageData(0,0,x,C).data),O=b(this,xt,Eb).call(this,I),M=b(this,xt,$g).call(this,O),R=b(this,xt,Ug).call(this,I,x,C,M);return this.processDrawnLines({lines:{curves:R,width:x,height:C},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(e,t,s,i,r){const[a,o,l]=b(this,xt,Sb).call(this,e),[h,c]=b(this,xt,wb).call(this,a,o,l,Math.hypot(o,l)*n(this,$o).sigmaSFactor,n(this,$o).sigmaR,n(this,$o).kernelSize),u=b(this,xt,$g).call(this,c),f=b(this,xt,Ug).call(this,h,o,l,u);return this.processDrawnLines({lines:{curves:f,width:o,height:l},pageWidth:t,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([t,s]=[s,t]);const{curves:l,width:h,height:c}=e,u=e.thickness??0,f=[],p=Math.min(t/h,s/c),m=p/t,v=p/s,A=[];for(const{points:E}of l){const S=a?b(this,xt,Ab).call(this,E):E;if(!S)continue;A.push(S);const T=S.length,x=new Float32Array(T),C=new Float32Array(3*(T===2?2:T-2));if(f.push({line:C,points:x}),T===2){x[0]=S[0]*m,x[1]=S[1]*v,C.set([NaN,NaN,NaN,NaN,x[0],x[1]],0);continue}let[I,O,M,R]=S;I*=m,O*=v,M*=m,R*=v,x.set([I,O,M,R],0),C.set([NaN,NaN,NaN,NaN,I,O],0);for(let D=4;D<T;D+=2){const j=x[D]=S[D]*m,F=x[D+1]=S[D+1]*v;C.set(z.createBezierPoints(I,O,M,R,j,F),(D-2)*3),[I,O,M,R]=[M,R,j,F]}}if(f.length===0)return null;const w=o?new Ng:new gu;return w.build(f,t,s,1,i,o?0:u,r),{outline:w,newCurves:A,areContours:o,thickness:u,width:h,height:c}}static async compressSignature({outlines:e,areContours:t,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const E of e){l+=E.length;for(let S=2,T=E.length;S<T;S++){const x=E[S]-E[S-2];a=Math.min(a,x),o=Math.max(o,x)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=e.length,u=Su+_h*c,f=new Uint32Array(u);let p=0;f[p++]=u*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,f[p++]=0,f[p++]=i,f[p++]=r,f[p++]=t?0:1,f[p++]=Math.max(0,Math.floor(s??0)),f[p++]=c,f[p++]=h.BYTES_PER_ELEMENT;for(const E of e)f[p++]=E.length-2,f[p++]=E[0],f[p++]=E[1];const m=new CompressionStream("deflate-raw"),v=m.writable.getWriter();await v.ready,v.write(f);const A=h.prototype.constructor;for(const E of e){const S=new A(E.length-2);for(let T=2,x=E.length;T<x;T++)S[T-2]=E[T]-E[T-2];v.write(S)}return v.close(),(await new Response(m.readable).bytes()).toBase64()}static async decompressSignature(e){try{const t=Uint8Array.fromBase64(e),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(t).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const S of s)a||(a=new Uint8Array(new Uint32Array(S.buffer,0,4)[0])),a.set(S,o),o+=S.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],u=l[3],f=l[4]===0,p=l[5],m=l[6],v=l[7],A=[],w=(Su+_h*m)*Uint32Array.BYTES_PER_ELEMENT;let E;switch(v){case Int8Array.BYTES_PER_ELEMENT:E=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:E=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:E=new Int32Array(a.buffer,w);break}o=0;for(let S=0;S<m;S++){const T=l[_h*S+Su],x=new Float32Array(T+2);A.push(x);for(let C=0;C<_h-1;C++)x[C]=l[_h*S+Su+C+1];for(let C=0;C<T;C++)x[C+2]=x[C]+E[o++]}return{areContours:f,thickness:p,outlines:A,width:c,height:u}}catch(t){return it(`decompressSignature: ${t}`),null}}}$o=new WeakMap,xt=new WeakSet,Bg=function(e,t,s,i){return s-=e,i-=t,s===0?i>0?0:4:s===1?i+6:2-i},mi=new WeakMap,yb=function(e,t,s,i,r,a,o){const l=b(this,xt,Bg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,u=n(this,mi)[2*c],f=n(this,mi)[2*c+1];if(e[(s+u)*t+(i+f)]!==0)return c}return-1},bb=function(e,t,s,i,r,a,o){const l=b(this,xt,Bg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,u=n(this,mi)[2*c],f=n(this,mi)[2*c+1];if(e[(s+u)*t+(i+f)]!==0)return c}return-1},Ug=function(e,t,s,i){const r=e.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=e[c]<=i?1:0;for(let c=1;c<s-1;c++)a[c*t]=a[c*t+t-1]=0;for(let c=0;c<t;c++)a[c]=a[t*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let u=1;u<t-1;u++){const f=c*t+u,p=a[f];if(p===0)continue;let m=c,v=u;if(p===1&&a[f-1]===0)o+=1,v-=1;else if(p>=1&&a[f+1]===0)o+=1,v+=1,p>1&&(l=p);else{p!==1&&(l=Math.abs(p));continue}const A=[u,c],w=v===u+1,E={isHole:w,points:A,id:o,parent:0};h.push(E);let S;for(const D of h)if(D.id===l){S=D;break}S?S.isHole?E.parent=w?S.parent:l:E.parent=w?l:S.parent:E.parent=w?l:0;const T=b(this,xt,yb).call(this,a,t,c,u,m,v,0);if(T===-1){a[f]=-o,a[f]!==1&&(l=Math.abs(a[f]));continue}let x=n(this,mi)[2*T],C=n(this,mi)[2*T+1];const I=c+x,O=u+C;m=I,v=O;let M=c,R=u;for(;;){const D=b(this,xt,bb).call(this,a,t,M,R,m,v,1);x=n(this,mi)[2*D],C=n(this,mi)[2*D+1];const j=M+x,F=R+C;A.push(F,j);const U=M*t+R;if(a[U+1]===0?a[U]=-o:a[U]===1&&(a[U]=o),j===c&&F===u&&M===I&&R===O){a[f]!==1&&(l=Math.abs(a[f]));break}else m=M,v=R,M=j,R=F}}}return h},af=function(e,t,s,i){if(s-t<=4){for(let I=t;I<s-2;I+=2)i.push(e[I],e[I+1]);return}const r=e[t],a=e[t+1],o=e[s-4]-r,l=e[s-3]-a,h=Math.hypot(o,l),c=o/h,u=l/h,f=c*a-u*r,p=l/o,m=1/h,v=Math.atan(p),A=Math.cos(v),w=Math.sin(v),E=m*(Math.abs(A)+Math.abs(w)),S=m*(1-E+E**2),T=Math.max(Math.atan(Math.abs(w+A)*S),Math.atan(Math.abs(w-A)*S));let x=0,C=t;for(let I=t+2;I<s-2;I+=2){const O=Math.abs(f-c*e[I+1]+u*e[I]);O>x&&(C=I,x=O)}x>(h*T)**2?(b(this,xt,af).call(this,e,t,C+2,i),b(this,xt,af).call(this,e,C,s,i)):i.push(r,a)},Ab=function(e){const t=[],s=e.length;return b(this,xt,af).call(this,e,0,s,t),t.push(e[s-2],e[s-1]),t.length<=4?null:t},wb=function(e,t,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,h=a>>1;for(let v=0;v<a;v++){const A=(v-h)**2;for(let w=0;w<a;w++)o[v*a+w]=Math.exp((A+(w-h)**2)/l)}const c=new Float32Array(256),u=-2*r**2;for(let v=0;v<256;v++)c[v]=Math.exp(v**2/u);const f=e.length,p=new Uint8Array(f),m=new Uint32Array(256);for(let v=0;v<s;v++)for(let A=0;A<t;A++){const w=v*t+A,E=e[w];let S=0,T=0;for(let C=0;C<a;C++){const I=v+C-h;if(!(I<0||I>=s))for(let O=0;O<a;O++){const M=A+O-h;if(M<0||M>=t)continue;const R=e[I*t+M],D=o[C*a+O]*c[Math.abs(R-E)];S+=R*D,T+=D}}const x=p[w]=Math.round(S/T);m[x]++}return[p,m]},Eb=function(e){const t=new Uint32Array(256);for(const s of e)t[s]++;return t},Hg=function(e){const t=e.length,s=new Uint8ClampedArray(t>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=e[o<<2];i=Math.max(i,h),r=Math.min(r,h)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},$g=function(e){let t,s=-1/0,i=-1/0;const r=e.findIndex(l=>l!==0);let a=r,o=r;for(t=r;t<256;t++){const l=e[t];l>s&&(t-a>i&&(i=t-a,o=t-1),s=l,a=t)}for(t=o-1;t>=0&&!(e[t]>e[t+1]);t--);return t},Sb=function(e){const t=e,{width:s,height:i}=e,{maxDim:r}=n(this,$o);let a=s,o=i;if(s>r||i>r){let f=s,p=i,m=Math.log2(Math.max(s,i)/r);const v=Math.floor(m);m=m===v?v-1:v;for(let w=0;w<m;w++){a=Math.ceil(f/2),o=Math.ceil(p/2);const E=new OffscreenCanvas(a,o);E.getContext("2d").drawImage(e,0,0,f,p,0,0,a,o),f=a,p=o,e!==t&&e.close(),e=E.transferToImageBitmap()}const A=Math.min(r/a,r/o);a=Math.round(a*A),o=Math.round(o*A)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(e,0,0,e.width,e.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[b(this,xt,Hg).call(this,c),a,o]},y(Ji,xt),y(Ji,$o,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),y(Ji,mi,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class om extends ub{constructor(){super(),super.updateProperties({fill:St._defaultLineColor,"stroke-width":0})}clone(){const e=new om;return e.updateAll(this),e}}class lm extends fp{constructor(e){super(e),super.updateProperties({stroke:St._defaultLineColor,"stroke-width":1})}clone(){const e=new lm(this._viewParameters);return e.updateAll(this),e}}var jr,Vi,Gr,jo;const fs=class fs extends Ef{constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"});y(this,jr,!1);y(this,Vi,null);y(this,Gr,null);y(this,jo,null);this._willKeepAspectRatio=!0,g(this,Gr,t.signatureData||null),g(this,Vi,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,s){St.initialize(t,s),this._defaultDrawingOptions=new om,this._defaultDrawnSignatureOptions=new lm(s.viewParameters)}static getDefaultDrawingOptions(t){const s=this._defaultDrawingOptions.clone();return s.updateProperties(t),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return st(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,Vi)}}static computeTelemetryFinalData(t){const s=t.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,Gr)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,Gr),{rawDims:{pageWidth:u,pageHeight:f},rotation:p}=this.parent.viewport,m=Ji.processDrawnLines({lines:r,pageWidth:u,pageHeight:f,rotation:p,innerMargin:fs._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(m,c,l,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:n(this,Vi)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,s)),this.div}setUuid(t){g(this,jo,t),this.addEditToolbar()}getUuid(){return n(this,jo)}get description(){return n(this,Vi)}set description(t){g(this,Vi,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:s,thickness:i,width:r,height:a}=n(this,Gr),o=Math.max(r,a),l=Ji.processDrawnLines({lines:{curves:t.map(h=>({points:h})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,s,i,r){const{x:a,y:o}=this,{outline:l}=g(this,Gr,t);g(this,jr,l instanceof Ng),this.description=i;let h;n(this,jr)?h=fs.getDefaultDrawingOptions():(h=fs._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[,c]=this.pageDimensions;let u=s/c;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Ji.process(t,s,i,r,fs._INNER_MARGIN)}getFromText(t,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return Ji.extractContoursFromText(t,s,i,r,a,fs._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return Ji.processDrawnLines({lines:t,pageWidth:s,pageHeight:i,rotation:r,innerMargin:fs._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:s}){t?this._drawingOptions=fs.getDefaultDrawingOptions():(this._drawingOptions=fs._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:s,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{isSignature:!0,areContours:n(this,jr),color:[0,0,0],thickness:n(this,jr)?0:r});return this.addComment(a),t?(a.paths={lines:s,points:i},a.uuid=n(this,jo),a.isCopy=!0):a.lines=s,n(this,Vi)&&(a.accessibilityData={type:"Figure",alt:n(this,Vi)}),a}static deserializeDraw(t,s,i,r,a,o){return o.areContours?Ng.deserialize(t,s,i,r,a,o):gu.deserialize(t,s,i,r,a,o)}static async deserialize(t,s,i){var a;const r=await super.deserialize(t,s,i);return g(r,jr,t.areContours),r.description=((a=t.accessibilityData)==null?void 0:a.alt)||"",g(r,jo,t.uuid),r}};jr=new WeakMap,Vi=new WeakMap,Gr=new WeakMap,jo=new WeakMap,P(fs,"_type","signature"),P(fs,"_editorType",nt.SIGNATURE),P(fs,"_defaultDrawingOptions",null);let jg=fs;var zt,Ee,_r,Bn,zr,Ch,Un,Go,Xi,Rs,Ih,vt,cc,dc,of,lf,hf,_g,cf,xb;class Gg extends St{constructor(t){super({...t,name:"stampEditor"});y(this,vt);y(this,zt,null);y(this,Ee,null);y(this,_r,null);y(this,Bn,null);y(this,zr,null);y(this,Ch,"");y(this,Un,null);y(this,Go,!1);y(this,Xi,null);y(this,Rs,!1);y(this,Ih,!1);g(this,Bn,t.bitmapUrl),g(this,zr,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,s){St.initialize(t,s)}static isHandlingMimeForPasting(t){return mf.includes(t)}static paste(t,s){s.pasteEditor({mode:nt.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!((t=this.altTextData)!=null&&t.altText)}}static computeTelemetryFinalData(t){const s=t.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(t=null,s=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=t||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var t;n(this,Ee)&&(g(this,zt,null),this._uiManager.imageManager.deleteId(n(this,Ee)),(t=n(this,Un))==null||t.remove(),g(this,Un,null),n(this,Xi)&&(clearTimeout(n(this,Xi)),g(this,Xi,null))),super.remove()}rebuild(){if(!this.parent){n(this,Ee)&&b(this,vt,of).call(this);return}super.rebuild(),this.div!==null&&(n(this,Ee)&&n(this,Un)===null&&b(this,vt,of).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(n(this,_r)||n(this,zt)||n(this,Bn)||n(this,zr)||n(this,Ee)||n(this,Go))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,s;return this._isCopy&&(t=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,Go)||(n(this,zt)?b(this,vt,lf).call(this):b(this,vt,of).call(this)),this._isCopy&&this._moveAfterPaste(t,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(t,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(g(this,Ee,i),r&&g(this,zt,r),g(this,Go,!1),b(this,vt,lf).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Xi)!==null&&clearTimeout(n(this,Xi)),g(this,Xi,setTimeout(()=>{g(this,Xi,null),b(this,vt,_g).call(this)},200))}copyCanvas(t,s,i=!1){t||(t=224);const{width:r,height:a}=n(this,zt),o=new Ei;let l=n(this,zt),h=r,c=a,u=null;if(s){if(r>s||a>s){const I=Math.min(s/r,s/a);h=Math.floor(r*I),c=Math.floor(a*I)}u=document.createElement("canvas");const p=u.width=Math.ceil(h*o.sx),m=u.height=Math.ceil(c*o.sy);n(this,Rs)||(l=b(this,vt,hf).call(this,p,m));const v=u.getContext("2d");v.filter=this._uiManager.hcmFilter;let A="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":Gb.isDarkMode&&(A="#8f8f9d",w="#42414d");const E=15,S=E*o.sx,T=E*o.sy,x=new OffscreenCanvas(S*2,T*2),C=x.getContext("2d");C.fillStyle=A,C.fillRect(0,0,S*2,T*2),C.fillStyle=w,C.fillRect(0,0,S,T),C.fillRect(S,T,S,T),v.fillStyle=v.createPattern(x,"repeat"),v.fillRect(0,0,p,m),v.drawImage(l,0,0,l.width,l.height,0,0,p,m)}let f=null;if(i){let p,m;if(o.symmetric&&l.width<t&&l.height<t)p=l.width,m=l.height;else if(l=n(this,zt),r>t||a>t){const w=Math.min(t/r,t/a);p=Math.floor(r*w),m=Math.floor(a*w),n(this,Rs)||(l=b(this,vt,hf).call(this,p,m))}const A=new OffscreenCanvas(p,m).getContext("2d",{willReadFrequently:!0});A.drawImage(l,0,0,l.width,l.height,0,0,p,m),f={width:p,height:m,data:A.getImageData(0,0,p,m).data}}return{canvas:u,width:h,height:c,imageData:f}}static async deserialize(t,s,i){var A;let r=null,a=!1;if(t instanceof Uy){const{data:{rect:w,rotation:E,id:S,structParent:T,popupRef:x,richText:C,contentsObj:I,creationDate:O,modificationDate:M},container:R,parent:{page:{pageNumber:D}},canvas:j}=t;let F,U;j?(delete t.canvas,{id:F,bitmap:U}=i.imageManager.getFromCanvas(R.id,j),j.remove()):(a=!0,t._hasNoCanvas=!0);const Z=((A=await s._structTree.getAriaAttributes(`${il}${S}`))==null?void 0:A.get("aria-label"))||"";r=t={annotationType:nt.STAMP,bitmapId:F,bitmap:U,pageIndex:D-1,rect:w.slice(0),rotation:E,annotationElementId:S,id:S,deleted:!1,accessibilityData:{decorative:!1,altText:Z},isSvg:!1,structParent:T,popupRef:x,richText:C,comment:(I==null?void 0:I.str)||null,creationDate:O,modificationDate:M}}const o=await super.deserialize(t,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:u,isSvg:f,accessibilityData:p}=t;a?(i.addMissingCanvas(t.id,o),g(o,Go,!0)):u&&i.imageManager.isValidId(u)?(g(o,Ee,u),h&&g(o,zt,h)):g(o,Bn,c),g(o,Rs,f);const[m,v]=o.pageDimensions;return o.width=(l[2]-l[0])/m,o.height=(l[3]-l[1])/v,p&&(o.altTextData=p),o._initialData=r,t.comment&&o.setCommentData(t),g(o,Ih,!!r),o}serialize(t=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:n(this,Ee),isSvg:n(this,Rs)});if(this.addComment(i),t)return i.bitmapUrl=b(this,vt,cf).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,vt,xb).call(this,i);return l.isSame?null:(l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,Rs)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,Ee)))s.stamps.set(n(this,Ee),{area:o,serialized:i}),i.bitmap=b(this,vt,cf).call(this,!1);else if(n(this,Rs)){const l=s.stamps.get(n(this,Ee));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,vt,cf).call(this,!1))}return i}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}zt=new WeakMap,Ee=new WeakMap,_r=new WeakMap,Bn=new WeakMap,zr=new WeakMap,Ch=new WeakMap,Un=new WeakMap,Go=new WeakMap,Xi=new WeakMap,Rs=new WeakMap,Ih=new WeakMap,vt=new WeakSet,cc=function(t,s=!1){if(!t){this.remove();return}g(this,zt,t.bitmap),s||(g(this,Ee,t.id),g(this,Rs,t.isSvg)),t.file&&g(this,Ch,t.file.name),b(this,vt,lf).call(this)},dc=function(){if(g(this,_r,null),this._uiManager.enableWaiting(!1),!!n(this,Un)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,zt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,zt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},of=function(){if(n(this,Ee)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Ee)).then(i=>b(this,vt,cc).call(this,i,!0)).finally(()=>b(this,vt,dc).call(this));return}if(n(this,Bn)){const i=n(this,Bn);g(this,Bn,null),this._uiManager.enableWaiting(!0),g(this,_r,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,vt,cc).call(this,r)).finally(()=>b(this,vt,dc).call(this)));return}if(n(this,zr)){const i=n(this,zr);g(this,zr,null),this._uiManager.enableWaiting(!0),g(this,_r,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,vt,cc).call(this,r)).finally(()=>b(this,vt,dc).call(this)));return}const t=document.createElement("input");t.type="file",t.accept=mf.join(",");const s=this._uiManager._signal;g(this,_r,new Promise(i=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,vt,cc).call(this,r)}i()},{signal:s}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,vt,dc).call(this))),t.click()},lf=function(){var h;const{div:t}=this;let{width:s,height:i}=n(this,zt);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const c=Math.min(o*r/s,o*a/i);s*=c,i*=c}this._uiManager.enableWaiting(!1);const l=g(this,Un,document.createElement("canvas"));l.setAttribute("role","img"),this.addContainer(l),this.width=s/r,this.height=i/a,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),b(this,vt,_g).call(this),n(this,Ih)||(this.parent.addUndoableEditor(this),g(this,Ih,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,Ch)&&this.div.setAttribute("aria-description",n(this,Ch)),this.annotationElementId||this._uiManager.a11yAlert(St._l10nAlert.stamp)},hf=function(t,s){const{width:i,height:r}=n(this,zt);let a=i,o=r,l=n(this,zt);for(;a>2*t||o>2*s;){const h=a,c=o;a>2*t&&(a=Math.ceil(a/2)),o>2*s&&(o=Math.ceil(o/2));const u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=u.transferToImageBitmap()}return l},_g=function(){const[t,s]=this.parentDimensions,{width:i,height:r}=this,a=new Ei,o=Math.ceil(i*t*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,Un);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,Rs)?n(this,zt):b(this,vt,hf).call(this,o,l),u=h.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(c,0,0,c.width,c.height,0,0,o,l)},cf=function(t){if(t){if(n(this,Rs)){const r=this._uiManager.imageManager.getSvgUrl(n(this,Ee));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,zt),s.getContext("2d").drawImage(n(this,zt),0,0),s.toDataURL()}if(n(this,Rs)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Yn.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Yn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,zt),0,0,n(this,zt).width,n(this,zt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,zt))},xb=function(t){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=t.pageIndex===s,a=(((o=t.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},P(Gg,"_type","stamp"),P(Gg,"_editorType",nt.STAMP);var _o,Ph,Wr,Vr,Hn,hs,Xr,Mh,Oh,vi,$n,Se,jn,Yr,Rh,V,Kr,Nt,zg,Tb,Ti,Wg,Vg,df;const ii=class ii{constructor({uiManager:e,pageIndex:t,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){y(this,Nt);y(this,_o);y(this,Ph,!1);y(this,Wr,null);y(this,Vr,null);y(this,Hn,null);y(this,hs,new Map);y(this,Xr,!1);y(this,Mh,!1);y(this,Oh,!1);y(this,vi,null);y(this,$n,null);y(this,Se,null);y(this,jn,null);y(this,Yr,null);y(this,Rh,-1);y(this,V);const u=[...n(ii,Kr).values()];if(!ii._initialized){ii._initialized=!0;for(const f of u)f.initialize(c,e)}e.registerEditorTypes(u),g(this,V,e),this.pageIndex=t,this.div=s,g(this,_o,r),g(this,Wr,a),this.viewport=h,g(this,Se,l),this.drawLayer=o,this._structTree=i,n(this,V).addLayer(this)}get isEmpty(){return n(this,hs).size===0}get isInvisible(){return this.isEmpty&&n(this,V).getMode()===nt.NONE}updateToolbar(e){n(this,V).updateToolbar(e)}updateMode(e=n(this,V).getMode()){switch(b(this,Nt,df).call(this),e){case nt.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case nt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case nt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;if(t.toggle("nonEditing",!1),e===nt.POPUP)t.toggle("commentEditing",!0);else{t.toggle("commentEditing",!1);for(const s of n(ii,Kr).values())t.toggle(`${s._type}Editing`,e===s._editorType)}this.div.hidden=!1}hasTextLayer(e){var t;return e===((t=n(this,Se))==null?void 0:t.div)}setEditingState(e){n(this,V).setEditingState(e)}addCommands(e){n(this,V).addCommands(e)}cleanUndoStack(e){n(this,V).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){var t;(t=n(this,Wr))==null||t.togglePointerEvents(e)}async enable(){var s;g(this,Oh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(s=n(this,Yr))==null||s.abort(),g(this,Yr,null);const e=new Set;for(const i of n(this,Nt,zg))i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,V).removeChangedExistingAnnotation(i),e.add(i.annotationElementId));const t=n(this,Wr);if(t)for(const i of t.getEditableAnnotations()){if(i.hide(),n(this,V).isDeletedAnnotationElement(i.data.id)||e.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}g(this,Oh,!1),n(this,V)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var i;if(g(this,Mh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),n(this,Se)&&!n(this,Yr)){g(this,Yr,new AbortController);const r=n(this,V).combinedSignal(n(this,Yr));n(this,Se).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,u=n(this,Rh);if(c-u>500){g(this,Rh,c);return}g(this,Rh,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const p=document.elementsFromPoint(l,h);if(f.toggle("getElements",!1),!this.div.contains(p[0]))return;let m;const v=new RegExp(`^${vc}[0-9]+$`);for(const w of p)if(v.test(w.id)){m=w.id;break}if(!m)return;const A=n(this,hs).get(m);(A==null?void 0:A.annotationElementId)===null&&(Wt(a),A.dblclick(a))},{signal:r,capture:!0})}const e=n(this,Wr),t=[];if(e){const r=new Map,a=new Map;for(const o of n(this,Nt,zg)){if(o.disableEditing(),!o.annotationElementId){t.push(o);continue}if(o.serialize()!==null){r.set(o.annotationElementId,o);continue}else a.set(o.annotationElementId,o);(i=this.getEditableAnnotation(o.annotationElementId))==null||i.show(),o.remove()}for(const o of e.getEditableAnnotations()){const{id:l}=o.data;if(n(this,V).isDeletedAnnotationElement(l)){o.updateEdited({deleted:!0});continue}let h=a.get(l);if(h){h.resetAnnotationElement(o),h.show(!1),o.show();continue}h=r.get(l),h&&(n(this,V).addChangedExistingAnnotation(h),h.renderAnnotationElement(o)&&h.show(!1)),o.show()}}b(this,Nt,df).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(ii,Kr).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e==null||e.updateFakeAnnotations(t),g(this,Mh,!1)}getEditableAnnotation(e){var t;return((t=n(this,Wr))==null?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){n(this,V).getActive()!==e&&n(this,V).setActiveEditor(e)}enableTextSelection(){var e;if(this.div.tabIndex=-1,(e=n(this,Se))!=null&&e.div&&!n(this,jn)){g(this,jn,new AbortController);const t=n(this,V).combinedSignal(n(this,jn));n(this,Se).div.addEventListener("pointerdown",b(this,Nt,Tb).bind(this),{signal:t}),n(this,Se).div.classList.add("highlighting")}}disableTextSelection(){var e;this.div.tabIndex=0,(e=n(this,Se))!=null&&e.div&&n(this,jn)&&(n(this,jn).abort(),g(this,jn,null),n(this,Se).div.classList.remove("highlighting"))}enableClick(){if(n(this,Vr))return;g(this,Vr,new AbortController);const e=n(this,V).combinedSignal(n(this,Vr));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){var e;(e=n(this,Vr))==null||e.abort(),g(this,Vr,null)}attach(e){n(this,hs).set(e.id,e);const{annotationElementId:t}=e;t&&n(this,V).isDeletedAnnotationElement(t)&&n(this,V).removeDeletedAnnotationElement(e)}detach(e){var t;n(this,hs).delete(e.id),(t=n(this,_o))==null||t.removePointerInTextLayer(e.contentDiv),!n(this,Mh)&&e.annotationElementId&&n(this,V).addDeletedAnnotationElement(e)}remove(e){this.detach(e),n(this,V).removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){var t;e.parent!==this&&(e.parent&&e.annotationElementId&&(n(this,V).addDeletedAnnotationElement(e),St.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),(t=e.parent)==null||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(!(e.parent===this&&e.isAttachedToDOM)){if(this.changeParent(e),n(this,V).addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!n(this,Oh)),n(this,V).addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){var s;if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!n(this,Hn)&&(e._focusEventsAllowed=!1,g(this,Hn,setTimeout(()=>{g(this,Hn,null),e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:n(this,V)._signal}),t.focus())},0))),e._structTreeParentId=(s=n(this,_o))==null?void 0:s.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||(e.parent=this),e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){const t=()=>e._uiManager.rebuild(e),s=()=>{e.remove()};this.addCommands({cmd:t,undo:s,mustExec:!1})}getEditorByUID(e){for(const t of n(this,hs).values())if(t.uid===e)return t;return null}combinedSignal(e){return n(this,V).combinedSignal(e)}canCreateNewEmptyEditor(){var e;return(e=n(this,Nt,Ti))==null?void 0:e.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e),await n(this,V).updateMode(e.mode);const{offsetX:s,offsetY:i}=b(this,Nt,Vg).call(this),r=n(this,V).getId(),a=b(this,Nt,Wg).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,V),isCentered:!0,...t});a&&this.add(a)}async deserialize(e){var t;return await((t=n(ii,Kr).get(e.annotationType??e.annotationEditorType))==null?void 0:t.deserialize(e,this,n(this,V)))||null}createAndAddNewEditor(e,t,s={}){const i=n(this,V).getId(),r=b(this,Nt,Wg).call(this,{parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:n(this,V),isCentered:t,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(e={}){this.createAndAddNewEditor(b(this,Nt,Vg).call(this),!0,e)}setSelected(e){n(this,V).setSelected(e)}toggleSelected(e){n(this,V).toggleSelected(e)}unselect(e){n(this,V).unselect(e)}pointerup(e){var i;const{isMac:t}=It.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div||!n(this,Xr)||(g(this,Xr,!1),(i=n(this,Nt,Ti))!=null&&i.isDrawer&&n(this,Nt,Ti).supportMultipleDrawings))return;if(!n(this,Ph)){g(this,Ph,!0);return}const s=n(this,V).getMode();if(s===nt.STAMP||s===nt.POPUP||s===nt.SIGNATURE){n(this,V).unselectAll();return}this.createAndAddNewEditor(e,!1)}pointerdown(e){var i;if(n(this,V).getMode()===nt.HIGHLIGHT&&this.enableTextSelection(),n(this,Xr)){g(this,Xr,!1);return}const{isMac:t}=It.platform;if(e.button!==0||e.ctrlKey&&t||e.target!==this.div)return;if(g(this,Xr,!0),(i=n(this,Nt,Ti))!=null&&i.isDrawer){this.startDrawingSession(e);return}const s=n(this,V).getActive();g(this,Ph,!s||s.isEmpty())}startDrawingSession(e){if(this.div.focus({preventScroll:!0}),n(this,vi)){n(this,Nt,Ti).startDrawing(this,n(this,V),!1,e);return}n(this,V).setCurrentDrawingSession(this),g(this,vi,new AbortController);const t=n(this,V).combinedSignal(n(this,vi));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(g(this,$n,null),this.commitOrRemove())},{signal:t}),n(this,Nt,Ti).startDrawing(this,n(this,V),!1,e)}pause(e){if(e){const{activeElement:t}=document;this.div.contains(t)&&g(this,$n,t);return}n(this,$n)&&setTimeout(()=>{var t;(t=n(this,$n))==null||t.focus(),g(this,$n,null)},0)}endDrawingSession(e=!1){return n(this,vi)?(n(this,V).setCurrentDrawingSession(null),n(this,vi).abort(),g(this,vi,null),g(this,$n,null),n(this,Nt,Ti).endDrawing(e)):null}findNewParent(e,t,s){const i=n(this,V).findParent(t,s);return i===null||i===this?!1:(i.changeParent(e),!0)}commitOrRemove(){return n(this,vi)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,vi)&&n(this,Nt,Ti).onScaleChangingWhenDrawing(this)}destroy(){var e,t;this.commitOrRemove(),((e=n(this,V).getActive())==null?void 0:e.parent)===this&&(n(this,V).commitOrRemove(),n(this,V).setActiveEditor(null)),n(this,Hn)&&(clearTimeout(n(this,Hn)),g(this,Hn,null));for(const s of n(this,hs).values())(t=n(this,_o))==null||t.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,hs).clear(),n(this,V).removeLayer(this)}async render({viewport:e}){this.viewport=e,ta(this.div,e);for(const t of n(this,V).getEditors(this.pageIndex))this.add(t),t.rebuild();await n(this,V).findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:e}){n(this,V).commitOrRemove(),b(this,Nt,df).call(this);const t=this.viewport.rotation,s=e.rotation;if(this.viewport=e,ta(this.div,{rotation:s}),t!==s)for(const i of n(this,hs).values())i.rotate(s)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return n(this,V).viewParameters.realScale}};_o=new WeakMap,Ph=new WeakMap,Wr=new WeakMap,Vr=new WeakMap,Hn=new WeakMap,hs=new WeakMap,Xr=new WeakMap,Mh=new WeakMap,Oh=new WeakMap,vi=new WeakMap,$n=new WeakMap,Se=new WeakMap,jn=new WeakMap,Yr=new WeakMap,Rh=new WeakMap,V=new WeakMap,Kr=new WeakMap,Nt=new WeakSet,zg=function(){return n(this,hs).size!==0?n(this,hs).values():n(this,V).getEditors(this.pageIndex)},Tb=function(e){n(this,V).unselectAll();const{target:t}=e;if(t===n(this,Se).div||(t.getAttribute("role")==="img"||t.classList.contains("endOfContent")||t.classList.contains("textLayerImages")||t.classList.contains("textLayerImagePlaceholder"))&&n(this,Se).div.contains(t)){const{isMac:s}=It.platform;if(e.button!==0||e.ctrlKey&&s)return;n(this,V).showAllEditors("highlight",!0,!0),n(this,Se).div.classList.add("free"),this.toggleDrawing(),wf.startHighlighting(this,n(this,V).direction==="ltr",{target:n(this,Se).div,x:e.x,y:e.y}),n(this,Se).div.addEventListener("pointerup",()=>{n(this,Se).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,V)._signal}),e.preventDefault()}},Ti=function(){return n(ii,Kr).get(n(this,V).getMode())},Wg=function(e){const t=n(this,Nt,Ti);return t?new t.prototype.constructor(e):null},Vg=function(){const{x:e,y:t,width:s,height:i}=this.boundingClientRect,r=Math.max(0,e),a=Math.max(0,t),o=Math.min(window.innerWidth,e+s),l=Math.min(window.innerHeight,t+i),h=(r+o)/2-e,c=(a+l)/2-t,[u,f]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:u,offsetY:f}},df=function(){for(const e of n(this,hs).values())e.isEmpty()&&e.remove()},P(ii,"_initialized",!1),y(ii,Kr,new Map([Tg,Fg,Gg,wf,jg].map(e=>[e._editorType,e])));let Sf=ii;function C0(d,e){return d===e?0:d.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function xu(d){var e;return d?d.nodeType===Node.ELEMENT_NODE?d.closest(".textLayer"):((e=d.parentElement)==null?void 0:e.closest(".textLayer"))||null:null}function I0(d,e,t,s){if(d===t)return e<=s;const i=d.compareDocumentPosition(t);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function Vm(d,e,t){if(d.nodeType!==Node.ELEMENT_NODE||!d.classList.contains("textLayer")||e!==d.childNodes.length)return{container:d,offset:e};let s=d.lastChild;return(s==null?void 0:s.nodeType)===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!t.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}var cs,Qe,qs,au,ou,zo,Wo,lu,Jf,Jr,Qr,Zr,qr,Gn,_e,Xg,Yg,Cb,uf,Ib,qi,Kg,Pb,Jg;const Q=class Q{constructor({filterFactory:e=null,pageColors:t=null,pageIndex:s,textLayer:i=null}){y(this,qi);y(this,cs,null);y(this,Qe,new Map);y(this,qs,null);y(this,au,null);y(this,ou,null);y(this,zo,null);y(this,Wo,new Map);if(this.pageIndex=s,g(this,au,e),g(this,ou,t),i){const r=n(Q,Gn).get(i);if(r!=null&&r.selectionDiv&&(r.selectionDiv.remove(),n(Q,Qr).delete(r.selectionDiv)),n(Q,Gn).set(i,{drawLayer:this}),n(Q,qr).add(i),g(this,qs,i),g(this,zo,new MutationObserver(a=>{var o,l,h;if(!(!n(this,cs)||!((o=n(this,qs))!=null&&o.isConnected)||!b(l=Q,_e,Yg).call(l))){for(const{addedNodes:c}of a)for(const u of c)if(u.nodeType===Node.ELEMENT_NODE&&u.classList.contains("endOfContent")){b(h=Q,_e,uf).call(h);return}}})),n(this,zo).observe(i,{childList:!0}),n(Q,Jr)===null){g(Q,Jr,new AbortController);const{signal:a}=n(Q,Jr);document.addEventListener("selectionchange",b(Q,_e,uf).bind(Q),{signal:a}),document.addEventListener("pointerdown",()=>{g(Q,Zr,!0)},{signal:a}),document.addEventListener("pointerup",()=>{g(Q,Zr,!1)},{signal:a}),window.addEventListener("blur",()=>{g(Q,Zr,!1)},{signal:a})}}}setParent(e){var t,s,i;if(!n(this,cs)){g(this,cs,e),(t=n(this,qs))!=null&&t.isConnected&&b(s=Q,_e,Yg).call(s)&&b(i=Q,_e,uf).call(i);return}if(n(this,cs)!==e){if(n(this,Qe).size>0)for(const r of n(this,Qe).values())r.remove(),e.append(r);g(this,cs,e)}}static get _svgFactory(){return st(this,"_svgFactory",new Tc)}draw(e,t=!1,s=!1){const i=$t(Q,lu)._++,r=b(this,qi,Kg).call(this),a=Q._svgFactory.createElement("defs");r.append(a);const o=Q._svgFactory.createElement("path");a.append(o);const l=`path_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),t&&n(this,Wo).set(i,o);const h=s?b(this,qi,Pb).call(this,a,l):null,c=Q._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,e),n(this,Qe).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(e,t){const s=$t(Q,lu)._++,i=b(this,qi,Kg).call(this),r=Q._svgFactory.createElement("defs");i.append(r);const a=Q._svgFactory.createElement("path");r.append(a);const o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(t){const u=Q._svgFactory.createElement("mask");r.append(u),l=`mask_${s}`,u.setAttribute("id",l),u.setAttribute("maskUnits","objectBoundingBox");const f=Q._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const p=Q._svgFactory.createElement("use");u.append(p),p.setAttribute("href",`#${o}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const h=Q._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,e),n(this,Qe).set(s,i),s}finalizeDraw(e,t){n(this,Wo).delete(e),this.updateProperties(e,t)}updateProperties(e,t){var l;if(!t)return;const{root:s,bbox:i,rootClass:r,path:a}=t,o=typeof e=="number"?n(this,Qe).get(e):e;if(o){if(s&&b(this,qi,Jg).call(this,o,s),i&&b(l=Q,_e,Ib).call(l,o,i),r){const{classList:h}=o;for(const[c,u]of Object.entries(r))h.toggle(c,u)}if(a){const c=o.firstElementChild.firstElementChild;b(this,qi,Jg).call(this,c,a)}}}updateParent(e,t){if(t===this)return;const s=n(this,Qe).get(e);s&&(n(t,cs).append(s),n(this,Qe).delete(e),n(t,Qe).set(e,s))}remove(e){n(this,Wo).delete(e),n(this,cs)!==null&&(n(this,Qe).get(e).remove(),n(this,Qe).delete(e))}destroy(){var e,t,s;g(this,cs,null);for(const i of n(this,Qe).values())i.remove();if(n(this,Qe).clear(),n(this,Wo).clear(),(e=n(this,zo))==null||e.disconnect(),g(this,zo,null),n(this,qs)){const i=n(Q,Gn).get(n(this,qs));(i==null?void 0:i.drawLayer)===this&&(b(t=Q,_e,Xg).call(t,n(this,qs)),n(Q,Gn).delete(n(this,qs)),n(Q,qr).delete(n(this,qs)),n(Q,qr).size===0&&((s=n(Q,Jr))==null||s.abort(),g(Q,Jr,null),g(Q,Zr,!1))),g(this,qs,null)}}};cs=new WeakMap,Qe=new WeakMap,qs=new WeakMap,au=new WeakMap,ou=new WeakMap,zo=new WeakMap,Wo=new WeakMap,lu=new WeakMap,Jf=new WeakMap,Jr=new WeakMap,Qr=new WeakMap,Zr=new WeakMap,qr=new WeakMap,Gn=new WeakMap,_e=new WeakSet,Xg=function(e){const t=n(this,Gn).get(e);t!=null&&t.selectionDiv&&(t.selectionDiv.remove(),n(this,Qr).delete(t.selectionDiv),t.selectionDiv=null,t.path=null)},Yg=function(){const e=document.getSelection();return!!e&&!e.isCollapsed},Cb=function(){return[...n(this,qr)].filter(e=>e.isConnected).sort(C0)},uf=function(){var a;const e=document.getSelection();if(!e||e.isCollapsed){for(const o of n(this,Qr))o.remove();n(this,Qr).clear();return}const t=new WeakMap,s=b(this,_e,Cb).call(this),i=[];for(let o=0,l=e.rangeCount;o<l;o++){const h=e.getRangeAt(o);if(h.collapsed)continue;let{startContainer:c,startOffset:u,endContainer:f,endOffset:p}=h,m=xu(c),v=xu(f);const A=m===null,w=v===null;if(n(this,Zr)&&A!==w)return;if(e.rangeCount===1){const{anchorNode:T,anchorOffset:x,focusNode:C,focusOffset:I}=e,O=xu(T),M=xu(C),R=I0(T,x,C,I);O&&M&&R!==null&&(R?(c=T,u=x,m=O,f=C,p=I,v=M):(c=C,u=I,m=M,f=T,p=x,v=O))}const E=s.filter(T=>h.intersectsNode(T));if(E.length===0)continue;let S=!1;if(m||(m=E[0],c=m,u=0,S=!0),v||(v=E.at(-1),f=v,p=v.childNodes.length,S=!0),f.nodeType===Node.ELEMENT_NODE){if(f.classList.contains("endOfContent")){const T=f.previousSibling;if(!T)continue;f=T,p=T.nodeType===Node.TEXT_NODE?T.textContent.length:T.childNodes.length}else if(f.classList.contains("textLayer")&&f.childNodes.length===p){const T=Vm(f,p,v);if(!T)continue;f=T.container,p=T.offset}}if(c.nodeType===Node.ELEMENT_NODE){const T=Vm(c,u,m);if(!T)continue;c=T.container,u=T.offset}if(m===v&&!S&&E.includes(m)){i.push([h,m]);continue}for(const T of E){const x=T.firstChild;if(!x)continue;const C=document.createRange();if(T===m?C.setStart(c,u):C.setStartBefore(x),T===v)C.setEnd(f,p);else{const I=T.lastChild;if(!I)continue;if(I.nodeType===Node.ELEMENT_NODE&&I.classList.contains("endOfContent")){const O=I.previousSibling;if(!O)continue;C.setEndAfter(O)}else C.setEndAfter(I)}C.collapsed||i.push([C,T])}}const r=new Set(i.map(o=>o[1]));for(const o of n(this,qr))r.has(o)||b(this,_e,Xg).call(this,o);for(const[o,l]of i){const h=n(Q,Gn).get(l);if(!h)continue;let c=t.get(l);if(!c){const v=l.getBoundingClientRect();c=(A,w,E,S)=>({x:(A-v.x)/v.width,y:(w-v.y)/v.height,width:E/v.width,height:S/v.height}),t.set(l,c)}const u=[];for(let{x:v,y:A,width:w,height:E}of o.getClientRects())w===0||E===0||({x:v,y:A,width:w,height:E}=c(v,A,w,E),!(w===1&&E===1)&&u.push(`M${v} ${A} h${w} v${E} h-${w} Z`));if(u.length===0)continue;const f=h.drawLayer;let p=h.selectionDiv,m=h.path;if(!p){const v=`clip_selection_${$t(Q,Jf)._++}`;p=document.createElement("div"),p.className="selection",p.style.clipPath=`url(#${v})`;const A=(a=n(f,au))==null?void 0:a.createSelectionStyle(n(f,ou));if(A)for(const[S,T]of Object.entries(A))p.style.setProperty(S,T);const w=Q._svgFactory.create(1,1,!0);w.setAttribute("aria-hidden","true"),w.setAttribute("width","100%"),w.setAttribute("height","100%");const E=Q._svgFactory.createElement("clipPath");E.setAttribute("id",v),E.setAttribute("clipPathUnits","objectBoundingBox"),m=Q._svgFactory.createElement("path"),E.append(m),w.append(E),p.append(w),h.path=m,h.selectionDiv=p}!p.parentNode&&n(f,cs)&&(n(f,cs).append(p),n(this,Qr).add(p)),m.setAttribute("d",u.join(" "))}},Ib=function(e,[t,s,i,r]){const{style:a}=e;a.top=`${100*s}%`,a.left=`${100*t}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},qi=new WeakSet,Kg=function(){const e=Q._svgFactory.create(1,1,!0);return n(this,cs).append(e),e.setAttribute("aria-hidden","true"),e},Pb=function(e,t){const s=Q._svgFactory.createElement("clipPath");e.append(s);const i=`clip_${t}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=Q._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${t}`),r.classList.add("clip"),i},Jg=function(e,t){for(const[s,i]of Object.entries(t))i===null?e.removeAttribute(s):e.setAttribute(s,i)},y(Q,_e),y(Q,lu,0),y(Q,Jf,0),y(Q,Jr,null),y(Q,Qr,new Set),y(Q,Zr,!1),y(Q,qr,new Set),y(Q,Gn,new WeakMap);let xf=Q;function Tu(d){return`${(d*100).toFixed(2)}%`}var Dh,hu,cu,kh,Yi,Ki,du,Qf,Mb;const mc=class mc{constructor(e,t,s,i){y(this,Qf);y(this,Dh,[]);y(this,hu,new Map);y(this,cu,null);y(this,kh,0);y(this,Yi,0);y(this,Ki,0);g(this,kh,e),g(this,Dh,t),g(this,Yi,s.rawDims.pageWidth),g(this,Ki,s.rawDims.pageHeight),g(this,cu,i)}render(){const e=document.createElement("div");e.className="textLayerImages";for(let t=0;t<n(this,Dh).length;t+=6){const s=b(this,Qf,Mb).call(this,n(this,Dh).subarray(t,t+6));s&&e.append(s)}return e.addEventListener("contextmenu",t=>{var w;if(!(t.target instanceof HTMLCanvasElement))return;const s=t.target,i=n(this,hu).get(s);if(!i)return;const r=(w=n(mc,du))==null?void 0:w.deref();if(r===s)return;r&&(r.width=0,r.height=0),g(mc,du,new WeakRef(s));const{inverseTransform:a,x1:o,y1:l,width:h,height:c}=i,u=n(this,cu).call(this),f=Math.ceil(o*u.width),p=Math.ceil(l*u.height),m=Math.floor((o+h/n(this,Yi))*u.width),v=Math.floor((l+c/n(this,Ki))*u.height);s.width=m-f,s.height=v-p;const A=s.getContext("2d");A.setTransform(...a),A.translate(-f,-p),A.drawImage(u,0,0)}),e}};Dh=new WeakMap,hu=new WeakMap,cu=new WeakMap,kh=new WeakMap,Yi=new WeakMap,Ki=new WeakMap,du=new WeakMap,Qf=new WeakSet,Mb=function([e,t,s,i,r,a]){const o=Math.hypot((r-e)*n(this,Yi),(a-t)*n(this,Ki)),l=Math.hypot((s-e)*n(this,Yi),(i-t)*n(this,Ki));if(o<n(this,kh)||l<n(this,kh))return null;const h=[(r-e)*n(this,Yi)/o,(a-t)*n(this,Ki)/o,(s-e)*n(this,Yi)/l,(i-t)*n(this,Ki)/l,0,0],c=H.inverseTransform(h),u=document.createElement("canvas");return u.className="textLayerImagePlaceholder",u.width=0,u.height=0,Object.assign(u.style,{opacity:0,position:"absolute",left:Tu(e),top:Tu(t),width:Tu(o/n(this,Yi)),height:Tu(l/n(this,Ki)),transformOrigin:"0% 0%",transform:`matrix(${h.join(",")})`}),n(this,hu).set(u,{inverseTransform:c,width:o,height:l,x1:e,y1:t}),u},y(mc,du,null);let Tf=mc;globalThis._pdfjsTestingUtils={HighlightOutliner:Ig};globalThis.pdfjsLib={AbortException:Xn,AnnotationEditorLayer:Sf,AnnotationEditorParamsType:at,AnnotationEditorType:nt,AnnotationEditorUIManager:ea,AnnotationLayer:bf,AnnotationMode:_n,AnnotationType:Xt,applyOpacity:sv,build:Iy,ColorPicker:xc,createValidAbsoluteUrl:Qg,CSSConstants:ev,DOMSVGFactory:Tc,DrawLayer:xf,FeatureTest:It,fetchData:sp,findContrastColor:iv,getDocument:Sy,getFilenameFromUrl:qm,getPdfFilenameFromUrl:tv,getRGB:$h,getRGBA:Hh,getUuid:qg,GlobalWorkerOptions:bi,ImageKind:uc,InvalidPDFException:pf,isDataScheme:pu,isPdfFile:np,isValidExplicitDest:_v,makeArr:Uh,makeMap:ep,makeObj:gf,MathClamp:Ht,noContextMenu:Bs,normalizeUnicode:Zm,OPS:yi,OutputScale:Ei,PasswordException:ff,PasswordResponses:Qm,PDFDataRangeTransport:nm,PDFDateString:Ac,PDFWorker:Fh,PermissionFlag:Jm,PixelsPerInch:Yn,RenderingCancelledException:ip,renderRichText:em,ResponseException:yc,setLayerDimensions:ta,shadow:st,SignatureExtractor:Ji,stopEvent:Wt,SupportedImageMimeTypes:mf,TextLayer:Lh,TextLayerImages:Tf,TouchManager:wc,updateUrlHash:Zg,Util:H,VerbosityLevel:uu,version:Cy,XfaLayer:tm};const P0=Object.freeze(Object.defineProperty({__proto__:null,AbortException:Xn,AnnotationEditorLayer:Sf,AnnotationEditorParamsType:at,AnnotationEditorType:nt,AnnotationEditorUIManager:ea,AnnotationLayer:bf,AnnotationMode:_n,AnnotationType:Xt,CSSConstants:ev,ColorPicker:xc,DOMSVGFactory:Tc,DrawLayer:xf,FeatureTest:It,GlobalWorkerOptions:bi,ImageKind:uc,InvalidPDFException:pf,MathClamp:Ht,OPS:yi,OutputScale:Ei,PDFDataRangeTransport:nm,PDFDateString:Ac,PDFWorker:Fh,PasswordException:ff,PasswordResponses:Qm,PermissionFlag:Jm,PixelsPerInch:Yn,RenderingCancelledException:ip,ResponseException:yc,SignatureExtractor:Ji,SupportedImageMimeTypes:mf,TextLayer:Lh,TextLayerImages:Tf,TouchManager:wc,Util:H,VerbosityLevel:uu,XfaLayer:tm,applyOpacity:sv,build:Iy,createValidAbsoluteUrl:Qg,fetchData:sp,findContrastColor:iv,getDocument:Sy,getFilenameFromUrl:qm,getPdfFilenameFromUrl:tv,getRGB:$h,getRGBA:Hh,getUuid:qg,isDataScheme:pu,isPdfFile:np,isValidExplicitDest:_v,makeArr:Uh,makeMap:ep,makeObj:gf,noContextMenu:Bs,normalizeUnicode:Zm,renderRichText:em,setLayerDimensions:ta,shadow:st,stopEvent:Wt,updateUrlHash:Zg,version:Cy},Symbol.toStringTag,{value:"Module"}));let Xm=!1;function O0(){return Xm||(bi.workerPort=new Db,Xm=!0),P0}export{O0 as getPdfjs};
|