From 64ab22865871f11037c1855c4d52518eb7fc39fc Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sun, 25 Oct 2026 16:01:06 +1100 Subject: [PATCH] feat(egress): record a test run's deliveries instead of sending them A test run used to suppress only forge and push writes, which named one destination among many. Deliveries now have one seam: TaskContext.Deliveries records each as "would ..." and performs none, and a recording egress session does the same for a Kit run's HTTP writes and central tool calls, answering them synthetically. Provider hosts stay live, since model traffic is how a test run reads. Native containers have no proxy (archie-core-n8d3). --- internal/app/agentworker/task_execution.go | 6 +- internal/app/archied/kit_launcher.go | 12 ++- internal/app/archied/model_egress.go | 4 + internal/daemon/kit_task.go | 25 ++++++ internal/domain/workflow/task/task.go | 6 +- internal/domain/workflow/test_run.go | 74 ++++++++++------- internal/domain/workflow/test_run_test.go | 12 +-- internal/domain/workflow/workflow.go | 3 + internal/events/events.go | 11 +-- internal/forgerpc/forgerpc.go | 2 +- internal/infrastructure/egress/proxy.go | 73 ++++++++++++++++- .../egress/proxy_record_test.go | 80 +++++++++++++++++++ internal/infrastructure/kitrun/launcher.go | 5 +- internal/worktreerpc/worktreerpc.go | 2 +- ui/dist/assets/index.js | 4 +- ui/src/tasks/TaskTable.vue | 2 +- ui/src/workflows/RunWorkflowButton.vue | 2 +- ui/src/workflows/StepRun.vue | 8 +- 18 files changed, 273 insertions(+), 58 deletions(-) create mode 100644 internal/infrastructure/egress/proxy_record_test.go diff --git a/internal/app/agentworker/task_execution.go b/internal/app/agentworker/task_execution.go index c6cdb0038..390d49890 100644 --- a/internal/app/agentworker/task_execution.go +++ b/internal/app/agentworker/task_execution.go @@ -278,11 +278,11 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen } // configureTaskContext applies what the task's kind changes about its context: -// a test run writes nothing to a forge, and pr-review reads the PR data the -// daemon prefetched into workDir. +// a test run records every outward delivery and performs none, and pr-review +// reads the PR data the daemon prefetched into workDir. func configureTaskContext(tc *workflow.TaskContext, workDir string) { if tc.Task.IsTestRun() { - workflow.SuppressForgeWrites(tc) + workflow.RecordDeliveries(tc) } if tc.Task.Workflow == "pr-review" { tc.PRSource = prsource.NewFromMount(filepath.Join(workDir, prsource.PrefetchDirName)) diff --git a/internal/app/archied/kit_launcher.go b/internal/app/archied/kit_launcher.go index 7767198a0..7d9feac28 100644 --- a/internal/app/archied/kit_launcher.go +++ b/internal/app/archied/kit_launcher.go @@ -16,6 +16,7 @@ import ( "github.com/samcharles93/archie-core/internal/app/servicekit" "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/domain/presence" + "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/infrastructure/egress" "github.com/samcharles93/archie-core/internal/infrastructure/kitrun" "github.com/samcharles93/archie-core/internal/infrastructure/tasktools" @@ -70,7 +71,16 @@ func (b *boot) setupKitLauncher(ctx context.Context) { return } b.addCleanup(cleanup) - proxy := egress.NewProxy(ca, egress.ProxyOptions{Resolver: resolver, OAuthStore: oauthStore, TaskTools: gateway}) + proxy := egress.NewProxy(ca, egress.ProxyOptions{ + Resolver: resolver, OAuthStore: oauthStore, TaskTools: gateway, + // A test run's recorded deliveries land on the task's timeline through + // the same bus every other event uses. + Events: func(event events.Event) { + if b.bus != nil { + b.bus.Publish(event) + } + }, + }) srv := &http.Server{Handler: proxy, ReadHeaderTimeout: 30 * time.Second} go func() { if err := srv.Serve(ln); err != nil && !errors.Is(err, http.ErrServerClosed) { diff --git a/internal/app/archied/model_egress.go b/internal/app/archied/model_egress.go index 00b671ba3..95612307a 100644 --- a/internal/app/archied/model_egress.go +++ b/internal/app/archied/model_egress.go @@ -67,6 +67,10 @@ func (m modelEgress) Open(token, org string, providers map[string]config.Provide hosts = append(hosts, host) env = append(env, keyed[name]+"="+egress.SentinelFor(name)) } + // A model session never records, whatever its task is: this is the one + // session that must carry provider traffic for real, and it carries nothing + // else because its network policy allows only provider hosts. A test run's + // recordings happen on the Kit session that carries the rest of the run. session, err := m.proxy.Register(egress.SessionOptions{ Token: token, Org: org, Substitutions: subs, Secrets: secrets, Network: &spec.PhasedNetwork{Runtime: &spec.NetworkRules{Allow: hosts}}, diff --git a/internal/daemon/kit_task.go b/internal/daemon/kit_task.go index 2b8a563d2..4016968e0 100644 --- a/internal/daemon/kit_task.go +++ b/internal/daemon/kit_task.go @@ -9,6 +9,7 @@ import ( "github.com/samcharles93/archie-core/internal/config" "github.com/samcharles93/archie-core/internal/domain/workflow" workflowtask "github.com/samcharles93/archie-core/internal/domain/workflow/task" + "github.com/samcharles93/archie-core/internal/infrastructure/egress" "github.com/samcharles93/archie-core/internal/infrastructure/kit" "github.com/samcharles93/archie-core/internal/infrastructure/kitrun" "github.com/samcharles93/archie-core/internal/storage" @@ -68,6 +69,10 @@ func (d *Daemon) runKitTask(ctx context.Context, task *workflow.Task, repo confi // override (Forge, Budgets, ...). taskCfg := d.configFor(task) credentialOrg, grantedServices := taskCfg.CredentialAccess("") + var record *egress.RecordOptions + if task.IsTestRun() { + record = &egress.RecordOptions{TaskID: task.ID, ModelHosts: modelHosts(d.Cfg.Get().Providers)} + } run, err := d.KitLauncher.Launch(ctx, kitrun.Request{ TaskID: task.ID, Attempt: task.Attempt, @@ -79,6 +84,7 @@ func (d *Daemon) runKitTask(ctx context.Context, task *workflow.Task, repo confi Org: credentialOrg, GrantedServices: grantedServices, RunCredential: credential, + Record: record, }) if err != nil { park("kit launch failed", err) @@ -186,3 +192,22 @@ func (d *Daemon) openModelEgress(ctx context.Context, task *workflow.Task, crede } return session, func() { d.ModelEgress.Close(ctx, credential) }, nil } + +// modelHosts is every host a configured provider is reached at. A test run +// records its deliveries, but a model call is how the run reads, so these hosts +// are let through whatever their method: this errs broad on purpose, because a +// provider left out would silently swallow the run's model calls, and no +// provider host is a delivery destination. +func modelHosts(providers map[string]config.Provider) []string { + seen := make(map[string]bool, len(providers)) + hosts := make([]string, 0, len(providers)) + for _, p := range providers { + host, err := egress.ProviderHost(p.Class, p.BaseURL) + if err != nil || seen[host] { + continue + } + seen[host] = true + hosts = append(hosts, host) + } + return hosts +} diff --git a/internal/domain/workflow/task/task.go b/internal/domain/workflow/task/task.go index da2bc7184..0a1c8b3c4 100644 --- a/internal/domain/workflow/task/task.go +++ b/internal/domain/workflow/task/task.go @@ -153,7 +153,7 @@ type Task struct { // SourceForge, SourceChat and SourceTest are the valid values for Task.Source. // A test run is a chat-shaped task that runs an unsaved draft definition and -// writes nothing to a forge. +// records every outward delivery instead of performing it. // Legacy rows and forge-polled tasks have Source == SourceForge (the // zero value defaults there via the SQLite column default). const ( @@ -169,8 +169,8 @@ func (t Task) IsForgeBacked() bool { return t.Source != SourceChat && t.Source != SourceTest } -// IsTestRun reports whether t runs an operator's draft with forge writes -// suppressed. +// IsTestRun reports whether t runs an operator's draft with every outward +// delivery recorded and none performed. func (t Task) IsTestRun() bool { return t.Source == SourceTest } diff --git a/internal/domain/workflow/test_run.go b/internal/domain/workflow/test_run.go index 7c796630b..06e22c993 100644 --- a/internal/domain/workflow/test_run.go +++ b/internal/domain/workflow/test_run.go @@ -7,60 +7,80 @@ import ( "github.com/samcharles93/archie-core/internal/events" ) -// SuppressForgeWrites makes tc skip every forge and push write, recording -// each as a forge_suppressed event on the step that attempted it. A test run -// uses it so an operator's draft cannot touch a repository. -func SuppressForgeWrites(tc *TaskContext) { - tc.Forge = suppressedForge{Forger: tc.Forge, tc: tc} - tc.Trees = suppressedTrees{Trees: tc.Trees, tc: tc} +// Deliveries is the one door a run's outward effects pass through: a forge +// write, a push, an HTTP post. There is one implementation, recordDeliveries, +// because a live run needs none -- a nil TaskContext.Deliveries performs. +type Deliveries interface { + // Record records one effect the run must not perform: what it would have + // done, phrased without the leading "would". The caller returns success as + // though it had been delivered, so the rest of the step runs as it would + // have. + Record(ctx context.Context, detail string) } -// suppress records one skipped write. -func (tc *TaskContext) suppress(action string) { - tc.Emit(events.KindForgeSuppressed, tc.Stage, action, nil) +// RecordDeliveries makes tc record every outward delivery its steps ask for +// and perform none of them, so an operator can run a draft workflow and see +// what it would do without it reaching anyone. The forge and push writes are +// wrapped here; a Kit run's network traffic and central tool calls are +// recorded by the egress proxy (egress.RecordOptions), which is also why a +// recording command.run still executes: only its network egress is recorded. A +// native container's own network has no proxy in front of it, so nothing it +// sends is recorded. +func RecordDeliveries(tc *TaskContext) { + tc.Deliveries = recordDeliveries{tc: tc} + tc.Forge = recordedForge{Forger: tc.Forge, deliveries: tc.Deliveries} + tc.Trees = recordedTrees{Trees: tc.Trees, deliveries: tc.Deliveries} } -type suppressedForge struct { +type recordDeliveries struct { + tc *TaskContext +} + +func (r recordDeliveries) Record(_ context.Context, detail string) { + r.tc.Emit(events.KindDeliveryRecorded, r.tc.Stage, "would "+detail, nil) +} + +type recordedForge struct { Forger - tc *TaskContext + deliveries Deliveries } -func (f suppressedForge) CloseIssue(_ context.Context, owner, repo string, number int, _ string) error { - f.tc.suppress(fmt.Sprintf("Would close issue %s/%s#%d", owner, repo, number)) +func (f recordedForge) CloseIssue(ctx context.Context, owner, repo string, number int, _ string) error { + f.deliveries.Record(ctx, fmt.Sprintf("close issue %s/%s#%d", owner, repo, number)) return nil } -func (f suppressedForge) CreatePR(_ context.Context, owner, repo, title, head, base, _ string) (int, error) { - f.tc.suppress(fmt.Sprintf("Would open PR %q in %s/%s from %s into %s", title, owner, repo, head, base)) +func (f recordedForge) CreatePR(ctx context.Context, owner, repo, title, head, base, _ string) (int, error) { + f.deliveries.Record(ctx, fmt.Sprintf("open PR %q in %s/%s from %s into %s", title, owner, repo, head, base)) return 0, nil } -func (f suppressedForge) LinkBranch(_ context.Context, owner, repo string, number int, branch string) error { - f.tc.suppress(fmt.Sprintf("Would link %s to %s/%s#%d", branch, owner, repo, number)) +func (f recordedForge) LinkBranch(ctx context.Context, owner, repo string, number int, branch string) error { + f.deliveries.Record(ctx, fmt.Sprintf("link %s to %s/%s#%d", branch, owner, repo, number)) return nil } -func (f suppressedForge) CreateReviewComments(_ context.Context, owner, repo string, number int, _ string, review Review) error { - f.tc.suppress(fmt.Sprintf("Would post a %s review with %d comments on %s/%s#%d", review.Event, len(review.Comments), owner, repo, number)) +func (f recordedForge) CreateReviewComments(ctx context.Context, owner, repo string, number int, _ string, review Review) error { + f.deliveries.Record(ctx, fmt.Sprintf("post a %s review with %d comments on %s/%s#%d", review.Event, len(review.Comments), owner, repo, number)) return nil } -func (f suppressedForge) Comment(_ context.Context, owner, repo string, number int, body string) (int64, error) { - f.tc.suppress(fmt.Sprintf("Would comment on %s/%s#%d: %s", owner, repo, number, body)) +func (f recordedForge) Comment(ctx context.Context, owner, repo string, number int, body string) (int64, error) { + f.deliveries.Record(ctx, fmt.Sprintf("comment on %s/%s#%d: %s", owner, repo, number, body)) return 0, nil } -func (f suppressedForge) ReplyToReview(_ context.Context, owner, repo string, number int, _ int64, body string) error { - f.tc.suppress(fmt.Sprintf("Would reply to a review on %s/%s#%d: %s", owner, repo, number, body)) +func (f recordedForge) ReplyToReview(ctx context.Context, owner, repo string, number int, _ int64, body string) error { + f.deliveries.Record(ctx, fmt.Sprintf("reply to a review on %s/%s#%d: %s", owner, repo, number, body)) return nil } -type suppressedTrees struct { +type recordedTrees struct { Trees - tc *TaskContext + deliveries Deliveries } -func (t suppressedTrees) Push(_ context.Context, _, branch string) error { - t.tc.suppress(fmt.Sprintf("Would push branch %s", branch)) +func (t recordedTrees) Push(ctx context.Context, _, branch string) error { + t.deliveries.Record(ctx, fmt.Sprintf("push branch %s", branch)) return nil } diff --git a/internal/domain/workflow/test_run_test.go b/internal/domain/workflow/test_run_test.go index b0dbd20f8..419900e30 100644 --- a/internal/domain/workflow/test_run_test.go +++ b/internal/domain/workflow/test_run_test.go @@ -2,20 +2,22 @@ package workflow import ( "context" + "strings" "testing" "github.com/samcharles93/archie-core/internal/events" ) -// TestSuppressForgeWritesSkipsEveryWrite pins that a test run reaches neither +// TestRecordDeliveriesRecordsEveryWrite pins that a test run reaches neither // the forge nor a push: the embedded nil Forger and Trees panic if any call -// falls through, and each skipped write is recorded as an event. -func TestSuppressForgeWritesSkipsEveryWrite(t *testing.T) { +// falls through, and each one is recorded on the step that asked for it as +// "would ...". +func TestRecordDeliveriesRecordsEveryWrite(t *testing.T) { bus := events.NewBus() sub := bus.Subscribe(16) defer sub.Close() tc := &TaskContext{Task: &Task{Source: SourceTest, Owner: "o", Repo: "r"}, Bus: bus, Stage: "open-pr"} - SuppressForgeWrites(tc) + RecordDeliveries(tc) ctx := context.Background() writes := map[string]func() error{ @@ -33,7 +35,7 @@ func TestSuppressForgeWritesSkipsEveryWrite(t *testing.T) { } select { case event := <-sub.C: - if event.Kind != events.KindForgeSuppressed || event.Stage != "open-pr" || event.Detail == "" { + if event.Kind != events.KindDeliveryRecorded || event.Stage != "open-pr" || !strings.HasPrefix(event.Detail, "would ") { t.Fatalf("%s recorded %+v", name, event) } default: diff --git a/internal/domain/workflow/workflow.go b/internal/domain/workflow/workflow.go index c1b369298..68f716abc 100644 --- a/internal/domain/workflow/workflow.go +++ b/internal/domain/workflow/workflow.go @@ -102,6 +102,9 @@ type TaskContext struct { Store Store Trees Trees Agent agentrun.Runner + // Deliveries records the run's outward effects instead of performing them. + // Nil performs them; a test run's RecordDeliveries sets it. + Deliveries Deliveries // Calls starts workflow.call callees and reads them back while a // wait:true caller waits. Nil is only safe for a workflow with no // workflow.call step: such a step in a runner with no capability diff --git a/internal/events/events.go b/internal/events/events.go index 94d91ff2d..41618aefa 100644 --- a/internal/events/events.go +++ b/internal/events/events.go @@ -23,11 +23,12 @@ const ( // run. Only emitted for runners that execute in the same process as their // tools; see agentexec.ToolCallReporter. KindToolCall = "tool_call" // data: tool, failed - // KindForgeSuppressed records a forge or push write a test run skipped. - // detail: what it would have done. - KindForgeSuppressed = "forge_suppressed" - KindParked = "parked" // data: reason - KindOutcome = "outcome" // data: status, detail + // KindDeliveryRecorded records one outward delivery a test run did not + // perform: a forge write, a push, an HTTP request, a central tool call. + // detail: what it would have done, phrased "would ...". + KindDeliveryRecorded = "delivery_recorded" + KindParked = "parked" // data: reason + KindOutcome = "outcome" // data: status, detail // KindChatOutcome records a finished task's outcome posted to the chat // that started it. KindChatOutcome = "chat_outcome" diff --git a/internal/forgerpc/forgerpc.go b/internal/forgerpc/forgerpc.go index a8ee8d720..64442a5f2 100644 --- a/internal/forgerpc/forgerpc.go +++ b/internal/forgerpc/forgerpc.go @@ -194,7 +194,7 @@ func (s *Server) authorize(identity string, target Target, permission string) er return errors.New("forge request is outside its run's repository") } if task.IsTestRun() { - return errors.New("forge writes are suppressed in a test run") + return errors.New("a test run records deliveries instead of performing them") } name := workflow.PackageOf(task.WorkflowDefinitionYAML) if name == "" { diff --git a/internal/infrastructure/egress/proxy.go b/internal/infrastructure/egress/proxy.go index 48d5c9c85..189c4b7f6 100644 --- a/internal/infrastructure/egress/proxy.go +++ b/internal/infrastructure/egress/proxy.go @@ -7,6 +7,7 @@ import ( "crypto/x509" "encoding/base64" "encoding/hex" + "encoding/json" "errors" "fmt" "net" @@ -20,8 +21,10 @@ import ( "time" "github.com/docker/sandbox-kit-spec/v3/spec" + "github.com/modelcontextprotocol/go-sdk/mcp" "github.com/samcharles93/archie-core/internal/domain/access" + "github.com/samcharles93/archie-core/internal/events" "github.com/samcharles93/archie-core/internal/infrastructure/tasktools" ) @@ -52,6 +55,7 @@ type Session struct { substitutions []substitution secrets map[string]string oauth []oauthRule + record *RecordOptions atRun atomic.Bool } @@ -89,6 +93,20 @@ type ProxyOptions struct { // one, Register refuses a session with a required OAuth credential. OAuthStore OAuthStore TaskTools tasktools.Backend + // Events publishes a recorded delivery on the daemon's event stream, so it + // lands on the task's timeline like every other event. Nil records nowhere. + Events func(events.Event) +} + +// RecordOptions make a session a test run's: what its container attempts is +// recorded on TaskID's timeline as "would ..." and answered with a synthetic +// success instead of being forwarded. +type RecordOptions struct { + TaskID int64 + // ModelHosts are the hosts the run's model calls go to. They are never + // recorded or swallowed whatever their method: a provider request is how + // the run reads, and a recorded one leaves an operator nothing to look at. + ModelHosts []string } // SessionOptions describe one container's run: the run credential it acts @@ -114,6 +132,9 @@ type SessionOptions struct { // substitution prefers them over the Resolver, so a run-supplied key needs // no credential binding. Secrets map[string]string + // Record makes this a test run's session. Nil forwards everything, which is + // what a live run and a setup session get. + Record *RecordOptions } // Proxy is the egress proxy sandbox containers reach through their relay. @@ -127,6 +148,7 @@ type Proxy struct { resolver Resolver oauth OAuthStore taskTools tasktools.Backend + events func(events.Event) mu sync.RWMutex sessions map[string]*Session @@ -135,7 +157,7 @@ type Proxy struct { type sessionKey struct{} func NewProxy(ca *CA, opts ProxyOptions) *Proxy { - p := &Proxy{ca: ca, dial: opts.Dial, resolver: opts.Resolver, oauth: opts.OAuthStore, taskTools: opts.TaskTools, sessions: map[string]*Session{}} + p := &Proxy{ca: ca, dial: opts.Dial, resolver: opts.Resolver, oauth: opts.OAuthStore, taskTools: opts.TaskTools, events: opts.Events, sessions: map[string]*Session{}} p.transport = &http.Transport{ DialContext: p.dialUpstream, TLSClientConfig: &tls.Config{RootCAs: opts.UpstreamRoots, MinVersion: tls.VersionTLS12}, @@ -154,7 +176,7 @@ func (p *Proxy) Register(opts SessionOptions) (*Session, error) { s := &Session{ token: opts.Token, org: opts.Org, runCredential: opts.RunCredential, principal: opts.Principal, injections: compileInjections(opts.Credentials, opts.Bound), oauth: compileOAuthRules(opts.Credentials, opts.Bound), - substitutions: compileSubstitutions(opts.Substitutions), secrets: opts.Secrets, + substitutions: compileSubstitutions(opts.Substitutions), secrets: opts.Secrets, record: opts.Record, } if opts.RunCredential != "" && p.taskTools != nil { var token [32]byte @@ -302,6 +324,13 @@ func (p *Proxy) serveConnect(w http.ResponseWriter, r *http.Request, s *Session) func (p *Proxy) forward(ctx context.Context, w http.ResponseWriter, r *http.Request, s *Session, scheme, host string, port int) { target := net.JoinHostPort(host, strconv.Itoa(port)) + if s.records(r.Method, host) { + // Recorded, never forwarded: an empty 2xx is all the client needs to + // carry on, and it must not learn which destinations are real. + p.recordDelivery(s, r.Method+" "+host+r.URL.Path) + w.WriteHeader(http.StatusOK) + return + } if rule, ok := tokenEndpointRule(s, r, host, port); ok { if !slices.Contains(rule.phases, s.phase()) { http.Error(w, "credential "+rule.service+" is not available in this phase", http.StatusForbidden) @@ -354,6 +383,26 @@ func (p *Proxy) forward(ctx context.Context, w http.ResponseWriter, r *http.Requ rp.ServeHTTP(w, r) } +// records reports whether this request is a delivery a recording session must +// record instead of perform: a write, to a host the run's model traffic does +// not go to. Reads are never deliveries. +func (s *Session) records(method, host string) bool { + switch method { + case http.MethodGet, http.MethodHead, http.MethodOptions: + return false + } + return s.record != nil && !slices.Contains(s.record.ModelHosts, host) +} + +// recordDelivery reports one delivery a recording session never made, as +// "would ..." on the task's timeline. +func (p *Proxy) recordDelivery(s *Session, detail string) { + if p.events == nil || s.record == nil { + return + } + p.events(events.Event{Kind: events.KindDeliveryRecorded, TaskID: s.record.TaskID, Detail: "would " + detail}) +} + // dialUpstream resolves and dials an upstream, refusing addresses that // would turn the proxy into a path back into the host or its networks. func (p *Proxy) dialUpstream(ctx context.Context, network, addr string) (net.Conn, error) { @@ -484,7 +533,25 @@ func (p *Proxy) serveTaskTools(parent context.Context, w http.ResponseWriter, r defer cancel() stop := context.AfterFunc(s.lifetime, cancel) //nolint:contextcheck // Session revocation is an additional cancellation source. defer stop() - tasktools.ServeHTTP(ctx, w, r, p.taskTools, s.runCredential, s.gatewayToken) + backend := p.taskTools + if s.record != nil { + // A central tool call is a delivery too. Discovery still runs: an agent + // that cannot list its tools cannot use any. + backend = recordedTools{Backend: backend, proxy: p, session: s} + } + tasktools.ServeHTTP(ctx, w, r, backend, s.runCredential, s.gatewayToken) +} + +// recordedTools records each central tool call instead of making it. +type recordedTools struct { + tasktools.Backend + proxy *Proxy + session *Session +} + +func (t recordedTools) Call(_ context.Context, _, tool string, _ json.RawMessage) (*mcp.CallToolResult, error) { + t.proxy.recordDelivery(t.session, "call "+tool) + return &mcp.CallToolResult{Content: []mcp.Content{&mcp.TextContent{Text: "would call " + tool}}}, nil } // credential is the host-held task grant, or a setup session's own grant. diff --git a/internal/infrastructure/egress/proxy_record_test.go b/internal/infrastructure/egress/proxy_record_test.go new file mode 100644 index 000000000..e89ca4c55 --- /dev/null +++ b/internal/infrastructure/egress/proxy_record_test.go @@ -0,0 +1,80 @@ +package egress + +import ( + "context" + "net" + "net/http" + "net/http/httptest" + "sync/atomic" + "testing" + + "github.com/samcharles93/archie-core/internal/events" +) + +// A recording session forwards none of the run's deliveries: each is answered +// with a synthetic success and reported on the task, so an operator sees what +// the draft would have sent. Reads still pass, and so do model calls whatever +// their method -- a recorded one would leave the run nothing to read. +func TestRecordedSessionRecordsDeliveries(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + method string + host string + modelHosts []string + wantDetail string // empty means the request must be forwarded + }{ + {name: "a write is recorded and not forwarded", method: http.MethodPost, host: "hooks.example", wantDetail: "would POST hooks.example/hook"}, + {name: "a read is forwarded", method: http.MethodGet, host: "hooks.example"}, + {name: "a write to a model host is forwarded", method: http.MethodPost, host: "api.model.example", modelHosts: []string{"api.model.example"}}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + var forwarded atomic.Bool + upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + forwarded.Store(true) + w.WriteHeader(http.StatusNoContent) + })) + defer upstream.Close() + + var recorded []events.Event + proxy := NewProxy(nil, ProxyOptions{ + Dial: func(ctx context.Context, _, _ string) (net.Conn, error) { + return (&net.Dialer{}).DialContext(ctx, "tcp", upstream.Listener.Addr().String()) + }, + Events: func(event events.Event) { recorded = append(recorded, event) }, + }) + session, err := proxy.Register(SessionOptions{Token: "proxy-password", Record: &RecordOptions{TaskID: 7, ModelHosts: tc.modelHosts}}) + if err != nil { + t.Fatalf("register session: %v", err) + } + + req := httptest.NewRequestWithContext(context.Background(), tc.method, "http://"+tc.host+"/hook", nil) + rec := httptest.NewRecorder() + proxy.forward(context.Background(), rec, req, session, "http", tc.host, 80) + + if tc.wantDetail == "" { + if !forwarded.Load() { + t.Fatalf("%s was not forwarded: %d %q", tc.method, rec.Code, rec.Body.String()) + } + if len(recorded) != 0 { + t.Fatalf("a forwarded request was recorded: %+v", recorded) + } + return + } + if forwarded.Load() { + t.Fatalf("%s reached the upstream", tc.method) + } + if rec.Code != http.StatusOK || rec.Body.Len() != 0 { + t.Fatalf("recorded request answered %d %q, want an empty 200", rec.Code, rec.Body.String()) + } + if len(recorded) != 1 || recorded[0].Kind != events.KindDeliveryRecorded || + recorded[0].TaskID != 7 || recorded[0].Detail != tc.wantDetail { + t.Fatalf("recorded %+v, want one %q on task 7", recorded, tc.wantDetail) + } + }) + } +} diff --git a/internal/infrastructure/kitrun/launcher.go b/internal/infrastructure/kitrun/launcher.go index c91ad1dfc..9360061fe 100644 --- a/internal/infrastructure/kitrun/launcher.go +++ b/internal/infrastructure/kitrun/launcher.go @@ -111,6 +111,9 @@ type Request struct { // RunCredential is the worker grant, retained only on the host and in the // worker environment. The harness gets a separate proxy password. RunCredential string + // Record is set for a test run: every delivery its container attempts is + // recorded on the task's timeline and performed none of. + Record *egress.RecordOptions } // Run is a started Kit task. @@ -520,5 +523,5 @@ func (l *Launcher) taskSession(req Request, k kitNeeds, kinds map[string]egress. if err != nil { return nil, err } - return l.Proxy.Register(egress.SessionOptions{RunCredential: req.RunCredential, Token: token, Org: req.Org, Network: k.network, Credentials: k.creds, Bound: kinds}) + return l.Proxy.Register(egress.SessionOptions{RunCredential: req.RunCredential, Token: token, Org: req.Org, Network: k.network, Credentials: k.creds, Bound: kinds, Record: req.Record}) } diff --git a/internal/worktreerpc/worktreerpc.go b/internal/worktreerpc/worktreerpc.go index 442ef69be..ed30dd246 100644 --- a/internal/worktreerpc/worktreerpc.go +++ b/internal/worktreerpc/worktreerpc.go @@ -62,7 +62,7 @@ func publishable(ctx context.Context, runs Runs, token, identity string) (*workf return nil, errors.New("worktree publication grant is invalid") } if task.IsTestRun() { - return nil, errors.New("pushes are suppressed in a test run") + return nil, errors.New("a test run records deliveries instead of performing them") } return task, nil } diff --git a/ui/dist/assets/index.js b/ui/dist/assets/index.js index ef7406cfa..e057f6969 100644 --- a/ui/dist/assets/index.js +++ b/ui/dist/assets/index.js @@ -184,7 +184,7 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),SG&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=GG(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=oG(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-KG),KG),t/=KG,t/Math.abs(t)+Math.round(t*(qG-1)))}shouldForceSelection(e){return vG?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),JG)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(vG&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=GG(n,this._bufferService.cols)}};ZG=xB([SB(3,YB),SB(4,ZB),SB(5,lV),SB(6,tV),SB(7,uV),SB(8,cV)],ZG);var QG=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},$G=class{constructor(){this._color=new QG,this._css=new QG}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},eK=Object.freeze((()=>{let e=[OW.toColor(`#2e3436`),OW.toColor(`#cc0000`),OW.toColor(`#4e9a06`),OW.toColor(`#c4a000`),OW.toColor(`#3465a4`),OW.toColor(`#75507b`),OW.toColor(`#06989a`),OW.toColor(`#d3d7cf`),OW.toColor(`#555753`),OW.toColor(`#ef2929`),OW.toColor(`#8ae234`),OW.toColor(`#fce94f`),OW.toColor(`#729fcf`),OW.toColor(`#ad7fa8`),OW.toColor(`#34e2e2`),OW.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:EW.toCss(r,i,a),rgba:EW.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:EW.toCss(n,n,n),rgba:EW.toRgba(n,n,n)})}return e})()),tK=OW.toColor(`#ffffff`),nK=OW.toColor(`#000000`),rK=OW.toColor(`#ffffff`),iK=nK,aK={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},oK=tK,sK=class extends RV{constructor(e){super(),this._optionsService=e,this._contrastCache=new $G,this._halfContrastCache=new $G,this._onChangeColors=this._register(new iH),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:tK,background:nK,cursor:rK,cursorAccent:iK,selectionForeground:void 0,selectionBackgroundTransparent:aK,selectionBackgroundOpaque:DW.blend(nK,aK),selectionInactiveBackgroundTransparent:aK,selectionInactiveBackgroundOpaque:DW.blend(nK,aK),scrollbarSliderBackground:DW.opacity(tK,.2),scrollbarSliderHoverBackground:DW.opacity(tK,.4),scrollbarSliderActiveBackground:DW.opacity(tK,.5),overviewRulerBorder:tK,ansi:eK.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=cK(e.foreground,tK),t.background=cK(e.background,nK),t.cursor=DW.blend(t.background,cK(e.cursor,rK)),t.cursorAccent=DW.blend(t.background,cK(e.cursorAccent,iK)),t.selectionBackgroundTransparent=cK(e.selectionBackground,aK),t.selectionBackgroundOpaque=DW.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=cK(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=DW.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?cK(e.selectionForeground,TW):void 0,t.selectionForeground===TW&&(t.selectionForeground=void 0),DW.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=DW.opacity(t.selectionBackgroundTransparent,.3)),DW.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=DW.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=cK(e.scrollbarSliderBackground,DW.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=cK(e.scrollbarSliderHoverBackground,DW.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=cK(e.scrollbarSliderActiveBackground,DW.opacity(t.foreground,.5)),t.overviewRulerBorder=cK(e.overviewRulerBorder,oK),t.ansi=eK.slice(),t.ansi[0]=cK(e.black,eK[0]),t.ansi[1]=cK(e.red,eK[1]),t.ansi[2]=cK(e.green,eK[2]),t.ansi[3]=cK(e.yellow,eK[3]),t.ansi[4]=cK(e.blue,eK[4]),t.ansi[5]=cK(e.magenta,eK[5]),t.ansi[6]=cK(e.cyan,eK[6]),t.ansi[7]=cK(e.white,eK[7]),t.ansi[8]=cK(e.brightBlack,eK[8]),t.ansi[9]=cK(e.brightRed,eK[9]),t.ansi[10]=cK(e.brightGreen,eK[10]),t.ansi[11]=cK(e.brightYellow,eK[11]),t.ansi[12]=cK(e.brightBlue,eK[12]),t.ansi[13]=cK(e.brightMagenta,eK[13]),t.ansi[14]=cK(e.brightCyan,eK[14]),t.ansi[15]=cK(e.brightWhite,eK[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;re.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},dK={trace:0,debug:1,info:2,warn:3,error:4,off:5},fK=`xterm.js: `,pK=class extends RV{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),mK=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=dK[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;tthis._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*gK+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*gK+0]=e|2097152|t[2]<<22):this._data[e*gK+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*gK+0]>>22}hasWidth(e){return this._data[e*gK+0]&12582912}getFg(e){return this._data[e*gK+1]}getBg(e){return this._data[e*gK+2]}hasContent(e){return this._data[e*gK+0]&4194303}getCodePoint(e){let t=this._data[e*gK+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*gK+0]&2097152}getString(e){let t=this._data[e*gK+0];return t&2097152?this._combined[e]:t&2097151?PB(t&2097151):``}isProtected(e){return this._data[e*gK+2]&536870912}loadCell(e,t){return vK=e*gK,t.content=this._data[vK+0],t.fg=this._data[vK+1],t.bg=this._data[vK+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*gK+0]=t.content,this._data[e*gK+1]=t.fg,this._data[e*gK+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*gK+0]=t|n<<22,this._data[e*gK+1]=r.fg,this._data[e*gK+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*gK+0];r&2097152?this._combined[e]+=PB(t):r&2097151?(this._combined[e]=PB(r&2097151)+PB(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*gK+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;rthis.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*yK=0;--e)if(this._data[e*gK+0]&4194303)return e+(this._data[e*gK+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*gK+0]&4194303||this._data[e*gK+2]&50331648)return e+(this._data[e*gK+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t>22||1}return r&&r.push(t),i}};function xK(e,t,n,r,i,a){let o=[];for(let s=0;s=s&&r0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function SK(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;oTK(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;sc&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function TK(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var EK=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new iH),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),NV(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};EK._nextId=1;var DK=EK,OK={},kK=OK.B;OK[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},OK.A={"#":`£`},OK.B=void 0,OK[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},OK.C=OK[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},OK.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},OK.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},OK.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},OK.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},OK.E=OK[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},OK.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},OK.H=OK[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},OK[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var AK=4294967295,jK=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=_K.clone(),this.savedCharset=kK,this.markers=[],this._nullCell=HB.fromCharData([0,RB,1,0]),this._whitespaceCell=HB.fromCharData([0,zB,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new DG,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new hK(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new VB),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new VB),this._whitespaceCell}getBlankLine(e,t){return new bK(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&eAK?AK:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=_K);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new hK(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(_K),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new bK(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=xK(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(_K),n);if(r.length>0){let n=SK(this.lines,r);CK(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(_K),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=TK(c,Math.max(g,0),this._cols))}for(let t=0;t0;)this.ybase===0?this.y0){let e=[],t=[];for(let e=0;e=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.linee.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},MK=class extends RV{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new iH),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new jK(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new jK(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},NK=2,PK=1,FK=class extends RV{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new iH),this.onResize=this._onResize.event,this._onScroll=this._register(new iH),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,NK),this.rows=Math.max(e.rawOptions.rows||0,PK),this.buffers=this._register(new MK(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,(!r||r.length!==this.cols||r.getFg(0)!==e.fg||r.getBg(0)!==e.bg)&&(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};FK=xB([SB(0,tV)],FK);var IK={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:vG,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},LK=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],RK=class extends RV{constructor(e){super(),this._onOptionChange=this._register(new iH),this.onOptionChange=this._onOptionChange.event;let t={...IK};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(FV(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in IK))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in IK))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=IK[e],!zK(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=IK[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=LK.includes(t)?t:IK[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function zK(e){return e===`block`||e===`underline`||e===`bar`}function BK(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&BK(e[r],t-1);return n}var VK=Object.freeze({insertMode:!1}),HK=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),UK=class extends RV{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new iH),this.onData=this._onData.event,this._onUserInput=this._register(new iH),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new iH),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new iH),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=BK(VK),this.decPrivateModes=BK(HK)}reset(){this.modes=BK(VK),this.decPrivateModes=BK(HK)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};UK=xB([SB(0,YB),SB(1,eV),SB(2,tV)],UK);var WK={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function GK(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var KK=String.fromCharCode,qK={DEFAULT:e=>{let t=[GK(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${KK(t[0])}${KK(t[1])}${KK(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${GK(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${GK(e,!0)};${e.x};${e.y}${t}`}},JK=class extends RV{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new iH),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(WK))this.addProtocol(e,WK[e]);for(let e of Object.keys(qK))this.addEncoding(e,qK[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};JK=xB([SB(0,YB),SB(1,ZB),SB(2,tV)],JK);var YK=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],XK=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],ZK;function QK(e,t){let n=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=eq.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return eq.createPropertyValue(0,n,r)}},eq=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new iH,this.onChange=this._onChange.event;let e=new $K;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},tq=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function nq(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var rq=2147483647,iq=256,aq=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>iq)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>rq?rq:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>rq?rq:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,rq):e}},oq=[],sq=class{constructor(){this._state=0,this._active=oq,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=oq}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=oq,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||oq,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,FB(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=oq,this._id=-1,this._state=0}}},cq=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=FB(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},lq=[],uq=class{constructor(){this._handlers=Object.create(null),this._active=lq,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=lq}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=lq,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||lq,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,FB(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=lq,this._ident=0}},dq=new aq;dq.addParam(0);var fq=class{constructor(e){this._handler=e,this._data=``,this._params=dq,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():dq,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=FB(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=dq,this._data=``,this._hitLimit=!1,e));return this._params=dq,this._data=``,this._hitLimit=!1,t}},pq=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;it),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(mq,0,2,0),e.add(mq,8,5,8),e.add(mq,6,0,6),e.add(mq,11,0,11),e.add(mq,13,13,13),e}(),gq=class extends RV{constructor(e=hq){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new aq,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(FV(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new sq),this._dcsParser=this._register(new uq),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;tr||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r=t||(r=e[i])<32||r>127&&r>4:i>>8}return n}}function bq(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function xq(e,t=16){let[n,r,i]=e;return`rgb:${bq(n,t)}/${bq(r,t)}/${bq(i,t)}`}var Sq={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Cq=131072,wq=10;function Tq(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Eq=5e3,Dq=0,Oq=class extends RV{constructor(e,t,n,r,i,a,o,s,c=new gq){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new IB,this._utf8Decoder=new LB,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_K.clone(),this._eraseAttrDataInternal=_K.clone(),this._onRequestBell=this._register(new iH),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new iH),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new iH),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new iH),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new iH),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new iH),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new iH),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new iH),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new iH),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new iH),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new iH),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new iH),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new iH),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new kq(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(vW.IND,()=>this.index()),this._parser.setExecuteHandler(vW.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(vW.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new cq(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new cq(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new cq(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new cq(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new cq(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new cq(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new cq(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new cq(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new cq(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new cq(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new cq(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new cq(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in OK)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new fq((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),Eq))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${Eq} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Cq&&(a=this._parseStack.position+Cq)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.lengthCq)for(let t=a;t0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;ps){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof bK&&d.copyCellsFrom(e,t,0,m,!1);t=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!Tq(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new fq(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new cq(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let c=s;for(let e=1;e0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=BB.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=_K.fg,e.bg=_K.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=_K.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=_K.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=_K.fg&16777215,r.bg&=-67108864,r.bg|=_K.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=_K.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Tq(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>wq&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>wq&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(Aq(n)){if(r===`?`)t.push({type:0,index:n});else{let e=yq(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=yq(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=_K.clone(),this._eraseAttrDataInternal=_K.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new HB;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},kq=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Dq=e,e=t,t=Dq),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};kq=xB([SB(0,YB)],kq);function Aq(e){return 0<=e&&e<256}var jq=5e7,Mq=12,Nq=50,Pq=class extends RV{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new iH),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>jq)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=Mq?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=Mq)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Nq&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Fq=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Fq=xB([SB(0,YB)],Fq);var Iq=!1,Lq=class extends RV{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new zV),this._onBinary=this._register(new iH),this.onBinary=this._onBinary.event,this._onData=this._register(new iH),this.onData=this._onData.event,this._onLineFeed=this._register(new iH),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new iH),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new iH),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new iH),this._instantiationService=new uK,this.optionsService=this._register(new RK(e)),this._instantiationService.setService(tV,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(FK)),this._instantiationService.setService(YB,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(pK)),this._instantiationService.setService(eV,this._logService),this.coreService=this._register(this._instantiationService.createInstance(UK)),this._instantiationService.setService(ZB,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(JK)),this._instantiationService.setService(XB,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(eq)),this._instantiationService.setService(rV,this.unicodeService),this._charsetService=this._instantiationService.createInstance(tq),this._instantiationService.setService(QB,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Fq),this._instantiationService.setService(nV,this._oscLinkService),this._inputHandler=this._register(new Oq(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(KV.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(KV.forward(this._bufferService.onResize,this._onResize)),this._register(KV.forward(this.coreService.onData,this._onData)),this._register(KV.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Pq((e,t)=>this._inputHandler.parse(e,t))),this._register(KV.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new iH),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Iq&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Iq=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,NK),t=Math.max(t,PK),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(nq.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(nq(this._bufferService),!1))),this._windowsWrappingHeuristics.value=FV(()=>{for(let t of e)t.dispose()})}}},Rq={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function zq(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=Rq[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var Bq=0,Vq=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new DG,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new DG,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(Bq=this._search(t),Bq===-1)||this._getKey(this._array[Bq])!==t)return!1;do if(this._array[Bq]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(Bq),!0;while(++Bqe-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(Bq=this._search(e),!(Bq<0||Bq>=this._array.length)&&this._getKey(this._array[Bq])===e))do yield this._array[Bq];while(++Bq=this._array.length)&&this._getKey(this._array[Bq])===e))do t(this._array[Bq]);while(++Bq=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Hq=0,Uq=0,Wq=class extends RV{constructor(){super(),this._decorations=new Vq(e=>e?.marker.line),this._onDecorationRegistered=this._register(new iH),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new iH),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(FV(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Gq(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e{Hq=t.options.x??0,Uq=Hq+(t.options.width??1),e>=Hq&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Jq=20,Yq=class extends RV{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;ethis._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new qq(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(xU(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(FV(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Jq+1&&(this._liveRegion.textContent+=EB.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;ee;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{NV(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(xU(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(xU(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(xU(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(xU(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;re?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;tthis._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;ethis._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Zq(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,NV(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};Xq=xB([SB(1,lV),SB(2,uV),SB(3,YB),SB(4,mV)],Xq);function Zq(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Qq=class extends Lq{constructor(e={}){super(e),this._linkifier=this._register(new zV),this.browser=uG,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new zV),this._onCursorMove=this._register(new iH),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new iH),this.onKey=this._onKey.event,this._onRender=this._register(new iH),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new iH),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new iH),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new iH),this.onBell=this._onBell.event,this._onFocus=this._register(new iH),this._onBlur=this._register(new iH),this._onA11yCharEmitter=this._register(new iH),this._onA11yTabEmitter=this._register(new iH),this._onWillOpen=this._register(new iH),this._setup(),this._decorationService=this._instantiationService.createInstance(Wq),this._instantiationService.setService(iV,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(aG),this._instantiationService.setService(mV,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(aV)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(KV.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(KV.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(KV.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(KV.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(FV(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=DW.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${xq(r)}${yW.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=EW.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=EW.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Yq,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(xU(this.element,`copy`,e=>{this.hasSelection()&&kB(e,this._selectionService)}));let e=e=>AB(e,this.textarea,this.coreService,this.optionsService);this._register(xU(this.textarea,`paste`,e)),this._register(xU(this.element,`paste`,e)),mG?this._register(xU(this.element,`mousedown`,e=>{e.button===2&&NB(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(xU(this.element,`contextmenu`,e=>{NB(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),SG&&this._register(xU(this.element,`auxclick`,e=>{e.button===1&&MB(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(xU(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(xU(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(xU(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(xU(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(xU(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(xU(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(xU(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(xU(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,wB.get()),CG||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(rG,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(cV,this._coreBrowserService),this._register(xU(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(xU(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance($W,this._document,this._helperContainer),this._instantiationService.setService(sV,this._charSizeService),this._themeService=this._instantiationService.createInstance(sK),this._instantiationService.setService(pV,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(PW),this._instantiationService.setService(fV,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(kG,this.rows,this.screenElement)),this._instantiationService.setService(uV,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(bW,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(cG),this._instantiationService.setService(lV,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Xq,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(dW,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ZG,this.element,this.screenElement,r)),this._instantiationService.setService(dV,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(KV.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(fW,this.screenElement)),this._register(xU(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Yq,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_W,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(_W,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(QW,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(xU(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(xU(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){jB(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key===`Dead`||e.key===`AltGraph`)&&(this._unprocessedDeadKey=!0);let n=zq(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&($q(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new HB)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},nJ=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new tJ(t)}getNullCell(){return new HB}},rJ=class extends RV{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new iH),this.onBufferChange=this._onBufferChange.event,this._normal=new nJ(this._core.buffers.normal,`normal`),this._alternate=new nJ(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},iJ=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},aJ=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},oJ=[`cols`,`rows`],sJ=0,cJ=class extends RV{constructor(e){super(),this._core=this._register(new Qq(e)),this._addonManager=this._register(new eJ),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(oJ.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new iJ(this._core),this._parser}get unicode(){return this._checkProposedApi(),new aJ(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new rJ(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r -`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return wB.get()},set promptLabel(e){wB.set(e)},get tooMuchOutput(){return EB.get()},set tooMuchOutput(e){EB.set(e)}}}_verifyIntegers(...e){for(sJ of e)if(sJ===1/0||isNaN(sJ)||sJ%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(sJ of e)if(sJ&&(sJ===1/0||isNaN(sJ)||sJ%1!=0||sJ<0))throw Error(`This API only accepts positive integers`)}},lJ=2,uJ=1,dJ=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(lJ,Math.floor(u/e.css.cell.width)),rows:Math.max(uJ,Math.floor(l/e.css.cell.height))}}},fJ={class:`flex h-[32rem] min-h-0 flex-col gap-2`},pJ={key:0,class:`text-sm text-fg-muted`,role:`status`},mJ=P({__name:`SandboxView`,props:{taskId:{},attempt:{}},setup(e){let t=e,n=J(null),r=J(`connecting`),i=null,a=null,o=null,s=null;function c(){try{o?.fit()}catch{}}return Be(()=>{let e=n.value;if(!e)return;i=new cJ({convertEol:!0,disableStdin:!0,cursorBlink:!1,fontFamily:`'IBM Plex Mono', ui-monospace, monospace`,fontSize:13,theme:{background:`#0b0f14`,foreground:`#e6edf3`}}),o=new dJ,i.loadAddon(o),i.open(e),c();let l=window.location.protocol===`https:`?`wss:`:`ws:`,u=new URLSearchParams({attempt:String(t.attempt)}),d=new WebSocket(`${l}//${window.location.host}/api/tasks/${encodeURIComponent(t.taskId)}/sandbox?${u}`);a=d,d.binaryType=`arraybuffer`,d.onopen=()=>{r.value=`open`},d.onmessage=e=>{i&&(typeof e.data==`string`&&(r.value=`failed`),i.write(typeof e.data==`string`?e.data:new Uint8Array(e.data)))},d.onerror=()=>{r.value=`failed`},d.onclose=()=>{r.value!==`failed`&&(r.value=`closed`)},s=new ResizeObserver(c),s.observe(e)}),nt(()=>{s?.disconnect(),s=null,a?.close(),a=null,i?.dispose(),i=null,o=null}),(e,t)=>(L(),j(`div`,fJ,[r.value===`open`?F(``,!0):(L(),j(`p`,pJ,[r.value===`connecting`?(L(),j(U,{key:0},[H(`Connecting…`)],64)):r.value===`closed`?(L(),j(U,{key:1},[H(`The sandbox ended.`)],64)):(L(),j(U,{key:2},[H(`Sandbox unavailable.`)],64))])),R(`div`,{ref_key:`host`,ref:n,class:`min-h-0 flex-1 overflow-hidden rounded-md border border-border bg-[#0b0f14] p-2`},null,512)]))}}),hJ={class:`flex flex-wrap items-center gap-3 border-b border-border pb-3`},gJ={class:`inline-flex items-center gap-2`},_J={class:`inline-flex items-center gap-2`},vJ=`__all__`,yJ=P({__name:`TaskLogFilters`,props:{filters:{},stages:{}},emits:[`filter`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>LM.map(e=>({value:e.value||vJ,label:e.label}))),a=Y(()=>n.filters.level||vJ),o=Y(()=>n.filters.stage||vJ);function s(e){r(`filter`,{...n.filters,...e})}function c(e){s({level:String(e)===vJ?``:String(e)})}function l(e){s({stage:String(e)===vJ?``:String(e)})}return(t,n)=>(L(),j(`div`,hJ,[R(`div`,gJ,[A(V(Vu),{"model-value":a.value,"onUpdate:modelValue":c},{default:I(()=>[A(V(Gu),{size:`sm`,"aria-label":`Filter log entries by level`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[A(V(Uu),null,{default:I(()=>[(L(!0),j(U,null,M(i.value,e=>(L(),q(V(Wu),{key:e.value,value:e.value},{default:I(()=>[H(B(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`model-value`])]),R(`div`,_J,[A(V(Vu),{"model-value":o.value,"onUpdate:modelValue":l},{default:I(()=>[A(V(Gu),{size:`sm`,"aria-label":`Filter log entries by stage`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[A(V(Uu),null,{default:I(()=>[A(V(Wu),{value:vJ},{default:I(()=>[...n[0]||=[H(`All stages`,-1)]]),_:1}),(L(!0),j(U,null,M(e.stages,e=>(L(),q(V(Wu),{key:e,value:e},{default:I(()=>[H(B(e),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`model-value`])])]))}}),bJ={class:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`},xJ={key:2,class:`flex flex-col items-start gap-2 py-3`},SJ={key:0,class:`mt-2 flex flex-wrap items-center gap-2 px-1`},CJ={key:0,class:`text-xs text-fg-muted`},wJ={key:1,class:`text-xs text-danger`},TJ={key:2,class:`text-xs text-fg-muted`},EJ={key:1,class:`px-1 pt-1 text-xs text-warn`},DJ=[`href`],OJ=500,kJ=P({__name:`TaskLogs`,props:{state:{},attempt:{},stages:{default:()=>[]},filters:{default:()=>({...MR})},filterable:{type:Boolean,default:!0},taskId:{default:null}},emits:[`filter`],setup(e){let t=e,n=Y(()=>Number(t.attempt)||Number(t.state?.attempt)||0),r=J(null),i=J([]),a=J(!1),o=J(!1),s=Y(()=>`${t.taskId}|${n.value}|${t.filters.level}|${t.filters.stage}`);N(s,()=>{r.value=null,i.value=[],o.value=!1});let c=Y(()=>r.value?.state??t.state),l=Y(()=>t.taskId!=null&&t.filterable),u=Y(()=>l.value&&!!c.value?.more_available&&(c.value?.cursor??0)>0),d=Y(()=>l.value&&i.value.length>0);async function f(e){if(t.taskId==null)return null;a.value=!0,o.value=!1;try{return await Z.taskLogs(String(t.taskId),{attempt:n.value||void 0,level:t.filters.level,stage:t.filters.stage,limit:OJ,before:e||void 0})}catch{return o.value=!0,null}finally{a.value=!1}}async function p(){let e=c.value,t=e?.cursor??0;if(!e?.more_available||t<=0)return;let n=await f(t);n&&(await v.replace({hash:``}),i.value.push({before:r.value?.before??0,state:e}),r.value={before:t,state:n})}function m(){let e=i.value.pop();e&&(o.value=!1,r.value=e)}let h=Y(()=>{let e=c.value;if(e===void 0)return{kind:`loading`,status:`Loading this attempt's log`};if(e===null)return{kind:`failed`,status:`This attempt's log could not be loaded`};if(e.found===!1&&!e.disabled)return{kind:`nolog`,status:`No log`};if(e.disabled)return{kind:`disabled`,status:`This dashboard cannot read task logs`};let t=e.entries||[];return t.length?{kind:`entries`,status:`${t.length} log entr${t.length===1?`y`:`ies`} shown`,entries:t}:{kind:`empty`,status:`This attempt's log has no entries matching the current filter`,entries:t}}),g=Y(()=>t.taskId==null?null:Z.taskLogDownloadURL(String(t.taskId),n.value||null)),_=Dn(),v=En(),y=J(),b=``;N([()=>_.hash,c],async()=>{let e=/^#log-line-(\d+)$/.exec(_.hash);if(!e){b=``;return}if(b===_.hash)return;r.value&&(r.value=null,i.value=[]),await We();let t=y.value?.querySelector(`[data-row-key="${e[1]}"]`);t&&(b=_.hash,t?.scrollIntoView({block:`center`}),t?.focus({preventScroll:!0}))},{immediate:!0,flush:`post`});let x=[`task`,`task_id`],S=e=>String(e.id??`${e.time}|${e.message??e.msg}`);return(t,n)=>(L(),j(`div`,null,[e.filterable?(L(),q(yJ,{key:0,class:`mb-3`,filters:e.filters,stages:e.stages,onFilter:n[0]||=e=>t.$emit(`filter`,e)},null,8,[`filters`,`stages`])):F(``,!0),R(`p`,bJ,B(h.value.status),1),h.value.kind===`loading`?(L(),q(Mz,{key:1,label:`Loading attempt log…`})):h.value.kind===`failed`?(L(),j(`div`,xJ,[...n[1]||=[R(`p`,{class:`text-sm text-fg-muted`},`Could not load this attempt's log. Archie did not answer.`,-1)]])):h.value.kind===`nolog`?(L(),q(V(mT),{key:3},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...n[2]||=[H(`No log`,-1)]]),_:1})]),_:1})]),_:1})):h.value.kind===`disabled`?(L(),q(V(mT),{key:4},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...n[3]||=[H(`This dashboard cannot read task logs`,-1)]]),_:1})]),_:1})]),_:1})):h.value.kind===`empty`?(L(),q(V(mT),{key:5},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...n[4]||=[H(`No entries match the current filter`,-1)]]),_:1})]),_:1})]),_:1})):(L(),j(U,{key:6},[R(`div`,{ref_key:`logFrame`,ref:y,class:`max-h-[62vh] overflow-y-auto rounded-sm border border-border bg-card`},[A(iN,{entries:h.value.entries,"row-key":S,omit:x,"storage-key":`task-log`},null,8,[`entries`])],512),l.value?(L(),j(`div`,SJ,[A(V(X),{variant:`outline`,size:`sm`,disabled:!u.value,onClick:p},{default:I(()=>[...n[5]||=[H(`Older`,-1)]]),_:1},8,[`disabled`]),A(V(X),{variant:`outline`,size:`sm`,disabled:!d.value||a.value,onClick:m},{default:I(()=>[...n[6]||=[H(`Newer`,-1)]]),_:1},8,[`disabled`]),a.value?(L(),j(`span`,CJ,`Loading…`)):o.value?(L(),j(`span`,wJ,`Could not load that page`)):c.value?.more_available?(L(),j(`span`,TJ,`More available`)):F(``,!0)])):F(``,!0),c.value?.truncated?(L(),j(`p`,EJ,`Log truncated; older entries are not pageable.`)):F(``,!0),g.value?(L(),q(V(X),{key:2,variant:`outline`,size:`sm`,class:`mt-3`,"as-child":``},{default:I(()=>[R(`a`,{href:g.value,download:``},`Download log`,8,DJ)]),_:1})):F(``,!0)],64))]))}}),AJ={key:5,class:`space-y-6`},jJ=P({__name:`TaskRunPanels`,props:{id:{}},setup(e){let t=e,n=IR();return(e,r)=>(L(!0),j(U,null,M(V(wR),e=>(L(),q(V(IO),{key:e.id,value:e.id},{default:I(()=>[V(n).attempts===void 0?(L(),q(Mz,{key:0,label:`Loading this task's attempts…`})):V(n).attempts===null?(L(),q(Az,{key:1,title:`Could not load this task's attempts`,detail:`Archie did not answer.`})):V(n).attemptNumber==null?(L(),q(V(mT),{key:2},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...r[0]||=[H(`No attempt recorded`,-1)]]),_:1})]),_:1})]),_:1})):e.id===`log`?(L(),q(kJ,{key:3,state:V(n).logState,attempt:V(n).attemptNumber,stages:V(n).stageNames,filters:V(n).filters,"task-id":t.id,onFilter:V(n).setFilters},null,8,[`state`,`attempt`,`stages`,`filters`,`task-id`,`onFilter`])):e.id===`changes`?(L(),q(hB,{key:4,state:V(n).changesState,task:V(n).task},null,8,[`state`,`task`])):e.id===`debug`?(L(),j(`div`,AJ,[A(_B,{state:V(n).debugState,attempt:V(n).attemptNumber},null,8,[`state`,`attempt`]),A(Bz,{events:V(n).events,attempt:V(n).attemptNumber},null,8,[`events`,`attempt`])])):e.id===`sandbox`?(L(),q(mJ,{key:`${t.id}:${V(n).attemptNumber}`,"task-id":t.id,attempt:V(n).attemptNumber},null,8,[`task-id`,`attempt`])):F(``,!0)]),_:2},1032,[`value`]))),128))}}),MJ={ok:{label:`ok`,kind:`ok`},failed:{label:`failed`,kind:`danger`},interrupted:{label:`interrupted`,kind:`warn`},running:{label:`running`,kind:`info`},skipped:{label:`skipped`,kind:`idle`},unknown:{label:`Outcome not recorded`,kind:`idle`}};function NJ(e){return MJ[e??``]||{label:gE(e||`unknown`),kind:_E(e||`unknown`)}}function PJ(e,t,n){return(e||[]).filter(e=>e?.kind===`step_retried`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>RT(e))}function FJ(e,t,n){return(e||[]).filter(e=>e&&e.kind===`agent_finish`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>RT(e))}var IJ={class:`relative grid grid-cols-[1.75rem_1fr] gap-2 pb-4 before:absolute before:top-4 before:bottom-0 before:left-[0.6875rem] before:w-px before:bg-border-strong last:before:hidden max-md:grid-cols-1 max-md:border-b max-md:border-border max-md:pb-3 max-md:before:hidden`},LJ=[`title`],RJ={class:`min-w-0`},zJ=[`aria-pressed`],BJ={key:1,class:`sr-only`},VJ={key:2,class:`text-xs text-fg-muted`},HJ={key:1,class:`mt-2 flex flex-wrap gap-3 text-xs`},UJ=P({__name:`StageRow`,props:{stage:{},attemptNumber:{},events:{},selected:{type:Boolean}},emits:[`select`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>NJ(n.stage.status)),a=Y(()=>FT(n.stage.duration_ms)),o=Y(()=>FJ(n.events,n.attemptNumber,n.stage.name)),s=Y(()=>PJ(n.events,n.attemptNumber,n.stage.name)),c=Y(()=>W(`relative mt-1 ml-1 size-3.5 shrink-0 rounded-full border-2 bg-card`,n.stage.status===`ok`?`border-ok`:n.stage.status===`failed`?`border-danger`:n.stage.status===`interrupted`?`border-warn`:n.stage.status===`running`?`border-info`:n.stage.status===`skipped`?`border-dashed border-muted-foreground/60`:`border-border-strong`));return(t,l)=>{let u=Me(`RouterLink`);return L(),j(`li`,IJ,[R(`span`,{class:z([c.value,`max-md:hidden`]),title:i.value.label,"aria-hidden":`true`},null,10,LJ),R(`div`,RJ,[R(`button`,{type:`button`,class:z([`-mx-2 -my-1 flex w-[calc(100%+1rem)] flex-wrap items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-muted/40`,n.selected?`bg-primary-soft hover:bg-primary-soft`:``]),"aria-pressed":n.selected??!1,onClick:l[0]||=e=>r(`select`)},[R(`span`,{class:z([`min-w-0 text-sm font-medium break-words hover:underline`,n.selected?`text-primary`:``])},B(e.stage.name||`(unnamed stage)`),3),e.stage.status===`ok`?(L(),j(`span`,BJ,`ok`)):(L(),q(V(k),{key:0,variant:i.value.kind},{default:I(()=>[H(B(i.value.label),1)]),_:1},8,[`variant`])),a.value?(L(),j(`span`,VJ,B(a.value),1)):F(``,!0)],10,zJ),e.stage.error?(L(),j(`div`,{key:0,class:z(V(W)(`mt-2 rounded-sm border-l-[3px] px-3 py-2 text-sm break-words whitespace-pre-wrap text-fg-muted`,e.stage.status===`interrupted`?`border-warn bg-warn-soft`:`border-danger bg-danger-soft`))},B(e.stage.error),3)):F(``,!0),e.stage.calls?.length?(L(),j(`div`,HJ,[(L(!0),j(U,null,M(e.stage.calls,e=>(L(),q(u,{key:e,to:`/tasks/${e}`,class:`text-fg-muted underline-offset-2 hover:text-foreground hover:underline`},{default:I(()=>[H(`called task #`+B(e),1)]),_:2},1032,[`to`]))),128))])):F(``,!0),(L(!0),j(U,null,M(s.value,(e,t)=>(L(),j(`div`,{key:`retry-${t}`,class:`mt-2 text-xs text-warn`},B([e.title,e.detail].filter(Boolean).join(` · `)),1))),128)),(L(!0),j(U,null,M(o.value,(e,t)=>(L(),j(`div`,{key:t,class:`mt-2 text-xs text-fg-muted`},[l[1]||=R(`span`,null,`Agent's own report, not verified by Archie:`,-1),H(` `+B([e.title,e.detail].filter(Boolean).join(` · `)),1)]))),128))])])}}}),WJ={key:2},GJ={key:0,class:`text-xs text-fg-muted`},KJ={key:0,role:`alert`,class:`mb-3 whitespace-pre-wrap break-words text-sm text-danger`},qJ=[`aria-label`],JJ=P({__name:`StageRail`,props:{state:{}},setup(e){let t=e,n=IR(),r=Y(()=>t.state?.attempts||[]),i=Y(()=>r.value.find(e=>Number(e.attempt)===Number(n.attemptNumber))),a=Y(()=>NJ(i.value?.status)),o=Y(()=>i.value?.stages||[]);function s(e){return!!e.name&&n.filters.stage===e.name}function c(e){if(!e.name)return;let t=s(e)&&n.tab===`log`;n.setFilters({stage:t?``:e.name,level:n.filters.level}),n.setTab(`log`)}let l=Y(()=>i.value?.error&&i.value.error!==n.task?.park_reason?i.value.error:``),u=J(new Date);lt(()=>u.value=new Date,3e4);let d=Y(()=>Fz(Nz(n.events,i.value?.attempt??null))),f=Y(()=>{if(!d.value)return``;let e=FT(d.value),t=Date.parse(i.value?.started_at??``);return i.value?.status!==`running`||Number.isNaN(t)?`${e} limit`:`${FT(Math.max(0,u.value.getTime()-t))} / ${e}`});return(t,u)=>e.state===void 0?(L(),q(Mz,{key:0,label:`Loading this task's attempts…`})):e.state===null?(L(),q(Az,{key:1,title:`Could not load this task's attempts`,detail:`Archie did not answer.`})):(L(),j(U,{key:2},[r.value.length?i.value?(L(),j(`div`,WJ,[R(`div`,{class:z([`flex flex-wrap items-center gap-3`,o.value.length||l.value?`mb-4`:void 0])},[A(V(k),{variant:a.value.kind},{default:I(()=>[H(B(a.value.label),1)]),_:1},8,[`variant`]),f.value?(L(),j(`span`,GJ,B(f.value),1)):F(``,!0)],2),l.value?(L(),j(`p`,KJ,B(l.value),1)):F(``,!0),o.value.length?(L(),j(`ol`,{key:1,"aria-label":`Stages recorded in attempt ${i.value.attempt}`},[(L(!0),j(U,null,M(o.value,(e,t)=>(L(),q(UJ,{key:`${e.seq??t}:${e.name}`,stage:e,"attempt-number":i.value.attempt,events:V(n).events,selected:s(e),onSelect:t=>c(e)},null,8,[`stage`,`attempt-number`,`events`,`selected`,`onSelect`]))),128))],8,qJ)):i.value.error?F(``,!0):(L(),q(V(mT),{key:2},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...u[1]||=[H(`No workflow steps recorded`,-1)]]),_:1})]),_:1})]),_:1}))])):(L(),q(V(mT),{key:1},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[H(`Attempt `+B(V(n).attemptNumber)+` is not recorded`,1)]),_:1}),A(V(gT),null,{default:I(()=>[H(`Recorded attempts: `+B(r.value.map(e=>e.attempt).join(`, `))+`.`,1)]),_:1})]),_:1})]),_:1})):(L(),q(V(mT),{key:0},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...u[0]||=[H(`No attempts recorded`,-1)]]),_:1})]),_:1})]),_:1}))],64))}}),YJ={class:`grid gap-4`,"aria-label":`Task details`},XJ={class:`flex flex-col gap-0.5`},ZJ=[`aria-current`,`onClick`],QJ={class:`flex-1`},$J={class:`text-xs text-fg-subtle`},eY={key:0,class:`px-3 pb-1 pl-7 text-xs text-fg-subtle`},tY=[`href`],nY=P({__name:`TaskRail`,setup(e){let t=IR(),n=Y(()=>[...t.attempts?.attempts??[]].reverse()),r=e=>NJ(e).kind,i=Y(()=>{let e=t.task;if(!e)return[];let n=[{label:`Workflow`,value:e.workflow||`none`}];return e.repo&&n.push({label:`Repository`,value:`${e.owner}/${e.repo}`,mono:!0,href:e.repo_url}),e.issue_url&&e.issue_number&&n.push({label:`Issue`,value:`#${e.issue_number}`,mono:!0,href:e.issue_url,arrow:!0}),e.tokens_used&&n.push({label:`Tokens`,value:uw(e.tokens_used),mono:!0}),n});return(e,a)=>(L(),j(`aside`,YJ,[n.value.length?(L(),q(V(uT),{key:0,title:`Attempts`,class:`mb-0`},{default:I(()=>[R(`ul`,XJ,[(L(!0),j(U,null,M(n.value,e=>(L(),j(`li`,{key:e.attempt},[R(`button`,{type:`button`,"aria-current":Number(e.attempt)===Number(V(t).attemptNumber)?`true`:void 0,class:z(V(W)(`flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-secondary`,Number(e.attempt)===Number(V(t).attemptNumber)&&`bg-secondary font-medium`)),onClick:n=>V(t).selectAttempt(Number(e.attempt))},[A(V(ST),{tone:r(e.status)},null,8,[`tone`]),R(`span`,QJ,`Attempt `+B(e.attempt),1),R(`span`,$J,B(e.status?V(NJ)(e.status).label:``),1)],10,ZJ),e.started_at?(L(),j(`p`,eY,[A(V(dw),{at:e.started_at},null,8,[`at`]),e.duration_ms?(L(),j(U,{key:0},[H(` · `+B(V(FT)(e.duration_ms)),1)],64)):F(``,!0)])):F(``,!0)]))),128))])]),_:1})):F(``,!0),A(V(uT),{title:`Stages`,class:`mb-0`},{default:I(()=>[A(JJ,{state:V(t).attempts},null,8,[`state`])]),_:1}),V(t).task?(L(),q(V(uT),{key:1,title:`Details`,class:`mb-0`},{default:I(()=>[A(V(XM),{rows:i.value},{value:I(({row:e})=>[e.href?(L(),j(`a`,{key:0,href:e.href,target:`_blank`,rel:`noreferrer`,class:`inline-flex items-center gap-0.5 hover:underline`},[H(B(e.value),1),e.arrow?(L(),q(V(Vl),{key:0,class:`size-3`,"aria-hidden":`true`})):F(``,!0)],8,tY)):(L(),j(U,{key:1},[H(B(e.value),1)],64))]),_:1},8,[`rows`])]),_:1})):F(``,!0)]))}}),rY={key:2},iY={class:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]`},aY={class:`flex min-w-0 flex-col gap-6`},oY=P({__name:`TaskDetailPage`,setup(e){let t=Dn(),n=Y(()=>String(t.params.id??``)),r=Y(()=>DR(n.value)),i=FR(r);return(e,t)=>r.value===null?(L(),q(RR,{key:0,kind:`invalid`,raw:n.value},null,8,[`raw`])):V(i).missing?(L(),q(RR,{key:1,kind:`missing`,raw:n.value},null,8,[`raw`])):(L(),j(`div`,rY,[A(dz,{id:n.value},null,8,[`id`]),A(Tz,{id:n.value},null,8,[`id`]),V(i).task?(L(),q(wz,{key:0,task:V(i).task,onDone:t[0]||=e=>V(i).refreshAll()},null,8,[`task`])):F(``,!0),R(`div`,iY,[R(`div`,aY,[V(i).task?.approval===`plan`&&V(i).task.plan?(L(),q(UR,{key:0,task:V(i).task,onDone:t[1]||=e=>V(i).refreshAll()},null,8,[`task`])):F(``,!0),A(V(ti),{class:`min-w-0`},{default:I(()=>[A(V(ri),null,{default:I(()=>[A(V(FO),{class:`gap-4`,"model-value":V(i).tab,"onUpdate:modelValue":V(i).setTab},{default:I(()=>[A(LR),A(jJ,{id:n.value},null,8,[`id`])]),_:1},8,[`model-value`,`onUpdate:modelValue`])]),_:1})]),_:1})]),A(nY,{class:`order-first lg:order-none`})])]))}}),sY={class:`flex flex-wrap items-center gap-2`},cY=`all`,lY=P({__name:`TaskFilters`,props:{status:{},search:{}},emits:[`update:status`,`update:search`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>n.status||cY);function a(e){r(`update:status`,typeof e==`string`&&e!==cY?e:``)}return(e,t)=>(L(),j(`div`,sY,[A(V(Q),{type:`search`,"model-value":n.search,"aria-label":`Search tasks by title or repository`,placeholder:`Search by title or repo…`,class:`w-55 max-sm:w-full`,"onUpdate:modelValue":t[0]||=e=>r(`update:search`,String(e))},null,8,[`model-value`]),A(V(Vu),{"model-value":i.value,"onUpdate:modelValue":a},{default:I(()=>[A(V(Gu),{"aria-label":`Filter by status`,class:`w-45 max-sm:w-full`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[A(V(Uu),null,{default:I(()=>[A(V(Wu),{value:cY},{default:I(()=>[...t[1]||=[H(`All statuses`,-1)]]),_:1}),A(V(Wu),{value:`needs_you`},{default:I(()=>[...t[2]||=[H(`Needs attention`,-1)]]),_:1}),(L(!0),j(U,null,M(V(vE)(),e=>(L(),q(V(Wu),{key:e.id,value:e.id},{default:I(()=>[H(B(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`model-value`])]))}});function uY(e){return new Set([`needs_you`,...e.map(e=>e.id)])}function dY(e,t){return e&&uY(t).has(e)?e:``}function fY(e,t){return dY(e,t)}var pY=[`href`],mY=[`href`],hY={class:`inline-flex items-center gap-1`},gY=P({__name:`TaskTable`,props:{tasks:{},showRepo:{type:Boolean,default:!0},showIssue:{type:Boolean,default:!0}},emits:[`done`],setup(e,{emit:t}){let n=e,r=t,i=e=>e.title||`untitled task`,a=Y(()=>[...n.showRepo?[{id:`repo`,label:`Repo`,class:`whitespace-nowrap text-fg-muted`,sort:e=>`${e.owner??``}/${e.repo??``}`}]:[],...n.showIssue?[{id:`issue`,label:`Issue`,class:`text-fg-muted`,sort:e=>e.issue_number??0}]:[],{id:`title`,label:`Title`,fixed:!0,class:`w-full whitespace-normal`,sort:i},{id:`status`,label:`Status`,sort:e=>e.status??``},{id:`workflow`,label:`Workflow`,class:`text-fg-muted`,sort:e=>e.workflow??``},{id:`activity`,label:`Last activity`,class:`text-fg-muted`,sort:e=>Date.parse(e.updated_at??``)||0}]),o={needs_human:`needs attention`,transient:`transient`,terminal:`terminal`};function s(e){switch(e.park_class){case`transient`:return`Environmental failure: a requeue can succeed`;case`terminal`:return`Retry cannot succeed: archive or re-create the work`;default:return`An operator decision is needed`}}let c=e=>e.source!==`chat`&&e.source!==`test`,l=e=>c(e)&&e.issue_url&&e.issue_number?e.issue_url:``;return(e,t)=>(L(),q(V(qM),{columns:a.value,rows:n.tasks,"row-key":e=>String(e.id),"row-link":e=>`/tasks/${e.id}`,"row-label":e=>`Open the run detail for ${i(e)}`,"storage-key":`tasks`},{empty:I(()=>[K(e.$slots,`state`)]),"cell-repo":I(({row:e})=>[e.repo_url?(L(),j(`a`,{key:0,class:`hover:text-foreground hover:underline`,href:e.repo_url,target:`_blank`,rel:`noreferrer`,onClick:t[0]||=pt(()=>{},[`stop`]),onKeydown:t[1]||=pt(()=>{},[`stop`])},B(e.owner)+`/`+B(e.repo),41,pY)):(L(),j(U,{key:1},[H(B(e.owner)+`/`+B(e.repo),1)],64))]),"cell-issue":I(({row:e})=>[l(e)?(L(),j(`a`,{key:0,class:`hover:text-foreground hover:underline`,href:l(e),target:`_blank`,rel:`noreferrer`,onClick:t[2]||=pt(()=>{},[`stop`]),onKeydown:t[3]||=pt(()=>{},[`stop`])},`#`+B(e.issue_number),41,mY)):c(e)&&e.issue_number?(L(),j(U,{key:1},[H(`#`+B(e.issue_number),1)],64)):F(``,!0)]),"cell-title":I(({row:e})=>[A(V(Gr),{class:`inline-block min-w-40 hover:underline`,to:`/tasks/${e.id}`,onClick:t[4]||=pt(()=>{},[`stop`]),onKeydown:t[5]||=pt(()=>{},[`stop`])},{default:I(()=>[H(B(i(e)),1)]),_:2},1032,[`to`]),e.source===`test`?(L(),q(V(k),{key:0,variant:`outline`,class:`ml-2`,title:`Ran an unsaved draft; forge writes were skipped`},{default:I(()=>[...t[7]||=[H(`Test`,-1)]]),_:1})):F(``,!0)]),"cell-status":I(({row:e})=>[R(`span`,hY,[A(V(k),{variant:V(_E)(e.status??``)},{default:I(()=>[H(B(V(gE)(e.status??``)),1)]),_:2},1032,[`variant`]),e.approval?(L(),q(V(k),{key:0,variant:`outline`},{default:I(()=>[H(B(V(wE)[e.approval]??e.approval),1)]),_:2},1024)):F(``,!0),e.status===`parked`&&o[e.park_class??``]?(L(),q(V(k),{key:1,variant:`outline`,title:s(e)},{default:I(()=>[H(B(o[e.park_class??``]),1)]),_:2},1032,[`title`])):F(``,!0)])]),"cell-workflow":I(({row:e})=>[H(B(e.workflow||`—`),1)]),"cell-activity":I(({row:e})=>[A(V(dw),{at:e.updated_at,title:e.created_at?`Created ${V(lw)(e.created_at)}`:void 0},null,8,[`at`,`title`])]),actions:I(({row:e})=>[A(aD,{task:e,onDone:t[6]||=e=>r(`done`,e)},null,8,[`task`])]),_:3},8,[`columns`,`rows`,`row-key`,`row-link`,`row-label`]))}}),_Y={key:0,class:`text-fg-muted flex items-center justify-center gap-2 p-6 text-sm`},vY=P({__name:`TasksState`,props:{kind:{},detail:{}},emits:[`clear`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>n.kind===`error`?{title:`Archie is not responding`,description:n.detail||``}:n.kind===`empty`?{title:`No tasks yet`,description:``}:n.kind===`no-match`?{title:`No matching tasks`,description:``}:{title:`Loading tasks…`,description:``});return(e,t)=>n.kind===`loading`?(L(),j(`div`,_Y,[A(V(uD)),H(` `+B(i.value.title),1)])):(L(),q(V(mT),{key:1},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[H(B(i.value.title),1)]),_:1}),i.value.description?(L(),q(V(gT),{key:0},{default:I(()=>[H(B(i.value.description),1)]),_:1})):F(``,!0)]),_:1}),n.kind===`no-match`?(L(),q(V(hT),{key:0},{default:I(()=>[A(V(X),{variant:`ghost`,size:`sm`,onClick:t[0]||=e=>r(`clear`)},{default:I(()=>[...t[1]||=[H(`Clear filters`,-1)]]),_:1})]),_:1})):F(``,!0)]),_:1}))}});function yY(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0}function bY(){return yY()?`auto`:`smooth`}var xY=P({__name:`TasksPage`,setup(e){let t=Dn(),n=En(),r=J(null),i=J(null),a=J(!1),o=J(null),s=J(``),c=Y(()=>typeof t.query.status==`string`?t.query.status:``),l=Y(()=>{let e=t.query.task,n=Number(typeof e==`string`?e:NaN);return Number.isSafeInteger(n)&&n>0?n:null}),u=Y(()=>fY(c.value,vE())),d=Y(()=>(r.value??[]).filter(e=>{let t=s.value.trim().toLowerCase();return!t||`${e.title??``} ${e.repo??``}`.toLowerCase().includes(t)})),f=Y(()=>{let e=d.value;return e.length<2||e.some(t=>t.repo!==e[0].repo)}),p=Y(()=>d.value.some(e=>e.source!==`chat`&&e.source!==`test`&&e.issue_number)),m=Y(()=>o.value?`error`:r.value===null?`loading`:r.value.length?`no-match`:`empty`);async function h(){o.value=null;let e=Math.min(Math.max(r.value?.length??0,100),500);try{let t=await Z.taskPage({status:u.value||void 0,limit:e});r.value=t.tasks,i.value=t.next}catch(e){o.value=String(e.message||e),r.value=null}}async function g(){if(i.value&&!a.value){a.value=!0;try{let e=await Z.taskPage({status:u.value||void 0,limit:100,cursor:i.value});r.value=[...r.value??[],...e.tasks],i.value=e.next}catch(e){o.value=String(e.message||e)}finally{a.value=!1}}}tp(`tasks`,()=>void h(),500),Be(h),N(u,()=>{r.value=null,h()});function _(e){let r=dY(e,vE()),i={...t.query};r?i.status=r:delete i.status,n.replace({query:i})}function v(){s.value=``,_(``)}let y=J(null);N([l,r],()=>{let e=l.value;e!==null&&r.value!==null&&y.value!==e&&(y.value=e,b(e))});async function b(e){await We(),requestAnimationFrame(()=>{let t=document.querySelector(`[data-row-key="${e}"]`);t&&(t.focus({preventScroll:!0}),t.scrollIntoView?.({block:`center`,behavior:bY()}))})}return(e,t)=>(L(),j(U,null,[A(rt,{title:`Tasks`},{default:I(()=>[o.value?F(``,!0):(L(),q(lY,{key:0,status:u.value,search:s.value,"onUpdate:status":_,"onUpdate:search":t[0]||=e=>s.value=e},null,8,[`status`,`search`]))]),_:1}),A(V(ti),null,{default:I(()=>[A(V(ri),{class:`flex flex-col gap-3`},{default:I(()=>[o.value?(L(),q(vY,{key:0,kind:`error`,detail:o.value},null,8,[`detail`])):(L(),j(U,{key:1},[A(gY,{tasks:d.value,"show-repo":f.value,"show-issue":p.value,onDone:h},{state:I(()=>[A(vY,{kind:m.value,onClear:v},null,8,[`kind`])]),_:1},8,[`tasks`,`show-repo`,`show-issue`]),i.value?(L(),q(V(X),{key:0,variant:`outline`,class:`self-center`,disabled:a.value,onClick:g},{default:I(()=>[...t[1]||=[H(`Load more`,-1)]]),_:1},8,[`disabled`])):F(``,!0)],64))]),_:1})]),_:1})],64))}}),SY={implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function CY(e){return e&&SY[e]?SY[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function wY(e,t){return!t||!e?0:Math.round(e/t*100)}function TY(e){if(!e)return`–`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function EY(e){return[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0))}function DY(e){return[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors)}function OY(e){return Math.max(...e.map(e=>e.avg_ms||0),1)}var kY={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,idle:`bg-idle`},AY={class:`mt-2 h-[5px] w-[140px] overflow-hidden rounded-full bg-border`},jY=P({__name:`WorkflowBar`,props:{fraction:{},kind:{default:`ok`}},setup(e){let t=e,n=Y(()=>`${Math.min(100,Math.max(0,t.fraction))}%`);return(e,r)=>(L(),j(`div`,AY,[R(`div`,{class:z([`h-full rounded-full transition-[width]`,V(kY)[t.kind]]),style:et(`width:${n.value}`)},null,6)]))}}),MY={class:`text-sm`},NY=P({__name:`SlowestStagesCard`,props:{stages:{}},setup(e){let t=e,n=Y(()=>EY(t.stages)),r=Y(()=>OY(t.stages));return(e,t)=>(L(),q(V(uT),{title:`Slowest stages`,class:`mb-0`},{default:I(()=>[A(V(TT),null,{default:I(()=>[A(V(AT),null,{default:I(()=>[A(V(OT),null,{default:I(()=>[A(V(kT),null,{default:I(()=>[...t[0]||=[H(`Workflow`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[1]||=[H(`Stage`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[2]||=[H(`Runs`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[3]||=[H(`Avg duration`,-1)]]),_:1})]),_:1})]),_:1}),A(V(ET),null,{default:I(()=>[(L(!0),j(U,null,M(n.value,(e,t)=>(L(),q(V(OT),{key:t},{default:I(()=>[A(V(DT),null,{default:I(()=>[H(B(V(CY)(e.workflow)),1)]),_:2},1024),A(V(DT),{class:`font-medium`},{default:I(()=>[H(B(e.stage),1)]),_:2},1024),A(V(DT),null,{default:I(()=>[H(B(e.runs),1)]),_:2},1024),A(V(DT),null,{default:I(()=>[R(`div`,MY,B(V(TY)(e.avg_ms)),1),A(jY,{fraction:V(wY)(e.avg_ms||0,r.value),kind:`info`},null,8,[`fraction`])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]),_:1}))}}),PY={class:`text-sm`},FY=P({__name:`StageFailuresCard`,props:{stages:{}},setup(e){let t=e,n=Y(()=>DY(t.stages));return(e,t)=>(L(),q(V(uT),{title:`Most failures`,class:`mb-0`},{default:I(()=>[n.value.length?(L(),q(V(TT),{key:1},{default:I(()=>[A(V(AT),null,{default:I(()=>[A(V(OT),null,{default:I(()=>[A(V(kT),null,{default:I(()=>[...t[1]||=[H(`Workflow`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[2]||=[H(`Stage`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[3]||=[H(`Failures`,-1)]]),_:1})]),_:1})]),_:1}),A(V(ET),null,{default:I(()=>[(L(!0),j(U,null,M(n.value,(e,t)=>(L(),q(V(OT),{key:t},{default:I(()=>[A(V(DT),null,{default:I(()=>[H(B(V(CY)(e.workflow)),1)]),_:2},1024),A(V(DT),{class:`font-medium`},{default:I(()=>[H(B(e.stage),1)]),_:2},1024),A(V(DT),null,{default:I(()=>[R(`div`,PY,B(e.errors)+` of `+B(e.runs),1),A(jY,{fraction:V(wY)(e.errors,e.runs),kind:`danger`},null,8,[`fraction`])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})):(L(),q(V(mT),{key:0},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...t[0]||=[H(`No failures recorded`,-1)]]),_:1})]),_:1})]),_:1}))]),_:1}))}}),IY={class:`space-y-5 p-4 text-sm`},LY={class:`flex items-center gap-2`},RY={key:0,class:`text-xs text-fg-muted`},zY={class:`ml-auto text-xs text-fg-muted`},BY={key:0,class:`rounded-md bg-danger-soft p-3 break-words whitespace-pre-wrap text-danger`},VY={key:1,role:`alert`,class:`text-danger`},HY={key:0,class:`font-medium`},UY={key:1,class:`text-xs text-fg-muted`},WY={class:`flex items-center gap-2 text-xs`},GY={class:`font-mono`},KY={key:0,class:`break-words whitespace-pre-wrap`},qY={key:0,class:`break-words whitespace-pre-wrap`},JY={class:`text-xs text-fg-muted`},YY={key:2,class:`space-y-1`},XY={class:`text-caption font-medium uppercase text-fg-muted`},ZY={class:`divide-y divide-border rounded-md border border-border`},QY={class:`flex justify-between gap-2 text-xs`},$Y={class:`font-mono`},eX={key:0,class:`mt-1 break-words whitespace-pre-wrap text-xs text-fg-muted`},tX={key:3,class:`text-xs text-fg-muted`},nX={key:4,class:`text-xs text-fg-muted`},rX={key:2,class:`space-y-1`},iX={class:`divide-y divide-border rounded-md border border-border`},aX={class:`space-y-3`},oX={key:0,role:`alert`,class:`text-danger`},sX={class:`space-y-2`},cX=P({__name:`StepRun`,props:{task:{},attempt:{},stage:{},stages:{}},setup(e){let t=e,n=J([]),r=J(),i=J(),a=J(``),o=J(``),s=J(!1),c=Y(()=>`${t.task.id}/${t.attempt}/${t.stage.id??t.stage.name}`),l=0,u,d=!1,f=!1;async function p(){if(!t.attempt)return;if(d){f=!0;return}d=!0;let e=l,s=String(t.task.id),c={attempt:t.attempt},u=await Promise.allSettled([Z.taskDebug(s,c),Z.taskChanges(s,c),Z.taskLogs(s,{...c,stage:t.stage.name})]);if(e!==l)return;let[m,h,g]=u;a.value=m.status===`rejected`?`Could not load step activity`:``,m.status===`fulfilled`&&(n.value=m.value.events??[]),o.value=h.status===`rejected`?`Could not load captured changes`:``,h.status===`fulfilled`&&(r.value=h.value),i.value=g.status===`fulfilled`?g.value:null,d=!1,f&&(f=!1,p())}N(c,()=>{l++,d=!1,f=!1,n.value=[],r.value=void 0,i.value=void 0,a.value=``,o.value=``,s.value=!1,p()},{immediate:!0}),N(()=>t.stage.status,e=>{clearInterval(u),p(),e===`running`&&(u=setInterval(()=>void p(),2e3))},{immediate:!0}),tp(`tasks`,()=>void p(),300),Ue(()=>{l++,clearInterval(u)});let m=Y(()=>NJ(t.stage.status)),h=Y(()=>new Set([t.stage.name,...(t.stage.agents??[]).map(e=>e.name.split(`/`).at(-1)??e.name)])),g=Y(()=>t.stages.find(e=>e.name===t.stage.name&&e.started_at&&t.stage.started_at&&e.started_at>t.stage.started_at)?.started_at);function _(e){if(!t.stage.started_at||!e)return t.stages.filter(e=>e.name===t.stage.name).length===1;let n=new Date(e).getTime();return n>=Date.parse(t.stage.started_at)&&(!t.stage.finished_at||n<=Date.parse(t.stage.finished_at))&&(!g.value||nn.value.filter(e=>Number(e.attempt)===t.attempt?e.data?.step_id==null?h.value.has(e.stage??``)&&_(e.at):Number(e.data.step_id)===t.stage.id:!1).sort((e,t)=>String(e.at??``).localeCompare(String(t.at??``)))),y=Y(()=>v.value.filter(e=>e.kind===`forge_suppressed`)),b=Y(()=>{let e=t.stage.agents??[];return[...new Set([``,...e.map(e=>e.name.includes(`/`)?e.name.split(`/`)[0]:``),...v.value.map(e=>String(e.data?.branch??``))])].map(t=>({branch:t,agents:e.filter(e=>(e.name.includes(`/`)?e.name.split(`/`)[0]:``)===t),reports:v.value.filter(e=>e.kind===`agent_finish`&&String(e.data?.branch??``)===t),tools:v.value.filter(e=>e.kind===`tool_call`&&String(e.data?.branch??``)===t)})).filter(e=>e.agents.length||e.reports.length||e.tools.length)}),x=Y(()=>(r.value?.captures??[]).filter(e=>e.stage===t.stage.name&&_(e.captured_at))),S=Y(()=>i.value?{...i.value,entries:(i.value.entries??[]).filter(e=>_(e.time))}:i.value);return(t,n)=>(L(),j(`div`,IY,[R(`div`,LY,[A(V(k),{variant:m.value.kind},{default:I(()=>[H(B(m.value.label),1)]),_:1},8,[`variant`]),e.stage.duration_ms==null?F(``,!0):(L(),j(`span`,RY,B(V(FT)(e.stage.duration_ms)),1)),R(`span`,zY,`Attempt `+B(e.attempt),1)]),e.stage.error?(L(),j(`p`,BY,B(e.stage.error),1)):F(``,!0),a.value?(L(),j(`p`,VY,B(a.value),1)):F(``,!0),(L(!0),j(U,null,M(b.value,e=>(L(),j(`section`,{key:e.branch,class:`space-y-3`},[e.branch?(L(),j(`h3`,HY,B(e.branch),1)):b.value.length>1?(L(),j(`p`,UY,`Activity without branch attribution`)):F(``,!0),(L(!0),j(U,null,M(e.agents,e=>(L(),j(`div`,{key:e.id,class:`space-y-1`},[R(`div`,WY,[R(`span`,GY,B(e.name.split(`/`).at(-1)),1),A(V(k),{variant:V(NJ)(e.status).kind},{default:I(()=>[H(B(e.status),1)]),_:2},1032,[`variant`])]),e.detail?(L(),j(`p`,KY,B(e.detail),1)):F(``,!0)]))),128)),(L(!0),j(U,null,M(e.reports,(t,n)=>(L(),j(`div`,{key:n,class:`space-y-1`},[t.detail&&!e.agents.some(e=>e.detail===t.detail)?(L(),j(`p`,qY,B(t.detail),1)):F(``,!0),R(`p`,JY,`Agent's own report · `+B(V(RT)(t).title),1)]))),128)),e.tools.length?(L(),j(`div`,YY,[R(`h4`,XY,`Tool calls · `+B(e.tools.length),1),R(`ol`,ZY,[(L(!0),j(U,null,M(s.value?e.tools:e.tools.slice(0,12),(e,t)=>(L(),j(`li`,{key:t,class:`px-3 py-2`},[R(`div`,QY,[R(`span`,$Y,B(e.data?.tool),1),R(`span`,{class:z(e.data?.failed?`text-danger`:`text-fg-muted`)},B(e.data?.failed?`Failed`:`Returned`),3)]),e.detail?(L(),j(`p`,eX,B(e.detail),1)):F(``,!0)]))),128))]),e.tools.length>12?(L(),q(V(X),{key:0,type:`button`,variant:`link`,size:`xs`,class:`px-0`,onClick:n[0]||=e=>s.value=!s.value},{default:I(()=>[H(B(s.value?`Show first 12`:`Show all ${e.tools.length}`),1)]),_:2},1024)):F(``,!0)])):F(``,!0),e.reports.length?(L(),j(`p`,tX,B(e.reports.map(e=>V(RT)(e).detail).filter(Boolean).join(` · `)),1)):e.agents.length?(L(),j(`p`,nX,B(e.agents.reduce((e,t)=>e+t.tokens_used,0).toLocaleString())+` tokens recorded`,1)):F(``,!0)]))),128)),y.value.length?(L(),j(`section`,rX,[n[1]||=R(`h3`,{class:`text-caption font-medium uppercase text-fg-muted`},`Skipped in test run`,-1),R(`ul`,iX,[(L(!0),j(U,null,M(y.value,(e,t)=>(L(),j(`li`,{key:t,class:`px-3 py-2 text-xs break-words whitespace-pre-wrap`},B(e.detail),1))),128))])])):F(``,!0),R(`section`,aX,[n[2]||=R(`h3`,{class:`text-caption font-medium uppercase text-fg-muted`},`Captured changes`,-1),o.value?(L(),j(`p`,oX,B(o.value),1)):F(``,!0),(L(!0),j(U,null,M(x.value,(t,n)=>(L(),q(pB,{key:n,capture:t,task:e.task},null,8,[`capture`,`task`]))),128))]),R(`section`,sX,[n[3]||=R(`h3`,{class:`text-caption font-medium uppercase text-fg-muted`},`Log`,-1),A(kJ,{state:S.value,attempt:e.attempt,filterable:!1},null,8,[`state`,`attempt`])])]))}}),lX=Symbol.for(`yaml.alias`),uX=Symbol.for(`yaml.document`),dX=Symbol.for(`yaml.map`),fX=Symbol.for(`yaml.pair`),pX=Symbol.for(`yaml.scalar`),mX=Symbol.for(`yaml.seq`),hX=Symbol.for(`yaml.node.type`),gX=e=>!!e&&typeof e==`object`&&e[hX]===lX,_X=e=>!!e&&typeof e==`object`&&e[hX]===uX,vX=e=>!!e&&typeof e==`object`&&e[hX]===dX,yX=e=>!!e&&typeof e==`object`&&e[hX]===fX,bX=e=>!!e&&typeof e==`object`&&e[hX]===pX,xX=e=>!!e&&typeof e==`object`&&e[hX]===mX;function SX(e){if(e&&typeof e==`object`)switch(e[hX]){case dX:case mX:return!0}return!1}function CX(e){if(e&&typeof e==`object`)switch(e[hX]){case lX:case dX:case pX:case mX:return!0}return!1}var wX=e=>(bX(e)||SX(e))&&!!e.anchor,TX=Symbol(`break visit`),EX=Symbol(`skip children`),DX=Symbol(`remove node`);function OX(e,t){let n=AX(t);_X(e)?kX(null,e.contents,n,Object.freeze([e]))===DX&&(e.contents=null):kX(null,e,n,Object.freeze([]))}OX.BREAK=TX,OX.SKIP=EX,OX.REMOVE=DX;function kX(e,t,n,r){let i=jX(e,t,n,r);if(CX(i)||yX(i))return MX(e,r,i),kX(e,i,n,r);if(typeof i!=`symbol`){if(SX(t)){r=Object.freeze(r.concat(t));for(let e=0;ee.replace(/[!,[\]{}]/g,e=>NX[e]),FX=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+PX(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&CX(e.contents)){let t={};OX(e.contents,(e,n)=>{CX(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)(i!==`!!`||a!==`tag:yaml.org,2002:`)&&(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(` +`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return wB.get()},set promptLabel(e){wB.set(e)},get tooMuchOutput(){return EB.get()},set tooMuchOutput(e){EB.set(e)}}}_verifyIntegers(...e){for(sJ of e)if(sJ===1/0||isNaN(sJ)||sJ%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(sJ of e)if(sJ&&(sJ===1/0||isNaN(sJ)||sJ%1!=0||sJ<0))throw Error(`This API only accepts positive integers`)}},lJ=2,uJ=1,dJ=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(lJ,Math.floor(u/e.css.cell.width)),rows:Math.max(uJ,Math.floor(l/e.css.cell.height))}}},fJ={class:`flex h-[32rem] min-h-0 flex-col gap-2`},pJ={key:0,class:`text-sm text-fg-muted`,role:`status`},mJ=P({__name:`SandboxView`,props:{taskId:{},attempt:{}},setup(e){let t=e,n=J(null),r=J(`connecting`),i=null,a=null,o=null,s=null;function c(){try{o?.fit()}catch{}}return Be(()=>{let e=n.value;if(!e)return;i=new cJ({convertEol:!0,disableStdin:!0,cursorBlink:!1,fontFamily:`'IBM Plex Mono', ui-monospace, monospace`,fontSize:13,theme:{background:`#0b0f14`,foreground:`#e6edf3`}}),o=new dJ,i.loadAddon(o),i.open(e),c();let l=window.location.protocol===`https:`?`wss:`:`ws:`,u=new URLSearchParams({attempt:String(t.attempt)}),d=new WebSocket(`${l}//${window.location.host}/api/tasks/${encodeURIComponent(t.taskId)}/sandbox?${u}`);a=d,d.binaryType=`arraybuffer`,d.onopen=()=>{r.value=`open`},d.onmessage=e=>{i&&(typeof e.data==`string`&&(r.value=`failed`),i.write(typeof e.data==`string`?e.data:new Uint8Array(e.data)))},d.onerror=()=>{r.value=`failed`},d.onclose=()=>{r.value!==`failed`&&(r.value=`closed`)},s=new ResizeObserver(c),s.observe(e)}),nt(()=>{s?.disconnect(),s=null,a?.close(),a=null,i?.dispose(),i=null,o=null}),(e,t)=>(L(),j(`div`,fJ,[r.value===`open`?F(``,!0):(L(),j(`p`,pJ,[r.value===`connecting`?(L(),j(U,{key:0},[H(`Connecting…`)],64)):r.value===`closed`?(L(),j(U,{key:1},[H(`The sandbox ended.`)],64)):(L(),j(U,{key:2},[H(`Sandbox unavailable.`)],64))])),R(`div`,{ref_key:`host`,ref:n,class:`min-h-0 flex-1 overflow-hidden rounded-md border border-border bg-[#0b0f14] p-2`},null,512)]))}}),hJ={class:`flex flex-wrap items-center gap-3 border-b border-border pb-3`},gJ={class:`inline-flex items-center gap-2`},_J={class:`inline-flex items-center gap-2`},vJ=`__all__`,yJ=P({__name:`TaskLogFilters`,props:{filters:{},stages:{}},emits:[`filter`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>LM.map(e=>({value:e.value||vJ,label:e.label}))),a=Y(()=>n.filters.level||vJ),o=Y(()=>n.filters.stage||vJ);function s(e){r(`filter`,{...n.filters,...e})}function c(e){s({level:String(e)===vJ?``:String(e)})}function l(e){s({stage:String(e)===vJ?``:String(e)})}return(t,n)=>(L(),j(`div`,hJ,[R(`div`,gJ,[A(V(Vu),{"model-value":a.value,"onUpdate:modelValue":c},{default:I(()=>[A(V(Gu),{size:`sm`,"aria-label":`Filter log entries by level`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[A(V(Uu),null,{default:I(()=>[(L(!0),j(U,null,M(i.value,e=>(L(),q(V(Wu),{key:e.value,value:e.value},{default:I(()=>[H(B(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`model-value`])]),R(`div`,_J,[A(V(Vu),{"model-value":o.value,"onUpdate:modelValue":l},{default:I(()=>[A(V(Gu),{size:`sm`,"aria-label":`Filter log entries by stage`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[A(V(Uu),null,{default:I(()=>[A(V(Wu),{value:vJ},{default:I(()=>[...n[0]||=[H(`All stages`,-1)]]),_:1}),(L(!0),j(U,null,M(e.stages,e=>(L(),q(V(Wu),{key:e,value:e},{default:I(()=>[H(B(e),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`model-value`])])]))}}),bJ={class:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`},xJ={key:2,class:`flex flex-col items-start gap-2 py-3`},SJ={key:0,class:`mt-2 flex flex-wrap items-center gap-2 px-1`},CJ={key:0,class:`text-xs text-fg-muted`},wJ={key:1,class:`text-xs text-danger`},TJ={key:2,class:`text-xs text-fg-muted`},EJ={key:1,class:`px-1 pt-1 text-xs text-warn`},DJ=[`href`],OJ=500,kJ=P({__name:`TaskLogs`,props:{state:{},attempt:{},stages:{default:()=>[]},filters:{default:()=>({...MR})},filterable:{type:Boolean,default:!0},taskId:{default:null}},emits:[`filter`],setup(e){let t=e,n=Y(()=>Number(t.attempt)||Number(t.state?.attempt)||0),r=J(null),i=J([]),a=J(!1),o=J(!1),s=Y(()=>`${t.taskId}|${n.value}|${t.filters.level}|${t.filters.stage}`);N(s,()=>{r.value=null,i.value=[],o.value=!1});let c=Y(()=>r.value?.state??t.state),l=Y(()=>t.taskId!=null&&t.filterable),u=Y(()=>l.value&&!!c.value?.more_available&&(c.value?.cursor??0)>0),d=Y(()=>l.value&&i.value.length>0);async function f(e){if(t.taskId==null)return null;a.value=!0,o.value=!1;try{return await Z.taskLogs(String(t.taskId),{attempt:n.value||void 0,level:t.filters.level,stage:t.filters.stage,limit:OJ,before:e||void 0})}catch{return o.value=!0,null}finally{a.value=!1}}async function p(){let e=c.value,t=e?.cursor??0;if(!e?.more_available||t<=0)return;let n=await f(t);n&&(await v.replace({hash:``}),i.value.push({before:r.value?.before??0,state:e}),r.value={before:t,state:n})}function m(){let e=i.value.pop();e&&(o.value=!1,r.value=e)}let h=Y(()=>{let e=c.value;if(e===void 0)return{kind:`loading`,status:`Loading this attempt's log`};if(e===null)return{kind:`failed`,status:`This attempt's log could not be loaded`};if(e.found===!1&&!e.disabled)return{kind:`nolog`,status:`No log`};if(e.disabled)return{kind:`disabled`,status:`This dashboard cannot read task logs`};let t=e.entries||[];return t.length?{kind:`entries`,status:`${t.length} log entr${t.length===1?`y`:`ies`} shown`,entries:t}:{kind:`empty`,status:`This attempt's log has no entries matching the current filter`,entries:t}}),g=Y(()=>t.taskId==null?null:Z.taskLogDownloadURL(String(t.taskId),n.value||null)),_=Dn(),v=En(),y=J(),b=``;N([()=>_.hash,c],async()=>{let e=/^#log-line-(\d+)$/.exec(_.hash);if(!e){b=``;return}if(b===_.hash)return;r.value&&(r.value=null,i.value=[]),await We();let t=y.value?.querySelector(`[data-row-key="${e[1]}"]`);t&&(b=_.hash,t?.scrollIntoView({block:`center`}),t?.focus({preventScroll:!0}))},{immediate:!0,flush:`post`});let x=[`task`,`task_id`],S=e=>String(e.id??`${e.time}|${e.message??e.msg}`);return(t,n)=>(L(),j(`div`,null,[e.filterable?(L(),q(yJ,{key:0,class:`mb-3`,filters:e.filters,stages:e.stages,onFilter:n[0]||=e=>t.$emit(`filter`,e)},null,8,[`filters`,`stages`])):F(``,!0),R(`p`,bJ,B(h.value.status),1),h.value.kind===`loading`?(L(),q(Mz,{key:1,label:`Loading attempt log…`})):h.value.kind===`failed`?(L(),j(`div`,xJ,[...n[1]||=[R(`p`,{class:`text-sm text-fg-muted`},`Could not load this attempt's log. Archie did not answer.`,-1)]])):h.value.kind===`nolog`?(L(),q(V(mT),{key:3},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...n[2]||=[H(`No log`,-1)]]),_:1})]),_:1})]),_:1})):h.value.kind===`disabled`?(L(),q(V(mT),{key:4},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...n[3]||=[H(`This dashboard cannot read task logs`,-1)]]),_:1})]),_:1})]),_:1})):h.value.kind===`empty`?(L(),q(V(mT),{key:5},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...n[4]||=[H(`No entries match the current filter`,-1)]]),_:1})]),_:1})]),_:1})):(L(),j(U,{key:6},[R(`div`,{ref_key:`logFrame`,ref:y,class:`max-h-[62vh] overflow-y-auto rounded-sm border border-border bg-card`},[A(iN,{entries:h.value.entries,"row-key":S,omit:x,"storage-key":`task-log`},null,8,[`entries`])],512),l.value?(L(),j(`div`,SJ,[A(V(X),{variant:`outline`,size:`sm`,disabled:!u.value,onClick:p},{default:I(()=>[...n[5]||=[H(`Older`,-1)]]),_:1},8,[`disabled`]),A(V(X),{variant:`outline`,size:`sm`,disabled:!d.value||a.value,onClick:m},{default:I(()=>[...n[6]||=[H(`Newer`,-1)]]),_:1},8,[`disabled`]),a.value?(L(),j(`span`,CJ,`Loading…`)):o.value?(L(),j(`span`,wJ,`Could not load that page`)):c.value?.more_available?(L(),j(`span`,TJ,`More available`)):F(``,!0)])):F(``,!0),c.value?.truncated?(L(),j(`p`,EJ,`Log truncated; older entries are not pageable.`)):F(``,!0),g.value?(L(),q(V(X),{key:2,variant:`outline`,size:`sm`,class:`mt-3`,"as-child":``},{default:I(()=>[R(`a`,{href:g.value,download:``},`Download log`,8,DJ)]),_:1})):F(``,!0)],64))]))}}),AJ={key:5,class:`space-y-6`},jJ=P({__name:`TaskRunPanels`,props:{id:{}},setup(e){let t=e,n=IR();return(e,r)=>(L(!0),j(U,null,M(V(wR),e=>(L(),q(V(IO),{key:e.id,value:e.id},{default:I(()=>[V(n).attempts===void 0?(L(),q(Mz,{key:0,label:`Loading this task's attempts…`})):V(n).attempts===null?(L(),q(Az,{key:1,title:`Could not load this task's attempts`,detail:`Archie did not answer.`})):V(n).attemptNumber==null?(L(),q(V(mT),{key:2},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...r[0]||=[H(`No attempt recorded`,-1)]]),_:1})]),_:1})]),_:1})):e.id===`log`?(L(),q(kJ,{key:3,state:V(n).logState,attempt:V(n).attemptNumber,stages:V(n).stageNames,filters:V(n).filters,"task-id":t.id,onFilter:V(n).setFilters},null,8,[`state`,`attempt`,`stages`,`filters`,`task-id`,`onFilter`])):e.id===`changes`?(L(),q(hB,{key:4,state:V(n).changesState,task:V(n).task},null,8,[`state`,`task`])):e.id===`debug`?(L(),j(`div`,AJ,[A(_B,{state:V(n).debugState,attempt:V(n).attemptNumber},null,8,[`state`,`attempt`]),A(Bz,{events:V(n).events,attempt:V(n).attemptNumber},null,8,[`events`,`attempt`])])):e.id===`sandbox`?(L(),q(mJ,{key:`${t.id}:${V(n).attemptNumber}`,"task-id":t.id,attempt:V(n).attemptNumber},null,8,[`task-id`,`attempt`])):F(``,!0)]),_:2},1032,[`value`]))),128))}}),MJ={ok:{label:`ok`,kind:`ok`},failed:{label:`failed`,kind:`danger`},interrupted:{label:`interrupted`,kind:`warn`},running:{label:`running`,kind:`info`},skipped:{label:`skipped`,kind:`idle`},unknown:{label:`Outcome not recorded`,kind:`idle`}};function NJ(e){return MJ[e??``]||{label:gE(e||`unknown`),kind:_E(e||`unknown`)}}function PJ(e,t,n){return(e||[]).filter(e=>e?.kind===`step_retried`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>RT(e))}function FJ(e,t,n){return(e||[]).filter(e=>e&&e.kind===`agent_finish`&&Number(e.attempt)===Number(t)&&(e.stage||``)===(n||``)).map(e=>RT(e))}var IJ={class:`relative grid grid-cols-[1.75rem_1fr] gap-2 pb-4 before:absolute before:top-4 before:bottom-0 before:left-[0.6875rem] before:w-px before:bg-border-strong last:before:hidden max-md:grid-cols-1 max-md:border-b max-md:border-border max-md:pb-3 max-md:before:hidden`},LJ=[`title`],RJ={class:`min-w-0`},zJ=[`aria-pressed`],BJ={key:1,class:`sr-only`},VJ={key:2,class:`text-xs text-fg-muted`},HJ={key:1,class:`mt-2 flex flex-wrap gap-3 text-xs`},UJ=P({__name:`StageRow`,props:{stage:{},attemptNumber:{},events:{},selected:{type:Boolean}},emits:[`select`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>NJ(n.stage.status)),a=Y(()=>FT(n.stage.duration_ms)),o=Y(()=>FJ(n.events,n.attemptNumber,n.stage.name)),s=Y(()=>PJ(n.events,n.attemptNumber,n.stage.name)),c=Y(()=>W(`relative mt-1 ml-1 size-3.5 shrink-0 rounded-full border-2 bg-card`,n.stage.status===`ok`?`border-ok`:n.stage.status===`failed`?`border-danger`:n.stage.status===`interrupted`?`border-warn`:n.stage.status===`running`?`border-info`:n.stage.status===`skipped`?`border-dashed border-muted-foreground/60`:`border-border-strong`));return(t,l)=>{let u=Me(`RouterLink`);return L(),j(`li`,IJ,[R(`span`,{class:z([c.value,`max-md:hidden`]),title:i.value.label,"aria-hidden":`true`},null,10,LJ),R(`div`,RJ,[R(`button`,{type:`button`,class:z([`-mx-2 -my-1 flex w-[calc(100%+1rem)] flex-wrap items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-muted/40`,n.selected?`bg-primary-soft hover:bg-primary-soft`:``]),"aria-pressed":n.selected??!1,onClick:l[0]||=e=>r(`select`)},[R(`span`,{class:z([`min-w-0 text-sm font-medium break-words hover:underline`,n.selected?`text-primary`:``])},B(e.stage.name||`(unnamed stage)`),3),e.stage.status===`ok`?(L(),j(`span`,BJ,`ok`)):(L(),q(V(k),{key:0,variant:i.value.kind},{default:I(()=>[H(B(i.value.label),1)]),_:1},8,[`variant`])),a.value?(L(),j(`span`,VJ,B(a.value),1)):F(``,!0)],10,zJ),e.stage.error?(L(),j(`div`,{key:0,class:z(V(W)(`mt-2 rounded-sm border-l-[3px] px-3 py-2 text-sm break-words whitespace-pre-wrap text-fg-muted`,e.stage.status===`interrupted`?`border-warn bg-warn-soft`:`border-danger bg-danger-soft`))},B(e.stage.error),3)):F(``,!0),e.stage.calls?.length?(L(),j(`div`,HJ,[(L(!0),j(U,null,M(e.stage.calls,e=>(L(),q(u,{key:e,to:`/tasks/${e}`,class:`text-fg-muted underline-offset-2 hover:text-foreground hover:underline`},{default:I(()=>[H(`called task #`+B(e),1)]),_:2},1032,[`to`]))),128))])):F(``,!0),(L(!0),j(U,null,M(s.value,(e,t)=>(L(),j(`div`,{key:`retry-${t}`,class:`mt-2 text-xs text-warn`},B([e.title,e.detail].filter(Boolean).join(` · `)),1))),128)),(L(!0),j(U,null,M(o.value,(e,t)=>(L(),j(`div`,{key:t,class:`mt-2 text-xs text-fg-muted`},[l[1]||=R(`span`,null,`Agent's own report, not verified by Archie:`,-1),H(` `+B([e.title,e.detail].filter(Boolean).join(` · `)),1)]))),128))])])}}}),WJ={key:2},GJ={key:0,class:`text-xs text-fg-muted`},KJ={key:0,role:`alert`,class:`mb-3 whitespace-pre-wrap break-words text-sm text-danger`},qJ=[`aria-label`],JJ=P({__name:`StageRail`,props:{state:{}},setup(e){let t=e,n=IR(),r=Y(()=>t.state?.attempts||[]),i=Y(()=>r.value.find(e=>Number(e.attempt)===Number(n.attemptNumber))),a=Y(()=>NJ(i.value?.status)),o=Y(()=>i.value?.stages||[]);function s(e){return!!e.name&&n.filters.stage===e.name}function c(e){if(!e.name)return;let t=s(e)&&n.tab===`log`;n.setFilters({stage:t?``:e.name,level:n.filters.level}),n.setTab(`log`)}let l=Y(()=>i.value?.error&&i.value.error!==n.task?.park_reason?i.value.error:``),u=J(new Date);lt(()=>u.value=new Date,3e4);let d=Y(()=>Fz(Nz(n.events,i.value?.attempt??null))),f=Y(()=>{if(!d.value)return``;let e=FT(d.value),t=Date.parse(i.value?.started_at??``);return i.value?.status!==`running`||Number.isNaN(t)?`${e} limit`:`${FT(Math.max(0,u.value.getTime()-t))} / ${e}`});return(t,u)=>e.state===void 0?(L(),q(Mz,{key:0,label:`Loading this task's attempts…`})):e.state===null?(L(),q(Az,{key:1,title:`Could not load this task's attempts`,detail:`Archie did not answer.`})):(L(),j(U,{key:2},[r.value.length?i.value?(L(),j(`div`,WJ,[R(`div`,{class:z([`flex flex-wrap items-center gap-3`,o.value.length||l.value?`mb-4`:void 0])},[A(V(k),{variant:a.value.kind},{default:I(()=>[H(B(a.value.label),1)]),_:1},8,[`variant`]),f.value?(L(),j(`span`,GJ,B(f.value),1)):F(``,!0)],2),l.value?(L(),j(`p`,KJ,B(l.value),1)):F(``,!0),o.value.length?(L(),j(`ol`,{key:1,"aria-label":`Stages recorded in attempt ${i.value.attempt}`},[(L(!0),j(U,null,M(o.value,(e,t)=>(L(),q(UJ,{key:`${e.seq??t}:${e.name}`,stage:e,"attempt-number":i.value.attempt,events:V(n).events,selected:s(e),onSelect:t=>c(e)},null,8,[`stage`,`attempt-number`,`events`,`selected`,`onSelect`]))),128))],8,qJ)):i.value.error?F(``,!0):(L(),q(V(mT),{key:2},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...u[1]||=[H(`No workflow steps recorded`,-1)]]),_:1})]),_:1})]),_:1}))])):(L(),q(V(mT),{key:1},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[H(`Attempt `+B(V(n).attemptNumber)+` is not recorded`,1)]),_:1}),A(V(gT),null,{default:I(()=>[H(`Recorded attempts: `+B(r.value.map(e=>e.attempt).join(`, `))+`.`,1)]),_:1})]),_:1})]),_:1})):(L(),q(V(mT),{key:0},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...u[0]||=[H(`No attempts recorded`,-1)]]),_:1})]),_:1})]),_:1}))],64))}}),YJ={class:`grid gap-4`,"aria-label":`Task details`},XJ={class:`flex flex-col gap-0.5`},ZJ=[`aria-current`,`onClick`],QJ={class:`flex-1`},$J={class:`text-xs text-fg-subtle`},eY={key:0,class:`px-3 pb-1 pl-7 text-xs text-fg-subtle`},tY=[`href`],nY=P({__name:`TaskRail`,setup(e){let t=IR(),n=Y(()=>[...t.attempts?.attempts??[]].reverse()),r=e=>NJ(e).kind,i=Y(()=>{let e=t.task;if(!e)return[];let n=[{label:`Workflow`,value:e.workflow||`none`}];return e.repo&&n.push({label:`Repository`,value:`${e.owner}/${e.repo}`,mono:!0,href:e.repo_url}),e.issue_url&&e.issue_number&&n.push({label:`Issue`,value:`#${e.issue_number}`,mono:!0,href:e.issue_url,arrow:!0}),e.tokens_used&&n.push({label:`Tokens`,value:uw(e.tokens_used),mono:!0}),n});return(e,a)=>(L(),j(`aside`,YJ,[n.value.length?(L(),q(V(uT),{key:0,title:`Attempts`,class:`mb-0`},{default:I(()=>[R(`ul`,XJ,[(L(!0),j(U,null,M(n.value,e=>(L(),j(`li`,{key:e.attempt},[R(`button`,{type:`button`,"aria-current":Number(e.attempt)===Number(V(t).attemptNumber)?`true`:void 0,class:z(V(W)(`flex w-full items-center gap-2.5 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-secondary`,Number(e.attempt)===Number(V(t).attemptNumber)&&`bg-secondary font-medium`)),onClick:n=>V(t).selectAttempt(Number(e.attempt))},[A(V(ST),{tone:r(e.status)},null,8,[`tone`]),R(`span`,QJ,`Attempt `+B(e.attempt),1),R(`span`,$J,B(e.status?V(NJ)(e.status).label:``),1)],10,ZJ),e.started_at?(L(),j(`p`,eY,[A(V(dw),{at:e.started_at},null,8,[`at`]),e.duration_ms?(L(),j(U,{key:0},[H(` · `+B(V(FT)(e.duration_ms)),1)],64)):F(``,!0)])):F(``,!0)]))),128))])]),_:1})):F(``,!0),A(V(uT),{title:`Stages`,class:`mb-0`},{default:I(()=>[A(JJ,{state:V(t).attempts},null,8,[`state`])]),_:1}),V(t).task?(L(),q(V(uT),{key:1,title:`Details`,class:`mb-0`},{default:I(()=>[A(V(XM),{rows:i.value},{value:I(({row:e})=>[e.href?(L(),j(`a`,{key:0,href:e.href,target:`_blank`,rel:`noreferrer`,class:`inline-flex items-center gap-0.5 hover:underline`},[H(B(e.value),1),e.arrow?(L(),q(V(Vl),{key:0,class:`size-3`,"aria-hidden":`true`})):F(``,!0)],8,tY)):(L(),j(U,{key:1},[H(B(e.value),1)],64))]),_:1},8,[`rows`])]),_:1})):F(``,!0)]))}}),rY={key:2},iY={class:`grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]`},aY={class:`flex min-w-0 flex-col gap-6`},oY=P({__name:`TaskDetailPage`,setup(e){let t=Dn(),n=Y(()=>String(t.params.id??``)),r=Y(()=>DR(n.value)),i=FR(r);return(e,t)=>r.value===null?(L(),q(RR,{key:0,kind:`invalid`,raw:n.value},null,8,[`raw`])):V(i).missing?(L(),q(RR,{key:1,kind:`missing`,raw:n.value},null,8,[`raw`])):(L(),j(`div`,rY,[A(dz,{id:n.value},null,8,[`id`]),A(Tz,{id:n.value},null,8,[`id`]),V(i).task?(L(),q(wz,{key:0,task:V(i).task,onDone:t[0]||=e=>V(i).refreshAll()},null,8,[`task`])):F(``,!0),R(`div`,iY,[R(`div`,aY,[V(i).task?.approval===`plan`&&V(i).task.plan?(L(),q(UR,{key:0,task:V(i).task,onDone:t[1]||=e=>V(i).refreshAll()},null,8,[`task`])):F(``,!0),A(V(ti),{class:`min-w-0`},{default:I(()=>[A(V(ri),null,{default:I(()=>[A(V(FO),{class:`gap-4`,"model-value":V(i).tab,"onUpdate:modelValue":V(i).setTab},{default:I(()=>[A(LR),A(jJ,{id:n.value},null,8,[`id`])]),_:1},8,[`model-value`,`onUpdate:modelValue`])]),_:1})]),_:1})]),A(nY,{class:`order-first lg:order-none`})])]))}}),sY={class:`flex flex-wrap items-center gap-2`},cY=`all`,lY=P({__name:`TaskFilters`,props:{status:{},search:{}},emits:[`update:status`,`update:search`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>n.status||cY);function a(e){r(`update:status`,typeof e==`string`&&e!==cY?e:``)}return(e,t)=>(L(),j(`div`,sY,[A(V(Q),{type:`search`,"model-value":n.search,"aria-label":`Search tasks by title or repository`,placeholder:`Search by title or repo…`,class:`w-55 max-sm:w-full`,"onUpdate:modelValue":t[0]||=e=>r(`update:search`,String(e))},null,8,[`model-value`]),A(V(Vu),{"model-value":i.value,"onUpdate:modelValue":a},{default:I(()=>[A(V(Gu),{"aria-label":`Filter by status`,class:`w-45 max-sm:w-full`},{default:I(()=>[A(V(Ku))]),_:1}),A(V(Hu),null,{default:I(()=>[A(V(Uu),null,{default:I(()=>[A(V(Wu),{value:cY},{default:I(()=>[...t[1]||=[H(`All statuses`,-1)]]),_:1}),A(V(Wu),{value:`needs_you`},{default:I(()=>[...t[2]||=[H(`Needs attention`,-1)]]),_:1}),(L(!0),j(U,null,M(V(vE)(),e=>(L(),q(V(Wu),{key:e.id,value:e.id},{default:I(()=>[H(B(e.label),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1})]),_:1},8,[`model-value`])]))}});function uY(e){return new Set([`needs_you`,...e.map(e=>e.id)])}function dY(e,t){return e&&uY(t).has(e)?e:``}function fY(e,t){return dY(e,t)}var pY=[`href`],mY=[`href`],hY={class:`inline-flex items-center gap-1`},gY=P({__name:`TaskTable`,props:{tasks:{},showRepo:{type:Boolean,default:!0},showIssue:{type:Boolean,default:!0}},emits:[`done`],setup(e,{emit:t}){let n=e,r=t,i=e=>e.title||`untitled task`,a=Y(()=>[...n.showRepo?[{id:`repo`,label:`Repo`,class:`whitespace-nowrap text-fg-muted`,sort:e=>`${e.owner??``}/${e.repo??``}`}]:[],...n.showIssue?[{id:`issue`,label:`Issue`,class:`text-fg-muted`,sort:e=>e.issue_number??0}]:[],{id:`title`,label:`Title`,fixed:!0,class:`w-full whitespace-normal`,sort:i},{id:`status`,label:`Status`,sort:e=>e.status??``},{id:`workflow`,label:`Workflow`,class:`text-fg-muted`,sort:e=>e.workflow??``},{id:`activity`,label:`Last activity`,class:`text-fg-muted`,sort:e=>Date.parse(e.updated_at??``)||0}]),o={needs_human:`needs attention`,transient:`transient`,terminal:`terminal`};function s(e){switch(e.park_class){case`transient`:return`Environmental failure: a requeue can succeed`;case`terminal`:return`Retry cannot succeed: archive or re-create the work`;default:return`An operator decision is needed`}}let c=e=>e.source!==`chat`&&e.source!==`test`,l=e=>c(e)&&e.issue_url&&e.issue_number?e.issue_url:``;return(e,t)=>(L(),q(V(qM),{columns:a.value,rows:n.tasks,"row-key":e=>String(e.id),"row-link":e=>`/tasks/${e.id}`,"row-label":e=>`Open the run detail for ${i(e)}`,"storage-key":`tasks`},{empty:I(()=>[K(e.$slots,`state`)]),"cell-repo":I(({row:e})=>[e.repo_url?(L(),j(`a`,{key:0,class:`hover:text-foreground hover:underline`,href:e.repo_url,target:`_blank`,rel:`noreferrer`,onClick:t[0]||=pt(()=>{},[`stop`]),onKeydown:t[1]||=pt(()=>{},[`stop`])},B(e.owner)+`/`+B(e.repo),41,pY)):(L(),j(U,{key:1},[H(B(e.owner)+`/`+B(e.repo),1)],64))]),"cell-issue":I(({row:e})=>[l(e)?(L(),j(`a`,{key:0,class:`hover:text-foreground hover:underline`,href:l(e),target:`_blank`,rel:`noreferrer`,onClick:t[2]||=pt(()=>{},[`stop`]),onKeydown:t[3]||=pt(()=>{},[`stop`])},`#`+B(e.issue_number),41,mY)):c(e)&&e.issue_number?(L(),j(U,{key:1},[H(`#`+B(e.issue_number),1)],64)):F(``,!0)]),"cell-title":I(({row:e})=>[A(V(Gr),{class:`inline-block min-w-40 hover:underline`,to:`/tasks/${e.id}`,onClick:t[4]||=pt(()=>{},[`stop`]),onKeydown:t[5]||=pt(()=>{},[`stop`])},{default:I(()=>[H(B(i(e)),1)]),_:2},1032,[`to`]),e.source===`test`?(L(),q(V(k),{key:0,variant:`outline`,class:`ml-2`,title:`Ran an unsaved draft; its deliveries were recorded, not sent`},{default:I(()=>[...t[7]||=[H(`Test`,-1)]]),_:1})):F(``,!0)]),"cell-status":I(({row:e})=>[R(`span`,hY,[A(V(k),{variant:V(_E)(e.status??``)},{default:I(()=>[H(B(V(gE)(e.status??``)),1)]),_:2},1032,[`variant`]),e.approval?(L(),q(V(k),{key:0,variant:`outline`},{default:I(()=>[H(B(V(wE)[e.approval]??e.approval),1)]),_:2},1024)):F(``,!0),e.status===`parked`&&o[e.park_class??``]?(L(),q(V(k),{key:1,variant:`outline`,title:s(e)},{default:I(()=>[H(B(o[e.park_class??``]),1)]),_:2},1032,[`title`])):F(``,!0)])]),"cell-workflow":I(({row:e})=>[H(B(e.workflow||`—`),1)]),"cell-activity":I(({row:e})=>[A(V(dw),{at:e.updated_at,title:e.created_at?`Created ${V(lw)(e.created_at)}`:void 0},null,8,[`at`,`title`])]),actions:I(({row:e})=>[A(aD,{task:e,onDone:t[6]||=e=>r(`done`,e)},null,8,[`task`])]),_:3},8,[`columns`,`rows`,`row-key`,`row-link`,`row-label`]))}}),_Y={key:0,class:`text-fg-muted flex items-center justify-center gap-2 p-6 text-sm`},vY=P({__name:`TasksState`,props:{kind:{},detail:{}},emits:[`clear`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>n.kind===`error`?{title:`Archie is not responding`,description:n.detail||``}:n.kind===`empty`?{title:`No tasks yet`,description:``}:n.kind===`no-match`?{title:`No matching tasks`,description:``}:{title:`Loading tasks…`,description:``});return(e,t)=>n.kind===`loading`?(L(),j(`div`,_Y,[A(V(uD)),H(` `+B(i.value.title),1)])):(L(),q(V(mT),{key:1},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[H(B(i.value.title),1)]),_:1}),i.value.description?(L(),q(V(gT),{key:0},{default:I(()=>[H(B(i.value.description),1)]),_:1})):F(``,!0)]),_:1}),n.kind===`no-match`?(L(),q(V(hT),{key:0},{default:I(()=>[A(V(X),{variant:`ghost`,size:`sm`,onClick:t[0]||=e=>r(`clear`)},{default:I(()=>[...t[1]||=[H(`Clear filters`,-1)]]),_:1})]),_:1})):F(``,!0)]),_:1}))}});function yY(){return typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches===!0}function bY(){return yY()?`auto`:`smooth`}var xY=P({__name:`TasksPage`,setup(e){let t=Dn(),n=En(),r=J(null),i=J(null),a=J(!1),o=J(null),s=J(``),c=Y(()=>typeof t.query.status==`string`?t.query.status:``),l=Y(()=>{let e=t.query.task,n=Number(typeof e==`string`?e:NaN);return Number.isSafeInteger(n)&&n>0?n:null}),u=Y(()=>fY(c.value,vE())),d=Y(()=>(r.value??[]).filter(e=>{let t=s.value.trim().toLowerCase();return!t||`${e.title??``} ${e.repo??``}`.toLowerCase().includes(t)})),f=Y(()=>{let e=d.value;return e.length<2||e.some(t=>t.repo!==e[0].repo)}),p=Y(()=>d.value.some(e=>e.source!==`chat`&&e.source!==`test`&&e.issue_number)),m=Y(()=>o.value?`error`:r.value===null?`loading`:r.value.length?`no-match`:`empty`);async function h(){o.value=null;let e=Math.min(Math.max(r.value?.length??0,100),500);try{let t=await Z.taskPage({status:u.value||void 0,limit:e});r.value=t.tasks,i.value=t.next}catch(e){o.value=String(e.message||e),r.value=null}}async function g(){if(i.value&&!a.value){a.value=!0;try{let e=await Z.taskPage({status:u.value||void 0,limit:100,cursor:i.value});r.value=[...r.value??[],...e.tasks],i.value=e.next}catch(e){o.value=String(e.message||e)}finally{a.value=!1}}}tp(`tasks`,()=>void h(),500),Be(h),N(u,()=>{r.value=null,h()});function _(e){let r=dY(e,vE()),i={...t.query};r?i.status=r:delete i.status,n.replace({query:i})}function v(){s.value=``,_(``)}let y=J(null);N([l,r],()=>{let e=l.value;e!==null&&r.value!==null&&y.value!==e&&(y.value=e,b(e))});async function b(e){await We(),requestAnimationFrame(()=>{let t=document.querySelector(`[data-row-key="${e}"]`);t&&(t.focus({preventScroll:!0}),t.scrollIntoView?.({block:`center`,behavior:bY()}))})}return(e,t)=>(L(),j(U,null,[A(rt,{title:`Tasks`},{default:I(()=>[o.value?F(``,!0):(L(),q(lY,{key:0,status:u.value,search:s.value,"onUpdate:status":_,"onUpdate:search":t[0]||=e=>s.value=e},null,8,[`status`,`search`]))]),_:1}),A(V(ti),null,{default:I(()=>[A(V(ri),{class:`flex flex-col gap-3`},{default:I(()=>[o.value?(L(),q(vY,{key:0,kind:`error`,detail:o.value},null,8,[`detail`])):(L(),j(U,{key:1},[A(gY,{tasks:d.value,"show-repo":f.value,"show-issue":p.value,onDone:h},{state:I(()=>[A(vY,{kind:m.value,onClear:v},null,8,[`kind`])]),_:1},8,[`tasks`,`show-repo`,`show-issue`]),i.value?(L(),q(V(X),{key:0,variant:`outline`,class:`self-center`,disabled:a.value,onClick:g},{default:I(()=>[...t[1]||=[H(`Load more`,-1)]]),_:1},8,[`disabled`])):F(``,!0)],64))]),_:1})]),_:1})],64))}}),SY={implement:`Implement`,tdd:`TDD`,feasibility:`Feasibility check`};function CY(e){return e&&SY[e]?SY[e]:e?e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `):`Unknown`}function wY(e,t){return!t||!e?0:Math.round(e/t*100)}function TY(e){if(!e)return`–`;if(e<1e3)return`${e} ms`;let t=e/1e3;return t<60?`${t.toFixed(1)} s`:`${(t/60).toFixed(1)} min`}function EY(e){return[...e].sort((e,t)=>(t.avg_ms||0)-(e.avg_ms||0))}function DY(e){return[...e].filter(e=>e.errors>0).sort((e,t)=>t.errors-e.errors)}function OY(e){return Math.max(...e.map(e=>e.avg_ms||0),1)}var kY={ok:`bg-ok`,warn:`bg-warn`,danger:`bg-danger`,info:`bg-info`,idle:`bg-idle`},AY={class:`mt-2 h-[5px] w-[140px] overflow-hidden rounded-full bg-border`},jY=P({__name:`WorkflowBar`,props:{fraction:{},kind:{default:`ok`}},setup(e){let t=e,n=Y(()=>`${Math.min(100,Math.max(0,t.fraction))}%`);return(e,r)=>(L(),j(`div`,AY,[R(`div`,{class:z([`h-full rounded-full transition-[width]`,V(kY)[t.kind]]),style:et(`width:${n.value}`)},null,6)]))}}),MY={class:`text-sm`},NY=P({__name:`SlowestStagesCard`,props:{stages:{}},setup(e){let t=e,n=Y(()=>EY(t.stages)),r=Y(()=>OY(t.stages));return(e,t)=>(L(),q(V(uT),{title:`Slowest stages`,class:`mb-0`},{default:I(()=>[A(V(TT),null,{default:I(()=>[A(V(AT),null,{default:I(()=>[A(V(OT),null,{default:I(()=>[A(V(kT),null,{default:I(()=>[...t[0]||=[H(`Workflow`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[1]||=[H(`Stage`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[2]||=[H(`Runs`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[3]||=[H(`Avg duration`,-1)]]),_:1})]),_:1})]),_:1}),A(V(ET),null,{default:I(()=>[(L(!0),j(U,null,M(n.value,(e,t)=>(L(),q(V(OT),{key:t},{default:I(()=>[A(V(DT),null,{default:I(()=>[H(B(V(CY)(e.workflow)),1)]),_:2},1024),A(V(DT),{class:`font-medium`},{default:I(()=>[H(B(e.stage),1)]),_:2},1024),A(V(DT),null,{default:I(()=>[H(B(e.runs),1)]),_:2},1024),A(V(DT),null,{default:I(()=>[R(`div`,MY,B(V(TY)(e.avg_ms)),1),A(jY,{fraction:V(wY)(e.avg_ms||0,r.value),kind:`info`},null,8,[`fraction`])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]),_:1}))}}),PY={class:`text-sm`},FY=P({__name:`StageFailuresCard`,props:{stages:{}},setup(e){let t=e,n=Y(()=>DY(t.stages));return(e,t)=>(L(),q(V(uT),{title:`Most failures`,class:`mb-0`},{default:I(()=>[n.value.length?(L(),q(V(TT),{key:1},{default:I(()=>[A(V(AT),null,{default:I(()=>[A(V(OT),null,{default:I(()=>[A(V(kT),null,{default:I(()=>[...t[1]||=[H(`Workflow`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[2]||=[H(`Stage`,-1)]]),_:1}),A(V(kT),null,{default:I(()=>[...t[3]||=[H(`Failures`,-1)]]),_:1})]),_:1})]),_:1}),A(V(ET),null,{default:I(()=>[(L(!0),j(U,null,M(n.value,(e,t)=>(L(),q(V(OT),{key:t},{default:I(()=>[A(V(DT),null,{default:I(()=>[H(B(V(CY)(e.workflow)),1)]),_:2},1024),A(V(DT),{class:`font-medium`},{default:I(()=>[H(B(e.stage),1)]),_:2},1024),A(V(DT),null,{default:I(()=>[R(`div`,PY,B(e.errors)+` of `+B(e.runs),1),A(jY,{fraction:V(wY)(e.errors,e.runs),kind:`danger`},null,8,[`fraction`])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})):(L(),q(V(mT),{key:0},{default:I(()=>[A(V(_T),null,{default:I(()=>[A(V(yT),null,{default:I(()=>[...t[0]||=[H(`No failures recorded`,-1)]]),_:1})]),_:1})]),_:1}))]),_:1}))}}),IY={class:`space-y-5 p-4 text-sm`},LY={class:`flex items-center gap-2`},RY={key:0,class:`text-xs text-fg-muted`},zY={class:`ml-auto text-xs text-fg-muted`},BY={key:0,class:`rounded-md bg-danger-soft p-3 break-words whitespace-pre-wrap text-danger`},VY={key:1,role:`alert`,class:`text-danger`},HY={key:0,class:`font-medium`},UY={key:1,class:`text-xs text-fg-muted`},WY={class:`flex items-center gap-2 text-xs`},GY={class:`font-mono`},KY={key:0,class:`break-words whitespace-pre-wrap`},qY={key:0,class:`break-words whitespace-pre-wrap`},JY={class:`text-xs text-fg-muted`},YY={key:2,class:`space-y-1`},XY={class:`text-caption font-medium uppercase text-fg-muted`},ZY={class:`divide-y divide-border rounded-md border border-border`},QY={class:`flex justify-between gap-2 text-xs`},$Y={class:`font-mono`},eX={key:0,class:`mt-1 break-words whitespace-pre-wrap text-xs text-fg-muted`},tX={key:3,class:`text-xs text-fg-muted`},nX={key:4,class:`text-xs text-fg-muted`},rX={key:2,class:`space-y-1`},iX={class:`divide-y divide-border rounded-md border border-border`},aX={class:`space-y-3`},oX={key:0,role:`alert`,class:`text-danger`},sX={class:`space-y-2`},cX=P({__name:`StepRun`,props:{task:{},attempt:{},stage:{},stages:{}},setup(e){let t=e,n=J([]),r=J(),i=J(),a=J(``),o=J(``),s=J(!1),c=Y(()=>`${t.task.id}/${t.attempt}/${t.stage.id??t.stage.name}`),l=0,u,d=!1,f=!1;async function p(){if(!t.attempt)return;if(d){f=!0;return}d=!0;let e=l,s=String(t.task.id),c={attempt:t.attempt},u=await Promise.allSettled([Z.taskDebug(s,c),Z.taskChanges(s,c),Z.taskLogs(s,{...c,stage:t.stage.name})]);if(e!==l)return;let[m,h,g]=u;a.value=m.status===`rejected`?`Could not load step activity`:``,m.status===`fulfilled`&&(n.value=m.value.events??[]),o.value=h.status===`rejected`?`Could not load captured changes`:``,h.status===`fulfilled`&&(r.value=h.value),i.value=g.status===`fulfilled`?g.value:null,d=!1,f&&(f=!1,p())}N(c,()=>{l++,d=!1,f=!1,n.value=[],r.value=void 0,i.value=void 0,a.value=``,o.value=``,s.value=!1,p()},{immediate:!0}),N(()=>t.stage.status,e=>{clearInterval(u),p(),e===`running`&&(u=setInterval(()=>void p(),2e3))},{immediate:!0}),tp(`tasks`,()=>void p(),300),Ue(()=>{l++,clearInterval(u)});let m=Y(()=>NJ(t.stage.status)),h=Y(()=>new Set([t.stage.name,...(t.stage.agents??[]).map(e=>e.name.split(`/`).at(-1)??e.name)])),g=Y(()=>t.stages.find(e=>e.name===t.stage.name&&e.started_at&&t.stage.started_at&&e.started_at>t.stage.started_at)?.started_at);function _(e){if(!t.stage.started_at||!e)return t.stages.filter(e=>e.name===t.stage.name).length===1;let n=new Date(e).getTime();return n>=Date.parse(t.stage.started_at)&&(!t.stage.finished_at||n<=Date.parse(t.stage.finished_at))&&(!g.value||nn.value.filter(e=>Number(e.attempt)===t.attempt?e.data?.step_id==null?h.value.has(e.stage??``)&&_(e.at):Number(e.data.step_id)===t.stage.id:!1).sort((e,t)=>String(e.at??``).localeCompare(String(t.at??``)))),y=Y(()=>v.value.filter(e=>e.kind===`delivery_recorded`)),b=Y(()=>{let e=t.stage.agents??[];return[...new Set([``,...e.map(e=>e.name.includes(`/`)?e.name.split(`/`)[0]:``),...v.value.map(e=>String(e.data?.branch??``))])].map(t=>({branch:t,agents:e.filter(e=>(e.name.includes(`/`)?e.name.split(`/`)[0]:``)===t),reports:v.value.filter(e=>e.kind===`agent_finish`&&String(e.data?.branch??``)===t),tools:v.value.filter(e=>e.kind===`tool_call`&&String(e.data?.branch??``)===t)})).filter(e=>e.agents.length||e.reports.length||e.tools.length)}),x=Y(()=>(r.value?.captures??[]).filter(e=>e.stage===t.stage.name&&_(e.captured_at))),S=Y(()=>i.value?{...i.value,entries:(i.value.entries??[]).filter(e=>_(e.time))}:i.value);return(t,n)=>(L(),j(`div`,IY,[R(`div`,LY,[A(V(k),{variant:m.value.kind},{default:I(()=>[H(B(m.value.label),1)]),_:1},8,[`variant`]),e.stage.duration_ms==null?F(``,!0):(L(),j(`span`,RY,B(V(FT)(e.stage.duration_ms)),1)),R(`span`,zY,`Attempt `+B(e.attempt),1)]),e.stage.error?(L(),j(`p`,BY,B(e.stage.error),1)):F(``,!0),a.value?(L(),j(`p`,VY,B(a.value),1)):F(``,!0),(L(!0),j(U,null,M(b.value,e=>(L(),j(`section`,{key:e.branch,class:`space-y-3`},[e.branch?(L(),j(`h3`,HY,B(e.branch),1)):b.value.length>1?(L(),j(`p`,UY,`Activity without branch attribution`)):F(``,!0),(L(!0),j(U,null,M(e.agents,e=>(L(),j(`div`,{key:e.id,class:`space-y-1`},[R(`div`,WY,[R(`span`,GY,B(e.name.split(`/`).at(-1)),1),A(V(k),{variant:V(NJ)(e.status).kind},{default:I(()=>[H(B(e.status),1)]),_:2},1032,[`variant`])]),e.detail?(L(),j(`p`,KY,B(e.detail),1)):F(``,!0)]))),128)),(L(!0),j(U,null,M(e.reports,(t,n)=>(L(),j(`div`,{key:n,class:`space-y-1`},[t.detail&&!e.agents.some(e=>e.detail===t.detail)?(L(),j(`p`,qY,B(t.detail),1)):F(``,!0),R(`p`,JY,`Agent's own report · `+B(V(RT)(t).title),1)]))),128)),e.tools.length?(L(),j(`div`,YY,[R(`h4`,XY,`Tool calls · `+B(e.tools.length),1),R(`ol`,ZY,[(L(!0),j(U,null,M(s.value?e.tools:e.tools.slice(0,12),(e,t)=>(L(),j(`li`,{key:t,class:`px-3 py-2`},[R(`div`,QY,[R(`span`,$Y,B(e.data?.tool),1),R(`span`,{class:z(e.data?.failed?`text-danger`:`text-fg-muted`)},B(e.data?.failed?`Failed`:`Returned`),3)]),e.detail?(L(),j(`p`,eX,B(e.detail),1)):F(``,!0)]))),128))]),e.tools.length>12?(L(),q(V(X),{key:0,type:`button`,variant:`link`,size:`xs`,class:`px-0`,onClick:n[0]||=e=>s.value=!s.value},{default:I(()=>[H(B(s.value?`Show first 12`:`Show all ${e.tools.length}`),1)]),_:2},1024)):F(``,!0)])):F(``,!0),e.reports.length?(L(),j(`p`,tX,B(e.reports.map(e=>V(RT)(e).detail).filter(Boolean).join(` · `)),1)):e.agents.length?(L(),j(`p`,nX,B(e.agents.reduce((e,t)=>e+t.tokens_used,0).toLocaleString())+` tokens recorded`,1)):F(``,!0)]))),128)),y.value.length?(L(),j(`section`,rX,[n[1]||=R(`h3`,{class:`text-caption font-medium uppercase text-fg-muted`},`Not delivered in a test run`,-1),R(`ul`,iX,[(L(!0),j(U,null,M(y.value,(e,t)=>(L(),j(`li`,{key:t,class:`px-3 py-2 text-xs break-words whitespace-pre-wrap`},B(e.detail),1))),128))])])):F(``,!0),R(`section`,aX,[n[2]||=R(`h3`,{class:`text-caption font-medium uppercase text-fg-muted`},`Captured changes`,-1),o.value?(L(),j(`p`,oX,B(o.value),1)):F(``,!0),(L(!0),j(U,null,M(x.value,(t,n)=>(L(),q(pB,{key:n,capture:t,task:e.task},null,8,[`capture`,`task`]))),128))]),R(`section`,sX,[n[3]||=R(`h3`,{class:`text-caption font-medium uppercase text-fg-muted`},`Log`,-1),A(kJ,{state:S.value,attempt:e.attempt,filterable:!1},null,8,[`state`,`attempt`])])]))}}),lX=Symbol.for(`yaml.alias`),uX=Symbol.for(`yaml.document`),dX=Symbol.for(`yaml.map`),fX=Symbol.for(`yaml.pair`),pX=Symbol.for(`yaml.scalar`),mX=Symbol.for(`yaml.seq`),hX=Symbol.for(`yaml.node.type`),gX=e=>!!e&&typeof e==`object`&&e[hX]===lX,_X=e=>!!e&&typeof e==`object`&&e[hX]===uX,vX=e=>!!e&&typeof e==`object`&&e[hX]===dX,yX=e=>!!e&&typeof e==`object`&&e[hX]===fX,bX=e=>!!e&&typeof e==`object`&&e[hX]===pX,xX=e=>!!e&&typeof e==`object`&&e[hX]===mX;function SX(e){if(e&&typeof e==`object`)switch(e[hX]){case dX:case mX:return!0}return!1}function CX(e){if(e&&typeof e==`object`)switch(e[hX]){case lX:case dX:case pX:case mX:return!0}return!1}var wX=e=>(bX(e)||SX(e))&&!!e.anchor,TX=Symbol(`break visit`),EX=Symbol(`skip children`),DX=Symbol(`remove node`);function OX(e,t){let n=AX(t);_X(e)?kX(null,e.contents,n,Object.freeze([e]))===DX&&(e.contents=null):kX(null,e,n,Object.freeze([]))}OX.BREAK=TX,OX.SKIP=EX,OX.REMOVE=DX;function kX(e,t,n,r){let i=jX(e,t,n,r);if(CX(i)||yX(i))return MX(e,r,i),kX(e,i,n,r);if(typeof i!=`symbol`){if(SX(t)){r=Object.freeze(r.concat(t));for(let e=0;ee.replace(/[!,[\]{}]/g,e=>NX[e]),FX=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+PX(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&CX(e.contents)){let t={};OX(e.contents,(e,n)=>{CX(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)(i!==`!!`||a!==`tag:yaml.org,2002:`)&&(!e||r.some(e=>e.startsWith(a)))&&t.push(`%TAG ${i} ${a}`);return t.join(` `)}};FX.defaultYaml={explicit:!1,version:`1.2`},FX.defaultTags={"!!":`tag:yaml.org,2002:`};function IX(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function LX(e){let t=new Set;return OX(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function RX(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function zX(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=LX(e);let a=RX(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(bX(t.node)||SX(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function BX(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;tVX(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!wX(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var HX=class{constructor(e){Object.defineProperty(this,hX,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!_X(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=VX(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?BX(i,{"":o},``,o):o}},UX=class extends HX{constructor(e){super(lX),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],OX(e,{Node:(e,t)=>{(gX(t)||wX(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(VX(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=WX(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(IX(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function WX(e,t,n){if(gX(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(SX(t)){let r=0;for(let i of t.items){let t=WX(e,i,n);t>r&&(r=t)}return r}if(yX(t)){let r=WX(e,t.key,n),i=WX(e,t.value,n);return Math.max(r,i)}return 1}var GX=e=>!e||typeof e!=`function`&&typeof e!=`object`,KX=class extends HX{constructor(e){super(pX),this.value=e}toJSON(e,t){return t?.keep?this.value:VX(this.value,e,t)}toString(){return String(this.value)}};KX.BLOCK_FOLDED=`BLOCK_FOLDED`,KX.BLOCK_LITERAL=`BLOCK_LITERAL`,KX.PLAIN=`PLAIN`,KX.QUOTE_DOUBLE=`QUOTE_DOUBLE`,KX.QUOTE_SINGLE=`QUOTE_SINGLE`;var qX=`tag:yaml.org,2002:`;function JX(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function YX(e,t,n){if(_X(e)&&(e=e.contents),CX(e))return e;if(yX(e)){let t=n.schema[dX].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new UX(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=qX+t.slice(2));let l=JX(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new KX(e);return c&&(c.node=t),t}l=e instanceof Map?o[dX]:Symbol.iterator in Object(e)?o[mX]:o[dX]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new KX(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function XX(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return YX(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var ZX=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,QX=class extends HX{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>CX(t)||yX(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(ZX(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(SX(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,XX(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(SX(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&bX(i)?i.value:i:SX(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!yX(t))return!1;let n=t.value;return n==null||e&&bX(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return SX(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(SX(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,XX(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},$X=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function eZ(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var tZ=(e,t,n)=>e.endsWith(` `)?eZ(n,t):n.includes(` `)?` @@ -294,7 +294,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\ `)[0]?.trim()||`invalid YAML`}function i0(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function a0(e){return typeof e==`string`&&e.trim()!==``}var o0={class:`space-y-4 px-3 py-3`},s0={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},c0={key:1,class:`space-y-3`},l0={key:0,class:`block space-y-1.5`},u0=[`id`],d0=[`value`],f0={class:`text-xs font-medium text-fg-muted`},p0={class:`flex items-center gap-2`},m0={key:1,role:`alert`,class:`text-xs text-danger`},h0={key:2,class:`space-y-1.5`},g0=[`title`],_0={key:4,class:`flex flex-wrap items-center gap-1 pt-0.5`},v0={key:0,class:`divide-y divide-border rounded-md border border-border`},y0=[`title`],b0={key:0,class:`space-y-3`},x0={class:`text-label`},S0={key:0,class:`text-danger`},C0={class:`ml-2 text-xs text-fg-subtle`},w0={key:1,class:`space-y-3`},T0={class:`text-label`},E0={class:`ml-2 text-xs text-fg-subtle`},D0=[`title`],O0={key:0,class:`text-xs text-danger`},k0={class:`space-y-1.5`},A0={key:0,role:`alert`,class:`text-xs text-danger`},j0={class:`divide-y divide-border rounded-md border border-border`},M0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},N0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},P0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},F0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},I0=[`for`],L0=P({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{},workflows:{},modelAliases:{}},emits:[`update:yaml`],setup(e,{emit:t}){let n=we(),r=e,i=t,a=Y(()=>i1(r.yaml,r.path)??{}),o=Y(()=>n1(a.value)),s=Y(()=>o.value?.kind??(typeof a.value.type==`string`?a.value.type:``)),c=Y(()=>o.value?.branches.map(([e])=>e)??[]),l=Y(()=>s.value===`parallel`?2:1);function u(e){i(`update:yaml`,a1(r.yaml,r.path,{...a.value,switch:{...a.value.switch,on:e}}))}let d=J(``),f=J(``);function p(e,t,n=``){try{let a=e===`add`?l1(r.yaml,r.path,t):e===`rename`?u1(r.yaml,r.path,t,n):d1(r.yaml,r.path,t);i(`update:yaml`,a),d.value=``,f.value=``}catch(e){f.value=String(e.message)}}let m=Y(()=>r.vocabulary.find(e=>e.name===s.value)),h=Y(()=>typeof a.value.settings==`object`&&a.value.settings!==null?a.value.settings:{}),g=Y(()=>g1(r.yaml,r.path)),_=Y(()=>K1(a.value)),v=Y(()=>m.value?.settings&&a.value.settings?J1(a.value.settings,m.value.settings,`settings`):``),y=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],b=/mission|body|detail|plan|rules/;function x(e,t){return[`workflow.call`,`workflow.handoff`].includes(s.value)&&e===`workflow`||s.value===`human.approve`&&e===`then`?`workflow`:s.value===`agent.run`&&e===`model`?`select`:t.type===`string`?t.enum?`select`:b.test(e)?`text`:`line`:t.type===`boolean`?`boolean`:t.type===`integer`||t.type===`number`?`number`:t.type===`array`&&t.items?.type===`string`?`lines`:`yaml`}let S=Y(()=>{let e=Object.entries(m.value?.settings?.properties??{}).filter(([e])=>s.value!==`workflow.call`||![`inputs`,`outputs`].includes(e)).map(([e,t])=>({key:e,schema:t,kind:x(e,t),options:s.value===`agent.run`&&e===`model`?r.modelAliases:t.enum??[]})),t=e.filter(e=>y.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>y.indexOf(e.key)-y.indexOf(t.key))[0],n=e.filter(e=>e!==t);return{lead:t,compact:n.filter(e=>[`workflow`,`select`,`line`,`number`,`boolean`].includes(e.kind)),long:n.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}}),C=J(!S.value.lead&&!o.value),w=e=>[{value:``,label:`Default`},...e.map(e=>({value:e,label:e}))];function T(e){let{id:t,type:n,...a}=e;i(`update:yaml`,a1(r.yaml,r.path,{id:t,type:n,...a}))}function ee(e,t){T({...a.value,[e]:t})}function E(e){let t={...a.value.retry,...e};ee(`retry`,t.attempts===void 0&&!t.backoff?void 0:{...t,attempts:t.attempts??1})}function D(e,t){let n={...h.value,[e]:t};s.value===`workflow.call`&&e===`wait`&&t!==!0&&delete n.outputs,T({...a.value,settings:n})}function te(e,t){let n={...h.value,[e]:t};s.value===`workflow.call`&&t!==h.value[e]&&(delete n.inputs,delete n.outputs),T({...a.value,settings:n})}let O=Y(()=>r.workflows.find(e=>e.id===h.value.workflow)),ne=Y(()=>Object.entries(v1(O.value?.yaml??``,`inputs`)??{})),re=Y(()=>Object.entries(v1(O.value?.yaml??``,`outputs`)??{})),ae=Y(()=>Object.entries(v1(r.yaml,`inputs`)??{})),k=Y(()=>Object.entries(v1(r.yaml,`outputs`)??{})),oe=Y(()=>h.value.inputs??{}),se=Y(()=>h.value.outputs??{}),ce=e=>typeof e==`string`&&e.startsWith(`inputs.`),le=e=>[`object`,`array`].includes(e.type??``),ue=e=>oe.value[e]===void 0?``:String(oe.value[e]);function de(e,t,n){D(`inputs`,{...oe.value,[e]:t===``?void 0:ce(t)?t:hD(t,n??`string`)})}let fe=(e,t,n)=>e.filter(([,e])=>e.type===t.type||e.type===`any`||t.type===`any`).map(([e])=>({value:`${n}.${e}`,label:e})),pe=J(null);function me(e){let t=pe.value??S.value.lead?.key;if(!t)return;let n=typeof h.value[t]==`string`?h.value[t]:``,r=`{{ steps.${e}.summary }}`;D(t,n?`${n.trimEnd()} ${r}`:r)}let he=J({});function ge(e,t){try{D(e,t.trim()?Q$(t):void 0),he.value={...he.value,[e]:``}}catch(t){he.value={...he.value,[e]:String(t.message).split(` `)[0]}}}let _e=e=>e===void 0?``:$$(e).trimEnd(),ve=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),ye=e=>typeof h.value[e]==`string`?h.value[e]:``,N=[{value:``,label:`Park the task`},{value:`continue`,label:`Continue`}];return(t,r)=>(L(),j(`div`,o0,[v.value?(L(),j(`p`,s0,B(v.value),1)):F(``,!0),o.value?(L(),j(`section`,c0,[s.value===`switch`?(L(),j(`label`,l0,[r[15]||=R(`span`,{class:`text-xs font-medium text-fg-muted`,title:`The value whose case runs; a case named default runs when none matches`},`Switch on`,-1),A(V(Q),{"model-value":o.value.on,class:`font-mono`,placeholder:`steps.assess.result.fit`,list:`${V(n)}-switch-on`,onChange:r[0]||=e=>u(e.target.value.trim())},null,8,[`model-value`,`list`]),R(`datalist`,{id:`${V(n)}-switch-on`},[(L(!0),j(U,null,M(g.value,e=>(L(),j(`option`,{key:e,value:`steps.${e}.result.`},null,8,d0))),128))],8,u0)])):F(``,!0),R(`div`,f0,B(s.value===`switch`?`Cases`:`Branches`),1),(L(!0),j(U,null,M(c.value,e=>(L(),j(`div`,{key:e,class:`flex items-center gap-2`},[A(V(Q),{"model-value":e,class:z(s.value===`switch`&&`font-mono`),"aria-label":`${s.value===`switch`?`Case`:`Branch`} ${e}`,onChange:t=>p(`rename`,e,t.target.value.trim())},null,8,[`model-value`,`class`,`aria-label`,`onChange`]),A(V(X),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e}`,disabled:c.value.length<=l.value,onClick:t=>p(`delete`,e)},{default:I(()=>[A(V(Mu))]),_:1},8,[`aria-label`,`disabled`,`onClick`])]))),128)),R(`div`,p0,[A(V(Q),{modelValue:d.value,"onUpdate:modelValue":r[1]||=e=>d.value=e,"aria-label":s.value===`switch`?`New case value`:`New branch name`,placeholder:s.value===`switch`?`Value, or default`:`Branch name`,onKeydown:r[2]||=gt(pt(e=>p(`add`,d.value.trim()),[`prevent`]),[`enter`])},null,8,[`modelValue`,`aria-label`,`placeholder`]),A(V(X),{type:`button`,size:`icon-sm`,variant:`outline`,"aria-label":s.value===`switch`?`Add case`:`Add branch`,disabled:!d.value.trim(),onClick:r[3]||=e=>p(`add`,d.value.trim())},{default:I(()=>[A(V(Eu))]),_:1},8,[`aria-label`,`disabled`])]),f.value?(L(),j(`p`,m0,B(f.value),1)):F(``,!0)])):F(``,!0),S.value.lead?(L(),j(`section`,h0,[R(`div`,{class:`flex items-center gap-1 text-xs font-medium text-fg-muted`,title:S.value.lead.schema.description},[H(B(ve(S.value.lead.key,S.value.lead.schema))+` `,1),S.value.lead.schema.description?(L(),q(V(tu),{key:0,class:`size-3 text-fg-subtle`})):F(``,!0)],8,g0),S.value.lead.kind===`workflow`?(L(),q(z1,{key:0,editable:s.value!==`workflow.call`,value:ye(S.value.lead.key),workflows:e.workflows,label:ve(S.value.lead.key,S.value.lead.schema),onPick:r[4]||=e=>te(S.value.lead.key,e)},null,8,[`editable`,`value`,`workflows`,`label`])):S.value.lead.kind===`select`?(L(),q(I1,{key:1,class:`w-full`,"model-value":ye(S.value.lead.key),options:w(S.value.lead.options),"aria-label":ve(S.value.lead.key,S.value.lead.schema),"onUpdate:modelValue":r[5]||=e=>D(S.value.lead.key,e||void 0)},null,8,[`model-value`,`options`,`aria-label`])):S.value.lead.kind===`text`?(L(),q(V(Jd),{key:2,"model-value":ye(S.value.lead.key),class:`min-h-32 text-label leading-relaxed`,onFocus:r[6]||=e=>pe.value=S.value.lead.key,"onUpdate:modelValue":r[7]||=e=>D(S.value.lead.key,String(e))},null,8,[`model-value`])):(L(),q(V(Q),{key:3,"model-value":ye(S.value.lead.key),onFocus:r[8]||=e=>pe.value=S.value.lead.key,"onUpdate:modelValue":r[9]||=e=>D(S.value.lead.key,String(e))},null,8,[`model-value`])),g.value.length&&S.value.lead.kind!==`select`?(L(),j(`div`,_0,[r[16]||=R(`span`,{class:`text-caption text-fg-subtle`},`Insert`,-1),(L(!0),j(U,null,M(g.value,e=>(L(),q(V(X),{key:e,type:`button`,variant:`outline`,size:`xs`,class:`font-mono`,title:`{{ steps.${e}.summary }}`,onClick:t=>me(e)},{default:I(()=>[H(B(e),1)]),_:2},1032,[`title`,`onClick`]))),128))])):F(``,!0)])):F(``,!0),A(V(X),{type:`button`,variant:`ghost`,size:`xs`,class:`-ml-2 text-fg-muted aria-expanded:bg-transparent`,"aria-expanded":C.value,onClick:r[10]||=e=>C.value=!C.value},{default:I(()=>[A(V(ie),{"data-icon":`inline-start`,class:z([`transition-transform`,!C.value&&`-rotate-90`])},null,8,[`class`]),r[17]||=H(`More `,-1)]),_:1},8,[`aria-expanded`]),C.value?(L(),j(U,{key:3},[S.value.compact.length?(L(),j(`section`,v0,[(L(!0),j(U,null,M(S.value.compact,t=>(L(),j(`div`,{key:t.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[R(`span`,{class:`flex flex-1 items-center gap-1 text-label`,title:t.schema.description},[H(B(ve(t.key,t.schema))+` `,1),t.schema.description?(L(),q(V(tu),{key:0,class:`size-3 text-fg-subtle`})):F(``,!0)],8,y0),t.kind===`workflow`?(L(),q(z1,{key:0,editable:s.value!==`workflow.call`,class:`max-w-48`,value:ye(t.key),workflows:e.workflows,label:ve(t.key,t.schema),onPick:e=>te(t.key,e)},null,8,[`editable`,`value`,`workflows`,`label`,`onPick`])):t.kind===`boolean`?(L(),q(V(iT),{key:1,"model-value":h.value[t.key]===!0,"onUpdate:modelValue":e=>D(t.key,e||void 0)},null,8,[`model-value`,`onUpdate:modelValue`])):t.kind===`select`?(L(),q(I1,{key:2,class:`w-40`,"model-value":ye(t.key),options:w(t.options),"aria-label":ve(t.key,t.schema),"onUpdate:modelValue":e=>D(t.key,e||void 0)},null,8,[`model-value`,`options`,`aria-label`,`onUpdate:modelValue`])):t.kind===`number`?(L(),q(V(Q),{key:3,type:`number`,class:`h-8 w-24 text-right text-label`,"model-value":h.value[t.key]??``,"onUpdate:modelValue":e=>D(t.key,String(e)===``?void 0:Number(String(e)))},null,8,[`model-value`,`onUpdate:modelValue`])):(L(),q(V(Q),{key:4,class:`h-8 w-40 text-label`,"model-value":ye(t.key),onFocus:e=>pe.value=t.key,"onUpdate:modelValue":e=>D(t.key,String(e))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`]))]))),128))])):F(``,!0),s.value===`workflow.call`&&O.value?(L(),j(U,{key:1},[ne.value.length?(L(),j(`section`,b0,[r[18]||=R(`div`,{class:`text-xs font-medium text-fg-muted`},`Inputs`,-1),(L(!0),j(U,null,M(ne.value,([e,t])=>(L(),j(`div`,{key:e,class:`space-y-1.5`},[R(`div`,x0,[H(B(e),1),t.required?(L(),j(`span`,S0,` *`)):F(``,!0),R(`span`,C0,B(t.type),1)]),le(t)?F(``,!0):(L(),q(I1,{key:0,class:`w-full`,"aria-label":`${e} source`,"model-value":ce(oe.value[e])?`input`:`value`,options:[{value:`value`,label:`Value`},{value:`input`,label:`Caller input`}],"onUpdate:modelValue":t=>de(e,t===`input`?`inputs.`:``)},null,8,[`aria-label`,`model-value`,`onUpdate:modelValue`])),ce(oe.value[e])||le(t)?(L(),q(I1,{key:1,class:`w-full`,"aria-label":e,placeholder:`Choose input`,"model-value":ue(e)===`inputs.`?``:ue(e),options:fe(ae.value,t,`inputs`),"onUpdate:modelValue":t=>de(e,t)},null,8,[`aria-label`,`model-value`,`options`,`onUpdate:modelValue`])):t.type===`bool`?(L(),q(I1,{key:2,class:`w-full`,"aria-label":e,"model-value":ue(e),options:[{value:``,label:`Unset`},{value:`true`,label:`True`},{value:`false`,label:`False`}],"onUpdate:modelValue":n=>de(e,n,t.type)},null,8,[`aria-label`,`model-value`,`onUpdate:modelValue`])):(L(),q(V(Q),{key:3,"aria-label":e,type:t.type===`number`?`number`:`text`,step:`any`,"model-value":ue(e),"onUpdate:modelValue":n=>de(e,String(n),t.type)},null,8,[`aria-label`,`type`,`model-value`,`onUpdate:modelValue`]))]))),128))])):F(``,!0),re.value.length?(L(),j(`section`,w0,[r[19]||=R(`div`,{class:`text-xs font-medium text-fg-muted`},`Outputs`,-1),(L(!0),j(U,null,M(re.value,([e,t])=>(L(),j(`div`,{key:e,class:`space-y-1.5`},[R(`div`,T0,[H(B(e),1),R(`span`,E0,B(t.type),1)]),A(I1,{class:`w-full`,"aria-label":`${e} output`,disabled:h.value.wait!==!0,"model-value":se.value[e]??``,options:[{value:``,label:`Do not publish`},...fe(k.value,t,`outputs`)],"onUpdate:modelValue":t=>D(`outputs`,{...se.value,[e]:t||void 0})},null,8,[`aria-label`,`disabled`,`model-value`,`options`,`onUpdate:modelValue`])]))),128))])):F(``,!0)],64)):F(``,!0),(L(!0),j(U,null,M(S.value.long,e=>(L(),j(`section`,{key:e.key,class:`space-y-1.5`},[R(`div`,{class:`flex items-center gap-1 text-xs font-medium text-fg-muted`,title:e.schema.description},[H(B(ve(e.key,e.schema))+` `,1),e.schema.description?(L(),q(V(tu),{key:0,class:`size-3 text-fg-subtle`})):F(``,!0)],8,D0),e.kind===`text`?(L(),q(V(Jd),{key:0,"model-value":ye(e.key),class:`min-h-20 text-label`,onFocus:t=>pe.value=e.key,"onUpdate:modelValue":t=>D(e.key,String(t))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`])):e.kind===`lines`?(L(),q(V(Jd),{key:1,"model-value":Array.isArray(h.value[e.key])?h.value[e.key].join(` `):``,class:`min-h-16 font-mono text-xs`,placeholder:`One per line`,"onUpdate:modelValue":t=>D(e.key,String(t).split(` -`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(L(),j(U,{key:2},[A(V(Jd),{"model-value":_e(h.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>ge(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),he.value[e.key]?(L(),j(`span`,O0,B(he.value[e.key]),1)):F(``,!0)],64))]))),128)),R(`section`,k0,[_.value?(L(),j(`p`,A0,B(_.value),1)):F(``,!0),R(`div`,j0,[R(`label`,M0,[r[20]||=R(`span`,{class:`flex-1 text-label`,title:`Empty always runs. A field such as inputs.enabled, !inputs.skip, or steps.plan.result.ready == true`},`Run only when`,-1),A(V(Q),{class:`h-8 w-48 font-mono text-xs`,placeholder:`inputs.enabled`,"aria-invalid":_.value&&_.value.startsWith(`when`)?!0:void 0,"model-value":a.value.when??``,"onUpdate:modelValue":r[11]||=e=>ee(`when`,String(e))},null,8,[`aria-invalid`,`model-value`])]),R(`label`,N0,[r[21]||=R(`span`,{class:`flex-1 text-label`},`If it fails`,-1),A(I1,{class:`w-36`,"aria-label":`If it fails`,"model-value":a.value.on_failure??``,options:N,"onUpdate:modelValue":r[12]||=e=>ee(`on_failure`,e||void 0)},null,8,[`model-value`])]),R(`label`,P0,[r[22]||=R(`span`,{class:`flex-1 text-label`},`Attempts`,-1),A(V(Q),{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-8 w-20 text-right text-label`,"model-value":a.value.retry?.attempts??``,"onUpdate:modelValue":r[13]||=e=>E({attempts:String(e)===``?void 0:Number(String(e))})},null,8,[`model-value`])]),R(`div`,F0,[R(`label`,{for:`${V(n)}-backoff`,class:`flex-1 text-label`},`Retry backoff`,8,I0),A(V(Zw),{id:`${V(n)}-backoff`,"model-value":a.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":r[14]||=e=>E({backoff:e||void 0})},null,8,[`id`,`model-value`])])])])],64)):F(``,!0)]))}}),R0={class:`space-y-1.5`},z0={class:`flex items-center text-xs font-medium text-fg-muted`},B0={key:0,class:`divide-y divide-border rounded-md border border-border`},V0=P({__name:`SpecList`,props:{yaml:{},field:{}},emits:[`update:yaml`],setup(e,{emit:t}){let n=e,r=t,i=[`string`,`number`,`bool`,`object`,`array`,`any`].map(e=>({value:e,label:e})),a=Y(()=>Object.entries(v1(n.yaml,n.field)??{}));function o(e){r(`update:yaml`,y1(n.yaml,n.field,Object.fromEntries(e.filter(([e])=>e))))}function s(e,t,n){o(a.value.map((r,i)=>i===e?[t,n]:r))}function c(){let e=n.field.slice(0,-1),t=a.value.length+1;for(;a.value.some(([n])=>n===`${e}_${t}`);)t++;o([...a.value,[`${e}_${t}`,{type:`string`}]])}return(t,n)=>(L(),j(`section`,R0,[R(`div`,z0,[H(B(e.field===`inputs`?`Inputs`:`Outputs`)+` `,1),A(V(X),{type:`button`,variant:`ghost`,size:`xs`,class:`ml-auto`,onClick:c},{default:I(()=>[A(V(Eu),{"data-icon":`inline-start`}),n[0]||=H(`Add`,-1)]),_:1})]),a.value.length?(L(),j(`div`,B0,[(L(!0),j(U,null,M(a.value,([t,n],r)=>(L(),j(`div`,{key:r,class:`flex items-center gap-2 px-2 py-1.5`},[A(V(Q),{"model-value":t,class:`h-8 min-w-0 flex-1 font-mono text-xs`,"aria-label":`${e.field} name`,onChange:e=>s(r,e.target.value.trim(),n)},null,8,[`model-value`,`aria-label`,`onChange`]),A(I1,{"model-value":n.type??`string`,options:V(i),class:`w-24`,"aria-label":`${t} type`,"onUpdate:modelValue":e=>s(r,t,{...n,type:e})},null,8,[`model-value`,`options`,`aria-label`,`onUpdate:modelValue`]),A(V(iT),{"model-value":n.required===!0,title:n.required?`Required`:`Optional`,"aria-label":`${t} required`,"onUpdate:modelValue":e=>s(r,t,{...n,required:e||void 0})},null,8,[`model-value`,`title`,`aria-label`,`onUpdate:modelValue`]),A(V(X),{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Remove ${t}`,onClick:e=>o(a.value.filter((e,t)=>t!==r))},{default:I(()=>[A(V(Mu))]),_:1},8,[`aria-label`,`onClick`])]))),128))])):F(``,!0)]))}}),H0={class:`space-y-4 px-3 py-3`},U0={class:`divide-y divide-border rounded-md border border-border`},W0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},G0={key:0,role:`alert`,class:`px-3 py-2 text-xs text-danger`},K0={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},q0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},J0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},Y0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},X0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},Z0={class:`space-y-1.5`},Q0=`6f129e29-0e26-5246-99bd-74cb4496203b`,$0=P({__name:`WorkflowSettings`,props:{yaml:{}},emits:[`update:yaml`],setup(e,{emit:t}){let n=e,r=t,i=e=>{let t=v1(n.yaml,e);return typeof t==`string`?t:``};function a(e,t){r(`update:yaml`,y1(n.yaml,e,t))}let o=MT(),s=J([]),c=J(!0),l=J(``);async function u(){c.value=!0,l.value=``,s.value=[];try{await o.loadOrg();let e=await Z.orgAgents(o.homeOrg);s.value=e.agents.filter(e=>e.lifecycle===`active`),!i(`identity`)&&s.value.some(e=>e.id===Q0)&&a(`identity`,Q0)}catch(e){l.value=String(e.message||e)}finally{c.value=!1}}Be(u);let d=Y(()=>{let e=i(`identity`),t=s.value.map(e=>({value:e.id,label:e.display_name}));return e&&!c.value&&!s.value.some(t=>t.id===e)?[{value:e,label:`${e} (unknown)`,disabled:!0},...t]:t}),f=qw(),p=Y(()=>{let e=Object.keys(f.stateFor(`agent-profiles`).resource?.value??{}).sort(),t=i(`profile`);return t&&!e.includes(t)&&e.unshift(t),[{value:``,label:`Default`},...e.map(e=>({value:e,label:e}))]}),m=[{value:`required`,label:`Repository`,hint:`Clones the task's repository`},{value:`optional`,label:`If given`,hint:`Clones one when the run names it`},{value:`none`,label:`None`,hint:`Scratch workspace, no clone`}],h=Y(()=>i(`repository`)||`required`),g=Y(()=>{let e=v1(n.yaml,`needs`);return e&&typeof e==`object`?e:{}});return(t,n)=>(L(),j(`div`,H0,[R(`div`,U0,[R(`label`,W0,[n[7]||=R(`span`,{class:`flex-1 text-label`},`Runs as`,-1),(L(),q(I1,{key:String(c.value),"model-value":i(`identity`),options:d.value,"aria-label":`Execution identity`,placeholder:c.value?`Loading agents…`:`Choose an agent`,disabled:c.value||!!l.value,class:`w-44`,"onUpdate:modelValue":n[0]||=e=>a(`identity`,e)},null,8,[`model-value`,`options`,`placeholder`,`disabled`]))]),l.value?(L(),j(`p`,G0,[H(B(l.value)+` `,1),A(V(X),{variant:`link`,size:`xs`,onClick:u},{default:I(()=>[...n[8]||=[H(`Retry`,-1)]]),_:1})])):!c.value&&!s.value.length?(L(),j(`p`,K0,`No active agents in your organisation.`)):F(``,!0),R(`label`,q0,[n[9]||=R(`span`,{class:`flex-1 text-label`},`Container profile`,-1),A(I1,{"model-value":i(`profile`),options:p.value,"aria-label":`Container profile`,class:`w-44`,"onUpdate:modelValue":n[1]||=e=>a(`profile`,e||void 0)},null,8,[`model-value`,`options`])]),R(`div`,J0,[n[10]||=R(`span`,{class:`flex-1 text-label`},`Works on`,-1),A(V(CT),{type:`single`,variant:`outline`,size:`sm`,"model-value":h.value,"aria-label":`Works on`,"onUpdate:modelValue":n[2]||=e=>{e&&a(`repository`,e===`required`?void 0:String(e))}},{default:I(()=>[(L(),j(U,null,M(m,e=>A(V(wT),{key:e.value,value:e.value,title:e.hint},{default:I(()=>[H(B(e.label),1)]),_:2},1032,[`value`,`title`])),64))]),_:1},8,[`model-value`])]),R(`label`,Y0,[n[11]||=R(`span`,{class:`flex-1 text-label`,title:`Stages return structured output through capture tools`},`Captures`,-1),A(V(iT),{"model-value":g.value.captures===!0,"onUpdate:modelValue":n[3]||=e=>a(`needs`,{...g.value,captures:e||void 0})},null,8,[`model-value`])]),R(`label`,X0,[n[12]||=R(`span`,{class:`flex-1 text-label`},`Gate retries`,-1),A(V(Q),{type:`number`,min:`0`,placeholder:`0`,class:`h-8 w-20 text-right text-label`,"model-value":g.value.gate_retries??``,"onUpdate:modelValue":n[4]||=e=>a(`needs`,{...g.value,gate_retries:String(e)===``?void 0:Number(String(e))})},null,8,[`model-value`])])]),R(`section`,Z0,[n[13]||=R(`label`,{for:`workflow-instructions`,class:`text-xs font-medium text-fg-muted`},`Instructions`,-1),A(V(Jd),{id:`workflow-instructions`,"model-value":i(`instructions`),rows:4,class:`font-mono text-label`,onChange:n[5]||=e=>a(`instructions`,e.target.value)},null,8,[`model-value`])]),A(V0,{yaml:e.yaml,field:`outputs`,"onUpdate:yaml":n[6]||=e=>r(`update:yaml`,e)},null,8,[`yaml`])]))}}),e2=`repository_path`;function t2(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:e2,path:n.trim(),type:`string`,required:!0}),r}function n2(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function r2(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=n2(ek(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function i2(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:ek(e.value,i.type??`string`)})}return n}function a2(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function o2(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...o2(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...o2(n,r)]}):[]}function s2(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function c2(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function l2(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var u2={class:`flex h-full flex-col`},d2={class:`flex items-center gap-2 border-b border-border px-4 py-3`},f2={class:`min-w-0 flex-1 truncate text-sm font-medium`},p2={key:0,class:`flex flex-1 items-center justify-center`},m2={class:`space-y-1.5`},h2={key:1,class:`space-y-1.5`},g2=[`title`],_2={class:`space-y-1.5`},v2={id:`bind-paths`},y2=[`value`],b2={class:`divide-y divide-border rounded-md border border-border`},x2={class:`flex items-center gap-1.5 text-xs`},S2={class:`font-mono`},C2={class:`text-fg-subtle`},w2={key:0,class:`text-danger`,title:`Required`},T2={key:2,class:`text-xs text-danger`},E2=[`title`],D2={key:0,class:`space-y-1 px-3 py-2`},O2={key:0,class:`text-xs text-danger`},k2={key:1,class:`truncate font-mono text-xs text-success`},A2={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},j2={class:`space-y-2`},M2={key:0,role:`alert`,class:`text-xs text-danger`},N2={key:1,class:`text-xs text-fg-subtle`},P2={class:`flex flex-wrap gap-2`},F2=`__new__`,I2=P({__name:`BindEvent`,props:{yaml:{},binding:{}},emits:[`back`,`saved`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>String(v1(n.yaml,`id`)??``)),a=Y(()=>Object.entries(v1(n.yaml,`inputs`)??{})),o=Y(()=>QO({id:``,name:``,repository:String(v1(n.yaml,`repository`)??``)||void 0})),s=J([]),c=J({}),l=Y(()=>[{value:``,label:`Pick a source`,disabled:!0},...s.value.map(e=>({value:e,label:c.value[e]?`${c.value[e]} (${e})`:e})),{value:F2,label:`New source…`}]),u=J([]),d=J([]),f=J([]),p=J([]),m=J(!0),h=J(``),g=J(``),_=J(null),v=J({}),y=J(``),b=J(null),x=J(!1),S=J(!1),C=J(!1),w=J(null),T=J(``),ee=J(n.binding?.status??``);async function E(){let e=await Z.captures(100).catch(()=>null);u.value=e?.captures??[]}Be(async()=>{let[e,t,r,i]=await Promise.all([Z.sources().catch(()=>null),Z.eventTypes().catch(()=>null),Z.mappings().catch(()=>null),Z.bindings().catch(()=>null),E()]);if(s.value=(e?.sources??[]).map(e=>e.path),c.value=Object.fromEntries((e?.sources??[]).filter(e=>e.name).map(e=>[e.path,e.name])),d.value=t?.event_types??[],f.value=r?.mappings??[],p.value=i?.bindings??[],n.binding){h.value=n.binding.matcher?.source??``;let e=f.value.find(e=>String(e.id)===n.binding?.mapping_id),t=a2(n.binding,e?.fields??[]);v.value=t.rows,y.value=t.repositoryPath}else s.value.length===1&&(h.value=s.value[0]);for(let[e]of a.value)v.value[e]??={from:`path`,path:``,value:``};m.value=!1}),tp(`captures`,()=>void E(),500);let D=Y(()=>h.value===F2?g.value.trim():h.value),te=Y(()=>Jk(window.location.origin,D.value)),O=Y(()=>u.value.filter(e=>e.source===D.value));N(O,e=>{e.some(e=>e.id===_.value)||(_.value=e[0]?.id??null)},{immediate:!0});let ne=Y(()=>O.value.find(e=>e.id===_.value)),re=Y(()=>s2(ne.value)),ie=Y(()=>o2(re.value)),ae=Y(()=>t2(a.value,v.value,o.value?y.value:``)),oe;N([ae,_],()=>{if(clearTimeout(oe),_.value===null||!ae.value.length){b.value=null;return}let e=_.value;oe=setTimeout(async()=>{let t=await Z.mappingPreview(e,ae.value).catch(()=>null);e===_.value&&(b.value=t)},250)},{deep:!0,immediate:!0});let se=Y(()=>D.value?h.value===F2?[`create the source first`]:ne.value?re.value===null?[`the picked event's body is not JSON`]:r2(a.value,v.value,b.value):[`no event from ${D.value} yet to preview against`]:[`pick a source`]);function ce(e){let t=b.value?.failures?.find(t=>t.field_name===e);if(t)return{failure:t.reason};let n=b.value?.values??{};return e in n?{value:l2(n[e])}:{}}function le(e){return p.value.some(t=>t.mapping_id===e&&t.id!==n.binding?.id)}async function ue(e){return f.value.find(e=>String(e.id)===n.binding?.mapping_id)?.event_type_id||(e.event_type?e.event_type:(await Z.eventTypeCreate({source:D.value,name:`${D.value} event`,example:{headers:c2(e),body:e.body??``}})).id)}async function de(){if(D.value&&!C.value){C.value=!0,T.value=``;try{let e=await Z.sourceCreate(D.value);w.value=e,s.value.push(e.path),h.value=e.path,g.value=``}catch(e){T.value=e instanceof Error?e.message:String(e)}finally{C.value=!1}}}async function fe(){if(!se.value.length&&ne.value){x.value=!0,T.value=``;try{let e={name:`${i.value} ← ${D.value}`,event_type_id:await ue(ne.value),fields:ae.value},t=n.binding?.mapping_id,s=t&&!le(t)?await Z.mappingUpdate(t,e):await Z.mappingCreate(e),c={name:n.binding?.name||`${D.value} → ${i.value}`,matcher:{source:D.value},mapping_id:String(s.id),filter:n.binding?.filter??``,workflow:i.value,repo_param:o.value&&y.value.trim()?e2:``,owner:n.binding?.owner??``,repo:n.binding?.repo??``,inputs:i2(a.value,v.value)};n.binding?await Z.bindingUpdate(n.binding.id,c):await Z.bindingCreate(c),r(`saved`)}catch(e){T.value=e instanceof Error?e.message:String(e)}finally{x.value=!1}}}async function pe(e,t){if(n.binding){T.value=``;try{await e(n.binding.id),ee.value=t,r(`saved`)}catch(e){T.value=e instanceof Error?e.message:String(e)}}}async function me(){if(n.binding){x.value=!0,T.value=``;try{await Z.bindingDelete(n.binding.id),r(`saved`)}catch(e){T.value=e instanceof Error?e.message:String(e)}finally{x.value=!1}}}let he=()=>pe(Z.bindingApprove,`armed`),ge=()=>pe(Z.bindingPause,`paused`),_e=()=>pe(Z.bindingResume,`pending_approval`);return(t,n)=>(L(),j(`div`,u2,[A(V(TE),{open:S.value,"onUpdate:open":n[0]||=e=>S.value=e},{default:I(()=>[A(V(OE),null,{default:I(()=>[A(V(jE),null,{default:I(()=>[A(V(NE),null,{default:I(()=>[...n[8]||=[H(`Remove event binding?`,-1)]]),_:1}),A(V(kE),null,{default:I(()=>[...n[9]||=[H(`This event will stop starting this workflow. The event source and mapping are kept.`,-1)]]),_:1})]),_:1}),A(V(AE),null,{default:I(()=>[A(V(DE),null,{default:I(()=>[...n[10]||=[H(`Cancel`,-1)]]),_:1}),A(V(EE),{onClick:me},{default:I(()=>[...n[11]||=[H(`Remove binding`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`open`]),R(`header`,d2,[A(V(X),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to settings`,onClick:n[1]||=e=>r(`back`)},{default:I(()=>[A(V(Rl))]),_:1}),R(`div`,f2,B(e.binding?e.binding.name:`Bind an event`),1),ee.value?(L(),q(V(k),{key:0,variant:V(ik)(ee.value)},{default:I(()=>[H(B(V(rk)(ee.value)),1)]),_:1},8,[`variant`])):F(``,!0)]),m.value?(L(),j(`div`,p2,[A(V(uD))])):(L(),j(`form`,{key:1,class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,onSubmit:pt(fe,[`prevent`])},[R(`section`,m2,[n[13]||=R(`label`,{for:`bind-source`,class:`text-xs font-medium text-fg-muted`},`Source`,-1),A(I1,{id:`bind-source`,"aria-label":`Source`,"model-value":h.value,options:l.value,class:`w-full`,disabled:!!e.binding,"onUpdate:modelValue":n[2]||=e=>h.value=e},null,8,[`model-value`,`options`,`disabled`]),h.value===F2?(L(),q(V(Q),{key:0,modelValue:g.value,"onUpdate:modelValue":n[3]||=e=>g.value=e,"aria-label":`New source path`,placeholder:`path, e.g. alertmanager`,class:`h-8 w-full font-mono text-label`},null,8,[`modelValue`])):F(``,!0),h.value===F2?(L(),q(V(X),{key:1,type:`button`,size:`sm`,disabled:C.value||!D.value,onClick:de},{default:I(()=>[C.value?(L(),q(V(uD),{key:0})):F(``,!0),n[12]||=H(`Create source`,-1)]),_:1},8,[`disabled`])):F(``,!0)]),w.value?(L(),q(Qk,{key:0,source:w.value,onDismiss:n[4]||=e=>w.value=null},null,8,[`source`])):F(``,!0),D.value?(L(),j(`section`,h2,[n[14]||=R(`label`,{for:`bind-capture`,class:`text-xs font-medium text-fg-muted`},`Example event`,-1),O.value.length?(L(),q(V(Vu),{key:0,"model-value":_.value??void 0,"onUpdate:modelValue":n[5]||=e=>_.value=String(e)},{default:I(()=>[A(V(Gu),{id:`bind-capture`,size:`sm`,class:`w-full`,"aria-label":`Example event`},{default:I(()=>[A(V(Ku),{placeholder:`Pick an event`})]),_:1}),A(V(Hu),null,{default:I(()=>[(L(!0),j(U,null,M(O.value,e=>(L(),q(V(Wu),{key:e.id,value:String(e.id)},{default:I(()=>[H(`#`+B(e.id)+` · `,1),A(V(dw),{at:e.received_at,absolute:``},null,8,[`at`]),H(B(e.event_type?``:` · unidentified`),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`model-value`])):(L(),j(`p`,{key:1,class:`text-xs text-fg-subtle`,title:`Send an event to ${te.value} and it appears here`},`No events`,8,g2))])):F(``,!0),R(`section`,_2,[n[16]||=R(`div`,{class:`text-xs font-medium text-fg-muted`},`Inputs`,-1),R(`datalist`,v2,[(L(!0),j(U,null,M(ie.value,e=>(L(),j(`option`,{key:e,value:e},null,8,y2))),128))]),R(`div`,b2,[(L(!0),j(U,null,M(a.value,([e,t])=>(L(),j(`div`,{key:e,class:`space-y-1 px-3 py-2`},[R(`div`,x2,[R(`span`,S2,B(e),1),R(`span`,C2,B(t.type??`string`),1),t.required?(L(),j(`span`,w2,`*`)):F(``,!0),A(V(X),{type:`button`,variant:`ghost`,size:`icon-xs`,class:`ml-auto`,title:v.value[e].from===`path`?`Use a fixed value`:`Read from the event`,"aria-label":`${e}: ${v.value[e].from===`path`?`use a fixed value`:`read from the event`}`,onClick:t=>v.value[e].from=v.value[e].from===`path`?`value`:`path`},{default:I(()=>[v.value[e].from===`path`?(L(),q(V(yte),{key:0})):(L(),q(V(Kl),{key:1}))]),_:2},1032,[`title`,`aria-label`,`onClick`])]),v.value[e].from===`path`?(L(),q(V(Q),{key:0,modelValue:v.value[e].path,"onUpdate:modelValue":t=>v.value[e].path=t,list:`bind-paths`,"aria-label":`${e} payload path`,placeholder:`payload path`,class:`h-8 w-full font-mono text-xs`},null,8,[`modelValue`,`onUpdate:modelValue`,`aria-label`])):(L(),q(V(Q),{key:1,modelValue:v.value[e].value,"onUpdate:modelValue":t=>v.value[e].value=t,"aria-label":`${e} fixed value`,placeholder:`fixed value`,class:`h-8 w-full font-mono text-xs`},null,8,[`modelValue`,`onUpdate:modelValue`,`aria-label`])),v.value[e].from===`path`&&ce(e).failure?(L(),j(`p`,T2,B(ce(e).failure),1)):v.value[e].from===`path`&&ce(e).value!==void 0?(L(),j(`p`,{key:3,class:`truncate font-mono text-xs text-success`,title:ce(e).value},B(ce(e).value),9,E2)):F(``,!0)]))),128)),o.value?(L(),j(`div`,D2,[n[15]||=R(`div`,{class:`text-xs`,title:`Optional: owner/name of a configured repository; blank uses the configured one`},`Repository`,-1),A(V(Q),{modelValue:y.value,"onUpdate:modelValue":n[6]||=e=>y.value=e,list:`bind-paths`,"aria-label":`Repository payload path`,placeholder:`payload path`,class:`h-8 w-full font-mono text-xs`},null,8,[`modelValue`]),ce(V(`repository_path`)).failure?(L(),j(`p`,O2,B(ce(V(e2)).failure),1)):ce(V(`repository_path`)).value===void 0?F(``,!0):(L(),j(`p`,k2,B(ce(V(e2)).value),1))])):F(``,!0),!a.value.length&&!o.value?(L(),j(`p`,A2,`No inputs.`)):F(``,!0)])]),R(`div`,j2,[T.value?(L(),j(`p`,M2,B(T.value),1)):se.value.length?(L(),j(`p`,N2,`Cannot save: `+B(se.value[0]),1)):F(``,!0),R(`div`,P2,[A(V(X),{type:`submit`,size:`sm`,disabled:x.value||!!se.value.length},{default:I(()=>[x.value?(L(),q(V(uD),{key:0})):F(``,!0),n[17]||=H(`Save binding`,-1)]),_:1},8,[`disabled`]),e.binding&&ee.value===`pending_approval`?(L(),q(V(X),{key:0,type:`button`,size:`sm`,variant:`outline`,onClick:he},{default:I(()=>[...n[18]||=[H(`Approve`,-1)]]),_:1})):F(``,!0),e.binding&&ee.value===`armed`?(L(),q(V(X),{key:1,type:`button`,size:`sm`,variant:`outline`,onClick:ge},{default:I(()=>[...n[19]||=[H(`Pause`,-1)]]),_:1})):F(``,!0),e.binding&&ee.value===`paused`?(L(),q(V(X),{key:2,type:`button`,size:`sm`,variant:`outline`,onClick:_e},{default:I(()=>[...n[20]||=[H(`Resume`,-1)]]),_:1})):F(``,!0),e.binding?(L(),q(V(X),{key:3,type:`button`,size:`sm`,variant:`destructive`,disabled:x.value,onClick:n[7]||=e=>S.value=!0},{default:I(()=>[...n[21]||=[H(`Remove binding`,-1)]]),_:1},8,[`disabled`])):F(``,!0)])])],32))]))}}),L2={key:1,class:`space-y-4 px-3 py-3`},R2={class:`space-y-1.5`},z2={class:`flex justify-end`},B2={key:0,class:`divide-y divide-border rounded-md border border-border`},V2=[`onClick`],H2={class:`truncate`},U2={key:1,class:`ml-auto truncate text-xs text-fg-subtle`},W2={class:`truncate`},G2={class:`ml-auto truncate text-xs text-fg-subtle`},K2={key:2,class:`flex items-center gap-2 px-3 py-2`,title:`Built-in issue routing. Disable this workflow to stop it running automatically.`},q2={class:`truncate`},J2={key:1,class:`ml-auto truncate text-xs text-fg-subtle`},Y2={key:1,class:`text-xs text-fg-subtle`},X2=P({__name:`TriggerSettings`,props:{yaml:{},triggers:{}},emits:[`update:yaml`,`bound`],setup(e,{emit:t}){let n=t,r=J();function i(){r.value=void 0,n(`bound`)}return(t,a)=>{let o=Me(`RouterLink`);return r.value===void 0?(L(),j(`div`,L2,[R(`section`,R2,[R(`div`,z2,[A(V(X),{type:`button`,variant:`ghost`,size:`xs`,onClick:a[1]||=e=>r.value=null},{default:I(()=>[A(V(Eu),{"data-icon":`inline-start`}),a[3]||=H(`Bind an event`,-1)]),_:1})]),e.triggers.length?(L(),j(`ul`,B2,[(L(!0),j(U,null,M(e.triggers,e=>(L(),j(`li`,{key:e.kind+e.label,class:`text-label`},[e.binding?(L(),j(`button`,{key:0,type:`button`,class:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-secondary`,onClick:t=>r.value=e.binding},[R(`span`,H2,B(e.label),1),e.binding.status===`armed`?F(``,!0):(L(),q(V(k),{key:0,variant:V(ik)(e.binding.status)},{default:I(()=>[H(B(V(rk)(e.binding.status)),1)]),_:2},1032,[`variant`])),e.detail?(L(),j(`span`,U2,B(e.detail),1)):F(``,!0)],8,V2)):e.kind===`workflow`||e.kind===`playbook`?(L(),q(o,{key:1,to:e.kind===`workflow`?{path:`/workflows`,query:{workflow:e.label}}:{path:`/org/playbooks`},class:`flex items-center gap-2 px-3 py-2 hover:bg-secondary`},{default:I(()=>[R(`span`,W2,B(e.label),1),R(`span`,G2,B(e.detail),1)]),_:2},1032,[`to`])):(L(),j(`div`,K2,[R(`span`,q2,B(e.label),1),e.kind===`issue`?(L(),q(V(k),{key:0,variant:`outline`,class:`ml-auto`},{default:I(()=>[...a[4]||=[H(`Built-in`,-1)]]),_:1})):F(``,!0),e.detail?(L(),j(`span`,J2,B(e.detail),1)):F(``,!0)]))]))),128))])):(L(),j(`p`,Y2,`Manual runs only.`))]),A(V0,{yaml:e.yaml,field:`inputs`,"onUpdate:yaml":a[2]||=e=>n(`update:yaml`,e)},null,8,[`yaml`])])):(L(),q(I2,{key:0,yaml:e.yaml,binding:r.value,onBack:a[0]||=e=>r.value=void 0,onSaved:i},null,8,[`yaml`,`binding`]))}}}),Z2=P({__name:`RunWorkflowButton`,props:Ye({workflow:{},disabled:{type:Boolean},draft:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ye([`started`],[`update:open`]),setup(e,{emit:t}){let n=t,r=ke(e,`open`);function i(e){r.value=!1,n(`started`,e)}return(t,n)=>(L(),q(V(pw),{open:r.value,"onUpdate:open":n[1]||=e=>r.value=e},{default:I(()=>[A(V(yw),{"as-child":``},{default:I(()=>[A(V(X),{type:`button`,size:`sm`,variant:`outline`,"aria-label":`${e.draft===void 0?`Run`:`Test`} ${e.workflow}`,disabled:e.disabled,title:e.draft===void 0?e.disabled?`Save first`:void 0:`Runs this draft once. Forge writes and pushes are skipped, including in called workflows; commands and tools still run`},{default:I(()=>[(L(),q(_e(e.draft===void 0?V(Tu):V(gu)),{"data-icon":`inline-start`})),n[2]||=H(),R(`span`,null,B(e.draft===void 0?`Run`:`Test`),1)]),_:1},8,[`aria-label`,`disabled`,`title`])]),_:1}),A(V(mw),{class:`sm:max-w-[640px]`},{default:I(()=>[A(V(_w),null,{default:I(()=>[A(V(vw),null,{default:I(()=>[H(B(e.draft===void 0?`Run`:`Test`)+` `+B(e.workflow),1)]),_:1})]),_:1}),r.value?(L(),q(VD,{key:0,workflow:e.workflow,draft:e.draft,onStarted:i,onCancel:n[0]||=e=>r.value=!1},null,8,[`workflow`,`draft`])):F(``,!0)]),_:1})]),_:1},8,[`open`]))}});function Q2(e){return Re()?(Ve(e),!0):!1}function $2(e){return typeof e==`function`?e():V(e)}var e4=typeof window<`u`&&typeof document<`u`,t4=e=>e!==void 0,n4=Object.prototype.toString,r4=e=>n4.call(e)===`[object Object]`,i4=()=>{};function a4(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}var o4=e=>e();function s4(e=o4){let t=J(!0);function n(){t.value=!1}function r(){t.value=!0}return{isActive:Le(t),pause:n,resume:r,eventFilter:(...n)=>{t.value&&e(...n)}}}function c4(e,t=!1,n=`Timeout`){return new Promise((r,i)=>{setTimeout(t?()=>i(n):r,e)})}function l4(e,t,n={}){let{eventFilter:r=o4,...i}=n;return N(e,a4(r,t),i)}function u4(e,t,n={}){let{eventFilter:r,...i}=n,{eventFilter:a,pause:o,resume:s,isActive:c}=s4(r);return{stop:l4(e,t,{...i,eventFilter:a}),pause:o,resume:s,isActive:c}}function d4(e,t={}){if(!$e(e))return Te(e);let n=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(let r in e.value)n[r]=Ie(()=>({get(){return e.value[r]},set(n){if($2(t.replaceRef)??!0){if(Array.isArray(e.value)){let t=[...e.value];t[r]=n,e.value=t}else{let t={...e.value,[r]:n};Object.setPrototypeOf(t,Object.getPrototypeOf(e.value)),e.value=t}}else e.value[r]=n}}));return n}function f4(e,t=!1){function n(n,{flush:r=`sync`,deep:i=!1,timeout:a,throwOnTimeout:o}={}){let s=null,c=[new Promise(a=>{s=N(e,e=>{n(e)!==t&&(s?.(),a(e))},{flush:r,deep:i,immediate:!0})})];return a!=null&&c.push(c4(a,o).then(()=>$2(e)).finally(()=>s?.())),Promise.race(c)}function r(r,i){if(!$e(r))return n(e=>e===r,i);let{flush:a=`sync`,deep:o=!1,timeout:s,throwOnTimeout:c}=i??{},l=null,u=[new Promise(n=>{l=N([e,r],([e,r])=>{t!==(e===r)&&(l?.(),n(e))},{flush:a,deep:o,immediate:!0})})];return s!=null&&u.push(c4(s,c).then(()=>$2(e)).finally(()=>(l?.(),$2(e)))),Promise.race(u)}function i(e){return n(e=>!!e,e)}function a(e){return r(null,e)}function o(e){return r(void 0,e)}function s(e){return n(Number.isNaN,e)}function c(e,t){return n(t=>{let n=Array.from(t);return n.includes(e)||n.includes($2(e))},t)}function l(e){return u(1,e)}function u(e=1,t){let r=-1;return n(()=>(r+=1,r>=e),t)}return Array.isArray($2(e))?{toMatch:n,toContains:c,changed:l,changedTimes:u,get not(){return f4(e,!t)}}:{toMatch:n,toBe:r,toBeTruthy:i,toBeNull:a,toBeNaN:s,toBeUndefined:o,changed:l,changedTimes:u,get not(){return f4(e,!t)}}}function p4(e){return f4(e)}function m4(e){let t=$2(e);return t?.$el??t}var h4=e4?window:void 0;function g4(...e){let t,n,r,i;if(typeof e[0]==`string`||Array.isArray(e[0])?([n,r,i]=e,t=h4):[t,n,r,i]=e,!t)return i4;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);let a=[],o=()=>{a.forEach(e=>e()),a.length=0},s=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),c=N(()=>[m4(t),$2(i)],([e,t])=>{if(o(),!e)return;let i=r4(t)?{...t}:t;a.push(...n.flatMap(t=>r.map(n=>s(e,t,n,i))))},{immediate:!0,flush:`post`}),l=()=>{c(),o()};return Q2(l),l}function _4(e){return typeof e==`function`?e:typeof e==`string`?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function v4(...e){let t,n,r={};e.length===3?(t=e[0],n=e[1],r=e[2]):e.length===2?typeof e[1]==`object`?(t=!0,n=e[0],r=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);let{target:i=h4,eventName:a=`keydown`,passive:o=!1,dedupe:s=!1}=r,c=_4(t);return g4(i,a,e=>{e.repeat&&$2(s)||c(e)&&n(e)},o)}function y4(e){return JSON.parse(JSON.stringify(e))}function b4(e,t,n,r={}){let{clone:i=!1,passive:a=!1,eventName:o,deep:s=!1,defaultValue:c,shouldEmit:l}=r,u=pe(),d=n||u?.emit||(u?.$emit)?.bind(u)||(u?.proxy?.$emit)?.bind(u?.proxy),f=o;t||=`modelValue`,f||=`update:${t.toString()}`;let p=e=>i?typeof i==`function`?i(e):y4(e):e,m=()=>t4(e[t])?p(e[t]):c,h=e=>{l?l(e)&&d(f,e):d(f,e)};if(a){let n=m(),r=J(n),i=!1;return N(()=>e[t],e=>{i||(i=!0,r.value=p(e),We(()=>i=!1))}),N(r,n=>{!i&&(n!==e[t]||s)&&h(n)},{deep:s}),r}return Y({get(){return m()},set(e){h(e)}})}var x4={value:()=>{}};function S4(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}C4.prototype=S4.prototype={constructor:C4,on:function(e,t){var n=this._,r=w4(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),O4.hasOwnProperty(t)?{space:O4[t],local:e}:e}function A4(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===D4&&t.documentElement.namespaceURI===D4?t.createElement(e):t.createElementNS(n,e)}}function j4(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function M4(e){var t=k4(e);return(t.local?j4:A4)(t)}function N4(){}function P4(e){return e==null?N4:function(){return this.querySelector(e)}}function F4(e){typeof e!=`function`&&(e=P4(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function d3(e){e||=f3;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function p3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function m3(){return Array.from(this)}function h3(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?D3:typeof t==`function`?k3:O3)(e,t,n??``)):j3(this.node(),e)}function j3(e,t){return e.style.getPropertyValue(t)||E3(e).getComputedStyle(e,null).getPropertyValue(t)}function M3(e){return function(){delete this[e]}}function N3(e,t){return function(){this[e]=t}}function P3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function F3(e,t){return arguments.length>1?this.each((t==null?M3:typeof t==`function`?P3:N3)(e,t)):this.node()[e]}function I3(e){return e.trim().split(/^|\s+/)}function L3(e){return e.classList||new R3(e)}function R3(e){this._node=e,this._names=I3(e.getAttribute(`class`)||``)}R3.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function z3(e,t){for(var n=L3(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function m6(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function I6(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}I6.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function L6(e){return!e.ctrlKey&&!e.button}function R6(){return this.parentNode}function z6(e,t){return t??{x:e.x,y:e.y}}function B6(){return navigator.maxTouchPoints||`ontouchstart`in this}function V6(){var e=L6,t=R6,n=z6,r=B6,i={},a=S4(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,k6).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(E6(n.view).on(`mousemove.drag`,m,A6).on(`mouseup.drag`,h,A6),N6(n.view),j6(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(M6(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){E6(e.view).on(`mousemove.drag mouseup.drag`,null),P6(e.view,l),M6(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?t8(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?t8(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Eie.exec(e))?new r8(t[1],t[2],t[3],1):(t=Die.exec(e))?new r8(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Oie.exec(e))?t8(t[1],t[2],t[3],t[4]):(t=kie.exec(e))?t8(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Aie.exec(e))?l8(t[1],t[2]/100,t[3]/100,1):(t=jie.exec(e))?l8(t[1],t[2]/100,t[3]/100,t[4]):X6.hasOwnProperty(e)?e8(X6[e]):e===`transparent`?new r8(NaN,NaN,NaN,0):null}function e8(e){return new r8(e>>16&255,e>>8&255,e&255,1)}function t8(e,t,n,r){return r<=0&&(e=t=n=NaN),new r8(e,t,n,r)}function Pie(e){return e instanceof W6||(e=$6(e)),e?(e=e.rgb(),new r8(e.r,e.g,e.b,e.opacity)):new r8}function n8(e,t,n,r){return arguments.length===1?Pie(e):new r8(e,t,n,r??1)}function r8(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}H6(r8,n8,U6(W6,{brighter(e){return e=e==null?K6:K6**+e,new r8(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?G6:G6**+e,new r8(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new r8(s8(this.r),s8(this.g),s8(this.b),o8(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:i8,formatHex:i8,formatHex8:Fie,formatRgb:a8,toString:a8}));function i8(){return`#${c8(this.r)}${c8(this.g)}${c8(this.b)}`}function Fie(){return`#${c8(this.r)}${c8(this.g)}${c8(this.b)}${c8((isNaN(this.opacity)?1:this.opacity)*255)}`}function a8(){let e=o8(this.opacity);return`${e===1?`rgb(`:`rgba(`}${s8(this.r)}, ${s8(this.g)}, ${s8(this.b)}${e===1?`)`:`, ${e})`}`}function o8(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function s8(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function c8(e){return e=s8(e),(e<16?`0`:``)+e.toString(16)}function l8(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new d8(e,t,n,r)}function u8(e){if(e instanceof d8)return new d8(e.h,e.s,e.l,e.opacity);if(e instanceof W6||(e=$6(e)),!e)return new d8;if(e instanceof d8)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new d8(o,s,c,e.opacity)}function Iie(e,t,n,r){return arguments.length===1?u8(e):new d8(e,t,n,r??1)}function d8(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}H6(d8,Iie,U6(W6,{brighter(e){return e=e==null?K6:K6**+e,new d8(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?G6:G6**+e,new d8(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new r8(m8(e>=240?e-240:e+120,i,r),m8(e,i,r),m8(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new d8(f8(this.h),p8(this.s),p8(this.l),o8(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=o8(this.opacity);return`${e===1?`hsl(`:`hsla(`}${f8(this.h)}, ${p8(this.s)*100}%, ${p8(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function f8(e){return e=(e||0)%360,e<0?e+360:e}function p8(e){return Math.max(0,Math.min(1,e||0))}function m8(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var h8=e=>()=>e;function Lie(e,t){return function(n){return e+n*t}}function Rie(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function zie(e){return(e=+e)==1?g8:function(t,n){return n-t?Rie(t,n,e):h8(isNaN(t)?n:t)}}function g8(e,t){var n=t-e;return n?Lie(e,n):h8(isNaN(e)?t:e)}var _8=function e(t){var n=zie(t);function r(e,t){var r=n((e=n8(e)).r,(t=n8(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=g8(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r}(1);function Bie(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:v8(r,i)})),n=b8.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:v8(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:v8(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:v8(e,n)},{i:s-2,x:v8(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--A8}function W8(){L8=(I8=z8.now())+R8,A8=j8=0;try{tae()}finally{A8=0,rae(),L8=0}}function nae(){var e=z8.now(),t=e-I8;t>N8&&(R8-=t,I8=e)}function rae(){for(var e,t=P8,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:P8=n);F8=e,G8(r)}function G8(e){A8||(j8&&=clearTimeout(j8),e-L8>24?(e<1/0&&(j8=setTimeout(W8,e-z8.now()-R8)),M8&&=clearInterval(M8)):(M8||=(I8=z8.now(),setInterval(nae,N8)),A8=1,B8(W8)))}function K8(e,t,n){var r=new H8;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var iae=S4(`start`,`end`,`cancel`,`interrupt`),aae=[],q8=0,J8=1,Y8=2,X8=3,Z8=4,Q8=5,$8=6;function e5(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;oae(e,n,{name:t,index:r,group:i,on:iae,tween:aae,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:q8})}function t5(e,t){var n=r5(e,t);if(n.state>q8)throw Error(`too late; already scheduled`);return n}function n5(e,t){var n=r5(e,t);if(n.state>X8)throw Error(`too late; already running`);return n}function r5(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function oae(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=U8(a,0,n.time);function a(e){n.state=J8,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==J8)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===X8)return K8(o);f.state===Z8?(f.state=$8,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+lY8&&r.state=0&&(e=e.slice(0,t)),!e||e===`start`})}function Iae(e,t,n){var r,i,a=Fae(t)?t5:n5;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Lae(e,t){var n=this._id;return arguments.length<2?r5(this.node(),n).on.on(e):this.each(Iae(n,e,t))}function Rae(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function zae(){return this.on(`end.remove`,Rae(this._id))}function Bae(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=P4(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function doe(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function f5(e,t,n){this.k=e,this.x=t,this.y=n}f5.prototype={constructor:f5,scale:function(e){return e===1?this:new f5(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new f5(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 p5=new f5(1,0,0);f5.prototype;function m5(e){e.stopImmediatePropagation()}function h5(e){e.preventDefault(),e.stopImmediatePropagation()}function foe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function poe(){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 g5(){return this.__zoom||p5}function moe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function hoe(){return navigator.maxTouchPoints||`ontouchstart`in this}function goe(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function _oe(){var e=foe,t=poe,n=goe,r=moe,i=hoe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=k8,l=S4(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,g5).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,ee).filter(i).on(`touchstart.zoom`,E).on(`touchmove.zoom`,D).on(`touchend.zoom touchcancel.zoom`,te).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,g5),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(p5.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new f5(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new f5(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new f5(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=E6(this.that).datum();l.call(e,this.that,new doe(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=O6(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],i5(this),s.start();h5(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=E6(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=O6(t,i),l=t.clientX,u=t.clientY;N6(t.view),m5(t),a.mouse=[c,this.__zoom.invert(c)],i5(this),a.start();function d(e){if(h5(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=O6(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),P6(e.view,a.moved),h5(e),a.event(e).end()}}function ee(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=O6(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);h5(r),s>0?E6(this).transition().duration(s).call(x,d,c,r):E6(this).call(_.transform,d,c,r)}}function E(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(m5(t),s=0;s(e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`,e))(_5||{}),v5=(e=>(e.Partial=`partial`,e.Full=`full`,e))(v5||{}),y5=(e=>(e.Bezier=`default`,e.SimpleBezier=`simple-bezier`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e))(y5||{}),b5=(e=>(e.Strict=`strict`,e.Loose=`loose`,e))(b5||{}),x5=(e=>(e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`,e))(x5||{}),S5=(e=>(e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`,e))(S5||{}),voe=[`INPUT`,`SELECT`,`TEXTAREA`],yoe=typeof document<`u`?document:null;function C5(e){let t=e.composedPath?.call(e)?.[0]||e.target,n=typeof t?.hasAttribute==`function`&&t.hasAttribute(`contenteditable`),r=typeof t?.closest==`function`?t.closest(`.nokey`):null;return voe.includes(t?.nodeName)||n||!!r}function boe(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function w5(e,t,n,r){let i=t.replace(`+`,` +`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(L(),j(U,{key:2},[A(V(Jd),{"model-value":_e(h.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>ge(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),he.value[e.key]?(L(),j(`span`,O0,B(he.value[e.key]),1)):F(``,!0)],64))]))),128)),R(`section`,k0,[_.value?(L(),j(`p`,A0,B(_.value),1)):F(``,!0),R(`div`,j0,[R(`label`,M0,[r[20]||=R(`span`,{class:`flex-1 text-label`,title:`Empty always runs. A field such as inputs.enabled, !inputs.skip, or steps.plan.result.ready == true`},`Run only when`,-1),A(V(Q),{class:`h-8 w-48 font-mono text-xs`,placeholder:`inputs.enabled`,"aria-invalid":_.value&&_.value.startsWith(`when`)?!0:void 0,"model-value":a.value.when??``,"onUpdate:modelValue":r[11]||=e=>ee(`when`,String(e))},null,8,[`aria-invalid`,`model-value`])]),R(`label`,N0,[r[21]||=R(`span`,{class:`flex-1 text-label`},`If it fails`,-1),A(I1,{class:`w-36`,"aria-label":`If it fails`,"model-value":a.value.on_failure??``,options:N,"onUpdate:modelValue":r[12]||=e=>ee(`on_failure`,e||void 0)},null,8,[`model-value`])]),R(`label`,P0,[r[22]||=R(`span`,{class:`flex-1 text-label`},`Attempts`,-1),A(V(Q),{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-8 w-20 text-right text-label`,"model-value":a.value.retry?.attempts??``,"onUpdate:modelValue":r[13]||=e=>E({attempts:String(e)===``?void 0:Number(String(e))})},null,8,[`model-value`])]),R(`div`,F0,[R(`label`,{for:`${V(n)}-backoff`,class:`flex-1 text-label`},`Retry backoff`,8,I0),A(V(Zw),{id:`${V(n)}-backoff`,"model-value":a.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":r[14]||=e=>E({backoff:e||void 0})},null,8,[`id`,`model-value`])])])])],64)):F(``,!0)]))}}),R0={class:`space-y-1.5`},z0={class:`flex items-center text-xs font-medium text-fg-muted`},B0={key:0,class:`divide-y divide-border rounded-md border border-border`},V0=P({__name:`SpecList`,props:{yaml:{},field:{}},emits:[`update:yaml`],setup(e,{emit:t}){let n=e,r=t,i=[`string`,`number`,`bool`,`object`,`array`,`any`].map(e=>({value:e,label:e})),a=Y(()=>Object.entries(v1(n.yaml,n.field)??{}));function o(e){r(`update:yaml`,y1(n.yaml,n.field,Object.fromEntries(e.filter(([e])=>e))))}function s(e,t,n){o(a.value.map((r,i)=>i===e?[t,n]:r))}function c(){let e=n.field.slice(0,-1),t=a.value.length+1;for(;a.value.some(([n])=>n===`${e}_${t}`);)t++;o([...a.value,[`${e}_${t}`,{type:`string`}]])}return(t,n)=>(L(),j(`section`,R0,[R(`div`,z0,[H(B(e.field===`inputs`?`Inputs`:`Outputs`)+` `,1),A(V(X),{type:`button`,variant:`ghost`,size:`xs`,class:`ml-auto`,onClick:c},{default:I(()=>[A(V(Eu),{"data-icon":`inline-start`}),n[0]||=H(`Add`,-1)]),_:1})]),a.value.length?(L(),j(`div`,B0,[(L(!0),j(U,null,M(a.value,([t,n],r)=>(L(),j(`div`,{key:r,class:`flex items-center gap-2 px-2 py-1.5`},[A(V(Q),{"model-value":t,class:`h-8 min-w-0 flex-1 font-mono text-xs`,"aria-label":`${e.field} name`,onChange:e=>s(r,e.target.value.trim(),n)},null,8,[`model-value`,`aria-label`,`onChange`]),A(I1,{"model-value":n.type??`string`,options:V(i),class:`w-24`,"aria-label":`${t} type`,"onUpdate:modelValue":e=>s(r,t,{...n,type:e})},null,8,[`model-value`,`options`,`aria-label`,`onUpdate:modelValue`]),A(V(iT),{"model-value":n.required===!0,title:n.required?`Required`:`Optional`,"aria-label":`${t} required`,"onUpdate:modelValue":e=>s(r,t,{...n,required:e||void 0})},null,8,[`model-value`,`title`,`aria-label`,`onUpdate:modelValue`]),A(V(X),{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Remove ${t}`,onClick:e=>o(a.value.filter((e,t)=>t!==r))},{default:I(()=>[A(V(Mu))]),_:1},8,[`aria-label`,`onClick`])]))),128))])):F(``,!0)]))}}),H0={class:`space-y-4 px-3 py-3`},U0={class:`divide-y divide-border rounded-md border border-border`},W0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},G0={key:0,role:`alert`,class:`px-3 py-2 text-xs text-danger`},K0={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},q0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},J0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},Y0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},X0={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},Z0={class:`space-y-1.5`},Q0=`6f129e29-0e26-5246-99bd-74cb4496203b`,$0=P({__name:`WorkflowSettings`,props:{yaml:{}},emits:[`update:yaml`],setup(e,{emit:t}){let n=e,r=t,i=e=>{let t=v1(n.yaml,e);return typeof t==`string`?t:``};function a(e,t){r(`update:yaml`,y1(n.yaml,e,t))}let o=MT(),s=J([]),c=J(!0),l=J(``);async function u(){c.value=!0,l.value=``,s.value=[];try{await o.loadOrg();let e=await Z.orgAgents(o.homeOrg);s.value=e.agents.filter(e=>e.lifecycle===`active`),!i(`identity`)&&s.value.some(e=>e.id===Q0)&&a(`identity`,Q0)}catch(e){l.value=String(e.message||e)}finally{c.value=!1}}Be(u);let d=Y(()=>{let e=i(`identity`),t=s.value.map(e=>({value:e.id,label:e.display_name}));return e&&!c.value&&!s.value.some(t=>t.id===e)?[{value:e,label:`${e} (unknown)`,disabled:!0},...t]:t}),f=qw(),p=Y(()=>{let e=Object.keys(f.stateFor(`agent-profiles`).resource?.value??{}).sort(),t=i(`profile`);return t&&!e.includes(t)&&e.unshift(t),[{value:``,label:`Default`},...e.map(e=>({value:e,label:e}))]}),m=[{value:`required`,label:`Repository`,hint:`Clones the task's repository`},{value:`optional`,label:`If given`,hint:`Clones one when the run names it`},{value:`none`,label:`None`,hint:`Scratch workspace, no clone`}],h=Y(()=>i(`repository`)||`required`),g=Y(()=>{let e=v1(n.yaml,`needs`);return e&&typeof e==`object`?e:{}});return(t,n)=>(L(),j(`div`,H0,[R(`div`,U0,[R(`label`,W0,[n[7]||=R(`span`,{class:`flex-1 text-label`},`Runs as`,-1),(L(),q(I1,{key:String(c.value),"model-value":i(`identity`),options:d.value,"aria-label":`Execution identity`,placeholder:c.value?`Loading agents…`:`Choose an agent`,disabled:c.value||!!l.value,class:`w-44`,"onUpdate:modelValue":n[0]||=e=>a(`identity`,e)},null,8,[`model-value`,`options`,`placeholder`,`disabled`]))]),l.value?(L(),j(`p`,G0,[H(B(l.value)+` `,1),A(V(X),{variant:`link`,size:`xs`,onClick:u},{default:I(()=>[...n[8]||=[H(`Retry`,-1)]]),_:1})])):!c.value&&!s.value.length?(L(),j(`p`,K0,`No active agents in your organisation.`)):F(``,!0),R(`label`,q0,[n[9]||=R(`span`,{class:`flex-1 text-label`},`Container profile`,-1),A(I1,{"model-value":i(`profile`),options:p.value,"aria-label":`Container profile`,class:`w-44`,"onUpdate:modelValue":n[1]||=e=>a(`profile`,e||void 0)},null,8,[`model-value`,`options`])]),R(`div`,J0,[n[10]||=R(`span`,{class:`flex-1 text-label`},`Works on`,-1),A(V(CT),{type:`single`,variant:`outline`,size:`sm`,"model-value":h.value,"aria-label":`Works on`,"onUpdate:modelValue":n[2]||=e=>{e&&a(`repository`,e===`required`?void 0:String(e))}},{default:I(()=>[(L(),j(U,null,M(m,e=>A(V(wT),{key:e.value,value:e.value,title:e.hint},{default:I(()=>[H(B(e.label),1)]),_:2},1032,[`value`,`title`])),64))]),_:1},8,[`model-value`])]),R(`label`,Y0,[n[11]||=R(`span`,{class:`flex-1 text-label`,title:`Stages return structured output through capture tools`},`Captures`,-1),A(V(iT),{"model-value":g.value.captures===!0,"onUpdate:modelValue":n[3]||=e=>a(`needs`,{...g.value,captures:e||void 0})},null,8,[`model-value`])]),R(`label`,X0,[n[12]||=R(`span`,{class:`flex-1 text-label`},`Gate retries`,-1),A(V(Q),{type:`number`,min:`0`,placeholder:`0`,class:`h-8 w-20 text-right text-label`,"model-value":g.value.gate_retries??``,"onUpdate:modelValue":n[4]||=e=>a(`needs`,{...g.value,gate_retries:String(e)===``?void 0:Number(String(e))})},null,8,[`model-value`])])]),R(`section`,Z0,[n[13]||=R(`label`,{for:`workflow-instructions`,class:`text-xs font-medium text-fg-muted`},`Instructions`,-1),A(V(Jd),{id:`workflow-instructions`,"model-value":i(`instructions`),rows:4,class:`font-mono text-label`,onChange:n[5]||=e=>a(`instructions`,e.target.value)},null,8,[`model-value`])]),A(V0,{yaml:e.yaml,field:`outputs`,"onUpdate:yaml":n[6]||=e=>r(`update:yaml`,e)},null,8,[`yaml`])]))}}),e2=`repository_path`;function t2(e,t,n){let r=[];for(let[n,i]of e){let e=t[n];e?.from===`path`&&e.path.trim()&&r.push({name:n,path:e.path.trim(),type:i.type??`string`,required:i.required===!0})}return n.trim()&&r.push({name:e2,path:n.trim(),type:`string`,required:!0}),r}function n2(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function r2(e,t,n){let r=[];for(let[i,a]of e){let e=t[i],o=a.type??`string`;if(!(e&&(e.from===`path`?e.path.trim():e.value!==``))){a.required&&r.push(`${i} is required`);continue}if(e.from===`path`){let e=n?.failures?.find(e=>e.field_name===i);e&&r.push(`${i}: ${e.reason}`);continue}let s=n2(ek(e.value,o));o!==`any`&&s!==o&&r.push(`${i} is ${o}, but ${JSON.stringify(e.value)} is not`)}return n?.failures?.some(e=>e.field_name===`repository_path`)&&r.push(`the repository path does not resolve`),r}function i2(e,t){let n={};for(let[r,i]of e){let e=t[r];e?.from===`path`&&e.path.trim()?n[r]={param:r}:e?.from===`value`&&e.value!==``&&(n[r]={value:ek(e.value,i.type??`string`)})}return n}function a2(e,t){let n=e=>t.find(t=>t.name===e)?.path??``,r={};for(let[t,i]of Object.entries(e.inputs??{}))r[t]=i.param?{from:`path`,path:n(i.param),value:``}:{from:`value`,path:``,value:typeof i.value==`string`?i.value:JSON.stringify(i.value)};return{rows:r,repositoryPath:n(e.repo_param)}}function o2(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...o2(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...o2(n,r)]}):[]}function s2(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function c2(e){try{let t=JSON.parse(e.headers??`{}`);return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t)]))}catch{return{}}}function l2(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var u2={class:`flex h-full flex-col`},d2={class:`flex items-center gap-2 border-b border-border px-4 py-3`},f2={class:`min-w-0 flex-1 truncate text-sm font-medium`},p2={key:0,class:`flex flex-1 items-center justify-center`},m2={class:`space-y-1.5`},h2={key:1,class:`space-y-1.5`},g2=[`title`],_2={class:`space-y-1.5`},v2={id:`bind-paths`},y2=[`value`],b2={class:`divide-y divide-border rounded-md border border-border`},x2={class:`flex items-center gap-1.5 text-xs`},S2={class:`font-mono`},C2={class:`text-fg-subtle`},w2={key:0,class:`text-danger`,title:`Required`},T2={key:2,class:`text-xs text-danger`},E2=[`title`],D2={key:0,class:`space-y-1 px-3 py-2`},O2={key:0,class:`text-xs text-danger`},k2={key:1,class:`truncate font-mono text-xs text-success`},A2={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},j2={class:`space-y-2`},M2={key:0,role:`alert`,class:`text-xs text-danger`},N2={key:1,class:`text-xs text-fg-subtle`},P2={class:`flex flex-wrap gap-2`},F2=`__new__`,I2=P({__name:`BindEvent`,props:{yaml:{},binding:{}},emits:[`back`,`saved`],setup(e,{emit:t}){let n=e,r=t,i=Y(()=>String(v1(n.yaml,`id`)??``)),a=Y(()=>Object.entries(v1(n.yaml,`inputs`)??{})),o=Y(()=>QO({id:``,name:``,repository:String(v1(n.yaml,`repository`)??``)||void 0})),s=J([]),c=J({}),l=Y(()=>[{value:``,label:`Pick a source`,disabled:!0},...s.value.map(e=>({value:e,label:c.value[e]?`${c.value[e]} (${e})`:e})),{value:F2,label:`New source…`}]),u=J([]),d=J([]),f=J([]),p=J([]),m=J(!0),h=J(``),g=J(``),_=J(null),v=J({}),y=J(``),b=J(null),x=J(!1),S=J(!1),C=J(!1),w=J(null),T=J(``),ee=J(n.binding?.status??``);async function E(){let e=await Z.captures(100).catch(()=>null);u.value=e?.captures??[]}Be(async()=>{let[e,t,r,i]=await Promise.all([Z.sources().catch(()=>null),Z.eventTypes().catch(()=>null),Z.mappings().catch(()=>null),Z.bindings().catch(()=>null),E()]);if(s.value=(e?.sources??[]).map(e=>e.path),c.value=Object.fromEntries((e?.sources??[]).filter(e=>e.name).map(e=>[e.path,e.name])),d.value=t?.event_types??[],f.value=r?.mappings??[],p.value=i?.bindings??[],n.binding){h.value=n.binding.matcher?.source??``;let e=f.value.find(e=>String(e.id)===n.binding?.mapping_id),t=a2(n.binding,e?.fields??[]);v.value=t.rows,y.value=t.repositoryPath}else s.value.length===1&&(h.value=s.value[0]);for(let[e]of a.value)v.value[e]??={from:`path`,path:``,value:``};m.value=!1}),tp(`captures`,()=>void E(),500);let D=Y(()=>h.value===F2?g.value.trim():h.value),te=Y(()=>Jk(window.location.origin,D.value)),O=Y(()=>u.value.filter(e=>e.source===D.value));N(O,e=>{e.some(e=>e.id===_.value)||(_.value=e[0]?.id??null)},{immediate:!0});let ne=Y(()=>O.value.find(e=>e.id===_.value)),re=Y(()=>s2(ne.value)),ie=Y(()=>o2(re.value)),ae=Y(()=>t2(a.value,v.value,o.value?y.value:``)),oe;N([ae,_],()=>{if(clearTimeout(oe),_.value===null||!ae.value.length){b.value=null;return}let e=_.value;oe=setTimeout(async()=>{let t=await Z.mappingPreview(e,ae.value).catch(()=>null);e===_.value&&(b.value=t)},250)},{deep:!0,immediate:!0});let se=Y(()=>D.value?h.value===F2?[`create the source first`]:ne.value?re.value===null?[`the picked event's body is not JSON`]:r2(a.value,v.value,b.value):[`no event from ${D.value} yet to preview against`]:[`pick a source`]);function ce(e){let t=b.value?.failures?.find(t=>t.field_name===e);if(t)return{failure:t.reason};let n=b.value?.values??{};return e in n?{value:l2(n[e])}:{}}function le(e){return p.value.some(t=>t.mapping_id===e&&t.id!==n.binding?.id)}async function ue(e){return f.value.find(e=>String(e.id)===n.binding?.mapping_id)?.event_type_id||(e.event_type?e.event_type:(await Z.eventTypeCreate({source:D.value,name:`${D.value} event`,example:{headers:c2(e),body:e.body??``}})).id)}async function de(){if(D.value&&!C.value){C.value=!0,T.value=``;try{let e=await Z.sourceCreate(D.value);w.value=e,s.value.push(e.path),h.value=e.path,g.value=``}catch(e){T.value=e instanceof Error?e.message:String(e)}finally{C.value=!1}}}async function fe(){if(!se.value.length&&ne.value){x.value=!0,T.value=``;try{let e={name:`${i.value} ← ${D.value}`,event_type_id:await ue(ne.value),fields:ae.value},t=n.binding?.mapping_id,s=t&&!le(t)?await Z.mappingUpdate(t,e):await Z.mappingCreate(e),c={name:n.binding?.name||`${D.value} → ${i.value}`,matcher:{source:D.value},mapping_id:String(s.id),filter:n.binding?.filter??``,workflow:i.value,repo_param:o.value&&y.value.trim()?e2:``,owner:n.binding?.owner??``,repo:n.binding?.repo??``,inputs:i2(a.value,v.value)};n.binding?await Z.bindingUpdate(n.binding.id,c):await Z.bindingCreate(c),r(`saved`)}catch(e){T.value=e instanceof Error?e.message:String(e)}finally{x.value=!1}}}async function pe(e,t){if(n.binding){T.value=``;try{await e(n.binding.id),ee.value=t,r(`saved`)}catch(e){T.value=e instanceof Error?e.message:String(e)}}}async function me(){if(n.binding){x.value=!0,T.value=``;try{await Z.bindingDelete(n.binding.id),r(`saved`)}catch(e){T.value=e instanceof Error?e.message:String(e)}finally{x.value=!1}}}let he=()=>pe(Z.bindingApprove,`armed`),ge=()=>pe(Z.bindingPause,`paused`),_e=()=>pe(Z.bindingResume,`pending_approval`);return(t,n)=>(L(),j(`div`,u2,[A(V(TE),{open:S.value,"onUpdate:open":n[0]||=e=>S.value=e},{default:I(()=>[A(V(OE),null,{default:I(()=>[A(V(jE),null,{default:I(()=>[A(V(NE),null,{default:I(()=>[...n[8]||=[H(`Remove event binding?`,-1)]]),_:1}),A(V(kE),null,{default:I(()=>[...n[9]||=[H(`This event will stop starting this workflow. The event source and mapping are kept.`,-1)]]),_:1})]),_:1}),A(V(AE),null,{default:I(()=>[A(V(DE),null,{default:I(()=>[...n[10]||=[H(`Cancel`,-1)]]),_:1}),A(V(EE),{onClick:me},{default:I(()=>[...n[11]||=[H(`Remove binding`,-1)]]),_:1})]),_:1})]),_:1})]),_:1},8,[`open`]),R(`header`,d2,[A(V(X),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Back to settings`,onClick:n[1]||=e=>r(`back`)},{default:I(()=>[A(V(Rl))]),_:1}),R(`div`,f2,B(e.binding?e.binding.name:`Bind an event`),1),ee.value?(L(),q(V(k),{key:0,variant:V(ik)(ee.value)},{default:I(()=>[H(B(V(rk)(ee.value)),1)]),_:1},8,[`variant`])):F(``,!0)]),m.value?(L(),j(`div`,p2,[A(V(uD))])):(L(),j(`form`,{key:1,class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`,onSubmit:pt(fe,[`prevent`])},[R(`section`,m2,[n[13]||=R(`label`,{for:`bind-source`,class:`text-xs font-medium text-fg-muted`},`Source`,-1),A(I1,{id:`bind-source`,"aria-label":`Source`,"model-value":h.value,options:l.value,class:`w-full`,disabled:!!e.binding,"onUpdate:modelValue":n[2]||=e=>h.value=e},null,8,[`model-value`,`options`,`disabled`]),h.value===F2?(L(),q(V(Q),{key:0,modelValue:g.value,"onUpdate:modelValue":n[3]||=e=>g.value=e,"aria-label":`New source path`,placeholder:`path, e.g. alertmanager`,class:`h-8 w-full font-mono text-label`},null,8,[`modelValue`])):F(``,!0),h.value===F2?(L(),q(V(X),{key:1,type:`button`,size:`sm`,disabled:C.value||!D.value,onClick:de},{default:I(()=>[C.value?(L(),q(V(uD),{key:0})):F(``,!0),n[12]||=H(`Create source`,-1)]),_:1},8,[`disabled`])):F(``,!0)]),w.value?(L(),q(Qk,{key:0,source:w.value,onDismiss:n[4]||=e=>w.value=null},null,8,[`source`])):F(``,!0),D.value?(L(),j(`section`,h2,[n[14]||=R(`label`,{for:`bind-capture`,class:`text-xs font-medium text-fg-muted`},`Example event`,-1),O.value.length?(L(),q(V(Vu),{key:0,"model-value":_.value??void 0,"onUpdate:modelValue":n[5]||=e=>_.value=String(e)},{default:I(()=>[A(V(Gu),{id:`bind-capture`,size:`sm`,class:`w-full`,"aria-label":`Example event`},{default:I(()=>[A(V(Ku),{placeholder:`Pick an event`})]),_:1}),A(V(Hu),null,{default:I(()=>[(L(!0),j(U,null,M(O.value,e=>(L(),q(V(Wu),{key:e.id,value:String(e.id)},{default:I(()=>[H(`#`+B(e.id)+` · `,1),A(V(dw),{at:e.received_at,absolute:``},null,8,[`at`]),H(B(e.event_type?``:` · unidentified`),1)]),_:2},1032,[`value`]))),128))]),_:1})]),_:1},8,[`model-value`])):(L(),j(`p`,{key:1,class:`text-xs text-fg-subtle`,title:`Send an event to ${te.value} and it appears here`},`No events`,8,g2))])):F(``,!0),R(`section`,_2,[n[16]||=R(`div`,{class:`text-xs font-medium text-fg-muted`},`Inputs`,-1),R(`datalist`,v2,[(L(!0),j(U,null,M(ie.value,e=>(L(),j(`option`,{key:e,value:e},null,8,y2))),128))]),R(`div`,b2,[(L(!0),j(U,null,M(a.value,([e,t])=>(L(),j(`div`,{key:e,class:`space-y-1 px-3 py-2`},[R(`div`,x2,[R(`span`,S2,B(e),1),R(`span`,C2,B(t.type??`string`),1),t.required?(L(),j(`span`,w2,`*`)):F(``,!0),A(V(X),{type:`button`,variant:`ghost`,size:`icon-xs`,class:`ml-auto`,title:v.value[e].from===`path`?`Use a fixed value`:`Read from the event`,"aria-label":`${e}: ${v.value[e].from===`path`?`use a fixed value`:`read from the event`}`,onClick:t=>v.value[e].from=v.value[e].from===`path`?`value`:`path`},{default:I(()=>[v.value[e].from===`path`?(L(),q(V(yte),{key:0})):(L(),q(V(Kl),{key:1}))]),_:2},1032,[`title`,`aria-label`,`onClick`])]),v.value[e].from===`path`?(L(),q(V(Q),{key:0,modelValue:v.value[e].path,"onUpdate:modelValue":t=>v.value[e].path=t,list:`bind-paths`,"aria-label":`${e} payload path`,placeholder:`payload path`,class:`h-8 w-full font-mono text-xs`},null,8,[`modelValue`,`onUpdate:modelValue`,`aria-label`])):(L(),q(V(Q),{key:1,modelValue:v.value[e].value,"onUpdate:modelValue":t=>v.value[e].value=t,"aria-label":`${e} fixed value`,placeholder:`fixed value`,class:`h-8 w-full font-mono text-xs`},null,8,[`modelValue`,`onUpdate:modelValue`,`aria-label`])),v.value[e].from===`path`&&ce(e).failure?(L(),j(`p`,T2,B(ce(e).failure),1)):v.value[e].from===`path`&&ce(e).value!==void 0?(L(),j(`p`,{key:3,class:`truncate font-mono text-xs text-success`,title:ce(e).value},B(ce(e).value),9,E2)):F(``,!0)]))),128)),o.value?(L(),j(`div`,D2,[n[15]||=R(`div`,{class:`text-xs`,title:`Optional: owner/name of a configured repository; blank uses the configured one`},`Repository`,-1),A(V(Q),{modelValue:y.value,"onUpdate:modelValue":n[6]||=e=>y.value=e,list:`bind-paths`,"aria-label":`Repository payload path`,placeholder:`payload path`,class:`h-8 w-full font-mono text-xs`},null,8,[`modelValue`]),ce(V(`repository_path`)).failure?(L(),j(`p`,O2,B(ce(V(e2)).failure),1)):ce(V(`repository_path`)).value===void 0?F(``,!0):(L(),j(`p`,k2,B(ce(V(e2)).value),1))])):F(``,!0),!a.value.length&&!o.value?(L(),j(`p`,A2,`No inputs.`)):F(``,!0)])]),R(`div`,j2,[T.value?(L(),j(`p`,M2,B(T.value),1)):se.value.length?(L(),j(`p`,N2,`Cannot save: `+B(se.value[0]),1)):F(``,!0),R(`div`,P2,[A(V(X),{type:`submit`,size:`sm`,disabled:x.value||!!se.value.length},{default:I(()=>[x.value?(L(),q(V(uD),{key:0})):F(``,!0),n[17]||=H(`Save binding`,-1)]),_:1},8,[`disabled`]),e.binding&&ee.value===`pending_approval`?(L(),q(V(X),{key:0,type:`button`,size:`sm`,variant:`outline`,onClick:he},{default:I(()=>[...n[18]||=[H(`Approve`,-1)]]),_:1})):F(``,!0),e.binding&&ee.value===`armed`?(L(),q(V(X),{key:1,type:`button`,size:`sm`,variant:`outline`,onClick:ge},{default:I(()=>[...n[19]||=[H(`Pause`,-1)]]),_:1})):F(``,!0),e.binding&&ee.value===`paused`?(L(),q(V(X),{key:2,type:`button`,size:`sm`,variant:`outline`,onClick:_e},{default:I(()=>[...n[20]||=[H(`Resume`,-1)]]),_:1})):F(``,!0),e.binding?(L(),q(V(X),{key:3,type:`button`,size:`sm`,variant:`destructive`,disabled:x.value,onClick:n[7]||=e=>S.value=!0},{default:I(()=>[...n[21]||=[H(`Remove binding`,-1)]]),_:1},8,[`disabled`])):F(``,!0)])])],32))]))}}),L2={key:1,class:`space-y-4 px-3 py-3`},R2={class:`space-y-1.5`},z2={class:`flex justify-end`},B2={key:0,class:`divide-y divide-border rounded-md border border-border`},V2=[`onClick`],H2={class:`truncate`},U2={key:1,class:`ml-auto truncate text-xs text-fg-subtle`},W2={class:`truncate`},G2={class:`ml-auto truncate text-xs text-fg-subtle`},K2={key:2,class:`flex items-center gap-2 px-3 py-2`,title:`Built-in issue routing. Disable this workflow to stop it running automatically.`},q2={class:`truncate`},J2={key:1,class:`ml-auto truncate text-xs text-fg-subtle`},Y2={key:1,class:`text-xs text-fg-subtle`},X2=P({__name:`TriggerSettings`,props:{yaml:{},triggers:{}},emits:[`update:yaml`,`bound`],setup(e,{emit:t}){let n=t,r=J();function i(){r.value=void 0,n(`bound`)}return(t,a)=>{let o=Me(`RouterLink`);return r.value===void 0?(L(),j(`div`,L2,[R(`section`,R2,[R(`div`,z2,[A(V(X),{type:`button`,variant:`ghost`,size:`xs`,onClick:a[1]||=e=>r.value=null},{default:I(()=>[A(V(Eu),{"data-icon":`inline-start`}),a[3]||=H(`Bind an event`,-1)]),_:1})]),e.triggers.length?(L(),j(`ul`,B2,[(L(!0),j(U,null,M(e.triggers,e=>(L(),j(`li`,{key:e.kind+e.label,class:`text-label`},[e.binding?(L(),j(`button`,{key:0,type:`button`,class:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-secondary`,onClick:t=>r.value=e.binding},[R(`span`,H2,B(e.label),1),e.binding.status===`armed`?F(``,!0):(L(),q(V(k),{key:0,variant:V(ik)(e.binding.status)},{default:I(()=>[H(B(V(rk)(e.binding.status)),1)]),_:2},1032,[`variant`])),e.detail?(L(),j(`span`,U2,B(e.detail),1)):F(``,!0)],8,V2)):e.kind===`workflow`||e.kind===`playbook`?(L(),q(o,{key:1,to:e.kind===`workflow`?{path:`/workflows`,query:{workflow:e.label}}:{path:`/org/playbooks`},class:`flex items-center gap-2 px-3 py-2 hover:bg-secondary`},{default:I(()=>[R(`span`,W2,B(e.label),1),R(`span`,G2,B(e.detail),1)]),_:2},1032,[`to`])):(L(),j(`div`,K2,[R(`span`,q2,B(e.label),1),e.kind===`issue`?(L(),q(V(k),{key:0,variant:`outline`,class:`ml-auto`},{default:I(()=>[...a[4]||=[H(`Built-in`,-1)]]),_:1})):F(``,!0),e.detail?(L(),j(`span`,J2,B(e.detail),1)):F(``,!0)]))]))),128))])):(L(),j(`p`,Y2,`Manual runs only.`))]),A(V0,{yaml:e.yaml,field:`inputs`,"onUpdate:yaml":a[2]||=e=>n(`update:yaml`,e)},null,8,[`yaml`])])):(L(),q(I2,{key:0,yaml:e.yaml,binding:r.value,onBack:a[0]||=e=>r.value=void 0,onSaved:i},null,8,[`yaml`,`binding`]))}}}),Z2=P({__name:`RunWorkflowButton`,props:Ye({workflow:{},disabled:{type:Boolean},draft:{}},{open:{type:Boolean,default:!1},openModifiers:{}}),emits:Ye([`started`],[`update:open`]),setup(e,{emit:t}){let n=t,r=ke(e,`open`);function i(e){r.value=!1,n(`started`,e)}return(t,n)=>(L(),q(V(pw),{open:r.value,"onUpdate:open":n[1]||=e=>r.value=e},{default:I(()=>[A(V(yw),{"as-child":``},{default:I(()=>[A(V(X),{type:`button`,size:`sm`,variant:`outline`,"aria-label":`${e.draft===void 0?`Run`:`Test`} ${e.workflow}`,disabled:e.disabled,title:e.draft===void 0?e.disabled?`Save first`:void 0:`Runs this draft once. Every delivery is recorded as what it would have sent and none is sent, including in called workflows; reads, model calls and commands still run`},{default:I(()=>[(L(),q(_e(e.draft===void 0?V(Tu):V(gu)),{"data-icon":`inline-start`})),n[2]||=H(),R(`span`,null,B(e.draft===void 0?`Run`:`Test`),1)]),_:1},8,[`aria-label`,`disabled`,`title`])]),_:1}),A(V(mw),{class:`sm:max-w-[640px]`},{default:I(()=>[A(V(_w),null,{default:I(()=>[A(V(vw),null,{default:I(()=>[H(B(e.draft===void 0?`Run`:`Test`)+` `+B(e.workflow),1)]),_:1})]),_:1}),r.value?(L(),q(VD,{key:0,workflow:e.workflow,draft:e.draft,onStarted:i,onCancel:n[0]||=e=>r.value=!1},null,8,[`workflow`,`draft`])):F(``,!0)]),_:1})]),_:1},8,[`open`]))}});function Q2(e){return Re()?(Ve(e),!0):!1}function $2(e){return typeof e==`function`?e():V(e)}var e4=typeof window<`u`&&typeof document<`u`,t4=e=>e!==void 0,n4=Object.prototype.toString,r4=e=>n4.call(e)===`[object Object]`,i4=()=>{};function a4(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}var o4=e=>e();function s4(e=o4){let t=J(!0);function n(){t.value=!1}function r(){t.value=!0}return{isActive:Le(t),pause:n,resume:r,eventFilter:(...n)=>{t.value&&e(...n)}}}function c4(e,t=!1,n=`Timeout`){return new Promise((r,i)=>{setTimeout(t?()=>i(n):r,e)})}function l4(e,t,n={}){let{eventFilter:r=o4,...i}=n;return N(e,a4(r,t),i)}function u4(e,t,n={}){let{eventFilter:r,...i}=n,{eventFilter:a,pause:o,resume:s,isActive:c}=s4(r);return{stop:l4(e,t,{...i,eventFilter:a}),pause:o,resume:s,isActive:c}}function d4(e,t={}){if(!$e(e))return Te(e);let n=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(let r in e.value)n[r]=Ie(()=>({get(){return e.value[r]},set(n){if($2(t.replaceRef)??!0){if(Array.isArray(e.value)){let t=[...e.value];t[r]=n,e.value=t}else{let t={...e.value,[r]:n};Object.setPrototypeOf(t,Object.getPrototypeOf(e.value)),e.value=t}}else e.value[r]=n}}));return n}function f4(e,t=!1){function n(n,{flush:r=`sync`,deep:i=!1,timeout:a,throwOnTimeout:o}={}){let s=null,c=[new Promise(a=>{s=N(e,e=>{n(e)!==t&&(s?.(),a(e))},{flush:r,deep:i,immediate:!0})})];return a!=null&&c.push(c4(a,o).then(()=>$2(e)).finally(()=>s?.())),Promise.race(c)}function r(r,i){if(!$e(r))return n(e=>e===r,i);let{flush:a=`sync`,deep:o=!1,timeout:s,throwOnTimeout:c}=i??{},l=null,u=[new Promise(n=>{l=N([e,r],([e,r])=>{t!==(e===r)&&(l?.(),n(e))},{flush:a,deep:o,immediate:!0})})];return s!=null&&u.push(c4(s,c).then(()=>$2(e)).finally(()=>(l?.(),$2(e)))),Promise.race(u)}function i(e){return n(e=>!!e,e)}function a(e){return r(null,e)}function o(e){return r(void 0,e)}function s(e){return n(Number.isNaN,e)}function c(e,t){return n(t=>{let n=Array.from(t);return n.includes(e)||n.includes($2(e))},t)}function l(e){return u(1,e)}function u(e=1,t){let r=-1;return n(()=>(r+=1,r>=e),t)}return Array.isArray($2(e))?{toMatch:n,toContains:c,changed:l,changedTimes:u,get not(){return f4(e,!t)}}:{toMatch:n,toBe:r,toBeTruthy:i,toBeNull:a,toBeNaN:s,toBeUndefined:o,changed:l,changedTimes:u,get not(){return f4(e,!t)}}}function p4(e){return f4(e)}function m4(e){let t=$2(e);return t?.$el??t}var h4=e4?window:void 0;function g4(...e){let t,n,r,i;if(typeof e[0]==`string`||Array.isArray(e[0])?([n,r,i]=e,t=h4):[t,n,r,i]=e,!t)return i4;Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]);let a=[],o=()=>{a.forEach(e=>e()),a.length=0},s=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),c=N(()=>[m4(t),$2(i)],([e,t])=>{if(o(),!e)return;let i=r4(t)?{...t}:t;a.push(...n.flatMap(t=>r.map(n=>s(e,t,n,i))))},{immediate:!0,flush:`post`}),l=()=>{c(),o()};return Q2(l),l}function _4(e){return typeof e==`function`?e:typeof e==`string`?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function v4(...e){let t,n,r={};e.length===3?(t=e[0],n=e[1],r=e[2]):e.length===2?typeof e[1]==`object`?(t=!0,n=e[0],r=e[1]):(t=e[0],n=e[1]):(t=!0,n=e[0]);let{target:i=h4,eventName:a=`keydown`,passive:o=!1,dedupe:s=!1}=r,c=_4(t);return g4(i,a,e=>{e.repeat&&$2(s)||c(e)&&n(e)},o)}function y4(e){return JSON.parse(JSON.stringify(e))}function b4(e,t,n,r={}){let{clone:i=!1,passive:a=!1,eventName:o,deep:s=!1,defaultValue:c,shouldEmit:l}=r,u=pe(),d=n||u?.emit||(u?.$emit)?.bind(u)||(u?.proxy?.$emit)?.bind(u?.proxy),f=o;t||=`modelValue`,f||=`update:${t.toString()}`;let p=e=>i?typeof i==`function`?i(e):y4(e):e,m=()=>t4(e[t])?p(e[t]):c,h=e=>{l?l(e)&&d(f,e):d(f,e)};if(a){let n=m(),r=J(n),i=!1;return N(()=>e[t],e=>{i||(i=!0,r.value=p(e),We(()=>i=!1))}),N(r,n=>{!i&&(n!==e[t]||s)&&h(n)},{deep:s}),r}return Y({get(){return m()},set(e){h(e)}})}var x4={value:()=>{}};function S4(){for(var e=0,t=arguments.length,n={},r;e=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}C4.prototype=S4.prototype={constructor:C4,on:function(e,t){var n=this._,r=w4(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a0)for(var n=Array(i),r=0,i,a;r=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),O4.hasOwnProperty(t)?{space:O4[t],local:e}:e}function A4(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===D4&&t.documentElement.namespaceURI===D4?t.createElement(e):t.createElementNS(n,e)}}function j4(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function M4(e){var t=k4(e);return(t.local?j4:A4)(t)}function N4(){}function P4(e){return e==null?N4:function(){return this.querySelector(e)}}function F4(e){typeof e!=`function`&&(e=P4(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i=v&&(v=_+1);!(b=g[v])&&++v=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function d3(e){e||=f3;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;at?1:e>=t?0:NaN}function p3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function m3(){return Array.from(this)}function h3(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?D3:typeof t==`function`?k3:O3)(e,t,n??``)):j3(this.node(),e)}function j3(e,t){return e.style.getPropertyValue(t)||E3(e).getComputedStyle(e,null).getPropertyValue(t)}function M3(e){return function(){delete this[e]}}function N3(e,t){return function(){this[e]=t}}function P3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function F3(e,t){return arguments.length>1?this.each((t==null?M3:typeof t==`function`?P3:N3)(e,t)):this.node()[e]}function I3(e){return e.trim().split(/^|\s+/)}function L3(e){return e.classList||new R3(e)}function R3(e){this._node=e,this._names=I3(e.getAttribute(`class`)||``)}R3.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function z3(e,t){for(var n=L3(e),r=-1,i=t.length;++r=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function m6(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n()=>e;function I6(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}I6.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function L6(e){return!e.ctrlKey&&!e.button}function R6(){return this.parentNode}function z6(e,t){return t??{x:e.x,y:e.y}}function B6(){return navigator.maxTouchPoints||`ontouchstart`in this}function V6(){var e=L6,t=R6,n=z6,r=B6,i={},a=S4(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,k6).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(E6(n.view).on(`mousemove.drag`,m,A6).on(`mouseup.drag`,h,A6),N6(n.view),j6(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(M6(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){E6(e.view).on(`mousemove.drag mouseup.drag`,null),P6(e.view,l),M6(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?t8(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?t8(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Eie.exec(e))?new r8(t[1],t[2],t[3],1):(t=Die.exec(e))?new r8(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Oie.exec(e))?t8(t[1],t[2],t[3],t[4]):(t=kie.exec(e))?t8(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Aie.exec(e))?l8(t[1],t[2]/100,t[3]/100,1):(t=jie.exec(e))?l8(t[1],t[2]/100,t[3]/100,t[4]):X6.hasOwnProperty(e)?e8(X6[e]):e===`transparent`?new r8(NaN,NaN,NaN,0):null}function e8(e){return new r8(e>>16&255,e>>8&255,e&255,1)}function t8(e,t,n,r){return r<=0&&(e=t=n=NaN),new r8(e,t,n,r)}function Pie(e){return e instanceof W6||(e=$6(e)),e?(e=e.rgb(),new r8(e.r,e.g,e.b,e.opacity)):new r8}function n8(e,t,n,r){return arguments.length===1?Pie(e):new r8(e,t,n,r??1)}function r8(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}H6(r8,n8,U6(W6,{brighter(e){return e=e==null?K6:K6**+e,new r8(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?G6:G6**+e,new r8(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new r8(s8(this.r),s8(this.g),s8(this.b),o8(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:i8,formatHex:i8,formatHex8:Fie,formatRgb:a8,toString:a8}));function i8(){return`#${c8(this.r)}${c8(this.g)}${c8(this.b)}`}function Fie(){return`#${c8(this.r)}${c8(this.g)}${c8(this.b)}${c8((isNaN(this.opacity)?1:this.opacity)*255)}`}function a8(){let e=o8(this.opacity);return`${e===1?`rgb(`:`rgba(`}${s8(this.r)}, ${s8(this.g)}, ${s8(this.b)}${e===1?`)`:`, ${e})`}`}function o8(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function s8(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function c8(e){return e=s8(e),(e<16?`0`:``)+e.toString(16)}function l8(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new d8(e,t,n,r)}function u8(e){if(e instanceof d8)return new d8(e.h,e.s,e.l,e.opacity);if(e instanceof W6||(e=$6(e)),!e)return new d8;if(e instanceof d8)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new d8(o,s,c,e.opacity)}function Iie(e,t,n,r){return arguments.length===1?u8(e):new d8(e,t,n,r??1)}function d8(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}H6(d8,Iie,U6(W6,{brighter(e){return e=e==null?K6:K6**+e,new d8(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?G6:G6**+e,new d8(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new r8(m8(e>=240?e-240:e+120,i,r),m8(e,i,r),m8(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new d8(f8(this.h),p8(this.s),p8(this.l),o8(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=o8(this.opacity);return`${e===1?`hsl(`:`hsla(`}${f8(this.h)}, ${p8(this.s)*100}%, ${p8(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function f8(e){return e=(e||0)%360,e<0?e+360:e}function p8(e){return Math.max(0,Math.min(1,e||0))}function m8(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var h8=e=>()=>e;function Lie(e,t){return function(n){return e+n*t}}function Rie(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function zie(e){return(e=+e)==1?g8:function(t,n){return n-t?Rie(t,n,e):h8(isNaN(t)?n:t)}}function g8(e,t){var n=t-e;return n?Lie(e,n):h8(isNaN(e)?t:e)}var _8=function e(t){var n=zie(t);function r(e,t){var r=n((e=n8(e)).r,(t=n8(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=g8(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r}(1);function Bie(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:v8(r,i)})),n=b8.lastIndex;return n180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:v8(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:v8(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:v8(e,n)},{i:s-2,x:v8(t,r)})}else(n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t=0&&e._call.call(void 0,t),e=e._next;--A8}function W8(){L8=(I8=z8.now())+R8,A8=j8=0;try{tae()}finally{A8=0,rae(),L8=0}}function nae(){var e=z8.now(),t=e-I8;t>N8&&(R8-=t,I8=e)}function rae(){for(var e,t=P8,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:P8=n);F8=e,G8(r)}function G8(e){A8||(j8&&=clearTimeout(j8),e-L8>24?(e<1/0&&(j8=setTimeout(W8,e-z8.now()-R8)),M8&&=clearInterval(M8)):(M8||=(I8=z8.now(),setInterval(nae,N8)),A8=1,B8(W8)))}function K8(e,t,n){var r=new H8;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var iae=S4(`start`,`end`,`cancel`,`interrupt`),aae=[],q8=0,J8=1,Y8=2,X8=3,Z8=4,Q8=5,$8=6;function e5(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;oae(e,n,{name:t,index:r,group:i,on:iae,tween:aae,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:q8})}function t5(e,t){var n=r5(e,t);if(n.state>q8)throw Error(`too late; already scheduled`);return n}function n5(e,t){var n=r5(e,t);if(n.state>X8)throw Error(`too late; already running`);return n}function r5(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function oae(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=U8(a,0,n.time);function a(e){n.state=J8,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==J8)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===X8)return K8(o);f.state===Z8?(f.state=$8,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+lY8&&r.state=0&&(e=e.slice(0,t)),!e||e===`start`})}function Iae(e,t,n){var r,i,a=Fae(t)?t5:n5;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Lae(e,t){var n=this._id;return arguments.length<2?r5(this.node(),n).on.on(e):this.each(Iae(n,e,t))}function Rae(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function zae(){return this.on(`end.remove`,Rae(this._id))}function Bae(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=P4(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o()=>e;function doe(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function f5(e,t,n){this.k=e,this.x=t,this.y=n}f5.prototype={constructor:f5,scale:function(e){return e===1?this:new f5(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new f5(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 p5=new f5(1,0,0);f5.prototype;function m5(e){e.stopImmediatePropagation()}function h5(e){e.preventDefault(),e.stopImmediatePropagation()}function foe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function poe(){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 g5(){return this.__zoom||p5}function moe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function hoe(){return navigator.maxTouchPoints||`ontouchstart`in this}function goe(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function _oe(){var e=foe,t=poe,n=goe,r=moe,i=hoe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=k8,l=S4(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,g5).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,ee).filter(i).on(`touchstart.zoom`,E).on(`touchmove.zoom`,D).on(`touchend.zoom touchcancel.zoom`,te).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,g5),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(p5.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new f5(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new f5(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new f5(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=E6(this.that).datum();l.call(e,this.that,new doe(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=O6(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],i5(this),s.start();h5(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=E6(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=O6(t,i),l=t.clientX,u=t.clientY;N6(t.view),m5(t),a.mouse=[c,this.__zoom.invert(c)],i5(this),a.start();function d(e){if(h5(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=O6(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),P6(e.view,a.moved),h5(e),a.event(e).end()}}function ee(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=O6(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);h5(r),s>0?E6(this).transition().duration(s).call(x,d,c,r):E6(this).call(_.transform,d,c,r)}}function E(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(m5(t),s=0;s(e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`,e))(_5||{}),v5=(e=>(e.Partial=`partial`,e.Full=`full`,e))(v5||{}),y5=(e=>(e.Bezier=`default`,e.SimpleBezier=`simple-bezier`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e))(y5||{}),b5=(e=>(e.Strict=`strict`,e.Loose=`loose`,e))(b5||{}),x5=(e=>(e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`,e))(x5||{}),S5=(e=>(e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`,e))(S5||{}),voe=[`INPUT`,`SELECT`,`TEXTAREA`],yoe=typeof document<`u`?document:null;function C5(e){let t=e.composedPath?.call(e)?.[0]||e.target,n=typeof t?.hasAttribute==`function`&&t.hasAttribute(`contenteditable`),r=typeof t?.closest==`function`?t.closest(`.nokey`):null;return voe.includes(t?.nodeName)||n||!!r}function boe(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function w5(e,t,n,r){let i=t.replace(`+`,` `).replace(` `,` diff --git a/ui/src/tasks/TaskTable.vue b/ui/src/tasks/TaskTable.vue index 9e817cecc..da728eb56 100644 --- a/ui/src/tasks/TaskTable.vue +++ b/ui/src/tasks/TaskTable.vue @@ -92,7 +92,7 @@ const issueHref = (task: Task) => (forgeIssue(task) && task.issue_url && task.is