orbital-command 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -42
- package/bin/commands/config.js +19 -0
- package/bin/commands/events.js +40 -0
- package/bin/commands/launch.js +126 -0
- package/bin/commands/manifest.js +283 -0
- package/bin/commands/registry.js +104 -0
- package/bin/commands/update.js +24 -0
- package/bin/lib/helpers.js +229 -0
- package/bin/orbital.js +147 -319
- package/dist/assets/Landing-CfQdHR0N.js +11 -0
- package/dist/assets/PrimitivesConfig-DThSipFy.js +32 -0
- package/dist/assets/QualityGates-B4kxM5UU.js +26 -0
- package/dist/assets/SessionTimeline-Bz1iZnmg.js +1 -0
- package/dist/assets/Settings-DLcZwbCT.js +12 -0
- package/dist/assets/SourceControl-BMNIz7Lt.js +36 -0
- package/dist/assets/WorkflowVisualizer-CxuSBOYu.js +69 -0
- package/dist/assets/arrow-down-DVPp6_qp.js +6 -0
- package/dist/assets/bot-NFaJBDn_.js +6 -0
- package/dist/assets/charts-LGLb8hyU.js +68 -0
- package/dist/assets/circle-x-IsFCkBZu.js +6 -0
- package/dist/assets/file-text-J1cebZXF.js +6 -0
- package/dist/assets/globe-WzeyHsUc.js +6 -0
- package/dist/assets/index-BdJ57EhC.css +1 -0
- package/dist/assets/index-o4ScMAuR.js +349 -0
- package/dist/assets/key-CKR8JJSj.js +6 -0
- package/dist/assets/minus-CHBsJyjp.js +6 -0
- package/dist/assets/radio-xqZaR-Uk.js +6 -0
- package/dist/assets/rocket-D_xvvNG6.js +6 -0
- package/dist/assets/shield-TdB1yv_a.js +6 -0
- package/dist/assets/ui-BmsSg9jU.js +53 -0
- package/dist/assets/useSocketListener-0L5yiN5i.js +1 -0
- package/dist/assets/useWorkflowEditor-CqeRWVQX.js +11 -0
- package/dist/assets/{vendor-Dzv9lrRc.js → vendor-Bqt8AJn2.js} +1 -1
- package/dist/assets/workflow-constants-Rw-GmgHZ.js +6 -0
- package/dist/assets/zap-C9wqYMpl.js +6 -0
- package/dist/favicon.svg +1 -0
- package/dist/index.html +6 -5
- package/dist/server/server/__tests__/data-routes.test.js +126 -0
- package/dist/server/server/__tests__/helpers/db.js +17 -0
- package/dist/server/server/__tests__/helpers/mock-emitter.js +8 -0
- package/dist/server/server/__tests__/scope-routes.test.js +138 -0
- package/dist/server/server/__tests__/sprint-routes.test.js +102 -0
- package/dist/server/server/__tests__/workflow-routes.test.js +107 -0
- package/dist/server/server/config-migrator.js +135 -0
- package/dist/server/server/config.js +51 -7
- package/dist/server/server/database.js +21 -28
- package/dist/server/server/global-config.js +143 -0
- package/dist/server/server/index.js +118 -276
- package/dist/server/server/init.js +243 -225
- package/dist/server/server/launch.js +29 -0
- package/dist/server/server/manifest-types.js +8 -0
- package/dist/server/server/manifest.js +454 -0
- package/dist/server/server/migrate-legacy.js +229 -0
- package/dist/server/server/parsers/event-parser.js +4 -1
- package/dist/server/server/parsers/event-parser.test.js +117 -0
- package/dist/server/server/parsers/scope-parser.js +74 -28
- package/dist/server/server/parsers/scope-parser.test.js +230 -0
- package/dist/server/server/project-context.js +265 -0
- package/dist/server/server/project-emitter.js +41 -0
- package/dist/server/server/project-manager.js +297 -0
- package/dist/server/server/routes/aggregate-routes.js +871 -0
- package/dist/server/server/routes/config-routes.js +41 -90
- package/dist/server/server/routes/data-routes.js +25 -123
- package/dist/server/server/routes/dispatch-routes.js +37 -15
- package/dist/server/server/routes/git-routes.js +74 -0
- package/dist/server/server/routes/manifest-routes.js +319 -0
- package/dist/server/server/routes/scope-routes.js +45 -28
- package/dist/server/server/routes/sync-routes.js +134 -0
- package/dist/server/server/routes/version-routes.js +1 -15
- package/dist/server/server/routes/workflow-routes.js +9 -3
- package/dist/server/server/schema.js +3 -0
- package/dist/server/server/services/batch-orchestrator.js +41 -17
- package/dist/server/server/services/claude-session-service.js +17 -14
- package/dist/server/server/services/config-service.js +10 -1
- package/dist/server/server/services/deploy-service.test.js +119 -0
- package/dist/server/server/services/event-service.js +64 -1
- package/dist/server/server/services/event-service.test.js +191 -0
- package/dist/server/server/services/gate-service.test.js +105 -0
- package/dist/server/server/services/git-service.js +108 -4
- package/dist/server/server/services/github-service.js +110 -2
- package/dist/server/server/services/readiness-service.test.js +190 -0
- package/dist/server/server/services/scope-cache.js +5 -1
- package/dist/server/server/services/scope-cache.test.js +142 -0
- package/dist/server/server/services/scope-service.js +222 -131
- package/dist/server/server/services/scope-service.test.js +137 -0
- package/dist/server/server/services/sprint-orchestrator.js +29 -15
- package/dist/server/server/services/sprint-service.js +23 -3
- package/dist/server/server/services/sprint-service.test.js +238 -0
- package/dist/server/server/services/sync-service.js +434 -0
- package/dist/server/server/services/sync-types.js +2 -0
- package/dist/server/server/services/workflow-service.js +26 -5
- package/dist/server/server/services/workflow-service.test.js +159 -0
- package/dist/server/server/settings-sync.js +284 -0
- package/dist/server/server/uninstall.js +195 -0
- package/dist/server/server/update-planner.js +279 -0
- package/dist/server/server/update.js +212 -0
- package/dist/server/server/utils/cc-hooks-parser.js +3 -0
- package/dist/server/server/utils/cc-hooks-parser.test.js +86 -0
- package/dist/server/server/utils/dispatch-utils.js +83 -24
- package/dist/server/server/utils/dispatch-utils.test.js +182 -0
- package/dist/server/server/utils/flag-builder.js +54 -0
- package/dist/server/server/utils/json-fields.js +14 -0
- package/dist/server/server/utils/json-fields.test.js +73 -0
- package/dist/server/server/utils/logger.js +37 -3
- package/dist/server/server/utils/package-info.js +30 -0
- package/dist/server/server/utils/route-helpers.js +47 -0
- package/dist/server/server/utils/route-helpers.test.js +115 -0
- package/dist/server/server/utils/terminal-launcher.js +79 -25
- package/dist/server/server/utils/worktree-manager.js +13 -4
- package/dist/server/server/validator.js +230 -0
- package/dist/server/server/watchers/event-watcher.js +28 -13
- package/dist/server/server/watchers/global-watcher.js +63 -0
- package/dist/server/server/watchers/scope-watcher.js +27 -12
- package/dist/server/server/wizard/config-editor.js +237 -0
- package/dist/server/server/wizard/detect.js +96 -0
- package/dist/server/server/wizard/doctor.js +115 -0
- package/dist/server/server/wizard/index.js +340 -0
- package/dist/server/server/wizard/phases/confirm.js +39 -0
- package/dist/server/server/wizard/phases/project-setup.js +90 -0
- package/dist/server/server/wizard/phases/setup-wizard.js +66 -0
- package/dist/server/server/wizard/phases/welcome.js +32 -0
- package/dist/server/server/wizard/phases/workflow-setup.js +22 -0
- package/dist/server/server/wizard/types.js +29 -0
- package/dist/server/server/wizard/ui.js +73 -0
- package/dist/server/shared/__fixtures__/workflow-configs.js +75 -0
- package/dist/server/shared/api-types.js +80 -1
- package/dist/server/shared/default-workflow.json +65 -0
- package/dist/server/shared/onboarding-tour.test.js +81 -0
- package/dist/server/shared/project-colors.js +24 -0
- package/dist/server/shared/workflow-config.test.js +84 -0
- package/dist/server/shared/workflow-engine.js +1 -1
- package/dist/server/shared/workflow-engine.test.js +302 -0
- package/dist/server/shared/workflow-normalizer.js +101 -0
- package/dist/server/shared/workflow-normalizer.test.js +100 -0
- package/dist/server/src/components/onboarding/tour-steps.js +84 -0
- package/package.json +34 -29
- package/schemas/orbital.config.schema.json +2 -5
- package/scripts/postinstall.js +18 -6
- package/scripts/release.sh +53 -0
- package/server/__tests__/data-routes.test.ts +151 -0
- package/server/__tests__/helpers/db.ts +19 -0
- package/server/__tests__/helpers/mock-emitter.ts +10 -0
- package/server/__tests__/scope-routes.test.ts +158 -0
- package/server/__tests__/sprint-routes.test.ts +118 -0
- package/server/__tests__/workflow-routes.test.ts +120 -0
- package/server/config-migrator.ts +160 -0
- package/server/config.ts +64 -12
- package/server/database.ts +22 -31
- package/server/global-config.ts +204 -0
- package/server/index.ts +139 -316
- package/server/init.ts +266 -234
- package/server/launch.ts +32 -0
- package/server/manifest-types.ts +145 -0
- package/server/manifest.ts +494 -0
- package/server/migrate-legacy.ts +290 -0
- package/server/parsers/event-parser.test.ts +135 -0
- package/server/parsers/event-parser.ts +4 -1
- package/server/parsers/scope-parser.test.ts +270 -0
- package/server/parsers/scope-parser.ts +79 -31
- package/server/project-context.ts +325 -0
- package/server/project-emitter.ts +50 -0
- package/server/project-manager.ts +368 -0
- package/server/routes/aggregate-routes.ts +968 -0
- package/server/routes/config-routes.ts +43 -85
- package/server/routes/data-routes.ts +34 -156
- package/server/routes/dispatch-routes.ts +46 -17
- package/server/routes/git-routes.ts +77 -0
- package/server/routes/manifest-routes.ts +388 -0
- package/server/routes/scope-routes.ts +39 -30
- package/server/routes/sync-routes.ts +175 -0
- package/server/routes/version-routes.ts +1 -16
- package/server/routes/workflow-routes.ts +9 -3
- package/server/schema.ts +3 -0
- package/server/services/batch-orchestrator.ts +41 -17
- package/server/services/claude-session-service.ts +16 -14
- package/server/services/config-service.ts +10 -1
- package/server/services/deploy-service.test.ts +145 -0
- package/server/services/deploy-service.ts +2 -2
- package/server/services/event-service.test.ts +242 -0
- package/server/services/event-service.ts +92 -3
- package/server/services/gate-service.test.ts +131 -0
- package/server/services/gate-service.ts +2 -2
- package/server/services/git-service.ts +137 -4
- package/server/services/github-service.ts +120 -2
- package/server/services/readiness-service.test.ts +217 -0
- package/server/services/scope-cache.test.ts +167 -0
- package/server/services/scope-cache.ts +4 -1
- package/server/services/scope-service.test.ts +169 -0
- package/server/services/scope-service.ts +224 -130
- package/server/services/sprint-orchestrator.ts +30 -15
- package/server/services/sprint-service.test.ts +271 -0
- package/server/services/sprint-service.ts +29 -5
- package/server/services/sync-service.ts +482 -0
- package/server/services/sync-types.ts +77 -0
- package/server/services/workflow-service.test.ts +190 -0
- package/server/services/workflow-service.ts +29 -9
- package/server/settings-sync.ts +359 -0
- package/server/uninstall.ts +214 -0
- package/server/update-planner.ts +346 -0
- package/server/update.ts +263 -0
- package/server/utils/cc-hooks-parser.test.ts +96 -0
- package/server/utils/cc-hooks-parser.ts +4 -0
- package/server/utils/dispatch-utils.test.ts +245 -0
- package/server/utils/dispatch-utils.ts +102 -30
- package/server/utils/flag-builder.ts +56 -0
- package/server/utils/json-fields.test.ts +83 -0
- package/server/utils/json-fields.ts +14 -0
- package/server/utils/logger.ts +40 -3
- package/server/utils/package-info.ts +32 -0
- package/server/utils/route-helpers.test.ts +144 -0
- package/server/utils/route-helpers.ts +50 -0
- package/server/utils/terminal-launcher.ts +85 -25
- package/server/utils/worktree-manager.ts +9 -4
- package/server/validator.ts +270 -0
- package/server/watchers/event-watcher.ts +24 -12
- package/server/watchers/global-watcher.ts +77 -0
- package/server/watchers/scope-watcher.ts +21 -9
- package/server/wizard/config-editor.ts +248 -0
- package/server/wizard/detect.ts +104 -0
- package/server/wizard/doctor.ts +114 -0
- package/server/wizard/index.ts +438 -0
- package/server/wizard/phases/confirm.ts +45 -0
- package/server/wizard/phases/project-setup.ts +106 -0
- package/server/wizard/phases/setup-wizard.ts +78 -0
- package/server/wizard/phases/welcome.ts +39 -0
- package/server/wizard/phases/workflow-setup.ts +28 -0
- package/server/wizard/types.ts +56 -0
- package/server/wizard/ui.ts +92 -0
- package/shared/__fixtures__/workflow-configs.ts +80 -0
- package/shared/api-types.ts +106 -0
- package/shared/onboarding-tour.test.ts +94 -0
- package/shared/project-colors.ts +24 -0
- package/shared/workflow-config.test.ts +111 -0
- package/shared/workflow-config.ts +7 -0
- package/shared/workflow-engine.test.ts +388 -0
- package/shared/workflow-engine.ts +1 -1
- package/shared/workflow-normalizer.test.ts +119 -0
- package/shared/workflow-normalizer.ts +118 -0
- package/templates/agents/QUICK-REFERENCE.md +1 -0
- package/templates/agents/README.md +1 -0
- package/templates/agents/SKILL-TRIGGERS.md +11 -0
- package/templates/agents/green-team/deep-dive.md +361 -0
- package/templates/hooks/end-session.sh +4 -1
- package/templates/hooks/init-session.sh +1 -0
- package/templates/hooks/orbital-emit.sh +2 -2
- package/templates/hooks/orbital-report-deploy.sh +4 -4
- package/templates/hooks/orbital-report-gates.sh +4 -4
- package/templates/hooks/orbital-scope-update.sh +1 -1
- package/templates/hooks/scope-commit-logger.sh +2 -2
- package/templates/hooks/scope-create-cleanup.sh +2 -2
- package/templates/hooks/scope-create-gate.sh +2 -5
- package/templates/hooks/scope-gate.sh +4 -6
- package/templates/hooks/scope-helpers.sh +28 -1
- package/templates/hooks/scope-lifecycle-gate.sh +14 -5
- package/templates/hooks/scope-prepare.sh +67 -12
- package/templates/hooks/scope-transition.sh +14 -6
- package/templates/hooks/time-tracker.sh +2 -5
- package/templates/migrations/renames.json +1 -0
- package/templates/orbital.config.json +8 -6
- package/{shared/default-workflow.json → templates/presets/default.json} +65 -0
- package/templates/presets/development.json +4 -4
- package/templates/presets/gitflow.json +7 -0
- package/templates/prompts/README.md +23 -0
- package/templates/prompts/deep-dive-audit.md +94 -0
- package/templates/quick/rules.md +56 -5
- package/templates/settings-hooks.json +1 -1
- package/templates/skills/git-commit/SKILL.md +27 -7
- package/templates/skills/git-dev/SKILL.md +13 -4
- package/templates/skills/git-main/SKILL.md +13 -3
- package/templates/skills/git-production/SKILL.md +9 -2
- package/templates/skills/git-staging/SKILL.md +11 -3
- package/templates/skills/scope-create/SKILL.md +17 -3
- package/templates/skills/scope-fix-review/SKILL.md +14 -7
- package/templates/skills/scope-implement/SKILL.md +15 -4
- package/templates/skills/scope-post-review/SKILL.md +77 -7
- package/templates/skills/scope-pre-review/SKILL.md +11 -4
- package/templates/skills/scope-verify/SKILL.md +5 -3
- package/templates/skills/test-code-review/SKILL.md +41 -33
- package/templates/skills/test-scaffold/SKILL.md +222 -0
- package/dist/assets/WorkflowVisualizer-BZ21PIIF.js +0 -84
- package/dist/assets/charts-D__PA1zp.js +0 -72
- package/dist/assets/index-D1G6i0nS.css +0 -1
- package/dist/assets/index-DpItvKpf.js +0 -419
- package/dist/assets/ui-BvF022GT.js +0 -53
- package/index.html +0 -15
- package/postcss.config.js +0 -6
- package/src/App.tsx +0 -33
- package/src/components/AgentBadge.tsx +0 -40
- package/src/components/BatchPreflightModal.tsx +0 -115
- package/src/components/CardDisplayToggle.tsx +0 -74
- package/src/components/ColumnHeaderActions.tsx +0 -55
- package/src/components/ColumnMenu.tsx +0 -99
- package/src/components/DeployHistory.tsx +0 -141
- package/src/components/DispatchModal.tsx +0 -164
- package/src/components/DispatchPopover.tsx +0 -139
- package/src/components/DragOverlay.tsx +0 -25
- package/src/components/DriftSidebar.tsx +0 -140
- package/src/components/EnvironmentStrip.tsx +0 -88
- package/src/components/ErrorBoundary.tsx +0 -62
- package/src/components/FilterChip.tsx +0 -105
- package/src/components/GateIndicator.tsx +0 -33
- package/src/components/IdeaDetailModal.tsx +0 -190
- package/src/components/IdeaFormDialog.tsx +0 -113
- package/src/components/KanbanColumn.tsx +0 -201
- package/src/components/MarkdownRenderer.tsx +0 -114
- package/src/components/NeonGrid.tsx +0 -128
- package/src/components/PromotionQueue.tsx +0 -89
- package/src/components/ScopeCard.tsx +0 -234
- package/src/components/ScopeDetailModal.tsx +0 -255
- package/src/components/ScopeFilterBar.tsx +0 -152
- package/src/components/SearchInput.tsx +0 -102
- package/src/components/SessionPanel.tsx +0 -335
- package/src/components/SprintContainer.tsx +0 -303
- package/src/components/SprintDependencyDialog.tsx +0 -78
- package/src/components/SprintPreflightModal.tsx +0 -138
- package/src/components/StatusBar.tsx +0 -168
- package/src/components/SwimCell.tsx +0 -67
- package/src/components/SwimLaneRow.tsx +0 -94
- package/src/components/SwimlaneBoardView.tsx +0 -108
- package/src/components/VersionBadge.tsx +0 -139
- package/src/components/ViewModeSelector.tsx +0 -114
- package/src/components/config/AgentChip.tsx +0 -53
- package/src/components/config/AgentCreateDialog.tsx +0 -321
- package/src/components/config/AgentEditor.tsx +0 -175
- package/src/components/config/DirectoryTree.tsx +0 -582
- package/src/components/config/FileEditor.tsx +0 -550
- package/src/components/config/HookChip.tsx +0 -50
- package/src/components/config/StageCard.tsx +0 -198
- package/src/components/config/TransitionZone.tsx +0 -173
- package/src/components/config/UnifiedWorkflowPipeline.tsx +0 -216
- package/src/components/config/WorkflowPipeline.tsx +0 -161
- package/src/components/source-control/BranchList.tsx +0 -93
- package/src/components/source-control/BranchPanel.tsx +0 -105
- package/src/components/source-control/CommitLog.tsx +0 -100
- package/src/components/source-control/CommitRow.tsx +0 -47
- package/src/components/source-control/GitHubPanel.tsx +0 -110
- package/src/components/source-control/GitHubSetupGuide.tsx +0 -52
- package/src/components/source-control/GitOverviewBar.tsx +0 -101
- package/src/components/source-control/PullRequestList.tsx +0 -69
- package/src/components/source-control/WorktreeList.tsx +0 -80
- package/src/components/ui/badge.tsx +0 -41
- package/src/components/ui/button.tsx +0 -55
- package/src/components/ui/card.tsx +0 -78
- package/src/components/ui/dialog.tsx +0 -94
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/scroll-area.tsx +0 -54
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/tabs.tsx +0 -52
- package/src/components/ui/toggle-switch.tsx +0 -35
- package/src/components/ui/tooltip.tsx +0 -27
- package/src/components/workflow/AddEdgeDialog.tsx +0 -217
- package/src/components/workflow/AddListDialog.tsx +0 -201
- package/src/components/workflow/ChecklistEditor.tsx +0 -239
- package/src/components/workflow/CommandPrefixManager.tsx +0 -118
- package/src/components/workflow/ConfigSettingsPanel.tsx +0 -189
- package/src/components/workflow/DirectionSelector.tsx +0 -133
- package/src/components/workflow/DispatchConfigPanel.tsx +0 -180
- package/src/components/workflow/EdgeDetailPanel.tsx +0 -236
- package/src/components/workflow/EdgePropertyEditor.tsx +0 -251
- package/src/components/workflow/EditToolbar.tsx +0 -138
- package/src/components/workflow/HookDetailPanel.tsx +0 -250
- package/src/components/workflow/HookExecutionLog.tsx +0 -24
- package/src/components/workflow/HookSourceModal.tsx +0 -129
- package/src/components/workflow/HooksDashboard.tsx +0 -363
- package/src/components/workflow/ListPropertyEditor.tsx +0 -251
- package/src/components/workflow/MigrationPreviewDialog.tsx +0 -237
- package/src/components/workflow/MovementRulesPanel.tsx +0 -188
- package/src/components/workflow/NodeDetailPanel.tsx +0 -245
- package/src/components/workflow/PresetSelector.tsx +0 -414
- package/src/components/workflow/SkillCommandBuilder.tsx +0 -174
- package/src/components/workflow/WorkflowEdgeComponent.tsx +0 -145
- package/src/components/workflow/WorkflowNode.tsx +0 -147
- package/src/components/workflow/graphLayout.ts +0 -186
- package/src/components/workflow/mergeHooks.ts +0 -85
- package/src/components/workflow/useEditHistory.ts +0 -88
- package/src/components/workflow/useWorkflowEditor.ts +0 -262
- package/src/components/workflow/validateConfig.ts +0 -70
- package/src/hooks/useActiveDispatches.ts +0 -198
- package/src/hooks/useBoardSettings.ts +0 -170
- package/src/hooks/useCardDisplay.ts +0 -57
- package/src/hooks/useCcHooks.ts +0 -24
- package/src/hooks/useConfigTree.ts +0 -51
- package/src/hooks/useEnforcementRules.ts +0 -46
- package/src/hooks/useEvents.ts +0 -59
- package/src/hooks/useFileEditor.ts +0 -165
- package/src/hooks/useGates.ts +0 -57
- package/src/hooks/useIdeaActions.ts +0 -53
- package/src/hooks/useKanbanDnd.ts +0 -410
- package/src/hooks/useOrbitalConfig.ts +0 -54
- package/src/hooks/usePipeline.ts +0 -47
- package/src/hooks/usePipelineData.ts +0 -338
- package/src/hooks/useReconnect.ts +0 -25
- package/src/hooks/useScopeFilters.ts +0 -125
- package/src/hooks/useScopeSessions.ts +0 -44
- package/src/hooks/useScopes.ts +0 -67
- package/src/hooks/useSearch.ts +0 -67
- package/src/hooks/useSettings.tsx +0 -187
- package/src/hooks/useSocket.ts +0 -25
- package/src/hooks/useSourceControl.ts +0 -105
- package/src/hooks/useSprintPreflight.ts +0 -55
- package/src/hooks/useSprints.ts +0 -154
- package/src/hooks/useStatusBarHighlight.ts +0 -18
- package/src/hooks/useSwimlaneBoardSettings.ts +0 -104
- package/src/hooks/useTheme.ts +0 -9
- package/src/hooks/useTransitionReadiness.ts +0 -53
- package/src/hooks/useVersion.ts +0 -155
- package/src/hooks/useViolations.ts +0 -65
- package/src/hooks/useWorkflow.tsx +0 -125
- package/src/hooks/useZoomModifier.ts +0 -19
- package/src/index.css +0 -797
- package/src/layouts/DashboardLayout.tsx +0 -113
- package/src/lib/collisionDetection.ts +0 -20
- package/src/lib/scope-fields.ts +0 -61
- package/src/lib/swimlane.ts +0 -146
- package/src/lib/utils.ts +0 -15
- package/src/main.tsx +0 -19
- package/src/socket.ts +0 -11
- package/src/types/index.ts +0 -497
- package/src/views/AgentFeed.tsx +0 -339
- package/src/views/DeployPipeline.tsx +0 -59
- package/src/views/EnforcementView.tsx +0 -378
- package/src/views/PrimitivesConfig.tsx +0 -500
- package/src/views/QualityGates.tsx +0 -1012
- package/src/views/ScopeBoard.tsx +0 -454
- package/src/views/SessionTimeline.tsx +0 -516
- package/src/views/Settings.tsx +0 -183
- package/src/views/SourceControl.tsx +0 -95
- package/src/views/WorkflowVisualizer.tsx +0 -382
- package/tailwind.config.js +0 -161
- package/tsconfig.json +0 -25
- package/vite.config.ts +0 -38
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import{j as r,x as ts,t as ns,O as ss,v as rs,y as os,w as Ue}from"./ui-BmsSg9jU.js";import{r as Xr,g as ic,d as is,a as N,b as ac}from"./vendor-Bqt8AJn2.js";import{i as cc,e as Hs,f as Os,g as lc,h as dc,j as uc,k as qt,l as En}from"./charts-LGLb8hyU.js";import{c as Ce,e as as,p as Gr,al as qr,q as Ur,X as he,G as Kr,f as be,l as cs,J as De,F as Jt,C as fc,aq as hc,d as ls,T as st,P as Te,a1 as pc,a3 as xc,a4 as mc,a5 as gc,a6 as bc,g as yc,R as Zr,U as Qr,b as Jr,a7 as wc,a8 as eo,aC as to,aD as Ie,aE as vc,aF as Nc,aG as jc,aH as Cc,aI as zc,aJ as kc,aK as no,n as Sc,u as Ec,aL as _c,aM as Mc,aN as ds,aO as Ic,r as Tc,t as Bs,aP as Ac,z as Pc,D as $c,aQ as Dc,aR as Lc,aS as Rc,aB as so,aT as Hc,E as Oc,k as Bc,K as Fc,aU as Vc,w as Yc,aV as Wc}from"./index-o4ScMAuR.js";import{Z as rt}from"./zap-C9wqYMpl.js";import{b as ot,c as us,d as Xc}from"./workflow-constants-Rw-GmgHZ.js";import{K as Gc}from"./key-CKR8JJSj.js";import{G as fs}from"./globe-WzeyHsUc.js";import{R as hs}from"./radio-xqZaR-Uk.js";import{S as ro,u as qc,P as Uc}from"./useWorkflowEditor-CqeRWVQX.js";import{M as oo}from"./minus-CHBsJyjp.js";import{S as hn}from"./shield-TdB1yv_a.js";import{B as en}from"./bot-NFaJBDn_.js";import{C as Kc}from"./circle-x-IsFCkBZu.js";/**
|
|
2
|
+
* @license lucide-react v0.577.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Zc=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]],Qc=Ce("clipboard-check",Zc);/**
|
|
7
|
+
* @license lucide-react v0.577.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Jc=[["path",{d:"m10 15 5 5 5-5",key:"1hpjnr"}],["path",{d:"M4 4h7a4 4 0 0 1 4 4v12",key:"wcbgct"}]],io=Ce("corner-right-down",Jc);/**
|
|
12
|
+
* @license lucide-react v0.577.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const el=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],tn=Ce("file-code-corner",el);/**
|
|
17
|
+
* @license lucide-react v0.577.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const tl=[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]],nl=Ce("folder-input",tl);/**
|
|
22
|
+
* @license lucide-react v0.577.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const sl=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],rl=Ce("grip-vertical",sl);/**
|
|
27
|
+
* @license lucide-react v0.577.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const ol=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],il=Ce("layout-grid",ol);/**
|
|
32
|
+
* @license lucide-react v0.577.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const al=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],cl=Ce("redo-2",al);/**
|
|
37
|
+
* @license lucide-react v0.577.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const ll=[["path",{d:"M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5",key:"bt2siv"}],["path",{d:"M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z",key:"1hjrv1"}],["path",{d:"M22 17v-1a2 2 0 0 0-2-2h-1",key:"1iynyr"}],["path",{d:"M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z",key:"161ggg"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],dl=Ce("server-off",ll);/**
|
|
42
|
+
* @license lucide-react v0.577.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const ul=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],fl=Ce("user",ul);function oe(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=oe(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var hl={value:()=>{}};function pn(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new Ut(n)}function Ut(e){this._=e}function pl(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",o=n.indexOf(".");if(o>=0&&(s=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}Ut.prototype=pn.prototype={constructor:Ut,on:function(e,t){var n=this._,s=pl(e+"",n),o,i=-1,a=s.length;if(arguments.length<2){for(;++i<a;)if((o=(e=s[i]).type)&&(o=xl(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(o=(e=s[i]).type)n[o]=Fs(n[o],e.name,t);else if(t==null)for(o in n)n[o]=Fs(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ut(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),s=0,o,i;s<o;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],s=0,o=i.length;s<o;++s)i[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,i=s.length;o<i;++o)s[o].value.apply(t,n)}};function xl(e,t){for(var n=0,s=e.length,o;n<s;++n)if((o=e[n]).name===t)return o.value}function Fs(e,t,n){for(var s=0,o=e.length;s<o;++s)if(e[s].name===t){e[s]=hl,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Wn="http://www.w3.org/1999/xhtml";const Vs={svg:"http://www.w3.org/2000/svg",xhtml:Wn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function xn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Vs.hasOwnProperty(t)?{space:Vs[t],local:e}:e}function ml(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Wn&&t.documentElement.namespaceURI===Wn?t.createElement(e):t.createElementNS(n,e)}}function gl(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ao(e){var t=xn(e);return(t.local?gl:ml)(t)}function bl(){}function ps(e){return e==null?bl:function(){return this.querySelector(e)}}function yl(e){typeof e!="function"&&(e=ps(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,c=s[o]=new Array(a),l,f,h=0;h<a;++h)(l=i[h])&&(f=e.call(l,l.__data__,h,i))&&("__data__"in l&&(f.__data__=l.__data__),c[h]=f);return new ce(s,this._parents)}function wl(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function vl(){return[]}function co(e){return e==null?vl:function(){return this.querySelectorAll(e)}}function Nl(e){return function(){return wl(e.apply(this,arguments))}}function jl(e){typeof e=="function"?e=Nl(e):e=co(e);for(var t=this._groups,n=t.length,s=[],o=[],i=0;i<n;++i)for(var a=t[i],c=a.length,l,f=0;f<c;++f)(l=a[f])&&(s.push(e.call(l,l.__data__,f,a)),o.push(l));return new ce(s,o)}function lo(e){return function(){return this.matches(e)}}function uo(e){return function(t){return t.matches(e)}}var Cl=Array.prototype.find;function zl(e){return function(){return Cl.call(this.children,e)}}function kl(){return this.firstElementChild}function Sl(e){return this.select(e==null?kl:zl(typeof e=="function"?e:uo(e)))}var El=Array.prototype.filter;function _l(){return Array.from(this.children)}function Ml(e){return function(){return El.call(this.children,e)}}function Il(e){return this.selectAll(e==null?_l:Ml(typeof e=="function"?e:uo(e)))}function Tl(e){typeof e!="function"&&(e=lo(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,c=s[o]=[],l,f=0;f<a;++f)(l=i[f])&&e.call(l,l.__data__,f,i)&&c.push(l);return new ce(s,this._parents)}function fo(e){return new Array(e.length)}function Al(){return new ce(this._enter||this._groups.map(fo),this._parents)}function nn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}nn.prototype={constructor:nn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Pl(e){return function(){return e}}function $l(e,t,n,s,o,i){for(var a=0,c,l=t.length,f=i.length;a<f;++a)(c=t[a])?(c.__data__=i[a],s[a]=c):n[a]=new nn(e,i[a]);for(;a<l;++a)(c=t[a])&&(o[a]=c)}function Dl(e,t,n,s,o,i,a){var c,l,f=new Map,h=t.length,d=i.length,u=new Array(h),p;for(c=0;c<h;++c)(l=t[c])&&(u[c]=p=a.call(l,l.__data__,c,t)+"",f.has(p)?o[c]=l:f.set(p,l));for(c=0;c<d;++c)p=a.call(e,i[c],c,i)+"",(l=f.get(p))?(s[c]=l,l.__data__=i[c],f.delete(p)):n[c]=new nn(e,i[c]);for(c=0;c<h;++c)(l=t[c])&&f.get(u[c])===l&&(o[c]=l)}function Ll(e){return e.__data__}function Rl(e,t){if(!arguments.length)return Array.from(this,Ll);var n=t?Dl:$l,s=this._parents,o=this._groups;typeof e!="function"&&(e=Pl(e));for(var i=o.length,a=new Array(i),c=new Array(i),l=new Array(i),f=0;f<i;++f){var h=s[f],d=o[f],u=d.length,p=Hl(e.call(h,h&&h.__data__,f,s)),x=p.length,b=c[f]=new Array(x),v=a[f]=new Array(x),y=l[f]=new Array(u);n(h,d,b,v,y,p,t);for(var m=0,g=0,w,C;m<x;++m)if(w=b[m]){for(m>=g&&(g=m+1);!(C=v[g])&&++g<x;);w._next=C||null}}return a=new ce(a,s),a._enter=c,a._exit=l,a}function Hl(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Ol(){return new ce(this._exit||this._groups.map(fo),this._parents)}function Bl(e,t,n){var s=this.enter(),o=this,i=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?i.remove():n(i),s&&o?s.merge(o).order():o}function Fl(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,o=n.length,i=s.length,a=Math.min(o,i),c=new Array(o),l=0;l<a;++l)for(var f=n[l],h=s[l],d=f.length,u=c[l]=new Array(d),p,x=0;x<d;++x)(p=f[x]||h[x])&&(u[x]=p);for(;l<o;++l)c[l]=n[l];return new ce(c,this._parents)}function Vl(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],o=s.length-1,i=s[o],a;--o>=0;)(a=s[o])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Yl(e){e||(e=Wl);function t(d,u){return d&&u?e(d.__data__,u.__data__):!d-!u}for(var n=this._groups,s=n.length,o=new Array(s),i=0;i<s;++i){for(var a=n[i],c=a.length,l=o[i]=new Array(c),f,h=0;h<c;++h)(f=a[h])&&(l[h]=f);l.sort(t)}return new ce(o,this._parents).order()}function Wl(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Xl(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Gl(){return Array.from(this)}function ql(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,i=s.length;o<i;++o){var a=s[o];if(a)return a}return null}function Ul(){let e=0;for(const t of this)++e;return e}function Kl(){return!this.node()}function Zl(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var o=t[n],i=0,a=o.length,c;i<a;++i)(c=o[i])&&e.call(c,c.__data__,i,o);return this}function Ql(e){return function(){this.removeAttribute(e)}}function Jl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ed(e,t){return function(){this.setAttribute(e,t)}}function td(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function nd(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function sd(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function rd(e,t){var n=xn(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?Jl:Ql:typeof t=="function"?n.local?sd:nd:n.local?td:ed)(n,t))}function ho(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function od(e){return function(){this.style.removeProperty(e)}}function id(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ad(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function cd(e,t,n){return arguments.length>1?this.each((t==null?od:typeof t=="function"?ad:id)(e,t,n??"")):Ke(this.node(),e)}function Ke(e,t){return e.style.getPropertyValue(t)||ho(e).getComputedStyle(e,null).getPropertyValue(t)}function ld(e){return function(){delete this[e]}}function dd(e,t){return function(){this[e]=t}}function ud(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function fd(e,t){return arguments.length>1?this.each((t==null?ld:typeof t=="function"?ud:dd)(e,t)):this.node()[e]}function po(e){return e.trim().split(/^|\s+/)}function xs(e){return e.classList||new xo(e)}function xo(e){this._node=e,this._names=po(e.getAttribute("class")||"")}xo.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function mo(e,t){for(var n=xs(e),s=-1,o=t.length;++s<o;)n.add(t[s])}function go(e,t){for(var n=xs(e),s=-1,o=t.length;++s<o;)n.remove(t[s])}function hd(e){return function(){mo(this,e)}}function pd(e){return function(){go(this,e)}}function xd(e,t){return function(){(t.apply(this,arguments)?mo:go)(this,e)}}function md(e,t){var n=po(e+"");if(arguments.length<2){for(var s=xs(this.node()),o=-1,i=n.length;++o<i;)if(!s.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?xd:t?hd:pd)(n,t))}function gd(){this.textContent=""}function bd(e){return function(){this.textContent=e}}function yd(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function wd(e){return arguments.length?this.each(e==null?gd:(typeof e=="function"?yd:bd)(e)):this.node().textContent}function vd(){this.innerHTML=""}function Nd(e){return function(){this.innerHTML=e}}function jd(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Cd(e){return arguments.length?this.each(e==null?vd:(typeof e=="function"?jd:Nd)(e)):this.node().innerHTML}function zd(){this.nextSibling&&this.parentNode.appendChild(this)}function kd(){return this.each(zd)}function Sd(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ed(){return this.each(Sd)}function _d(e){var t=typeof e=="function"?e:ao(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Md(){return null}function Id(e,t){var n=typeof e=="function"?e:ao(e),s=t==null?Md:typeof t=="function"?t:ps(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function Td(){var e=this.parentNode;e&&e.removeChild(this)}function Ad(){return this.each(Td)}function Pd(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $d(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dd(e){return this.select(e?$d:Pd)}function Ld(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Rd(e){return function(t){e.call(this,t,this.__data__)}}function Hd(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function Od(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,o=t.length,i;n<o;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++s]=i;++s?t.length=s:delete this.__on}}}function Bd(e,t,n){return function(){var s=this.__on,o,i=Rd(t);if(s){for(var a=0,c=s.length;a<c;++a)if((o=s[a]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),o.value=t;return}}this.addEventListener(e.type,i,n),o={type:e.type,name:e.name,value:t,listener:i,options:n},s?s.push(o):this.__on=[o]}}function Fd(e,t,n){var s=Hd(e+""),o,i=s.length,a;if(arguments.length<2){var c=this.node().__on;if(c){for(var l=0,f=c.length,h;l<f;++l)for(o=0,h=c[l];o<i;++o)if((a=s[o]).type===h.type&&a.name===h.name)return h.value}return}for(c=t?Bd:Od,o=0;o<i;++o)this.each(c(s[o],t,n));return this}function bo(e,t,n){var s=ho(e),o=s.CustomEvent;typeof o=="function"?o=new o(t,n):(o=s.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Vd(e,t){return function(){return bo(this,e,t)}}function Yd(e,t){return function(){return bo(this,e,t.apply(this,arguments))}}function Wd(e,t){return this.each((typeof t=="function"?Yd:Vd)(e,t))}function*Xd(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],o=0,i=s.length,a;o<i;++o)(a=s[o])&&(yield a)}var yo=[null];function ce(e,t){this._groups=e,this._parents=t}function zt(){return new ce([[document.documentElement]],yo)}function Gd(){return this}ce.prototype=zt.prototype={constructor:ce,select:yl,selectAll:jl,selectChild:Sl,selectChildren:Il,filter:Tl,data:Rl,enter:Al,exit:Ol,join:Bl,merge:Fl,selection:Gd,order:Vl,sort:Yl,call:Xl,nodes:Gl,node:ql,size:Ul,empty:Kl,each:Zl,attr:rd,style:cd,property:fd,classed:md,text:wd,html:Cd,raise:kd,lower:Ed,append:_d,insert:Id,remove:Ad,clone:Dd,datum:Ld,on:Fd,dispatch:Wd,[Symbol.iterator]:Xd};function ae(e){return typeof e=="string"?new ce([[document.querySelector(e)]],[document.documentElement]):new ce([[e]],yo)}function qd(e){let t;for(;t=e.sourceEvent;)e=t;return e}function le(e,t){if(e=qd(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ud={passive:!1},bt={capture:!0,passive:!1};function _n(e){e.stopImmediatePropagation()}function qe(e){e.preventDefault(),e.stopImmediatePropagation()}function wo(e){var t=e.document.documentElement,n=ae(e).on("dragstart.drag",qe,bt);"onselectstart"in t?n.on("selectstart.drag",qe,bt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function vo(e,t){var n=e.document.documentElement,s=ae(e).on("dragstart.drag",null);t&&(s.on("click.drag",qe,bt),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const At=e=>()=>e;function Xn(e,{sourceEvent:t,subject:n,target:s,identifier:o,active:i,x:a,y:c,dx:l,dy:f,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:h}})}Xn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Kd(e){return!e.ctrlKey&&!e.button}function Zd(){return this.parentNode}function Qd(e,t){return t??{x:e.x,y:e.y}}function Jd(){return navigator.maxTouchPoints||"ontouchstart"in this}function No(){var e=Kd,t=Zd,n=Qd,s=Jd,o={},i=pn("start","drag","end"),a=0,c,l,f,h,d=0;function u(w){w.on("mousedown.drag",p).filter(s).on("touchstart.drag",v).on("touchmove.drag",y,Ud).on("touchend.drag touchcancel.drag",m).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,C){if(!(h||!e.call(this,w,C))){var z=g(this,t.call(this,w,C),w,C,"mouse");z&&(ae(w.view).on("mousemove.drag",x,bt).on("mouseup.drag",b,bt),wo(w.view),_n(w),f=!1,c=w.clientX,l=w.clientY,z("start",w))}}function x(w){if(qe(w),!f){var C=w.clientX-c,z=w.clientY-l;f=C*C+z*z>d}o.mouse("drag",w)}function b(w){ae(w.view).on("mousemove.drag mouseup.drag",null),vo(w.view,f),qe(w),o.mouse("end",w)}function v(w,C){if(e.call(this,w,C)){var z=w.changedTouches,k=t.call(this,w,C),P=z.length,$,B;for($=0;$<P;++$)(B=g(this,k,w,C,z[$].identifier,z[$]))&&(_n(w),B("start",w,z[$]))}}function y(w){var C=w.changedTouches,z=C.length,k,P;for(k=0;k<z;++k)(P=o[C[k].identifier])&&(qe(w),P("drag",w,C[k]))}function m(w){var C=w.changedTouches,z=C.length,k,P;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),k=0;k<z;++k)(P=o[C[k].identifier])&&(_n(w),P("end",w,C[k]))}function g(w,C,z,k,P,$){var B=i.copy(),M=le($||z,C),A,H,j;if((j=n.call(w,new Xn("beforestart",{sourceEvent:z,target:u,identifier:P,active:a,x:M[0],y:M[1],dx:0,dy:0,dispatch:B}),k))!=null)return A=j.x-M[0]||0,H=j.y-M[1]||0,function T(S,I,E){var _=M,L;switch(S){case"start":o[P]=T,L=a++;break;case"end":delete o[P],--a;case"drag":M=le(E||I,C),L=a;break}B.call(S,w,new Xn(S,{sourceEvent:I,subject:j,target:u,identifier:P,active:L,x:M[0]+A,y:M[1]+H,dx:M[0]-_[0],dy:M[1]-_[1],dispatch:B}),k)}}return u.filter=function(w){return arguments.length?(e=typeof w=="function"?w:At(!!w),u):e},u.container=function(w){return arguments.length?(t=typeof w=="function"?w:At(w),u):t},u.subject=function(w){return arguments.length?(n=typeof w=="function"?w:At(w),u):n},u.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:At(!!w),u):s},u.on=function(){var w=i.on.apply(i,arguments);return w===i?u:w},u.clickDistance=function(w){return arguments.length?(d=(w=+w)*w,u):Math.sqrt(d)},u}var Ze=0,xt=0,dt=0,jo=1e3,sn,mt,rn=0,Le=0,mn=0,yt=typeof performance=="object"&&performance.now?performance:Date,Co=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ms(){return Le||(Co(eu),Le=yt.now()+mn)}function eu(){Le=0}function on(){this._call=this._time=this._next=null}on.prototype=zo.prototype={constructor:on,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ms():+n)+(t==null?0:+t),!this._next&&mt!==this&&(mt?mt._next=this:sn=this,mt=this),this._call=e,this._time=n,Gn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Gn())}};function zo(e,t,n){var s=new on;return s.restart(e,t,n),s}function tu(){ms(),++Ze;for(var e=sn,t;e;)(t=Le-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function Ys(){Le=(rn=yt.now())+mn,Ze=xt=0;try{tu()}finally{Ze=0,su(),Le=0}}function nu(){var e=yt.now(),t=e-rn;t>jo&&(mn-=t,rn=e)}function su(){for(var e,t=sn,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:sn=n);mt=e,Gn(s)}function Gn(e){if(!Ze){xt&&(xt=clearTimeout(xt));var t=e-Le;t>24?(e<1/0&&(xt=setTimeout(Ys,e-yt.now()-mn)),dt&&(dt=clearInterval(dt))):(dt||(rn=yt.now(),dt=setInterval(nu,jo)),Ze=1,Co(Ys))}}function Ws(e,t,n){var s=new on;return t=t==null?0:+t,s.restart(o=>{s.stop(),e(o+t)},t,n),s}var ru=pn("start","end","cancel","interrupt"),ou=[],ko=0,Xs=1,qn=2,Kt=3,Gs=4,Un=5,Zt=6;function gn(e,t,n,s,o,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;iu(e,n,{name:t,index:s,group:o,on:ru,tween:ou,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ko})}function gs(e,t){var n=pe(e,t);if(n.state>ko)throw new Error("too late; already scheduled");return n}function ye(e,t){var n=pe(e,t);if(n.state>Kt)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function iu(e,t,n){var s=e.__transition,o;s[t]=n,n.timer=zo(i,0,n.time);function i(f){n.state=Xs,n.timer.restart(a,n.delay,n.time),n.delay<=f&&a(f-n.delay)}function a(f){var h,d,u,p;if(n.state!==Xs)return l();for(h in s)if(p=s[h],p.name===n.name){if(p.state===Kt)return Ws(a);p.state===Gs?(p.state=Zt,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete s[h]):+h<t&&(p.state=Zt,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete s[h])}if(Ws(function(){n.state===Kt&&(n.state=Gs,n.timer.restart(c,n.delay,n.time),c(f))}),n.state=qn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===qn){for(n.state=Kt,o=new Array(u=n.tween.length),h=0,d=-1;h<u;++h)(p=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(o[++d]=p);o.length=d+1}}function c(f){for(var h=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(l),n.state=Un,1),d=-1,u=o.length;++d<u;)o[d].call(e,h);n.state===Un&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Zt,n.timer.stop(),delete s[t];for(var f in s)return;delete e.__transition}}function Qt(e,t){var n=e.__transition,s,o,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((s=n[a]).name!==t){i=!1;continue}o=s.state>qn&&s.state<Un,s.state=Zt,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[a]}i&&delete e.__transition}}function au(e){return this.each(function(){Qt(this,e)})}function cu(e,t){var n,s;return function(){var o=ye(this,e),i=o.tween;if(i!==n){s=n=i;for(var a=0,c=s.length;a<c;++a)if(s[a].name===t){s=s.slice(),s.splice(a,1);break}}o.tween=s}}function lu(e,t,n){var s,o;if(typeof n!="function")throw new Error;return function(){var i=ye(this,e),a=i.tween;if(a!==s){o=(s=a).slice();for(var c={name:t,value:n},l=0,f=o.length;l<f;++l)if(o[l].name===t){o[l]=c;break}l===f&&o.push(c)}i.tween=o}}function du(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=pe(this.node(),n).tween,o=0,i=s.length,a;o<i;++o)if((a=s[o]).name===e)return a.value;return null}return this.each((t==null?cu:lu)(n,e,t))}function bs(e,t,n){var s=e._id;return e.each(function(){var o=ye(this,s);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return pe(o,s).value[t]}}function So(e,t){var n;return(typeof t=="number"?cc:t instanceof Hs?Os:(n=Hs(t))?(t=n,Os):lc)(e,t)}function uu(e){return function(){this.removeAttribute(e)}}function fu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hu(e,t,n){var s,o=n+"",i;return function(){var a=this.getAttribute(e);return a===o?null:a===s?i:i=t(s=a,n)}}function pu(e,t,n){var s,o=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===o?null:a===s?i:i=t(s=a,n)}}function xu(e,t,n){var s,o,i;return function(){var a,c=n(this),l;return c==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=c+"",a===l?null:a===s&&l===o?i:(o=l,i=t(s=a,c)))}}function mu(e,t,n){var s,o,i;return function(){var a,c=n(this),l;return c==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=c+"",a===l?null:a===s&&l===o?i:(o=l,i=t(s=a,c)))}}function gu(e,t){var n=xn(e),s=n==="transform"?dc:So;return this.attrTween(e,typeof t=="function"?(n.local?mu:xu)(n,s,bs(this,"attr."+e,t)):t==null?(n.local?fu:uu)(n):(n.local?pu:hu)(n,s,t))}function bu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function yu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function wu(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&yu(e,i)),n}return o._value=t,o}function vu(e,t){var n,s;function o(){var i=t.apply(this,arguments);return i!==s&&(n=(s=i)&&bu(e,i)),n}return o._value=t,o}function Nu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var s=xn(e);return this.tween(n,(s.local?wu:vu)(s,t))}function ju(e,t){return function(){gs(this,e).delay=+t.apply(this,arguments)}}function Cu(e,t){return t=+t,function(){gs(this,e).delay=t}}function zu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ju:Cu)(t,e)):pe(this.node(),t).delay}function ku(e,t){return function(){ye(this,e).duration=+t.apply(this,arguments)}}function Su(e,t){return t=+t,function(){ye(this,e).duration=t}}function Eu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ku:Su)(t,e)):pe(this.node(),t).duration}function _u(e,t){if(typeof t!="function")throw new Error;return function(){ye(this,e).ease=t}}function Mu(e){var t=this._id;return arguments.length?this.each(_u(t,e)):pe(this.node(),t).ease}function Iu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ye(this,e).ease=n}}function Tu(e){if(typeof e!="function")throw new Error;return this.each(Iu(this._id,e))}function Au(e){typeof e!="function"&&(e=lo(e));for(var t=this._groups,n=t.length,s=new Array(n),o=0;o<n;++o)for(var i=t[o],a=i.length,c=s[o]=[],l,f=0;f<a;++f)(l=i[f])&&e.call(l,l.__data__,f,i)&&c.push(l);return new je(s,this._parents,this._name,this._id)}function Pu(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,o=n.length,i=Math.min(s,o),a=new Array(s),c=0;c<i;++c)for(var l=t[c],f=n[c],h=l.length,d=a[c]=new Array(h),u,p=0;p<h;++p)(u=l[p]||f[p])&&(d[p]=u);for(;c<s;++c)a[c]=t[c];return new je(a,this._parents,this._name,this._id)}function $u(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Du(e,t,n){var s,o,i=$u(t)?gs:ye;return function(){var a=i(this,e),c=a.on;c!==s&&(o=(s=c).copy()).on(t,n),a.on=o}}function Lu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(Du(n,e,t))}function Ru(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Hu(){return this.on("end.remove",Ru(this._id))}function Ou(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ps(e));for(var s=this._groups,o=s.length,i=new Array(o),a=0;a<o;++a)for(var c=s[a],l=c.length,f=i[a]=new Array(l),h,d,u=0;u<l;++u)(h=c[u])&&(d=e.call(h,h.__data__,u,c))&&("__data__"in h&&(d.__data__=h.__data__),f[u]=d,gn(f[u],t,n,u,f,pe(h,n)));return new je(i,this._parents,t,n)}function Bu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=co(e));for(var s=this._groups,o=s.length,i=[],a=[],c=0;c<o;++c)for(var l=s[c],f=l.length,h,d=0;d<f;++d)if(h=l[d]){for(var u=e.call(h,h.__data__,d,l),p,x=pe(h,n),b=0,v=u.length;b<v;++b)(p=u[b])&&gn(p,t,n,b,u,x);i.push(u),a.push(h)}return new je(i,a,t,n)}var Fu=zt.prototype.constructor;function Vu(){return new Fu(this._groups,this._parents)}function Yu(e,t){var n,s,o;return function(){var i=Ke(this,e),a=(this.style.removeProperty(e),Ke(this,e));return i===a?null:i===n&&a===s?o:o=t(n=i,s=a)}}function Eo(e){return function(){this.style.removeProperty(e)}}function Wu(e,t,n){var s,o=n+"",i;return function(){var a=Ke(this,e);return a===o?null:a===s?i:i=t(s=a,n)}}function Xu(e,t,n){var s,o,i;return function(){var a=Ke(this,e),c=n(this),l=c+"";return c==null&&(l=c=(this.style.removeProperty(e),Ke(this,e))),a===l?null:a===s&&l===o?i:(o=l,i=t(s=a,c))}}function Gu(e,t){var n,s,o,i="style."+t,a="end."+i,c;return function(){var l=ye(this,e),f=l.on,h=l.value[i]==null?c||(c=Eo(t)):void 0;(f!==n||o!==h)&&(s=(n=f).copy()).on(a,o=h),l.on=s}}function qu(e,t,n){var s=(e+="")=="transform"?uc:So;return t==null?this.styleTween(e,Yu(e,s)).on("end.style."+e,Eo(e)):typeof t=="function"?this.styleTween(e,Xu(e,s,bs(this,"style."+e,t))).each(Gu(this._id,e)):this.styleTween(e,Wu(e,s,t),n).on("end.style."+e,null)}function Uu(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Ku(e,t,n){var s,o;function i(){var a=t.apply(this,arguments);return a!==o&&(s=(o=a)&&Uu(e,a,n)),s}return i._value=t,i}function Zu(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,Ku(e,t,n??""))}function Qu(e){return function(){this.textContent=e}}function Ju(e){return function(){var t=e(this);this.textContent=t??""}}function ef(e){return this.tween("text",typeof e=="function"?Ju(bs(this,"text",e)):Qu(e==null?"":e+""))}function tf(e){return function(t){this.textContent=e.call(this,t)}}function nf(e){var t,n;function s(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&tf(o)),t}return s._value=e,s}function sf(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,nf(e))}function rf(){for(var e=this._name,t=this._id,n=_o(),s=this._groups,o=s.length,i=0;i<o;++i)for(var a=s[i],c=a.length,l,f=0;f<c;++f)if(l=a[f]){var h=pe(l,t);gn(l,e,n,f,a,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new je(s,this._parents,e,n)}function of(){var e,t,n=this,s=n._id,o=n.size();return new Promise(function(i,a){var c={value:a},l={value:function(){--o===0&&i()}};n.each(function(){var f=ye(this,s),h=f.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(l)),f.on=t}),o===0&&i()})}var af=0;function je(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function _o(){return++af}var ve=zt.prototype;je.prototype={constructor:je,select:Ou,selectAll:Bu,selectChild:ve.selectChild,selectChildren:ve.selectChildren,filter:Au,merge:Pu,selection:Vu,transition:rf,call:ve.call,nodes:ve.nodes,node:ve.node,size:ve.size,empty:ve.empty,each:ve.each,on:Lu,attr:gu,attrTween:Nu,style:qu,styleTween:Zu,text:ef,textTween:sf,remove:Hu,tween:du,delay:zu,duration:Eu,ease:Mu,easeVarying:Tu,end:of,[Symbol.iterator]:ve[Symbol.iterator]};function cf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lf={time:null,delay:0,duration:250,ease:cf};function df(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function uf(e){var t,n;e instanceof je?(t=e._id,e=e._name):(t=_o(),(n=lf).time=ms(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,i=0;i<o;++i)for(var a=s[i],c=a.length,l,f=0;f<c;++f)(l=a[f])&&gn(l,e,t,f,a,n||df(l,t));return new je(s,this._parents,e,t)}zt.prototype.interrupt=au;zt.prototype.transition=uf;const Pt=e=>()=>e;function ff(e,{sourceEvent:t,target:n,transform:s,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:s,enumerable:!0,configurable:!0},_:{value:o}})}function Ne(e,t,n){this.k=e,this.x=t,this.y=n}Ne.prototype={constructor:Ne,scale:function(e){return e===1?this:new Ne(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Ne(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var bn=new Ne(1,0,0);Mo.prototype=Ne.prototype;function Mo(e){for(;!e.__zoom;)if(!(e=e.parentNode))return bn;return e.__zoom}function Mn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function hf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function pf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function qs(){return this.__zoom||bn}function xf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function mf(){return navigator.maxTouchPoints||"ontouchstart"in this}function gf(e,t,n){var s=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function Io(){var e=hf,t=pf,n=gf,s=xf,o=mf,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],c=250,l=qt,f=pn("start","zoom","end"),h,d,u,p=500,x=150,b=0,v=10;function y(j){j.property("__zoom",qs).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",B).filter(o).on("touchstart.zoom",M).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(j,T,S,I){var E=j.selection?j.selection():j;E.property("__zoom",qs),j!==E?C(j,T,S,I):E.interrupt().each(function(){z(this,arguments).event(I).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},y.scaleBy=function(j,T,S,I){y.scaleTo(j,function(){var E=this.__zoom.k,_=typeof T=="function"?T.apply(this,arguments):T;return E*_},S,I)},y.scaleTo=function(j,T,S,I){y.transform(j,function(){var E=t.apply(this,arguments),_=this.__zoom,L=S==null?w(E):typeof S=="function"?S.apply(this,arguments):S,R=_.invert(L),D=typeof T=="function"?T.apply(this,arguments):T;return n(g(m(_,D),L,R),E,a)},S,I)},y.translateBy=function(j,T,S,I){y.transform(j,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),a)},null,I)},y.translateTo=function(j,T,S,I,E){y.transform(j,function(){var _=t.apply(this,arguments),L=this.__zoom,R=I==null?w(_):typeof I=="function"?I.apply(this,arguments):I;return n(bn.translate(R[0],R[1]).scale(L.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof S=="function"?-S.apply(this,arguments):-S),_,a)},I,E)};function m(j,T){return T=Math.max(i[0],Math.min(i[1],T)),T===j.k?j:new Ne(T,j.x,j.y)}function g(j,T,S){var I=T[0]-S[0]*j.k,E=T[1]-S[1]*j.k;return I===j.x&&E===j.y?j:new Ne(j.k,I,E)}function w(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function C(j,T,S,I){j.on("start.zoom",function(){z(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(I).end()}).tween("zoom",function(){var E=this,_=arguments,L=z(E,_).event(I),R=t.apply(E,_),D=S==null?w(R):typeof S=="function"?S.apply(E,_):S,V=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),W=E.__zoom,G=typeof T=="function"?T.apply(E,_):T,K=l(W.invert(D).concat(V/W.k),G.invert(D).concat(V/G.k));return function(F){if(F===1)F=G;else{var O=K(F),Y=V/O[2];F=new Ne(Y,D[0]-O[0]*Y,D[1]-O[1]*Y)}L.zoom(null,F)}})}function z(j,T,S){return!S&&j.__zooming||new k(j,T)}function k(j,T){this.that=j,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,T),this.taps=0}k.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,T){return this.mouse&&j!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var T=ae(this.that).datum();f.call(j,this.that,new ff(j,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:f}),T)}};function P(j,...T){if(!e.apply(this,arguments))return;var S=z(this,T).event(j),I=this.__zoom,E=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,s.apply(this,arguments)))),_=le(j);if(S.wheel)(S.mouse[0][0]!==_[0]||S.mouse[0][1]!==_[1])&&(S.mouse[1]=I.invert(S.mouse[0]=_)),clearTimeout(S.wheel);else{if(I.k===E)return;S.mouse=[_,I.invert(_)],Qt(this),S.start()}ut(j),S.wheel=setTimeout(L,x),S.zoom("mouse",n(g(m(I,E),S.mouse[0],S.mouse[1]),S.extent,a));function L(){S.wheel=null,S.end()}}function $(j,...T){if(u||!e.apply(this,arguments))return;var S=j.currentTarget,I=z(this,T,!0).event(j),E=ae(j.view).on("mousemove.zoom",D,!0).on("mouseup.zoom",V,!0),_=le(j,S),L=j.clientX,R=j.clientY;wo(j.view),Mn(j),I.mouse=[_,this.__zoom.invert(_)],Qt(this),I.start();function D(W){if(ut(W),!I.moved){var G=W.clientX-L,K=W.clientY-R;I.moved=G*G+K*K>b}I.event(W).zoom("mouse",n(g(I.that.__zoom,I.mouse[0]=le(W,S),I.mouse[1]),I.extent,a))}function V(W){E.on("mousemove.zoom mouseup.zoom",null),vo(W.view,I.moved),ut(W),I.event(W).end()}}function B(j,...T){if(e.apply(this,arguments)){var S=this.__zoom,I=le(j.changedTouches?j.changedTouches[0]:j,this),E=S.invert(I),_=S.k*(j.shiftKey?.5:2),L=n(g(m(S,_),I,E),t.apply(this,T),a);ut(j),c>0?ae(this).transition().duration(c).call(C,L,I,j):ae(this).call(y.transform,L,I,j)}}function M(j,...T){if(e.apply(this,arguments)){var S=j.touches,I=S.length,E=z(this,T,j.changedTouches.length===I).event(j),_,L,R,D;for(Mn(j),L=0;L<I;++L)R=S[L],D=le(R,this),D=[D,this.__zoom.invert(D),R.identifier],E.touch0?!E.touch1&&E.touch0[2]!==D[2]&&(E.touch1=D,E.taps=0):(E.touch0=D,_=!0,E.taps=1+!!h);h&&(h=clearTimeout(h)),_&&(E.taps<2&&(d=D[0],h=setTimeout(function(){h=null},p)),Qt(this),E.start())}}function A(j,...T){if(this.__zooming){var S=z(this,T).event(j),I=j.changedTouches,E=I.length,_,L,R,D;for(ut(j),_=0;_<E;++_)L=I[_],R=le(L,this),S.touch0&&S.touch0[2]===L.identifier?S.touch0[0]=R:S.touch1&&S.touch1[2]===L.identifier&&(S.touch1[0]=R);if(L=S.that.__zoom,S.touch1){var V=S.touch0[0],W=S.touch0[1],G=S.touch1[0],K=S.touch1[1],F=(F=G[0]-V[0])*F+(F=G[1]-V[1])*F,O=(O=K[0]-W[0])*O+(O=K[1]-W[1])*O;L=m(L,Math.sqrt(F/O)),R=[(V[0]+G[0])/2,(V[1]+G[1])/2],D=[(W[0]+K[0])/2,(W[1]+K[1])/2]}else if(S.touch0)R=S.touch0[0],D=S.touch0[1];else return;S.zoom("touch",n(g(L,R,D),S.extent,a))}}function H(j,...T){if(this.__zooming){var S=z(this,T).event(j),I=j.changedTouches,E=I.length,_,L;for(Mn(j),u&&clearTimeout(u),u=setTimeout(function(){u=null},p),_=0;_<E;++_)L=I[_],S.touch0&&S.touch0[2]===L.identifier?delete S.touch0:S.touch1&&S.touch1[2]===L.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(L=le(L,this),Math.hypot(d[0]-L[0],d[1]-L[1])<v)){var R=ae(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return y.wheelDelta=function(j){return arguments.length?(s=typeof j=="function"?j:Pt(+j),y):s},y.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Pt(!!j),y):e},y.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Pt(!!j),y):o},y.extent=function(j){return arguments.length?(t=typeof j=="function"?j:Pt([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),y):t},y.scaleExtent=function(j){return arguments.length?(i[0]=+j[0],i[1]=+j[1],y):[i[0],i[1]]},y.translateExtent=function(j){return arguments.length?(a[0][0]=+j[0][0],a[1][0]=+j[1][0],a[0][1]=+j[0][1],a[1][1]=+j[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(j){return arguments.length?(n=j,y):n},y.duration=function(j){return arguments.length?(c=+j,y):c},y.interpolate=function(j){return arguments.length?(l=j,y):l},y.on=function(){var j=f.on.apply(f,arguments);return j===f?y:j},y.clickDistance=function(j){return arguments.length?(b=(j=+j)*j,y):Math.sqrt(b)},y.tapDistance=function(j){return arguments.length?(v=+j,y):v},y}const ge={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:s})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:s}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},wt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],To=["Enter"," ","Escape"],Ao={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Qe;(function(e){e.Strict="strict",e.Loose="loose"})(Qe||(Qe={}));var $e;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})($e||($e={}));var vt;(function(e){e.Partial="partial",e.Full="full"})(vt||(vt={}));const Po={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Me;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Me||(Me={}));var an;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(an||(an={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Us={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function $o(e){return e===null?null:e?"valid":"invalid"}const Do=e=>"id"in e&&"source"in e&&"target"in e,bf=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),ys=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),kt=(e,t=[0,0])=>{const{width:n,height:s}=ze(e),o=e.origin??t,i=n*o[0],a=s*o[1];return{x:e.position.x-i,y:e.position.y-a}},yf=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,o)=>{const i=typeof o=="string";let a=!t.nodeLookup&&!i?o:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(o):ys(o)?o:t.nodeLookup.get(o.id));const c=a?cn(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return yn(s,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return wn(n)},St=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},s=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=yn(n,cn(o)),s=!0)}),s?wn(n):{x:0,y:0,width:0,height:0}},ws=(e,t,[n,s,o]=[0,0,1],i=!1,a=!1)=>{const c={..._t(t,[n,s,o]),width:t.width/o,height:t.height/o},l=[];for(const f of e.values()){const{measured:h,selectable:d=!0,hidden:u=!1}=f;if(a&&!d||u)continue;const p=h.width??f.width??f.initialWidth??null,x=h.height??f.height??f.initialHeight??null,b=Nt(c,et(f)),v=(p??0)*(x??0),y=i&&b>0;(!f.internals.handleBounds||y||b>=v||f.dragging)&&l.push(f)}return l},wf=(e,t)=>{const n=new Set;return e.forEach(s=>{n.add(s.id)}),t.filter(s=>n.has(s.source)||n.has(s.target))};function vf(e,t){const n=new Map,s=t!=null&&t.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!o.hidden)&&(!s||s.has(o.id))&&n.set(o.id,o)}),n}async function Nf({nodes:e,width:t,height:n,panZoom:s,minZoom:o,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const c=vf(e,a),l=St(c),f=vs(l,t,n,(a==null?void 0:a.minZoom)??o,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await s.setViewport(f,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function Lo({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:s=[0,0],nodeExtent:o,onError:i}){const a=n.get(e),c=a.parentId?n.get(a.parentId):void 0,{x:l,y:f}=c?c.internals.positionAbsolute:{x:0,y:0},h=a.origin??s;let d=a.extent||o;if(a.extent==="parent"&&!a.expandParent)if(!c)i==null||i("005",ge.error005());else{const p=c.measured.width,x=c.measured.height;p&&x&&(d=[[l,f],[l+p,f+x]])}else c&&tt(a.extent)&&(d=[[a.extent[0][0]+l,a.extent[0][1]+f],[a.extent[1][0]+l,a.extent[1][1]+f]]);const u=tt(d)?Re(t,d,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",ge.error015())),{position:{x:u.x-l+(a.measured.width??0)*h[0],y:u.y-f+(a.measured.height??0)*h[1]},positionAbsolute:u}}async function jf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:s,onBeforeDelete:o}){const i=new Set(e.map(u=>u.id)),a=[];for(const u of n){if(u.deletable===!1)continue;const p=i.has(u.id),x=!p&&u.parentId&&a.find(b=>b.id===u.parentId);(p||x)&&a.push(u)}const c=new Set(t.map(u=>u.id)),l=s.filter(u=>u.deletable!==!1),h=wf(a,l);for(const u of l)c.has(u.id)&&!h.find(x=>x.id===u.id)&&h.push(u);if(!o)return{edges:h,nodes:a};const d=await o({nodes:a,edges:h});return typeof d=="boolean"?d?{edges:h,nodes:a}:{edges:[],nodes:[]}:d}const Je=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Re=(e={x:0,y:0},t,n)=>({x:Je(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Je(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ro(e,t,n){const{width:s,height:o}=ze(n),{x:i,y:a}=n.internals.positionAbsolute;return Re(e,[[i,a],[i+s,a+o]],t)}const Ks=(e,t,n)=>e<t?Je(Math.abs(e-t),1,t)/t:e>n?-Je(Math.abs(e-n),1,t)/t:0,Ho=(e,t,n=15,s=40)=>{const o=Ks(e.x,s,t.width-s)*n,i=Ks(e.y,s,t.height-s)*n;return[o,i]},yn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Kn=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),wn=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),et=(e,t=[0,0])=>{var o,i;const{x:n,y:s}=ys(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:s,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},cn=(e,t=[0,0])=>{var o,i;const{x:n,y:s}=ys(e)?e.internals.positionAbsolute:kt(e,t);return{x:n,y:s,x2:n+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:s+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},Oo=(e,t)=>wn(yn(Kn(e),Kn(t))),Nt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},Zs=e=>ue(e.width)&&ue(e.height)&&ue(e.x)&&ue(e.y),ue=e=>!isNaN(e)&&isFinite(e),Cf=(e,t)=>{},Et=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),_t=({x:e,y:t},[n,s,o],i=!1,a=[1,1])=>{const c={x:(e-n)/o,y:(t-s)/o};return i?Et(c,a):c},ln=({x:e,y:t},[n,s,o])=>({x:e*o+n,y:t*o+s});function Be(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function zf(e,t,n){if(typeof e=="string"||typeof e=="number"){const s=Be(e,n),o=Be(e,t);return{top:s,right:o,bottom:s,left:o,x:o*2,y:s*2}}if(typeof e=="object"){const s=Be(e.top??e.y??0,n),o=Be(e.bottom??e.y??0,n),i=Be(e.left??e.x??0,t),a=Be(e.right??e.x??0,t);return{top:s,right:a,bottom:o,left:i,x:i+a,y:s+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function kf(e,t,n,s,o,i){const{x:a,y:c}=ln(e,[t,n,s]),{x:l,y:f}=ln({x:e.x+e.width,y:e.y+e.height},[t,n,s]),h=o-l,d=i-f;return{left:Math.floor(a),top:Math.floor(c),right:Math.floor(h),bottom:Math.floor(d)}}const vs=(e,t,n,s,o,i)=>{const a=zf(i,t,n),c=(t-a.x)/e.width,l=(n-a.y)/e.height,f=Math.min(c,l),h=Je(f,s,o),d=e.x+e.width/2,u=e.y+e.height/2,p=t/2-d*h,x=n/2-u*h,b=kf(e,p,x,h,t,n),v={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:p-v.left+v.right,y:x-v.top+v.bottom,zoom:h}},jt=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function tt(e){return e!=null&&e!=="parent"}function ze(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Bo(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Fo(e,t={width:0,height:0},n,s,o){const i={...e},a=s.get(n);if(a){const c=a.origin||o;i.x+=a.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Qs(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Sf(){let e,t;return{promise:new Promise((s,o)=>{e=s,t=o}),resolve:e,reject:t}}function Ef(e){return{...Ao,...e||{}}}function gt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:s,containerBounds:o}){const{x:i,y:a}=fe(e),c=_t({x:i-((o==null?void 0:o.left)??0),y:a-((o==null?void 0:o.top)??0)},s),{x:l,y:f}=n?Et(c,t):c;return{xSnapped:l,ySnapped:f,...c}}const Ns=e=>({width:e.offsetWidth,height:e.offsetHeight}),Vo=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},_f=["INPUT","SELECT","TEXTAREA"];function Yo(e){var s,o;const t=((o=(s=e.composedPath)==null?void 0:s.call(e))==null?void 0:o[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:_f.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Wo=e=>"clientX"in e,fe=(e,t)=>{var i,a;const n=Wo(e),s=n?e.clientX:(i=e.touches)==null?void 0:i[0].clientX,o=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:o-((t==null?void 0:t.top)??0)}},Js=(e,t,n,s,o)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:o,position:a.getAttribute("data-handlepos"),x:(c.left-n.left)/s,y:(c.top-n.top)/s,...Ns(a)}})};function Xo({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:o,sourceControlY:i,targetControlX:a,targetControlY:c}){const l=e*.125+o*.375+a*.375+n*.125,f=t*.125+i*.375+c*.375+s*.125,h=Math.abs(l-e),d=Math.abs(f-t);return[l,f,h,d]}function $t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function er({pos:e,x1:t,y1:n,x2:s,y2:o,c:i}){switch(e){case X.Left:return[t-$t(t-s,i),n];case X.Right:return[t+$t(s-t,i),n];case X.Top:return[t,n-$t(n-o,i)];case X.Bottom:return[t,n+$t(o-n,i)]}}function Go({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:s,targetY:o,targetPosition:i=X.Top,curvature:a=.25}){const[c,l]=er({pos:n,x1:e,y1:t,x2:s,y2:o,c:a}),[f,h]=er({pos:i,x1:s,y1:o,x2:e,y2:t,c:a}),[d,u,p,x]=Xo({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:c,sourceControlY:l,targetControlX:f,targetControlY:h});return[`M${e},${t} C${c},${l} ${f},${h} ${s},${o}`,d,u,p,x]}function qo({sourceX:e,sourceY:t,targetX:n,targetY:s}){const o=Math.abs(n-e)/2,i=n<e?n+o:n-o,a=Math.abs(s-t)/2,c=s<t?s+a:s-a;return[i,c,o,a]}function Mf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:s=0,elevateOnSelect:o=!1,zIndexMode:i="basic"}){if(i==="manual")return s;const a=o&&n?s+1e3:s,c=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return a+c}function If({sourceNode:e,targetNode:t,width:n,height:s,transform:o}){const i=yn(cn(e),cn(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:s/o[2]};return Nt(a,wn(i))>0}const Tf=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`xy-edge__${e}${t||""}-${n}${s||""}`,Af=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Pf=(e,t,n={})=>{if(!e.source||!e.target)return t;const s=n.getEdgeId||Tf;let o;return Do(e)?o={...e}:o={...e,id:s(e)},Af(o,t)?t:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,t.concat(o))};function Uo({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[o,i,a,c]=qo({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,o,i,a,c]}const tr={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},$f=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},nr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Df({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:s=X.Top,center:o,offset:i,stepPosition:a}){const c=tr[t],l=tr[s],f={x:e.x+c.x*i,y:e.y+c.y*i},h={x:n.x+l.x*i,y:n.y+l.y*i},d=$f({source:f,sourcePosition:t,target:h}),u=d.x!==0?"x":"y",p=d[u];let x=[],b,v;const y={x:0,y:0},m={x:0,y:0},[,,g,w]=qo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[u]*l[u]===-1){u==="x"?(b=o.x??f.x+(h.x-f.x)*a,v=o.y??(f.y+h.y)/2):(b=o.x??(f.x+h.x)/2,v=o.y??f.y+(h.y-f.y)*a);const z=[{x:b,y:f.y},{x:b,y:h.y}],k=[{x:f.x,y:v},{x:h.x,y:v}];c[u]===p?x=u==="x"?z:k:x=u==="x"?k:z}else{const z=[{x:f.x,y:h.y}],k=[{x:h.x,y:f.y}];if(u==="x"?x=c.x===p?k:z:x=c.y===p?z:k,t===s){const A=Math.abs(e[u]-n[u]);if(A<=i){const H=Math.min(i-1,i-A);c[u]===p?y[u]=(f[u]>e[u]?-1:1)*H:m[u]=(h[u]>n[u]?-1:1)*H}}if(t!==s){const A=u==="x"?"y":"x",H=c[u]===l[A],j=f[A]>h[A],T=f[A]<h[A];(c[u]===1&&(!H&&j||H&&T)||c[u]!==1&&(!H&&T||H&&j))&&(x=u==="x"?z:k)}const P={x:f.x+y.x,y:f.y+y.y},$={x:h.x+m.x,y:h.y+m.y},B=Math.max(Math.abs(P.x-x[0].x),Math.abs($.x-x[0].x)),M=Math.max(Math.abs(P.y-x[0].y),Math.abs($.y-x[0].y));B>=M?(b=(P.x+$.x)/2,v=x[0].y):(b=x[0].x,v=(P.y+$.y)/2)}return[[e,{x:f.x+y.x,y:f.y+y.y},...x,{x:h.x+m.x,y:h.y+m.y},n],b,v,g,w]}function Lf(e,t,n,s){const o=Math.min(nr(e,t)/2,nr(t,n)/2,s),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const f=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${i+o*f},${a}Q ${i},${a} ${i},${a+o*h}`}const c=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${a+o*l}Q ${i},${a} ${i+o*c},${a}`}function dn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:s,targetY:o,targetPosition:i=X.Top,borderRadius:a=5,centerX:c,centerY:l,offset:f=20,stepPosition:h=.5}){const[d,u,p,x,b]=Df({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:o},targetPosition:i,center:{x:c,y:l},offset:f,stepPosition:h});return[d.reduce((y,m,g)=>{let w="";return g>0&&g<d.length-1?w=Lf(d[g-1],m,d[g+1],a):w=`${g===0?"M":"L"}${m.x} ${m.y}`,y+=w,y},""),u,p,x,b]}function sr(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Rf(e){var d;const{sourceNode:t,targetNode:n}=e;if(!sr(t)||!sr(n))return null;const s=t.internals.handleBounds||rr(t.handles),o=n.internals.handleBounds||rr(n.handles),i=or((s==null?void 0:s.source)??[],e.sourceHandle),a=or(e.connectionMode===Qe.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!i||!a)return(d=e.onError)==null||d.call(e,"008",ge.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=(i==null?void 0:i.position)||X.Bottom,l=(a==null?void 0:a.position)||X.Top,f=He(t,i,c),h=He(n,a,l);return{sourceX:f.x,sourceY:f.y,targetX:h.x,targetY:h.y,sourcePosition:c,targetPosition:l}}function rr(e){if(!e)return null;const t=[],n=[];for(const s of e)s.width=s.width??1,s.height=s.height??1,s.type==="source"?t.push(s):s.type==="target"&&n.push(s);return{source:t,target:n}}function He(e,t,n=X.Left,s=!1){const o=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:c}=t??ze(e);if(s)return{x:o+a/2,y:i+c/2};switch((t==null?void 0:t.position)??n){case X.Top:return{x:o+a/2,y:i};case X.Right:return{x:o+a,y:i+c/2};case X.Bottom:return{x:o+a/2,y:i+c};case X.Left:return{x:o,y:i+c/2}}}function or(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Zn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`:""}function Hf(e,{id:t,defaultColor:n,defaultMarkerStart:s,defaultMarkerEnd:o}){const i=new Set;return e.reduce((a,c)=>([c.markerStart||s,c.markerEnd||o].forEach(l=>{if(l&&typeof l=="object"){const f=Zn(l,t);i.has(f)||(a.push({id:f,color:l.color||n,...l}),i.add(f))}}),a),[]).sort((a,c)=>a.id.localeCompare(c.id))}const Ko=1e3,Of=10,js={nodeOrigin:[0,0],nodeExtent:wt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Bf={...js,checkEquality:!0};function Cs(e,t){const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}function Ff(e,t,n){const s=Cs(js,n);for(const o of e.values())if(o.parentId)ks(o,e,t,s);else{const i=kt(o,s.nodeOrigin),a=tt(o.extent)?o.extent:s.nodeExtent,c=Re(i,a,ze(o));o.internals.positionAbsolute=c}}function Vf(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],s=[];for(const o of e.handles){const i={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(i):o.type==="target"&&s.push(i)}return{source:n,target:s}}function zs(e){return e==="manual"}function Qn(e,t,n,s={}){var f,h;const o=Cs(Bf,s),i={i:0},a=new Map(t),c=o!=null&&o.elevateNodesOnSelect&&!zs(o.zIndexMode)?Ko:0;let l=e.length>0;t.clear(),n.clear();for(const d of e){let u=a.get(d.id);if(o.checkEquality&&d===(u==null?void 0:u.internals.userNode))t.set(d.id,u);else{const p=kt(d,o.nodeOrigin),x=tt(d.extent)?d.extent:o.nodeExtent,b=Re(p,x,ze(d));u={...o.defaults,...d,measured:{width:(f=d.measured)==null?void 0:f.width,height:(h=d.measured)==null?void 0:h.height},internals:{positionAbsolute:b,handleBounds:Vf(d,u),z:Zo(d,c,o.zIndexMode),userNode:d}},t.set(d.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),d.parentId&&ks(u,t,n,s,i)}return l}function Yf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function ks(e,t,n,s,o){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:c,zIndexMode:l}=Cs(js,s),f=e.parentId,h=t.get(f);if(!h){console.warn(`Parent node ${f} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Yf(e,n),o&&!h.parentId&&h.internals.rootParentIndex===void 0&&l==="auto"&&(h.internals.rootParentIndex=++o.i,h.internals.z=h.internals.z+o.i*Of),o&&h.internals.rootParentIndex!==void 0&&(o.i=h.internals.rootParentIndex);const d=i&&!zs(l)?Ko:0,{x:u,y:p,z:x}=Wf(e,h,a,c,d,l),{positionAbsolute:b}=e.internals,v=u!==b.x||p!==b.y;(v||x!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:u,y:p}:b,z:x}})}function Zo(e,t,n){const s=ue(e.zIndex)?e.zIndex:0;return zs(n)?s:s+(e.selected?t:0)}function Wf(e,t,n,s,o,i){const{x:a,y:c}=t.internals.positionAbsolute,l=ze(e),f=kt(e,n),h=tt(e.extent)?Re(f,e.extent,l):f;let d=Re({x:a+h.x,y:c+h.y},s,l);e.extent==="parent"&&(d=Ro(d,l,t));const u=Zo(e,o,i),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=u?p+1:u}}function Ss(e,t,n,s=[0,0]){var a;const o=[],i=new Map;for(const c of e){const l=t.get(c.parentId);if(!l)continue;const f=((a=i.get(c.parentId))==null?void 0:a.expandedRect)??et(l),h=Oo(f,c.rect);i.set(c.parentId,{expandedRect:h,parent:l})}return i.size>0&&i.forEach(({expandedRect:c,parent:l},f)=>{var g;const h=l.internals.positionAbsolute,d=ze(l),u=l.origin??s,p=c.x<h.x?Math.round(Math.abs(h.x-c.x)):0,x=c.y<h.y?Math.round(Math.abs(h.y-c.y)):0,b=Math.max(d.width,Math.round(c.width)),v=Math.max(d.height,Math.round(c.height)),y=(b-d.width)*u[0],m=(v-d.height)*u[1];(p>0||x>0||y||m)&&(o.push({id:f,type:"position",position:{x:l.position.x-p+y,y:l.position.y-x+m}}),(g=n.get(f))==null||g.forEach(w=>{e.some(C=>C.id===w.id)||o.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+x}})})),(d.width<c.width||d.height<c.height||p||x)&&o.push({id:f,type:"dimensions",setAttributes:!0,dimensions:{width:b+(p?u[0]*p-y:0),height:v+(x?u[1]*x-m:0)}})}),o}function Xf(e,t,n,s,o,i,a){const c=s==null?void 0:s.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const f=[],h=window.getComputedStyle(c),{m22:d}=new window.DOMMatrixReadOnly(h.transform),u=[];for(const p of e.values()){const x=t.get(p.id);if(!x)continue;if(x.hidden){t.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),l=!0;continue}const b=Ns(p.nodeElement),v=x.measured.width!==b.width||x.measured.height!==b.height;if(!!(b.width&&b.height&&(v||!x.internals.handleBounds||p.force))){const m=p.nodeElement.getBoundingClientRect(),g=tt(x.extent)?x.extent:i;let{positionAbsolute:w}=x.internals;x.parentId&&x.extent==="parent"?w=Ro(w,b,t.get(x.parentId)):g&&(w=Re(w,g,b));const C={...x,measured:b,internals:{...x.internals,positionAbsolute:w,handleBounds:{source:Js("source",p.nodeElement,m,d,x.id),target:Js("target",p.nodeElement,m,d,x.id)}}};t.set(x.id,C),x.parentId&&ks(C,t,n,{nodeOrigin:o,zIndexMode:a}),l=!0,v&&(f.push({id:x.id,type:"dimensions",dimensions:b}),x.expandParent&&x.parentId&&u.push({id:x.id,parentId:x.parentId,rect:et(C,o)}))}}if(u.length>0){const p=Ss(u,t,n,o);f.push(...p)}return{changes:f,updatedInternals:l}}async function Gf({delta:e,panZoom:t,transform:n,translateExtent:s,width:o,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,i]],s),c=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(c)}function ir(e,t,n,s,o,i){let a=o;const c=s.get(a)||new Map;s.set(a,c.set(n,t)),a=`${o}-${e}`;const l=s.get(a)||new Map;if(s.set(a,l.set(n,t)),i){a=`${o}-${e}-${i}`;const f=s.get(a)||new Map;s.set(a,f.set(n,t))}}function Qo(e,t,n){e.clear(),t.clear();for(const s of n){const{source:o,target:i,sourceHandle:a=null,targetHandle:c=null}=s,l={edgeId:s.id,source:o,target:i,sourceHandle:a,targetHandle:c},f=`${o}-${a}--${i}-${c}`,h=`${i}-${c}--${o}-${a}`;ir("source",l,h,e,o,a),ir("target",l,f,e,i,c),t.set(s.id,s)}}function Jo(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Jo(n,t):!1}function ar(e,t,n){var o;let s=e;do{if((o=s==null?void 0:s.matches)!=null&&o.call(s,t))return!0;if(s===n)return!1;s=s==null?void 0:s.parentElement}while(s);return!1}function qf(e,t,n,s){const o=new Map;for(const[i,a]of e)if((a.selected||a.id===s)&&(!a.parentId||!Jo(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const c=e.get(i);c&&o.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return o}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:s=!0}){var a,c,l;const o=[];for(const[f,h]of t){const d=(a=n.get(f))==null?void 0:a.internals.userNode;d&&o.push({...d,position:h.position,dragging:s})}if(!e)return[o[0],o];const i=(c=n.get(e))==null?void 0:c.internals.userNode;return[i?{...i,position:((l=t.get(e))==null?void 0:l.position)||i.position,dragging:s}:o[0],o]}function Uf({dragItems:e,snapGrid:t,x:n,y:s}){const o=e.values().next().value;if(!o)return null;const i={x:n-o.distance.x,y:s-o.distance.y},a=Et(i,t);return{x:a.x-i.x,y:a.y-i.y}}function Kf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:s,onDragStop:o}){let i={x:null,y:null},a=0,c=new Map,l=!1,f={x:0,y:0},h=null,d=!1,u=null,p=!1,x=!1,b=null;function v({noDragClassName:m,handleSelector:g,domNode:w,isSelectable:C,nodeId:z,nodeClickDistance:k=0}){u=ae(w);function P({x:A,y:H}){const{nodeLookup:j,nodeExtent:T,snapGrid:S,snapToGrid:I,nodeOrigin:E,onNodeDrag:_,onSelectionDrag:L,onError:R,updateNodePositions:D}=t();i={x:A,y:H};let V=!1;const W=c.size>1,G=W&&T?Kn(St(c)):null,K=W&&I?Uf({dragItems:c,snapGrid:S,x:A,y:H}):null;for(const[F,O]of c){if(!j.has(F))continue;let Y={x:A-O.distance.x,y:H-O.distance.y};I&&(Y=K?{x:Math.round(Y.x+K.x),y:Math.round(Y.y+K.y)}:Et(Y,S));let q=null;if(W&&T&&!O.extent&&G){const{positionAbsolute:U}=O.internals,ee=U.x-G.x+T[0][0],ne=U.x+O.measured.width-G.x2+T[1][0],te=U.y-G.y+T[0][1],ie=U.y+O.measured.height-G.y2+T[1][1];q=[[ee,te],[ne,ie]]}const{position:Q,positionAbsolute:Z}=Lo({nodeId:F,nextPosition:Y,nodeLookup:j,nodeExtent:q||T,nodeOrigin:E,onError:R});V=V||O.position.x!==Q.x||O.position.y!==Q.y,O.position=Q,O.internals.positionAbsolute=Z}if(x=x||V,!!V&&(D(c,!0),b&&(s||_||!z&&L))){const[F,O]=In({nodeId:z,dragItems:c,nodeLookup:j});s==null||s(b,c,F,O),_==null||_(b,F,O),z||L==null||L(b,O)}}async function $(){if(!h)return;const{transform:A,panBy:H,autoPanSpeed:j,autoPanOnNodeDrag:T}=t();if(!T){l=!1,cancelAnimationFrame(a);return}const[S,I]=Ho(f,h,j);(S!==0||I!==0)&&(i.x=(i.x??0)-S/A[2],i.y=(i.y??0)-I/A[2],await H({x:S,y:I})&&P(i)),a=requestAnimationFrame($)}function B(A){var W;const{nodeLookup:H,multiSelectionActive:j,nodesDraggable:T,transform:S,snapGrid:I,snapToGrid:E,selectNodesOnDrag:_,onNodeDragStart:L,onSelectionDragStart:R,unselectNodesAndEdges:D}=t();d=!0,(!_||!C)&&!j&&z&&((W=H.get(z))!=null&&W.selected||D()),C&&_&&z&&(e==null||e(z));const V=gt(A.sourceEvent,{transform:S,snapGrid:I,snapToGrid:E,containerBounds:h});if(i=V,c=qf(H,T,V,z),c.size>0&&(n||L||!z&&R)){const[G,K]=In({nodeId:z,dragItems:c,nodeLookup:H});n==null||n(A.sourceEvent,c,G,K),L==null||L(A.sourceEvent,G,K),z||R==null||R(A.sourceEvent,K)}}const M=No().clickDistance(k).on("start",A=>{const{domNode:H,nodeDragThreshold:j,transform:T,snapGrid:S,snapToGrid:I}=t();h=(H==null?void 0:H.getBoundingClientRect())||null,p=!1,x=!1,b=A.sourceEvent,j===0&&B(A),i=gt(A.sourceEvent,{transform:T,snapGrid:S,snapToGrid:I,containerBounds:h}),f=fe(A.sourceEvent,h)}).on("drag",A=>{const{autoPanOnNodeDrag:H,transform:j,snapGrid:T,snapToGrid:S,nodeDragThreshold:I,nodeLookup:E}=t(),_=gt(A.sourceEvent,{transform:j,snapGrid:T,snapToGrid:S,containerBounds:h});if(b=A.sourceEvent,(A.sourceEvent.type==="touchmove"&&A.sourceEvent.touches.length>1||z&&!E.has(z))&&(p=!0),!p){if(!l&&H&&d&&(l=!0,$()),!d){const L=fe(A.sourceEvent,h),R=L.x-f.x,D=L.y-f.y;Math.sqrt(R*R+D*D)>I&&B(A)}(i.x!==_.xSnapped||i.y!==_.ySnapped)&&c&&d&&(f=fe(A.sourceEvent,h),P(_))}}).on("end",A=>{if(!(!d||p)&&(l=!1,d=!1,cancelAnimationFrame(a),c.size>0)){const{nodeLookup:H,updateNodePositions:j,onNodeDragStop:T,onSelectionDragStop:S}=t();if(x&&(j(c,!1),x=!1),o||T||!z&&S){const[I,E]=In({nodeId:z,dragItems:c,nodeLookup:H,dragging:!1});o==null||o(A.sourceEvent,c,I,E),T==null||T(A.sourceEvent,I,E),z||S==null||S(A.sourceEvent,E)}}}).filter(A=>{const H=A.target;return!A.button&&(!m||!ar(H,`.${m}`,w))&&(!g||ar(H,g,w))});u.call(M)}function y(){u==null||u.on(".drag",null)}return{update:v,destroy:y}}function Zf(e,t,n){const s=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())Nt(o,et(i))>0&&s.push(i);return s}const Qf=250;function Jf(e,t,n,s){var c,l;let o=[],i=1/0;const a=Zf(e,n,t+Qf);for(const f of a){const h=[...((c=f.internals.handleBounds)==null?void 0:c.source)??[],...((l=f.internals.handleBounds)==null?void 0:l.target)??[]];for(const d of h){if(s.nodeId===d.nodeId&&s.type===d.type&&s.id===d.id)continue;const{x:u,y:p}=He(f,d,d.position,!0),x=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(p-e.y,2));x>t||(x<i?(o=[{...d,x:u,y:p}],i=x):x===i&&o.push({...d,x:u,y:p}))}}if(!o.length)return null;if(o.length>1){const f=s.type==="source"?"target":"source";return o.find(h=>h.type===f)??o[0]}return o[0]}function ei(e,t,n,s,o,i=!1){var f,h,d;const a=s.get(e);if(!a)return null;const c=o==="strict"?(f=a.internals.handleBounds)==null?void 0:f[t]:[...((h=a.internals.handleBounds)==null?void 0:h.source)??[],...((d=a.internals.handleBounds)==null?void 0:d.target)??[]],l=(n?c==null?void 0:c.find(u=>u.id===n):c==null?void 0:c[0])??null;return l&&i?{...l,...He(a,l,l.position,!0)}:l}function ti(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function eh(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ni=()=>!0;function th(e,{connectionMode:t,connectionRadius:n,handleId:s,nodeId:o,edgeUpdaterType:i,isTarget:a,domNode:c,nodeLookup:l,lib:f,autoPanOnConnect:h,flowId:d,panBy:u,cancelConnection:p,onConnectStart:x,onConnect:b,onConnectEnd:v,isValidConnection:y=ni,onReconnectEnd:m,updateConnection:g,getTransform:w,getFromHandle:C,autoPanSpeed:z,dragThreshold:k=1,handleDomNode:P}){const $=Vo(e.target);let B=0,M;const{x:A,y:H}=fe(e),j=ti(i,P),T=c==null?void 0:c.getBoundingClientRect();let S=!1;if(!T||!j)return;const I=ei(o,j,s,l,t);if(!I)return;let E=fe(e,T),_=!1,L=null,R=!1,D=null;function V(){if(!h||!T)return;const[Q,Z]=Ho(E,T,z);u({x:Q,y:Z}),B=requestAnimationFrame(V)}const W={...I,nodeId:o,type:j,position:I.position},G=l.get(o);let F={inProgress:!0,isValid:null,from:He(G,W,X.Left,!0),fromHandle:W,fromPosition:W.position,fromNode:G,to:E,toHandle:null,toPosition:Us[W.position],toNode:null,pointer:E};function O(){S=!0,g(F),x==null||x(e,{nodeId:o,handleId:s,handleType:j})}k===0&&O();function Y(Q){if(!S){const{x:ie,y:ke}=fe(Q),we=ie-A,Ae=ke-H;if(!(we*we+Ae*Ae>k*k))return;O()}if(!C()||!W){q(Q);return}const Z=w();E=fe(Q,T),M=Jf(_t(E,Z,!1,[1,1]),n,l,W),_||(V(),_=!0);const U=si(Q,{handle:M,connectionMode:t,fromNodeId:o,fromHandleId:s,fromType:a?"target":"source",isValidConnection:y,doc:$,lib:f,flowId:d,nodeLookup:l});D=U.handleDomNode,L=U.connection,R=eh(!!M,U.isValid);const ee=l.get(o),ne=ee?He(ee,W,X.Left,!0):F.from,te={...F,from:ne,isValid:R,to:U.toHandle&&R?ln({x:U.toHandle.x,y:U.toHandle.y},Z):E,toHandle:U.toHandle,toPosition:R&&U.toHandle?U.toHandle.position:Us[W.position],toNode:U.toHandle?l.get(U.toHandle.nodeId):null,pointer:E};g(te),F=te}function q(Q){if(!("touches"in Q&&Q.touches.length>0)){if(S){(M||D)&&L&&R&&(b==null||b(L));const{inProgress:Z,...U}=F,ee={...U,toPosition:F.toHandle?F.toPosition:null};v==null||v(Q,ee),i&&(m==null||m(Q,ee))}p(),cancelAnimationFrame(B),_=!1,R=!1,L=null,D=null,$.removeEventListener("mousemove",Y),$.removeEventListener("mouseup",q),$.removeEventListener("touchmove",Y),$.removeEventListener("touchend",q)}}$.addEventListener("mousemove",Y),$.addEventListener("mouseup",q),$.addEventListener("touchmove",Y),$.addEventListener("touchend",q)}function si(e,{handle:t,connectionMode:n,fromNodeId:s,fromHandleId:o,fromType:i,doc:a,lib:c,flowId:l,isValidConnection:f=ni,nodeLookup:h}){const d=i==="target",u=t?a.querySelector(`.${c}-flow__handle[data-id="${l}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:p,y:x}=fe(e),b=a.elementFromPoint(p,x),v=b!=null&&b.classList.contains(`${c}-flow__handle`)?b:u,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const m=ti(void 0,v),g=v.getAttribute("data-nodeid"),w=v.getAttribute("data-handleid"),C=v.classList.contains("connectable"),z=v.classList.contains("connectableend");if(!g||!m)return y;const k={source:d?g:s,sourceHandle:d?w:o,target:d?s:g,targetHandle:d?o:w};y.connection=k;const $=C&&z&&(n===Qe.Strict?d&&m==="source"||!d&&m==="target":g!==s||w!==o);y.isValid=$&&f(k),y.toHandle=ei(g,m,w,h,n,!0)}return y}const Jn={onPointerDown:th,isValid:si};function nh({domNode:e,panZoom:t,getTransform:n,getViewScale:s}){const o=ae(e);function i({translateExtent:c,width:l,height:f,zoomStep:h=1,pannable:d=!0,zoomable:u=!0,inversePan:p=!1}){const x=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const w=n(),C=g.sourceEvent.ctrlKey&&jt()?10:1,z=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*h,k=w[2]*Math.pow(2,z*C);t.scaleTo(k)};let b=[0,0];const v=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(b=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const w=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],z=[C[0]-b[0],C[1]-b[1]];b=C;const k=s()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),P={x:w[0]-z[0]*k,y:w[1]-z[1]*k},$=[[0,0],[l,f]];t.setViewportConstrained({x:P.x,y:P.y,zoom:w[2]},$,c)},m=Io().on("start",v).on("zoom",d?y:null).on("zoom.wheel",u?x:null);o.call(m,{})}function a(){o.on("zoom",null)}return{update:i,destroy:a,pointer:le}}const vn=e=>({x:e.x,y:e.y,zoom:e.k}),Tn=({x:e,y:t,zoom:n})=>bn.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),ri=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),sh=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,An=(e,t=0,n=sh,s=()=>{})=>{const o=typeof t=="number"&&t>0;return o||s(),o?e.transition().duration(t).ease(n).on("end",s):e},oi=e=>{const t=e.ctrlKey&&jt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function rh({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:s,panOnScrollMode:o,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:f}){return h=>{if(Xe(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(h.ctrlKey&&a){const v=le(h),y=oi(h),m=d*Math.pow(2,y);s.scaleTo(n,m,v,h);return}const u=h.deltaMode===1?20:1;let p=o===$e.Vertical?0:h.deltaX*u,x=o===$e.Horizontal?0:h.deltaY*u;!jt()&&h.shiftKey&&o!==$e.Vertical&&(p=h.deltaY*u,x=0),s.translateBy(n,-(p/d)*i,-(x/d)*i,{internal:!0});const b=vn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l==null||l(h,b),e.panScrollTimeout=setTimeout(()=>{f==null||f(h,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c==null||c(h,b))}}function oh({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(s,o){const i=s.type==="wheel",a=!t&&i&&!s.ctrlKey,c=Xe(s,e);if(s.ctrlKey&&i&&c&&s.preventDefault(),a||c)return null;s.preventDefault(),n.call(this,s,o)}}function ih({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return s=>{var i,a,c;if((i=s.sourceEvent)!=null&&i.internal)return;const o=vn(s.transform);e.mouseButton=((a=s.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((c=s.sourceEvent)==null?void 0:c.type)==="mousedown"&&t(!0),n&&(n==null||n(s.sourceEvent,o))}}function ah({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:s,onPanZoom:o}){return i=>{var a,c;e.usedRightMouseButton=!!(n&&ri(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||s([i.transform.x,i.transform.y,i.transform.k]),o&&!((c=i.sourceEvent)!=null&&c.internal)&&(o==null||o(i.sourceEvent,vn(i.transform)))}}function ch({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:s,onPanZoomEnd:o,onPaneContextMenu:i}){return a=>{var c;if(!((c=a.sourceEvent)!=null&&c.internal)&&(e.isZoomingOrPanning=!1,i&&ri(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,s(!1),o)){const l=vn(a.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(a.sourceEvent,l)},n?150:0)}}}function lh({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:s,panOnScroll:o,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:f,connectionInProgress:h}){return d=>{var v;const u=e||t,p=n&&d.ctrlKey,x=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${f}-flow__node`)||Xe(d,`${f}-flow__edge`)))return!0;if(!s&&!u&&!o&&!i&&!n||a||h&&!x||Xe(d,c)&&x||Xe(d,l)&&(!x||o&&x&&!e)||!n&&d.ctrlKey&&x)return!1;if(!n&&d.type==="touchstart"&&((v=d.touches)==null?void 0:v.length)>1)return d.preventDefault(),!1;if(!u&&!o&&!p&&x||!s&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(s)&&!s.includes(d.button)&&d.type==="mousedown")return!1;const b=Array.isArray(s)&&s.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||x)&&b}}function dh({domNode:e,minZoom:t,maxZoom:n,translateExtent:s,viewport:o,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:l}){const f={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),d=Io().scaleExtent([t,n]).translateExtent(s),u=ae(e).call(d);m({x:o.x,y:o.y,zoom:Je(o.zoom,t,n)},[[0,0],[h.width,h.height]],s);const p=u.on("wheel.zoom"),x=u.on("dblclick.zoom");d.wheelDelta(oi);function b(M,A){return u?new Promise(H=>{d==null||d.interpolate((A==null?void 0:A.interpolate)==="linear"?En:qt).transform(An(u,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>H(!0)),M)}):Promise.resolve(!1)}function v({noWheelClassName:M,noPanClassName:A,onPaneContextMenu:H,userSelectionActive:j,panOnScroll:T,panOnDrag:S,panOnScrollMode:I,panOnScrollSpeed:E,preventScrolling:_,zoomOnPinch:L,zoomOnScroll:R,zoomOnDoubleClick:D,zoomActivationKeyPressed:V,lib:W,onTransformChange:G,connectionInProgress:K,paneClickDistance:F,selectionOnDrag:O}){j&&!f.isZoomingOrPanning&&y();const Y=T&&!V&&!j;d.clickDistance(O?1/0:!ue(F)||F<0?0:F);const q=Y?rh({zoomPanValues:f,noWheelClassName:M,d3Selection:u,d3Zoom:d,panOnScrollMode:I,panOnScrollSpeed:E,zoomOnPinch:L,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:c}):oh({noWheelClassName:M,preventScrolling:_,d3ZoomHandler:p});if(u.on("wheel.zoom",q,{passive:!1}),!j){const Z=ih({zoomPanValues:f,onDraggingChange:l,onPanZoomStart:a});d.on("start",Z);const U=ah({zoomPanValues:f,panOnDrag:S,onPaneContextMenu:!!H,onPanZoom:i,onTransformChange:G});d.on("zoom",U);const ee=ch({zoomPanValues:f,panOnDrag:S,panOnScroll:T,onPaneContextMenu:H,onPanZoomEnd:c,onDraggingChange:l});d.on("end",ee)}const Q=lh({zoomActivationKeyPressed:V,panOnDrag:S,zoomOnScroll:R,panOnScroll:T,zoomOnDoubleClick:D,zoomOnPinch:L,userSelectionActive:j,noPanClassName:A,noWheelClassName:M,lib:W,connectionInProgress:K});d.filter(Q),D?u.on("dblclick.zoom",x):u.on("dblclick.zoom",null)}function y(){d.on("zoom",null)}async function m(M,A,H){const j=Tn(M),T=d==null?void 0:d.constrain()(j,A,H);return T&&await b(T),new Promise(S=>S(T))}async function g(M,A){const H=Tn(M);return await b(H,A),new Promise(j=>j(H))}function w(M){if(u){const A=Tn(M),H=u.property("__zoom");(H.k!==M.zoom||H.x!==M.x||H.y!==M.y)&&(d==null||d.transform(u,A,null,{sync:!0}))}}function C(){const M=u?Mo(u.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}function z(M,A){return u?new Promise(H=>{d==null||d.interpolate((A==null?void 0:A.interpolate)==="linear"?En:qt).scaleTo(An(u,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>H(!0)),M)}):Promise.resolve(!1)}function k(M,A){return u?new Promise(H=>{d==null||d.interpolate((A==null?void 0:A.interpolate)==="linear"?En:qt).scaleBy(An(u,A==null?void 0:A.duration,A==null?void 0:A.ease,()=>H(!0)),M)}):Promise.resolve(!1)}function P(M){d==null||d.scaleExtent(M)}function $(M){d==null||d.translateExtent(M)}function B(M){const A=!ue(M)||M<0?0:M;d==null||d.clickDistance(A)}return{update:v,destroy:y,setViewport:g,setViewportConstrained:m,getViewport:C,scaleTo:z,scaleBy:k,setScaleExtent:P,setTranslateExtent:$,syncViewport:w,setClickDistance:B}}var nt;(function(e){e.Line="line",e.Handle="handle"})(nt||(nt={}));function uh({width:e,prevWidth:t,height:n,prevHeight:s,affectsX:o,affectsY:i}){const a=e-t,c=n-s,l=[a>0?1:a<0?-1:0,c>0?1:c<0?-1:0];return a&&o&&(l[0]=l[0]*-1),c&&i&&(l[1]=l[1]*-1),l}function cr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),s=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:s,affectsY:o}}function Se(e,t){return Math.max(0,t-e)}function Ee(e,t){return Math.max(0,e-t)}function Dt(e,t,n){return Math.max(0,t-e,e-n)}function lr(e,t){return e?!t:t}function fh(e,t,n,s,o,i,a,c){let{affectsX:l,affectsY:f}=t;const{isHorizontal:h,isVertical:d}=t,u=h&&d,{xSnapped:p,ySnapped:x}=n,{minWidth:b,maxWidth:v,minHeight:y,maxHeight:m}=s,{x:g,y:w,width:C,height:z,aspectRatio:k}=e;let P=Math.floor(h?p-e.pointerX:0),$=Math.floor(d?x-e.pointerY:0);const B=C+(l?-P:P),M=z+(f?-$:$),A=-i[0]*C,H=-i[1]*z;let j=Dt(B,b,v),T=Dt(M,y,m);if(a){let E=0,_=0;l&&P<0?E=Se(g+P+A,a[0][0]):!l&&P>0&&(E=Ee(g+B+A,a[1][0])),f&&$<0?_=Se(w+$+H,a[0][1]):!f&&$>0&&(_=Ee(w+M+H,a[1][1])),j=Math.max(j,E),T=Math.max(T,_)}if(c){let E=0,_=0;l&&P>0?E=Ee(g+P,c[0][0]):!l&&P<0&&(E=Se(g+B,c[1][0])),f&&$>0?_=Ee(w+$,c[0][1]):!f&&$<0&&(_=Se(w+M,c[1][1])),j=Math.max(j,E),T=Math.max(T,_)}if(o){if(h){const E=Dt(B/k,y,m)*k;if(j=Math.max(j,E),a){let _=0;!l&&!f||l&&!f&&u?_=Ee(w+H+B/k,a[1][1])*k:_=Se(w+H+(l?P:-P)/k,a[0][1])*k,j=Math.max(j,_)}if(c){let _=0;!l&&!f||l&&!f&&u?_=Se(w+B/k,c[1][1])*k:_=Ee(w+(l?P:-P)/k,c[0][1])*k,j=Math.max(j,_)}}if(d){const E=Dt(M*k,b,v)/k;if(T=Math.max(T,E),a){let _=0;!l&&!f||f&&!l&&u?_=Ee(g+M*k+A,a[1][0])/k:_=Se(g+(f?$:-$)*k+A,a[0][0])/k,T=Math.max(T,_)}if(c){let _=0;!l&&!f||f&&!l&&u?_=Se(g+M*k,c[1][0])/k:_=Ee(g+(f?$:-$)*k,c[0][0])/k,T=Math.max(T,_)}}}$=$+($<0?T:-T),P=P+(P<0?j:-j),o&&(u?B>M*k?$=(lr(l,f)?-P:P)/k:P=(lr(l,f)?-$:$)*k:h?($=P/k,f=l):(P=$*k,l=f));const S=l?g+P:g,I=f?w+$:w;return{width:C+(l?-P:P),height:z+(f?-$:$),x:i[0]*P*(l?-1:1)+S,y:i[1]*$*(f?-1:1)+I}}const ii={width:0,height:0,x:0,y:0},hh={...ii,pointerX:0,pointerY:0,aspectRatio:1};function ph(e){return[[0,0],[e.measured.width,e.measured.height]]}function xh(e,t,n){const s=t.position.x+e.position.x,o=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,c=n[0]*i,l=n[1]*a;return[[s-c,o-l],[s+i-c,o+a-l]]}function mh({domNode:e,nodeId:t,getStoreItems:n,onChange:s,onEnd:o}){const i=ae(e);let a={controlDirection:cr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:f,boundaries:h,keepAspectRatio:d,resizeDirection:u,onResizeStart:p,onResize:x,onResizeEnd:b,shouldResize:v}){let y={...ii},m={...hh};a={boundaries:h,resizeDirection:u,keepAspectRatio:d,controlDirection:cr(f)};let g,w=null,C=[],z,k,P,$=!1;const B=No().on("start",M=>{const{nodeLookup:A,transform:H,snapGrid:j,snapToGrid:T,nodeOrigin:S,paneDomNode:I}=n();if(g=A.get(t),!g)return;w=(I==null?void 0:I.getBoundingClientRect())??null;const{xSnapped:E,ySnapped:_}=gt(M.sourceEvent,{transform:H,snapGrid:j,snapToGrid:T,containerBounds:w});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},m={...y,pointerX:E,pointerY:_,aspectRatio:y.width/y.height},z=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(z=A.get(g.parentId),k=z&&g.extent==="parent"?ph(z):void 0),C=[],P=void 0;for(const[L,R]of A)if(R.parentId===t&&(C.push({id:L,position:{...R.position},extent:R.extent}),R.extent==="parent"||R.expandParent)){const D=xh(R,g,R.origin??S);P?P=[[Math.min(D[0][0],P[0][0]),Math.min(D[0][1],P[0][1])],[Math.max(D[1][0],P[1][0]),Math.max(D[1][1],P[1][1])]]:P=D}p==null||p(M,{...y})}).on("drag",M=>{const{transform:A,snapGrid:H,snapToGrid:j,nodeOrigin:T}=n(),S=gt(M.sourceEvent,{transform:A,snapGrid:H,snapToGrid:j,containerBounds:w}),I=[];if(!g)return;const{x:E,y:_,width:L,height:R}=y,D={},V=g.origin??T,{width:W,height:G,x:K,y:F}=fh(m,a.controlDirection,S,a.boundaries,a.keepAspectRatio,V,k,P),O=W!==L,Y=G!==R,q=K!==E&&O,Q=F!==_&&Y;if(!q&&!Q&&!O&&!Y)return;if((q||Q||V[0]===1||V[1]===1)&&(D.x=q?K:y.x,D.y=Q?F:y.y,y.x=D.x,y.y=D.y,C.length>0)){const ne=K-E,te=F-_;for(const ie of C)ie.position={x:ie.position.x-ne+V[0]*(W-L),y:ie.position.y-te+V[1]*(G-R)},I.push(ie)}if((O||Y)&&(D.width=O&&(!a.resizeDirection||a.resizeDirection==="horizontal")?W:y.width,D.height=Y&&(!a.resizeDirection||a.resizeDirection==="vertical")?G:y.height,y.width=D.width,y.height=D.height),z&&g.expandParent){const ne=V[0]*(D.width??0);D.x&&D.x<ne&&(y.x=ne,m.x=m.x-(D.x-ne));const te=V[1]*(D.height??0);D.y&&D.y<te&&(y.y=te,m.y=m.y-(D.y-te))}const Z=uh({width:y.width,prevWidth:L,height:y.height,prevHeight:R,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),U={...y,direction:Z};(v==null?void 0:v(M,U))!==!1&&($=!0,x==null||x(M,U),s(D,I))}).on("end",M=>{$&&(b==null||b(M,{...y}),o==null||o({...y}),$=!1)});i.call(B)}function l(){i.on(".drag",null)}return{update:c,destroy:l}}var Pn={exports:{}},$n={},Dn={exports:{}},Ln={};/**
|
|
47
|
+
* @license React
|
|
48
|
+
* use-sync-external-store-shim.production.js
|
|
49
|
+
*
|
|
50
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
51
|
+
*
|
|
52
|
+
* This source code is licensed under the MIT license found in the
|
|
53
|
+
* LICENSE file in the root directory of this source tree.
|
|
54
|
+
*/var dr;function gh(){if(dr)return Ln;dr=1;var e=Xr();function t(d,u){return d===u&&(d!==0||1/d===1/u)||d!==d&&u!==u}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,o=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function c(d,u){var p=u(),x=s({inst:{value:p,getSnapshot:u}}),b=x[0].inst,v=x[1];return i(function(){b.value=p,b.getSnapshot=u,l(b)&&v({inst:b})},[d,p,u]),o(function(){return l(b)&&v({inst:b}),d(function(){l(b)&&v({inst:b})})},[d]),a(p),p}function l(d){var u=d.getSnapshot;d=d.value;try{var p=u();return!n(d,p)}catch{return!0}}function f(d,u){return u()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Ln.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,Ln}var ur;function bh(){return ur||(ur=1,Dn.exports=gh()),Dn.exports}/**
|
|
55
|
+
* @license React
|
|
56
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
57
|
+
*
|
|
58
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the MIT license found in the
|
|
61
|
+
* LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/var fr;function yh(){if(fr)return $n;fr=1;var e=Xr(),t=bh();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var s=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,i=e.useRef,a=e.useEffect,c=e.useMemo,l=e.useDebugValue;return $n.useSyncExternalStoreWithSelector=function(f,h,d,u,p){var x=i(null);if(x.current===null){var b={hasValue:!1,value:null};x.current=b}else b=x.current;x=c(function(){function y(z){if(!m){if(m=!0,g=z,z=u(z),p!==void 0&&b.hasValue){var k=b.value;if(p(k,z))return w=k}return w=z}if(k=w,s(g,z))return k;var P=u(z);return p!==void 0&&p(k,P)?(g=z,k):(g=z,w=P)}var m=!1,g,w,C=d===void 0?null:d;return[function(){return y(h())},C===null?void 0:function(){return y(C())}]},[h,d,u,p]);var v=o(f,x[0],x[1]);return a(function(){b.hasValue=!0,b.value=v},[v]),l(v),v},$n}var hr;function wh(){return hr||(hr=1,Pn.exports=yh()),Pn.exports}var vh=wh();const Nh=ic(vh),jh={},pr=e=>{let t;const n=new Set,s=(h,d)=>{const u=typeof h=="function"?h(t):h;if(!Object.is(u,t)){const p=t;t=d??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(x=>x(t,p))}},o=()=>t,l={setState:s,getState:o,getInitialState:()=>f,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(jh?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},f=t=e(s,o,l);return l},Ch=e=>e?pr(e):pr,{useDebugValue:zh}=is,{useSyncExternalStoreWithSelector:kh}=Nh,Sh=e=>e;function ai(e,t=Sh,n){const s=kh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return zh(s),s}const xr=(e,t)=>{const n=Ch(e),s=(o,i=t)=>ai(n,o,i);return Object.assign(s,n),s},Eh=(e,t)=>e?xr(e,t):xr;function se(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[s,o]of e)if(!Object.is(o,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}const Nn=N.createContext(null),_h=Nn.Provider,ci=ge.error001();function J(e,t){const n=N.useContext(Nn);if(n===null)throw new Error(ci);return ai(n,e,t)}function re(){const e=N.useContext(Nn);if(e===null)throw new Error(ci);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const mr={display:"none"},Mh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},li="react-flow__node-desc",di="react-flow__edge-desc",Ih="react-flow__aria-live",Th=e=>e.ariaLiveMessage,Ah=e=>e.ariaLabelConfig;function Ph({rfId:e}){const t=J(Th);return r.jsx("div",{id:`${Ih}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Mh,children:t})}function $h({rfId:e,disableKeyboardA11y:t}){const n=J(Ah);return r.jsxs(r.Fragment,{children:[r.jsx("div",{id:`${li}-${e}`,style:mr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),r.jsx("div",{id:`${di}-${e}`,style:mr,children:n["edge.a11yDescription.default"]}),!t&&r.jsx(Ph,{rfId:e})]})}const jn=N.forwardRef(({position:e="top-left",children:t,className:n,style:s,...o},i)=>{const a=`${e}`.split("-");return r.jsx("div",{className:oe(["react-flow__panel",n,...a]),style:s,ref:i,...o,children:t})});jn.displayName="Panel";function Dh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:r.jsx(jn,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:r.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Lh=e=>{const t=[],n=[];for(const[,s]of e.nodeLookup)s.selected&&t.push(s.internals.userNode);for(const[,s]of e.edgeLookup)s.selected&&n.push(s);return{selectedNodes:t,selectedEdges:n}},Lt=e=>e.id;function Rh(e,t){return se(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&se(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function Hh({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:s}=J(Lh,Rh);return N.useEffect(()=>{const o={nodes:n,edges:s};e==null||e(o),t.getState().onSelectionChangeHandlers.forEach(i=>i(o))},[n,s,e]),null}const Oh=e=>!!e.onSelectionChangeHandlers;function Bh({onSelectionChange:e}){const t=J(Oh);return e||t?r.jsx(Hh,{onSelectionChange:e}):null}const ui=[0,0],Fh={x:0,y:0,zoom:1},Vh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],gr=[...Vh,"rfId"],Yh=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),br={translateExtent:wt,nodeOrigin:ui,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Wh(e){const{setNodes:t,setEdges:n,setMinZoom:s,setMaxZoom:o,setTranslateExtent:i,setNodeExtent:a,reset:c,setDefaultNodesAndEdges:l}=J(Yh,se),f=re();N.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{h.current=br,c()}),[]);const h=N.useRef(br);return N.useEffect(()=>{for(const d of gr){const u=e[d],p=h.current[d];u!==p&&(typeof e[d]>"u"||(d==="nodes"?t(u):d==="edges"?n(u):d==="minZoom"?s(u):d==="maxZoom"?o(u):d==="translateExtent"?i(u):d==="nodeExtent"?a(u):d==="ariaLabelConfig"?f.setState({ariaLabelConfig:Ef(u)}):d==="fitView"?f.setState({fitViewQueued:u}):d==="fitViewOptions"?f.setState({fitViewOptions:u}):f.setState({[d]:u})))}h.current=e},gr.map(d=>e[d])),null}function yr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Xh(e){var s;const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const o=yr(),i=()=>n(o!=null&&o.matches?"dark":"light");return i(),o==null||o.addEventListener("change",i),()=>{o==null||o.removeEventListener("change",i)}},[e]),t!==null?t:(s=yr())!=null&&s.matches?"dark":"light"}const wr=typeof document<"u"?document:null;function Ct(e=null,t={target:wr,actInsideInputWithModifier:!0}){const[n,s]=N.useState(!1),o=N.useRef(!1),i=N.useRef(new Set([])),[a,c]=N.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
63
|
+
`).replace(`
|
|
64
|
+
|
|
65
|
+
`,`
|
|
66
|
+
+`).split(`
|
|
67
|
+
`)),h=f.reduce((d,u)=>d.concat(...u),[]);return[f,h]}return[[],[]]},[e]);return N.useEffect(()=>{const l=(t==null?void 0:t.target)??wr,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const h=p=>{var v,y;if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!f)&&Yo(p))return!1;const b=Nr(p.code,c);if(i.current.add(p[b]),vr(a,i.current,!1)){const m=((y=(v=p.composedPath)==null?void 0:v.call(p))==null?void 0:y[0])||p.target,g=(m==null?void 0:m.nodeName)==="BUTTON"||(m==null?void 0:m.nodeName)==="A";t.preventDefault!==!1&&(o.current||!g)&&p.preventDefault(),s(!0)}},d=p=>{const x=Nr(p.code,c);vr(a,i.current,!0)?(s(!1),i.current.clear()):i.current.delete(p[x]),p.key==="Meta"&&i.current.clear(),o.current=!1},u=()=>{i.current.clear(),s(!1)};return l==null||l.addEventListener("keydown",h),l==null||l.addEventListener("keyup",d),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{l==null||l.removeEventListener("keydown",h),l==null||l.removeEventListener("keyup",d),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[e,s]),n}function vr(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(o=>t.has(o)))}function Nr(e,t){return t.includes(e)?"code":"key"}const Gh=()=>{const e=re();return N.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t==null?void 0:t.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:s}=e.getState();return s?s.scaleTo(t,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[s,o,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??s,y:t.y??o,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,s]=e.getState().transform;return{x:t,y:n,zoom:s}},setCenter:async(t,n,s)=>e.getState().setCenter(t,n,s),fitBounds:async(t,n)=>{const{width:s,height:o,minZoom:i,maxZoom:a,panZoom:c}=e.getState(),l=vs(t,s,o,i,a,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:s,snapGrid:o,snapToGrid:i,domNode:a}=e.getState();if(!a)return t;const{x:c,y:l}=a.getBoundingClientRect(),f={x:t.x-c,y:t.y-l},h=n.snapGrid??o,d=n.snapToGrid??i;return _t(f,s,d,h)},flowToScreenPosition:t=>{const{transform:n,domNode:s}=e.getState();if(!s)return t;const{x:o,y:i}=s.getBoundingClientRect(),a=ln(t,n);return{x:a.x+o,y:a.y+i}}}),[])};function fi(e,t){const n=[],s=new Map,o=[];for(const i of e)if(i.type==="add"){o.push(i);continue}else if(i.type==="remove"||i.type==="replace")s.set(i.id,[i]);else{const a=s.get(i.id);a?a.push(i):s.set(i.id,[i])}for(const i of t){const a=s.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const c={...i};for(const l of a)qh(l,c);n.push(c)}return o.length&&o.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function qh(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function hi(e,t){return fi(e,t)}function pi(e,t){return fi(e,t)}function Pe(e,t){return{id:e,type:"select",selected:t}}function Ge(e,t=new Set,n=!1){const s=[];for(const[o,i]of e){const a=t.has(o);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),s.push(Pe(i.id,a)))}return s}function jr({items:e=[],lookup:t}){var o;const n=[],s=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const c=t.get(a.id),l=((o=c==null?void 0:c.internals)==null?void 0:o.userNode)??c;l!==void 0&&l!==a&&n.push({id:a.id,item:a,type:"replace"}),l===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)s.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function Cr(e){return{id:e.id,type:"remove"}}const zr=e=>bf(e),Uh=e=>Do(e);function xi(e){return N.forwardRef(e)}const Kh=typeof window<"u"?N.useLayoutEffect:N.useEffect;function kr(e){const[t,n]=N.useState(BigInt(0)),[s]=N.useState(()=>Zh(()=>n(o=>o+BigInt(1))));return Kh(()=>{const o=s.get();o.length&&(e(o),s.reset())},[t]),s}function Zh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const mi=N.createContext(null);function Qh({children:e}){const t=re(),n=N.useCallback(c=>{const{nodes:l=[],setNodes:f,hasDefaultNodes:h,onNodesChange:d,nodeLookup:u,fitViewQueued:p,onNodesChangeMiddlewareMap:x}=t.getState();let b=l;for(const y of c)b=typeof y=="function"?y(b):y;let v=jr({items:b,lookup:u});for(const y of x.values())v=y(v);h&&f(b),v.length>0?d==null||d(v):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:m,setNodes:g}=t.getState();y&&g(m)})},[]),s=kr(n),o=N.useCallback(c=>{const{edges:l=[],setEdges:f,hasDefaultEdges:h,onEdgesChange:d,edgeLookup:u}=t.getState();let p=l;for(const x of c)p=typeof x=="function"?x(p):x;h?f(p):d&&d(jr({items:p,lookup:u}))},[]),i=kr(o),a=N.useMemo(()=>({nodeQueue:s,edgeQueue:i}),[]);return r.jsx(mi.Provider,{value:a,children:e})}function Jh(){const e=N.useContext(mi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const ep=e=>!!e.panZoom;function Es(){const e=Gh(),t=re(),n=Jh(),s=J(ep),o=N.useMemo(()=>{const i=d=>t.getState().nodeLookup.get(d),a=d=>{n.nodeQueue.push(d)},c=d=>{n.edgeQueue.push(d)},l=d=>{var y,m;const{nodeLookup:u,nodeOrigin:p}=t.getState(),x=zr(d)?d:u.get(d.id),b=x.parentId?Fo(x.position,x.measured,x.parentId,u,p):x.position,v={...x,position:b,width:((y=x.measured)==null?void 0:y.width)??x.width,height:((m=x.measured)==null?void 0:m.height)??x.height};return et(v)},f=(d,u,p={replace:!1})=>{a(x=>x.map(b=>{if(b.id===d){const v=typeof u=="function"?u(b):u;return p.replace&&zr(v)?v:{...b,...v}}return b}))},h=(d,u,p={replace:!1})=>{c(x=>x.map(b=>{if(b.id===d){const v=typeof u=="function"?u(b):u;return p.replace&&Uh(v)?v:{...b,...v}}return b}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var u;return(u=i(d))==null?void 0:u.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(u=>({...u}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:a,setEdges:c,addNodes:d=>{const u=Array.isArray(d)?d:[d];n.nodeQueue.push(p=>[...p,...u])},addEdges:d=>{const u=Array.isArray(d)?d:[d];n.edgeQueue.push(p=>[...p,...u])},toObject:()=>{const{nodes:d=[],edges:u=[],transform:p}=t.getState(),[x,b,v]=p;return{nodes:d.map(y=>({...y})),edges:u.map(y=>({...y})),viewport:{x,y:b,zoom:v}}},deleteElements:async({nodes:d=[],edges:u=[]})=>{const{nodes:p,edges:x,onNodesDelete:b,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:m,onDelete:g,onBeforeDelete:w}=t.getState(),{nodes:C,edges:z}=await jf({nodesToRemove:d,edgesToRemove:u,nodes:p,edges:x,onBeforeDelete:w}),k=z.length>0,P=C.length>0;if(k){const $=z.map(Cr);v==null||v(z),m($)}if(P){const $=C.map(Cr);b==null||b(C),y($)}return(P||k)&&(g==null||g({nodes:C,edges:z})),{deletedNodes:C,deletedEdges:z}},getIntersectingNodes:(d,u=!0,p)=>{const x=Zs(d),b=x?d:l(d),v=p!==void 0;return b?(p||t.getState().nodes).filter(y=>{const m=t.getState().nodeLookup.get(y.id);if(m&&!x&&(y.id===d.id||!m.internals.positionAbsolute))return!1;const g=et(v?y:m),w=Nt(g,b);return u&&w>0||w>=g.width*g.height||w>=b.width*b.height}):[]},isNodeIntersecting:(d,u,p=!0)=>{const b=Zs(d)?d:l(d);if(!b)return!1;const v=Nt(b,u);return p&&v>0||v>=u.width*u.height||v>=b.width*b.height},updateNode:f,updateNodeData:(d,u,p={replace:!1})=>{f(d,x=>{const b=typeof u=="function"?u(x):u;return p.replace?{...x,data:b}:{...x,data:{...x.data,...b}}},p)},updateEdge:h,updateEdgeData:(d,u,p={replace:!1})=>{h(d,x=>{const b=typeof u=="function"?u(x):u;return p.replace?{...x,data:b}:{...x,data:{...x.data,...b}}},p)},getNodesBounds:d=>{const{nodeLookup:u,nodeOrigin:p}=t.getState();return yf(d,{nodeLookup:u,nodeOrigin:p})},getHandleConnections:({type:d,id:u,nodeId:p})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${p}-${d}${u?`-${u}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:d,handleId:u,nodeId:p})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${p}${d?u?`-${d}-${u}`:`-${d}`:""}`))==null?void 0:x.values())??[])},fitView:async d=>{const u=t.getState().fitViewResolver??Sf();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:u}),n.nodeQueue.push(p=>[...p]),u.promise}}},[]);return N.useMemo(()=>({...o,...e,viewportInitialized:s}),[s])}const Sr=e=>e.selected,tp=typeof window<"u"?window:void 0;function np({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=re(),{deleteElements:s}=Es(),o=Ct(e,{actInsideInputWithModifier:!1}),i=Ct(t,{target:tp});N.useEffect(()=>{if(o){const{edges:a,nodes:c}=n.getState();s({nodes:c.filter(Sr),edges:a.filter(Sr)}),n.setState({nodesSelectionActive:!1})}},[o]),N.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function sp(e){const t=re();N.useEffect(()=>{const n=()=>{var o,i,a,c;if(!e.current||!(((i=(o=e.current).checkVisibility)==null?void 0:i.call(o))??!0))return!1;const s=Ns(e.current);(s.height===0||s.width===0)&&((c=(a=t.getState()).onError)==null||c.call(a,"004",ge.error004())),t.setState({width:s.width||500,height:s.height||500})};if(e.current){n(),window.addEventListener("resize",n);const s=new ResizeObserver(()=>n());return s.observe(e.current),()=>{window.removeEventListener("resize",n),s&&e.current&&s.unobserve(e.current)}}},[])}const Cn={position:"absolute",width:"100%",height:"100%",top:0,left:0},rp=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function op({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:s=!1,panOnScrollSpeed:o=.5,panOnScrollMode:i=$e.Free,zoomOnDoubleClick:a=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:f,minZoom:h,maxZoom:d,zoomActivationKeyCode:u,preventScrolling:p=!0,children:x,noWheelClassName:b,noPanClassName:v,onViewportChange:y,isControlledViewport:m,paneClickDistance:g,selectionOnDrag:w}){const C=re(),z=N.useRef(null),{userSelectionActive:k,lib:P,connectionInProgress:$}=J(rp,se),B=Ct(u),M=N.useRef();sp(z);const A=N.useCallback(H=>{y==null||y({x:H[0],y:H[1],zoom:H[2]}),m||C.setState({transform:H})},[y,m]);return N.useEffect(()=>{if(z.current){M.current=dh({domNode:z.current,minZoom:h,maxZoom:d,translateExtent:f,viewport:l,onDraggingChange:S=>C.setState(I=>I.paneDragging===S?I:{paneDragging:S}),onPanZoomStart:(S,I)=>{const{onViewportChangeStart:E,onMoveStart:_}=C.getState();_==null||_(S,I),E==null||E(I)},onPanZoom:(S,I)=>{const{onViewportChange:E,onMove:_}=C.getState();_==null||_(S,I),E==null||E(I)},onPanZoomEnd:(S,I)=>{const{onViewportChangeEnd:E,onMoveEnd:_}=C.getState();_==null||_(S,I),E==null||E(I)}});const{x:H,y:j,zoom:T}=M.current.getViewport();return C.setState({panZoom:M.current,transform:[H,j,T],domNode:z.current.closest(".react-flow")}),()=>{var S;(S=M.current)==null||S.destroy()}}},[]),N.useEffect(()=>{var H;(H=M.current)==null||H.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:s,panOnScrollSpeed:o,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:c,zoomActivationKeyPressed:B,preventScrolling:p,noPanClassName:v,userSelectionActive:k,noWheelClassName:b,lib:P,onTransformChange:A,connectionInProgress:$,selectionOnDrag:w,paneClickDistance:g})},[e,t,n,s,o,i,a,c,B,p,v,k,b,P,A,$,w,g]),r.jsx("div",{className:"react-flow__renderer",ref:z,style:Cn,children:x})}const ip=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ap(){const{userSelectionActive:e,userSelectionRect:t}=J(ip,se);return e&&t?r.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Rn=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},cp=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function lp({isSelecting:e,selectionKeyPressed:t,selectionMode:n=vt.Full,panOnDrag:s,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:f,onPaneScroll:h,onPaneMouseEnter:d,onPaneMouseMove:u,onPaneMouseLeave:p,children:x}){const b=re(),{userSelectionActive:v,elementsSelectable:y,dragging:m,connectionInProgress:g}=J(cp,se),w=y&&(e||v),C=N.useRef(null),z=N.useRef(),k=N.useRef(new Set),P=N.useRef(new Set),$=N.useRef(!1),B=E=>{if($.current||g){$.current=!1;return}l==null||l(E),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},M=E=>{if(Array.isArray(s)&&(s!=null&&s.includes(2))){E.preventDefault();return}f==null||f(E)},A=h?E=>h(E):void 0,H=E=>{$.current&&(E.stopPropagation(),$.current=!1)},j=E=>{var G,K;const{domNode:_}=b.getState();if(z.current=_==null?void 0:_.getBoundingClientRect(),!z.current)return;const L=E.target===C.current;if(!L&&!!E.target.closest(".nokey")||!e||!(i&&L||t)||E.button!==0||!E.isPrimary)return;(K=(G=E.target)==null?void 0:G.setPointerCapture)==null||K.call(G,E.pointerId),$.current=!1;const{x:V,y:W}=fe(E.nativeEvent,z.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:W,x:V,y:W}}),L||(E.stopPropagation(),E.preventDefault())},T=E=>{const{userSelectionRect:_,transform:L,nodeLookup:R,edgeLookup:D,connectionLookup:V,triggerNodeChanges:W,triggerEdgeChanges:G,defaultEdgeOptions:K,resetSelectedElements:F}=b.getState();if(!z.current||!_)return;const{x:O,y:Y}=fe(E.nativeEvent,z.current),{startX:q,startY:Q}=_;if(!$.current){const te=t?0:o;if(Math.hypot(O-q,Y-Q)<=te)return;F(),a==null||a(E)}$.current=!0;const Z={startX:q,startY:Q,x:O<q?O:q,y:Y<Q?Y:Q,width:Math.abs(O-q),height:Math.abs(Y-Q)},U=k.current,ee=P.current;k.current=new Set(ws(R,Z,L,n===vt.Partial,!0).map(te=>te.id)),P.current=new Set;const ne=(K==null?void 0:K.selectable)??!0;for(const te of k.current){const ie=V.get(te);if(ie)for(const{edgeId:ke}of ie.values()){const we=D.get(ke);we&&(we.selectable??ne)&&P.current.add(ke)}}if(!Qs(U,k.current)){const te=Ge(R,k.current,!0);W(te)}if(!Qs(ee,P.current)){const te=Ge(D,P.current);G(te)}b.setState({userSelectionRect:Z,userSelectionActive:!0,nodesSelectionActive:!1})},S=E=>{var _,L;E.button===0&&((L=(_=E.target)==null?void 0:_.releasePointerCapture)==null||L.call(_,E.pointerId),!v&&E.target===C.current&&b.getState().userSelectionRect&&(B==null||B(E)),b.setState({userSelectionActive:!1,userSelectionRect:null}),$.current&&(c==null||c(E),b.setState({nodesSelectionActive:k.current.size>0})))},I=s===!0||Array.isArray(s)&&s.includes(0);return r.jsxs("div",{className:oe(["react-flow__pane",{draggable:I,dragging:m,selection:e}]),onClick:w?void 0:Rn(B,C),onContextMenu:Rn(M,C),onWheel:Rn(A,C),onPointerEnter:w?void 0:d,onPointerMove:w?T:u,onPointerUp:w?S:void 0,onPointerDownCapture:w?j:void 0,onClickCapture:w?H:void 0,onPointerLeave:p,ref:C,style:Cn,children:[x,r.jsx(ap,{})]})}function es({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:c,onError:l}=t.getState(),f=c.get(e);if(!f){l==null||l("012",ge.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&a)&&(i({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var h;return(h=s==null?void 0:s.current)==null?void 0:h.blur()})):o([e])}function gi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:o,isSelectable:i,nodeClickDistance:a}){const c=re(),[l,f]=N.useState(!1),h=N.useRef();return N.useEffect(()=>{h.current=Kf({getStoreItems:()=>c.getState(),onNodeMouseDown:d=>{es({id:d,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),N.useEffect(()=>{if(!(t||!e.current||!h.current))return h.current.update({noDragClassName:n,handleSelector:s,domNode:e.current,isSelectable:i,nodeId:o,nodeClickDistance:a}),()=>{var d;(d=h.current)==null||d.destroy()}},[n,s,t,i,e,o,a]),l}const dp=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function bi(){const e=re();return N.useCallback(n=>{const{nodeExtent:s,snapToGrid:o,snapGrid:i,nodesDraggable:a,onError:c,updateNodePositions:l,nodeLookup:f,nodeOrigin:h}=e.getState(),d=new Map,u=dp(a),p=o?i[0]:5,x=o?i[1]:5,b=n.direction.x*p*n.factor,v=n.direction.y*x*n.factor;for(const[,y]of f){if(!u(y))continue;let m={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+v};o&&(m=Et(m,i));const{position:g,positionAbsolute:w}=Lo({nodeId:y.id,nextPosition:m,nodeLookup:f,nodeExtent:s,nodeOrigin:h,onError:c});y.position=g,y.internals.positionAbsolute=w,d.set(y.id,y)}l(d)},[])}const _s=N.createContext(null),up=_s.Provider;_s.Consumer;const yi=()=>N.useContext(_s),fp=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),hp=(e,t,n)=>s=>{const{connectionClickStartHandle:o,connectionMode:i,connection:a}=s,{fromHandle:c,toHandle:l,isValid:f}=a,h=(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:h,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:i===Qe.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!o,valid:h&&f}};function pp({type:e="source",position:t=X.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:i=!0,id:a,onConnect:c,children:l,className:f,onMouseDown:h,onTouchStart:d,...u},p){var T,S;const x=a||null,b=e==="target",v=re(),y=yi(),{connectOnClick:m,noPanClassName:g,rfId:w}=J(fp,se),{connectingFrom:C,connectingTo:z,clickConnecting:k,isPossibleEndHandle:P,connectionInProcess:$,clickConnectionInProcess:B,valid:M}=J(hp(y,x,e),se);y||(S=(T=v.getState()).onError)==null||S.call(T,"010",ge.error010());const A=I=>{const{defaultEdgeOptions:E,onConnect:_,hasDefaultEdges:L}=v.getState(),R={...E,...I};if(L){const{edges:D,setEdges:V}=v.getState();V(Pf(R,D))}_==null||_(R),c==null||c(R)},H=I=>{if(!y)return;const E=Wo(I.nativeEvent);if(o&&(E&&I.button===0||!E)){const _=v.getState();Jn.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:_.autoPanOnConnect,connectionMode:_.connectionMode,connectionRadius:_.connectionRadius,domNode:_.domNode,nodeLookup:_.nodeLookup,lib:_.lib,isTarget:b,handleId:x,nodeId:y,flowId:_.rfId,panBy:_.panBy,cancelConnection:_.cancelConnection,onConnectStart:_.onConnectStart,onConnectEnd:(...L)=>{var R,D;return(D=(R=v.getState()).onConnectEnd)==null?void 0:D.call(R,...L)},updateConnection:_.updateConnection,onConnect:A,isValidConnection:n||((...L)=>{var R,D;return((D=(R=v.getState()).isValidConnection)==null?void 0:D.call(R,...L))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:_.autoPanSpeed,dragThreshold:_.connectionDragThreshold})}E?h==null||h(I):d==null||d(I)},j=I=>{const{onClickConnectStart:E,onClickConnectEnd:_,connectionClickStartHandle:L,connectionMode:R,isValidConnection:D,lib:V,rfId:W,nodeLookup:G,connection:K}=v.getState();if(!y||!L&&!o)return;if(!L){E==null||E(I.nativeEvent,{nodeId:y,handleId:x,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:x}});return}const F=Vo(I.target),O=n||D,{connection:Y,isValid:q}=Jn.isValid(I.nativeEvent,{handle:{nodeId:y,id:x,type:e},connectionMode:R,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:O,flowId:W,doc:F,lib:V,nodeLookup:G});q&&Y&&A(Y);const Q=structuredClone(K);delete Q.inProgress,Q.toPosition=Q.toHandle?Q.toHandle.position:null,_==null||_(I,Q),v.setState({connectionClickStartHandle:null})};return r.jsx("div",{"data-handleid":x,"data-nodeid":y,"data-handlepos":t,"data-id":`${w}-${y}-${x}-${e}`,className:oe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",g,f,{source:!b,target:b,connectable:s,connectablestart:o,connectableend:i,clickconnecting:k,connectingfrom:C,connectingto:z,valid:M,connectionindicator:s&&(!$||P)&&($||B?i:o)}]),onMouseDown:H,onTouchStart:H,onClick:m?j:void 0,ref:p,...u,children:l})}const de=N.memo(xi(pp));function xp({data:e,isConnectable:t,sourcePosition:n=X.Bottom}){return r.jsxs(r.Fragment,{children:[e==null?void 0:e.label,r.jsx(de,{type:"source",position:n,isConnectable:t})]})}function mp({data:e,isConnectable:t,targetPosition:n=X.Top,sourcePosition:s=X.Bottom}){return r.jsxs(r.Fragment,{children:[r.jsx(de,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,r.jsx(de,{type:"source",position:s,isConnectable:t})]})}function gp(){return null}function bp({data:e,isConnectable:t,targetPosition:n=X.Top}){return r.jsxs(r.Fragment,{children:[r.jsx(de,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const un={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Er={input:xp,default:mp,output:bp,group:gp};function yp(e){var t,n,s,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((s=e.style)==null?void 0:s.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const wp=e=>{const{width:t,height:n,x:s,y:o}=St(e.nodeLookup,{filter:i=>!!i.selected});return{width:ue(t)?t:null,height:ue(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${s}px,${o}px)`}};function vp({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=re(),{width:o,height:i,transformString:a,userSelectionActive:c}=J(wp,se),l=bi(),f=N.useRef(null);N.useEffect(()=>{var p;n||(p=f.current)==null||p.focus({preventScroll:!0})},[n]);const h=!c&&o!==null&&i!==null;if(gi({nodeRef:f,disabled:!h}),!h)return null;const d=e?p=>{const x=s.getState().nodes.filter(b=>b.selected);e(p,x)}:void 0,u=p=>{Object.prototype.hasOwnProperty.call(un,p.key)&&(p.preventDefault(),l({direction:un[p.key],factor:p.shiftKey?4:1}))};return r.jsx("div",{className:oe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:r.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:o,height:i}})})}const _r=typeof window<"u"?window:void 0,Np=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function wi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:c,deleteKeyCode:l,selectionKeyCode:f,selectionOnDrag:h,selectionMode:d,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:m,zoomOnPinch:g,panOnScroll:w,panOnScrollSpeed:C,panOnScrollMode:z,zoomOnDoubleClick:k,panOnDrag:P,defaultViewport:$,translateExtent:B,minZoom:M,maxZoom:A,preventScrolling:H,onSelectionContextMenu:j,noWheelClassName:T,noPanClassName:S,disableKeyboardA11y:I,onViewportChange:E,isControlledViewport:_}){const{nodesSelectionActive:L,userSelectionActive:R}=J(Np,se),D=Ct(f,{target:_r}),V=Ct(b,{target:_r}),W=V||P,G=V||w,K=h&&W!==!0,F=D||R||K;return np({deleteKeyCode:l,multiSelectionKeyCode:x}),r.jsx(op,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:m,zoomOnPinch:g,panOnScroll:G,panOnScrollSpeed:C,panOnScrollMode:z,zoomOnDoubleClick:k,panOnDrag:!D&&W,defaultViewport:$,translateExtent:B,minZoom:M,maxZoom:A,zoomActivationKeyCode:v,preventScrolling:H,noWheelClassName:T,noPanClassName:S,onViewportChange:E,isControlledViewport:_,paneClickDistance:c,selectionOnDrag:K,children:r.jsxs(lp,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:W,isSelecting:!!F,selectionMode:d,selectionKeyPressed:D,paneClickDistance:c,selectionOnDrag:K,children:[e,L&&r.jsx(vp,{onSelectionContextMenu:j,noPanClassName:S,disableKeyboardA11y:I})]})})}wi.displayName="FlowRenderer";const jp=N.memo(wi),Cp=e=>t=>e?ws(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function zp(e){return J(N.useCallback(Cp(e),[e]),se)}const kp=e=>e.updateNodeInternals;function Sp(){const e=J(kp),[t]=N.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const s=new Map;n.forEach(o=>{const i=o.target.getAttribute("data-id");s.set(i,{id:i,nodeElement:o.target,force:!0})}),e(s)}));return N.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Ep({node:e,nodeType:t,hasDimensions:n,resizeObserver:s}){const o=re(),i=N.useRef(null),a=N.useRef(null),c=N.useRef(e.sourcePosition),l=N.useRef(e.targetPosition),f=N.useRef(t),h=n&&!!e.internals.handleBounds;return N.useEffect(()=>{i.current&&!e.hidden&&(!h||a.current!==i.current)&&(a.current&&(s==null||s.unobserve(a.current)),s==null||s.observe(i.current),a.current=i.current)},[h,e.hidden]),N.useEffect(()=>()=>{a.current&&(s==null||s.unobserve(a.current),a.current=null)},[]),N.useEffect(()=>{if(i.current){const d=f.current!==t,u=c.current!==e.sourcePosition,p=l.current!==e.targetPosition;(d||u||p)&&(f.current=t,c.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function _p({id:e,onClick:t,onMouseEnter:n,onMouseMove:s,onMouseLeave:o,onContextMenu:i,onDoubleClick:a,nodesDraggable:c,elementsSelectable:l,nodesConnectable:f,nodesFocusable:h,resizeObserver:d,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:x,rfId:b,nodeTypes:v,nodeClickDistance:y,onError:m}){const{node:g,internals:w,isParent:C}=J(O=>{const Y=O.nodeLookup.get(e),q=O.parentLookup.has(e);return{node:Y,internals:Y.internals,isParent:q}},se);let z=g.type||"default",k=(v==null?void 0:v[z])||Er[z];k===void 0&&(m==null||m("003",ge.error003(z)),z="default",k=(v==null?void 0:v.default)||Er.default);const P=!!(g.draggable||c&&typeof g.draggable>"u"),$=!!(g.selectable||l&&typeof g.selectable>"u"),B=!!(g.connectable||f&&typeof g.connectable>"u"),M=!!(g.focusable||h&&typeof g.focusable>"u"),A=re(),H=Bo(g),j=Ep({node:g,nodeType:z,hasDimensions:H,resizeObserver:d}),T=gi({nodeRef:j,disabled:g.hidden||!P,noDragClassName:u,handleSelector:g.dragHandle,nodeId:e,isSelectable:$,nodeClickDistance:y}),S=bi();if(g.hidden)return null;const I=ze(g),E=yp(g),_=$||P||t||n||s||o,L=n?O=>n(O,{...w.userNode}):void 0,R=s?O=>s(O,{...w.userNode}):void 0,D=o?O=>o(O,{...w.userNode}):void 0,V=i?O=>i(O,{...w.userNode}):void 0,W=a?O=>a(O,{...w.userNode}):void 0,G=O=>{const{selectNodesOnDrag:Y,nodeDragThreshold:q}=A.getState();$&&(!Y||!P||q>0)&&es({id:e,store:A,nodeRef:j}),t&&t(O,{...w.userNode})},K=O=>{if(!(Yo(O.nativeEvent)||x)){if(To.includes(O.key)&&$){const Y=O.key==="Escape";es({id:e,store:A,unselect:Y,nodeRef:j})}else if(P&&g.selected&&Object.prototype.hasOwnProperty.call(un,O.key)){O.preventDefault();const{ariaLabelConfig:Y}=A.getState();A.setState({ariaLiveMessage:Y["node.a11yDescription.ariaLiveMessage"]({direction:O.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),S({direction:un[O.key],factor:O.shiftKey?4:1})}}},F=()=>{var ee;if(x||!((ee=j.current)!=null&&ee.matches(":focus-visible")))return;const{transform:O,width:Y,height:q,autoPanOnNodeFocus:Q,setCenter:Z}=A.getState();if(!Q)return;ws(new Map([[e,g]]),{x:0,y:0,width:Y,height:q},O,!0).length>0||Z(g.position.x+I.width/2,g.position.y+I.height/2,{zoom:O[2]})};return r.jsx("div",{className:oe(["react-flow__node",`react-flow__node-${z}`,{[p]:P},g.className,{selected:g.selected,selectable:$,parent:C,draggable:P,dragging:T}]),ref:j,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:_?"all":"none",visibility:H?"visible":"hidden",...g.style,...E},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:R,onMouseLeave:D,onContextMenu:V,onClick:G,onDoubleClick:W,onKeyDown:M?K:void 0,tabIndex:M?0:void 0,onFocus:M?F:void 0,role:g.ariaRole??(M?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${li}-${b}`,"aria-label":g.ariaLabel,...g.domAttributes,children:r.jsx(up,{value:e,children:r.jsx(k,{id:e,data:g.data,type:z,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:g.selected??!1,selectable:$,draggable:P,deletable:g.deletable??!0,isConnectable:B,sourcePosition:g.sourcePosition,targetPosition:g.targetPosition,dragging:T,dragHandle:g.dragHandle,zIndex:w.z,parentId:g.parentId,...I})})})}var Mp=N.memo(_p);const Ip=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function vi(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:o,onError:i}=J(Ip,se),a=zp(e.onlyRenderVisibleElements),c=Sp();return r.jsx("div",{className:"react-flow__nodes",style:Cn,children:a.map(l=>r.jsx(Mp,{id:l,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:i},l))})}vi.displayName="NodeRenderer";const Tp=N.memo(vi);function Ap(e){return J(N.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const s=[];if(n.width&&n.height)for(const o of n.edges){const i=n.nodeLookup.get(o.source),a=n.nodeLookup.get(o.target);i&&a&&If({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&s.push(o.id)}return s},[e]),se)}const Pp=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return r.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},$p=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return r.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Mr={[an.Arrow]:Pp,[an.ArrowClosed]:$p};function Dp(e){const t=re();return N.useMemo(()=>{var o,i;return Object.prototype.hasOwnProperty.call(Mr,e)?Mr[e]:((i=(o=t.getState()).onError)==null||i.call(o,"009",ge.error009(e)),null)},[e])}const Lp=({id:e,type:t,color:n,width:s=12.5,height:o=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:c="auto-start-reverse"})=>{const l=Dp(t);return l?r.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:c,refX:"0",refY:"0",children:r.jsx(l,{color:n,strokeWidth:a})}):null},Ni=({defaultColor:e,rfId:t})=>{const n=J(i=>i.edges),s=J(i=>i.defaultEdgeOptions),o=N.useMemo(()=>Hf(n,{id:t,defaultColor:e,defaultMarkerStart:s==null?void 0:s.markerStart,defaultMarkerEnd:s==null?void 0:s.markerEnd}),[n,s,t,e]);return o.length?r.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:r.jsx("defs",{children:o.map(i=>r.jsx(Lp,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Ni.displayName="MarkerDefinitions";var Rp=N.memo(Ni);function ji({x:e,y:t,label:n,labelStyle:s,labelShowBg:o=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:c=2,children:l,className:f,...h}){const[d,u]=N.useState({x:1,y:0,width:0,height:0}),p=oe(["react-flow__edge-textwrapper",f]),x=N.useRef(null);return N.useEffect(()=>{if(x.current){const b=x.current.getBBox();u({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?r.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?"visible":"hidden",...h,children:[o&&r.jsx("rect",{width:d.width+2*a[0],x:-a[0],y:-a[1],height:d.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),r.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:x,style:s,children:n}),l]}):null}ji.displayName="EdgeText";const Hp=N.memo(ji);function Mt({path:e,labelX:t,labelY:n,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l,interactionWidth:f=20,...h}){return r.jsxs(r.Fragment,{children:[r.jsx("path",{...h,d:e,fill:"none",className:oe(["react-flow__edge-path",h.className])}),f?r.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,s&&ue(t)&&ue(n)?r.jsx(Hp,{x:t,y:n,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:a,labelBgPadding:c,labelBgBorderRadius:l}):null]})}function Ir({pos:e,x1:t,y1:n,x2:s,y2:o}){return e===X.Left||e===X.Right?[.5*(t+s),n]:[t,.5*(n+o)]}function Ci({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:s,targetY:o,targetPosition:i=X.Top}){const[a,c]=Ir({pos:n,x1:e,y1:t,x2:s,y2:o}),[l,f]=Ir({pos:i,x1:s,y1:o,x2:e,y2:t}),[h,d,u,p]=Xo({sourceX:e,sourceY:t,targetX:s,targetY:o,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:f});return[`M${e},${t} C${a},${c} ${l},${f} ${s},${o}`,h,d,u,p]}function zi(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:a,targetPosition:c,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,interactionWidth:y})=>{const[m,g,w]=Ci({sourceX:n,sourceY:s,sourcePosition:a,targetX:o,targetY:i,targetPosition:c}),C=e.isInternal?void 0:t;return r.jsx(Mt,{id:C,path:m,labelX:g,labelY:w,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,interactionWidth:y})})}const Op=zi({isInternal:!1}),ki=zi({isInternal:!0});Op.displayName="SimpleBezierEdge";ki.displayName="SimpleBezierEdgeInternal";function Si(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,sourcePosition:p=X.Bottom,targetPosition:x=X.Top,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:m})=>{const[g,w,C]=dn({sourceX:n,sourceY:s,sourcePosition:p,targetX:o,targetY:i,targetPosition:x,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),z=e.isInternal?void 0:t;return r.jsx(Mt,{id:z,path:g,labelX:w,labelY:C,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:b,markerStart:v,interactionWidth:m})})}const Ei=Si({isInternal:!1}),_i=Si({isInternal:!0});Ei.displayName="SmoothStepEdge";_i.displayName="SmoothStepEdgeInternal";function Mi(e){return N.memo(({id:t,...n})=>{var o;const s=e.isInternal?void 0:t;return r.jsx(Ei,{...n,id:s,pathOptions:N.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const Bp=Mi({isInternal:!1}),Ii=Mi({isInternal:!0});Bp.displayName="StepEdge";Ii.displayName="StepEdgeInternal";function Ti(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:b})=>{const[v,y,m]=Uo({sourceX:n,sourceY:s,targetX:o,targetY:i}),g=e.isInternal?void 0:t;return r.jsx(Mt,{id:g,path:v,labelX:y,labelY:m,label:a,labelStyle:c,labelShowBg:l,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:b})})}const Fp=Ti({isInternal:!1}),Ai=Ti({isInternal:!0});Fp.displayName="StraightEdge";Ai.displayName="StraightEdgeInternal";function Pi(e){return N.memo(({id:t,sourceX:n,sourceY:s,targetX:o,targetY:i,sourcePosition:a=X.Bottom,targetPosition:c=X.Top,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,pathOptions:y,interactionWidth:m})=>{const[g,w,C]=Go({sourceX:n,sourceY:s,sourcePosition:a,targetX:o,targetY:i,targetPosition:c,curvature:y==null?void 0:y.curvature}),z=e.isInternal?void 0:t;return r.jsx(Mt,{id:z,path:g,labelX:w,labelY:C,label:l,labelStyle:f,labelShowBg:h,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:b,markerStart:v,interactionWidth:m})})}const Vp=Pi({isInternal:!1}),$i=Pi({isInternal:!0});Vp.displayName="BezierEdge";$i.displayName="BezierEdgeInternal";const Tr={default:$i,straight:Ai,step:Ii,smoothstep:_i,simplebezier:ki},Ar={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Yp=(e,t,n)=>n===X.Left?e-t:n===X.Right?e+t:e,Wp=(e,t,n)=>n===X.Top?e-t:n===X.Bottom?e+t:e,Pr="react-flow__edgeupdater";function $r({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:o,onMouseEnter:i,onMouseOut:a,type:c}){return r.jsx("circle",{onMouseDown:o,onMouseEnter:i,onMouseOut:a,className:oe([Pr,`${Pr}-${c}`]),cx:Yp(t,s,e),cy:Wp(n,s,e),r:s,stroke:"transparent",fill:"transparent"})}function Xp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:s,sourceY:o,targetX:i,targetY:a,sourcePosition:c,targetPosition:l,onReconnect:f,onReconnectStart:h,onReconnectEnd:d,setReconnecting:u,setUpdateHover:p}){const x=re(),b=(w,C)=>{if(w.button!==0)return;const{autoPanOnConnect:z,domNode:k,connectionMode:P,connectionRadius:$,lib:B,onConnectStart:M,cancelConnection:A,nodeLookup:H,rfId:j,panBy:T,updateConnection:S}=x.getState(),I=C.type==="target",E=(R,D)=>{u(!1),d==null||d(R,n,C.type,D)},_=R=>f==null?void 0:f(n,R),L=(R,D)=>{u(!0),h==null||h(w,n,C.type),M==null||M(R,D)};Jn.onPointerDown(w.nativeEvent,{autoPanOnConnect:z,connectionMode:P,connectionRadius:$,domNode:k,handleId:C.id,nodeId:C.nodeId,nodeLookup:H,isTarget:I,edgeUpdaterType:C.type,lib:B,flowId:j,cancelConnection:A,panBy:T,isValidConnection:(...R)=>{var D,V;return((V=(D=x.getState()).isValidConnection)==null?void 0:V.call(D,...R))??!0},onConnect:_,onConnectStart:L,onConnectEnd:(...R)=>{var D,V;return(V=(D=x.getState()).onConnectEnd)==null?void 0:V.call(D,...R)},onReconnectEnd:E,updateConnection:S,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},v=w=>b(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=w=>b(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),m=()=>p(!0),g=()=>p(!1);return r.jsxs(r.Fragment,{children:[(e===!0||e==="source")&&r.jsx($r,{position:c,centerX:s,centerY:o,radius:t,onMouseDown:v,onMouseEnter:m,onMouseOut:g,type:"source"}),(e===!0||e==="target")&&r.jsx($r,{position:l,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:m,onMouseOut:g,type:"target"})]})}function Gp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:s,onClick:o,onDoubleClick:i,onContextMenu:a,onMouseEnter:c,onMouseMove:l,onMouseLeave:f,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,rfId:x,edgeTypes:b,noPanClassName:v,onError:y,disableKeyboardA11y:m}){let g=J(Z=>Z.edgeLookup.get(e));const w=J(Z=>Z.defaultEdgeOptions);g=w?{...w,...g}:g;let C=g.type||"default",z=(b==null?void 0:b[C])||Tr[C];z===void 0&&(y==null||y("011",ge.error011(C)),C="default",z=(b==null?void 0:b.default)||Tr.default);const k=!!(g.focusable||t&&typeof g.focusable>"u"),P=typeof d<"u"&&(g.reconnectable||n&&typeof g.reconnectable>"u"),$=!!(g.selectable||s&&typeof g.selectable>"u"),B=N.useRef(null),[M,A]=N.useState(!1),[H,j]=N.useState(!1),T=re(),{zIndex:S,sourceX:I,sourceY:E,targetX:_,targetY:L,sourcePosition:R,targetPosition:D}=J(N.useCallback(Z=>{const U=Z.nodeLookup.get(g.source),ee=Z.nodeLookup.get(g.target);if(!U||!ee)return{zIndex:g.zIndex,...Ar};const ne=Rf({id:e,sourceNode:U,targetNode:ee,sourceHandle:g.sourceHandle||null,targetHandle:g.targetHandle||null,connectionMode:Z.connectionMode,onError:y});return{zIndex:Mf({selected:g.selected,zIndex:g.zIndex,sourceNode:U,targetNode:ee,elevateOnSelect:Z.elevateEdgesOnSelect,zIndexMode:Z.zIndexMode}),...ne||Ar}},[g.source,g.target,g.sourceHandle,g.targetHandle,g.selected,g.zIndex]),se),V=N.useMemo(()=>g.markerStart?`url('#${Zn(g.markerStart,x)}')`:void 0,[g.markerStart,x]),W=N.useMemo(()=>g.markerEnd?`url('#${Zn(g.markerEnd,x)}')`:void 0,[g.markerEnd,x]);if(g.hidden||I===null||E===null||_===null||L===null)return null;const G=Z=>{var te;const{addSelectedEdges:U,unselectNodesAndEdges:ee,multiSelectionActive:ne}=T.getState();$&&(T.setState({nodesSelectionActive:!1}),g.selected&&ne?(ee({nodes:[],edges:[g]}),(te=B.current)==null||te.blur()):U([e])),o&&o(Z,g)},K=i?Z=>{i(Z,{...g})}:void 0,F=a?Z=>{a(Z,{...g})}:void 0,O=c?Z=>{c(Z,{...g})}:void 0,Y=l?Z=>{l(Z,{...g})}:void 0,q=f?Z=>{f(Z,{...g})}:void 0,Q=Z=>{var U;if(!m&&To.includes(Z.key)&&$){const{unselectNodesAndEdges:ee,addSelectedEdges:ne}=T.getState();Z.key==="Escape"?((U=B.current)==null||U.blur(),ee({edges:[g]})):ne([e])}};return r.jsx("svg",{style:{zIndex:S},children:r.jsxs("g",{className:oe(["react-flow__edge",`react-flow__edge-${C}`,g.className,v,{selected:g.selected,animated:g.animated,inactive:!$&&!o,updating:M,selectable:$}]),onClick:G,onDoubleClick:K,onContextMenu:F,onMouseEnter:O,onMouseMove:Y,onMouseLeave:q,onKeyDown:k?Q:void 0,tabIndex:k?0:void 0,role:g.ariaRole??(k?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":g.ariaLabel===null?void 0:g.ariaLabel||`Edge from ${g.source} to ${g.target}`,"aria-describedby":k?`${di}-${x}`:void 0,ref:B,...g.domAttributes,children:[!H&&r.jsx(z,{id:e,source:g.source,target:g.target,type:g.type,selected:g.selected,animated:g.animated,selectable:$,deletable:g.deletable??!0,label:g.label,labelStyle:g.labelStyle,labelShowBg:g.labelShowBg,labelBgStyle:g.labelBgStyle,labelBgPadding:g.labelBgPadding,labelBgBorderRadius:g.labelBgBorderRadius,sourceX:I,sourceY:E,targetX:_,targetY:L,sourcePosition:R,targetPosition:D,data:g.data,style:g.style,sourceHandleId:g.sourceHandle,targetHandleId:g.targetHandle,markerStart:V,markerEnd:W,pathOptions:"pathOptions"in g?g.pathOptions:void 0,interactionWidth:g.interactionWidth}),P&&r.jsx(Xp,{edge:g,isReconnectable:P,reconnectRadius:h,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,sourceX:I,sourceY:E,targetX:_,targetY:L,sourcePosition:R,targetPosition:D,setUpdateHover:A,setReconnecting:j})]})})}var qp=N.memo(Gp);const Up=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Di({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:s,noPanClassName:o,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:c,onEdgeMouseMove:l,onEdgeMouseLeave:f,onEdgeClick:h,reconnectRadius:d,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,disableKeyboardA11y:b}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:m,onError:g}=J(Up,se),w=Ap(t);return r.jsxs("div",{className:"react-flow__edges",children:[r.jsx(Rp,{defaultColor:e,rfId:n}),w.map(C=>r.jsx(qp,{id:C,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:m,noPanClassName:o,onReconnect:i,onContextMenu:a,onMouseEnter:c,onMouseMove:l,onMouseLeave:f,onClick:h,reconnectRadius:d,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,rfId:n,onError:g,edgeTypes:s,disableKeyboardA11y:b},C))]})}Di.displayName="EdgeRenderer";const Kp=N.memo(Di),Zp=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Qp({children:e}){const t=J(Zp);return r.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Jp(e){const t=Es(),n=N.useRef(!1);N.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const ex=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function tx(e){const t=J(ex),n=re();return N.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function nx(e){return e.connection.inProgress?{...e.connection,to:_t(e.connection.to,e.transform)}:{...e.connection}}function sx(e){return nx}function rx(e){const t=sx();return J(t,se)}const ox=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ix({containerStyle:e,style:t,type:n,component:s}){const{nodesConnectable:o,width:i,height:a,isValid:c,inProgress:l}=J(ox,se);return!(i&&o&&l)?null:r.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:r.jsx("g",{className:oe(["react-flow__connection",$o(c)]),children:r.jsx(Li,{style:t,type:n,CustomComponent:s,isValid:c})})})}const Li=({style:e,type:t=Me.Bezier,CustomComponent:n,isValid:s})=>{const{inProgress:o,from:i,fromNode:a,fromHandle:c,fromPosition:l,to:f,toNode:h,toHandle:d,toPosition:u,pointer:p}=rx();if(!o)return;if(n)return r.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:c,fromX:i.x,fromY:i.y,toX:f.x,toY:f.y,fromPosition:l,toPosition:u,connectionStatus:$o(s),toNode:h,toHandle:d,pointer:p});let x="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:f.x,targetY:f.y,targetPosition:u};switch(t){case Me.Bezier:[x]=Go(b);break;case Me.SimpleBezier:[x]=Ci(b);break;case Me.Step:[x]=dn({...b,borderRadius:0});break;case Me.SmoothStep:[x]=dn(b);break;default:[x]=Uo(b)}return r.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:e})};Li.displayName="ConnectionLine";const ax={};function Dr(e=ax){N.useRef(e),re(),N.useEffect(()=>{},[e])}function cx(){re(),N.useRef(!1),N.useEffect(()=>{},[])}function Ri({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:s,onEdgeClick:o,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:d,onSelectionStart:u,onSelectionEnd:p,connectionLineType:x,connectionLineStyle:b,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:m,selectionOnDrag:g,selectionMode:w,multiSelectionKeyCode:C,panActivationKeyCode:z,zoomActivationKeyCode:k,deleteKeyCode:P,onlyRenderVisibleElements:$,elementsSelectable:B,defaultViewport:M,translateExtent:A,minZoom:H,maxZoom:j,preventScrolling:T,defaultMarkerColor:S,zoomOnScroll:I,zoomOnPinch:E,panOnScroll:_,panOnScrollSpeed:L,panOnScrollMode:R,zoomOnDoubleClick:D,panOnDrag:V,onPaneClick:W,onPaneMouseEnter:G,onPaneMouseMove:K,onPaneMouseLeave:F,onPaneScroll:O,onPaneContextMenu:Y,paneClickDistance:q,nodeClickDistance:Q,onEdgeContextMenu:Z,onEdgeMouseEnter:U,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,onReconnect:ie,onReconnectStart:ke,onReconnectEnd:we,noDragClassName:Ae,noWheelClassName:it,noPanClassName:at,disableKeyboardA11y:ct,nodeExtent:zn,rfId:It,viewport:Oe,onViewportChange:lt}){return Dr(e),Dr(t),cx(),Jp(n),tx(Oe),r.jsx(jp,{onPaneClick:W,onPaneMouseEnter:G,onPaneMouseMove:K,onPaneMouseLeave:F,onPaneContextMenu:Y,onPaneScroll:O,paneClickDistance:q,deleteKeyCode:P,selectionKeyCode:m,selectionOnDrag:g,selectionMode:w,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:z,zoomActivationKeyCode:k,elementsSelectable:B,zoomOnScroll:I,zoomOnPinch:E,zoomOnDoubleClick:D,panOnScroll:_,panOnScrollSpeed:L,panOnScrollMode:R,panOnDrag:V,defaultViewport:M,translateExtent:A,minZoom:H,maxZoom:j,onSelectionContextMenu:d,preventScrolling:T,noDragClassName:Ae,noWheelClassName:it,noPanClassName:at,disableKeyboardA11y:ct,onViewportChange:lt,isControlledViewport:!!Oe,children:r.jsxs(Qp,{children:[r.jsx(Kp,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:a,onReconnect:ie,onReconnectStart:ke,onReconnectEnd:we,onlyRenderVisibleElements:$,onEdgeContextMenu:Z,onEdgeMouseEnter:U,onEdgeMouseMove:ee,onEdgeMouseLeave:ne,reconnectRadius:te,defaultMarkerColor:S,noPanClassName:at,disableKeyboardA11y:ct,rfId:It}),r.jsx(ix,{style:b,type:x,component:v,containerStyle:y}),r.jsx("div",{className:"react-flow__edgelabel-renderer"}),r.jsx(Tp,{nodeTypes:e,onNodeClick:s,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:l,onNodeMouseLeave:f,onNodeContextMenu:h,nodeClickDistance:Q,onlyRenderVisibleElements:$,noPanClassName:at,noDragClassName:Ae,disableKeyboardA11y:ct,nodeExtent:zn,rfId:It}),r.jsx("div",{className:"react-flow__viewport-portal"})]})})}Ri.displayName="GraphView";const lx=N.memo(Ri),Lr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:a,fitViewOptions:c,minZoom:l=.5,maxZoom:f=2,nodeOrigin:h,nodeExtent:d,zIndexMode:u="basic"}={})=>{const p=new Map,x=new Map,b=new Map,v=new Map,y=s??t??[],m=n??e??[],g=h??[0,0],w=d??wt;Qo(b,v,y);const C=Qn(m,p,x,{nodeOrigin:g,nodeExtent:w,zIndexMode:u});let z=[0,0,1];if(a&&o&&i){const k=St(p,{filter:M=>!!((M.width||M.initialWidth)&&(M.height||M.initialHeight))}),{x:P,y:$,zoom:B}=vs(k,o,i,l,f,(c==null?void 0:c.padding)??.1);z=[P,$,B]}return{rfId:"1",width:o??0,height:i??0,transform:z,nodes:m,nodesInitialized:C,nodeLookup:p,parentLookup:x,edges:y,edgeLookup:v,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:s!==void 0,panZoom:null,minZoom:l,maxZoom:f,translateExtent:wt,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Qe.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:g,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:c,fitViewResolver:null,connection:{...Po},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Cf,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ao,zIndexMode:u,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},dx=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:h,nodeExtent:d,zIndexMode:u})=>Eh((p,x)=>{async function b(){const{nodeLookup:v,panZoom:y,fitViewOptions:m,fitViewResolver:g,width:w,height:C,minZoom:z,maxZoom:k}=x();y&&(await Nf({nodes:v,width:w,height:C,panZoom:y,minZoom:z,maxZoom:k},m),g==null||g.resolve(!0),p({fitViewResolver:null}))}return{...Lr({nodes:e,edges:t,width:o,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:f,nodeOrigin:h,nodeExtent:d,defaultNodes:n,defaultEdges:s,zIndexMode:u}),setNodes:v=>{const{nodeLookup:y,parentLookup:m,nodeOrigin:g,elevateNodesOnSelect:w,fitViewQueued:C,zIndexMode:z}=x(),k=Qn(v,y,m,{nodeOrigin:g,nodeExtent:d,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:z});C&&k?(b(),p({nodes:v,nodesInitialized:k,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:v,nodesInitialized:k})},setEdges:v=>{const{connectionLookup:y,edgeLookup:m}=x();Qo(y,m,v),p({edges:v})},setDefaultNodesAndEdges:(v,y)=>{if(v){const{setNodes:m}=x();m(v),p({hasDefaultNodes:!0})}if(y){const{setEdges:m}=x();m(y),p({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:y,nodeLookup:m,parentLookup:g,domNode:w,nodeOrigin:C,nodeExtent:z,debug:k,fitViewQueued:P,zIndexMode:$}=x(),{changes:B,updatedInternals:M}=Xf(v,m,g,w,C,z,$);M&&(Ff(m,g,{nodeOrigin:C,nodeExtent:z,zIndexMode:$}),P?(b(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(B==null?void 0:B.length)>0&&(k&&console.log("React Flow: trigger node changes",B),y==null||y(B)))},updateNodePositions:(v,y=!1)=>{const m=[];let g=[];const{nodeLookup:w,triggerNodeChanges:C,connection:z,updateConnection:k,onNodesChangeMiddlewareMap:P}=x();for(const[$,B]of v){const M=w.get($),A=!!(M!=null&&M.expandParent&&(M!=null&&M.parentId)&&(B!=null&&B.position)),H={id:$,type:"position",position:A?{x:Math.max(0,B.position.x),y:Math.max(0,B.position.y)}:B.position,dragging:y};if(M&&z.inProgress&&z.fromNode.id===M.id){const j=He(M,z.fromHandle,X.Left,!0);k({...z,from:j})}A&&M.parentId&&m.push({id:$,parentId:M.parentId,rect:{...B.internals.positionAbsolute,width:B.measured.width??0,height:B.measured.height??0}}),g.push(H)}if(m.length>0){const{parentLookup:$,nodeOrigin:B}=x(),M=Ss(m,w,$,B);g.push(...M)}for(const $ of P.values())g=$(g);C(g)},triggerNodeChanges:v=>{const{onNodesChange:y,setNodes:m,nodes:g,hasDefaultNodes:w,debug:C}=x();if(v!=null&&v.length){if(w){const z=hi(v,g);m(z)}C&&console.log("React Flow: trigger node changes",v),y==null||y(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:y,setEdges:m,edges:g,hasDefaultEdges:w,debug:C}=x();if(v!=null&&v.length){if(w){const z=pi(v,g);m(z)}C&&console.log("React Flow: trigger edge changes",v),y==null||y(v)}},addSelectedNodes:v=>{const{multiSelectionActive:y,edgeLookup:m,nodeLookup:g,triggerNodeChanges:w,triggerEdgeChanges:C}=x();if(y){const z=v.map(k=>Pe(k,!0));w(z);return}w(Ge(g,new Set([...v]),!0)),C(Ge(m))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:m,nodeLookup:g,triggerNodeChanges:w,triggerEdgeChanges:C}=x();if(y){const z=v.map(k=>Pe(k,!0));C(z);return}C(Ge(m,new Set([...v]))),w(Ge(g,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:y}={})=>{const{edges:m,nodes:g,nodeLookup:w,triggerNodeChanges:C,triggerEdgeChanges:z}=x(),k=v||g,P=y||m,$=[];for(const M of k){if(!M.selected)continue;const A=w.get(M.id);A&&(A.selected=!1),$.push(Pe(M.id,!1))}const B=[];for(const M of P)M.selected&&B.push(Pe(M.id,!1));C($),z(B)},setMinZoom:v=>{const{panZoom:y,maxZoom:m}=x();y==null||y.setScaleExtent([v,m]),p({minZoom:v})},setMaxZoom:v=>{const{panZoom:y,minZoom:m}=x();y==null||y.setScaleExtent([m,v]),p({maxZoom:v})},setTranslateExtent:v=>{var y;(y=x().panZoom)==null||y.setTranslateExtent(v),p({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:y,triggerNodeChanges:m,triggerEdgeChanges:g,elementsSelectable:w}=x();if(!w)return;const C=y.reduce((k,P)=>P.selected?[...k,Pe(P.id,!1)]:k,[]),z=v.reduce((k,P)=>P.selected?[...k,Pe(P.id,!1)]:k,[]);m(C),g(z)},setNodeExtent:v=>{const{nodes:y,nodeLookup:m,parentLookup:g,nodeOrigin:w,elevateNodesOnSelect:C,nodeExtent:z,zIndexMode:k}=x();v[0][0]===z[0][0]&&v[0][1]===z[0][1]&&v[1][0]===z[1][0]&&v[1][1]===z[1][1]||(Qn(y,m,g,{nodeOrigin:w,nodeExtent:v,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:k}),p({nodeExtent:v}))},panBy:v=>{const{transform:y,width:m,height:g,panZoom:w,translateExtent:C}=x();return Gf({delta:v,panZoom:w,transform:y,translateExtent:C,width:m,height:g})},setCenter:async(v,y,m)=>{const{width:g,height:w,maxZoom:C,panZoom:z}=x();if(!z)return Promise.resolve(!1);const k=typeof(m==null?void 0:m.zoom)<"u"?m.zoom:C;return await z.setViewport({x:g/2-v*k,y:w/2-y*k,zoom:k},{duration:m==null?void 0:m.duration,ease:m==null?void 0:m.ease,interpolate:m==null?void 0:m.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...Po}})},updateConnection:v=>{p({connection:v})},reset:()=>p({...Lr()})}},Object.is);function ux({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:s,initialWidth:o,initialHeight:i,initialMinZoom:a,initialMaxZoom:c,initialFitViewOptions:l,fitView:f,nodeOrigin:h,nodeExtent:d,zIndexMode:u,children:p}){const[x]=N.useState(()=>dx({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,width:o,height:i,fitView:f,minZoom:a,maxZoom:c,fitViewOptions:l,nodeOrigin:h,nodeExtent:d,zIndexMode:u}));return r.jsx(_h,{value:x,children:r.jsx(Qh,{children:p})})}function fx({children:e,nodes:t,edges:n,defaultNodes:s,defaultEdges:o,width:i,height:a,fitView:c,fitViewOptions:l,minZoom:f,maxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p}){return N.useContext(Nn)?r.jsx(r.Fragment,{children:e}):r.jsx(ux,{initialNodes:t,initialEdges:n,defaultNodes:s,defaultEdges:o,initialWidth:i,initialHeight:a,fitView:c,initialFitViewOptions:l,initialMinZoom:f,initialMaxZoom:h,nodeOrigin:d,nodeExtent:u,zIndexMode:p,children:e})}const hx={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function px({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:o,nodeTypes:i,edgeTypes:a,onNodeClick:c,onEdgeClick:l,onInit:f,onMove:h,onMoveStart:d,onMoveEnd:u,onConnect:p,onConnectStart:x,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:m,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:z,onNodeDragStart:k,onNodeDrag:P,onNodeDragStop:$,onNodesDelete:B,onEdgesDelete:M,onDelete:A,onSelectionChange:H,onSelectionDragStart:j,onSelectionDrag:T,onSelectionDragStop:S,onSelectionContextMenu:I,onSelectionStart:E,onSelectionEnd:_,onBeforeDelete:L,connectionMode:R,connectionLineType:D=Me.Bezier,connectionLineStyle:V,connectionLineComponent:W,connectionLineContainerStyle:G,deleteKeyCode:K="Backspace",selectionKeyCode:F="Shift",selectionOnDrag:O=!1,selectionMode:Y=vt.Full,panActivationKeyCode:q="Space",multiSelectionKeyCode:Q=jt()?"Meta":"Control",zoomActivationKeyCode:Z=jt()?"Meta":"Control",snapToGrid:U,snapGrid:ee,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:te,nodesDraggable:ie,autoPanOnNodeFocus:ke,nodesConnectable:we,nodesFocusable:Ae,nodeOrigin:it=ui,edgesFocusable:at,edgesReconnectable:ct,elementsSelectable:zn=!0,defaultViewport:It=Fh,minZoom:Oe=.5,maxZoom:lt=2,translateExtent:Is=wt,preventScrolling:sa=!0,nodeExtent:kn,defaultMarkerColor:ra="#b1b1b7",zoomOnScroll:oa=!0,zoomOnPinch:ia=!0,panOnScroll:aa=!1,panOnScrollSpeed:ca=.5,panOnScrollMode:la=$e.Free,zoomOnDoubleClick:da=!0,panOnDrag:ua=!0,onPaneClick:fa,onPaneMouseEnter:ha,onPaneMouseMove:pa,onPaneMouseLeave:xa,onPaneScroll:ma,onPaneContextMenu:ga,paneClickDistance:ba=1,nodeClickDistance:ya=0,children:wa,onReconnect:va,onReconnectStart:Na,onReconnectEnd:ja,onEdgeContextMenu:Ca,onEdgeDoubleClick:za,onEdgeMouseEnter:ka,onEdgeMouseMove:Sa,onEdgeMouseLeave:Ea,reconnectRadius:_a=10,onNodesChange:Ma,onEdgesChange:Ia,noDragClassName:Ta="nodrag",noWheelClassName:Aa="nowheel",noPanClassName:Ts="nopan",fitView:As,fitViewOptions:Ps,connectOnClick:Pa,attributionPosition:$a,proOptions:Da,defaultEdgeOptions:La,elevateNodesOnSelect:Ra=!0,elevateEdgesOnSelect:Ha=!1,disableKeyboardA11y:$s=!1,autoPanOnConnect:Oa,autoPanOnNodeDrag:Ba,autoPanSpeed:Fa,connectionRadius:Va,isValidConnection:Ya,onError:Wa,style:Xa,id:Ds,nodeDragThreshold:Ga,connectionDragThreshold:qa,viewport:Ua,onViewportChange:Ka,width:Za,height:Qa,colorMode:Ja="light",debug:ec,onScroll:Tt,ariaLabelConfig:tc,zIndexMode:Ls="basic",...nc},sc){const Sn=Ds||"1",rc=Xh(Ja),oc=N.useCallback(Rs=>{Rs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Tt==null||Tt(Rs)},[Tt]);return r.jsx("div",{"data-testid":"rf__wrapper",...nc,onScroll:oc,style:{...Xa,...hx},ref:sc,className:oe(["react-flow",o,rc]),id:Ds,role:"application",children:r.jsxs(fx,{nodes:e,edges:t,width:Za,height:Qa,fitView:As,fitViewOptions:Ps,minZoom:Oe,maxZoom:lt,nodeOrigin:it,nodeExtent:kn,zIndexMode:Ls,children:[r.jsx(lx,{onInit:f,onNodeClick:c,onEdgeClick:l,onNodeMouseEnter:m,onNodeMouseMove:g,onNodeMouseLeave:w,onNodeContextMenu:C,onNodeDoubleClick:z,nodeTypes:i,edgeTypes:a,connectionLineType:D,connectionLineStyle:V,connectionLineComponent:W,connectionLineContainerStyle:G,selectionKeyCode:F,selectionOnDrag:O,selectionMode:Y,deleteKeyCode:K,multiSelectionKeyCode:Q,panActivationKeyCode:q,zoomActivationKeyCode:Z,onlyRenderVisibleElements:ne,defaultViewport:It,translateExtent:Is,minZoom:Oe,maxZoom:lt,preventScrolling:sa,zoomOnScroll:oa,zoomOnPinch:ia,zoomOnDoubleClick:da,panOnScroll:aa,panOnScrollSpeed:ca,panOnScrollMode:la,panOnDrag:ua,onPaneClick:fa,onPaneMouseEnter:ha,onPaneMouseMove:pa,onPaneMouseLeave:xa,onPaneScroll:ma,onPaneContextMenu:ga,paneClickDistance:ba,nodeClickDistance:ya,onSelectionContextMenu:I,onSelectionStart:E,onSelectionEnd:_,onReconnect:va,onReconnectStart:Na,onReconnectEnd:ja,onEdgeContextMenu:Ca,onEdgeDoubleClick:za,onEdgeMouseEnter:ka,onEdgeMouseMove:Sa,onEdgeMouseLeave:Ea,reconnectRadius:_a,defaultMarkerColor:ra,noDragClassName:Ta,noWheelClassName:Aa,noPanClassName:Ts,rfId:Sn,disableKeyboardA11y:$s,nodeExtent:kn,viewport:Ua,onViewportChange:Ka}),r.jsx(Wh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:p,onConnectStart:x,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:ie,autoPanOnNodeFocus:ke,nodesConnectable:we,nodesFocusable:Ae,edgesFocusable:at,edgesReconnectable:ct,elementsSelectable:zn,elevateNodesOnSelect:Ra,elevateEdgesOnSelect:Ha,minZoom:Oe,maxZoom:lt,nodeExtent:kn,onNodesChange:Ma,onEdgesChange:Ia,snapToGrid:U,snapGrid:ee,connectionMode:R,translateExtent:Is,connectOnClick:Pa,defaultEdgeOptions:La,fitView:As,fitViewOptions:Ps,onNodesDelete:B,onEdgesDelete:M,onDelete:A,onNodeDragStart:k,onNodeDrag:P,onNodeDragStop:$,onSelectionDrag:T,onSelectionDragStart:j,onSelectionDragStop:S,onMove:h,onMoveStart:d,onMoveEnd:u,noPanClassName:Ts,nodeOrigin:it,rfId:Sn,autoPanOnConnect:Oa,autoPanOnNodeDrag:Ba,autoPanSpeed:Fa,onError:Wa,connectionRadius:Va,isValidConnection:Ya,selectNodesOnDrag:te,nodeDragThreshold:Ga,connectionDragThreshold:qa,onBeforeDelete:L,debug:ec,ariaLabelConfig:tc,zIndexMode:Ls}),r.jsx(Bh,{onSelectionChange:H}),wa,r.jsx(Dh,{proOptions:Da,position:$a}),r.jsx($h,{rfId:Sn,disableKeyboardA11y:$s})]})})}var Hi=xi(px);const xx=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function mx({children:e}){const t=J(xx);return t?ac.createPortal(e,t):null}function gx(e){const[t,n]=N.useState(e),s=N.useCallback(o=>n(i=>hi(o,i)),[]);return[t,n,s]}function bx(e){const[t,n]=N.useState(e),s=N.useCallback(o=>n(i=>pi(o,i)),[]);return[t,n,s]}function yx({dimensions:e,lineWidth:t,variant:n,className:s}){return r.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:oe(["react-flow__background-pattern",n,s])})}function wx({radius:e,className:t}){return r.jsx("circle",{cx:e,cy:e,r:e,className:oe(["react-flow__background-pattern","dots",t])})}var me;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(me||(me={}));const vx={[me.Dots]:1,[me.Lines]:1,[me.Cross]:6},Nx=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Oi({id:e,variant:t=me.Dots,gap:n=20,size:s,lineWidth:o=1,offset:i=0,color:a,bgColor:c,style:l,className:f,patternClassName:h}){const d=N.useRef(null),{transform:u,patternId:p}=J(Nx,se),x=s||vx[t],b=t===me.Dots,v=t===me.Cross,y=Array.isArray(n)?n:[n,n],m=[y[0]*u[2]||1,y[1]*u[2]||1],g=x*u[2],w=Array.isArray(i)?i:[i,i],C=v?[g,g]:m,z=[w[0]*u[2]||1+C[0]/2,w[1]*u[2]||1+C[1]/2],k=`${p}${e||""}`;return r.jsxs("svg",{className:oe(["react-flow__background",f]),style:{...l,...Cn,"--xy-background-color-props":c,"--xy-background-pattern-color-props":a},ref:d,"data-testid":"rf__background",children:[r.jsx("pattern",{id:k,x:u[0]%m[0],y:u[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:b?r.jsx(wx,{radius:g/2,className:h}):r.jsx(yx,{dimensions:C,lineWidth:o,variant:t,className:h})}),r.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${k})`})]})}Oi.displayName="Background";const Bi=N.memo(Oi);function jx(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:r.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Cx(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:r.jsx("path",{d:"M0 0h32v4.2H0z"})})}function zx(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:r.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function kx(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Sx(){return r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:r.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Rt({children:e,className:t,...n}){return r.jsx("button",{type:"button",className:oe(["react-flow__controls-button",t]),...n,children:e})}const Ex=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Fi({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:i,onZoomOut:a,onFitView:c,onInteractiveChange:l,className:f,children:h,position:d="bottom-left",orientation:u="vertical","aria-label":p}){const x=re(),{isInteractive:b,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:m}=J(Ex,se),{zoomIn:g,zoomOut:w,fitView:C}=Es(),z=()=>{g(),i==null||i()},k=()=>{w(),a==null||a()},P=()=>{C(o),c==null||c()},$=()=>{x.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),l==null||l(!b)},B=u==="horizontal"?"horizontal":"vertical";return r.jsxs(jn,{className:oe(["react-flow__controls",B,f]),position:d,style:e,"data-testid":"rf__controls","aria-label":p??m["controls.ariaLabel"],children:[t&&r.jsxs(r.Fragment,{children:[r.jsx(Rt,{onClick:z,className:"react-flow__controls-zoomin",title:m["controls.zoomIn.ariaLabel"],"aria-label":m["controls.zoomIn.ariaLabel"],disabled:y,children:r.jsx(jx,{})}),r.jsx(Rt,{onClick:k,className:"react-flow__controls-zoomout",title:m["controls.zoomOut.ariaLabel"],"aria-label":m["controls.zoomOut.ariaLabel"],disabled:v,children:r.jsx(Cx,{})})]}),n&&r.jsx(Rt,{className:"react-flow__controls-fitview",onClick:P,title:m["controls.fitView.ariaLabel"],"aria-label":m["controls.fitView.ariaLabel"],children:r.jsx(zx,{})}),s&&r.jsx(Rt,{className:"react-flow__controls-interactive",onClick:$,title:m["controls.interactive.ariaLabel"],"aria-label":m["controls.interactive.ariaLabel"],children:b?r.jsx(Sx,{}):r.jsx(kx,{})}),h]})}Fi.displayName="Controls";const _x=N.memo(Fi);function Mx({id:e,x:t,y:n,width:s,height:o,style:i,color:a,strokeColor:c,strokeWidth:l,className:f,borderRadius:h,shapeRendering:d,selected:u,onClick:p}){const{background:x,backgroundColor:b}=i||{},v=a||x||b;return r.jsx("rect",{className:oe(["react-flow__minimap-node",{selected:u},f]),x:t,y:n,rx:h,ry:h,width:s,height:o,style:{fill:v,stroke:c,strokeWidth:l},shapeRendering:d,onClick:p?y=>p(y,e):void 0})}const Ix=N.memo(Mx),Tx=e=>e.nodes.map(t=>t.id),Hn=e=>e instanceof Function?e:()=>e;function Ax({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:o,nodeComponent:i=Ix,onClick:a}){const c=J(Tx,se),l=Hn(t),f=Hn(e),h=Hn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return r.jsx(r.Fragment,{children:c.map(u=>r.jsx($x,{id:u,nodeColorFunc:l,nodeStrokeColorFunc:f,nodeClassNameFunc:h,nodeBorderRadius:s,nodeStrokeWidth:o,NodeComponent:i,onClick:a,shapeRendering:d},u))})}function Px({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:s,nodeBorderRadius:o,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:c,onClick:l}){const{node:f,x:h,y:d,width:u,height:p}=J(x=>{const b=x.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const v=b.internals.userNode,{x:y,y:m}=b.internals.positionAbsolute,{width:g,height:w}=ze(v);return{node:v,x:y,y:m,width:g,height:w}},se);return!f||f.hidden||!Bo(f)?null:r.jsx(c,{x:h,y:d,width:u,height:p,style:f.style,selected:!!f.selected,className:s(f),color:t(f),borderRadius:o,strokeColor:n(f),strokeWidth:i,shapeRendering:a,onClick:l,id:f.id})}const $x=N.memo(Px);var Dx=N.memo(Ax);const Lx=200,Rx=150,Hx=e=>!e.hidden,Ox=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Oo(St(e.nodeLookup,{filter:Hx}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Bx="react-flow__minimap-desc";function Vi({style:e,className:t,nodeStrokeColor:n,nodeColor:s,nodeClassName:o="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:c,bgColor:l,maskColor:f,maskStrokeColor:h,maskStrokeWidth:d,position:u="bottom-right",onClick:p,onNodeClick:x,pannable:b=!1,zoomable:v=!1,ariaLabel:y,inversePan:m,zoomStep:g=1,offsetScale:w=5}){const C=re(),z=N.useRef(null),{boundingRect:k,viewBB:P,rfId:$,panZoom:B,translateExtent:M,flowWidth:A,flowHeight:H,ariaLabelConfig:j}=J(Ox,se),T=(e==null?void 0:e.width)??Lx,S=(e==null?void 0:e.height)??Rx,I=k.width/T,E=k.height/S,_=Math.max(I,E),L=_*T,R=_*S,D=w*_,V=k.x-(L-k.width)/2-D,W=k.y-(R-k.height)/2-D,G=L+D*2,K=R+D*2,F=`${Bx}-${$}`,O=N.useRef(0),Y=N.useRef();O.current=_,N.useEffect(()=>{if(z.current&&B)return Y.current=nh({domNode:z.current,panZoom:B,getTransform:()=>C.getState().transform,getViewScale:()=>O.current}),()=>{var U;(U=Y.current)==null||U.destroy()}},[B]),N.useEffect(()=>{var U;(U=Y.current)==null||U.update({translateExtent:M,width:A,height:H,inversePan:m,pannable:b,zoomStep:g,zoomable:v})},[b,v,m,g,M,A,H]);const q=p?U=>{var te;const[ee,ne]=((te=Y.current)==null?void 0:te.pointer(U))||[0,0];p(U,{x:ee,y:ne})}:void 0,Q=x?N.useCallback((U,ee)=>{const ne=C.getState().nodeLookup.get(ee).internals.userNode;x(U,ne)},[]):void 0,Z=y??j["minimap.ariaLabel"];return r.jsx(jn,{position:u,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*_:void 0,"--xy-minimap-node-background-color-props":typeof s=="string"?s:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:oe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:r.jsxs("svg",{width:T,height:S,viewBox:`${V} ${W} ${G} ${K}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":F,ref:z,onClick:q,children:[Z&&r.jsx("title",{id:F,children:Z}),r.jsx(Dx,{onClick:Q,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:o,nodeStrokeWidth:a,nodeComponent:c}),r.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-D},${W-D}h${G+D*2}v${K+D*2}h${-G-D*2}z
|
|
68
|
+
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Vi.displayName="MiniMap";N.memo(Vi);const Fx=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Vx={[nt.Line]:"right",[nt.Handle]:"bottom-right"};function Yx({nodeId:e,position:t,variant:n=nt.Handle,className:s,style:o=void 0,children:i,color:a,minWidth:c=10,minHeight:l=10,maxWidth:f=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:u,autoScale:p=!0,shouldResize:x,onResizeStart:b,onResize:v,onResizeEnd:y}){const m=yi(),g=typeof e=="string"?e:m,w=re(),C=N.useRef(null),z=n===nt.Handle,k=J(N.useCallback(Fx(z&&p),[z,p]),se),P=N.useRef(null),$=t??Vx[n];N.useEffect(()=>{if(!(!C.current||!g))return P.current||(P.current=mh({domNode:C.current,nodeId:g,getStoreItems:()=>{const{nodeLookup:M,transform:A,snapGrid:H,snapToGrid:j,nodeOrigin:T,domNode:S}=w.getState();return{nodeLookup:M,transform:A,snapGrid:H,snapToGrid:j,nodeOrigin:T,paneDomNode:S}},onChange:(M,A)=>{const{triggerNodeChanges:H,nodeLookup:j,parentLookup:T,nodeOrigin:S}=w.getState(),I=[],E={x:M.x,y:M.y},_=j.get(g);if(_&&_.expandParent&&_.parentId){const L=_.origin??S,R=M.width??_.measured.width??0,D=M.height??_.measured.height??0,V={id:_.id,parentId:_.parentId,rect:{width:R,height:D,...Fo({x:M.x??_.position.x,y:M.y??_.position.y},{width:R,height:D},_.parentId,j,L)}},W=Ss([V],j,T,S);I.push(...W),E.x=M.x?Math.max(L[0]*R,M.x):void 0,E.y=M.y?Math.max(L[1]*D,M.y):void 0}if(E.x!==void 0&&E.y!==void 0){const L={id:g,type:"position",position:{...E}};I.push(L)}if(M.width!==void 0&&M.height!==void 0){const R={id:g,type:"dimensions",resizing:!0,setAttributes:u?u==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};I.push(R)}for(const L of A){const R={...L,type:"position"};I.push(R)}H(I)},onEnd:({width:M,height:A})=>{const H={id:g,type:"dimensions",resizing:!1,dimensions:{width:M,height:A}};w.getState().triggerNodeChanges([H])}})),P.current.update({controlPosition:$,boundaries:{minWidth:c,minHeight:l,maxWidth:f,maxHeight:h},keepAspectRatio:d,resizeDirection:u,onResizeStart:b,onResize:v,onResizeEnd:y,shouldResize:x}),()=>{var M;(M=P.current)==null||M.destroy()}},[$,c,l,f,h,d,b,v,y,x]);const B=$.split("-");return r.jsx("div",{className:oe(["react-flow__resize-control","nodrag",...B,n,s]),ref:C,style:{...o,scale:k,...a&&{[z?"backgroundColor":"borderColor"]:a}},children:i})}N.memo(Yx);function Wx(){const[e,t]=N.useState([]),[n,s]=N.useState(!0),o=as();return N.useEffect(()=>{let i=!1;return fetch(o("/workflow/claude-hooks")).then(async a=>{if(!i&&a.ok){const c=await a.json();t(c.data)}}).catch(()=>{}).finally(()=>{i||s(!1)}),()=>{i=!0}},[o]),{ccHooks:e,loading:n}}function Xx({data:e,selected:t}){const{list:n,scopeCount:s,activeHandles:o}=e,i=c=>!o||o.has(c),a=c=>(o==null?void 0:o.get(c))??n.hex;return r.jsxs("div",{className:"group relative rounded-lg border px-4 py-3 transition-all duration-200",style:{borderColor:t?n.hex:`${n.hex}66`,backgroundColor:`${n.hex}12`,boxShadow:t?`0 0 16px ${n.hex}40`:"none",minWidth:180},children:[i("left")&&r.jsx(de,{type:"target",id:"left",position:X.Left,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("left")}}),i("top")&&r.jsx(de,{type:"target",id:"top",position:X.Top,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("top"),left:"35%"}}),i("bottom-in")&&r.jsx(de,{type:"target",id:"bottom-in",position:X.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom-in"),left:"65%"}}),r.jsxs("div",{className:"flex items-center gap-2",children:[n.isEntryPoint&&r.jsx(Gr,{className:"h-3.5 w-3.5 shrink-0 fill-current",style:{color:n.hex}}),r.jsx("span",{className:"text-sm font-medium text-foreground",children:n.label}),s>0&&r.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[10px] font-semibold leading-none",style:{backgroundColor:`${n.hex}25`,color:n.hex},children:s})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",style:{minHeight:18},children:[n.supportsBatch&&r.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-zinc-800/60 px-1.5 py-0.5 text-[9px] text-zinc-400",children:[r.jsx(qr,{className:"h-2.5 w-2.5"}),"batch"]}),n.supportsSprint&&r.jsxs("span",{className:"flex items-center gap-0.5 rounded bg-zinc-800/60 px-1.5 py-0.5 text-[9px] text-zinc-400",children:[r.jsx(rt,{className:"h-2.5 w-2.5"}),"sprint"]})]}),i("top-out")&&r.jsx(de,{type:"source",id:"top-out",position:X.Top,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("top-out"),left:"65%"}}),i("right")&&r.jsx(de,{type:"source",id:"right",position:X.Right,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("right")}}),i("bottom-fwd")&&r.jsx(de,{type:"source",id:"bottom-fwd",position:X.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom-fwd"),left:"65%"}}),i("bottom")&&r.jsx(de,{type:"source",id:"bottom",position:X.Bottom,className:"!h-2.5 !w-2.5 !border-2 !border-zinc-800",style:{backgroundColor:a("bottom"),left:"35%"}})]})}const Yi=N.memo(Xx),Gx={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},qx={guard:{bg:"#ef4444",border:"#dc2626"},gate:{bg:"#f59e0b",border:"#d97706"},lifecycle:{bg:"#3b82f6",border:"#2563eb"},observer:{bg:"#6b7280",border:"#4b5563"}};function Ux({id:e,sourceX:t,sourceY:n,targetX:s,targetY:o,sourcePosition:i,targetPosition:a,data:c,selected:l}){const f=c==null?void 0:c.edge,h=(c==null?void 0:c.hookCount)??0,d=c==null?void 0:c.highestCategory,u=(c==null?void 0:c.showHookOverlay)??!1,p=Gx[(f==null?void 0:f.direction)??"forward"]??"#22c55e",[x,b,v]=dn({sourceX:t,sourceY:n,targetX:s,targetY:o,sourcePosition:i,targetPosition:a,borderRadius:12,offset:25}),y=d?qx[d]:{bg:"#3b82f6",border:"#2563eb"};return r.jsxs(r.Fragment,{children:[r.jsx(Mt,{id:e,path:x,style:{stroke:p,strokeWidth:l?2.5:1.5,strokeDasharray:(f==null?void 0:f.direction)==="shortcut"?"6 4":void 0,opacity:l?1:.6,filter:l?`drop-shadow(0 0 4px ${p}80)`:void 0}}),r.jsx("defs",{children:r.jsxs("filter",{id:`glow-${e}`,x:"-100%",y:"-100%",width:"300%",height:"300%",children:[r.jsx("feGaussianBlur",{stdDeviation:"5",result:"blur"}),r.jsxs("feMerge",{children:[r.jsx("feMergeNode",{in:"blur"}),r.jsx("feMergeNode",{in:"blur"})]})]})}),r.jsxs("circle",{fill:p,filter:`url(#glow-${e})`,opacity:.35,children:[r.jsx("animate",{attributeName:"r",values:"3;7;3",dur:"1.5s",repeatCount:"indefinite"}),r.jsx("animateMotion",{dur:"3s",repeatCount:"indefinite",path:x})]}),r.jsx("circle",{r:"2.5",fill:p,opacity:1,children:r.jsx("animateMotion",{dur:"3s",repeatCount:"indefinite",path:x})}),r.jsxs(mx,{children:[r.jsx("div",{className:"nodrag nopan pointer-events-auto cursor-pointer rounded px-1.5 py-0.5 text-[9px] font-medium transition-opacity",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${b}px,${v}px)`,color:p,backgroundColor:"rgb(9 9 11 / 0.85)",border:`1px solid ${p}33`,opacity:l?1:0},children:(f==null?void 0:f.label)??""}),u&&h>0&&r.jsx("div",{className:"nodrag nopan pointer-events-none flex items-center justify-center rounded-full text-[8px] font-bold",style:{position:"absolute",transform:`translate(-50%, -120%) translate(${b}px,${v}px)`,width:18,height:18,backgroundColor:y.bg,color:"#fff",border:`2px solid ${y.border}`,boxShadow:`0 0 6px ${y.bg}80`},children:h})]})]})}const Wi=N.memo(Ux),Rr=260,Kx=230,Zx=160,Hr=140,Ht=16;function Xi(e,t,n,s){const o=[...t].sort((d,u)=>d.order-u.order),i=new Map(o.map((d,u)=>[d.id,u])),a=new Map;for(const d of o)a.set(d.id,[]);const c=[];for(const d of e)d.group&&a.has(d.group)?a.get(d.group).push(d):c.push(d);const l=new Map;let f=0;for(const d of o){l.set(d.id,f);const u=a.get(d.id).length;f+=u===1?Zx:u*Kx}const h=[];for(const d of o){const u=i.get(d.id),p=l.get(d.id),x=a.get(d.id);for(let b=0;b<x.length;b++){const v=x[b];h.push({id:v.id,type:"workflow",position:{x:Ht+p+b*Rr,y:Ht+u*Hr},data:{list:v,scopeCount:n.get(v.id)??0}})}}if(c.length>0){const d=o.length;for(let u=0;u<c.length;u++){const p=c[u];h.push({id:p.id,type:"workflow",position:{x:Ht+u*Rr,y:Ht+d*Hr},data:{list:p,scopeCount:n.get(p.id)??0}})}}return h}function Gi(e,t,n,s){const o=new Map(n.map(c=>[c.id,c])),i=new Map(t.map(c=>[c.id,c])),a=["guard","gate","lifecycle","observer"];return e.map(c=>{const l=c.hooks??[],f=l.map(v=>o.get(v)).filter(v=>v!==void 0),h=a.find(v=>f.some(y=>y.category===v)),d=i.get(c.from),u=i.get(c.to),p=(d==null?void 0:d.group)!=null&&d.group===(u==null?void 0:u.group),{sourceHandle:x,targetHandle:b}=Ui(c.direction,p);return{id:`${c.from}:${c.to}`,source:c.from,target:c.to,sourceHandle:x,targetHandle:b,type:"workflow",data:{edge:c,hookCount:l.length,hasBlockingHook:f.some(v=>v.blocking===!0),highestCategory:h,showHookOverlay:s}}})}const Qx={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function qi(e,t){const n=new Map(t.map(o=>[o.id,o])),s=new Map;for(const o of e){const i=n.get(o.from),a=n.get(o.to),c=(i==null?void 0:i.group)!=null&&i.group===(a==null?void 0:a.group),{sourceHandle:l,targetHandle:f}=Ui(o.direction,c),h=Qx[o.direction]??"#22c55e";s.has(o.from)||s.set(o.from,new Map),s.has(o.to)||s.set(o.to,new Map),s.get(o.from).set(l,h),s.get(o.to).set(f,h)}return s}function Ui(e,t){return e==="backward"?{sourceHandle:"bottom",targetHandle:"bottom-in"}:e==="shortcut"?{sourceHandle:"top-out",targetHandle:"top"}:t?{sourceHandle:"right",targetHandle:"left"}:{sourceHandle:"bottom-fwd",targetHandle:"left"}}const Jx={workflow:Yi},e0={workflow:Wi};function t0({engines:e}){const{getProjectName:t,getProjectColor:n,setActiveProjectId:s}=Ur(),o=N.useMemo(()=>[...e.entries()],[e]);return r.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto pb-4",children:o.map(([i,a])=>r.jsx(n0,{projectId:i,engine:a,name:t(i),color:n(i),onNavigate:()=>s(i)},i))})}function n0({engine:e,name:t,color:n,onNavigate:s}){const o=e.getConfig(),i=N.useMemo(()=>[...o.lists].sort((f,h)=>f.order-h.order),[o.lists]),a=N.useMemo(()=>qi(o.edges,i),[o.edges,i]),c=N.useMemo(()=>Xi(i,o.groups??[],new Map,o.edges).map(f=>({...f,data:{...f.data,activeHandles:a.get(f.id)}})),[i,o.groups,o.edges,a]),l=N.useMemo(()=>Gi(o.edges,i,o.hooks??[],!1),[o.edges,i,o.hooks]);return r.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/30",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:`hsl(${n})`}}),r.jsx("span",{className:"text-sm font-medium text-foreground/90",children:t}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:[o.name," · ",i.length," lists · ",o.edges.length," edges"]})]}),r.jsx("button",{onClick:s,className:"rounded px-2.5 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-zinc-800 hover:text-foreground",children:"View & Edit"})]}),r.jsx("div",{className:"h-[280px]",children:r.jsx(Hi,{nodes:c,edges:l,nodeTypes:Jx,edgeTypes:e0,fitView:!0,fitViewOptions:{padding:.12},minZoom:.15,maxZoom:1,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!1,zoomOnScroll:!1,zoomOnPinch:!1,zoomOnDoubleClick:!1,preventScrolling:!1,proOptions:{hideAttribution:!0},children:r.jsx(Bi,{variant:me.Dots,gap:20,size:1,color:"#27272a"})})})]})}const s0=["guard","gate","lifecycle","observer"];function r0({list:e,hooks:t,connectedEdges:n,onClose:s,onHookClick:o}){if(!e)return null;const i=n.filter(l=>l.to===e.id),a=n.filter(l=>l.from===e.id),c=N.useMemo(()=>{const l=new Map;for(const f of t){const h=l.get(f.category);h?h.push(f):l.set(f.category,[f])}return l},[t]);return r.jsxs("div",{className:"card-glass flex h-full w-80 shrink-0 flex-col rounded-lg border border-border bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:e.hex}}),r.jsx("span",{className:"text-sm font-medium",children:e.label})]}),r.jsx("button",{onClick:s,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsxs(ft,{title:"Properties",children:[r.jsx(Ot,{label:"ID",value:e.id}),r.jsx(Ot,{label:"Order",value:String(e.order)}),e.group&&r.jsx(Ot,{label:"Group",value:e.group}),r.jsx(Ot,{label:"Color",value:e.hex})]}),r.jsxs(ft,{title:"Flags",children:[r.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.isEntryPoint&&r.jsx(ht,{icon:Gr,label:"Entry Point",color:e.hex}),e.supportsBatch&&r.jsx(ht,{icon:qr,label:"Batch",color:"#22c55e"}),e.supportsSprint&&r.jsx(ht,{icon:rt,label:"Sprint",color:"#6366f1"}),e.gitBranch&&r.jsx(ht,{icon:Kr,label:e.gitBranch,color:"#f59e0b"}),e.sessionKey&&r.jsx(ht,{icon:Gc,label:e.sessionKey,color:"#8b5cf6"})]}),!e.isEntryPoint&&!e.supportsBatch&&!e.supportsSprint&&!e.gitBranch&&!e.sessionKey&&r.jsx("span",{className:"text-zinc-600",children:"None"})]}),r.jsx(ft,{title:`Inbound (${i.length})`,children:i.length===0?r.jsx("span",{className:"text-zinc-600",children:"None"}):i.map(l=>r.jsx(Or,{edge:l,showField:"from"},`${l.from}:${l.to}`))}),r.jsx(ft,{title:`Outbound (${a.length})`,children:a.length===0?r.jsx("span",{className:"text-zinc-600",children:"None"}):a.map(l=>r.jsx(Or,{edge:l,showField:"to"},`${l.from}:${l.to}`))}),t.length>0&&r.jsx(ft,{title:`Hooks (${t.length})`,children:r.jsx("div",{className:"space-y-3",children:s0.map(l=>{const f=c.get(l);if(!(f!=null&&f.length))return null;const h=ot[l],d=h.icon;return r.jsxs("div",{children:[r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[r.jsx(d,{className:"h-2.5 w-2.5",style:{color:h.color}}),r.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider",style:{color:h.color},children:h.label})]}),f.map(u=>r.jsx(c0,{hook:u,onClick:o},u.id))]},l)})})})]})]})}function ft({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),r.jsx("div",{className:"space-y-1.5",children:t})]})}function Ot({label:e,value:t}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-zinc-500",children:e}),r.jsx("span",{className:"font-mono text-zinc-300",children:t})]})}function ht({icon:e,label:t,color:n}){return r.jsxs("span",{className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px]",style:{backgroundColor:`${n}15`,color:n},children:[r.jsx(e,{className:"h-3 w-3"}),t]})}const o0={before:"#eab308",after:"#3b82f6"},i0={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},a0={shell:be,event:hs,webhook:fs};function c0({hook:e,onClick:t}){const n=o0[e.timing]??"#3b82f6",s=i0[e.type]??"#22c55e",o=a0[e.type]??be,i=cs(e),a=us[i],c=ot[e.category],l=c.icon;return r.jsxs("button",{onClick:()=>t==null?void 0:t(e),className:"w-full rounded border bg-zinc-950/50 p-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:e.blocking?"#ef444466":"#27272a"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(l,{className:"h-2.5 w-2.5",style:{color:c.color}}),r.jsx("span",{className:"text-zinc-300",children:e.label}),r.jsx("span",{className:"ml-auto rounded px-1 py-0.5 text-[8px] font-bold uppercase",style:{backgroundColor:`${a}20`,color:a},children:i})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.timing}),r.jsxs("span",{className:"flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:[r.jsx(o,{className:"h-2.5 w-2.5"}),e.type]})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded border border-border bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-400",children:[r.jsx(o,{className:"h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("span",{className:"truncate",children:e.target})]}),e.description&&r.jsx("p",{className:"mt-1 text-zinc-500",children:e.description})]})}const l0={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function Or({edge:e,showField:t}){const n=l0[e.direction]??"#22c55e";return r.jsxs("div",{className:"flex items-center gap-2 rounded border border-border/50 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("span",{className:"rounded px-1 py-0.5 text-[9px] uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.direction}),r.jsx("span",{className:"text-zinc-400",children:t==="from"?e.from:e.to}),r.jsx("span",{className:"ml-auto text-zinc-600",children:e.label})]})}const d0={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},u0=["guard","gate","lifecycle","observer"];function f0({edge:e,hooks:t,onClose:n,onHookClick:s}){if(!e)return null;const o=d0[e.direction]??"#22c55e",i=N.useMemo(()=>{const a=new Map;for(const c of t){const l=a.get(c.category);l?l.push(c):a.set(c.category,[c])}return a},[t]);return r.jsxs("div",{className:"card-glass flex h-full w-80 shrink-0 flex-col rounded-lg border border-border bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[r.jsx("span",{className:"text-zinc-300",children:e.from}),r.jsx(De,{className:"h-3.5 w-3.5 text-zinc-600"}),r.jsx("span",{className:"text-zinc-300",children:e.to})]}),r.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsxs(pt,{title:"Transition",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-semibold uppercase",style:{backgroundColor:`${o}20`,color:o},children:e.direction}),r.jsx("span",{className:"text-zinc-300",children:e.label})]}),r.jsx("p",{className:"mt-1.5 text-zinc-500",children:e.description})]}),e.command&&r.jsx(pt,{title:"Command",children:r.jsxs("div",{className:"flex items-center gap-2 rounded border border-border bg-zinc-950 px-3 py-2 font-mono text-emerald-400",children:[r.jsx(be,{className:"h-3.5 w-3.5 shrink-0 text-zinc-600"}),e.command]})}),r.jsx(pt,{title:"Behavior",children:r.jsxs("div",{className:"flex flex-wrap gap-2",children:[r.jsx(Bt,{label:"Confirm",value:e.confirmLevel}),e.dispatchOnly&&r.jsx(Bt,{label:"Dispatch Only",active:!0}),e.humanOnly&&r.jsx(Bt,{label:"Human Only",active:!0}),e.skipServerTransition&&r.jsx(Bt,{label:"Skip Server",active:!0})]})}),e.checklist&&e.checklist.length>0&&r.jsx(pt,{title:`Checklist (${e.checklist.length})`,children:r.jsx("div",{className:"space-y-1.5",children:e.checklist.map((a,c)=>r.jsxs("div",{className:"flex items-start gap-2 text-zinc-400",children:[r.jsx(Jt,{className:"mt-0.5 h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("span",{children:a})]},c))})}),t.length>0&&r.jsx(pt,{title:`Hooks (${t.length})`,children:r.jsx("div",{className:"space-y-3",children:u0.map(a=>{const c=i.get(a);if(!(c!=null&&c.length))return null;const l=ot[a],f=l.icon;return r.jsxs("div",{children:[r.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5",children:[r.jsx(f,{className:"h-2.5 w-2.5",style:{color:l.color}}),r.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider",style:{color:l.color},children:l.label})]}),c.map(h=>r.jsx(m0,{hook:h,onClick:s},h.id))]},a)})})})]})]})}function pt({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}const h0={before:"#eab308",after:"#3b82f6"},p0={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},x0={shell:be,event:hs,webhook:fs};function m0({hook:e,onClick:t}){const n=h0[e.timing]??"#3b82f6",s=p0[e.type]??"#22c55e",o=x0[e.type]??be,i=cs(e),a=us[i],c=ot[e.category],l=c.icon;return r.jsxs("button",{onClick:()=>t==null?void 0:t(e),className:"w-full rounded border bg-zinc-950/50 p-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:e.blocking?"#ef444466":"#27272a"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(l,{className:"h-2.5 w-2.5",style:{color:c.color}}),r.jsx("span",{className:"text-zinc-300",children:e.label}),r.jsx("span",{className:"ml-auto rounded px-1 py-0.5 text-[8px] font-bold uppercase",style:{backgroundColor:`${a}20`,color:a},children:i})]}),r.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${n}20`,color:n},children:e.timing}),r.jsxs("span",{className:"flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:[r.jsx(o,{className:"h-2.5 w-2.5"}),e.type]})]}),r.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 rounded border border-border bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-400",children:[r.jsx(o,{className:"h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("span",{className:"truncate",children:e.target})]}),e.description&&r.jsx("p",{className:"mt-1 text-zinc-500",children:e.description})]})}function Bt({label:e,value:t,active:n}){return r.jsxs("span",{className:"rounded border px-1.5 py-0.5 text-[10px]",style:{borderColor:n?"#22c55e33":"#27272a",color:n?"#22c55e":"#a1a1aa",backgroundColor:n?"#22c55e10":"transparent"},children:[e,t?`: ${t}`:""]})}function g0({activeConfigName:e}){const[t,n]=N.useState([]),[s,o]=N.useState(!1),i=as(),[a,c]=N.useState(!1),[l,f]=N.useState(""),[h,d]=N.useState(!1),[u,p]=N.useState(null),[x,b]=N.useState(!1),v=N.useCallback(async()=>{try{const C=await fetch(i("/workflow/presets"));if(!C.ok)return;const z=await C.json();z.success&&n(z.data)}catch{}},[i]);N.useEffect(()=>{v()},[v]);const y=async C=>{try{const z=await fetch(i(`/workflow/presets/${encodeURIComponent(C)}`));if(!z.ok)return;const k=await z.json();if(!k.success)return;const P=await fetch(i("/workflow/preview"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k.data)});if(!P.ok)return;const $=await P.json();if(!$.success)return;const B=$.data;if(B.removedLists.length===0&&B.addedLists.length===0&&B.orphanedScopes.length===0){await m(k.data,{});return}const A=(k.data.lists??[]).map(H=>H.id);p({presetName:C,config:k.data,plan:B,mappings:{...B.suggestedMappings},newListIds:A}),o(!1)}catch{}},m=async(C,z)=>{b(!0);try{await fetch(i("/workflow/apply"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:C,orphanMappings:z})}),p(null),o(!1)}catch{}finally{b(!1)}},g=async()=>{if(l.trim()){c(!0);try{await fetch(i("/workflow/presets"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:l.trim()})}),f(""),d(!1),v()}catch{}finally{c(!1)}}},w=async C=>{try{await fetch(i(`/workflow/presets/${encodeURIComponent(C)}`),{method:"DELETE"}),v()}catch{}};return r.jsxs("div",{className:"relative",children:[r.jsxs("button",{onClick:()=>o(!s),className:"flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-900 px-3 py-1.5 text-xs text-zinc-300 transition-colors hover:border-zinc-700 hover:text-zinc-100",children:[e,r.jsx(fc,{className:"h-3.5 w-3.5 text-zinc-500"})]}),s&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1)}),r.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1.5 w-64 rounded-lg border border-zinc-800 bg-zinc-900/95 p-2 shadow-xl backdrop-blur",children:[r.jsx("div",{className:"mb-1 px-2 text-[9px] font-semibold uppercase tracking-wider text-zinc-600",children:"Presets"}),t.length===0?r.jsx("div",{className:"px-2 py-3 text-center text-xs text-zinc-600",children:"No presets saved"}):r.jsx("div",{className:"max-h-48 space-y-0.5 overflow-y-auto",children:t.map(C=>r.jsxs("div",{className:"group flex items-center gap-2 rounded px-2 py-1.5 text-xs hover:bg-zinc-800",children:[r.jsxs("button",{onClick:()=>y(C.name),className:"flex flex-1 items-center gap-2 text-left text-zinc-300",children:[r.jsx(hc,{className:"h-3 w-3 text-zinc-600"}),C.name,C.isDefault&&r.jsx("span",{className:"text-[9px] text-zinc-600",children:"(default)"})]}),!C.isDefault&&r.jsx("button",{onClick:()=>w(C.name),className:"rounded p-0.5 text-zinc-600 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:r.jsx(ls,{className:"h-3 w-3"})})]},C.name))}),r.jsx("div",{className:"mt-2 border-t border-zinc-800 pt-2",children:h?r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:l,onChange:C=>f(C.target.value),onKeyDown:C=>C.key==="Enter"&&g(),placeholder:"Preset name...",className:"flex-1 rounded border border-zinc-700 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 outline-none placeholder:text-zinc-700 focus:border-zinc-600",autoFocus:!0}),r.jsx("button",{onClick:g,disabled:a||!l.trim(),className:"rounded bg-zinc-800 px-2 py-1 text-xs text-zinc-300 hover:bg-zinc-700 disabled:opacity-50",children:"Save"})]}):r.jsxs("button",{onClick:()=>d(!0),className:"flex w-full items-center gap-2 rounded px-2 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:[r.jsx(ro,{className:"h-3 w-3"}),"Save current as preset"]})})]})]}),u&&r.jsx(b0,{presetName:u.presetName,plan:u.plan,mappings:u.mappings,newListIds:u.newListIds,applying:x,onUpdateMapping:(C,z)=>{p(k=>k&&{...k,mappings:{...k.mappings,[C]:z}})},onConfirm:()=>m(u.config,u.mappings),onCancel:()=>p(null)})]})}function b0({presetName:e,plan:t,mappings:n,newListIds:s,applying:o,onUpdateMapping:i,onConfirm:a,onCancel:c}){const l=t.orphanedScopes.length>0,f=t.orphanedScopes.every(h=>n[h.listId]&&n[h.listId].trim().length>0);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"fixed inset-0 z-[60] bg-black/60 backdrop-blur-sm",onClick:c}),r.jsx("div",{className:"fixed inset-0 z-[61] flex items-center justify-center p-4",children:r.jsxs("div",{className:"w-full max-w-lg rounded-lg border border-zinc-800 bg-zinc-950 shadow-2xl",onClick:h=>h.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 border-b border-zinc-800 px-5 py-4",children:[r.jsx(st,{className:"h-5 w-5 text-amber-400"}),r.jsxs("div",{children:[r.jsxs("h3",{className:"text-sm font-medium text-zinc-100",children:['Switch to "',e,'"?']}),r.jsx("p",{className:"mt-0.5 text-xs text-zinc-500",children:"This will change your workflow and may move scopes between lists."})]})]}),r.jsxs("div",{className:"max-h-[60vh] overflow-y-auto px-5 py-4 space-y-4",children:[t.removedLists.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[r.jsx(oo,{className:"h-3 w-3 text-red-400"}),"Lists being removed"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.removedLists.map(h=>r.jsx("span",{className:"rounded bg-red-500/10 px-2 py-0.5 text-xs text-red-300 border border-red-500/20",children:h},h))})]}),t.addedLists.length>0&&r.jsxs("div",{children:[r.jsxs("h4",{className:"mb-1.5 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[r.jsx(Te,{className:"h-3 w-3 text-green-400"}),"Lists being added"]}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.addedLists.map(h=>r.jsx("span",{className:"rounded bg-green-500/10 px-2 py-0.5 text-xs text-green-300 border border-green-500/20",children:h},h))})]}),l&&r.jsxs("div",{children:[r.jsxs("h4",{className:"mb-2 flex items-center gap-1.5 text-xs font-medium text-zinc-300",children:[r.jsx(nl,{className:"h-3 w-3 text-amber-400"}),"Scopes that need to move"]}),r.jsx("p",{className:"mb-3 text-xs text-zinc-500",children:"These scopes are in lists being removed. Choose where each group should be moved."}),r.jsx("div",{className:"space-y-3",children:t.orphanedScopes.map(h=>r.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-900/50 p-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[r.jsx("span",{className:"rounded bg-red-500/10 px-1.5 py-0.5 text-red-300 border border-red-500/20",children:h.listId}),r.jsx(De,{className:"h-3 w-3 text-zinc-600"}),r.jsxs("select",{value:n[h.listId]??"",onChange:d=>i(h.listId,d.target.value),className:"rounded border border-zinc-700 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select destination..."}),s.map(d=>r.jsx("option",{value:d,children:d},d))]})]}),r.jsxs("div",{className:"mt-2 text-xxs text-zinc-500",children:[h.scopeFiles.length," scope",h.scopeFiles.length!==1?"s":"",":"," ",r.jsxs("span",{className:"text-zinc-400",children:[h.scopeFiles.slice(0,5).join(", "),h.scopeFiles.length>5&&` +${h.scopeFiles.length-5} more`]})]})]},h.listId))})]}),t.lostEdges.length>0&&r.jsxs("div",{children:[r.jsx("h4",{className:"mb-1.5 text-xs font-medium text-zinc-300",children:"Transitions being removed"}),r.jsx("div",{className:"space-y-1",children:t.lostEdges.map((h,d)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-zinc-500",children:[r.jsx("span",{children:h.from}),r.jsx(De,{className:"h-3 w-3"}),r.jsx("span",{children:h.to})]},d))})]}),t.impactSummary&&r.jsx("div",{className:"rounded bg-zinc-900 px-3 py-2 text-xs text-zinc-400 border border-zinc-800",children:t.impactSummary})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-3",children:[r.jsx("button",{onClick:c,className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200 transition-colors",children:"Cancel"}),r.jsx("button",{onClick:a,disabled:o||l&&!f,className:"rounded bg-amber-500/20 border border-amber-500/30 px-3 py-1.5 text-xs text-amber-300 hover:bg-amber-500/30 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:o?"Applying...":"Confirm Switch"})]})]})})]})}function y0({hook:e,open:t,onClose:n}){const[s,o]=N.useState(null),[i,a]=N.useState(!1),[c,l]=N.useState(null),f=as();return N.useEffect(()=>{if(!e||!t){o(null),l(null);return}let h=!1;return a(!0),l(null),fetch(f(`/workflow/hooks/source?path=${encodeURIComponent(e.scriptPath)}`)).then(async d=>{if(!h)if(d.ok){const u=await d.json();o(u.data)}else{const u=await d.json().catch(()=>({error:`HTTP ${d.status}`}));l(u.error??`Failed to load source (HTTP ${d.status})`),o(null)}}).catch(d=>{h||l(d instanceof Error?d.message:"Network error")}).finally(()=>{h||a(!1)}),()=>{h=!0}},[e==null?void 0:e.id,e==null?void 0:e.scriptPath,t,f]),e?r.jsx(pc,{open:t,onOpenChange:h=>{h||n()},children:r.jsxs(xc,{className:"max-w-[min(56rem,calc(100vw_-_2rem))] h-[80vh] flex flex-col p-0 gap-0 overflow-hidden",children:[r.jsxs(mc,{className:"px-4 pt-3 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 pr-8",children:[r.jsx(tn,{className:"h-4 w-4 shrink-0 text-zinc-500"}),r.jsx(gc,{className:"text-sm font-medium text-foreground leading-tight truncate",children:e.label})]}),r.jsx(bc,{className:"mt-1 font-mono text-[11px] text-zinc-500 truncate",children:e.scriptPath})]}),r.jsx("div",{className:"flex-1 min-h-0 border-t border-zinc-800 bg-[#0a0a12]",children:r.jsx(yc,{className:"h-full",children:r.jsxs("div",{className:"px-2 py-3",children:[i&&r.jsxs("div",{className:"flex items-center gap-2 px-4 py-8 text-xs text-zinc-500",children:[r.jsx(Zr,{className:"h-4 w-4 animate-spin"}),"Loading source..."]}),c&&r.jsxs("div",{className:"px-4 py-8 text-xs text-red-400",children:[r.jsx(tn,{className:"mb-2 h-5 w-5 text-zinc-600"}),c]}),s&&r.jsx(w0,{content:s.content,filePath:s.filePath}),!i&&!c&&!s&&r.jsx("div",{className:"px-4 py-8 text-xs text-zinc-600 italic",children:"No source available"})]})})}),s&&r.jsxs("div",{className:"border-t border-zinc-800 px-4 py-2 text-[10px] text-zinc-600",children:[s.lineCount," lines"]})]})}):null}function w0({content:e,filePath:t}){const n=e.split(`
|
|
69
|
+
`),s=String(n.length).length;return r.jsxs("div",{children:[r.jsxs("div",{className:"mb-2 flex items-center gap-2 rounded border border-zinc-800/50 bg-zinc-900/50 px-3 py-1.5 font-mono text-[10px] text-zinc-500",children:[r.jsx(tn,{className:"h-3 w-3 shrink-0"}),t]}),r.jsx("pre",{className:"font-mono text-[12px] leading-[1.6]",children:n.map((o,i)=>r.jsxs("div",{className:"flex hover:bg-white/[0.02]",children:[r.jsx("span",{className:"select-none text-right text-zinc-700 pr-3 shrink-0",style:{width:`${s+2}ch`},children:i+1}),r.jsx("span",{className:"text-zinc-300 whitespace-pre overflow-x-auto",children:o||" "})]},i))})]})}function v0(){return r.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-zinc-800 bg-zinc-950/50 p-8 text-center",children:[r.jsxs("div",{className:"flex items-center gap-2 text-zinc-600",children:[r.jsx(rt,{className:"h-4 w-4"}),r.jsx(Qr,{className:"h-4 w-4"})]}),r.jsx("span",{className:"text-xs font-medium text-zinc-500",children:"No hook execution data available"}),r.jsx("p",{className:"max-w-xs text-[10px] text-zinc-600",children:"Hook execution tracking will be added when the Hook & Event Foundation (scope 079) is implemented. This panel will show real-time hook firing events with timestamps, results, and durations."})]})}const N0=["guard","gate","lifecycle","observer"],j0=["SessionStart","PreToolUse","PostToolUse","SessionEnd"],C0={SessionStart:"#22c55e",PreToolUse:"#eab308",PostToolUse:"#3b82f6",SessionEnd:"#ef4444"};function z0({hooks:e,edges:t,onHookClick:n}){const{workflowHooks:s,ccOnlyHooks:o,stats:i}=N.useMemo(()=>{const l=[],f=[];let h=0;for(const u of e)u.source==="workflow"||u.source==="both"?(l.push(u),u.source==="both"&&h++):f.push(u);const d=t.filter(u=>(u.hooks??[]).length>0).length;return{workflowHooks:l,ccOnlyHooks:f,stats:{total:e.length,workflow:l.length,ccOnly:f.length,shared:h,edgesWithHooks:d}}},[e,t]),a=N.useMemo(()=>{const l=new Map;for(const f of s){if(!f.workflow)continue;const h=f.workflow.category,d=l.get(h);d?d.push(f):l.set(h,[f])}return l},[s]),c=N.useMemo(()=>{var f;const l=new Map;for(const h of o){if(!((f=h.ccTriggers)!=null&&f.length))continue;const d=h.ccTriggers[0],u=d.event,p=d.matcher??"(all)";l.has(u)||l.set(u,[]);const x=l.get(u),b=x.find(v=>v.matcher===p);b?b.hooks.push(h):x.push({matcher:p,hooks:[h]})}return l},[o]);return r.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[r.jsx(k0,{stats:i}),r.jsxs("section",{children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx(hn,{className:"h-4 w-4 text-orange-400"}),r.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Transition Enforcement"}),r.jsxs("span",{className:"text-[10px] text-zinc-500",children:[s.length," hooks on ",i.edgesWithHooks," edges"]})]}),r.jsx("p",{className:"mb-4 text-[11px] text-zinc-500",children:"Hooks that fire during scope transitions"}),r.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-1 items-stretch",children:[r.jsx("div",{className:"md:flex md:items-center hidden",children:r.jsx("span",{className:"rounded-l bg-yellow-500/10 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-yellow-500 [writing-mode:vertical-lr] rotate-180",children:"Before"})}),r.jsx("div",{className:"md:hidden",children:r.jsx("span",{className:"inline-block rounded bg-yellow-500/10 px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-yellow-500",children:"Before Transition"})}),r.jsx("div",{className:"grid flex-1 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:N0.slice(0,3).map((l,f)=>r.jsx(Br,{category:l,hooks:a.get(l)??[],onHookClick:n,showArrow:f<2},l))}),r.jsx("div",{className:"hidden md:flex flex-col items-center justify-center px-2",children:r.jsx("div",{className:"h-full w-px bg-zinc-800"})}),r.jsx("div",{className:"md:flex md:items-center hidden",children:r.jsx("span",{className:"rounded-l bg-cyan-500/10 px-2 py-1 text-[9px] font-semibold uppercase tracking-wider text-cyan-500 [writing-mode:vertical-lr] rotate-180",children:"After"})}),r.jsx("div",{className:"md:hidden",children:r.jsx("span",{className:"inline-block rounded bg-cyan-500/10 px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wider text-cyan-500",children:"After Transition"})}),r.jsx("div",{className:"w-full md:w-56",children:r.jsx(Br,{category:"observer",hooks:a.get("observer")??[],onHookClick:n,showArrow:!1})})]})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx(en,{className:"h-4 w-4 text-emerald-400"}),r.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Session Enforcement"}),r.jsxs("span",{className:"text-[10px] text-zinc-500",children:[o.length," CC hooks"]})]}),r.jsx("p",{className:"mb-4 text-[11px] text-zinc-500",children:"Hooks that fire on Claude Code tool events"}),r.jsx("div",{className:"grid grid-cols-4 gap-3",children:j0.map((l,f)=>r.jsx(S0,{event:l,matcherGroups:c.get(l)??[],onHookClick:n,showArrow:f<3},l))})]}),r.jsxs("section",{children:[r.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[r.jsx(Qr,{className:"h-4 w-4 text-zinc-500"}),r.jsx("h2",{className:"text-sm font-medium text-zinc-200",children:"Execution Log"}),r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] text-zinc-500",children:"scope 079"})]}),r.jsx(v0,{})]})]})}function k0({stats:e}){return r.jsxs("div",{className:"flex items-center gap-4 rounded-lg border border-zinc-800 bg-zinc-900/50 px-4 py-2.5",children:[r.jsx(On,{icon:rt,color:"#f97316",label:"hooks",value:e.total}),r.jsx(Bn,{}),r.jsx(On,{icon:hn,color:"#f97316",label:"workflow",value:e.workflow}),r.jsx(Bn,{}),r.jsx(On,{icon:en,color:"#10b981",label:"CC-only",value:e.ccOnly}),r.jsx(Bn,{}),r.jsxs("span",{className:"text-[10px] text-zinc-500",children:[e.shared," shared scripts"]})]})}function On({icon:e,color:t,label:n,value:s}){return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3.5 w-3.5",style:{color:t}}),r.jsx("span",{className:"text-sm font-semibold text-zinc-200",children:s}),r.jsx("span",{className:"text-[10px] text-zinc-500",children:n})]})}function Bn(){return r.jsx("div",{className:"h-4 w-px bg-zinc-800"})}function Br({category:e,hooks:t,onHookClick:n,showArrow:s}){const o=ot[e],i=o.icon;return r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[r.jsx(i,{className:"h-3 w-3",style:{color:o.color}}),r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:o.color},children:o.label})," ",r.jsxs("span",{className:"text-[9px] text-zinc-600",children:["(",t.length,")"]})]}),r.jsx("div",{className:"space-y-1.5",children:t.length===0?r.jsxs("div",{className:"rounded border border-dashed border-zinc-800 px-3 py-4 text-center text-[10px] text-zinc-700",children:["No ",o.label.toLowerCase()]}):t.map(a=>r.jsx(Ki,{hook:a,onHookClick:n},a.id))}),s&&r.jsx("div",{className:"absolute -right-2.5 top-1/2 -translate-y-1/2 text-zinc-700",children:r.jsx(Jr,{className:"h-4 w-4"})})]})}function S0({event:e,matcherGroups:t,onHookClick:n,showArrow:s}){const o=C0[e],i=t.reduce((a,c)=>a+c.hooks.length,0);return r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"mb-2 flex items-center gap-1.5",children:[r.jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:o}}),r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:o},children:e}),i>0&&r.jsxs("span",{className:"text-[9px] text-zinc-600",children:["(",i,")"]})]}),r.jsx("div",{className:"space-y-2",children:t.length===0?r.jsx("div",{className:"rounded border border-dashed border-zinc-800 px-3 py-4 text-center text-[10px] text-zinc-700",children:"No hooks"}):t.map(a=>r.jsxs("div",{children:[a.matcher!=="(all)"&&r.jsx("div",{className:"mb-1 rounded bg-zinc-800/50 px-1.5 py-0.5 font-mono text-[9px] text-zinc-500 w-fit",children:a.matcher}),r.jsx("div",{className:"space-y-1.5",children:a.hooks.map(c=>r.jsx(Ki,{hook:c,onHookClick:n},c.id))})]},a.matcher))}),s&&r.jsx("div",{className:"absolute -right-2.5 top-1/2 -translate-y-1/2 text-zinc-700",children:r.jsx(Jr,{className:"h-4 w-4"})})]})}function Ki({hook:e,onHookClick:t}){var o;const n=(o=e.workflow)==null?void 0:o.blocking,s=e.source==="both";return r.jsx("button",{onClick:()=>t(e),className:"w-full rounded border bg-zinc-950/50 px-2.5 py-2 text-left transition-colors hover:border-zinc-600 hover:bg-zinc-900/70",style:{borderColor:n?"#ef444440":"#27272a"},children:r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px] font-medium text-zinc-300 truncate",children:e.label}),n&&r.jsx(hn,{className:"h-2.5 w-2.5 shrink-0 text-red-400"}),s&&r.jsx("span",{className:"ml-auto shrink-0 rounded bg-emerald-500/15 px-1 py-0.5 text-[8px] font-bold text-emerald-400",children:"+CC"})]})})}const E0={before:"#eab308",after:"#3b82f6"},_0={shell:be,event:hs,webhook:fs},M0={shell:"#22c55e",event:"#a855f7",webhook:"#f97316"},I0={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"},T0={workflow:{label:"Workflow",color:"#f97316"},"claude-code":{label:"Claude Code",color:"#10b981"},both:{label:"Both",color:"#8b5cf6"}},A0={SessionStart:"#22c55e",SessionEnd:"#ef4444",PreToolUse:"#eab308",PostToolUse:"#3b82f6"};function P0({hook:e,edges:t,onClose:n,onViewSource:s,onNavigateToEdge:o}){var v;const i=N.useMemo(()=>e!=null&&e.workflow?t.filter(y=>(y.hooks??[]).includes(e.id)):[],[e,t]);if(!e)return null;const a=!!e.workflow,c=!!((v=e.ccTriggers)!=null&&v.length),l=T0[e.source],f=a?ot[e.workflow.category]:null,h=(f==null?void 0:f.icon)??en,d=(f==null?void 0:f.color)??"#10b981",u=a?cs({category:e.workflow.category}):null,p=u?us[u]:null,x=u?Xc[u]:null,b=a?_0[e.workflow.type]??be:en;return r.jsxs("div",{className:"card-glass flex h-full w-96 shrink-0 flex-col rounded-lg border border-border bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(h,{className:"h-4 w-4 shrink-0",style:{color:d}}),r.jsx("span",{className:"text-sm font-medium text-zinc-200 truncate",children:e.label})]}),r.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-bold uppercase",style:{backgroundColor:`${l.color}20`,color:l.color},children:l.label}),a&&u&&p&&r.jsx("span",{className:"rounded px-2 py-0.5 text-[10px] font-bold uppercase",style:{backgroundColor:`${p}20`,color:p},children:u}),a&&e.workflow.blocking&&r.jsxs("span",{className:"flex items-center gap-1 rounded bg-red-500/15 px-2 py-0.5 text-[10px] font-semibold uppercase text-red-400",children:[r.jsx(hn,{className:"h-2.5 w-2.5"}),"Blocking"]})]}),a&&r.jsxs(Fe,{title:"Workflow Properties",children:[r.jsx(Ft,{label:"Timing",value:e.workflow.timing,color:E0[e.workflow.timing]}),r.jsx(Ft,{label:"Type",value:e.workflow.type,color:M0[e.workflow.type]}),r.jsx(Ft,{label:"Category",value:e.workflow.category,color:d}),r.jsx(Ft,{label:"Blocking",value:e.workflow.blocking?"Yes":"No",color:e.workflow.blocking?"#ef4444":"#6b7280"})]}),a&&u&&p&&r.jsxs(Fe,{title:"Enforcement",children:[r.jsx("p",{className:"text-zinc-500",children:x}),r.jsxs("p",{className:"mt-1 text-[10px] text-zinc-600",children:[e.workflow.category," ",r.jsx("span",{className:"text-zinc-700",children:"→"})," ",r.jsx("span",{style:{color:p},children:u})]})]}),a&&e.workflow.description&&r.jsx(Fe,{title:"Description",children:r.jsx("p",{className:"text-zinc-400 leading-relaxed",children:e.workflow.description})}),r.jsx(Fe,{title:"Script Path",children:r.jsxs("div",{className:"flex items-center gap-2 rounded border border-border bg-zinc-950 px-3 py-2 font-mono text-[11px] text-emerald-400",children:[r.jsx(b,{className:"h-3.5 w-3.5 shrink-0 text-zinc-600"}),r.jsx("span",{className:"truncate",children:e.scriptPath})]})}),c&&r.jsx(Fe,{title:`Claude Code Triggers (${e.ccTriggers.length})`,children:r.jsx($0,{triggers:e.ccTriggers})}),a&&r.jsx(Fe,{title:`Attached Edges (${i.length})`,children:i.length===0?r.jsx("span",{className:"text-zinc-600",children:"No edges reference this hook"}):r.jsx("div",{className:"space-y-1.5",children:i.map(y=>{const m=I0[y.direction]??"#22c55e";return r.jsxs("button",{onClick:()=>o==null?void 0:o(y.from,y.to),className:"flex w-full items-center gap-2 rounded border border-border/50 bg-zinc-950/30 px-2 py-1.5 text-left transition-colors hover:border-zinc-700 hover:bg-zinc-900/50",children:[r.jsx("span",{className:"rounded px-1 py-0.5 text-[9px] uppercase",style:{backgroundColor:`${m}20`,color:m},children:y.direction}),r.jsx("span",{className:"text-zinc-300",children:y.from}),r.jsx(De,{className:"h-2.5 w-2.5 text-zinc-600"}),r.jsx("span",{className:"text-zinc-300",children:y.to}),r.jsx(wc,{className:"ml-auto h-3 w-3 text-zinc-600"})]},`${y.from}:${y.to}`)})})})]}),r.jsx("div",{className:"border-t border-border p-3",children:r.jsxs("button",{onClick:()=>s(e),className:"flex w-full items-center justify-center gap-2 rounded border border-zinc-700 bg-zinc-800/50 px-3 py-2 text-xs text-zinc-300 transition-colors hover:border-zinc-600 hover:bg-zinc-800",children:[r.jsx(tn,{className:"h-3.5 w-3.5"}),"View Source Code"]})})]})}function $0({triggers:e}){return r.jsx("div",{className:"space-y-1.5",children:e.map((t,n)=>{const s=A0[t.event]??"#10b981";return r.jsxs("div",{className:"flex items-center gap-2 rounded border border-border/50 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[9px] font-semibold uppercase",style:{backgroundColor:`${s}20`,color:s},children:t.event}),t.matcher&&r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 font-mono text-[9px] text-zinc-400",children:t.matcher}),t.statusMessage&&r.jsx("span",{className:"ml-auto truncate text-[10px] text-zinc-600",children:t.statusMessage})]},n)})})}function Fe({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Ft({label:e,value:t,color:n}){return r.jsxs("div",{className:"flex items-center justify-between py-0.5",children:[r.jsx("span",{className:"text-zinc-500",children:e}),r.jsx("span",{className:"text-zinc-300",style:n?{color:n}:void 0,children:t})]})}function D0(e){const t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,o=Math.max(t,n,s),i=Math.min(t,n,s),a=(o+i)/2;if(o===i)return`0 0% ${Math.round(a*100)}%`;const c=o-i,l=a>.5?c/(2-o-i):c/(o+i);let f=0;return o===t?f=((n-s)/c+(n<s?6:0))/6:o===n?f=((s-t)/c+2)/6:f=((t-n)/c+4)/6,`${Math.round(f*360)} ${Math.round(l*100)}% ${Math.round(a*100)}%`}function L0({list:e,config:t,isNew:n,onSave:s,onDelete:o,onClose:i}){const[a,c]=N.useState(()=>structuredClone(e)),[l,f]=N.useState(!1),h=N.useMemo(()=>[...new Set(t.lists.map(v=>v.group).filter(Boolean))],[t.lists]),d=N.useMemo(()=>{const b=[];return a.label.trim()||b.push("Label is required"),/^[a-z0-9-]+$/.test(a.id)||b.push("ID must be lowercase alphanumeric + hyphens"),a.id||b.push("ID is required"),t.lists.some(v=>v.id===a.id&&v.id!==e.id)&&b.push("ID already exists"),a.isEntryPoint&&t.lists.some(v=>v.isEntryPoint&&v.id!==e.id)&&b.push("Another list is already the entry point"),b},[a,t.lists,e.id]),u=N.useCallback((b,v)=>{c(y=>({...y,[b]:v}))},[]),p=N.useCallback(b=>{c(v=>({...v,hex:b,color:D0(b)}))},[]),x=N.useCallback(()=>{d.length>0||s(a)},[a,d,s]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-cyan-500/30 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"h-3 w-3 rounded-full",style:{backgroundColor:a.hex}}),r.jsx("span",{className:"text-sm font-medium",children:n?"New List":"Edit List"})]}),r.jsx("button",{onClick:i,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-4 text-xs",children:[r.jsx(_e,{label:"ID",children:r.jsx("input",{value:a.id,onChange:b=>u("id",b.target.value),disabled:!n,className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500 disabled:opacity-50",placeholder:"e.g. review"})}),r.jsx(_e,{label:"Label",children:r.jsx("input",{value:a.label,onChange:b=>u("label",b.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Review"})}),r.jsx(_e,{label:"Color",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"color",value:a.hex,onChange:b=>p(b.target.value),className:"h-8 w-8 cursor-pointer rounded border border-zinc-700 bg-zinc-800 p-0.5"}),r.jsx("input",{value:a.hex,onChange:b=>p(b.target.value),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none focus:border-zinc-500"})]})}),r.jsx(_e,{label:"Order",children:r.jsx("input",{type:"number",value:a.order,onChange:b=>u("order",parseInt(b.target.value,10)||0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(_e,{label:"Group",children:r.jsxs("select",{value:a.group??"",onChange:b=>u("group",b.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"None"}),h.map(b=>r.jsx("option",{value:b,children:b},b))]})}),r.jsx(_e,{label:"Git Branch (optional)",children:r.jsx("input",{value:a.gitBranch??"",onChange:b=>u("gitBranch",b.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. dev"})}),r.jsx(_e,{label:"Session Key (optional)",children:r.jsx("input",{value:a.sessionKey??"",onChange:b=>u("sessionKey",b.target.value||void 0),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. COMMIT_SESSION"})}),r.jsx(_e,{label:"Flags",children:r.jsxs("div",{className:"space-y-2",children:[r.jsx(Vt,{label:"Entry Point",checked:a.isEntryPoint??!1,onChange:b=>u("isEntryPoint",b||void 0)}),r.jsx(Vt,{label:"Has Directory",checked:a.hasDirectory,onChange:b=>u("hasDirectory",b)}),r.jsx(Vt,{label:"Supports Batch",checked:a.supportsBatch??!1,onChange:b=>u("supportsBatch",b||void 0)}),r.jsx(Vt,{label:"Supports Sprint",checked:a.supportsSprint??!1,onChange:b=>u("supportsSprint",b||void 0)})]})}),d.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:d.map(b=>r.jsx("p",{className:"text-[10px] text-red-400",children:b},b))})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-4 py-3",children:[!n&&(l?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[10px] text-red-400",children:"Confirm?"}),r.jsx("button",{onClick:o,className:"rounded bg-red-500/20 px-2 py-1 text-[10px] text-red-400 hover:bg-red-500/30",children:"Delete"}),r.jsx("button",{onClick:()=>f(!1),className:"rounded px-2 py-1 text-[10px] text-zinc-500 hover:text-zinc-300",children:"Cancel"})]}):r.jsx("button",{onClick:()=>f(!0),className:"rounded p-1.5 text-zinc-600 hover:bg-red-500/10 hover:text-red-400",children:r.jsx(ls,{className:"h-3.5 w-3.5"})})),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:x,disabled:d.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(eo,{className:"h-3 w-3"}),"Apply"]})]})]})}function _e({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Vt({label:e,checked:t,onChange:n}){return r.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s=>n(s.target.checked),className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsx("span",{className:"text-zinc-300",children:e})]})}const Fn=[{value:"forward",label:"Forward",description:"Normal progression through the workflow",icon:De,arrowColor:"#22c55e",bgActive:"rgba(34,197,94,0.12)",borderActive:"rgba(34,197,94,0.4)",hint:""},{value:"backward",label:"Backward",description:"Return to a previous stage for rework",icon:to,arrowColor:"#f59e0b",bgActive:"rgba(245,158,11,0.12)",borderActive:"rgba(245,158,11,0.4)",hint:"Backward edges are shown as amber dashed lines"},{value:"shortcut",label:"Shortcut",description:"Skip intermediate stages",icon:io,arrowColor:"#6366f1",bgActive:"rgba(99,102,241,0.12)",borderActive:"rgba(99,102,241,0.4)",hint:"Shortcut edges are shown as dashed lines and may require a checklist confirmation"}];function R0({value:e,onChange:t,fromLabel:n,toLabel:s}){const o=Fn.find(i=>i.value===e)??Fn[0];return r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"space-y-1.5",children:Fn.map(i=>{const a=e===i.value,c=i.icon;return r.jsxs("button",{onClick:()=>t(i.value),className:"flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left transition-all",style:{backgroundColor:a?i.bgActive:"transparent",border:`1px solid ${a?i.borderActive:"#27272a"}`},children:[r.jsx(c,{className:"h-4 w-4 shrink-0",style:{color:a?i.arrowColor:"#52525b"}}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-[11px] font-semibold",style:{color:a?i.arrowColor:"#a1a1aa"},children:i.label}),r.jsx("div",{className:"text-[9px] text-zinc-500 truncate",children:i.description})]})]},i.value)})}),r.jsxs("div",{className:"flex items-center justify-center gap-2 rounded-md border border-zinc-800 bg-zinc-950/50 px-3 py-2",children:[r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] font-medium text-zinc-300",children:n}),r.jsx("svg",{width:"48",height:"16",viewBox:"0 0 48 16",className:"shrink-0",children:e==="backward"?r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"40",y1:"8",x2:"8",y2:"8",stroke:o.arrowColor,strokeWidth:"1.5",strokeDasharray:"3 2"}),r.jsx("polygon",{points:"8,8 14,4 14,12",fill:o.arrowColor})]}):r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"8",y1:"8",x2:"40",y2:"8",stroke:o.arrowColor,strokeWidth:"1.5",strokeDasharray:e==="shortcut"?"3 2":"none"}),r.jsx("polygon",{points:"40,8 34,4 34,12",fill:o.arrowColor})]})}),r.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[9px] font-medium text-zinc-300",children:s})]}),o.hint&&r.jsx("p",{className:"text-[9px] text-zinc-600 leading-relaxed",children:o.hint})]})}const H0="093",O0=["/scope-","/git-","/test-","/session-"];function B0({value:e,onChange:t,allowedPrefixes:n}){const[s,o]=N.useState(!1),i=N.useRef(null),a=n.length>0?n:O0,c=N.useMemo(()=>e?a.some(p=>e.startsWith(p))?{valid:!0,message:""}:{valid:!1,message:`Command must start with: ${a.join(", ")}`}:null,[e,a]),l=N.useMemo(()=>e?e.replace("{id}",H0):null,[e]),f=N.useCallback(u=>{var p;t(u+"{id}"),o(!1),(p=i.current)==null||p.focus()},[t]),h=N.useCallback(()=>{t(null),o(!1)},[t]),d=N.useMemo(()=>{if(!e)return[];const u=[],p=a.find(x=>e.startsWith(x));if(p){u.push({text:p,type:"prefix"});const x=e.slice(p.length);Fr(x,u)}else Fr(e,u);return u},[e,a]);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"relative",children:[r.jsxs("div",{className:"flex items-center rounded border border-zinc-700 bg-zinc-800 focus-within:border-zinc-500",children:[r.jsx(be,{className:"ml-2 h-3 w-3 shrink-0 text-zinc-600"}),r.jsx("input",{ref:i,value:e??"",onChange:u=>t(u.target.value||null),onFocus:()=>!e&&o(!0),onBlur:()=>setTimeout(()=>o(!1),150),className:"flex-1 bg-transparent px-2 py-1.5 font-mono text-xs text-zinc-200 outline-none placeholder:text-zinc-600",placeholder:"/scope-implement {id}"}),e&&r.jsx("button",{onClick:h,className:"mr-1 rounded p-0.5 text-zinc-600 hover:text-zinc-300",children:r.jsx(he,{className:"h-3 w-3"})})]}),s&&!e&&r.jsx("div",{className:"absolute left-0 top-full z-10 mt-1 w-full rounded border border-zinc-700 bg-zinc-800 py-1 shadow-xl",children:a.map(u=>r.jsxs("button",{onMouseDown:()=>f(u),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-zinc-700",children:[r.jsx("span",{className:"font-mono text-cyan-400",children:u.trim()}),r.jsx("span",{className:"text-[9px] text-zinc-600",children:"{id}"})]},u))})]}),e&&d.length>0&&r.jsx("div",{className:"rounded border border-zinc-800 bg-zinc-950/70 px-2.5 py-1.5 font-mono text-xs",children:d.map((u,p)=>r.jsx("span",{style:{color:u.type==="prefix"?"#60a5fa":u.type==="placeholder"?"#facc15":"#e4e4e7"},children:u.text},p))}),l&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[9px] text-zinc-600",children:"Preview:"}),r.jsx("code",{className:"text-[9px] font-mono text-zinc-400",children:l})]}),c&&!c.valid&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-amber-400",children:[r.jsx(st,{className:"h-3 w-3 shrink-0"}),c.message]}),r.jsxs("p",{className:"text-[9px] text-zinc-600",children:["Use ",r.jsx("code",{className:"rounded bg-zinc-800 px-1 text-yellow-400",children:"{id}"})," as the scope ID placeholder"]})]})}function Fr(e,t){const n=/\{id\}/g;let s=0,o;for(;(o=n.exec(e))!==null;)o.index>s&&t.push({text:e.slice(s,o.index),type:"arg"}),t.push({text:"{id}",type:"placeholder"}),s=o.index+o[0].length;s<e.length&&t.push({text:e.slice(s),type:"arg"})}function Zi(e,t,n){const s=e.slice();return s.splice(n<0?s.length+n:n,0,s.splice(t,1)[0]),s}function F0(e,t){return e.reduce((n,s,o)=>{const i=t.get(s);return i&&(n[o]=i),n},Array(e.length))}function Yt(e){return e!==null&&e>=0}function V0(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Y0(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Qi=e=>{let{rects:t,activeIndex:n,overIndex:s,index:o}=e;const i=Zi(t,s,n),a=t[o],c=i[o];return!c||!a?null:{x:c.left-a.left,y:c.top-a.top,scaleX:c.width/a.width,scaleY:c.height/a.height}},Wt={scaleX:1,scaleY:1},W0=e=>{var t;let{activeIndex:n,activeNodeRect:s,index:o,rects:i,overIndex:a}=e;const c=(t=i[n])!=null?t:s;if(!c)return null;if(o===n){const f=i[a];return f?{x:0,y:n<a?f.top+f.height-(c.top+c.height):f.top-c.top,...Wt}:null}const l=X0(i,o,n);return o>n&&o<=a?{x:0,y:-c.height-l,...Wt}:o<n&&o>=a?{x:0,y:c.height+l,...Wt}:{x:0,y:0,...Wt}};function X0(e,t,n){const s=e[t],o=e[t-1],i=e[t+1];return s?n<t?o?s.top-(o.top+o.height):i?i.top-(s.top+s.height):0:i?i.top-(s.top+s.height):o?s.top-(o.top+o.height):0:0}const Ji="Sortable",ea=is.createContext({activeIndex:-1,containerId:Ji,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Qi,disabled:{draggable:!1,droppable:!1}});function G0(e){let{children:t,id:n,items:s,strategy:o=Qi,disabled:i=!1}=e;const{active:a,dragOverlay:c,droppableRects:l,over:f,measureDroppableContainers:h}=zc(),d=kc(Ji,n),u=c.rect!==null,p=N.useMemo(()=>s.map(z=>typeof z=="object"&&"id"in z?z.id:z),[s]),x=a!=null,b=a?p.indexOf(a.id):-1,v=f?p.indexOf(f.id):-1,y=N.useRef(p),m=!V0(p,y.current),g=v!==-1&&b===-1||m,w=Y0(i);no(()=>{m&&x&&h(p)},[m,p,x,h]),N.useEffect(()=>{y.current=p},[p]);const C=N.useMemo(()=>({activeIndex:b,containerId:d,disabled:w,disableTransforms:g,items:p,overIndex:v,useDragOverlay:u,sortedRects:F0(p,l),strategy:o}),[b,d,w.draggable,w.droppable,g,p,v,l,u,o]);return is.createElement(ea.Provider,{value:C},t)}const q0=e=>{let{id:t,items:n,activeIndex:s,overIndex:o}=e;return Zi(n,s,o).indexOf(t)},U0=e=>{let{containerId:t,isSorting:n,wasDragging:s,index:o,items:i,newIndex:a,previousItems:c,previousContainerId:l,transition:f}=e;return!f||!s||c!==i&&o===a?!1:n?!0:a!==o&&t===l},K0={duration:200,easing:"ease"},ta="transform",Z0=ds.Transition.toString({property:ta,duration:0,easing:"linear"}),Q0={roleDescription:"sortable"};function J0(e){let{disabled:t,index:n,node:s,rect:o}=e;const[i,a]=N.useState(null),c=N.useRef(n);return no(()=>{if(!t&&n!==c.current&&s.current){const l=o.current;if(l){const f=Ic(s.current,{ignoreTransform:!0}),h={x:l.left-f.left,y:l.top-f.top,scaleX:l.width/f.width,scaleY:l.height/f.height};(h.x||h.y)&&a(h)}}n!==c.current&&(c.current=n)},[t,n,s,o]),N.useEffect(()=>{i&&a(null)},[i]),i}function em(e){let{animateLayoutChanges:t=U0,attributes:n,disabled:s,data:o,getNewIndex:i=q0,id:a,strategy:c,resizeObserverConfig:l,transition:f=K0}=e;const{items:h,containerId:d,activeIndex:u,disabled:p,disableTransforms:x,sortedRects:b,overIndex:v,useDragOverlay:y,strategy:m}=N.useContext(ea),g=tm(s,p),w=h.indexOf(a),C=N.useMemo(()=>({sortable:{containerId:d,index:w,items:h},...o}),[d,o,w,h]),z=N.useMemo(()=>h.slice(h.indexOf(a)),[h,a]),{rect:k,node:P,isOver:$,setNodeRef:B}=Sc({id:a,data:C,disabled:g.droppable,resizeObserverConfig:{updateMeasurementsFor:z,...l}}),{active:M,activatorEvent:A,activeNodeRect:H,attributes:j,setNodeRef:T,listeners:S,isDragging:I,over:E,setActivatorNodeRef:_,transform:L}=Ec({id:a,data:C,attributes:{...Q0,...n},disabled:g.draggable}),R=_c(B,T),D=!!M,V=D&&!x&&Yt(u)&&Yt(v),W=!y&&I,G=W&&V?L:null,F=V?G??(c??m)({rects:b,activeNodeRect:H,activeIndex:u,overIndex:v,index:w}):null,O=Yt(u)&&Yt(v)?i({id:a,items:h,activeIndex:u,overIndex:v}):w,Y=M==null?void 0:M.id,q=N.useRef({activeId:Y,items:h,newIndex:O,containerId:d}),Q=h!==q.current.items,Z=t({active:M,containerId:d,isDragging:I,isSorting:D,id:a,index:w,items:h,newIndex:q.current.newIndex,previousItems:q.current.items,previousContainerId:q.current.containerId,transition:f,wasDragging:q.current.activeId!=null}),U=J0({disabled:!Z,index:w,node:P,rect:k});return N.useEffect(()=>{D&&q.current.newIndex!==O&&(q.current.newIndex=O),d!==q.current.containerId&&(q.current.containerId=d),h!==q.current.items&&(q.current.items=h)},[D,O,d,h]),N.useEffect(()=>{if(Y===q.current.activeId)return;if(Y!=null&&q.current.activeId==null){q.current.activeId=Y;return}const ne=setTimeout(()=>{q.current.activeId=Y},50);return()=>clearTimeout(ne)},[Y]),{active:M,activeIndex:u,attributes:j,data:C,rect:k,index:w,newIndex:O,items:h,isOver:$,isSorting:D,isDragging:I,listeners:S,node:P,overIndex:v,over:E,setNodeRef:R,setActivatorNodeRef:_,setDroppableNodeRef:B,setDraggableNodeRef:T,transform:U??F,transition:ee()};function ee(){if(U||Q&&q.current.newIndex===w)return Z0;if(!(W&&!Mc(A)||!f)&&(D||Z))return ds.Transition.toString({...f,property:ta})}}function tm(e,t){var n,s;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e==null?void 0:e.draggable)!=null?n:t.draggable,droppable:(s=e==null?void 0:e.droppable)!=null?s:t.droppable}}function fn(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const nm=[Ie.Down,Ie.Right,Ie.Up,Ie.Left],sm=(e,t)=>{let{context:{active:n,collisionRect:s,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:c}}=t;if(nm.includes(e.code)){if(e.preventDefault(),!n||!s)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const u=o.get(d.id);if(u)switch(e.code){case Ie.Down:s.top<u.top&&l.push(d);break;case Ie.Up:s.top>u.top&&l.push(d);break;case Ie.Left:s.left>u.left&&l.push(d);break;case Ie.Right:s.left<u.left&&l.push(d);break}});const f=vc({collisionRect:s,droppableRects:o,droppableContainers:l});let h=Nc(f,"id");if(h===(a==null?void 0:a.id)&&f.length>1&&(h=f[1].id),h!=null){const d=i.get(n.id),u=i.get(h),p=u?o.get(u.id):null,x=u==null?void 0:u.node.current;if(x&&p&&d&&u){const v=jc(x).some((z,k)=>c[k]!==z),y=na(d,u),m=rm(d,u),g=v||!y?{x:0,y:0}:{x:m?s.width-p.width:0,y:m?s.height-p.height:0},w={x:p.left,y:p.top};return g.x&&g.y?w:Cc(w,g)}}}};function na(e,t){return!fn(e)||!fn(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function rm(e,t){return!fn(e)||!fn(t)||!na(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const om=["Implementation is complete and tested","No merge conflicts with target branch","Tests pass on source branch","Code reviewed","Documentation updated"];function im({items:e,onChange:t,confirmLevel:n}){const[s,o]=N.useState(""),[i,a]=N.useState(null),[c,l]=N.useState(""),f=N.useId(),h=Tc(Bs(Pc,{activationConstraint:{distance:4}}),Bs(Ac,{coordinateGetter:sm})),d=e.map((m,g)=>`checklist-${g}`),u=N.useCallback(m=>{const{active:g,over:w}=m;if(!w||g.id===w.id)return;const C=d.indexOf(String(g.id)),z=d.indexOf(String(w.id));if(C===-1||z===-1)return;const k=[...e],[P]=k.splice(C,1);k.splice(z,0,P),t(k)},[e,d,t]),p=N.useCallback(()=>{const m=s.trim();m&&(t([...e,m]),o(""))},[s,e,t]),x=N.useCallback(m=>{t(e.filter((g,w)=>w!==m)),i===m&&a(null)},[e,t,i]),b=N.useCallback(m=>{a(m),l(e[m])},[e]),v=N.useCallback(()=>{if(i===null)return;const m=c.trim();if(m&&m!==e[i]){const g=[...e];g[i]=m,t(g)}a(null)},[i,c,e,t]),y=N.useCallback(m=>{e.includes(m)||t([...e,m])},[e,t]);return r.jsxs("div",{className:"space-y-2",children:[e.length>0?r.jsx($c,{id:f,sensors:h,collisionDetection:Dc,onDragEnd:u,children:r.jsx(G0,{items:d,strategy:W0,children:r.jsx("div",{className:"space-y-1",children:e.map((m,g)=>r.jsx(am,{id:d[g],item:m,index:g,isEditing:i===g,editValue:c,onEditValueChange:l,onStartEdit:b,onFinishEdit:v,onRemove:x},d[g]))})})}):r.jsxs("div",{className:"rounded border border-dashed border-zinc-800 bg-zinc-950/30 px-3 py-4 text-center",children:[r.jsx(Lc,{className:"mx-auto mb-1.5 h-4 w-4 text-zinc-700"}),r.jsx("p",{className:"text-[10px] text-zinc-600",children:"No checklist items. Add items that must be acknowledged before this transition."})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:m=>o(m.target.value),onKeyDown:m=>m.key==="Enter"&&p(),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 text-xs text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"New item..."}),r.jsx("button",{onClick:p,disabled:!s.trim(),className:"rounded bg-zinc-800 p-1.5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200 disabled:opacity-40",children:r.jsx(Te,{className:"h-3 w-3"})})]}),r.jsxs("div",{children:[r.jsx("span",{className:"mb-1 block text-[9px] font-medium text-zinc-600",children:"Quick add:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:om.filter(m=>!e.includes(m)).map(m=>r.jsxs("button",{onClick:()=>y(m),className:"rounded border border-zinc-800 bg-zinc-950/50 px-1.5 py-0.5 text-[9px] text-zinc-500 transition-colors hover:border-zinc-700 hover:text-zinc-300",children:["+ ",m.length>30?`${m.slice(0,30)}…`:m]},m))})]}),n==="full"&&e.length>0&&r.jsxs("div",{className:"rounded border border-violet-500/20 bg-violet-500/5 p-2",children:[r.jsx("span",{className:"text-[9px] font-medium text-violet-400",children:"Dispatch preview:"}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.map((m,g)=>r.jsxs("li",{className:"flex items-center gap-1.5 text-[9px] text-zinc-400",children:[r.jsx("span",{className:"h-3 w-3 shrink-0 rounded border border-zinc-600"}),m]},g))})]})]})}function am({id:e,item:t,index:n,isEditing:s,editValue:o,onEditValueChange:i,onStartEdit:a,onFinishEdit:c,onRemove:l}){const{attributes:f,listeners:h,setNodeRef:d,transform:u,transition:p,isDragging:x}=em({id:e}),b={transform:ds.Transform.toString(u),transition:p,opacity:x?.5:1};return r.jsxs("div",{ref:d,style:b,className:"group flex items-center gap-1.5 rounded border border-zinc-800 bg-zinc-950/30 px-1.5 py-1",children:[r.jsx("button",{...f,...h,className:"cursor-grab touch-none rounded p-0.5 text-zinc-700 hover:text-zinc-500 active:cursor-grabbing",children:r.jsx(rl,{className:"h-3 w-3"})}),s?r.jsx("input",{value:o,onChange:v=>i(v.target.value),onBlur:c,onKeyDown:v=>v.key==="Enter"&&c(),className:"flex-1 bg-transparent text-xs text-zinc-200 outline-none",autoFocus:!0}):r.jsx("span",{onClick:()=>a(n),className:"flex-1 cursor-text truncate text-xs text-zinc-300",children:t}),r.jsx("button",{onClick:()=>l(n),className:"rounded p-0.5 text-zinc-700 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:r.jsx(oo,{className:"h-3 w-3"})})]})}function cm({dispatchOnly:e,humanOnly:t,skipServerTransition:n,confirmLevel:s,hasCommand:o,onDispatchOnlyChange:i,onHumanOnlyChange:a,onSkipServerTransitionChange:c,onConfirmLevelChange:l}){return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(Vn,{icon:be,label:"Dispatch Only",description:"This transition can only be triggered by a skill command, not by manual drag-and-drop",checked:e,onChange:i}),e&&!o&&r.jsx("p",{className:"ml-6 text-[9px] text-amber-400",children:"No command configured — add one below for this toggle to be effective"}),r.jsx(Vn,{icon:fl,label:"Human Only",description:"This transition requires human confirmation and cannot be triggered by automated processes",checked:t,onChange:a,badge:t?"HUMAN":void 0,badgeColor:"#6366f1"}),r.jsx(Vn,{icon:dl,label:"Skip Server Transition",description:"The skill command handles the status change itself — the server won't move the scope",checked:n,onChange:c}),n&&r.jsx("p",{className:"ml-6 text-[9px] text-amber-400",children:"The bound skill must handle the scope move itself"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Confirmation Mode"}),r.jsxs("div",{className:"grid grid-cols-2 gap-1.5",children:[r.jsx(Vr,{icon:rt,label:"Quick",description:"Immediate — one click to confirm",active:s==="quick",onClick:()=>l("quick"),color:"#f59e0b"}),r.jsx(Vr,{icon:Qc,label:"Full",description:"Review — must acknowledge checklist",active:s==="full",onClick:()=>l("full"),color:"#8b5cf6"})]}),s==="full"&&r.jsx("p",{className:"mt-1.5 text-[9px] text-violet-400",children:"Users must review the checklist before confirming this transition"})]})]})}function Vn({icon:e,label:t,description:n,checked:s,onChange:o,badge:i,badgeColor:a}){return r.jsxs("label",{className:"flex cursor-pointer gap-2 rounded-md border border-zinc-800 bg-zinc-950/30 px-2.5 py-2 transition-colors hover:border-zinc-700",children:[r.jsxs("div",{className:"relative mt-0.5 h-4 w-7 shrink-0 rounded-full transition-colors",style:{backgroundColor:s?"#22c55e":"#3f3f46"},children:[r.jsx("div",{className:"absolute top-0.5 h-3 w-3 rounded-full bg-white transition-transform",style:{transform:s?"translateX(12px)":"translateX(2px)"}}),r.jsx("input",{type:"checkbox",checked:s,onChange:c=>o(c.target.checked),className:"sr-only"})]}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3 w-3 text-zinc-400"}),r.jsx("span",{className:"text-[11px] font-medium text-zinc-300",children:t}),i&&r.jsx("span",{className:"rounded px-1 py-0.5 text-[8px] font-bold",style:{backgroundColor:`${a}20`,color:a},children:i})]}),r.jsx("p",{className:"mt-0.5 text-[9px] text-zinc-600 leading-relaxed",children:n})]})]})}function Vr({icon:e,label:t,description:n,active:s,onClick:o,color:i}){return r.jsxs("button",{onClick:o,className:"rounded-md px-2.5 py-2 text-left transition-all",style:{backgroundColor:s?`${i}12`:"transparent",border:`1px solid ${s?`${i}60`:"#27272a"}`},children:[r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3.5 w-3.5",style:{color:s?i:"#52525b"}}),r.jsx("span",{className:"text-[10px] font-semibold",style:{color:s?i:"#a1a1aa"},children:t})]}),r.jsx("p",{className:"mt-0.5 text-[8px]",style:{color:s?"#a1a1aa":"#52525b"},children:n})]})}function lm({edge:e,lists:t}){const n=N.useMemo(()=>[...t].sort((c,l)=>c.order-l.order),[t]),s=t.find(c=>c.id===e.from),o=t.find(c=>c.id===e.to),i=(s==null?void 0:s.order)??-1,a=(o==null?void 0:o.order)??-1;return e.direction==="shortcut"?r.jsx(dm,{sortedLists:n,fromOrder:i,toOrder:a,edge:e}):e.direction==="backward"?r.jsx(um,{edge:e,fromLabel:(s==null?void 0:s.label)??e.from,toLabel:(o==null?void 0:o.label)??e.to}):r.jsx(fm,{edge:e,fromLabel:(s==null?void 0:s.label)??e.from,toLabel:(o==null?void 0:o.label)??e.to})}function dm({sortedLists:e,fromOrder:t,toOrder:n,edge:s}){const o=e.filter(i=>i.order>Math.min(t,n)&&i.order<Math.max(t,n));return r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ms,{icon:io,color:"#6366f1",label:"Shortcut — Skip Rules"}),r.jsx("div",{className:"flex items-center gap-1 rounded border border-zinc-800 bg-zinc-950/50 px-2.5 py-2 overflow-x-auto",children:e.map((i,a)=>{const c=i.id===s.from,l=i.id===s.to,f=o.some(h=>h.id===i.id);return r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"rounded px-1.5 py-0.5 text-[8px] font-medium whitespace-nowrap",style:{backgroundColor:c||l?"#6366f120":f?"#27272a":"#18181b",color:c||l?"#818cf8":f?"#52525b":"#71717a",border:c||l?"1px solid #6366f140":"1px solid transparent",textDecoration:f?"line-through":"none"},children:i.label}),a<e.length-1&&r.jsx("span",{className:"text-[8px] text-zinc-700",children:"›"})]},i.id)})}),o.length>0?r.jsxs("p",{className:"text-[9px] text-zinc-500",children:[r.jsx("span",{className:"text-indigo-400",children:s.from})," → ",r.jsx("span",{className:"text-indigo-400",children:s.to})," skips ",r.jsx("span",{className:"text-zinc-400",children:o.map(i=>i.label).join(", ")})]}):r.jsx("p",{className:"text-[9px] text-zinc-500",children:"No intermediate lists are skipped."})]})}function um({edge:e,fromLabel:t,toLabel:n}){const s=["Issue documented","Fix scope created","Root cause identified"];return r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ms,{icon:to,color:"#f59e0b",label:"Backward — Revert Rules"}),r.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/20 bg-amber-500/5 px-2.5 py-2",children:[r.jsx("span",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-medium text-amber-400",children:t}),r.jsxs("svg",{width:"24",height:"12",viewBox:"0 0 24 12",className:"shrink-0",children:[r.jsx("line",{x1:"20",y1:"6",x2:"4",y2:"6",stroke:"#f59e0b",strokeWidth:"1.5",strokeDasharray:"2 2"}),r.jsx("polygon",{points:"4,6 8,3 8,9",fill:"#f59e0b"})]}),r.jsx("span",{className:"rounded bg-amber-500/20 px-1.5 py-0.5 text-[9px] font-medium text-amber-400",children:n}),r.jsx("span",{className:"ml-auto rounded bg-amber-500/15 px-1.5 py-0.5 text-[8px] font-semibold text-amber-400",children:"REPAIR"})]}),r.jsxs("p",{className:"text-[9px] text-zinc-500",children:[t," → ",n," is a ",r.jsx("span",{className:"text-amber-400",children:"repair"})," operation. Scopes move backward for rework."]}),(!e.checklist||e.checklist.length===0)&&r.jsxs("div",{className:"rounded border border-zinc-800 bg-zinc-950/50 p-2",children:[r.jsxs("div",{className:"flex items-center gap-1 mb-1.5",children:[r.jsx(Rc,{className:"h-3 w-3 text-zinc-600"}),r.jsx("span",{className:"text-[9px] font-medium text-zinc-500",children:"Suggested checklist items"})]}),r.jsx("ul",{className:"space-y-0.5",children:s.map(o=>r.jsxs("li",{className:"text-[9px] text-zinc-600 flex items-center gap-1.5",children:[r.jsx("span",{className:"h-1 w-1 rounded-full bg-zinc-700 shrink-0"}),o]},o))})]})]})}function fm({edge:e,fromLabel:t,toLabel:n}){return r.jsxs("div",{className:"space-y-2",children:[r.jsx(Ms,{icon:De,color:"#22c55e",label:"Forward — Progression"}),r.jsxs("div",{className:"flex items-center gap-2 rounded border border-emerald-500/20 bg-emerald-500/5 px-2.5 py-2",children:[r.jsx("span",{className:"rounded bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-medium text-emerald-400",children:t}),r.jsxs("svg",{width:"24",height:"12",viewBox:"0 0 24 12",className:"shrink-0",children:[r.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6",stroke:"#22c55e",strokeWidth:"1.5"}),r.jsx("polygon",{points:"20,6 16,3 16,9",fill:"#22c55e"})]}),r.jsx("span",{className:"rounded bg-emerald-500/20 px-1.5 py-0.5 text-[9px] font-medium text-emerald-400",children:n})]}),e.dispatchOnly&&r.jsxs("p",{className:"text-[9px] text-zinc-500",children:["This transition requires a ",r.jsx("span",{className:"text-cyan-400",children:"skill command"})," to trigger."]})]})}function Ms({icon:e,color:t,label:n}){return r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx(e,{className:"h-3 w-3",style:{color:t}}),r.jsx("span",{className:"text-[10px] font-semibold",style:{color:t},children:n})]})}function hm({edge:e,config:t,onSave:n,onDelete:s,onClose:o}){const[i,a]=N.useState(()=>structuredClone(e)),[c,l]=N.useState(!1),f=N.useMemo(()=>t.lists.map(m=>m.id),[t.lists]),h=N.useMemo(()=>t.hooks??[],[t.hooks]),d=N.useMemo(()=>t.allowedCommandPrefixes??[],[t.allowedCommandPrefixes]),u=N.useMemo(()=>{var m;return((m=t.lists.find(g=>g.id===i.from))==null?void 0:m.label)??i.from},[t.lists,i.from]),p=N.useMemo(()=>{var m;return((m=t.lists.find(g=>g.id===i.to))==null?void 0:m.label)??i.to},[t.lists,i.to]),x=N.useMemo(()=>{const m=[];i.from||m.push("From is required"),i.to||m.push("To is required"),i.from===i.to&&m.push("From and To must be different"),i.label.trim()||m.push("Label is required"),i.description.trim()||m.push("Description is required");const g=`${i.from}:${i.to}`,w=`${e.from}:${e.to}`;return g!==w&&t.edges.some(C=>`${C.from}:${C.to}`===g)&&m.push("An edge with this from:to already exists"),m},[i,e,t.edges]),b=N.useCallback((m,g)=>{a(w=>({...w,[m]:g}))},[]),v=N.useCallback(m=>{a(g=>{const w=g.hooks??[],C=w.includes(m);return{...g,hooks:C?w.filter(z=>z!==m):[...w,m]}})},[]),y=N.useCallback(()=>{x.length>0||n(i)},[i,x,n]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-cyan-500/30 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsx("span",{className:"text-sm font-medium",children:"Edit Edge"}),r.jsx("button",{onClick:o,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-3 overflow-y-auto p-4 text-xs",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsx(xe,{label:"From",children:r.jsx("select",{value:i.from,onChange:m=>b("from",m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:f.map(m=>r.jsx("option",{value:m,children:m},m))})}),r.jsx(xe,{label:"To",children:r.jsx("select",{value:i.to,onChange:m=>b("to",m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:f.map(m=>r.jsx("option",{value:m,children:m},m))})})]}),r.jsx(xe,{label:"Direction",children:r.jsx(R0,{value:i.direction,onChange:m=>b("direction",m),fromLabel:u,toLabel:p})}),r.jsx(xe,{label:"Movement Rules",children:r.jsx(lm,{edge:i,lists:t.lists})}),r.jsx(xe,{label:"Label",children:r.jsx("input",{value:i.label,onChange:m=>b("label",m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(xe,{label:"Description",children:r.jsx("textarea",{value:i.description,onChange:m=>b("description",m.target.value),rows:2,className:"w-full resize-none rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(xe,{label:"Skill Command",children:r.jsx(B0,{value:i.command,onChange:m=>b("command",m),allowedPrefixes:d})}),r.jsx(xe,{label:"Dispatch & Confirmation",children:r.jsx(cm,{dispatchOnly:i.dispatchOnly??!1,humanOnly:i.humanOnly??!1,skipServerTransition:i.skipServerTransition??!1,confirmLevel:i.confirmLevel,hasCommand:i.command!==null,onDispatchOnlyChange:m=>b("dispatchOnly",m||void 0),onHumanOnlyChange:m=>b("humanOnly",m||void 0),onSkipServerTransitionChange:m=>b("skipServerTransition",m||void 0),onConfirmLevelChange:m=>b("confirmLevel",m)})}),r.jsx(xe,{label:`Checklist (${(i.checklist??[]).length})`,children:r.jsx(im,{items:i.checklist??[],onChange:m=>b("checklist",m.length>0?m:void 0),confirmLevel:i.confirmLevel})}),h.length>0&&r.jsx(xe,{label:`Hooks (${(i.hooks??[]).length} selected)`,children:r.jsx("div",{className:"space-y-1.5",children:h.map(m=>r.jsx(pm,{hook:m,checked:(i.hooks??[]).includes(m.id),onToggle:()=>v(m.id)},m.id))})}),x.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:x.map(m=>r.jsx("p",{className:"text-[10px] text-red-400",children:m},m))})]}),r.jsxs("div",{className:"flex items-center gap-2 border-t border-zinc-800 px-4 py-3",children:[c?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[10px] text-red-400",children:"Confirm?"}),r.jsx("button",{onClick:s,className:"rounded bg-red-500/20 px-2 py-1 text-[10px] text-red-400 hover:bg-red-500/30",children:"Delete"}),r.jsx("button",{onClick:()=>l(!1),className:"rounded px-2 py-1 text-[10px] text-zinc-500 hover:text-zinc-300",children:"Cancel"})]}):r.jsx("button",{onClick:()=>l(!0),className:"rounded p-1.5 text-zinc-600 hover:bg-red-500/10 hover:text-red-400",children:r.jsx(ls,{className:"h-3.5 w-3.5"})}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:y,disabled:x.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(eo,{className:"h-3 w-3"}),"Apply"]})]})]})}function xe({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function pm({hook:e,checked:t,onToggle:n}){return r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:n,className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("span",{className:"text-zinc-300",children:e.label}),r.jsxs("span",{className:"ml-1.5 text-[9px] text-zinc-600",children:[e.timing," · ",e.type]})]})]})}function xm({canUndo:e,canRedo:t,changeCount:n,validation:s,saving:o,onAddList:i,onAddEdge:a,onConfigSettings:c,onUndo:l,onRedo:f,onSave:h,onDiscard:d,onPreview:u}){return r.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-cyan-500/30 bg-zinc-900/95 px-3 py-2 shadow-lg backdrop-blur",children:[r.jsx(Ve,{icon:Te,label:"List",onClick:i,color:"blue"}),r.jsx(Ve,{icon:Kr,label:"Edge",onClick:a,color:"blue"}),r.jsx(Ve,{icon:so,label:"Config",onClick:c}),r.jsx(Yn,{}),r.jsx(Ve,{icon:Hc,onClick:l,disabled:!e}),r.jsx(Ve,{icon:cl,onClick:f,disabled:!t}),n>0&&r.jsxs("span",{className:"rounded-full bg-amber-500/20 px-2 py-0.5 text-[9px] font-semibold text-amber-400",children:[n," change",n!==1?"s":""]}),r.jsx(Yn,{}),s.valid?r.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-emerald-400",children:[r.jsx(Jt,{className:"h-3.5 w-3.5"}),"Valid"]}):r.jsxs("span",{className:"group relative flex items-center gap-1 text-[10px] text-red-400",children:[r.jsx(st,{className:"h-3.5 w-3.5"}),s.errors.length," error",s.errors.length!==1?"s":"",r.jsx("div",{className:"absolute bottom-full left-0 z-50 mb-2 hidden w-64 rounded border border-red-500/30 bg-zinc-900 p-2 shadow-xl group-hover:block",children:s.errors.map(p=>r.jsx("p",{className:"text-[10px] text-red-400",children:p},p))})]}),r.jsx(Yn,{}),r.jsx(Ve,{icon:Oc,label:"Preview",onClick:u}),r.jsxs("button",{onClick:h,disabled:!s.valid||n===0||o,className:"flex items-center gap-1.5 rounded bg-emerald-600 px-3 py-1.5 text-[11px] font-medium text-white transition-colors hover:bg-emerald-500 disabled:opacity-40",children:[r.jsx(ro,{className:"h-3 w-3"}),o?"Saving...":"Save"]}),r.jsxs("button",{onClick:d,className:"flex items-center gap-1.5 rounded bg-red-600/80 px-3 py-1.5 text-[11px] font-medium text-white transition-colors hover:bg-red-500",children:[r.jsx(Kc,{className:"h-3 w-3"}),"Discard"]})]})}function Ve({icon:e,label:t,onClick:n,disabled:s,color:o}){const i=o==="blue";return r.jsxs("button",{onClick:n,disabled:s,className:"flex items-center gap-1 rounded px-2 py-1.5 text-[10px] font-medium transition-colors disabled:opacity-30",style:{color:i?"#3b82f6":"#a1a1aa",backgroundColor:"transparent"},onMouseEnter:a=>{a.currentTarget.style.backgroundColor=i?"#3b82f615":"#27272a"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="transparent"},children:[r.jsx(e,{className:"h-3.5 w-3.5"}),t]})}function Yn(){return r.jsx("div",{className:"h-4 w-px bg-zinc-800"})}function mm(e){const t=parseInt(e.slice(1,3),16)/255,n=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,o=Math.max(t,n,s),i=Math.min(t,n,s),a=(o+i)/2;if(o===i)return`0 0% ${Math.round(a*100)}%`;const c=o-i,l=a>.5?c/(2-o-i):c/(o+i);let f=0;return o===t?f=((n-s)/c+(n<s?6:0))/6:o===n?f=((s-t)/c+2)/6:f=((t-n)/c+4)/6,`${Math.round(f*360)} ${Math.round(l*100)}% ${Math.round(a*100)}%`}function gm({open:e,onOpenChange:t,config:n,onAdd:s}){const[o,i]=N.useState(""),[a,c]=N.useState(""),[l,f]=N.useState("#3b82f6"),[h,d]=N.useState(""),u=N.useMemo(()=>[...new Set(n.lists.map(m=>m.group).filter(Boolean))],[n.lists]),p=N.useMemo(()=>Math.max(0,...n.lists.map(y=>y.order)),[n.lists]),x=N.useMemo(()=>{const y=[];return o?/^[a-z0-9-]+$/.test(o)?n.lists.some(m=>m.id===o)&&y.push("ID already exists"):y.push("ID must be lowercase alphanumeric + hyphens"):y.push("ID is required"),a.trim()||y.push("Label is required"),y},[o,a,n.lists]),b=N.useCallback(()=>{i(""),c(""),f("#3b82f6"),d("")},[]),v=N.useCallback(()=>{if(x.length>0)return;const y={id:o,label:a.trim(),order:p+1,color:mm(l),hex:l,hasDirectory:!0,...h?{group:h}:{}};s(y),b(),t(!1)},[x,o,a,l,h,p,s,b,t]);return r.jsx(ts,{open:e,onOpenChange:t,children:r.jsxs(ns,{children:[r.jsx(ss,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),r.jsxs(rs,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[r.jsxs(os,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[r.jsx(Te,{className:"h-4 w-4 text-cyan-400"}),"Add List"]}),r.jsx(Ue,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"space-y-4 p-5 text-xs",children:[r.jsxs("div",{className:"flex items-center gap-3 rounded border border-zinc-800 bg-zinc-950/50 p-3",children:[r.jsx("div",{className:"h-5 w-5 rounded",style:{backgroundColor:l}}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-zinc-200",children:a||"New List"}),r.jsx("p",{className:"font-mono text-[10px] text-zinc-500",children:o||"list-id"})]})]}),r.jsx(Xt,{label:"ID",children:r.jsx("input",{value:o,onChange:y=>i(y.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. review",autoFocus:!0})}),r.jsx(Xt,{label:"Label",children:r.jsx("input",{value:a,onChange:y=>c(y.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Review"})}),r.jsx(Xt,{label:"Color",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"color",value:l,onChange:y=>f(y.target.value),className:"h-8 w-8 cursor-pointer rounded border border-zinc-700 bg-zinc-800 p-0.5"}),r.jsx("input",{value:l,onChange:y=>f(y.target.value),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none focus:border-zinc-500"})]})}),r.jsx(Xt,{label:"Group",children:r.jsxs("select",{value:h,onChange:y=>d(y.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"None"}),u.map(y=>r.jsx("option",{value:y,children:y},y))]})}),x.length>0&&o.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:x.map(y=>r.jsx("p",{className:"text-[10px] text-red-400",children:y},y))})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[r.jsx(Ue,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),r.jsxs("button",{onClick:v,disabled:x.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(Te,{className:"h-3.5 w-3.5"}),"Add List"]})]})]})]})})}function Xt({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}const bm=["forward","backward","shortcut"],ym=["quick","full"],wm={forward:"#22c55e",backward:"#f59e0b",shortcut:"#6366f1"};function vm({open:e,onOpenChange:t,config:n,onAdd:s}){const[o,i]=N.useState(""),[a,c]=N.useState(""),[l,f]=N.useState("forward"),[h,d]=N.useState(""),[u,p]=N.useState(""),[x,b]=N.useState("quick"),v=N.useMemo(()=>n.lists.map(w=>w.id),[n.lists]),y=N.useMemo(()=>{const w=[];return o||w.push("From is required"),a||w.push("To is required"),o&&a&&o===a&&w.push("From and To must be different"),o&&a&&n.edges.some(C=>C.from===o&&C.to===a)&&w.push("An edge with this from:to already exists"),h.trim()||w.push("Label is required"),w},[o,a,h,n.edges]),m=N.useCallback(()=>{i(""),c(""),f("forward"),d(""),p(""),b("quick")},[]),g=N.useCallback(()=>{if(y.length>0)return;const w={from:o,to:a,direction:l,label:h.trim(),description:`Transition from ${o} to ${a}`,command:u.trim()||null,confirmLevel:x};s(w),m(),t(!1)},[y,o,a,l,h,u,x,s,m,t]);return r.jsx(ts,{open:e,onOpenChange:t,children:r.jsxs(ns,{children:[r.jsx(ss,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),r.jsxs(rs,{className:"fixed left-1/2 top-1/2 z-50 w-96 -translate-x-1/2 -translate-y-1/2 rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[r.jsxs(os,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[r.jsx(Te,{className:"h-4 w-4 text-cyan-400"}),"Add Edge"]}),r.jsx(Ue,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"space-y-4 p-5 text-xs",children:[r.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[r.jsx(Ye,{label:"From",children:r.jsxs("select",{value:o,onChange:w=>i(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select..."}),v.map(w=>r.jsx("option",{value:w,children:w},w))]})}),r.jsx(Ye,{label:"To",children:r.jsxs("select",{value:a,onChange:w=>c(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select..."}),v.map(w=>r.jsx("option",{value:w,children:w},w))]})})]}),r.jsx(Ye,{label:"Direction",children:r.jsx("div",{className:"flex gap-1",children:bm.map(w=>{const C=wm[w];return r.jsx("button",{onClick:()=>f(w),className:"flex-1 rounded px-2 py-1.5 text-[10px] font-medium uppercase transition-colors",style:{backgroundColor:l===w?`${C}20`:"transparent",color:l===w?C:"#71717a",border:`1px solid ${l===w?`${C}40`:"#27272a"}`},children:w},w)})})}),r.jsx(Ye,{label:"Label",children:r.jsx("input",{value:h,onChange:w=>d(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"e.g. Implement"})}),r.jsx(Ye,{label:"Command (optional)",children:r.jsx("input",{value:u,onChange:w=>p(w.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-2 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"/scope-implement {id}"})}),r.jsx(Ye,{label:"Confirm Level",children:r.jsx("div",{className:"flex gap-1",children:ym.map(w=>r.jsx("button",{onClick:()=>b(w),className:"flex-1 rounded px-2 py-1.5 text-[10px] font-medium uppercase transition-colors",style:{backgroundColor:x===w?"#22c55e20":"transparent",color:x===w?"#22c55e":"#71717a",border:`1px solid ${x===w?"#22c55e40":"#27272a"}`},children:w},w))})}),y.length>0&&o.length>0&&a.length>0&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-2.5",children:y.map(w=>r.jsx("p",{className:"text-[10px] text-red-400",children:w},w))})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[r.jsx(Ue,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),r.jsxs("button",{onClick:g,disabled:y.length>0,className:"flex items-center gap-1.5 rounded bg-cyan-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-cyan-500 disabled:opacity-40",children:[r.jsx(Te,{className:"h-3.5 w-3.5"}),"Add Edge"]})]})]})]})})}function Ye({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Nm({open:e,onOpenChange:t,config:n,plan:s,loading:o,error:i,onApply:a}){const[c,l]=N.useState({});N.useMemo(()=>{s!=null&&s.suggestedMappings&&l({...s.suggestedMappings})},[s==null?void 0:s.suggestedMappings]);const f=N.useMemo(()=>n.lists.map(u=>u.id),[n.lists]),h=N.useMemo(()=>s?s.orphanedScopes.every(u=>c[u.listId]):!0,[s,c]),d=N.useCallback(()=>{h&&a(c)},[h,c,a]);return r.jsx(ts,{open:e,onOpenChange:t,children:r.jsxs(ns,{children:[r.jsx(ss,{className:"fixed inset-0 z-40 bg-black/60 backdrop-blur-sm"}),r.jsxs(rs,{className:"fixed left-1/2 top-1/2 z-50 max-h-[80vh] w-[520px] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-lg border border-zinc-800 bg-zinc-900 shadow-xl",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-5 py-4",children:[r.jsxs(os,{className:"flex items-center gap-2 text-sm font-medium text-zinc-100",children:[r.jsx(st,{className:"h-4 w-4 text-amber-400"}),"Migration Preview"]}),r.jsx(Ue,{className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-5 text-xs",children:[o&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-zinc-500",children:[r.jsx(Zr,{className:"h-4 w-4 animate-spin"}),r.jsx("span",{children:"Computing migration impact..."})]}),i&&r.jsx("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-3 text-red-400",children:i}),s&&!o&&r.jsxs("div",{className:"space-y-4",children:[!s.valid&&r.jsxs("div",{className:"rounded border border-red-500/30 bg-red-500/10 p-3",children:[r.jsx("p",{className:"mb-2 font-semibold text-red-400",children:"Validation Errors"}),s.validationErrors.map(u=>r.jsx("p",{className:"text-red-400",children:u},u))]}),s.valid&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"rounded border border-zinc-800 bg-zinc-950/50 p-3",children:r.jsx("p",{className:"text-zinc-300",children:s.impactSummary})}),s.addedLists.length>0&&r.jsx(Gt,{title:`Added Lists (${s.addedLists.length})`,children:r.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.addedLists.map(u=>r.jsxs("span",{className:"rounded bg-emerald-500/15 px-2 py-1 font-mono text-emerald-400",children:["+ ",u]},u))})}),s.removedLists.length>0&&r.jsx(Gt,{title:`Removed Lists (${s.removedLists.length})`,children:r.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.removedLists.map(u=>r.jsxs("span",{className:"rounded bg-red-500/15 px-2 py-1 font-mono text-red-400",children:["- ",u]},u))})}),s.lostEdges.length>0&&r.jsx(Gt,{title:`Lost Edges (${s.lostEdges.length})`,children:r.jsx("div",{className:"space-y-1",children:s.lostEdges.map(u=>r.jsxs("div",{className:"flex items-center gap-2 text-zinc-400",children:[r.jsx("span",{className:"font-mono",children:u.from}),r.jsx(De,{className:"h-3 w-3 text-zinc-600"}),r.jsx("span",{className:"font-mono",children:u.to})]},`${u.from}:${u.to}`))})}),s.orphanedScopes.length>0&&r.jsx(Gt,{title:"Orphaned Scopes — Reassignment Required",children:r.jsx("div",{className:"space-y-3",children:s.orphanedScopes.map(u=>r.jsxs("div",{className:"rounded border border-amber-500/30 bg-amber-500/5 p-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"font-mono text-amber-400",children:u.listId}),r.jsxs("span",{className:"text-zinc-500",children:[u.scopeFiles.length," scope(s)"]})]}),r.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[r.jsx("span",{className:"text-zinc-500",children:"Move to:"}),r.jsxs("select",{value:c[u.listId]??"",onChange:p=>l(x=>({...x,[u.listId]:p.target.value})),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",children:[r.jsx("option",{value:"",children:"Select destination..."}),f.map(p=>r.jsx("option",{value:p,children:p},p))]})]}),u.scopeFiles.length<=5&&r.jsx("div",{className:"mt-2 space-y-0.5",children:u.scopeFiles.map(p=>r.jsx("p",{className:"font-mono text-[10px] text-zinc-500",children:p},p))})]},u.listId))})}),s.removedLists.length===0&&s.addedLists.length===0&&s.lostEdges.length===0&&s.orphanedScopes.length===0&&r.jsxs("div",{className:"flex items-center gap-2 rounded border border-emerald-500/30 bg-emerald-500/10 p-3 text-emerald-400",children:[r.jsx(Jt,{className:"h-4 w-4"}),r.jsx("span",{children:"No migration needed — configs are compatible"})]})]})]})]}),r.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-zinc-800 px-5 py-4",children:[r.jsx(Ue,{className:"rounded px-3 py-1.5 text-xs text-zinc-400 hover:bg-zinc-800 hover:text-zinc-200",children:"Cancel"}),(s==null?void 0:s.valid)&&r.jsxs("button",{onClick:d,disabled:!h,className:"flex items-center gap-1.5 rounded bg-emerald-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-emerald-500 disabled:opacity-40",children:[r.jsx(Jt,{className:"h-3.5 w-3.5"}),"Apply Migration"]})]})]})]})})}function Gt({title:e,children:t}){return r.jsxs("div",{children:[r.jsx("h4",{className:"mb-2 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function jm({prefixes:e,edges:t,onChange:n}){const[s,o]=N.useState(""),[i,a]=N.useState(null),c=N.useMemo(()=>{const d=new Map;for(const u of e){const p=t.filter(x=>{var b;return(b=x.command)==null?void 0:b.startsWith(u)}).map(x=>`${x.from} → ${x.to}`);d.set(u,p)}return d},[e,t]),l=N.useCallback(d=>d.startsWith("/")?d.endsWith(" ")?e.includes(d)?"Already exists":null:"Must end with a space":"Must start with /",[e]),f=N.useCallback(()=>{const d=s,u=l(d);if(u){a(u);return}n([...e,d]),o(""),a(null)},[s,e,n,l]),h=N.useCallback(d=>{n(e.filter(u=>u!==d))},[e,n]);return r.jsxs("div",{className:"space-y-2",children:[e.length>0?r.jsx("div",{className:"space-y-1",children:e.map(d=>{const u=c.get(d)??[];return r.jsxs("div",{className:"group flex items-start gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2.5 py-1.5",children:[r.jsx(be,{className:"mt-0.5 h-3 w-3 shrink-0 text-zinc-600"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("code",{className:"text-xs font-mono text-cyan-400",children:d.trim()}),u.length>0?r.jsxs("p",{className:"mt-0.5 text-[9px] text-zinc-600",children:["Used by: ",u.join(", ")]}):r.jsx("p",{className:"mt-0.5 text-[9px] text-zinc-700",children:"No edges use this prefix"})]}),r.jsx("button",{onClick:()=>h(d),className:"rounded p-0.5 text-zinc-700 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:r.jsx(he,{className:"h-3 w-3"})})]},d)})}):r.jsx("p",{className:"text-[10px] text-zinc-600",children:"No command prefixes configured."}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:d=>{o(d.target.value),a(null)},onKeyDown:d=>d.key==="Enter"&&f(),className:"flex-1 rounded border border-zinc-700 bg-zinc-800 px-2 py-1 font-mono text-xs text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"/prefix "}),r.jsx("button",{onClick:f,disabled:!s,className:"rounded bg-zinc-800 p-1.5 text-zinc-400 hover:bg-zinc-700 hover:text-zinc-200 disabled:opacity-40",children:r.jsx(Te,{className:"h-3 w-3"})})]}),i&&r.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-amber-400",children:[r.jsx(st,{className:"h-3 w-3 shrink-0"}),i]}),r.jsxs("p",{className:"text-[9px] text-zinc-600",children:["Prefixes must start with ",r.jsx("code",{className:"text-zinc-400",children:"/"})," and end with a space"]})]})}function Cm({config:e,onUpdate:t,onClose:n}){const[s,o]=N.useState(e.name),[i,a]=N.useState(e.description??""),[c,l]=N.useState(e.commitBranchPatterns??""),[f,h]=N.useState(e.branchingMode??"trunk"),d=N.useMemo(()=>e.lists.map(m=>m.id),[e.lists]),[u,p]=N.useState(new Set(e.terminalStatuses??[])),x=N.useMemo(()=>{if(!c)return null;try{return new RegExp(c),null}catch{return"Invalid regex pattern"}},[c]),b=N.useCallback(m=>{p(g=>{const w=new Set(g);return w.has(m)?w.delete(m):w.add(m),w})},[]),v=N.useCallback(m=>{t({...e,allowedCommandPrefixes:m})},[e,t]),y=N.useCallback(()=>{t({...e,name:s.trim()||e.name,description:i.trim()||void 0,branchingMode:f,terminalStatuses:[...u],commitBranchPatterns:c||void 0})},[e,s,i,f,u,c,t]);return r.jsxs("div",{className:"flex h-full w-80 shrink-0 flex-col rounded-lg border border-zinc-700 bg-zinc-900/95 backdrop-blur",children:[r.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(so,{className:"h-3.5 w-3.5 text-zinc-400"}),r.jsx("span",{className:"text-sm font-medium",children:"Config Settings"})]}),r.jsx("button",{onClick:n,className:"rounded p-1 text-zinc-500 hover:bg-zinc-800 hover:text-zinc-300",children:r.jsx(he,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-4 text-xs",children:[r.jsx(We,{label:"Config Name",children:r.jsx("input",{value:s,onChange:m=>o(m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500"})}),r.jsx(We,{label:"Description",children:r.jsx("textarea",{value:i,onChange:m=>a(m.target.value),rows:2,className:"w-full resize-none rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 text-zinc-200 outline-none focus:border-zinc-500",placeholder:"Optional config description..."})}),r.jsxs(We,{label:"Branching Mode",children:[r.jsx("div",{className:"flex gap-2",children:["trunk","worktree"].map(m=>r.jsxs("label",{className:"flex flex-1 cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("input",{type:"radio",name:"branchingMode",value:m,checked:f===m,onChange:()=>h(m),className:"h-3.5 w-3.5 border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsx("span",{className:"text-zinc-300 capitalize",children:m})]},m))}),r.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:"Trunk: all work on current branch. Worktree: git worktree per scope for isolation."})]}),r.jsx(We,{label:"Allowed Command Prefixes",children:r.jsx(jm,{prefixes:e.allowedCommandPrefixes??[],edges:e.edges,onChange:v})}),r.jsxs(We,{label:"Terminal Statuses",children:[r.jsx("div",{className:"space-y-1",children:d.map(m=>r.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded border border-zinc-800 bg-zinc-950/30 px-2 py-1.5",children:[r.jsx("input",{type:"checkbox",checked:u.has(m),onChange:()=>b(m),className:"h-3.5 w-3.5 rounded border-zinc-600 bg-zinc-800 text-cyan-500 focus:ring-0 focus:ring-offset-0"}),r.jsx("span",{className:"text-zinc-300",children:m})]},m))}),r.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:'Terminal statuses mark a scope as "done" — no further progression expected.'})]}),r.jsxs(We,{label:"Commit Branch Patterns",children:[r.jsx("input",{value:c,onChange:m=>l(m.target.value),className:"w-full rounded border border-zinc-700 bg-zinc-800 px-2.5 py-1.5 font-mono text-zinc-200 outline-none placeholder:text-zinc-600 focus:border-zinc-500",placeholder:"^(dev|feat/|fix/|scope/)"}),x&&r.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[9px] text-amber-400",children:[r.jsx(st,{className:"h-3 w-3 shrink-0"}),x]}),r.jsx("p",{className:"mt-1 text-[9px] text-zinc-600",children:"Regex pattern for branches that should trigger commit-session hooks."})]})]}),r.jsx("div",{className:"flex items-center justify-end border-t border-zinc-800 px-4 py-3",children:r.jsx("button",{onClick:y,className:"rounded bg-cyan-600 px-3 py-1.5 text-[11px] font-medium text-white hover:bg-cyan-500",children:"Apply"})})]})}function We({label:e,children:t}){return r.jsxs("div",{children:[r.jsx("label",{className:"mb-1.5 block text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:e}),t]})}function Yr(e){return e.replace(/^"?\$CLAUDE_PROJECT_DIR"?\/?/,"").replace(/^\.\//,"")}function zm(e){return e.replace(/\.[^.]+$/,"").split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function km(e,t){const n=new Map;for(const s of e){const o=Yr(s.target);n.set(o,{id:s.id,label:s.label,scriptPath:o,source:"workflow",workflow:{timing:s.timing,type:s.type,category:s.category,blocking:s.blocking??!1,description:s.description}})}for(const s of t){const o=Yr(s.scriptPath),i={event:s.event,matcher:s.matcher,statusMessage:s.statusMessage},a=n.get(o);if(a)a.source="both",a.ccTriggers||(a.ccTriggers=[]),a.ccTriggers.push(i);else{const c=o,l=n.get(c);l?l.ccTriggers.push(i):n.set(c,{id:s.id,label:zm(s.scriptName),scriptPath:o,source:"claude-code",ccTriggers:[i]})}}return Array.from(n.values())}const Sm={workflow:Yi},Em={workflow:Wi};function Vm(){const{engine:e}=Bc(),{scopes:t}=Fc(),{ccHooks:n}=Wx(),{activeProjectId:s,hasMultipleProjects:o,projectEngines:i}=Ur(),a=o&&s===null,c=e.getConfig(),l=qc(c),f=N.useMemo(()=>!a||i.size===0?!1:!Vc([...i.values()]),[a,i]),h=l.editMode?l.editConfig:c,d=N.useMemo(()=>[...h.lists].sort((F,O)=>F.order-O.order),[h.lists]),u=h.edges,p=h.hooks??[],x=N.useMemo(()=>km(p,n),[p,n]),[b,v]=N.useState("graph"),[y,m]=N.useState(null),[g,w]=N.useState(null),C=N.useCallback(F=>{const O=x.find(Y=>Y.id===F.id);O&&m(O)},[x]),z=N.useCallback((F,O)=>{w(null),v("graph"),E({type:"edge",from:F,to:O})},[]),k=N.useMemo(()=>{const F=new Map;for(const O of t)F.set(O.status,(F.get(O.status)??0)+1);return F},[t]),P=N.useMemo(()=>qi(u,d),[u,d]),$=N.useMemo(()=>Xi(d,h.groups??[],k).map(F=>({...F,data:{...F.data,activeHandles:P.get(F.id)}})),[d,h.groups,k,u,P]),B=N.useMemo(()=>Gi(u,d,p,!1),[u,d,p]),[M,A,H]=gx($),[j,T,S]=bx(B);N.useEffect(()=>{A($)},[$,A]),N.useEffect(()=>{T(B)},[B,T]);const[I,E]=N.useState({type:"none"}),_=N.useCallback((F,O)=>{E({type:"node",listId:O.id})},[]),L=N.useCallback((F,O)=>{const[Y,q]=O.id.split(":");E({type:"edge",from:Y,to:q})},[]),R=N.useCallback(()=>E({type:"none"}),[]),D=I.type==="node"?h.lists.find(F=>F.id===I.listId)??null:null,V=I.type==="edge"?u.find(F=>F.from===I.from&&F.to===I.to)??null:null,W=N.useMemo(()=>{if(!D)return[];const F=u.filter(Y=>Y.from===D.id||Y.to===D.id),O=new Set(F.flatMap(Y=>Y.hooks??[]));return p.filter(Y=>O.has(Y.id))},[D,u,p]),G=N.useMemo(()=>D?u.filter(F=>F.from===D.id||F.to===D.id):[],[D,u]),K=N.useMemo(()=>V?(V.hooks??[]).map(F=>p.find(O=>O.id===F)).filter(F=>F!==void 0):[],[V,p]);return r.jsxs("div",{className:"flex flex-1 min-h-0 flex-col",children:[r.jsx(Yc,{}),r.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(Wc,{className:"h-4 w-4 text-primary"}),r.jsx("h1",{className:"text-xl font-light",children:"Workflow"}),a&&r.jsx("span",{className:"rounded bg-zinc-500/20 px-2 py-0.5 text-[10px] font-semibold text-zinc-400",children:"READ-ONLY"}),l.editMode&&r.jsx("span",{className:"rounded bg-cyan-500/20 px-2 py-0.5 text-[10px] font-semibold text-cyan-400",children:"EDIT MODE"}),!l.editMode&&r.jsxs("div",{className:"ml-4 flex rounded-lg border border-zinc-800 bg-zinc-900/50 p-0.5",children:[r.jsx(Wr,{active:b==="graph",onClick:()=>v("graph"),icon:r.jsx(il,{className:"h-3 w-3"}),label:"Graph"}),r.jsx(Wr,{active:b==="hooks",onClick:()=>v("hooks"),icon:r.jsx(rt,{className:"h-3 w-3"}),label:"Hooks",count:x.length})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!l.editMode&&!a&&r.jsxs("button",{onClick:l.enterEditMode,className:"flex items-center gap-1.5 rounded border border-zinc-800 px-3 py-1.5 text-xs text-zinc-400 transition-colors hover:border-cyan-500/40 hover:text-cyan-400",children:[r.jsx(Uc,{className:"h-3.5 w-3.5"}),"Edit"]}),!l.editMode&&!a&&r.jsx(g0,{activeConfigName:c.name})]})]}),l.editMode&&r.jsx("div",{className:"mb-3",children:r.jsx(xm,{canUndo:l.canUndo,canRedo:l.canRedo,changeCount:l.changeCount,validation:l.validation,saving:l.saving,onAddList:()=>l.setShowAddList(!0),onAddEdge:()=>l.setShowAddEdge(!0),onConfigSettings:()=>{l.setShowConfigSettings(!0),E({type:"none"})},onUndo:l.undo,onRedo:l.redo,onSave:l.save,onDiscard:l.discard,onPreview:l.preview})}),(b==="graph"||l.editMode)&&a&&f&&r.jsx(t0,{engines:i}),(b==="graph"||l.editMode)&&!(a&&f)&&r.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[r.jsx("div",{className:"min-h-0 flex-1 rounded-lg border bg-transparent",style:{borderColor:l.editMode?"#3b82f640":"#27272a"},children:r.jsxs(Hi,{nodes:M,edges:j,onNodesChange:H,onEdgesChange:S,nodeTypes:Sm,edgeTypes:Em,onNodeClick:_,onEdgeClick:L,onPaneClick:R,fitView:!0,fitViewOptions:{padding:.08},minZoom:.3,maxZoom:2,proOptions:{hideAttribution:!0},children:[r.jsx(Bi,{variant:me.Dots,gap:20,size:1,color:"#27272a"}),r.jsx(_x,{className:"!border-zinc-800 !bg-zinc-900 [&>button]:!border-zinc-800 [&>button]:!bg-zinc-900 [&>button]:!fill-zinc-400 [&>button:hover]:!bg-zinc-800"})]})}),l.editMode&&I.type==="node"&&D&&r.jsx(L0,{list:D,config:l.editConfig,onSave:F=>{l.updateList(D,F),E({type:"none"})},onDelete:()=>{l.deleteList(D.id),E({type:"none"})},onClose:()=>E({type:"none"})},D.id),l.editMode&&I.type==="edge"&&V&&r.jsx(hm,{edge:V,config:l.editConfig,onSave:F=>{l.updateEdge(V,F),E({type:"none"})},onDelete:()=>{l.deleteEdge(V.from,V.to),E({type:"none"})},onClose:()=>E({type:"none"})},`${V.from}:${V.to}`),l.editMode&&l.showConfigSettings&&I.type==="none"&&r.jsx(Cm,{config:l.editConfig,onUpdate:l.updateConfig,onClose:()=>l.setShowConfigSettings(!1)}),!l.editMode&&I.type==="node"&&r.jsx(r0,{list:D,hooks:W,connectedEdges:G,onClose:()=>E({type:"none"}),onHookClick:C}),!l.editMode&&I.type==="edge"&&r.jsx(f0,{edge:V,hooks:K,onClose:()=>E({type:"none"}),onHookClick:C})]}),b==="hooks"&&!l.editMode&&r.jsxs("div",{className:"flex min-h-0 flex-1 gap-3",children:[r.jsx(z0,{hooks:x,edges:u,onHookClick:w}),g&&r.jsx(P0,{hook:g,edges:u,onClose:()=>w(null),onViewSource:m,onNavigateToEdge:z})]}),r.jsx(gm,{open:l.showAddList,onOpenChange:l.setShowAddList,config:l.editConfig,onAdd:l.addList}),r.jsx(vm,{open:l.showAddEdge,onOpenChange:l.setShowAddEdge,config:l.editConfig,onAdd:l.addEdge}),r.jsx(Nm,{open:l.showPreview,onOpenChange:l.setShowPreview,config:l.editConfig,plan:l.previewPlan,loading:l.previewLoading,error:l.previewError,onApply:l.applyMigration}),r.jsx(y0,{hook:y,open:y!==null,onClose:()=>m(null)})]})}function Wr({active:e,onClick:t,icon:n,label:s,count:o}){return r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",style:{backgroundColor:e?"#27272a":"transparent",color:e?"#e4e4e7":"#71717a"},children:[n,s,o!==void 0&&o>0&&r.jsxs(r.Fragment,{children:[" ",r.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[9px] font-semibold leading-none",style:{backgroundColor:e?"#f9731630":"#27272a",color:e?"#f97316":"#71717a"},children:o})]})]})}export{Vm as default};
|