Compare commits

..
14 Commits
Author SHA1 Message Date
sam 30419532ba chore(release): v1.49.2
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
deploy / gate (push) Canceled after 1m51s
2026-10-07 23:18:11 +11:00
sam fff67838e0 fix(releaseupdate): read GitHub releases directly; drop go-selfupdate and its openpgp dependency 2026-10-07 23:18:03 +11:00
sam 15ebe24927 chore(release): v1.49.1
deploy / gate (push) Failing after 3m43s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 23:10:38 +11:00
sam b2c1629925 fix(ui): an expired session reloads to the sign-in page instead of showing a banner 2026-10-07 23:05:52 +11:00
sam 0e8fcf70a0 chore(release): v1.49.0
deploy / gate (push) Failing after 5m18s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 22:17:00 +11:00
sam 4673b435b7 fix(extension): confine egress only for packages that declare egress hosts 2026-10-07 22:15:06 +11:00
sam 1e062fd7f0 fix(releaseupdate): reuse a found release for ten minutes to stay under GitHub's unauthenticated rate limit 2026-10-07 01:17:21 +11:00
sam 74a3ec925c feat(releaseupdate): archied update check finds releases through go-selfupdate; archie-update-check is deleted 2026-10-07 01:12:11 +11:00
sam 4944ec8473 chore(release): v1.48.1
deploy / gate (push) Failing after 3m28s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 01:00:30 +11:00
sam 204b65a0e3 fix(controlplane): update-settings selects a release channel; services run only the installed update scripts 2026-10-07 01:00:28 +11:00
sam cbedb8a504 chore(release): v1.48.0
deploy / gate (push) Failing after 5m4s
deploy / archied-image (push) Skipped
deploy / agent-image (push) Skipped
deploy / dist-zip (push) Skipped
2026-10-07 00:57:07 +11:00
sam a8dbab0cff feat(controlplane): update commands are an update-settings kind edited on Status, defaulting to the installed scripts 2026-10-07 00:57:01 +11:00
sam 789ff73fe9 fix(scripts): archie-update-install loads the archie env file so a shell run can back up the bundled database 2026-10-07 00:53:23 +11:00
sam 5176938e95 ci(deploy): build the archied and agent images in parallel so the release zip waits only on the agent image 2026-10-07 00:35:13 +11:00
44 changed files with 700 additions and 626 deletions

No files matched your search

+42 -11
View File
@@ -170,9 +170,7 @@ jobs:
echo "This commit is not a release, so the images are published as :edge and sha-<sha>; :latest keeps naming the newest release."
fi
build-and-push:
outputs:
agent_digest: ${{ steps.agent.outputs.digest }}
archied-image:
needs: gate
runs-on: ubuntu-latest
steps:
@@ -264,6 +262,43 @@ jobs:
cache-from: type=gha,scope=archied
cache-to: type=gha,mode=max,scope=archied
agent-image:
outputs:
agent_digest: ${{ steps.agent.outputs.digest }}
needs: gate
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Annotated tags: dereference to the commit, as archied-image does.
- name: Resolve the commit this ref points at
id: commit
run: |
sha="$(git rev-parse "${GITHUB_REF}^{commit}")"
echo "sha=$sha" >> "$GITHUB_OUTPUT"
echo "short=${sha:0:12}" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Resolve runtime version
id: versions
run: |
RUNTIME_TAG="$(git tag --points-at HEAD --list 'archie/v*' | sort -V | tail -1)"
RELEASE_TAG="$(git tag --points-at HEAD --list 'v*' | sort -V | tail -1)"
RUNTIME_VERSION="${RUNTIME_TAG#archie/}"
[ -n "$RUNTIME_VERSION" ] || RUNTIME_VERSION="${RELEASE_TAG#v}"
echo "runtime_tag=$RUNTIME_TAG" >> "$GITHUB_OUTPUT"
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
echo "runtime=$RUNTIME_VERSION" >> "$GITHUB_OUTPUT"
- name: Build and push archie-agent
id: agent
if: steps.versions.outputs.runtime_tag != '' || steps.versions.outputs.release_tag != ''
@@ -283,14 +318,10 @@ jobs:
# Packages every host-run binary (archied, archie-gateway,
# archie-state-store, archie-ui, archie-messaging) as a
# linux/amd64 zip for a
# non-Docker install. Independent of build-and-push: it never touches the
# archied/archie-agent image jobs, and a gateway-only release (no
# archie/v* tag) still produces this zip -- it's keyed to the archied tag
# alone. archie-agent is deliberately excluded: it only ever runs inside
# the Docker image build-and-push already publishes, never as a host
# binary (archie-core-8cda.4.7.1).
# non-Docker install. It waits only for the agent image, whose digest
# release.json pins; archie-agent itself never ships as a host binary.
dist-zip:
needs: [gate, build-and-push]
needs: [gate, agent-image]
# Not gated on github.ref. A release is pushed as main plus both tags at
# one SHA, the concurrency group below collapses those into a single run,
# and the survivor is whichever ref happened to start last -- for
@@ -352,7 +383,7 @@ jobs:
done
cp deployments/INSTRUCTIONS.md CHANGELOG.md "$name/"
cp scripts/archie-update-* "$name/"
digest='${{ needs.build-and-push.outputs.agent_digest }}'
digest='${{ needs.agent-image.outputs.agent_digest }}'
test -n "$digest"
jq --arg image "ghcr.io/samcharles93/archie-agent@$digest" '. + {agent_image: $image}' release.json > "$name/release.json"
# README.md doesn't exist yet in this repo; include it once it does
+32
View File
@@ -5,6 +5,38 @@ release's per-component sections are labelled beneath its heading.
## [Unreleased]
## [1.49.2] - 2026-10-07
### archied
- Carries the 1.49.0 and 1.49.1 changes, whose builds were never published. The update check reads GitHub releases directly and still offers only releases with a verifiable linux-amd64 zip.
## [1.49.1] - 2026-10-07
### archied
- When the dashboard session expires, the page returns to the sign-in screen instead of showing errors on every page until a manual refresh.
## [1.49.0] - 2026-10-07
### archied
- Extensions that declare no egress hosts (vault, email, gitea) reach the network again; only packages that declare their hosts are confined to them. The Accept dialog shows "network: unrestricted" for the rest.
- The update check finds releases itself, and reuses a found release for ten minutes so repeated checks stay under GitHub's rate limit.
## [1.48.1] - 2026-10-07
### archied
- **Settings → Status → Updates** now chooses only the release channel (stable, prereleases, or a pinned version). Update checks and installs always run the `archie-update-*` scripts installed beside the binaries; the dashboard can no longer set the command that runs.
## [1.48.0] - 2026-10-07
### archied
- **Settings → Status → Updates** edits the update check and install commands. They default to the `archie-update-*` scripts installed beside the binaries, so a zip install shows **Install** on the Versions card with nothing configured. The `update_check_command` and `update_install_command` keys under `[chat.telegram]` are no longer read; remove them from `config.toml`.
- `archie-update-install` run from a shell now reads `~/.config/archie/env`, so the pre-update backup of the bundled database no longer fails with `no password supplied`. Run it with `--auto` to install the newest release.
## [1.47.3] - 2026-10-07
### archied
+2 -2
View File
@@ -16,8 +16,8 @@ func main() {
if archied.IsSetupArgs(args) {
os.Exit(archied.RunSetup(args[1:], os.Stdin, os.Stdout, os.Stderr))
}
if len(args) > 0 && args[0] == "select-release" {
os.Exit(archied.RunReleaseChannel(args[1:], os.Stdin, os.Stdout, os.Stderr))
if len(args) > 0 && args[0] == "update" {
os.Exit(archied.RunUpdate(args[1:], os.Stdout, os.Stderr))
}
if len(args) > 0 && args[0] == "update-image" {
os.Exit(archied.RunUpdateImage(args[1:], os.Stderr))
-7
View File
@@ -146,16 +146,9 @@ class = "ollama"
# "openrouter/openai/gpt-5.6-sol",
# ]
# Optional self-hosted update adapter. Both values are argv arrays (never
# shell snippets). The check command must write a releaseupdate.Snapshot JSON
# document to stdout; configure the installer as well to show Approve/Defer.
# [chat.telegram]
# The bot token from @BotFather, resolved through a configured secret engine.
# token = { engine = "bws", key = "TELEGRAM_BOT_TOKEN" }
# Run by archie-messaging, which serves /update, so these commands execute on
# whichever host runs that process.
# update_check_command = ["/usr/local/bin/archie-update-check"]
# update_install_command = ["/usr/local/bin/archie-update-install"]
# Email and the generic inbound webhook are archipelago channel extensions
# (channels/email, channels/webhook): install, accept and enable them from the
+5 -4
View File
@@ -92,14 +92,15 @@ an install (or an upgrade across v1.30.0) needs its unit as well -- see
`archie-update-install` downloads the approved release's Linux/amd64 archive
and verifies its `SHA256SUMS` entry before executing or installing it. Releases
must include `release.json`, all host binaries, and the three updater scripts.
must include `release.json`, all host binaries, and the two updater scripts.
Older releases without this contract cannot be installed through the artifact
path. `--from-source` (or `ARCHIE_UPDATE_SOURCE_BUILD=1`) explicitly clones and
builds the selected release instead.
The update check command accepts `--channel stable` (default), `--channel next`
(includes prereleases), or `--channel exact-pin --pin 1.2.3`. Set these arguments
in the control plane's channel settings alongside the existing check command.
`archied update check` finds the newest GitHub release with a linux-amd64 zip on
the channel chosen under Settings → Status → Updates: stable, next (includes
prereleases) or a pinned version. From a shell it reads
`ARCHIE_UPDATE_RELEASE_CHANNEL` and `ARCHIE_UPDATE_PIN`, or `-channel` and `-pin`.
The notification destination remains separate from the release channel.
For scheduled, unattended runs, `archie-update-install --auto` discovers the
+10
View File
@@ -65,6 +65,11 @@
"/news/archie/1.47.1/": "/news/1.47.1/",
"/news/archie/1.47.2/": "/news/1.47.2/",
"/news/archie/1.47.3/": "/news/1.47.3/",
"/news/archie/1.48.0/": "/news/1.48.0/",
"/news/archie/1.48.1/": "/news/1.48.1/",
"/news/archie/1.49.0/": "/news/1.49.0/",
"/news/archie/1.49.1/": "/news/1.49.1/",
"/news/archie/1.49.2/": "/news/1.49.2/",
"/news/archie/1.5.0/": "/news/1.5.0/",
"/news/archie/1.6.0/": "/news/1.6.0/",
"/news/archie/1.7.0/": "/news/1.7.0/",
@@ -147,6 +152,11 @@
"/news/archied/1.47.1/": "/news/1.47.1/",
"/news/archied/1.47.2/": "/news/1.47.2/",
"/news/archied/1.47.3/": "/news/1.47.3/",
"/news/archied/1.48.0/": "/news/1.48.0/",
"/news/archied/1.48.1/": "/news/1.48.1/",
"/news/archied/1.49.0/": "/news/1.49.0/",
"/news/archied/1.49.1/": "/news/1.49.1/",
"/news/archied/1.49.2/": "/news/1.49.2/",
"/news/archied/1.5.0/": "/news/1.5.0/",
"/news/archied/1.6.0/": "/news/1.6.0/",
"/news/archied/1.7.0/": "/news/1.7.0/",
+25
View File
@@ -1,4 +1,29 @@
[
{
"version": "1.49.2",
"date": "2026-10-07",
"body": "### archied\n\n- Carries the 1.49.0 and 1.49.1 changes, whose builds were never published. The update check reads GitHub releases directly and still offers only releases with a verifiable linux-amd64 zip."
},
{
"version": "1.49.1",
"date": "2026-10-07",
"body": "### archied\n\n- When the dashboard session expires, the page returns to the sign-in screen instead of showing errors on every page until a manual refresh."
},
{
"version": "1.49.0",
"date": "2026-10-07",
"body": "### archied\n\n- Extensions that declare no egress hosts (vault, email, gitea) reach the network again; only packages that declare their hosts are confined to them. The Accept dialog shows \"network: unrestricted\" for the rest.\n- The update check finds releases itself, and reuses a found release for ten minutes so repeated checks stay under GitHub's rate limit."
},
{
"version": "1.48.1",
"date": "2026-10-07",
"body": "### archied\n\n- **Settings → Status → Updates** now chooses only the release channel (stable, prereleases, or a pinned version). Update checks and installs always run the `archie-update-*` scripts installed beside the binaries; the dashboard can no longer set the command that runs."
},
{
"version": "1.48.0",
"date": "2026-10-07",
"body": "### archied\n\n- **Settings → Status → Updates** edits the update check and install commands. They default to the `archie-update-*` scripts installed beside the binaries, so a zip install shows **Install** on the Versions card with nothing configured. The `update_check_command` and `update_install_command` keys under `[chat.telegram]` are no longer read; remove them from `config.toml`.\n- `archie-update-install` run from a shell now reads `~/.config/archie/env`, so the pre-update backup of the bundled database no longer fails with `no password supplied`. Run it with `--auto` to install the newest release."
},
{
"version": "1.47.3",
"date": "2026-10-07",
-32
View File
@@ -1,32 +0,0 @@
package archied
import (
"flag"
"fmt"
"io"
"strings"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
func RunReleaseChannel(args []string, in io.Reader, out, stderr io.Writer) int {
flags := flag.NewFlagSet("select-release", flag.ContinueOnError)
flags.SetOutput(stderr)
channel := flags.String("channel", "stable", "stable, next, or exact-pin")
pin := flags.String("pin", "", "exact release version")
if err := flags.Parse(args); err != nil {
return 1
}
data, err := io.ReadAll(in)
if err != nil {
fmt.Fprintln(stderr, err)
return 1
}
version, err := releaseupdate.SelectRelease(strings.Fields(string(data)), *channel, *pin)
if err != nil {
fmt.Fprintln(stderr, err)
return 1
}
fmt.Fprintln(out, version)
return 0
}
+48
View File
@@ -0,0 +1,48 @@
package archied
import (
"context"
"encoding/json"
"flag"
"fmt"
"io"
"os"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
// RunUpdate serves `archied update check`, printing the release snapshot as
// JSON. The channel defaults to the environment the installer passes on.
func RunUpdate(args []string, out, stderr io.Writer) int {
if len(args) == 0 || args[0] != "check" {
fmt.Fprintln(stderr, "usage: archied update check [-channel stable|next|exact-pin] [-pin version]")
return 2
}
flags := flag.NewFlagSet("update check", flag.ContinueOnError)
flags.SetOutput(stderr)
channel := flags.String("channel", envOr("ARCHIE_UPDATE_RELEASE_CHANNEL", "stable"), "stable, next, or exact-pin")
pin := flags.String("pin", os.Getenv("ARCHIE_UPDATE_PIN"), "exact release version")
if err := flags.Parse(args[1:]); err != nil {
return 2
}
catalog := &releaseupdate.GitHubCatalog{Channel: func(context.Context) (string, string, error) { return *channel, *pin, nil }}
snapshot, err := catalog.Check(context.Background())
if err != nil {
fmt.Fprintln(stderr, err)
return 1
}
encoder := json.NewEncoder(out)
encoder.SetIndent("", " ")
if err := encoder.Encode(snapshot); err != nil {
fmt.Fprintln(stderr, err)
return 1
}
return 0
}
func envOr(key, fallback string) string {
if value := os.Getenv(key); value != "" {
return value
}
return fallback
}
+4 -17
View File
@@ -17,6 +17,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/events"
"github.com/samcharles93/archie-core/internal/gateway"
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/tools"
@@ -95,23 +96,9 @@ func componentInstallTypeEnricher(nats config.NATSConfig) func(string) (string,
}
}
func makeUpdateService(s chatSetup) *releaseupdate.Service {
cfg := s.Cfg.Get()
if len(cfg.Chat.Telegram.UpdateCheckCommand) == 0 {
return nil
}
updates := &releaseupdate.Service{
Catalog: releaseupdate.CommandCatalog{Command: cfg.Chat.Telegram.UpdateCheckCommand},
StatePath: filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"),
InstallType: installtype.Type(),
Enrich: componentInstallTypeEnricher(cfg.NATS),
}
if len(cfg.Chat.Telegram.UpdateInstallCommand) != 0 {
updates.Installer = releaseupdate.CommandInstaller{
Command: cfg.Chat.Telegram.UpdateInstallCommand,
HealthURL: cfg.Health.URL(),
}
}
func makeUpdateService(reader controlplanerpc.ResourceReader, cfg config.Config) *releaseupdate.Service {
updates := controlplanerpc.UpdateService(reader, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"), cfg.Health.URL())
updates.Enrich = componentInstallTypeEnricher(cfg.NATS)
return updates
}
@@ -86,7 +86,7 @@ func (b *server) setupChatRuntime(ctx context.Context, cfg config.Config, actor
},
cancelExecution: b.stateStore.CancelExecution,
})
b.updateService = makeUpdateService(chatSetup{Cfg: config.NewHolder(cfg)})
b.updateService = makeUpdateService(b.controlPlane, cfg)
return nil
}
+4
View File
@@ -19,6 +19,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/infrastructure/messagingrpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/sdnotify"
"github.com/samcharles93/archie-core/internal/secret"
)
@@ -43,6 +44,9 @@ type deps struct {
// SettingsSource enables live channel-settings reconciliation. Nil disables
// it.
SettingsSource chatSettingsSource
// Updates serves /update from the stored update settings. Nil without a
// State Store.
Updates *releaseupdate.Service
// ApplyReporter records what this process applied. Nil reports nothing.
ApplyReporter *applystatus.Reporter
// AppliedVersion is the channel-settings version already running when the
+5
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log/slog"
"net"
"path/filepath"
"google.golang.org/grpc"
@@ -20,6 +21,7 @@ import (
"github.com/samcharles93/archie-core/internal/infrastructure/messagingrpc"
"github.com/samcharles93/archie-core/internal/infrastructure/secretengine"
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/secret"
)
@@ -52,6 +54,7 @@ func Run(ctx context.Context, o Options) error {
var settingsSource chatSettingsSource
var applyReporter *applystatus.Reporter
var appliedVersion int64
var updates *releaseupdate.Service
var extensionChannels []*channelInstance
if cfg.Options.StateStore.Target != "" {
stateStore, closeClient, dialErr := staterpc.Dial(cfg.Options.StateStore.Target, presence.Messaging, cfg.Options.StateStore.Token, staterpc.WaitForPeer)
@@ -81,6 +84,7 @@ func Run(ctx context.Context, o Options) error {
settings = messaging.NewSettingsCommand(messagingControlPlane{client: stateStore.ControlPlane()}).WithIdentities(stateStore)
channelStatusStore, presenceStore = stateStore, stateStore
settingsSource, applyReporter, appliedVersion = controlPlaneClient, reporter, channelVersion
updates = controlplanerpc.UpdateService(controlPlaneClient, filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"), cfg.HealthURL)
}
if cfg.Options.StateStore.Target == "" {
@@ -101,6 +105,7 @@ func Run(ctx context.Context, o Options) error {
SettingsSource: settingsSource,
ApplyReporter: applyReporter,
AppliedVersion: appliedVersion,
Updates: updates,
})
if err != nil {
return err
@@ -14,7 +14,6 @@ import (
"github.com/samcharles93/archie-core/internal/domain/messaging"
"github.com/samcharles93/archie-core/internal/domain/presence"
"github.com/samcharles93/archie-core/internal/domain/storecontract"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/releaseannounce"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/secret"
@@ -28,8 +27,8 @@ func configureTelegram(ctx context.Context, g *telegram.Gateway, cfg ResolvedCon
g.Reload = telegramReloader(cfg.Options, d.Secrets, d.Log)
g.RunningVersions = runningVersions(ctx, d.Presence, cfg.Options.DependencyTimeout)
if updates := updateService(cfg); updates != nil {
g.Updates = updates
if d.Updates != nil {
g.Updates = d.Updates
}
if cfg.WorkDir != "" {
g.UpdateReportPath = identityStatePath(cfg.WorkDir, "update-report", cfg.BotUser)
@@ -91,26 +90,6 @@ func gatewayVersionReporter(ctx context.Context, chat messaging.ChatContract, ti
}
}
// updateService builds /update from [chat.telegram] commands, or nil when
// none are configured.
func updateService(cfg ResolvedConfig) *releaseupdate.Service {
if len(cfg.Telegram.UpdateCheckCommand) == 0 {
return nil
}
updates := &releaseupdate.Service{
Catalog: releaseupdate.CommandCatalog{Command: cfg.Telegram.UpdateCheckCommand},
StatePath: filepath.Join(cfg.WorkDir, "telegram-update-deferrals.json"),
InstallType: installtype.Type(),
}
if len(cfg.Telegram.UpdateInstallCommand) != 0 {
updates.Installer = releaseupdate.CommandInstaller{
Command: cfg.Telegram.UpdateInstallCommand,
HealthURL: cfg.HealthURL,
}
}
return updates
}
// telegramReloader re-resolves the token and allowlist from this service's own
// configuration on /restart. A reload that cannot produce a token is refused so
// the running bot keeps the credential it is already authenticated with.
+3 -1
View File
@@ -17,6 +17,7 @@ import (
infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access"
"github.com/samcharles93/archie-core/internal/infrastructure/captureintake"
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
"github.com/samcharles93/archie-core/internal/webhookguard"
"github.com/samcharles93/archie-core/internal/webui"
)
@@ -29,6 +30,7 @@ type deps struct {
Log *slog.Logger
Store storecontract.TaskStore
Chat messaging.ChatContract
Updates *releaseupdate.Service
Health *health.Registry
ControlPlane controlpb.ControlPlaneServiceClient
Identities identity.Repository
@@ -107,7 +109,7 @@ func compose(d deps) *webui.Server {
srv.EventTypes = eventTypes
}
if d.Chat != nil {
srv.Chat = &webui.ChatService{Contract: d.Chat}
srv.Chat = &webui.ChatService{Contract: d.Chat, Updates: d.Updates}
}
wireCatalog(d, srv)
// The policy chain: wired together or not at all.
+4
View File
@@ -8,6 +8,7 @@ import (
"net"
"net/http"
"os"
"path/filepath"
"slices"
"time"
@@ -18,6 +19,8 @@ import (
"github.com/samcharles93/archie-core/internal/domain/applystatus"
"github.com/samcharles93/archie-core/internal/domain/presence"
infraaccess "github.com/samcharles93/archie-core/internal/infrastructure/access"
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
"github.com/samcharles93/archie-core/internal/infrastructure/gatewayrpc"
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
"github.com/samcharles93/archie-core/internal/webui"
@@ -87,6 +90,7 @@ func Run(ctx context.Context, options Options) error {
Log: log,
Store: tasks,
Chat: chat,
Updates: controlplanerpc.UpdateService(controlplanerpc.NewRPCClient(tasks.ControlPlane()), filepath.Join(configuration.DefaultWorkDir(), "ui-update-deferrals.json"), ""),
Health: newReadinessRegistry(opts, tasks, chat, chain, provider),
ControlPlane: tasks.ControlPlane(),
Identities: tasks,
@@ -9,6 +9,7 @@ import (
"github.com/samcharles93/archie-core/internal/domain/workintake"
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanerpc"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
const (
@@ -18,6 +19,7 @@ const (
PluginSettingsKind = "plugin-settings"
ContainerRuntimePoliciesKind = "container-runtime-policies"
ExtensionSettingsKind = controlplanerpc.ExtensionSettingsKind
UpdateSettingsKind = controlplanerpc.UpdateSettingsKind
)
type schedulingPolicy struct {
@@ -59,6 +61,8 @@ func operationalDefinitions() []Definition {
{Kind: ExtensionSettingsKind, Title: "Extension settings", ApplyMode: "live", Document: controlplanerpc.ExtensionSettings{}, Seed: func(config.Config) any { return controlplanerpc.ExtensionSettings{} }, Validate: validateExtensions},
// Live: the container pool reads these on every acquire and the dispatcher
// is resized on publish.
// Live: every check and install reads the channel afresh.
{Kind: UpdateSettingsKind, Title: "Update settings", ApplyMode: "live", Document: controlplanerpc.UpdateSettings{}, Seed: func(config.Config) any { return controlplanerpc.UpdateSettings{Channel: "stable"} }, Validate: validateUpdateSettings},
{Kind: ContainerRuntimePoliciesKind, Title: "Container runtime policies", ApplyMode: "live", Document: containerRuntimePolicies{}, Seed: seedContainerPolicies, Validate: validateContainers, Normalize: normalizeContainerPolicies},
}
}
@@ -119,3 +123,10 @@ func validateScheduling(input []byte) error {
return nil
})
}
// validateUpdateSettings refuses a channel the update scripts cannot select.
func validateUpdateSettings(input []byte) error {
return validateAs(input, func(doc controlplanerpc.UpdateSettings) error {
return releaseupdate.ValidateChannel(doc.Channel, doc.Pin)
})
}
-7
View File
@@ -534,8 +534,6 @@ func (c Config) Clone() Config {
c.Identities = cloneIdentities(c.Identities)
c.Chat.Models = append([]string(nil), c.Chat.Models...)
c.Chat.Telegram.AllowedUserIDs = append([]int64(nil), c.Chat.Telegram.AllowedUserIDs...)
c.Chat.Telegram.UpdateCheckCommand = append([]string(nil), c.Chat.Telegram.UpdateCheckCommand...)
c.Chat.Telegram.UpdateInstallCommand = append([]string(nil), c.Chat.Telegram.UpdateInstallCommand...)
c.Bindings.PreviousEncryptionKeys = append([]SecretRef(nil), c.Bindings.PreviousEncryptionKeys...)
c.Tools.MCPServers = cloneMCPServers(c.Tools.MCPServers)
// Services is a map of structs, so the header is shared by the value copy
@@ -918,11 +916,6 @@ type TelegramConfig struct {
// Token references the bot token from @BotFather through the configured
// secret engine. Empty disables the Telegram channel.
Token SecretRef `toml:"token" yaml:"token"`
// UpdateCheckCommand writes a releaseupdate.Snapshot JSON document to
// stdout. UpdateInstallCommand applies an already-approved update. Both
// are argv arrays, never shell snippets.
UpdateCheckCommand []string `toml:"update_check_command" yaml:"update_check_command"`
UpdateInstallCommand []string `toml:"update_install_command" yaml:"update_install_command"`
}
// Notify configures outbound notifications (n8n webhook → email etc.).
@@ -80,11 +80,10 @@ func RuntimeChatConfigFrom(ctx context.Context, reader ResourceReader, base conf
if err := json.Unmarshal(value, &settings); err != nil {
return err
}
check, install := base.Telegram.UpdateCheckCommand, base.Telegram.UpdateInstallCommand
out = config.ChatConfig{
Operator: settings.Operator, ShowToolCalls: settings.ShowToolCalls, MaxSteps: settings.MaxSteps,
Models: settings.Models,
Telegram: config.TelegramConfig{AllowedUserIDs: settings.Telegram.AllowedUserIDs, Token: settings.Telegram.Token, UpdateCheckCommand: check, UpdateInstallCommand: install},
Telegram: config.TelegramConfig{AllowedUserIDs: settings.Telegram.AllowedUserIDs, Token: settings.Telegram.Token},
RateLimit: config.RateLimitConfig{Window: time.Duration(settings.RateLimit.Window), MaxRequests: settings.RateLimit.MaxRequests},
UnrestrictedFilesystem: settings.UnrestrictedFilesystem, Workspace: settings.Workspace,
}
@@ -2,11 +2,14 @@ package controlplanerpc
import (
"bytes"
"context"
"encoding/json"
"fmt"
"time"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/installtype"
"github.com/samcharles93/archie-core/internal/releaseupdate"
)
// ChannelSettings is the channel-settings resource document, with
@@ -105,3 +108,36 @@ func (d *ChannelDuration) UnmarshalJSON(data []byte) error {
*d = ChannelDuration(nanos)
return nil
}
// UpdateSettingsKind holds which releases the update scripts select.
const UpdateSettingsKind = "update-settings"
// UpdateSettings is the update-settings document.
type UpdateSettings struct {
Channel string `json:"channel" title:"Release channel" doc:"stable, next (includes prereleases) or exact-pin."`
Pin string `json:"pin" title:"Pinned version" doc:"The version exact-pin installs."`
}
// UpdateService checks GitHub on the stored release channel and installs
// through the script beside this binary. statePath keeps each recipient's
// deferrals; healthURL reaches the installer.
func UpdateService(reader ResourceReader, statePath, healthURL string) *releaseupdate.Service {
return &releaseupdate.Service{
Catalog: &releaseupdate.GitHubCatalog{Channel: updateChannel(reader)},
Installer: releaseupdate.ScriptInstaller{HealthURL: healthURL},
StatePath: statePath,
InstallType: installtype.Type(),
}
}
// updateChannel reads the update-settings resource. An unstored kind is the
// stable channel.
func updateChannel(reader ResourceReader) func(context.Context) (string, string, error) {
return func(ctx context.Context) (string, string, error) {
settings := UpdateSettings{Channel: "stable"}
_, _, err := reader.Query(ctx, UpdateSettingsKind, func(value []byte) error {
return json.Unmarshal(value, &settings)
})
return settings.Channel, settings.Pin, err
}
}
@@ -53,6 +53,15 @@ func confinedCommand(ctx context.Context, binary *os.File, socket string) (*exec
return cmd, nil
}
// openCommand runs the verified binary by its open descriptor with the host's
// network, for a package that declares no egress hosts.
func openCommand(ctx context.Context, binary *os.File) *exec.Cmd {
path := fmt.Sprintf("/proc/%d/fd/%d", os.Getpid(), binary.Fd())
cmd := exec.CommandContext(ctx, path) //nolint:gosec // the host-verified binary, by descriptor
cmd.SysProcAttr = &syscall.SysProcAttr{Pdeathsig: syscall.SIGKILL}
return cmd
}
// launch runs inside the namespace: loopback up, relay listening, then the
// extension from descriptor 3 with every capability gone.
func launch(socket string) int {
@@ -14,3 +14,7 @@ import (
func confinedCommand(context.Context, *os.File, string) (*exec.Cmd, error) {
return nil, errors.New("extensions need Linux network namespaces to confine their egress")
}
func openCommand(ctx context.Context, binary *os.File) *exec.Cmd {
return exec.CommandContext(ctx, binary.Name()) //nolint:gosec // the host-verified binary
}
+27 -10
View File
@@ -11,6 +11,7 @@ import (
"fmt"
"io"
"os"
"os/exec"
"sync"
"github.com/hashicorp/go-hclog"
@@ -36,9 +37,9 @@ type Spec struct {
// Env names the host environment variables the extension may see. PATH and
// HOME are always passed so a plugin can find the CLI it wraps.
Env []string
// Egress is the accepted egress host list. The extension runs in its own
// network namespace and reaches only these hosts, through a proxy; an
// empty list reaches nothing.
// Egress is the accepted egress host list. When it names hosts, the
// extension runs in its own network namespace and reaches only these,
// through a proxy; an empty list runs it on the host's network.
Egress []string
}
@@ -58,7 +59,28 @@ type proc struct {
func (p *proc) kill() {
p.client.Kill()
p.gate.close()
if p.gate != nil {
p.gate.close()
}
}
// command confines the extension to egress when the package declares hosts.
// A package that declares none opted out of confinement and gets the host's
// network, with no gate.
func command(ctx context.Context, binary *os.File, egress []string) (*exec.Cmd, *gate, error) {
if len(egress) == 0 {
return openCommand(ctx, binary), nil, nil
}
g, err := openGate(ctx, egress)
if err != nil {
return nil, nil, fmt.Errorf("egress: %w", err)
}
cmd, err := confinedCommand(ctx, binary, g.socket)
if err != nil {
g.close()
return nil, nil, err
}
return cmd, g, nil
}
// NewHost returns a Host that reports plugin lifecycle problems to log.
@@ -81,13 +103,8 @@ func (h *Host) Start(ctx context.Context, spec Spec, surface string, impl goplug
return nil, fmt.Errorf("extension %q: %w", spec.Name, err)
}
defer func() { _ = binary.Close() }()
g, err := openGate(ctx, spec.Egress)
cmd, g, err := command(ctx, binary, spec.Egress)
if err != nil {
return nil, fmt.Errorf("extension %q: egress: %w", spec.Name, err)
}
cmd, err := confinedCommand(ctx, binary, g.socket)
if err != nil {
g.close()
return nil, fmt.Errorf("extension %q: %w", spec.Name, err)
}
cmd.Env = passEnv(spec.Env)
@@ -158,10 +158,13 @@ func TestHostLaunch(t *testing.T) {
key string
want string
wantErr string
// open runs the package with no declared egress hosts.
open bool
}{
{name: "an accepted egress host is reachable through the proxy", sha: good, key: "GET:http://" + accepted, want: "reached"},
{name: "a host that was not accepted is refused", sha: good, key: "GET:http://" + other, want: "403 Forbidden"},
{name: "a direct connection bypassing the proxy fails", sha: good, key: "DIAL:" + accepted, want: "dial failed"},
{name: "a package declaring no egress hosts dials directly", sha: good, key: "DIAL:" + accepted, want: "connected", open: true},
{name: "loopback is refused even when accepted", sha: good, key: "GET:http://" + loopback, want: "502 Bad Gateway"},
{name: "settings reach the engine", sha: good, key: "color", want: "blue"},
{name: "an unknown key is not found", sha: good, key: "missing", wantErr: "not found"},
@@ -174,6 +177,9 @@ func TestHostLaunch(t *testing.T) {
host := extension.NewHost(hclog.NewNullLogger())
t.Cleanup(host.Close)
spec := extension.Spec{Name: "echo", Path: os.Args[0], SHA256: tt.sha, Env: []string{"ARCHIE_TEST_PASSED"}, Egress: []string{accepted, loopback}}
if tt.open {
spec.Egress = nil
}
engine, err := Start(context.Background(), host, spec, map[string]string{"color": "blue"})
if tt.sha != good {
if err == nil || !strings.Contains(err.Error(), tt.wantErr) {
+7 -41
View File
@@ -2,53 +2,19 @@ package releaseupdate
import (
"fmt"
"regexp"
"strings"
"golang.org/x/mod/semver"
)
// SelectRelease compares release versions, never git-describe strings. Exact
// pins still have to exist in the catalog; a pin cannot invent a release.
func SelectRelease(tags []string, channel, pin string) (string, error) {
if channel == "" {
channel = "stable"
}
// ValidateChannel refuses an unknown channel, and an exact pin that is not a
// semantic version.
func ValidateChannel(channel, pin string) error {
if channel != "stable" && channel != "next" && channel != "exact-pin" {
return "", fmt.Errorf("unknown release channel %q", channel)
return fmt.Errorf("unknown release channel %q", channel)
}
pin = strings.TrimPrefix(pin, "v")
if channel == "exact-pin" && !semver.IsValid("v"+pin) {
return "", fmt.Errorf("exact-pin requires a semantic version")
}
fullVersion := regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+([+-].*)?$`)
newest := ""
for _, tag := range tags {
tag = strings.TrimPrefix(tag, "refs/tags/")
tag = strings.TrimPrefix(tag, "archied/")
if !fullVersion.MatchString(tag) || !semver.IsValid(tag) {
continue
}
if !releaseMatchesChannel(tag, channel, pin) {
continue
}
if semver.Compare(tag, newest) > 0 {
newest = tag
}
}
if newest == "" {
return "", fmt.Errorf("no release found for channel %s (pin %s)", channel, pin)
}
return strings.TrimPrefix(newest, "v"), nil
}
func releaseMatchesChannel(tag, channel, pin string) bool {
switch channel {
case "stable":
return semver.Prerelease(tag) == ""
case "exact-pin":
return tag == "v"+pin
default:
return true
if channel == "exact-pin" && !semver.IsValid("v"+strings.TrimPrefix(pin, "v")) {
return fmt.Errorf("exact-pin requires a semantic version")
}
return nil
}
-24
View File
@@ -1,24 +0,0 @@
package releaseupdate
import "testing"
func TestSelectRelease(t *testing.T) {
tags := []string{"archied/v1.9.0", "v1.10.0", "archied/v2.0.0-rc.2", "v2.0.0-rc.10", "archie/v9.0.0", "nonsense"}
for _, tc := range []struct{ channel, pin, want string }{
{"stable", "", "1.10.0"},
{"", "", "1.10.0"},
{"next", "", "2.0.0-rc.10"},
{"exact-pin", "1.9.0", "1.9.0"},
{"exact-pin", "2.0.0-rc.2", "2.0.0-rc.2"},
{"exact-pin", "9.0.0", ""},
{"exact-pin", "", ""},
{"invalid", "", ""},
} {
t.Run(tc.channel+tc.pin, func(t *testing.T) {
got, err := SelectRelease(tags, tc.channel, tc.pin)
if got != tc.want || (err != nil) != (tc.want == "") {
t.Fatalf("got %q, %v; want %q", got, err, tc.want)
}
})
}
}
+34 -28
View File
@@ -5,8 +5,11 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
)
@@ -16,34 +19,6 @@ import (
// as-is.
const updateResultSentinel = "ARCHIE_UPDATE_RESULT "
// CommandCatalog reads a Snapshot JSON document from an explicitly configured
// argv command. It never invokes a shell; deployment tooling remains an
// administrator-owned adapter.
type CommandCatalog struct {
Command []string
ReleaseChannel string
Pin string
}
func (c CommandCatalog) Check(ctx context.Context) (Snapshot, error) {
if len(c.Command) == 0 {
return Snapshot{}, fmt.Errorf("update check command is empty")
}
cmd := exec.CommandContext(ctx, c.Command[0], c.Command[1:]...)
if c.ReleaseChannel != "" {
cmd.Env = append(cmd.Environ(), "ARCHIE_UPDATE_RELEASE_CHANNEL="+c.ReleaseChannel, "ARCHIE_UPDATE_PIN="+c.Pin)
}
output, err := cmd.Output()
if err != nil {
return Snapshot{}, fmt.Errorf("run update check: %w", err)
}
var snapshot Snapshot
if err := json.Unmarshal(output, &snapshot); err != nil {
return Snapshot{}, fmt.Errorf("decode update check output: %w", err)
}
return snapshot, nil
}
// CommandInstaller runs the deployment's install command. HealthURL is
// passed as ARCHIE_HEALTH_URL when set.
type CommandInstaller struct {
@@ -133,3 +108,34 @@ func componentVersions(snapshot Snapshot) map[string]Component {
}
return versions
}
// ErrNotConfigured is returned when the step's command is unset.
var ErrNotConfigured = errors.New("updates are not configured")
// ScriptInstaller runs the install script a release places beside this binary.
type ScriptInstaller struct {
HealthURL string
}
func (s ScriptInstaller) path() string {
exe, err := os.Executable()
if err != nil {
return ""
}
path := filepath.Join(filepath.Dir(exe), "archie-update-install")
if info, err := os.Stat(path); err != nil || info.Mode()&0o111 == 0 {
return ""
}
return path
}
func (s ScriptInstaller) Install(ctx context.Context, snapshot Snapshot, meta InstallMeta, progress func(string)) (Result, error) {
path := s.path()
if path == "" {
return Result{}, ErrNotConfigured
}
return CommandInstaller{Command: []string{path}, HealthURL: s.HealthURL}.Install(ctx, snapshot, meta, progress)
}
// Installable reports whether the install script is present.
func (s ScriptInstaller) Installable(context.Context) bool { return s.path() != "" }
+214
View File
@@ -0,0 +1,214 @@
package releaseupdate
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"os"
"path/filepath"
"regexp"
"strings"
"sync"
"time"
"golang.org/x/mod/semver"
"github.com/samcharles93/archie-core/internal/buildinfo"
)
// ReleaseSlug is the repository releases are published to.
const ReleaseSlug = "samcharles93/archie-core"
const changelogURL = "https://github.com/" + ReleaseSlug + "/blob/main/CHANGELOG.md"
// buildSuffix is the git-describe tail of an untagged build (1.7.0-4-g0736708).
var buildSuffix = regexp.MustCompile(`-[0-9]+-g[0-9a-f]+$`)
// GitHubCatalog finds the newest release on the selected channel that ships a
// linux-amd64 zip, and reports it against this build. Only one version covers
// every component, so the daemon and agent are offered the same release.
type GitHubCatalog struct {
// Channel returns the release channel and pin in force.
Channel func(context.Context) (channel, pin string, err error)
// A found release is reused for checkTTL: unauthenticated GitHub API
// calls are limited to 60 an hour per address.
mu sync.Mutex
key string
at time.Time
release *release
}
const checkTTL = 10 * time.Minute
func (c *GitHubCatalog) Check(ctx context.Context) (Snapshot, error) {
channel, pin, err := c.Channel(ctx)
if err != nil {
return Snapshot{}, err
}
if channel == "" {
channel = "stable"
}
release, err := c.detect(ctx, channel, pin)
if err != nil {
return Snapshot{}, err
}
component := func(id, label, installed string) Component {
return Component{
ID: id, Label: label,
Installed: installed, Available: release.version,
Reference: release.asset, Changelog: changelogURL,
}
}
return Snapshot{Components: []Component{
component("daemon", "Gateway", installedVersion(buildinfo.Version)),
component("agent", "Runtime", installedAgent()),
}}, nil
}
func (c *GitHubCatalog) detect(ctx context.Context, channel, pin string) (*release, error) {
c.mu.Lock()
defer c.mu.Unlock()
key := channel + "\x00" + pin
if c.release != nil && c.key == key && time.Since(c.at) < checkTTL {
return c.release, nil
}
release, err := detectRelease(ctx, channel, pin)
if err != nil {
return nil, err
}
c.key, c.at, c.release = key, time.Now(), release
return release, nil
}
// release is one published version and the zip that installs it here.
type release struct {
version string
asset string
}
const releasesURL = "https://api.github.com/repos/" + ReleaseSlug + "/releases?per_page=100"
type githubRelease struct {
TagName string `json:"tag_name"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
Assets []struct {
Name string `json:"name"`
} `json:"assets"`
}
// detectRelease resolves channel to one published release. A release with no
// zip for this platform, or no SHA256SUMS to verify it against, is not
// installable, so it is never offered.
func detectRelease(ctx context.Context, channel, pin string) (*release, error) {
if err := ValidateChannel(channel, pin); err != nil {
return nil, err
}
releases, err := listReleases(ctx)
if err != nil {
return nil, fmt.Errorf("find releases: %w", err)
}
if found := pick(releases, channel, pin); found != nil {
return found, nil
}
return nil, errors.New("no published release with a linux-amd64 zip matches the channel")
}
func listReleases(ctx context.Context) ([]githubRelease, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, releasesURL, nil)
if err != nil {
return nil, err
}
req.Header.Set("Accept", "application/vnd.github+json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("GitHub answered %s", resp.Status)
}
var releases []githubRelease
if err := json.NewDecoder(resp.Body).Decode(&releases); err != nil {
return nil, fmt.Errorf("decode releases: %w", err)
}
return releases, nil
}
// pick returns the newest installable release on channel.
func pick(releases []githubRelease, channel, pin string) *release {
var best *release
for _, r := range releases {
if !onChannel(r, channel, pin) {
continue
}
asset := installable(r)
if asset == "" {
continue
}
if best == nil || semver.Compare(r.TagName, "v"+best.version) > 0 {
best = &release{version: strings.TrimPrefix(r.TagName, "v"), asset: asset}
}
}
return best
}
// onChannel: stable skips prereleases, next includes them, and exact-pin takes
// only the pinned tag.
func onChannel(r githubRelease, channel, pin string) bool {
if r.Draft || !semver.IsValid(r.TagName) {
return false
}
switch channel {
case "exact-pin":
return r.TagName == "v"+strings.TrimPrefix(pin, "v")
case "next":
return true
default:
return !r.Prerelease
}
}
// installable names the release's linux-amd64 zip, or "" when it has none or
// no SHA256SUMS to verify it against.
func installable(r githubRelease) string {
asset, sums := "", false
for _, a := range r.Assets {
switch {
case a.Name == "SHA256SUMS":
sums = true
case strings.HasSuffix(a.Name, "-linux-amd64.zip"):
asset = a.Name
}
}
if !sums {
return ""
}
return asset
}
func installedVersion(version string) string {
return buildSuffix.ReplaceAllString(version, "")
}
// installedAgent is the image the installer last switched to, recorded in a
// sidecar beside the binaries; without one it is the runtime this release was
// cut with. A malformed sidecar is unknown, not guessed.
func installedAgent() string {
exe, err := os.Executable()
if err != nil {
return installedVersion(buildinfo.Runtime)
}
data, err := os.ReadFile(filepath.Join(filepath.Dir(exe), "archie-agent.version"))
if errors.Is(err, os.ErrNotExist) {
return installedVersion(buildinfo.Runtime)
}
version := strings.TrimSpace(string(data))
if err != nil || strings.ContainsAny(version, " \n") || ValidateChannel("exact-pin", version) != nil {
return ""
}
return installedVersion(version)
}
+1 -1
View File
@@ -161,7 +161,7 @@ func makeUpdateArchive(t *testing.T, root, scripts, scenario string) []byte {
for _, name := range []string{"archied", "archie-state-store", "archie-gateway", "archie-ui", "archie-messaging"} {
files[name] = "#!/bin/bash\n# new\nif [ \"$1\" = -version ]; then echo '" + name + " 2.0.0'; fi\nexit 0\n"
}
for _, name := range []string{"archie-update-install", "archie-update-watchdog", "archie-update-check"} {
for _, name := range []string{"archie-update-install", "archie-update-watchdog"} {
data, err := os.ReadFile(filepath.Join(scripts, name))
if err != nil {
t.Fatal(err)
+11 -1
View File
@@ -204,7 +204,17 @@ func (s *Service) Install(ctx context.Context, snapshot Snapshot, meta InstallMe
return s.Installer.Install(installCtx, snapshot, meta, progress)
}
func (s *Service) CanInstall() bool { return s != nil && s.Installer != nil }
func (s *Service) CanInstall() bool {
if s == nil || s.Installer == nil {
return false
}
if installer, ok := s.Installer.(interface{ Installable(context.Context) bool }); ok {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
return installer.Installable(ctx)
}
return true
}
type deferrals map[string]map[string]string
+13 -2
View File
@@ -3,6 +3,7 @@ package webui
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"reflect"
@@ -506,6 +507,16 @@ func (s *Server) handleChatPersona(w http.ResponseWriter, r *http.Request) {
writeJSON(w, map[string]any{"ok": true, "name": strings.ToLower(req.Name)})
}
// writeUpdateCheckError answers an unset check command as not configured, which
// the dashboard shows as such rather than as a failure.
func writeUpdateCheckError(w http.ResponseWriter, err error) {
if errors.Is(err, releaseupdate.ErrNotConfigured) {
http.Error(w, "updates are not configured", http.StatusNotImplemented)
return
}
http.Error(w, err.Error(), http.StatusBadGateway)
}
func (s *Server) handleChatUpdate(w http.ResponseWriter, r *http.Request) {
chat, ok := s.chatReady(w)
if !ok {
@@ -517,7 +528,7 @@ func (s *Server) handleChatUpdate(w http.ResponseWriter, r *http.Request) {
}
snapshot, err := chat.Updates.Check(r.Context(), 0)
if err != nil {
http.Error(w, err.Error(), http.StatusBadGateway)
writeUpdateCheckError(w, err)
return
}
writeJSON(w, map[string]any{
@@ -564,7 +575,7 @@ func (s *Server) handleChatUpdateInstall(w http.ResponseWriter, r *http.Request)
}
fresh, err := chat.Updates.Check(r.Context(), 0)
if err != nil {
http.Error(w, err.Error(), http.StatusBadGateway)
writeUpdateCheckError(w, err)
return
}
if !releaseupdate.SameAvailable(fresh, req.Snapshot) {
+1 -1
View File
@@ -71,7 +71,7 @@ func (s *Server) handleVersion(w http.ResponseWriter, r *http.Request) {
}
snapshot, err := s.Chat.Updates.Check(r.Context(), 0)
if err != nil {
http.Error(w, err.Error(), http.StatusBadGateway)
writeUpdateCheckError(w, err)
return
}
running := map[string]string{}
-186
View File
@@ -1,186 +0,0 @@
#!/usr/bin/env bash
# archie-update-check -- update discovery adapter for archied's /update command.
#
# Writes a releaseupdate.Snapshot JSON document to stdout. archied runs this
# via CommandCatalog (internal/releaseupdate/command.go), which never invokes
# a shell, so this file must be directly executable.
#
# "Installed" for the daemon is the release the running binary was ACTUALLY
# built from, read via `archied -version`. The agent value in that output is
# only the runtime version the daemon release was cut with; it is not the
# managed image that an installer later rebuilt. The installer therefore owns
# a sidecar beside BIN_DIR, archie-agent.version, and that is authoritative.
# Older installations without the sidecar use the agent line as a compatibility
# fallback. An existing malformed sidecar is reported as unknown, not replaced
# by a fabricated version. Build-stamp git-describe suffixes are stripped for
# comparison (1.7.0-4-g0736708 -> 1.7.0).
#
# "Available" is the newest release TAG, resolved without any dependency on a
# local checkout. Two independent sources, in order:
#
# 1. the forge API (tags + releases), which also reports whether the tag has
# a PUBLISHED artifact -- the thing an artifact install path downloads;
# 2. `git ls-remote` against the source remote, which needs no API and no
# working tree.
#
# The tag is the authority for "an update exists"; the artifact is reported
# separately in Reference, so a tagged-but-unpublished release is still
# announced (it is installable via the source-build fallback) instead of being
# silently hidden.
#
# A tag source that fails to resolve is a FAILURE TO CHECK, not an absence.
# An empty Available means "this component is at the newest release we could
# resolve", so it must never be the result of a probe that failed. When no
# authoritative source answers at all, this script exits non-zero and the
# /update command says it could not check -- rather than rendering a failed
# lookup as "Archie is up to date".
set -uo pipefail
readonly REPO_SLUG="${ARCHIE_SOURCE_SLUG:-samcharles93/archie-core}"
readonly API_BASE="${ARCHIE_FORGE_API:-https://api.github.com}"
readonly SOURCE_URL="${ARCHIE_SOURCE_URL:-https://github.com/${REPO_SLUG}.git}"
readonly BIN="${ARCHIE_BIN:-$HOME/.local/bin/archied}"
readonly BIN_DIR="${ARCHIE_BIN_DIR:-$(dirname "$BIN")}"
readonly AGENT_VERSION_FILE="${ARCHIE_AGENT_VERSION_FILE:-$BIN_DIR/archie-agent.version}"
readonly CURL_TIMEOUT="${ARCHIE_FORGE_TIMEOUT:-20}"
readonly TOKEN="${ARCHIE_FORGE_TOKEN:-}"
# base 1.7.0-4-g0736708 -> 1.7.0
base() { printf '%s\n' "$1" | sed -E 's/-[0-9]+-g[0-9a-f]+$//'; }
# installed_for reads the version this binary reports for a named component.
# archied stamps both its own version and the runtime version the release was
# cut with, and -version prints one line per component -- so the installed
# runtime is what THIS RELEASE says it was built against, not a stray binary
# on the host. releaseupdate/service.go documents why a host-side archie-agent
# binary cannot answer this: every archie-agent process is task-scoped and
# ephemeral, observed only through a completed taskrun.Response.
installed_for() {
"$BIN" -version 2>/dev/null | awk -v n="$1" '$1 == n { print $2; exit }'
}
curl_api() {
if [ -n "$TOKEN" ]; then
curl -fsS --max-time "$CURL_TIMEOUT" \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github+json" \
"$1" 2>/dev/null
else
curl -fsS --max-time "$CURL_TIMEOUT" \
-H "Accept: application/vnd.github+json" \
"$1" 2>/dev/null
fi
}
RELEASE_CHANNEL="${ARCHIE_UPDATE_RELEASE_CHANNEL:-stable}"
PIN="${ARCHIE_UPDATE_PIN:-}"
while [ "$#" -gt 0 ]; do
case "$1" in
--channel) RELEASE_CHANNEL="$2"; shift 2 ;;
--pin) PIN="$2"; shift 2 ;;
*) echo "unknown option: $1" >&2; exit 1 ;;
esac
done
select_release() { "$BIN" select-release -channel "$RELEASE_CHANNEL" -pin "$PIN"; }
newest_tag_git() {
local tags
tags="$(git ls-remote --tags --refs "$SOURCE_URL" 'archied/v*' 'v*' 2>/dev/null)" || return 1
printf '%s\n' "$tags" | awk '{print $2}' | select_release
}
newest_tag_api() {
local page payload tags=""
for page in $(seq 1 100); do
payload="$(curl_api "${API_BASE}/repos/${REPO_SLUG}/tags?per_page=100&page=${page}")" || return 1
tags+="$(jq -er '.[].name' <<< "$payload")"$'\n'
if [ "$(jq 'length' <<< "$payload")" -lt 100 ]; then
printf '%s' "$tags" | select_release
return $?
fi
done
echo "tag catalog exceeded pagination limit" >&2
return 1
}
# artifact_state reports whether a tagged release is PUBLISHED with assets,
# which decides whether an artifact install can use it or the source-build
# fallback has to. Purely descriptive: a failure here never fabricates a
# state, it reports "unknown-artifact".
artifact_state() {
local tag="$1" payload count
command -v jq >/dev/null 2>&1 || { printf 'unknown-artifact'; return 0; }
payload="$(curl_api "${API_BASE}/repos/${REPO_SLUG}/releases/tags/${tag}")" || { printf 'no-release'; return 0; }
[ -n "$payload" ] || { printf 'no-release'; return 0; }
count="$(printf '%s\n' "$payload" | jq -r '[.assets[] | select(.name != "")] | length' 2>/dev/null)"
case "${count:-}" in
'' | *[!0-9]*) printf 'unknown-artifact' ;;
0) printf 'no-artifact' ;;
*) printf '%s-assets' "$count" ;;
esac
}
esc() { printf '%s' "${1:-}" | sed 's/\\/\\\\/g; s/"/\\"/g'; }
daemon_installed="$(base "$(installed_for archied || true)")"
agent_installed=""
if [ -f "$AGENT_VERSION_FILE" ]; then
# A sidecar is updater state: accept only one released semantic version and
# deliberately do not fall back if it is empty or malformed.
sidecar_version="$(awk 'NF { if (seen++) { bad=1; next } gsub(/^[[:space:]]+|[[:space:]]+$/, "", $0); print } END { if (bad) exit 1 }' "$AGENT_VERSION_FILE" 2>/dev/null || true)"
if [[ "$sidecar_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then
agent_installed="$(base "$sidecar_version")"
fi
else
# Compatibility for hosts installed before the sidecar existed.
agent_installed="$(base "$(installed_for archie-agent || true)")"
fi
# One version covers every component (RELEASING.md): the runtime image a
# release publishes carries the release's own version, tagged archied/v*.
daemon_available="$(newest_tag_git archied || true)"
tag_source="git-tags"
if [ -z "$daemon_available" ]; then
daemon_available="$(newest_tag_api archied || true)"
tag_source="forge-api-tags"
fi
agent_available="$daemon_available"
if [ -z "$daemon_available" ]; then
# Neither source answered. Report the failure; do not exit 0 with two empty
# components, which the caller renders as "up to date".
echo "archie-update-check: could not resolve any release tag from ${SOURCE_URL} or ${API_BASE}/repos/${REPO_SLUG}/tags" >&2
exit 1
fi
daemon_artifacts=""
[ -n "$daemon_available" ] && daemon_artifacts="$(artifact_state "archied/v${daemon_available}")"
agent_artifacts=""
agent_artifacts="$daemon_artifacts"
reference_for() {
local component="$1" version="$2" artifacts="$3"
[ -z "$version" ] && { printf ''; return 0; }
printf '%s artifact=%s (%s)' "$tag_source" "$artifacts" "$component"
}
cat <<EOF
{
"Components": [
{
"ID": "daemon",
"Label": "Gateway",
"Installed": "$(esc "$daemon_installed")",
"Available": "$(esc "$daemon_available")",
"Reference": "$(esc "$(reference_for archie-core "$daemon_available" "$daemon_artifacts")")",
"Changelog": "https://github.com/${REPO_SLUG}/blob/main/CHANGELOG.md"
},
{
"ID": "agent",
"Label": "Runtime",
"Installed": "$(esc "$agent_installed")",
"Available": "$(esc "$agent_available")",
"Reference": "$(esc "$(reference_for archie-runtime "$agent_available" "$agent_artifacts")")",
"Changelog": "https://github.com/${REPO_SLUG}/blob/main/CHANGELOG.md"
}
],
"Deferred": false
}
EOF
+10 -2
View File
@@ -15,6 +15,14 @@ SOURCE_URL="${ARCHIE_SOURCE_URL:-https://github.com/samcharles93/archie-core.git
BIN_DIR="${ARCHIE_BIN_DIR:-$HOME/.local/bin}"
CONFIG_PATH="${ARCHIE_CONFIG_PATH:-${XDG_CONFIG_HOME:-$HOME/.config}/archie/config.toml}"
export PATH="/usr/local/go/bin:$PATH"
# The units load this file; a run from a shell needs it too, for PGPASSWORD.
ENV_FILE="$(dirname "$CONFIG_PATH")/env"
if [ -r "$ENV_FILE" ]; then
set -a
# shellcheck disable=SC1090
. "$ENV_FILE"
set +a
fi
# State for the managed image, independent of archied's daemon build stamp.
AGENT_VERSION_FILE="${ARCHIE_AGENT_VERSION_FILE:-$BIN_DIR/archie-agent.version}"
@@ -55,7 +63,7 @@ for arg in "$@"; do
done
if [ "$AUTO" = 1 ] && [ -z "${ARCHIE_UPDATE_DAEMON_VERSION:-}${ARCHIE_UPDATE_AGENT_VERSION:-}" ]; then
snapshot="$("$(dirname "$0")/archie-update-check")"
snapshot="$("$BIN_DIR/archied" update check)"
export ARCHIE_UPDATE_DAEMON_PREVIOUS="$(jq -r '.Components[] | select(.ID == "daemon") | .Installed' <<< "$snapshot")"
export ARCHIE_UPDATE_DAEMON_VERSION="$(jq -r '.Components[] | select(.ID == "daemon") | .Available' <<< "$snapshot")"
export ARCHIE_UPDATE_AGENT_PREVIOUS="$(jq -r '.Components[] | select(.ID == "agent") | .Installed' <<< "$snapshot")"
@@ -218,7 +226,7 @@ if [[ ",$components," == *,daemon,* ]]; then
done
mkdir -p "$(dirname "$DB_SNAPSHOT")"
"$BIN_DIR/archie-state-store" backup -config "$CONFIG_PATH" -out "$DB_SNAPSHOT"
built="$GATEWAY_BINARIES archie-update-install archie-update-watchdog archie-update-check"
built="$GATEWAY_BINARIES archie-update-install archie-update-watchdog"
fi
# Freeze recovery code and every prior file before publishing the intent.
+1 -1
View File
@@ -92,7 +92,7 @@ archied_dirs() {
component_dirs ./cmd/archie-ui
printf '%s\n' "cmd/archied" "Dockerfile.archied" "cmd/archie-ui" "internal/app/archieui" \
"Taskfile.yml" ".github/workflows/deploy.yml" "install.sh" \
"scripts/archie-update-install" "scripts/archie-update-check" \
"scripts/archie-update-install" \
"scripts/archie-update-watchdog" "deployments/INSTRUCTIONS.md"
}
+71 -71
View File
@@ -1,74 +1,74 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HarnessPage.js","assets/HarnessPage.css"])))=>i.map(i=>d[i]);
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var r={},i=[],a=()=>{},o=()=>!1,s=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),c=e=>e.startsWith(`onUpdate:`),l=Object.assign,u=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},d=Object.prototype.hasOwnProperty,f=(e,t)=>d.call(e,t),p=Array.isArray,m=e=>w(e)===`[object Map]`,h=e=>w(e)===`[object Set]`,g=e=>w(e)===`[object Date]`,_=e=>w(e)===`[object RegExp]`,v=e=>typeof e==`function`,y=e=>typeof e==`string`,b=e=>typeof e==`symbol`,x=e=>typeof e==`object`&&!!e,S=e=>(x(e)||v(e))&&v(e.then)&&v(e.catch),C=Object.prototype.toString,w=e=>C.call(e),T=e=>w(e).slice(8,-1),E=e=>w(e)===`[object Object]`,D=e=>y(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,O=n(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ee=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},te=/-\w/g,ne=ee(e=>e.replace(te,e=>e.slice(1).toUpperCase())),re=/\B([A-Z])/g,ie=ee(e=>e.replace(re,`-$1`).toLowerCase()),ae=ee(e=>e.charAt(0).toUpperCase()+e.slice(1)),oe=ee(e=>e?`on${ae(e)}`:``),k=(e,t)=>!Object.is(e,t),se=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},ce=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},le=e=>{let t=parseFloat(e);return isNaN(t)?e:t},ue=e=>{let t=y(e)?Number(e):NaN;return isNaN(t)?e:t},de,fe=()=>de||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},pe=n(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function me(e){if(p(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=y(r)?ve(r):me(r);if(i)for(let e in i)t[e]=i[e]}return t}if(y(e)||x(e))return e}var he=/;(?![^(]*\))/g,ge=/:([^]+)/,_e=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function ve(e){let t={};return e.replace(_e,e=>e.startsWith(`/*`)?``:e).split(he).forEach(e=>{if(e){let n=e.split(ge);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function A(e){let t=``;if(y(e))t=e;else if(p(e))for(let n=0;n<e.length;n++){let r=A(e[n]);r&&(t+=r+` `)}else if(x(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function ye(e){if(!e)return null;let{class:t,style:n}=e;return t&&!y(t)&&(e.class=A(t)),n&&(e.style=me(n)),e}var be=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,xe=n(be);be+``;function Se(e){return!!e||e===``}function Ce(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=De(e[i],t[i],n);return r}function we(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&De(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Te(e,t,n){let r=m(e),i=m(t);if(r||i||(r=h(e),i=h(t),r||i))return r&&i?we(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!De(e[r],t[r],n))return!1}return String(e)===String(t)}function Ee(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function De(e,t,n){if(e===t)return!0;let r=g(e),i=g(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=b(e),i=b(t),r||i?e===t:(r=p(e),i=p(t),r||i?r&&i?Ee(e,t,n,Ce):!1:(r=x(e),i=x(t),r||i?!r||!i?!1:Ee(e,t,n,Te):String(e)===String(t))))}function Oe(e,t){return e.findIndex(e=>De(e,t))}var ke=e=>!!(e&&e.__v_isRef===!0),j=e=>y(e)?e:e==null?``:p(e)||x(e)&&(e.toString===C||!v(e.toString))?ke(e)?j(e.value):JSON.stringify(e,Ae,2):String(e),Ae=(e,t)=>ke(t)?Ae(e,t.value):m(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[je(t,r)+` =>`]=n,e),{})}:h(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>je(e))}:b(t)?je(t):x(t)&&!p(t)&&!E(t)?String(t):t,je=(e,t=``)=>b(e)?`Symbol(${e.description??t})`:e;function Me(e){return e==null?`initial`:typeof Line truncated
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function n(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return e=>e in t}var r={},i=[],a=()=>{},o=()=>!1,s=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),c=e=>e.startsWith(`onUpdate:`),l=Object.assign,u=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},d=Object.prototype.hasOwnProperty,f=(e,t)=>d.call(e,t),p=Array.isArray,m=e=>w(e)===`[object Map]`,h=e=>w(e)===`[object Set]`,g=e=>w(e)===`[object Date]`,_=e=>w(e)===`[object RegExp]`,v=e=>typeof e==`function`,y=e=>typeof e==`string`,b=e=>typeof e==`symbol`,x=e=>typeof e==`object`&&!!e,S=e=>(x(e)||v(e))&&v(e.then)&&v(e.catch),C=Object.prototype.toString,w=e=>C.call(e),T=e=>w(e).slice(8,-1),E=e=>w(e)===`[object Object]`,D=e=>y(e)&&e!==`NaN`&&e[0]!==`-`&&``+parseInt(e,10)===e,O=n(`,key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted`),ee=e=>{let t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},te=/-\w/g,ne=ee(e=>e.replace(te,e=>e.slice(1).toUpperCase())),re=/\B([A-Z])/g,ie=ee(e=>e.replace(re,`-$1`).toLowerCase()),ae=ee(e=>e.charAt(0).toUpperCase()+e.slice(1)),oe=ee(e=>e?`on${ae(e)}`:``),k=(e,t)=>!Object.is(e,t),se=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},ce=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},le=e=>{let t=parseFloat(e);return isNaN(t)?e:t},ue=e=>{let t=y(e)?Number(e):NaN;return isNaN(t)?e:t},de,fe=()=>de||=typeof globalThis<`u`?globalThis:typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:{},pe=n(`Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol`);function me(e){if(p(e)){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=y(r)?ve(r):me(r);if(i)for(let e in i)t[e]=i[e]}return t}if(y(e)||x(e))return e}var he=/;(?![^(]*\))/g,ge=/:([^]+)/,_e=/"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;function ve(e){let t={};return e.replace(_e,e=>e.startsWith(`/*`)?``:e).split(he).forEach(e=>{if(e){let n=e.split(ge);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function A(e){let t=``;if(y(e))t=e;else if(p(e))for(let n=0;n<e.length;n++){let r=A(e[n]);r&&(t+=r+` `)}else if(x(e))for(let n in e)e[n]&&(t+=n+` `);return t.trim()}function ye(e){if(!e)return null;let{class:t,style:n}=e;return t&&!y(t)&&(e.class=A(t)),n&&(e.style=me(n)),e}var be=`itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`,xe=n(be);be+``;function Se(e){return!!e||e===``}function Ce(e,t,n){if(e.length!==t.length)return!1;let r=!0;for(let i=0;r&&i<e.length;i++)r=De(e[i],t[i],n);return r}function we(e,t,n){if(e.size!==t.size)return!1;let r=Array.from(t),i=new Uint8Array(r.length);for(let t of e){let e=-1;for(let a=0;a<r.length;a++)if(!i[a]&&De(t,r[a],n)){e=a;break}if(e<0)return!1;i[e]=1}return!0}function Te(e,t,n){let r=m(e),i=m(t);if(r||i||(r=h(e),i=h(t),r||i))return r&&i?we(e,t,n):!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e){let i=e.hasOwnProperty(r),a=t.hasOwnProperty(r);if(i&&!a||!i&&a||!De(e[r],t[r],n))return!1}return String(e)===String(t)}function Ee(e,t,n,r){n||=[new Map,new Map];let[i,a]=n;if(i.has(e)||a.has(t))return i.get(e)===t&&a.get(t)===e;i.set(e,t),a.set(t,e);let o=r(e,t,n);return i.delete(e),a.delete(t),o}function De(e,t,n){if(e===t)return!0;let r=g(e),i=g(t);return r||i?r&&i?e.getTime()===t.getTime():!1:(r=b(e),i=b(t),r||i?e===t:(r=p(e),i=p(t),r||i?r&&i?Ee(e,t,n,Ce):!1:(r=x(e),i=x(t),r||i?!r||!i?!1:Ee(e,t,n,Te):String(e)===String(t))))}function Oe(e,t){return e.findIndex(e=>De(e,t))}var ke=e=>!!(e&&e.__v_isRef===!0),j=e=>y(e)?e:e==null?``:p(e)||x(e)&&(e.toString===C||!v(e.toString))?ke(e)?j(e.value):JSON.stringify(e,Ae,2):String(e),Ae=(e,t)=>ke(t)?Ae(e,t.value):m(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[je(t,r)+` =>`]=n,e),{})}:h(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>je(e))}:b(t)?je(t):x(t)&&!p(t)&&!E(t)?String(t):t,je=(e,t=``)=>b(e)?`Symbol(${e.description??t})`:e;function Me(e){return e==null?`initial`:typeof Line truncated
`&&(e.tagName===`PRE`||e.tagName===`TEXTAREA`)&&(n=n.slice(1));let{textContent:r}=e;r!==n&&r!==n.replace(/\r\n|\r/g,`
`)&&(pi(e,0)||ri(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||s(a)&&!O(a)||a[0]===`.`||t&&!O(a)||u&&u.includes(a)){if(ui(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&$t(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&us(x,n,t),h&&lr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&Ho(()=>{x&&us(x,n,t),l&&g.enter(e),h&&lr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=ss(d[t]),g=h.type===Wo;e?(g&&!u&&t+1<p&&ss(d[t+1]).type===Wo&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,pi(r,1)||ri()),n(null,h,r,null,o,s,oi(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&si(f)&&f.data===`]`?a(t.anchor=f):(ri(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(hi(e,t)||ri(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,oi(d),s),r&&(r.vnode.el=t.el,eo(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&si(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var li=new Set([`src`,`srcset`,`href`,`poster`]);function ui(e,t,n){return li.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var di=`data-allow-mismatch`,fi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function pi(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(di);)e=e.parentElement;return mi(e&&e.getAttribute(di),t)}function mi(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(fi[t])}}function hi(e,t){return pi(e.parentElement,1)||gi(e)||_i(t)}function gi(e){return e.nodeType===1&&mi(e.getAttribute(di),1)}function _i({props:e}){let t=e&&e[di];return typeof t==`string`&&mi(t,1)}var vi=fe().requestIdleCallback||(e=>setTimeout(e,1)),yi=fe().cancelIdleCallback||(e=>clearTimeout(e)),bi=(e=1e4)=>t=>{let n=vi(t,{timeout:e});return()=>yi(n)};function xi(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var Si=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(xi(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Ci=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},wi=(e=[])=>(t,n)=>{y(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Ti(e,t){if(si(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(si(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Ei=e=>!!e.type.__asyncLoader;function Di(e){v(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return I({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Ti(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=ms;if(Xr(e),u)return()=>Oi(u,e);let t=t=>{l=null,Rn(t,e,13,!r)};if(s&&e.suspense||xs)return p().then(t=>()=>Oi(t,e)).catch(e=>(t(e),()=>r?W(r,{error:e}):null));let a=M(!1),c=M(),d=M(!!i),f,m;return Gi(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&ki(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Oi(u,e);if(c.value&&r)return W(r,{error:c.value});if(n&&!d Line truncated
`))),e[Sl]=yl(i);let a=r||i.props&&i.props.type===`number`;Bc(e,t?`change`:`input`,t=>{t.target.composing||e[Sl](wl(e.value,n,a))}),(n||a)&&Bc(e,`change`,()=>{e.value=wl(e.value,n,a)}),t||(Bc(e,`compositionstart`,bl),Bc(e,`compositionend`,xl),Bc(e,`change`,xl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[Cl];delete e[Cl],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Sl](wl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Sl]=yl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?le(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},El={deep:!0,created(e,t,n){e[Sl]=yl(n),Bc(e,`change`,()=>{let t=e._modelValue,n=jl(e),r=e.checked,i=e[Sl];if(p(t)){let e=Oe(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(Ml(e,r))})},mounted:Dl,beforeUpdate(e,t,n){e[Sl]=yl(n),Dl(e,t,n)}};function Dl(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Oe(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=De(t,Ml(e,!0))}e.checked!==i&&(e.checked=i)}var Ol={created(e,{value:t},n){e.checked=De(t,n.props.value),e[Sl]=yl(n),Bc(e,`change`,()=>{e[Sl](jl(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Sl]=yl(r),t!==n&&(e.checked=De(t,r.props.value))}},kl={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,Bc(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?le(jl(e)):jl(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Sl](i)}finally{qn(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Sl]=yl(r)},mounted(e,{value:t}){Al(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Sl]=yl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!yee(t,n[1],n[0]))&&Al(e,t)}};function yee(e,t,n){if(!n||p(e))return De(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function Al(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=jl(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Oe(t,o)>-1}else a.selected=t.has(o)}else if(De(jl(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function jl(e){return`_value`in e?e._value:e.value}function Ml(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var Nl={created(e,t,n){Fl(e,t,n,null,`created`)},mounted(e,t,n){Fl(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){Fl(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){Fl(e,t,n,r,`updated`)}};function Pl(e,t){switch(e){case`SELECT`:return kl;case`TEXTAREA`:return Tl;default:switch(t){case`checkbox`:return El;case`radio`:return Ol;default:return Tl}}}function Fl(e,t,n,r,i){let a=Pl(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function bee(){Tl.getSSRProps=({value:e})=>({value:e}),Ol.getSSRProps=({value:e},t)=>{if(t.props&&De(t.props.value,e))return{checked:!0}},El.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Oe(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},Nl.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=Pl(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var xee=[`ctrl`,`shift`,`alt`,`meta`],See={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>xee.some(n=>e[`${n}Key`]&&!t.includes(n))},Il=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=See[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},Cee={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Ll=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ie(n.key);if(t.some(e=>e===r||Cee[e]===r))return e(n)}))},Rl=l({patchProp:Qc},Qs),zl,Bl=!1;function Vl(){return zl||=xo(Rl)}function Hl(){return zl=Bl?zl:So(Rl),Bl=!0,zl}var Ul=((...e)=>{Vl().render(...e)}),Wl=((...e)=>{Hl().hydrate(...e)}),Gl=((...e)=>{let t=Vl().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Jl(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,ql(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a}, Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Mp;function Np(e){Mp=e}var Pp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Fp(e){let t=e instanceof Pp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Ip(e,t){let n=await fetch(e,t);if(Mp?.(n.status===401),!n.ok)throw new Pp(await jp(n),n.status);return n}async function Lp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=kp,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Ip(e,s);return a?await c.json():void 0}var X={health:()=>Lp(`/health/detailed`),services:()=>Lp(`/api/services`),policies:()=>Lp(`/api/access/policies`),putPolicy:e=>Lp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Lp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),orgs:()=>Lp(`/api/orgs`),orgCreate:e=>Lp(`/api/orgs`,{method:`POST`,body:e}),org:e=>Lp(`/api/orgs/${encodeURIComponent(e)}`),orgWorkspaces:e=>Lp(`/api/orgs/${encodeURIComponent(e)}/workspaces`),createOrgWorkspace:(e,t)=>Lp(`/api/orgs/${encodeURIComponent(e)}/workspaces`,{method:`POST`,body:t}),orgMembers:e=>Lp(`/api/orgs/${encodeURIComponent(e)}/members`),setOrgMember:(e,t,n)=>Lp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PUT`,body:n}),removeOrgMember:(e,t,n)=>Lp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`+Ap({workspace:n}),{method:`DELETE`,parse:!1}),assignOrgAgent:(e,t)=>Lp(`/api/orgs/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}`,{method:`PUT`}),summary:()=>Lp(`/api/summary`),tasks:()=>Lp(`/api/tasks`),taskPage:async e=>{let t=await Ip(`/api/tasks`+Ap(e),{headers:{Accept:`application/json`},signal:AbortSignal.timeout(kp)});return{tasks:await t.json(),next:t.headers.get(`X-Next-Cursor`)}},taskMeta:()=>Lp(`/api/task-meta`),task:e=>Lp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Lp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/changes`+Ap(t)),taskDebug:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/debug`+Ap(t)),taskAction:(e,t,n)=>Lp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Lp(`/api/setup`),capabilities:()=>Lp(`/api/capabilities`),workflows:()=>Lp(`/api/workflows`),workflowEnabled:(e,t)=>Lp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Lp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Lp(`/api/skills`),channels:()=>Lp(`/api/channels`),curators:()=>Lp(`/api/curators`),channelReload:e=>Lp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Lp(`/api/config`),logs:e=>Lp(`/api/logs`+Ap(e)),taskLogs:(e,t)=>Lp(`/api/tasks/${encodeURIComponent(e)}/logs`+Ap(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Lp(`/api/version`),updateSnapshot:()=>Lp(`/api/chat/update`),updateInstall:e=>Lp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Lp(`/api/captures`+Ap({limit:e})),eventTypes:()=>Lp(`/api/event-types`),eventTypeCreate:e=>Lp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Lp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Lp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Lp(`/api/mappings`),mappingCreate:e=>Lp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Lp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Lp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Lp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Lp(`/api/bindings`),dispatches:(e,t)=>Lp(`/api/${e}/${encodeURIComponent(t)}/dispatches`),bindingCreate:e=>Lp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Lp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Lp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Lp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),bindingPause:e=>Lp(`/api/bindings/${encodeURIComponent(e)}/pause`,{method:`POST`}),bindingResume:e=>Lp(`/api/bindings/${encodeURIComponent(e)}/resume`,{method:`POST`}),harnessBindings:()=>Lp(`/api/harness/bindings`),sources:()=>Lp(`/api/sources`),sourceCreate:e=>Lp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Lp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Lp(`/api/sources/${encodeURIComponent(e)}/aLine truncated
`)&&(pi(e,0)||ri(),e.textContent=t.children)}if(d){if(_||b||!o||f&48){let t=e.tagName.includes(`-`),i=e.namespaceURI.includes(`svg`)?`svg`:e.namespaceURI.includes(`MathML`)?`mathml`:void 0;for(let a in d)if(_&&(a.endsWith(`value`)||a===`indeterminate`)||s(a)&&!O(a)||a[0]===`.`||t&&!O(a)||u&&u.includes(a)){if(ui(e,a,d[a]))continue;r(e,a,null,d[a],i,n)}}else if(d.onClick)r(e,`onClick`,null,d.onClick,void 0,n);else if(f&4&&$t(d.style))for(let e in d.style)d.style[e]}let x;(x=d&&d.onVnodeBeforeMount)&&ds(x,n,t),h&&lr(t,null,n,`beforeMount`),((x=d&&d.onVnodeMounted)||h||l)&&Uo(()=>{x&&ds(x,n,t),l&&g.enter(e),h&&lr(t,null,n,`mounted`)},i)}return e.nextSibling},m=(e,t,r,o,s,c,u)=>{u||=!!t.dynamicChildren;let d=t.children,p=d.length,m=!1;for(let t=0;t<p;t++){let h=u?d[t]:d[t]=cs(d[t]),g=h.type===Go;e?(g&&!u&&t+1<p&&cs(d[t+1]).type===Go&&(l(i(e.data.slice(h.children.length)),r,a(e)),e.data=h.children),e=f(e,h,o,s,c,u)):g&&!h.children?l(h.el=i(``),r):(m||(m=!0,pi(r,1)||ri()),n(null,h,r,null,o,s,oi(r),c))}return e},h=(e,t,n,r,i,s)=>{let{slotScopeIds:c}=t;c&&(i=i?i.concat(c):c);let d=o(e),f=m(a(e),t,d,n,r,i,s);return f&&si(f)&&f.data===`]`?a(t.anchor=f):(ri(),l(t.anchor=u(`]`),d,f),f)},g=(e,t,r,i,s,l)=>{if(hi(e,t)||ri(),t.el=null,l){let t=_(e);for(;;){let n=a(e);if(n&&n!==t)c(n);else break}}let u=a(e),d=o(e);return c(e),n(null,t,d,u,r,i,oi(d),s),r&&(r.vnode.el=t.el,to(r,t.el)),u},_=(e,t=`[`,n=`]`)=>{let r=0;for(;e;)if(e=a(e),e&&si(e)&&(e.data===t&&r++,e.data===n)){if(r===0)return a(e);r--}return e},v=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>e.nodeType===1&&e.tagName===`TEMPLATE`;return[d,f]}var li=new Set([`src`,`srcset`,`href`,`poster`]);function ui(e,t,n){return li.has(t)?e.getAttribute(t)===(n==null?null:`${n}`):!1}var di=`data-allow-mismatch`,fi={0:`text`,1:`children`,2:`class`,3:`style`,4:`attribute`};function pi(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(di);)e=e.parentElement;return mi(e&&e.getAttribute(di),t)}function mi(e,t){if(e==null)return!1;if(e===``)return!0;{let n=e.split(`,`);return t===0&&n.includes(`children`)?!0:n.includes(fi[t])}}function hi(e,t){return pi(e.parentElement,1)||gi(e)||_i(t)}function gi(e){return e.nodeType===1&&mi(e.getAttribute(di),1)}function _i({props:e}){let t=e&&e[di];return typeof t==`string`&&mi(t,1)}var vi=fe().requestIdleCallback||(e=>setTimeout(e,1)),yi=fe().cancelIdleCallback||(e=>clearTimeout(e)),bi=(e=1e4)=>t=>{let n=vi(t,{timeout:e});return()=>yi(n)};function xi(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:a,innerWidth:o}=window;return(t>0&&t<a||r>0&&r<a)&&(n>0&&n<o||i>0&&i<o)}var Si=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(xi(e))return t(),r.disconnect(),!1;r.observe(e)}}),()=>r.disconnect()},Ci=e=>t=>{if(e){let n=matchMedia(e);if(n.matches)t();else return n.addEventListener(`change`,t,{once:!0}),()=>n.removeEventListener(`change`,t)}},wi=(e=[])=>(t,n)=>{y(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,a(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},a=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),a};function Ti(e,t){if(si(e)&&e.data===`[`){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(si(r)){if(r.data===`]`){if(--n===0)break}else r.data===`[`&&n++}r=r.nextSibling}}else t(e)}var Ei=e=>!!e.type.__asyncLoader;function Di(e){v(e)&&(e={loader:e});let{loader:t,loadingComponent:n,errorComponent:r,delay:i=200,hydrate:a,timeout:o,suspensible:s=!0,onError:c}=e,l=null,u,d=0,f=()=>(d++,l=null,p()),p=()=>{let e;return l||(e=l=t().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(f()),()=>n(e),d+1)});throw e}).then(t=>e!==l&&l?l:(t&&(t.__esModule||t[Symbol.toStringTag]===`Module`)&&(t=t.default),u=t,t)))};return I({name:`AsyncComponentWrapper`,__asyncLoader:p,__asyncHydrate(e,t,n){let r=e.isConnected,i=!1;(t.bu||=[]).push(()=>i=!0);let o=()=>{i||!e.parentNode||r&&!e.isConnected||n()},s=a?()=>{let n=a(o,t=>Ti(e,t));n&&(t.bum||=[]).push(n)}:o;u?s():p().then(()=>!t.isUnmounted&&s())},get __asyncResolved(){return u},setup(){let e=hs;if(Xr(e),u)return()=>Oi(u,e);let t=t=>{l=null,Rn(t,e,13,!r)};if(s&&e.suspense||Ss)return p().then(t=>()=>Oi(t,e)).catch(e=>(t(e),()=>r?W(r,{error:e}):null));let a=M(!1),c=M(),d=M(!!i),f,m;return Gi(()=>{f!=null&&clearTimeout(f),m!=null&&clearTimeout(m)}),i&&(m=setTimeout(()=>{e.isUnmounted||(d.value=!1)},i)),o!=null&&(f=setTimeout(()=>{if(!e.isUnmounted&&!a.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);t(e),c.value=e}},o)),p().then(()=>{e.isUnmounted||(a.value=!0,e.parent&&ki(e.parent.vnode)&&e.parent.update())}).catch(n=>{if(e.isUnmounted){l=null;return}t(n),c.value=n}),()=>{if(a.value&&u)return Oi(u,e);if(c.value&&r)return W(r,{error:c.value});if(n&&!d Line truncated
`))),e[Cl]=bl(i);let a=r||i.props&&i.props.type===`number`;Vc(e,t?`change`:`input`,t=>{t.target.composing||e[Cl](Tl(e.value,n,a))}),(n||a)&&Vc(e,`change`,()=>{e.value=Tl(e.value,n,a)}),t||(Vc(e,`compositionstart`,xl),Vc(e,`compositionend`,Sl),Vc(e,`change`,Sl))},mounted(e,{value:t,modifiers:{trim:n,number:r}}){let i=t??``,a=e[wl];delete e[wl],a!==void 0&&(e.type===`text`||e.type===`textarea`)&&e.value!==a?e[Cl](Tl(e.value,n,r)):e.value=i},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:a}},o){if(e[Cl]=bl(o),e.composing)return;let s=(a||e.type===`number`)&&!/^0\d/.test(e.value)?le(e.value):e.value,c=t??``;if(s===c)return;let l=e.getRootNode();(l instanceof Document||l instanceof ShadowRoot)&&l.activeElement===e&&e.type!==`range`&&(r&&t===n||i&&e.value.trim()===c)||(e.value=c)}},Dl={deep:!0,created(e,t,n){e[Cl]=bl(n),Vc(e,`change`,()=>{let t=e._modelValue,n=Ml(e),r=e.checked,i=e[Cl];if(p(t)){let e=Oe(t,n),a=e!==-1;if(r&&!a)i(t.concat(n));else if(!r&&a){let n=[...t];n.splice(e,1),i(n)}}else if(h(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(Nl(e,r))})},mounted:Ol,beforeUpdate(e,t,n){e[Cl]=bl(n),Ol(e,t,n)}};function Ol(e,{value:t,oldValue:n},r){e._modelValue=t;let i;if(p(t))i=Oe(t,r.props.value)>-1;else if(h(t))i=t.has(r.props.value);else{if(t===n)return;i=De(t,Nl(e,!0))}e.checked!==i&&(e.checked=i)}var kl={created(e,{value:t},n){e.checked=De(t,n.props.value),e[Cl]=bl(n),Vc(e,`change`,()=>{e[Cl](Ml(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Cl]=bl(r),t!==n&&(e.checked=De(t,r.props.value))}},Al={deep:!0,created(e,{value:t,modifiers:{number:n}},r){e._modelValue=t,Vc(e,`change`,()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?le(Ml(e)):Ml(e)),r=e.multiple,i=r?h(e._modelValue)?new Set(t):t:t[0],a=e._pendingValue=[r,r?p(i)?t.slice():t:i];try{e[Cl](i)}finally{qn(()=>{e._pendingValue===a&&(e._pendingValue=void 0)})}}),e[Cl]=bl(r)},mounted(e,{value:t}){jl(e,t)},beforeUpdate(e,{value:t},n){e._modelValue=t,e[Cl]=bl(n)},updated(e,{value:t}){let n=e._pendingValue;e._pendingValue=void 0,(!n||n[0]!==e.multiple||!vee(t,n[1],n[0]))&&jl(e,t)}};function vee(e,t,n){if(!n||p(e))return De(e,t);if(h(e)){if(e.size!==t.length)return!1;for(let n of t)if(!e.has(n))return!1;return!0}return!1}function jl(e,t){let n=e.multiple,r=p(t);if(!n||r||h(t)){for(let i=0,a=e.options.length;i<a;i++){let a=e.options[i],o=Ml(a);if(n){if(r){let e=typeof o;a.selected=e===`string`||e===`number`?t.some(e=>String(e)===String(o)):Oe(t,o)>-1}else a.selected=t.has(o)}else if(De(Ml(a),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Ml(e){return`_value`in e?e._value:e.value}function Nl(e,t){let n=t?`_trueValue`:`_falseValue`;return n in e?e[n]:t}var Pl={created(e,t,n){Il(e,t,n,null,`created`)},mounted(e,t,n){Il(e,t,n,null,`mounted`)},beforeUpdate(e,t,n,r){Il(e,t,n,r,`beforeUpdate`)},updated(e,t,n,r){Il(e,t,n,r,`updated`)}};function Fl(e,t){switch(e){case`SELECT`:return Al;case`TEXTAREA`:return El;default:switch(t){case`checkbox`:return Dl;case`radio`:return kl;default:return El}}}function Il(e,t,n,r,i){let a=Fl(e.tagName,n.props&&n.props.type)[i];a&&a(e,t,n,r)}function yee(){El.getSSRProps=({value:e})=>({value:e}),kl.getSSRProps=({value:e},t)=>{if(t.props&&De(t.props.value,e))return{checked:!0}},Dl.getSSRProps=({value:e},t)=>{if(p(e)){if(t.props&&Oe(e,t.props.value)>-1)return{checked:!0}}else if(h(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},Pl.getSSRProps=(e,t)=>{if(typeof t.type!=`string`)return;let n=Fl(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}var bee=[`ctrl`,`shift`,`alt`,`meta`],xee={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>`button`in e&&e.button!==0,middle:e=>`button`in e&&e.button!==1,right:e=>`button`in e&&e.button!==2,exact:(e,t)=>bee.some(n=>e[`${n}Key`]&&!t.includes(n))},Ll=(e,t)=>{if(!e)return e;let n=e._withMods||={},r=t.join(`.`);return n[r]||(n[r]=((n,...r)=>{for(let e=0;e<t.length;e++){let r=xee[t[e]];if(r&&r(n,t))return}return e(n,...r)}))},See={esc:`escape`,space:` `,up:`arrow-up`,left:`arrow-left`,right:`arrow-right`,down:`arrow-down`,delete:`backspace`},Rl=(e,t)=>{let n=e._withKeys||={},r=t.join(`.`);return n[r]||(n[r]=(n=>{if(!(`key`in n))return;let r=ie(n.key);if(t.some(e=>e===r||See[e]===r))return e(n)}))},zl=l({patchProp:$c},$s),Bl,Vl=!1;function Hl(){return Bl||=So(zl)}function Ul(){return Bl=Vl?Bl:Co(zl),Vl=!0,Bl}var Wl=((...e)=>{Hl().render(...e)}),Gl=((...e)=>{Ul().hydrate(...e)}),Kl=((...e)=>{let t=Hl().createApp(...e),{mount:n}=t;return t.mount=e=>{let r=Yl(e);if(!r)return;let i=t._component;!v(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent=``);let a=n(r,!1,Jl(r));return r instanceof Element&&(r.removeAttribute(`v-cloak`),r.setAttribute(`data-v-app`,``)),a}, Line truncated
`)[0].slice(0,200)}catch{}return`${e.status} ${e.statusText}`}var Np;function Pp(e){Np=e}var Fp=class extends Error{status;constructor(e,t){super(e),this.name=`ApiError`,this.status=t}};function Ip(e){let t=e instanceof Fp?e.status:void 0,n=e instanceof Error&&e.message?e.message:`Action failed`;return t===401?{kind:`session-expired`,message:n}:t!==void 0&&t>=400&&t<500?{kind:`refused`,message:n}:{kind:`broken`,message:n}}async function Lp(e,t){let n=await fetch(e,t);if(Np?.(n.status===401),!n.ok)throw new Fp(await Mp(n),n.status);return n}async function Rp(e,t={}){let{method:n=`GET`,body:r,timeoutMs:i=Ap,parse:a=!0}=t,o={Accept:`application/json`},s={method:n,headers:o,signal:AbortSignal.timeout(i)};n!==`GET`&&(o[`Content-Type`]=`application/json`,o[`X-Archie-CSRF`]=`1`),r!==void 0&&(s.body=JSON.stringify(r));let c=await Lp(e,s);return a?await c.json():void 0}var X={health:()=>Rp(`/health/detailed`),services:()=>Rp(`/api/services`),policies:()=>Rp(`/api/access/policies`),putPolicy:e=>Rp(`/api/access/policies`,{method:`PUT`,body:e}),deletePolicy:e=>Rp(`/api/access/policies`,{method:`DELETE`,body:e,parse:!1}),orgs:()=>Rp(`/api/orgs`),orgCreate:e=>Rp(`/api/orgs`,{method:`POST`,body:e}),org:e=>Rp(`/api/orgs/${encodeURIComponent(e)}`),orgWorkspaces:e=>Rp(`/api/orgs/${encodeURIComponent(e)}/workspaces`),createOrgWorkspace:(e,t)=>Rp(`/api/orgs/${encodeURIComponent(e)}/workspaces`,{method:`POST`,body:t}),orgMembers:e=>Rp(`/api/orgs/${encodeURIComponent(e)}/members`),setOrgMember:(e,t,n)=>Rp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`,{method:`PUT`,body:n}),removeOrgMember:(e,t,n)=>Rp(`/api/orgs/${encodeURIComponent(e)}/members/${encodeURIComponent(t)}`+jp({workspace:n}),{method:`DELETE`,parse:!1}),assignOrgAgent:(e,t)=>Rp(`/api/orgs/${encodeURIComponent(e)}/agents/${encodeURIComponent(t)}`,{method:`PUT`}),summary:()=>Rp(`/api/summary`),tasks:()=>Rp(`/api/tasks`),taskPage:async e=>{let t=await Lp(`/api/tasks`+jp(e),{headers:{Accept:`application/json`},signal:AbortSignal.timeout(Ap)});return{tasks:await t.json(),next:t.headers.get(`X-Next-Cursor`)}},taskMeta:()=>Rp(`/api/task-meta`),task:e=>Rp(`/api/tasks/${encodeURIComponent(e)}`),taskAttempts:e=>Rp(`/api/tasks/${encodeURIComponent(e)}/attempts`),taskChanges:(e,t)=>Rp(`/api/tasks/${encodeURIComponent(e)}/changes`+jp(t)),taskDebug:(e,t)=>Rp(`/api/tasks/${encodeURIComponent(e)}/debug`+jp(t)),taskAction:(e,t,n)=>Rp(`/api/tasks/${encodeURIComponent(e)}/action`,{method:`POST`,body:{action:t,...n}}),setup:()=>Rp(`/api/setup`),capabilities:()=>Rp(`/api/capabilities`),workflows:()=>Rp(`/api/workflows`),workflowEnabled:(e,t)=>Rp(`/api/workflows/${encodeURIComponent(e)}/enabled`,{method:`PUT`,body:{enabled:t},parse:!1}),workRequest:e=>Rp(`/api/work-requests`,{method:`POST`,body:e}),skills:()=>Rp(`/api/skills`),channels:()=>Rp(`/api/channels`),curators:()=>Rp(`/api/curators`),channelReload:e=>Rp(`/api/channels/${encodeURIComponent(e)}/reload`,{method:`POST`,body:{}}),config:()=>Rp(`/api/config`),logs:e=>Rp(`/api/logs`+jp(e)),taskLogs:(e,t)=>Rp(`/api/tasks/${encodeURIComponent(e)}/logs`+jp(t)),taskLogDownloadURL:(e,t)=>`/api/tasks/${encodeURIComponent(e)}/logs/download`+(t==null?``:`?attempt=${t}`),version:()=>Rp(`/api/version`),updateSnapshot:()=>Rp(`/api/chat/update`),updateInstall:e=>Rp(`/api/chat/update/install`,{method:`POST`,body:{snapshot:e},timeoutMs:9e5}),captures:e=>Rp(`/api/captures`+jp({limit:e})),eventTypes:()=>Rp(`/api/event-types`),eventTypeCreate:e=>Rp(`/api/event-types`,{method:`POST`,body:e}),eventTypeUpdate:(e,t)=>Rp(`/api/event-types/${encodeURIComponent(e)}`,{method:`PUT`,body:t}),eventTypeDelete:e=>Rp(`/api/event-types/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappings:()=>Rp(`/api/mappings`),mappingCreate:e=>Rp(`/api/mappings`,{method:`POST`,body:e}),mappingUpdate:(e,t)=>Rp(`/api/mappings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),mappingDelete:e=>Rp(`/api/mappings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),mappingPreview:(e,t)=>Rp(`/api/mappings/preview`,{method:`POST`,body:{capture_id:e,fields:t}}),bindings:()=>Rp(`/api/bindings`),dispatches:(e,t)=>Rp(`/api/${e}/${encodeURIComponent(t)}/dispatches`),bindingCreate:e=>Rp(`/api/bindings`,{method:`POST`,body:e}),bindingUpdate:(e,t)=>Rp(`/api/bindings/${encodeURIComponent(e)}`,{method:`PATCH`,body:t}),bindingDelete:e=>Rp(`/api/bindings/${encodeURIComponent(e)}`,{method:`DELETE`,parse:!1}),bindingApprove:e=>Rp(`/api/bindings/${encodeURIComponent(e)}/approve`,{method:`POST`}),bindingPause:e=>Rp(`/api/bindings/${encodeURIComponent(e)}/pause`,{method:`POST`}),bindingResume:e=>Rp(`/api/bindings/${encodeURIComponent(e)}/resume`,{method:`POST`}),harnessBindings:()=>Rp(`/api/harness/bindings`),sources:()=>Rp(`/api/sources`),sourceCreate:e=>Rp(`/api/sources`,{method:`POST`,body:{path:e}}),sourceSigning:(e,t)=>Rp(`/api/sources/${encodeURIComponent(e)}/signing`,{method:`POST`,body:{signed:t}}),sourceApproveUnsigned:e=>Rp(`/api/sources/${encodeURIComponent(e)}/aLine truncated
`);u=r.pop()||``;for(let e of r){let t=e.split(`
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&($p.value=n.session_id),n.type===`delta`&&(o+=n.text,im.value=im.value?{...im.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],im.value=im.value?{...im.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);em.value=[...em.value,{from:`assistant`,text:o,tool_calls:a}],im.value=null,nm.value=`Ready`,await ym()}catch(e){let t=e;t.name===`AbortError`&&!c?(im.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},nm.value=`Stopped`):(im.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?Jp(r):void 0,isRetry:i},nm.value=`Error — retry available`)}finally{clearTimeout(l),_m=null,rm.value=!1}}function Mee(){nm.value=`Stopping…`,$p.value&&X.chatCancel($p.value).catch(()=>{}),vm()}function Nee(){Vi(()=>{ym().catch(e=>{nm.value=e.message||`Chat unavailable`})}),Gi(()=>{vm()})}var Pee=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Fee=I({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return Y(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(B(),V(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":N(Xp),onClick:i[0]||=e=>n(`toggle`)},[U(`span`,{"aria-hidden":`true`,class:A(r(!e.open))},[W(N(_d),{size:22})],2),U(`span`,{"aria-hidden":`true`,class:A(r(e.open))},[W(N(qd),{size:22})],2)],8,Pee))}});function Tm(e){return typeof e==`string`?`'${e}'`:new Lee().serialize(e)}var Iee=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Em=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Iee.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Dm(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Em[n]?Em[n]:n+128,s=a<128&&Em[a]?Em[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var Lee=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Dm(e,t):n===`number`&&r===`number`?e-t:Dm(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Dm),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`FloatLine truncated
`).find(e=>e.startsWith(`data: `));if(!t)continue;let n=JSON.parse(t.slice(6));if(n.session_id&&(em.value=n.session_id),n.type===`delta`&&(o+=n.text,am.value=am.value?{...am.value,text:o}:null),(n.type===`tool`||n.type===`navigate`)&&(a=[...a,n],am.value=am.value?{...am.value,tools:a}:null),n.type===`done`&&(s=!0,o||=n.text||``),n.type===`error`)throw Error(n.text)}if(t)break}if(!s)throw Error(`chat stream ended before completion`);tm.value=[...tm.value,{from:`assistant`,text:o,tool_calls:a}],am.value=null,rm.value=`Ready`,await bm()}catch(e){let t=e;t.name===`AbortError`&&!c?(am.value={text:`Turn stopped.`,tools:a,isError:!1,turn:r,isRetry:i},rm.value=`Stopped`):(am.value={text:`Unable to complete that turn: ${t.message||t}`,tools:a,isError:!0,turn:r?Yp(r):void 0,isRetry:i},rm.value=`Error — retry available`)}finally{clearTimeout(l),vm=null,im.value=!1}}function jee(){rm.value=`Stopping…`,em.value&&X.chatCancel(em.value).catch(()=>{}),ym()}function Mee(){Vi(()=>{bm().catch(e=>{rm.value=e.message||`Chat unavailable`})}),Gi(()=>{ym()})}var Nee=[`aria-label`,`title`,`aria-expanded`,`aria-controls`],Pee=I({__name:`ChatFab`,props:{open:{type:Boolean}},emits:[`toggle`],setup(e,{emit:t}){let n=t;function r(e){return Y(`col-start-1 row-start-1 grid place-items-center transition-[opacity,transform] duration-[140ms]`,e?`opacity-100`:`-rotate-45 scale-[0.7] opacity-0`)}return(t,i)=>(B(),V(`button`,{type:`button`,class:`relative z-10 grid size-14 cursor-pointer place-items-center rounded-full border border-border-strong bg-secondary text-primary shadow-[var(--shadow-md)] transition-transform duration-[140ms] hover:-translate-y-px focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary active:translate-y-0`,"aria-label":e.open?`Close chat`:`Chat with Archie`,title:e.open?`Close chat`:`Chat with Archie`,"aria-expanded":e.open,"aria-controls":N(Zp),onClick:i[0]||=e=>n(`toggle`)},[U(`span`,{"aria-hidden":`true`,class:A(r(!e.open))},[W(N(vd),{size:22})],2),U(`span`,{"aria-hidden":`true`,class:A(r(e.open))},[W(N(Jd),{size:22})],2)],8,Nee))}});function Em(e){return typeof e==`string`?`'${e}'`:new Iee().serialize(e)}var Fee=` _-,;:!?.'"()[]{}@*/\\&#%\`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz`,Dm=(function(){let e=new Uint8Array(128);for(let t=0;t<69;t++)e[Fee.charCodeAt(t)]=t+1;for(let t=65;t<=90;t++)e[t]=e[t+32];return e})();function Om(e,t){if(e===t)return 0;let n=Math.min(e.length,t.length),r=0;for(let i=0;i<n;i++){let n=e.charCodeAt(i),a=t.charCodeAt(i);if(n===a)continue;let o=n<128&&Dm[n]?Dm[n]:n+128,s=a<128&&Dm[a]?Dm[a]:a+128;if(o!==s)return o<s?-1:1;r===0&&(r=n>a?-1:1)}return e.length===t.length?r:e.length<t.length?-1:1}var Iee=(function(){class e{#e=new Map;compare(e,t){let n=typeof e,r=typeof t;return n===`string`&&r===`string`?Om(e,t):n===`number`&&r===`number`?e-t:Om(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(e===null)return`null`;switch(typeof e){case`string`:return t?e:`'${e}'`;case`bigint`:return`${e}n`;case`object`:return this.$object(e);case`function`:return this.$function(e)}return String(e)}serializeObject(e){let t=Object.prototype.toString.call(e);if(t!==`[object Object]`)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);let n=e.constructor,r=n===Object||n===void 0?``:n.name;if(r!==``&&globalThis[r]===n)return this.serializeBuiltInType(r,e);if(`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();return r+(typeof t==`object`&&t?this.$object(t):`(${this.serialize(t)})`)}let i=Object.keys(e).sort(Om),a=`${r}{`;for(let t=0;t<i.length;t++){let n=i[t];a+=`${n}:${this.serialize(e[n])}`,t<i.length-1&&(a+=`,`)}return a+`}`}serializeBuiltInType(e,t){let n=this[`$`+e];if(n)return n.call(this,t);if(typeof t.entries==`function`)return this.serializeObjectEntries(e,t.entries());throw Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){let n=Array.from(t).sort((e,t)=>this.compare(e[0],t[0])),r=`${e}{`;for(let e=0;e<n.length;e++){let[t,i]=n[e];r+=`${this.serialize(t,!0)}:${this.serialize(i)}`,e<n.length-1&&(r+=`,`)}return r+`}`}$object(e){let t=this.#e.get(e);return t===void 0&&(this.#e.set(e,`#${this.#e.size}`),t=this.serializeObject(e),this.#e.set(e,t)),t}$function(e){let t=Function.prototype.toString.call(e);return t.slice(-15)===`[native code] }`?`${e.name||``}()[native]`:`${e.name}(${e.length})${t.replace(/\s*\n\s*/g,``)}`}$Array(e){let t=`[`;for(let n=0;n<e.length;n++)t+=this.serialize(e[n]),n<e.length-1&&(t+=`,`);return t+`]`}$Date(e){try{return`Date(${e.toISOString()})`}catch{return`Date(null)`}}$ArrayBuffer(e){return`ArrayBuffer[${new Uint8Array(e).join(`,`)}]`}$Set(e){return`Set${this.$Array(Array.from(e).sort((e,t)=>this.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries(`Map`,e.entries())}}for(let t of[`Error`,`RegExp`,`URL`])e.prototype[`$`+t]=function(e){return`${t}(${e})`};for(let t of[`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`FloatLine truncated
`)].join(`
`))}return()=>i.value||r.value||o.value?Fs(t.default({present:o.value})[0],{ref:e=>{let t=Qm(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),gg=I({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=mh(n.default()),r=e.findIndex(e=>e.type!==Go);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?q(t,i.props):t,o=as({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),_g=[`area`,`img`,`input`],vg=I({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&_g.includes(r)?()=>Fs(r,t):r===`template`?()=>Fs(gg,t,{default:n.default}):()=>Fs(e.as,t,{default:n.default})}});function yg(){let e=M();return{primitiveElement:e,currentElement:J(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:Qm(e))}}var[bg,xg]=Mm(`CollapsibleRoot`),Sg=I({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=ph(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=vn(r);return xg({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Z(),(e,t)=>(B(),H(N(vg),{as:e.as,"as-child":r.asChild,"data-state":N(i)?`open`:`closed`,"data-disabled":N(a)?``:void 0},{default:P(()=>[R(e.$slots,`default`,{open:N(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),Cg=I({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=bg();i.contentId||=ag(void 0,`reka-collapsible-content`);let a=M(),{forwardRef:o,currentElement:s}=Z(),c=M(0),l=M(0),u=J(()=>i.open.value),d=M(u.value),f=M();F(()=>[u.value,a.value?.present],async()=>{await qn();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=J(()=>d.value&&i.open.value);return Vi(()=>{requestAnimationFrame(()=>{d.value=!1})}),$m(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(B(),H(N(hg),{ref_key:`presentRef`,ref:a,present:e.forceMount||N(i).open.value,"force-mount":!0},{default:P(({present:t})=>[W(N(vg),q(e.$attrs,{id:N(i).contentId,ref:N(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:N(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:N(i).open.value?`open`:`closed`,"data-disabled":N(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:P(()=>[!N(i).unmountOnHide.value||t?R(e.$slots,`default`,{key:0}):K(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),wg=I({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Z();let n=bg();return(e,r)=>(B(),H(N(vg),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":N(n).contentId,"aria-expanded":N(n).open.value,"data-state":N(n).open.value?`open`:`closed`,"data-disabled":N(n).disabled?.value?``:void 0,disabled:N(n).disabled?.value,onClick:N(n).onOpenToggle},{default:P(()=>[R(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function Tg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Eg({type:e,defaultValue:t,modelValue:n}){return e||Tg({type:e,defaultValue:t,modelValue:n})}function Dg({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function Og(e,t){let n=J(()=>Eg(e)),r=ph(e,`modelValue`,t,{defaultValue:Dg(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=Om(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Im(t,e)){let n=t.findIndex(t=>Om(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:J(()=>n.value===`single`)}}var[kg,Ag]=Mm(`AccordionRoot`),jg=I({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
`))}return()=>i.value||r.value||o.value?Is(t.default({present:o.value})[0],{ref:e=>{let t=$m(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?a.value=t.firstElementChild:a.value=t),t}}):null}}),_g=I({name:`PrimitiveSlot`,inheritAttrs:!1,setup(e,{attrs:t,slots:n}){return()=>{if(!n.default)return null;let e=hh(n.default()),r=e.findIndex(e=>e.type!==Ko);if(r===-1)return e;let i=e[r];delete i.props?.ref;let a=i.props?q(t,i.props):t,o=os({...i,props:{}},a);return e.length===1?o:(e[r]=o,e)}}}),vg=[`area`,`img`,`input`],yg=I({name:`Primitive`,inheritAttrs:!1,props:{asChild:{type:Boolean,default:!1},as:{type:[String,Object],default:`div`}},setup(e,{attrs:t,slots:n}){let r=e.asChild?`template`:e.as;return typeof r==`string`&&vg.includes(r)?()=>Is(r,t):r===`template`?()=>Is(_g,t,{default:n.default}):()=>Is(e.as,t,{default:n.default})}});function bg(){let e=M();return{primitiveElement:e,currentElement:J(()=>[`#text`,`#comment`].includes(e.value?.$el.nodeName)?e.value?.$el.nextElementSibling:$m(e))}}var[xg,Sg]=Nm(`CollapsibleRoot`),Cg=I({__name:`CollapsibleRoot`,props:{defaultOpen:{type:Boolean,required:!1,default:!1},open:{type:Boolean,required:!1,default:void 0},disabled:{type:Boolean,required:!1},unmountOnHide:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:open`],setup(e,{expose:t,emit:n}){let r=e,i=mh(r,`open`,n,{defaultValue:r.defaultOpen,passive:r.open===void 0}),{disabled:a,unmountOnHide:o}=vn(r);return Sg({contentId:``,disabled:a,open:i,unmountOnHide:o,onOpenToggle:()=>{a.value||(i.value=!i.value)}}),t({open:i}),Z(),(e,t)=>(B(),H(N(yg),{as:e.as,"as-child":r.asChild,"data-state":N(i)?`open`:`closed`,"data-disabled":N(a)?``:void 0},{default:P(()=>[R(e.$slots,`default`,{open:N(i)})]),_:3},8,[`as`,`as-child`,`data-state`,`data-disabled`]))}}),wg=I({inheritAttrs:!1,__name:`CollapsibleContent`,props:{forceMount:{type:Boolean,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`contentFound`],setup(e,{emit:t}){let n=e,r=t,i=xg();i.contentId||=og(void 0,`reka-collapsible-content`);let a=M(),{forwardRef:o,currentElement:s}=Z(),c=M(0),l=M(0),u=J(()=>i.open.value),d=M(u.value),f=M();F(()=>[u.value,a.value?.present],async()=>{await qn();let e=s.value;if(!e)return;f.value=f.value||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();l.value=t.height,c.value=t.width,d.value||(e.style.transitionDuration=f.value.transitionDuration,e.style.animationName=f.value.animationName)},{immediate:!0});let p=J(()=>d.value&&i.open.value);return Vi(()=>{requestAnimationFrame(()=>{d.value=!1})}),eh(s,`beforematch`,e=>{requestAnimationFrame(()=>{i.onOpenToggle(),r(`contentFound`)})}),(e,t)=>(B(),H(N(gg),{ref_key:`presentRef`,ref:a,present:e.forceMount||N(i).open.value,"force-mount":!0},{default:P(({present:t})=>[W(N(yg),q(e.$attrs,{id:N(i).contentId,ref:N(o),"as-child":n.asChild,as:e.as,hidden:t?void 0:N(i).unmountOnHide.value?``:`until-found`,"data-state":p.value?void 0:N(i).open.value?`open`:`closed`,"data-disabled":N(i).disabled?.value?``:void 0,style:{"--reka-collapsible-content-height":`${l.value}px`,"--reka-collapsible-content-width":`${c.value}px`}}),{default:P(()=>[!N(i).unmountOnHide.value||t?R(e.$slots,`default`,{key:0}):K(`v-if`,!0)]),_:2},1040,[`id`,`as-child`,`as`,`hidden`,`data-state`,`data-disabled`,`style`])]),_:3},8,[`present`]))}}),Tg=I({__name:`CollapsibleTrigger`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`}},setup(e){let t=e;Z();let n=xg();return(e,r)=>(B(),H(N(yg),{type:e.as===`button`?`button`:void 0,as:e.as,"as-child":t.asChild,"aria-controls":N(n).contentId,"aria-expanded":N(n).open.value,"data-state":N(n).open.value?`open`:`closed`,"data-disabled":N(n).disabled?.value?``:void 0,disabled:N(n).disabled?.value,onClick:N(n).onOpenToggle},{default:P(()=>[R(e.$slots,`default`)]),_:3},8,[`type`,`as`,`as-child`,`aria-controls`,`aria-expanded`,`data-state`,`data-disabled`,`disabled`,`onClick`]))}});function Eg({type:e,defaultValue:t,modelValue:n}){let r=n||t;return n!==void 0||t!==void 0?Array.isArray(r)?`multiple`:`single`:e??`single`}function Dg({type:e,defaultValue:t,modelValue:n}){return e||Eg({type:e,defaultValue:t,modelValue:n})}function Og({type:e,defaultValue:t}){return t===void 0?e===`single`?void 0:[]:t}function kg(e,t){let n=J(()=>Dg(e)),r=mh(e,`modelValue`,t,{defaultValue:Og(e),passive:e.modelValue===void 0,deep:!0});function i(e){if(n.value===`single`)r.value=km(e,r.value)?void 0:e;else{let t=Array.isArray(r.value)?[...r.value||[]]:[r.value].filter(Boolean);if(Lm(t,e)){let n=t.findIndex(t=>km(t,e));t.splice(n,1)}else t.push(e);r.value=t}}return{modelValue:r,changeModelValue:i,isSingle:J(()=>n.value===`single`)}}var[Ag,jg]=Nm(`AccordionRoot`),Mg=I({__name:`AccordionRoot`,props:{collapsible:{type:Boolean,required:! Line truncated
- a positive number
- less than the value passed to \`max\` (or ${lS} if no \`max\` prop is set)
- less than the value passed to \`max\` (or ${uS} if no \`max\` prop is set)
- \`null\` or \`undefined\` if the progress is indeterminate.
Defaulting to \`null\`.`),null)}function mS(e){return fS(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${lS}\`.`),lS)}var hS=I({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:lS},getValueLabel:{type:Function,required:!1,default:(e,t)=>fS(e)?`${Math.round(e/t*lS)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Z();let i=ph(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=ph(n,`max`,r,{passive:n.max===void 0});F(()=>i.value,async e=>{let t=pS(e,n.max);t!==e&&(await qn(),i.value=t)},{immediate:!0}),F(()=>n.max,e=>{let t=mS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=J(()=>Fm(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return dS({modelValue:i,max:a,progressState:o}),(e,t)=>(B(),H(N(vg),{"as-child":e.asChild,as:e.as,"aria-valuemax":N(a),"aria-valuemin":0,"aria-valuenow":fS(N(i))?N(i):void 0,"aria-valuetext":e.getValueText?.(N(i),N(a)),"aria-label":e.getValueLabel(N(i),N(a)),role:`progressbar`,"data-state":o.value,"data-value":N(i)??void 0,"data-max":N(a)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),gS=I({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=uS();return Z(),(e,r)=>(B(),H(N(vg),q(t,{"data-state":N(n).progressState.value,"data-value":N(n).modelValue?.value??void 0,"data-max":N(n).max.value}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),_S=`radio.select`;function vS(e,t,n){Pm(_S,n,{originalEvent:e,value:t})}var yS=I({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=ph(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=vn(n),{forwardRef:o,currentElement:s}=Z(),c=Lh(s),l=Bh(),u=J(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||vS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(B(),V(z,null,[W(N(vg),q({id:e.id,ref:N(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":N(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":N(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:N(a),required:e.required,name:e.name},{...N(l),...e.$attrs},{onClick:Il(d,[`stop`])}),{default:P(()=>[R(e.$slots,`default`,{checked:N(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),N(c)&&e.name?(B(),H(N(q_),q({key:0,type:`radio`,tabindex:`-1`,value:N(a),checked:!!N(i),name:e.name,disabled:e.disabled,required:e.required},N(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):K(`v-if`,!0)],64))}}),[bS,xS]=Mm(`RadioGroupRoot`),SS=I({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Z(),o=ph(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=vn(n),p=Mh(f),m=Lh(a);return xS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(B(),H(N(kb),{"as-child":``,orientation:N(l),dir:N(p),loop:N(c)},{default:P(()=>[W(N(vg),{ref:N(i),role:`radiogroup`,"data-disabled":N(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":N(l),"aria-required":N(d),dir:N(p)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(o)}),N(m)&&N(u)?(B(),H(N(q_),{key:0,required:N(d),disabled:N(s),value:N(o),name:N(u)},null,8,[`required`,`disabled`,`value`,`name`])):K(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[Jee,Yee]=Mm(`RadioGroupItem`),CS=I({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:nLine truncated
Defaulting to \`null\`.`),null)}function hS(e){return pS(e)&&!Number.isNaN(e)&&e>0?e:(console.error(`Invalid prop \`max\` of value \`${e}\` supplied to \`ProgressRoot\`. Only numbers greater than 0 are valid max values. Defaulting to \`${uS}\`.`),uS)}var gS=I({__name:`ProgressRoot`,props:{modelValue:{type:[Number,null],required:!1},max:{type:Number,required:!1,default:uS},getValueLabel:{type:Function,required:!1,default:(e,t)=>pS(e)?`${Math.round(e/t*uS)}%`:void 0},getValueText:{type:Function,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:[`update:modelValue`,`update:max`],setup(e,{emit:t}){let n=e,r=t;Z();let i=mh(n,`modelValue`,r,{passive:n.modelValue===void 0}),a=mh(n,`max`,r,{passive:n.max===void 0});F(()=>i.value,async e=>{let t=mS(e,n.max);t!==e&&(await qn(),i.value=t)},{immediate:!0}),F(()=>n.max,e=>{let t=hS(n.max);t!==e&&(a.value=t)},{immediate:!0});let o=J(()=>Im(i.value)?`indeterminate`:i.value===a.value?`complete`:`loading`);return fS({modelValue:i,max:a,progressState:o}),(e,t)=>(B(),H(N(yg),{"as-child":e.asChild,as:e.as,"aria-valuemax":N(a),"aria-valuemin":0,"aria-valuenow":pS(N(i))?N(i):void 0,"aria-valuetext":e.getValueText?.(N(i),N(a)),"aria-label":e.getValueLabel(N(i),N(a)),role:`progressbar`,"data-state":o.value,"data-value":N(i)??void 0,"data-max":N(a)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(i)})]),_:3},8,[`as-child`,`as`,`aria-valuemax`,`aria-valuenow`,`aria-valuetext`,`aria-label`,`data-state`,`data-value`,`data-max`]))}}),_S=I({__name:`ProgressIndicator`,props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},setup(e){let t=e,n=dS();return Z(),(e,r)=>(B(),H(N(yg),q(t,{"data-state":N(n).progressState.value,"data-value":N(n).modelValue?.value??void 0,"data-max":N(n).max.value}),{default:P(()=>[R(e.$slots,`default`)]),_:3},16,[`data-state`,`data-value`,`data-max`]))}}),vS=`radio.select`;function yS(e,t,n){Fm(vS,n,{originalEvent:e,value:t})}var bS=I({inheritAttrs:!1,__name:`Radio`,props:{id:{type:String,required:!1},value:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},checked:{type:Boolean,required:!1,default:void 0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:`button`},name:{type:String,required:!1},required:{type:Boolean,required:!1}},emits:[`update:checked`,`select`],setup(e,{emit:t}){let n=e,r=t,i=mh(n,`checked`,r,{passive:n.checked===void 0}),{value:a}=vn(n),{forwardRef:o,currentElement:s}=Z(),c=Rh(s),l=Vh(),u=J(()=>n.id&&s.value?document.querySelector(`[for="${n.id}"]`)?.innerText:void 0);function d(e){n.disabled||yS(e,n.value,e=>{r(`select`,e),!e?.defaultPrevented&&(i.value=!0,c.value&&e.stopPropagation())})}return(e,t)=>(B(),V(z,null,[W(N(yg),q({id:e.id,ref:N(o),role:`radio`,type:e.as===`button`?`button`:void 0,as:e.as,"aria-checked":N(i)??!1,"aria-label":u.value,"as-child":e.asChild,disabled:e.disabled?``:void 0,"data-state":N(i)?`checked`:`unchecked`,"data-disabled":e.disabled?``:void 0,value:N(a),required:e.required,name:e.name},{...N(l),...e.$attrs},{onClick:Ll(d,[`stop`])}),{default:P(()=>[R(e.$slots,`default`,{checked:N(i)})]),_:3},16,[`id`,`type`,`as`,`aria-checked`,`aria-label`,`as-child`,`disabled`,`data-state`,`data-disabled`,`value`,`required`,`name`]),N(c)&&e.name?(B(),H(N(J_),q({key:0,type:`radio`,tabindex:`-1`,value:N(a),checked:!!N(i),name:e.name,disabled:e.disabled,required:e.required},N(l)),null,16,[`value`,`checked`,`name`,`disabled`,`required`])):K(`v-if`,!0)],64))}}),[xS,SS]=Nm(`RadioGroupRoot`),CS=I({__name:`RadioGroupRoot`,props:{modelValue:{type:null,required:!1},defaultValue:{type:null,required:!1},disabled:{type:Boolean,required:!1,default:!1},orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!0},asChild:{type:Boolean,required:!1},as:{type:null,required:!1},name:{type:String,required:!1},required:{type:Boolean,required:!1,default:!1}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,r=t,{forwardRef:i,currentElement:a}=Z(),o=mh(n,`modelValue`,r,{defaultValue:n.defaultValue,passive:n.modelValue===void 0}),{disabled:s,loop:c,orientation:l,name:u,required:d,dir:f}=vn(n),p=Nh(f),m=Rh(a);return SS({modelValue:o,changeModelValue:e=>{o.value=e},disabled:s,loop:c,orientation:l,name:u?.value,required:d}),(e,t)=>(B(),H(N(Ab),{"as-child":``,orientation:N(l),dir:N(p),loop:N(c)},{default:P(()=>[W(N(yg),{ref:N(i),role:`radiogroup`,"data-disabled":N(s)?``:void 0,"as-child":e.asChild,as:e.as,"aria-orientation":N(l),"aria-required":N(d),dir:N(p)},{default:P(()=>[R(e.$slots,`default`,{modelValue:N(o)}),N(m)&&N(u)?(B(),H(N(J_),{key:0,required:N(d),disabled:N(s),value:N(o),name:N(u)},null,8,[`required`,`disabled`,`value`,`name`])):K(`v-if`,!0)]),_:3},8,[`data-disabled`,`as-child`,`as`,`aria-orientation`,`aria-required`,`dir`])]),_:3},8,[`orientation`,`dir`,`loop`]))}}),[qee,wS]=Nm(`RadioGroupItem`),TS=I({inheritAttrs:!1,__name:`RadioGroupItem`,props:{id:{type:String,required:!1},value:{type:nuLine truncated
`),r=[],i=null,a=null,o=()=>{r.length&&(t.push({kind:`p`,inline:UT(r.join(` `))}),r=[])},s=()=>{i&&=(t.push({kind:i.tag,items:i.items.map(e=>UT(e))}),null)};for(let e=0;e<n.length;e++){let c=n[e];if(c.startsWith("```")){o(),s(),a?(t.push({kind:`pre`,code:a.join(`
`)}),a=null):a=[];continue}if(a){a.push(c);continue}let l=WT(c),u=e+1<n.length?WT(n[e+1]):null;if(l&&u&&Ete(u)&&l.length===u.length){o(),s();let r=[];for(e+=2;e<n.length;e++){let t=WT(n[e]);if(!t||t.length!==l.length){e--;break}r.push(t)}t.push({kind:`table`,head:l.map(e=>UT(e)),rows:r.map(e=>e.map(e=>UT(e)))});continue}if(!c.trim()){o(),s();continue}let d=c.match(/^(#{1,3})\s+(.+)$/);if(d){o(),s(),t.push({kind:`h${d[1].length}`,inline:UT(d[2])});continue}let f=c.match(/^\s*[-*]\s+(.+)$/),p=c.match(/^\s*\d+[.)]\s+(.+)$/);if(f||p){o();let e=p?`ol`:`ul`;(!i||i.tag!==e)&&(s(),i={tag:e,items:[]}),i.items.push((f||p)[1]);continue}if(c.startsWith(`>`)){o(),s(),t.push({kind:`blockquote`,inline:UT(c.replace(/^>\s?/,``))});continue}r.push(c)}return o(),s(),a&&t.push({kind:`pre`,code:a.join(`
`)}),t}function WT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Ete(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Dte={class:`[overflow-wrap:anywhere]`},Ote={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},kte={class:`font-mono text-[0.85em]`},Ate={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},jte={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Mte={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Nte={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Pte={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Fte={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Ite={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Lte={key:8,class:`mb-2.5 last:mb-0`},Rte=I({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=J(()=>Tte(t.text));return(e,t)=>(B(),V(`div`,Dte,[(B(!0),V(z,null,L(n.value,(e,t)=>(B(),V(z,{key:t},[e.kind===`pre`?(B(),V(`pre`,Ote,[U(`code`,kte,j(e.code),1)])):e.kind===`table`?(B(),V(`table`,Ate,[U(`thead`,null,[U(`tr`,null,[(B(!0),V(z,null,L(e.head,(e,t)=>(B(),V(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[W(HT,{inline:e},null,8,[`inline`])]))),128))])]),U(`tbody`,null,[(B(!0),V(z,null,L(e.rows,(e,t)=>(B(),V(`tr`,{key:t},[(B(!0),V(z,null,L(e,(e,t)=>(B(),V(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[W(HT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(B(),V(`blockquote`,jte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(B(),V(`h1`,Mte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(B(),V(`h2`,Nte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(B(),V(`h3`,Pte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(B(),V(`ul`,Fte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(HT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(B(),V(`ol`,Ite,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(HT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(B(),V(`p`,Lte,[W(HT,{inline:e.inline},null,8,[`inline`])])):K(``,!0)],64))),128))]))}}),zte={class:`truncate`},Bte=I({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Qi(`RouterLink`);return B(),H(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:P(()=>[W(N(Gu),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,zte,j(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Vte={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Hte={class:`font-semibold text-foreground`},Ute={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Wte=I({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=J(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=J(()=>t.tool.parameters||t.tool.Parameters||``),i=J(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=J(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(B(),H(Bte,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(B(),V(`div`,Vte,[W(N(Kd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Hte,j(n.value),1),r.value?(B(),V(`code`,Ute,j(r.value),1)):K(``,!0),U(`span`,{class:A(N(Y)(`text-fg-muted`,i.value&&`text-danger`))},j(a.value),3)]))}}),Gte={key:0,class:`mb-2 grid gap-0.5 text-xs`},Kte={key:1,class:`mb-2 flex flex-wrap gap-1.5`},qte={key:3,class:`whitespace-pre-wrap`},GT=I({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(B(),V(`div`,{class:A([`flex`,e.assistant?`justify-start`:`justify-end`])},[U(`div`,{class:A(N(Y)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(B(),V(`div`,Gte,[(B(!0),V(z,null,L(e.tools,(t,n)=>(B(),H(Wte,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):K(``,!0),e.media.length?(B(),V(`div`,Kte,[(B(!0),V(z,null,L(e.media,(e,t)=>(B(),H(_te,{key:t,attachment:e},null,8,[`attachment`]))),128))])):K(``,!0),e.assistant?(B(),H(Rte,{key:2,text:e.text},null,8,[`text`])):(B(),V(`div`,qte,j(e.text),1)),R(t.$slots,`default`)],2)],2))}}),Jte={class:`w-full self-center justify-self-center py-6 text-center`},Yte={class:`grid gap-2`},Xte=[`onCLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>NA?`${n.slice(0,NA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var FA=[`title`],IA=I({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>oA(n.event)),a=J(()=>PA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=J(()=>n.event.at?mk(n.event.at):`—`);return(e,t)=>(B(),H(N(AA),{class:A(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[Ll(Il(o,[`prevent`]),[`enter`]),Ll(Il(o,[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[G(j(n.event.kind||n.event.type||`event`),1)]),_:1}),W(N($),{class:`font-mono`},{default:P(()=>[G(j(i.value>0?`#${i.value}`:`—`),1)]),_:1}),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},j(a.value.text),9,FA)]),_:1}),W(N($),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),LA=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function RA(e){return(Number(e?.task_id)||0)>0}function zA(e,t){return t===`tasks`?RA(e):t!==`system`||!RA(e)}function BA(e,t){return e.filter(e=>zA(e,t))}function VA(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function HA(e,t){return`${e}:${t??0}`}function UA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=HA(PA(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var WA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},GA={class:`max-h-[28rem] overflow-y-auto`},KA=[`aria-expanded`,`aria-label`,`onClick`],qA=[`title`],JA=I({__name:`LiveActivityCard`,setup(e){let t=oE(),{activity:n,streamKind:r,streamState:i}=Au(gO()),a=M(`all`),o=J(()=>BA(n.value,a.value)),s=J(()=>VA(o.value.length,a.value)),c=Jt(new Set),l=J(()=>UA(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return PA(e.representative)}function p(e){return e.representative.at?mk(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(B(),H(N(sk),null,{default:P(()=>[W(N(fk),null,{default:P(()=>[W(N(pk),null,{default:P(()=>[...t[1]||=[G(`Live activity`,-1)]]),_:1}),W(N(ck),{class:`flex items-center gap-2`},{default:P(()=>[W(N(EA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:N(LA)},null,8,[`modelValue`,`options`]),W(N(ik),{variant:N(r)},{default:P(()=>[G(j(N(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),W(N(lk),null,{default:P(()=>[U(`div`,WA,[U(`div`,GA,[W(N(OA),null,{default:P(()=>[W(N(MA),{class:`sticky top-0 z-10 bg-card`},{default:P(()=>[W(N(AA),null,{default:P(()=>[W(N(jA),null,{default:P(()=>[...t[2]||=[G(`Event`,-1)]]),_:1}),W(N(jA),null,{default:P(()=>[...t[3]||=[G(`Task`,-1)]]),_:1}),W(N(jA),null,{default:P(()=>[...t[4]||=[G(`Detail`,-1)]]),_:1}),W(N(jA),null,{default:P(()=>[...t[5]||=[G(`When`,-1)]]),_:1})]),_:1})]),_:1}),W(N(kA),null,{default:P(()=>[o.value.length?K(``,!0):(B(),H(N(AA),{key:0},{default:P(()=>[W(N($),{colspan:`4`},{default:P(()=>[W(N(XO),null,{default:P(()=>[W(N($O),null,{default:P(()=>[W(N(nk),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(B(!0),V(z,{key:1},L(l.value,e=>(B(),V(z,{key:e.key},[e.count===1?(B(),H(IA,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(B(),V(z,{key:1},[W(N(AA),{class:A(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[Ll(Il(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Ll(Il(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[U(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:Il(t=>u(e.key),[`stop`])},[d(e)?(B(),H(N(Qu),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(B(),H(N($u),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),G(` `+j(e.label)+` `,1),W(N(ik),{variant:`idle`},{default:P(()=>[G(`×`+j(e.count),1)]),_:2},1024)],8,KA)]),_:2},1024),W(N($),{class:`font-mono`},{default:P(()=>[G(j(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},j(f(e).text),9,qA)]),_:2},1024),W(N($),null,{default:P(()=>[G(j(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(B(!0),V(z,{key:0},L(e.events,(t,n)=>(B(),H(IA,{key:`${e.key}:${n}`,event:t,onO Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function hM(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function gM(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function _M(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function vM(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var yM=M([]),bM=M([]),xM=M(!0),SM=M(null),CM=M(null),wM=M(!1),TM=M(null);async function EM(){try{let e=await X.eventTypes();xM.value=e.enabled!==!1,yM.value=e.event_types||[],bM.value=e.proposals||[],SM.value=null}catch(e){SM.value=e.message||String(e)}}function DM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function OM(e){TM.value=null,CM.value=e}function kM(e){let t=LM.value.find(t=>String(t.id)===e.sample_id);OM({mode:`proposal`,id:null,source:e.source,name:``,rule:DM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function AM(e=``){OM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function jM(e){OM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:DM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function MM(){CM.value=null}async function NM(){let e=CM.value;if(e){wM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:vM(e.rule)});else{let t=e.mode===`paste`?mM(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:vM(e.rule),example:{headers:t,body:e.body}})}CM.value=null,await EM()}catch(e){TM.value=e.message||String(e)}finally{wM.value=!1}}}var PM=M(null);async function FM(){let e=PM.value;if(PM.value=null,e)try{await X.eventTypeDelete(e.id),await EM()}catch(e){SM.value=e.message||String(e)}}var IM=100,LM=M([]),RM=M(!0),zM=M(null),BM=M(!0),VM=M(null);async function HM(){try{let e=await X.captures(IM);RM.value=e.enabled!==!1,LM.value=e.captures||[],zM.value=null}catch(e){zM.value=e.message||String(e)}finally{BM.value=!1}}function UM(e){let t=LM.value.find(t=>t.id===e);return t&&(VM.value=t),!!t}function WM(){LM.value.length&&(VM.value=LM.value[0])}function GM(){_O(`captures`,()=>{HM(),EM()})}var KM={key:0,class:`text-xs text-fg-muted`},qM={key:1,class:`flex flex-col gap-1 text-xs`},JM={key:1},YM={key:2,class:`text-xs text-fg-muted`},XM=I({__name:`DispatchLinks`,props:{kind:{},id:{}},setup(e){let t=e,n=M([]),r=M(!1);F(()=>[t.kind,t.id],async()=>{r.value=!1;try{n.value=await X.dispatches(t.kind,t.id)}catch{n.value=[],r.value=!0}},{immediate:!0});let i=e=>({path:`/events`,query:{tab:`inspector`,capture:e}});return(e,a)=>{let o=Qi(`RouterLink`);return r.value?(B(),V(`p`,KM,`Dispatches unavailable.`)):n.value.length?(B(),V(`ul`,qM,[(B(!0),V(z,null,L(n.value,e=>(B(),V(`li`,{key:e.binding_id+e.capture_id,class:`flex flex-wrap items-center gap-x-2 font-mono text-fg-muted`},[t.kind===`bindings`?K(``,!0):(B(),H(o,{key:0,to:{path:`/events`,query:{tab:`bindings`}},class:`hover:text-foreground`},{default:P(()=>[G(`binding `+j(e.binding_id.slice(0,8))+` v`+j(e.binding_version),1)]),_:2},1024)),t.kind===`captures`?K(``,!0):(B(),H(o,{key:1,to:i(e.capture_id),class:`hover:text-foreground`},{default:P(()=>[G(`capture `+j(e.capture_id.slice(0,8)),1)]),_:2},1032,[`to`])),t.kind===`tasks`?K(``,!0):(B(),V(z,{key:2},[e.task_id?(B(),H(o,{key:0,to:`/tasks/${e.task_id}`,class:`text-foreground hover:underline`},{default:P(()=>[G(`task #`+j(e.task_id),1)]),_:2},1032,[`to`])):(B(),V(`span`,JM,j(e.reason||`claimed, no task recorded`),1))],64)),U(`span`,null,j(N(mk)(e.dispatched_at)),1)]))),128))])):t.kind===`tasks`?K(``,!0):(B(),V(`p`,YM,` No dispatches yet. `))}}}),ZM=I({__name:`Spinner`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),H(N(pd),{role:`status`,"aria-label":`Loading`,class:A(N(Y)(`size-4 animate-spin`,t.class))},null,8,[`class`]))}});function QM(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function $M(e){return(e?.repository??`required`)!==`none`}function eN(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function tN(e,t){switch(t){case`string`:return e;case`number`:return e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):e;case`bool`:return e===`true`||e!==`false`&&e;default:try{return JSON.parse(e)}catch{return e}}}var nN={pending_approval:`pending approval`,armed:`armed`,paused:`paused`},rN={pending_approval:`warn`,armed:`ok`,paused:`idle`};function iN(e) Line truncated
`)}};SJ.defaultYaml={explicit:!1,version:`1.2`},SJ.defaultTags={"!!":`tag:yaml.org,2002:`};function CJ(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 wJ(e){let t=new Set;return hJ(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function TJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function EJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=wJ(e);let a=TJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(sJ(t.node)||lJ(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 DJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=DJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=DJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=DJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=DJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function OJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>OJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!dJ(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 kJ=class{constructor(e){Object.defineProperty(this,nJ,{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(!iJ(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=OJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?DJ(i,{"":o},``,o):o}},AJ=class extends kJ{constructor(e){super(Xq),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=[],hJ(e,{Node:(e,t)=>{(rJ(t)||dJ(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||=(OJ(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=jJ(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(CJ(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 jJ(e,t,n){if(rJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(lJ(t)){let r=0;for(let i of t.items){let t=jJ(e,i,n);t>r&&(r=t)}return r}if(oJ(t)){let r=jJ(e,t.key,n),i=jJ(e,t.value,n);return Math.max(r,i)}return 1}var MJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,NJ=class extends kJ{constructor(e){super(eJ),this.value=e}toJSON(e,t){return t?.keep?this.value:OJ(this.value,e,t)}toString(){return String(this.value)}};NJ.BLOCK_FOLDED=`BLOCK_FOLDED`,NJ.BLOCK_LITERAL=`BLOCK_LITERAL`,NJ.PLAIN=`PLAIN`,NJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,NJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var PJ=`tag:yaml.org,2002:`;function FJ(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 IJ(e,t,n){if(iJ(e)&&(e=e.contents),uJ(e))return e;if(oJ(e)){let t=n.schema[Qq].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 AJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=PJ+t.slice(2));let l=FJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new NJ(e);return c&&(c.node=t),t Line truncated
`)?VJ(n,t):n.includes(`
`)}),t}function WT(e){let t=String(e||``).trim();if(!t.includes(`|`))return null;let n=t.replace(/^\|/,``).replace(/\|$/,``).split(`|`).map(e=>e.trim());return n.length>1&&n.every(e=>e!==``)?n:null}function Ete(e){return e.every(e=>/^:?-{3,}:?$/.test(e))}var Dte={class:`[overflow-wrap:anywhere]`},Ote={key:0,class:`my-2 overflow-auto rounded-md border border-border bg-background/60 p-3`},kte={class:`font-mono text-[0.85em]`},Ate={key:1,class:`my-3 w-full border-collapse text-[0.92em]`},jte={key:2,class:`my-2 border-l-[3px] border-primary pl-3 text-fg-muted`},Mte={key:3,class:`mt-1 mb-2 text-xl leading-tight font-semibold tracking-[-0.02em]`},Nte={key:4,class:`mt-1 mb-2 text-lg leading-tight font-semibold tracking-[-0.02em]`},Pte={key:5,class:`mt-1 mb-2 text-base leading-tight font-semibold tracking-[-0.02em]`},Fte={key:6,class:`my-2.5 flex list-disc flex-col gap-1 pl-5`},Ite={key:7,class:`my-2.5 flex list-decimal flex-col gap-1 pl-5`},Lte={key:8,class:`mb-2.5 last:mb-0`},Rte=I({__name:`ChatMarkdown`,props:{text:{}},setup(e){let t=e,n=J(()=>Tte(t.text));return(e,t)=>(B(),V(`div`,Dte,[(B(!0),V(z,null,L(n.value,(e,t)=>(B(),V(z,{key:t},[e.kind===`pre`?(B(),V(`pre`,Ote,[U(`code`,kte,j(e.code),1)])):e.kind===`table`?(B(),V(`table`,Ate,[U(`thead`,null,[U(`tr`,null,[(B(!0),V(z,null,L(e.head,(e,t)=>(B(),V(`th`,{key:t,class:`border border-border bg-muted px-2 py-1.5 text-left font-semibold`},[W(HT,{inline:e},null,8,[`inline`])]))),128))])]),U(`tbody`,null,[(B(!0),V(z,null,L(e.rows,(e,t)=>(B(),V(`tr`,{key:t},[(B(!0),V(z,null,L(e,(e,t)=>(B(),V(`td`,{key:t,class:`border border-border px-2 py-1.5 text-left`},[W(HT,{inline:e},null,8,[`inline`])]))),128))]))),128))])])):e.kind===`blockquote`?(B(),V(`blockquote`,jte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h1`?(B(),V(`h1`,Mte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h2`?(B(),V(`h2`,Nte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`h3`?(B(),V(`h3`,Pte,[W(HT,{inline:e.inline},null,8,[`inline`])])):e.kind===`ul`?(B(),V(`ul`,Fte,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(HT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`ol`?(B(),V(`ol`,Ite,[(B(!0),V(z,null,L(e.items,(e,t)=>(B(),V(`li`,{key:t},[W(HT,{inline:e},null,8,[`inline`])]))),128))])):e.kind===`p`?(B(),V(`p`,Lte,[W(HT,{inline:e.inline},null,8,[`inline`])])):K(``,!0)],64))),128))]))}}),zte={class:`truncate`},Bte=I({__name:`ChatNavChip`,props:{path:{},label:{}},setup(e){return(t,n)=>{let r=Qi(`RouterLink`);return B(),H(r,{to:e.path,title:`Go to ${e.label||e.path}`,class:`inline-flex max-w-full items-center gap-1.5 rounded-full border border-primary/45 bg-primary-soft px-2.5 py-1 text-xs font-semibold text-link transition-colors hover:border-primary hover:bg-primary/15 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`},{default:P(()=>[W(N(Ku),{"aria-hidden":`true`,class:`size-3.5 shrink-0`}),U(`span`,zte,j(e.label||e.path),1)]),_:1},8,[`to`,`title`])}}}),Vte={key:1,class:`flex items-baseline gap-1.5 [overflow-wrap:anywhere]`},Hte={class:`font-semibold text-foreground`},Ute={key:0,class:`font-mono text-[0.95em] text-fg-subtle`},Wte=I({__name:`ChatToolCall`,props:{tool:{},streaming:{type:Boolean}},setup(e){let t=e,n=J(()=>t.tool.name||t.tool.Name||t.tool.tool||`tool`),r=J(()=>t.tool.parameters||t.tool.Parameters||``),i=J(()=>!!(t.tool.err||t.tool.Err||t.tool.failed)),a=J(()=>t.tool.summary||t.tool.Summary||t.tool.text||t.tool.err||t.tool.Err||(t.streaming?i.value?`failed`:`running…`:`done`));return(t,o)=>e.tool.path?(B(),H(Bte,{key:0,path:e.tool.path,label:e.tool.label},null,8,[`path`,`label`])):(B(),V(`div`,Vte,[W(N(qd),{"aria-hidden":`true`,class:`size-3.5 shrink-0 self-center text-fg-subtle`}),U(`span`,Hte,j(n.value),1),r.value?(B(),V(`code`,Ute,j(r.value),1)):K(``,!0),U(`span`,{class:A(N(Y)(`text-fg-muted`,i.value&&`text-danger`))},j(a.value),3)]))}}),Gte={key:0,class:`mb-2 grid gap-0.5 text-xs`},Kte={key:1,class:`mb-2 flex flex-wrap gap-1.5`},qte={key:3,class:`whitespace-pre-wrap`},GT=I({__name:`ChatBubble`,props:{text:{},tools:{default:()=>[]},media:{default:()=>[]},assistant:{type:Boolean,default:!1},streaming:{type:Boolean,default:!1}},setup(e){return(t,n)=>(B(),V(`div`,{class:A([`flex`,e.assistant?`justify-start`:`justify-end`])},[U(`div`,{class:A(N(Y)(`max-w-[min(78ch,86%)] rounded-[0.85rem] px-4 py-3 leading-normal [overflow-wrap:anywhere]`,e.assistant?`bg-muted`:`bg-primary/15`))},[e.assistant&&e.tools.length?(B(),V(`div`,Gte,[(B(!0),V(z,null,L(e.tools,(t,n)=>(B(),H(Wte,{key:n,tool:t,streaming:e.streaming},null,8,[`tool`,`streaming`]))),128))])):K(``,!0),e.media.length?(B(),V(`div`,Kte,[(B(!0),V(z,null,L(e.media,(e,t)=>(B(),H(_te,{key:t,attachment:e},null,8,[`attachment`]))),128))])):K(``,!0),e.assistant?(B(),H(Rte,{key:2,text:e.text},null,8,[`text`])):(B(),V(`div`,qte,j(e.text),1)),R(t.$slots,`default`)],2)],2))}}),Jte={class:`w-full self-center justify-self-center py-6 text-center`},Yte={class:`grid gap-2`},Xte=[`onCLine truncated
`).map(e=>e.trim()).find(Boolean)||``,r=n.length>PA?`${n.slice(0,PA).trimEnd()}…`:n;return{text:r,full:t,truncated:r!==t}}var IA=[`title`],LA=I({__name:`ActivityRow`,props:{event:{}},emits:[`open`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>sA(n.event)),a=J(()=>FA(n.event));function o(){i.value>0&&r(`open`,i.value)}let s=J(()=>n.event.at?hk(n.event.at):`—`);return(e,t)=>(B(),H(N(jA),{class:A(i.value>0?`cursor-pointer`:``),role:i.value>0?`link`:void 0,tabindex:i.value>0?0:void 0,title:i.value>0?`Open task details`:void 0,onClick:o,onKeydown:[Rl(Ll(o,[`prevent`]),[`enter`]),Rl(Ll(o,[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[G(j(n.event.kind||n.event.type||`event`),1)]),_:1}),W(N($),{class:`font-mono`},{default:P(()=>[G(j(i.value>0?`#${i.value}`:`—`),1)]),_:1}),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:a.value.truncated?a.value.full:void 0},j(a.value.text),9,IA)]),_:1}),W(N($),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1},8,[`class`,`role`,`tabindex`,`title`,`onKeydown`]))}}),RA=[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`system`,label:`System`}];function zA(e){return(Number(e?.task_id)||0)>0}function BA(e,t){return t===`tasks`?zA(e):t!==`system`||!zA(e)}function VA(e,t){return e.filter(e=>BA(e,t))}function HA(e,t){return e>0?``:t===`all`?`Waiting for activity`:t===`tasks`?`No task events yet`:`No system events yet`}function UA(e,t){return`${e}:${t??0}`}function WA(e){let t=[];for(let n of e){let e=n.kind||n.type||`event`,r=Number(n.task_id)||0,i=UA(FA(n).text,r),a=t[t.length-1];if(a&&a.key===i){a.count+=1,a.events.push(n);continue}t.push({key:i,label:e,taskID:r,count:1,representative:n,events:[n]})}return t}var GA={role:`region`,"aria-label":`Live activity`,"aria-live":`polite`},KA={class:`max-h-[28rem] overflow-y-auto`},qA=[`aria-expanded`,`aria-label`,`onClick`],JA=[`title`],YA=I({__name:`LiveActivityCard`,setup(e){let t=oE(),{activity:n,streamKind:r,streamState:i}=ju(_O()),a=M(`all`),o=J(()=>VA(n.value,a.value)),s=J(()=>HA(o.value.length,a.value)),c=Jt(new Set),l=J(()=>WA(o.value));function u(e){c.has(e)?c.delete(e):c.add(e)}function d(e){return c.has(e.key)}function f(e){return FA(e.representative)}function p(e){return e.representative.at?hk(e.representative.at):`—`}function m(e){t.push(`/tasks?task=${encodeURIComponent(e)}`)}return(e,t)=>(B(),H(N(ck),null,{default:P(()=>[W(N(pk),null,{default:P(()=>[W(N(mk),null,{default:P(()=>[...t[1]||=[G(`Live activity`,-1)]]),_:1}),W(N(lk),{class:`flex items-center gap-2`},{default:P(()=>[W(N(DA),{modelValue:a.value,"onUpdate:modelValue":t[0]||=e=>a.value=e,label:`Filter activity`,options:N(RA)},null,8,[`modelValue`,`options`]),W(N(ak),{variant:N(r)},{default:P(()=>[G(j(N(i)),1)]),_:1},8,[`variant`])]),_:1})]),_:1}),W(N(uk),null,{default:P(()=>[U(`div`,GA,[U(`div`,KA,[W(N(kA),null,{default:P(()=>[W(N(NA),{class:`sticky top-0 z-10 bg-card`},{default:P(()=>[W(N(jA),null,{default:P(()=>[W(N(MA),null,{default:P(()=>[...t[2]||=[G(`Event`,-1)]]),_:1}),W(N(MA),null,{default:P(()=>[...t[3]||=[G(`Task`,-1)]]),_:1}),W(N(MA),null,{default:P(()=>[...t[4]||=[G(`Detail`,-1)]]),_:1}),W(N(MA),null,{default:P(()=>[...t[5]||=[G(`When`,-1)]]),_:1})]),_:1})]),_:1}),W(N(AA),null,{default:P(()=>[o.value.length?K(``,!0):(B(),H(N(jA),{key:0},{default:P(()=>[W(N($),{colspan:`4`},{default:P(()=>[W(N(ZO),null,{default:P(()=>[W(N(ek),null,{default:P(()=>[W(N(rk),null,{default:P(()=>[G(j(s.value),1)]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})),o.value.length?(B(!0),V(z,{key:1},L(l.value,e=>(B(),V(z,{key:e.key},[e.count===1?(B(),H(LA,{key:0,event:e.representative,onOpen:m},null,8,[`event`])):(B(),V(z,{key:1},[W(N(jA),{class:A(e.taskID>0?`cursor-pointer`:``),role:e.taskID>0?`link`:void 0,tabindex:e.taskID>0?0:void 0,title:e.taskID>0?`Open task details`:void 0,onClick:t=>e.taskID>0&&m(e.taskID),onKeydown:[Rl(Ll(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`enter`]),Rl(Ll(t=>e.taskID>0&&m(e.taskID),[`prevent`]),[`space`])]},{default:P(()=>[W(N($),{class:`font-medium`},{default:P(()=>[U(`button`,{type:`button`,class:`inline-flex items-center gap-1 rounded hover:opacity-80`,"aria-expanded":d(e),"aria-label":`${d(e)?`Hide`:`Show`} ${e.count} ${e.label} events`,onClick:Ll(t=>u(e.key),[`stop`])},[d(e)?(B(),H(N($u),{key:0,class:`size-3.5 shrink-0 text-fg-subtle`})):(B(),H(N(ed),{key:1,class:`size-3.5 shrink-0 text-fg-subtle`})),G(` `+j(e.label)+` `,1),W(N(ak),{variant:`idle`},{default:P(()=>[G(`×`+j(e.count),1)]),_:2},1024)],8,qA)]),_:2},1024),W(N($),{class:`font-mono`},{default:P(()=>[G(j(e.taskID>0?`#${e.taskID}`:`—`),1)]),_:2},1024),W(N($),{class:`w-[55%] max-w-0`},{default:P(()=>[U(`span`,{class:`block truncate`,title:f(e).truncated?f(e).full:void 0},j(f(e).text),9,JA)]),_:2},1024),W(N($),null,{default:P(()=>[G(j(p(e)),1)]),_:2},1024)]),_:2},1032,[`class`,`role`,`tabindex`,`title`,`onClick`,`onKeydown`]),d(e)?(B(!0),V(z,{key:0},L(e.events,(t,n)=>(B(),H(LA,{key:`${e.key}:${n}`,event:t,onO Line truncated
`)){let e=n.indexOf(`:`);if(e<=0)continue;let r=n.slice(0,e).trim();r&&(t[r]=n.slice(e+1).trim())}return t}function hM(e,t){if(!e.event_type)return{label:`Unidentified`,identified:!1};let n=t.find(t=>t.id===e.event_type);return{label:n?n.name:`Deleted type`,identified:!0}}function gM(e,t){if(!e)return`No event type`;let n=t.find(t=>t.id===e);return n?`${n.source} / ${n.name}`:`Deleted type`}function _M(e){let t=[...(e.headers||[]).map(e=>`${e.name} = ${e.value}`),...(e.payload||[]).map(e=>e.op===`present`?`${e.path} present`:`${e.path} = ${e.value??``}`)];return t.length?t.join(` · `):`any event`}function vM(e){return{headers:(e.headers||[]).filter(e=>e.name.trim()!==``).map(e=>({name:e.name.trim(),value:e.value})),payload:(e.payload||[]).filter(e=>e.path.trim()!==``).map(e=>e.op===`present`?{path:e.path.trim(),op:e.op}:{path:e.path.trim(),op:e.op,value:e.value??``})}}var yM=M([]),bM=M([]),xM=M(!0),SM=M(null),CM=M(null),wM=M(!1),TM=M(null);async function EM(){try{let e=await X.eventTypes();xM.value=e.enabled!==!1,yM.value=e.event_types||[],bM.value=e.proposals||[],SM.value=null}catch(e){SM.value=e.message||String(e)}}function DM(e){return{headers:(e.headers||[]).map(e=>({...e})),payload:(e.payload||[]).map(e=>({...e}))}}function OM(e){TM.value=null,CM.value=e}function kM(e){let t=LM.value.find(t=>String(t.id)===e.sample_id);OM({mode:`proposal`,id:null,source:e.source,name:``,rule:DM(e.rule),headersText:``,body:t?.body||``,exampleHeaders:e.headers||{}})}function AM(e=``){OM({mode:`paste`,id:null,source:e,name:``,rule:{headers:[],payload:[]},headersText:``,body:``,exampleHeaders:{}})}function jM(e){OM({mode:`edit`,id:e.id,source:e.source,name:e.name,rule:DM(e.rule),headersText:``,body:``,exampleHeaders:{}})}function MM(){CM.value=null}async function NM(){let e=CM.value;if(e){wM.value=!0;try{if(e.mode===`edit`&&e.id)await X.eventTypeUpdate(e.id,{name:e.name,rule:vM(e.rule)});else{let t=e.mode===`paste`?mM(e.headersText):e.exampleHeaders;await X.eventTypeCreate({source:e.source,name:e.name,rule:e.mode===`paste`?void 0:vM(e.rule),example:{headers:t,body:e.body}})}CM.value=null,await EM()}catch(e){TM.value=e.message||String(e)}finally{wM.value=!1}}}var PM=M(null);async function FM(){let e=PM.value;if(PM.value=null,e)try{await X.eventTypeDelete(e.id),await EM()}catch(e){SM.value=e.message||String(e)}}var IM=100,LM=M([]),RM=M(!0),zM=M(null),BM=M(!0),VM=M(null);async function HM(){try{let e=await X.captures(IM);RM.value=e.enabled!==!1,LM.value=e.captures||[],zM.value=null}catch(e){zM.value=e.message||String(e)}finally{BM.value=!1}}function UM(e){let t=LM.value.find(t=>t.id===e);return t&&(VM.value=t),!!t}function WM(){LM.value.length&&(VM.value=LM.value[0])}function GM(){vO(`captures`,()=>{HM(),EM()})}var KM={key:0,class:`text-xs text-fg-muted`},qM={key:1,class:`flex flex-col gap-1 text-xs`},JM={key:1},YM={key:2,class:`text-xs text-fg-muted`},XM=I({__name:`DispatchLinks`,props:{kind:{},id:{}},setup(e){let t=e,n=M([]),r=M(!1);F(()=>[t.kind,t.id],async()=>{r.value=!1;try{n.value=await X.dispatches(t.kind,t.id)}catch{n.value=[],r.value=!0}},{immediate:!0});let i=e=>({path:`/events`,query:{tab:`inspector`,capture:e}});return(e,a)=>{let o=Qi(`RouterLink`);return r.value?(B(),V(`p`,KM,`Dispatches unavailable.`)):n.value.length?(B(),V(`ul`,qM,[(B(!0),V(z,null,L(n.value,e=>(B(),V(`li`,{key:e.binding_id+e.capture_id,class:`flex flex-wrap items-center gap-x-2 font-mono text-fg-muted`},[t.kind===`bindings`?K(``,!0):(B(),H(o,{key:0,to:{path:`/events`,query:{tab:`bindings`}},class:`hover:text-foreground`},{default:P(()=>[G(`binding `+j(e.binding_id.slice(0,8))+` v`+j(e.binding_version),1)]),_:2},1024)),t.kind===`captures`?K(``,!0):(B(),H(o,{key:1,to:i(e.capture_id),class:`hover:text-foreground`},{default:P(()=>[G(`capture `+j(e.capture_id.slice(0,8)),1)]),_:2},1032,[`to`])),t.kind===`tasks`?K(``,!0):(B(),V(z,{key:2},[e.task_id?(B(),H(o,{key:0,to:`/tasks/${e.task_id}`,class:`text-foreground hover:underline`},{default:P(()=>[G(`task #`+j(e.task_id),1)]),_:2},1032,[`to`])):(B(),V(`span`,JM,j(e.reason||`claimed, no task recorded`),1))],64)),U(`span`,null,j(N(hk)(e.dispatched_at)),1)]))),128))])):t.kind===`tasks`?K(``,!0):(B(),V(`p`,YM,` No dispatches yet. `))}}}),ZM=I({__name:`Spinner`,props:{class:{type:[Boolean,null,String,Object,Array]}},setup(e){let t=e;return(e,n)=>(B(),H(N(md),{role:`status`,"aria-label":`Loading`,class:A(N(Y)(`size-4 animate-spin`,t.class))},null,8,[`class`]))}});function QM(e,t){return t?e.filter(e=>e.event_type_id===t):[]}function $M(e){return(e?.repository??`required`)!==`none`}function eN(e,t){return e.filter(e=>t===`any`||e.type===`any`||e.type===t)}function tN(e,t){switch(t){case`string`:return e;case`number`:return e.trim()!==``&&!Number.isNaN(Number(e))?Number(e):e;case`bool`:return e===`true`||e!==`false`&&e;default:try{return JSON.parse(e)}catch{return e}}}var nN={pending_approval:`pending approval`,armed:`armed`,paused:`paused`},rN={pending_approval:`warn`,armed:`ok`,paused:`idle`};function iN(e) Line truncated
`)}};wJ.defaultYaml={explicit:!1,version:`1.2`},wJ.defaultTags={"!!":`tag:yaml.org,2002:`};function TJ(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 EJ(e){let t=new Set;return _J(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function DJ(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function OJ(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=EJ(e);let a=DJ(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(lJ(t.node)||dJ(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 kJ(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=kJ(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=kJ(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=kJ(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=kJ(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function AJ(e,t,n){if(Array.isArray(e))return e.map((e,t)=>AJ(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!pJ(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 jJ=class{constructor(e){Object.defineProperty(this,iJ,{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(!oJ(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=AJ(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?kJ(i,{"":o},``,o):o}},MJ=class extends jJ{constructor(e){super(Qq),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=[],_J(e,{Node:(e,t)=>{(aJ(t)||pJ(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||=(AJ(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=NJ(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(TJ(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 NJ(e,t,n){if(aJ(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(dJ(t)){let r=0;for(let i of t.items){let t=NJ(e,i,n);t>r&&(r=t)}return r}if(cJ(t)){let r=NJ(e,t.key,n),i=NJ(e,t.value,n);return Math.max(r,i)}return 1}var PJ=e=>!e||typeof e!=`function`&&typeof e!=`object`,FJ=class extends jJ{constructor(e){super(nJ),this.value=e}toJSON(e,t){return t?.keep?this.value:AJ(this.value,e,t)}toString(){return String(this.value)}};FJ.BLOCK_FOLDED=`BLOCK_FOLDED`,FJ.BLOCK_LITERAL=`BLOCK_LITERAL`,FJ.PLAIN=`PLAIN`,FJ.QUOTE_DOUBLE=`QUOTE_DOUBLE`,FJ.QUOTE_SINGLE=`QUOTE_SINGLE`;var IJ=`tag:yaml.org,2002:`;function LJ(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 RJ(e,t,n){if(oJ(e)&&(e=e.contents),fJ(e))return e;if(cJ(e)){let t=n.schema[eJ].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 MJ(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=IJ+t.slice(2));let l=LJ(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new FJ(e);return c&&(c.node=t),t Line truncated
`)?UJ(n,t):n.includes(`
`)?`
`+VJ(n,t):(e.endsWith(` `)?``:` `)+n,UJ=`flow`,WJ=`block`,GJ=`quoted`;function KJ(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=qJ(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=qJ(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`+UJ(n,t):(e.endsWith(` `)?``:` `)+n,GJ=`flow`,KJ=`block`,qJ=`quoted`;function JJ(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=YJ(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
`)n===`block`&&(h=YJ(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
`&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function qJ(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var JJ=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),YJ=e=>/^(%|---|\.\.\.)/m.test(e);function XJ(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function ZJ(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(YJ(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function YJ(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
`);r=t,i=t+1,a=e[i]}return r}var XJ=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),ZJ=e=>/^(%|---|\.\.\.)/m.test(e);function QJ(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
`){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function $J(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(ZJ(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
`;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:KJ(o,a,GJ,JJ(t,!1))}function QJ(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return ZJ(e,t);let n=t.indent||(YJ(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:KJ(r,n,UJ,JJ(t,!1))}function $J(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=ZJ;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?QJ:i&&!t?ZJ:n?QJ:ZJ}return r(e,t)}var eY;try{eY=RegExp(`(^|(?<!
`,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:JJ(o,a,qJ,XJ(t,!1))}function eY(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
`)||/[ \t]\n|\n[ \t]/.test(e))return $J(e,t);let n=t.indent||(ZJ(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:JJ(r,n,GJ,XJ(t,!1))}function tY(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=$J;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?eY:i&&!t?$J:n?eY:$J}return r(e,t)}var nY;try{nY=RegExp(`(^|(?<!
))
+(?!
|$)`,`g`)}catch{eY=/\n+(?!\n|$)/g}function tY({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return $J(n,r);let l=r.indent||(r.forceBlockIndent||YJ(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===NJ.BLOCK_FOLDED?!1:t===NJ.BLOCK_LITERAL||!XJ(n,c,l.length);if(!n)return u?`|
|$)`,`g`)}catch{nY=/\n+(?!\n|$)/g}function rY({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return tY(n,r);let l=r.indent||(r.forceBlockIndent||ZJ(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===FJ.BLOCK_FOLDED?!1:t===FJ.BLOCK_LITERAL||!QJ(n,c,l.length);if(!n)return u?`|
`:`>
`;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
`&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
`);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
`&&(p=p.slice(0,-1)),p.replace(eY,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`&&(p=p.slice(0,-1)),p.replace(nY,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
`)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=JJ(r,!0);o!==`folded`&&t!==NJ.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=KJ(`${v}${e}${p}`,l,WJ,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function nY(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return $J(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?$J(a,t):tY(e,t,n,r);if(!s&&!u&&i!==NJ.PLAIN&&a.includes(`
`))return tY(e,t,n,r);if(YJ(a)){if(c===``)return t.forceBlockIndent=!0,tY(e,t,n,r);if(s&&c===l)return $J(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return $J(a,t)}return s?d:KJ(d,c,UJ,JJ(t,!1))}function rY(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==NJ.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=NJ.QUOTE_DOUBLE);let c=e=>{switch(e){case NJ.BLOCK_FOLDED:case NJ.BLOCK_LITERAL:return i||a?$J(o.value,t):tY(o,t,n,r);case NJ.QUOTE_DOUBLE:return ZJ(o.value,t);case NJ.QUOTE_SINGLE:return QJ(o.value,t);case NJ.PLAIN:return nY(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function iY(e,t){let n=Object.assign({blockQuote:!0,commentString:BJ,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function aY(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(sJ(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function oY(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(sJ(e)||lJ(e))&&e.anchor;a&&CJ(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function sY(e,t,n,r){if(oJ(e))return e.toString(t,n,r);if(rJ(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=uJ(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=aY(t.doc.schema.tags,a);let o=oY(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):sJ(a)?rY(a,t,n,r):a.toString(t,n,r);return o?sJ(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function cY({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=uJ(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(lJ(e)||!uJ(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||lJ(e)||(sJ(e)?e.type===NJ.BLOCK_FOLDED||e.type===NJ.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=sY(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=HJ(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=HJ(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=HJ(g,n.indent,l(f))));let _,v,y;uJ(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&sJ(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&cJ(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=sY(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${VJ(e,n.indent)}`}x===``&&!n.inFlow?S===`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=XJ(r,!0);o!==`folded`&&t!==FJ.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=JJ(`${v}${e}${p}`,l,KJ,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function iY(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
`)||u&&/[[\]{},]/.test(a))return tY(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
`)?tY(a,t):rY(e,t,n,r);if(!s&&!u&&i!==FJ.PLAIN&&a.includes(`
`))return rY(e,t,n,r);if(ZJ(a)){if(c===``)return t.forceBlockIndent=!0,rY(e,t,n,r);if(s&&c===l)return tY(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return tY(a,t)}return s?d:JJ(d,c,GJ,XJ(t,!1))}function aY(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==FJ.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=FJ.QUOTE_DOUBLE);let c=e=>{switch(e){case FJ.BLOCK_FOLDED:case FJ.BLOCK_LITERAL:return i||a?tY(o.value,t):rY(o,t,n,r);case FJ.QUOTE_DOUBLE:return $J(o.value,t);case FJ.QUOTE_SINGLE:return eY(o.value,t);case FJ.PLAIN:return iY(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function oY(e,t){let n=Object.assign({blockQuote:!0,commentString:HJ,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function sY(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(lJ(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function cY(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(lJ(e)||dJ(e))&&e.anchor;a&&TJ(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function lY(e,t,n,r){if(cJ(e))return e.toString(t,n,r);if(aJ(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=fJ(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=sY(t.doc.schema.tags,a);let o=cY(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):lJ(a)?aY(a,t,n,r):a.toString(t,n,r);return o?lJ(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function uY({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=fJ(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(dJ(e)||!fJ(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||dJ(e)||(lJ(e)?e.type===FJ.BLOCK_FOLDED||e.type===FJ.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=lY(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=WJ(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=WJ(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=WJ(g,n.indent,l(f))));let _,v,y;fJ(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&lJ(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&uJ(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let b=!1,x=lY(t,n,()=>b=!0,()=>h=!0),S=` `;if(f||_||v){if(S=_?`
`:``,v){let e=l(v);S+=`\n${UJ(e,n.indent)}`}x===``&&!n.inFlow?S===`
`&&y&&(S=`
`):S+=`\n${n.indent}`}else if(!p&&lJ(t)){let e=x[0],r=x.indexOf(`
`):S+=`\n${n.indent}`}else if(!p&&dJ(t)){let e=x[0],r=x.indexOf(`
`),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=x.indexOf(` `);e===`&`&&n!==-1&&n<r&&x[n+1]===`!`&&(n=x.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(S=`\n${n.indent}`)}}else(x===``||x[0]===`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=HJ(g,n.indent,l(y)):h&&i&&i(),g}function lY(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var uY=`<<`,dY={identify:e=>e===uY||typeof e==`symbol`&&e.description===uY,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new NJ(Symbol(uY)),{addToJSMap:pY}),stringify:()=>uY},fY=(e,t)=>(dY.identify(t)||sJ(t)&&(!t.type||t.type===NJ.PLAIN)&&dY.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===dY.tag&&e.default);function pY(e,t,n){let r=hY(e,n);if(cJ(r))for(let n of r.items)mY(e,t,n);else if(Array.isArray(r))for(let n of r)mY(e,t,n);else mY(e,t,r)}function mY(e,t,n){let r=hY(e,n);if(!aJ(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function hY(e,t){return e&&rJ(t)?t.resolve(e.doc,e):t}function gY(e,t,{key:n,value:r}){if(uJ(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(fY(e,n))pY(e,t,r);else{let i=OJ(n,``,e);if(t instanceof Map)t.set(i,OJ(r,i,e));else if(t instanceof Set)t.add(i);else{let a=_Y(n,i,e),o=OJ(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function _Y(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(uJ(e)&&n?.doc){let t=iY(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),lY(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function vY(e,t,n){return new yY(IJ(e,void 0,n),IJ(t,void 0,n))}var yY=class e{constructor(e,t=null){Object.defineProperty(this,nJ,{value:$q}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return uJ(n)&&(n=n.clone(t)),uJ(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return gY(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?cY(this,e,t,n):JSON.stringify(this)}};function bY(e,t,n){return(t.inFlow??e.flow?SY:xY)(e,t,n)}function xY({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(uJ(i))!d&&i.spaceBefore&&f.push(``),CY(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(oJ(i)){let e=uJ(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),CY(n,f,e.commentBefore,d))}d=!1;let s=sY(i,u,()=>o=null,()=>d=!0);o&&(s+=HJ(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`)&&(S=``);return g+=S+x,n.inFlow?b&&r&&r():y&&!b?g+=WJ(g,n.indent,l(y)):h&&i&&i(),g}function dY(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var fY=`<<`,pY={identify:e=>e===fY||typeof e==`symbol`&&e.description===fY,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new FJ(Symbol(fY)),{addToJSMap:hY}),stringify:()=>fY},mY=(e,t)=>(pY.identify(t)||lJ(t)&&(!t.type||t.type===FJ.PLAIN)&&pY.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===pY.tag&&e.default);function hY(e,t,n){let r=_Y(e,n);if(uJ(r))for(let n of r.items)gY(e,t,n);else if(Array.isArray(r))for(let n of r)gY(e,t,n);else gY(e,t,r)}function gY(e,t,n){let r=_Y(e,n);if(!sJ(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function _Y(e,t){return e&&aJ(t)?t.resolve(e.doc,e):t}function vY(e,t,{key:n,value:r}){if(fJ(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(mY(e,n))hY(e,t,r);else{let i=AJ(n,``,e);if(t instanceof Map)t.set(i,AJ(r,i,e));else if(t instanceof Set)t.add(i);else{let a=yY(n,i,e),o=AJ(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function yY(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(fJ(e)&&n?.doc){let t=oY(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),dY(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function bY(e,t,n){return new xY(RJ(e,void 0,n),RJ(t,void 0,n))}var xY=class e{constructor(e,t=null){Object.defineProperty(this,iJ,{value:tJ}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return fJ(n)&&(n=n.clone(t)),fJ(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return vY(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?uY(this,e,t,n):JSON.stringify(this)}};function SY(e,t,n){return(t.inFlow??e.flow?wY:CY)(e,t,n)}function CY({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(fJ(i))!d&&i.spaceBefore&&f.push(``),TY(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(cJ(i)){let e=fJ(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),TY(n,f,e.commentBefore,d))}d=!1;let s=lY(i,u,()=>o=null,()=>d=!0);o&&(s+=WJ(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
`}}return e?(p+=`
`+VJ(l(e),c),s&&s()):d&&o&&o(),p}function SY({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(uJ(i))i.spaceBefore&&d.push(``),CY(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(oJ(i)){let e=uJ(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),CY(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=uJ(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=sY(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=HJ(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function CY({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=VJ(t(r),e);n.push(i.trimStart())}}function wY(e,t){let n=sJ(t)?t.value:t;for(let r of e)if(oJ(r)&&(r.key===t||r.key===n||sJ(r.key)&&r.key.value===n))return r}var TY=class extends zJ{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(Qq,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(vY(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=oJ(e)?e:!e||typeof e!=`object`||!(`key`in e)?new yY(e,e?.value):new yY(e.key,e.value);let r=wY(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);sJ(r.value)&&MJ(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=wY(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=wY(this.items,e)?.value;return(!t&&sJ(n)?n.value:n)??void 0}has(e){return!!wY(this.items,e)}set(e,t){this.add(new yY(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)gY(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!oJ(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),bY(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},EY={collection:`map`,default:!0,nodeClass:TY,tag:`tag:yaml.org,2002:map`,resolve(e,t){return aJ(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>TY.from(e,t,n)},DY=class extends zJ{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(tJ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=OY(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=OY(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&sJ(r)?r.value:r}has(e){let t=OY(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=OY(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];sJ(r)&&MJ(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(OJ(e,String(r++),t));return n}toString(e,t,n){return e?bY(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(IJ(a,void 0,n))}}return i}};function OY(e){let t=sJ(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var kY={collection:`seq`,default:!0,nodeClass:DY,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return cJ(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>DY.from(e,t,n)},AY={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),rY(e,t,n,r)}},jY={identify:e=>e==null,createNode:()=>new NJ(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new NJ(null),stringify:({source:e},t)=>typeof e==`string`&&jY.test.test(e)?e:t.options.nullStr},MY={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new NJ(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&MY.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function NY({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var PY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:NY},FY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return rY({comment:e,type:t,value:s},r,i,a)}};function YY(e,t){if(cJ(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!oJ(r)){if(aJ(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new yY(new NJ(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=oJ(r)?r:new yY(r)}}else t(`Expected a sequence for this tag`);return e}function XY(e,t,n){let{replacer:r}=n,i=new DY(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(vY(o,s,n))}return i}var ZY={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:YY,createNode:XY},QY=class e extends DY{constructor(){super(),this.add=TY.prototype.add.bind(this),this.delete=TY.prototype.delete.bind(this),this.get=TY.prototype.get.bind(this),this.has=TY.prototype.has.bind(this),this.set=TY.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(oJ(e)?(r=OJ(e.key,``,t),i=OJ(e.value,r,t)):r=OJ(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=XY(e,t,n),i=new this;return i.items=r.items,i}};QY.tag=`tag:yaml.org,2002:omap`;var $Y={collection:`seq`,identify:e=>e instanceof Map,nodeClass:QY,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=YY(e,t),r=[];for(let{key:e}of n.items)sJ(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new QY,n)},createNode:(e,t,n)=>QY.from(e,t,n)};function eX({value:e,source:t},n){return t&&(e?tX:nX).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var tX={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new NJ(!0),stringify:eX},nX={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new NJ(!1),stringify:eX},rX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:NY},iX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():NY(e)}},aX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new NJ(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:NY},oX=e=>typeof e==`bigint`||Number.isInteger(e);function sX(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function cX(e,t,n){let{value:r}=e;if(oX(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return NY(e)}var lX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>sX(e,2,2,n),stringify:e=>cX(e,2,`0b`)},uX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>sX(e,1,8,n),stringify:e=>cX(e,8,`0`)},dX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>sX(e,0,10,n),stringify:NY},fX={identify:oX,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>sX(e,2,16,n),stringify:e=>cX(e,16,`0x`)},pX=class e extends TY{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=oJ(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new yY(e.key,null):new yY(e,null),wY(this.items,t.key)||this.items.push(t)}get(e,t){let n=wY(this.items,e);return!t&&oJ(n)?sJ(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=wY(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new yY(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(VJ(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(VJ(a(t),``)))}return n.join(`
`+UJ(l(e),c),s&&s()):d&&o&&o(),p}function wY({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(fJ(i))i.spaceBefore&&d.push(``),TY(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(cJ(i)){let e=fJ(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),TY(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=fJ(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=lY(i,c,()=>a=null);l||=d.length>u||o.includes(`
`),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=WJ(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
`;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function TY({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=UJ(t(r),e);n.push(i.trimStart())}}function EY(e,t){let n=lJ(t)?t.value:t;for(let r of e)if(cJ(r)&&(r.key===t||r.key===n||lJ(r.key)&&r.key.value===n))return r}var DY=class extends VJ{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(eJ,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(bY(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=cJ(e)?e:!e||typeof e!=`object`||!(`key`in e)?new xY(e,e?.value):new xY(e.key,e.value);let r=EY(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);lJ(r.value)&&PJ(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=EY(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=EY(this.items,e)?.value;return(!t&&lJ(n)?n.value:n)??void 0}has(e){return!!EY(this.items,e)}set(e,t){this.add(new xY(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)vY(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!cJ(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),SY(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},OY={collection:`map`,default:!0,nodeClass:DY,tag:`tag:yaml.org,2002:map`,resolve(e,t){return sJ(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>DY.from(e,t,n)},kY=class extends VJ{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(rJ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=AY(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=AY(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&lJ(r)?r.value:r}has(e){let t=AY(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=AY(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];lJ(r)&&PJ(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(AJ(e,String(r++),t));return n}toString(e,t,n){return e?SY(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(RJ(a,void 0,n))}}return i}};function AY(e){let t=lJ(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var jY={collection:`seq`,default:!0,nodeClass:kY,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return uJ(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>kY.from(e,t,n)},MY={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),aY(e,t,n,r)}},NY={identify:e=>e==null,createNode:()=>new FJ(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new FJ(null),stringify:({source:e},t)=>typeof e==`string`&&NY.test.test(e)?e:t.options.nullStr},PY={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new FJ(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&PY.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function FY({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var IY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:FY},LY={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),string Line truncated
`:` `)}return aY({comment:e,type:t,value:s},r,i,a)}};function ZY(e,t){if(uJ(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!cJ(r)){if(sJ(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new xY(new FJ(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=cJ(r)?r:new xY(r)}}else t(`Expected a sequence for this tag`);return e}function QY(e,t,n){let{replacer:r}=n,i=new kY(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(bY(o,s,n))}return i}var $Y={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:ZY,createNode:QY},eX=class e extends kY{constructor(){super(),this.add=DY.prototype.add.bind(this),this.delete=DY.prototype.delete.bind(this),this.get=DY.prototype.get.bind(this),this.has=DY.prototype.has.bind(this),this.set=DY.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(cJ(e)?(r=AJ(e.key,``,t),i=AJ(e.value,r,t)):r=AJ(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=QY(e,t,n),i=new this;return i.items=r.items,i}};eX.tag=`tag:yaml.org,2002:omap`;var tX={collection:`seq`,identify:e=>e instanceof Map,nodeClass:eX,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=ZY(e,t),r=[];for(let{key:e}of n.items)lJ(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new eX,n)},createNode:(e,t,n)=>eX.from(e,t,n)};function nX({value:e,source:t},n){return t&&(e?rX:iX).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var rX={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new FJ(!0),stringify:nX},iX={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new FJ(!1),stringify:nX},aX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:FY},oX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():FY(e)}},sX={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new FJ(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:FY},cX=e=>typeof e==`bigint`||Number.isInteger(e);function lX(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function uX(e,t,n){let{value:r}=e;if(cX(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return FY(e)}var dX={identify:cX,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>lX(e,2,2,n),stringify:e=>uX(e,2,`0b`)},fX={identify:cX,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>lX(e,1,8,n),stringify:e=>uX(e,8,`0`)},pX={identify:cX,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>lX(e,0,10,n),stringify:FY},mX={identify:cX,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>lX(e,2,16,n),stringify:e=>uX(e,16,`0x`)},hX=class e extends DY{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=cJ(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new xY(e.key,null):new xY(e,null),EY(this.items,t.key)||this.items.push(t)}get(e,t){let n=EY(this.items,e);return!t&&cJ(n)?lJ(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=EY(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new xY(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return s Line truncated
`)?(n.push(`...`),n.push(UJ(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(UJ(a(t),``)))}return n.join(`
`)+`
`}var OX=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,nJ,{value:Zq});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new SJ({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[nJ]:{value:Zq}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=uJ(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){kX(this.contents)&&this.contents.add(e)}addIn(e,t){kX(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=wJ(this);e.anchor=!t||n.has(t)?TJ(t||`a`,n):t}return new AJ(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=EJ(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=IJ(e,l,p);return o&&lJ(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new yY(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return kX(this.contents)?this.contents.delete(e):!1}deleteIn(e){return RJ(e)?this.contents!=null&&(this.contents=null,!0):kX(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return lJ(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return RJ(e)?!t&&sJ(this.contents)?this.contents.value:this.contents:lJ(this.contents)?this.contents.getIn(e,t):void 0}has(e){return lJ(this.contents)?this.contents.has(e):!1}hasIn(e){return RJ(e)?this.contents!==void 0:lJ(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=LJ(this.schema,[e],t):kX(this.contents)&&this.contents.set(e,t)}setIn(e,t){RJ(e)?this.contents=t:this.contents==null?this.contents=LJ(this.schema,Array.from(e),t):kX(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new SJ({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new SJ({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new EX(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=OJ(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?DJ(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return DX(this,e)}};function kX(e){if(lJ(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var AX=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},jX=class extends AX{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},MX=class extends AX{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},NX=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function PX(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function FX(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(FX(t.key)||FX(t.value))return!0}return!1;default:return!0}}function IX(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&FX(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function LX(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||sJ(e)&&sJ(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var RX=`All mapping items must start at the same column`;function zX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??TY)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=PX(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,RX)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||FX(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,RX);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&IX(r.indent,u,i),n.atKey=!1,LX(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=PX(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&IX(r.indent,f,i),s=c.range[2];let l=new yY(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new yY(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function BX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??DY)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=PX(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&IX(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function VX(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var HX=`Block collections are not allowed within flow collections`,UX=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function WX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?TY:DY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=PX(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&FX(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];oJ(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],UX(m)&&i(r.range,`BLOCK_IN_FLOW`,HX)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);UX(f)&&i(g.range,`BLOCK_IN_FLOW`,HX),n.atKey=!1;let _=PX(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?UX(m)&&i(v.range,`BLOCK_IN_FLOW`,HX):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new yY(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;LX(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new TY(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=VX(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function GX(e,t,n,r,i,a){let o=n.type===`block-map`?zX(e,t,n,r,a):n.type===`block-seq`?BX(e,t,n,r,a):WX(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function KX(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===TY.tagName&&s===`map`||o===DY.tagName&&s===`seq`)return GX(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),GX(e,t,n,i,o)}let l=GX(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=uJ(u)?u:new NJ(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function qX(e,t,n){let r=t.offset,i=JX(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?NJ.BLOCK_FOLDED:NJ.BLOCK_LITERAL,o=t.source?YX(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`}var AX=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,iJ,{value:$q});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new wJ({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[iJ]:{value:$q}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=fJ(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){jX(this.contents)&&this.contents.add(e)}addIn(e,t){jX(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=EJ(this);e.anchor=!t||n.has(t)?DJ(t||`a`,n):t}return new MJ(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=OJ(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=RJ(e,l,p);return o&&dJ(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new xY(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return jX(this.contents)?this.contents.delete(e):!1}deleteIn(e){return BJ(e)?this.contents!=null&&(this.contents=null,!0):jX(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return dJ(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return BJ(e)?!t&&lJ(this.contents)?this.contents.value:this.contents:dJ(this.contents)?this.contents.getIn(e,t):void 0}has(e){return dJ(this.contents)?this.contents.has(e):!1}hasIn(e){return BJ(e)?this.contents!==void 0:dJ(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=zJ(this.schema,[e],t):jX(this.contents)&&this.contents.set(e,t)}setIn(e,t){BJ(e)?this.contents=t:this.contents==null?this.contents=zJ(this.schema,Array.from(e),t):jX(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new wJ({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new wJ({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new OX(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=AJ(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?kJ(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return kX(this,e)}};function jX(e){if(dJ(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var MX=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},NX=class extends MX{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},PX=class extends MX{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},FX=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
`),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function IX(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}function LX(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
`))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(LX(t.key)||LX(t.value))return!0}return!1;default:return!0}}function RX(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&LX(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function zX(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||lJ(e)&&lJ(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var BX=`All mapping items must start at the same column`;function VX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??DY)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=IX(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,BX)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
`+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||LX(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,BX);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&RX(r.indent,u,i),n.atKey=!1,zX(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=IX(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&RX(r.indent,f,i),s=c.range[2];let l=new xY(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let e=new xY(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function Pne({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??kY)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=IX(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&RX(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function HX(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var UX=`Block collections are not allowed within flow collections`,WX=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function GX({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?DY:kY))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=IX(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
`+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&LX(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];cJ(t)&&(t=t.value??t.key),t.comment?t.comment+=`
`+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],WX(m)&&i(r.range,`BLOCK_IN_FLOW`,UX)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);WX(f)&&i(g.range,`BLOCK_IN_FLOW`,UX),n.atKey=!1;let _=IX(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.start<_.found.offset-1024&&i(_.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?WX(m)&&i(v.range,`BLOCK_IN_FLOW`,UX):_.comment&&(g.comment?g.comment+=`
`+_.comment:g.comment=_.comment);let y=new xY(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;zX(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new DY(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=HX(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
`+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function KX(e,t,n,r,i,a){let o=n.type===`block-map`?VX(e,t,n,r,a):n.type===`block-seq`?Pne(e,t,n,r,a):GX(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function qX(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===DY.tagName&&s===`map`||o===kY.tagName&&s===`seq`)return KX(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),KX(e,t,n,i,o)}let l=KX(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=fJ(u)?u:new FJ(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function JX(e,t,n){let r=t.offset,i=YX(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?FJ.BLOCK_FOLDED:FJ.BLOCK_LITERAL,o=t.source?XX(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
`.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===NJ.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===FJ.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
`):t.length>c||r[0]===` `?(f===` `?f=`
`:!p&&f===`
`&&(f=`
@@ -81,59 +81,59 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
`+o[e][0].slice(c);d[d.length-1]!==`
`&&(d+=`
`);break;default:d+=`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function JX({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function YX(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function XX(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=NJ.PLAIN,c=ZX(a,l);break;case`single-quoted-scalar`:s=NJ.QUOTE_SINGLE,c=QX(a,l);break;case`double-quoted-scalar`:s=NJ.QUOTE_DOUBLE,c=eZ(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=VX(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function ZX(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),$X(e)}function QX(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),$X(e.slice(1,-1)).replace(/''/g,`'`)}function $X(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function YX({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function XX(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function ZX(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=FJ.PLAIN,c=QX(a,l);break;case`single-quoted-scalar`:s=FJ.QUOTE_SINGLE,c=$X(a,l);break;case`double-quoted-scalar`:s=FJ.QUOTE_DOUBLE,c=tZ(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=HX(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function QX(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),eZ(e)}function $X(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),eZ(e.slice(1,-1)).replace(/''/g,`'`)}function eZ(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
`?a+=o:o=`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function eZ(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function tZ(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
`){if(i===`
`){let{fold:t,offset:i}=tZ(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=nZ[i];if(a)n+=a;else if(i===`
`){let{fold:t,offset:i}=nZ(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=rZ[i];if(a)n+=a;else if(i===`
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=rZ(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=iZ(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
`&&(a!==`\r`||e[r+2]!==`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function tZ(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function nZ(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
`);)r===`
`&&(n+=`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var nZ={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function rZ(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function iZ(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?qX(e,t,r):XX(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[eJ]:c?aZ(e.schema,i,c,n,r):t.type===`scalar`?oZ(e,i,t,r):e.schema[eJ];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=sJ(a)?a:new NJ(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new NJ(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function aZ(e,t,n,r,i){if(n===`!`)return e[eJ];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[eJ])}function oZ({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[eJ];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[eJ];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function sZ(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var cZ={composeNode:lZ,composeEmptyNode:uZ};function lZ(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=dZ(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=iZ(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=KX(cZ,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=uZ(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!sJ(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function uZ(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=iZ(e,{type:`scalar`,offset:sZ(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function dZ({options:e},{offset:t,source:n,end:r},i){let a=new AJ(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=VX(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function fZ(e,t,{offset:n,start:r,value:i,end:a},o){let s=new OX(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=PX(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?lZ(c,i,l,o):uZ(c,l.end,r,null,l,o);let u=s.contents.range[2],d=VX(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function pZ(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function mZ(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var rZ={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
`,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function iZ(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function aZ(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?JX(e,t,r):ZX(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[nJ]:c?oZ(e.schema,i,c,n,r):t.type===`scalar`?sZ(e,i,t,r):e.schema[nJ];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=lJ(a)?a:new FJ(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new FJ(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function oZ(e,t,n,r,i){if(n===`!`)return e[nJ];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[nJ])}function sZ({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[nJ];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[nJ];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function cZ(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var lZ={composeNode:uZ,composeEmptyNode:dZ};function uZ(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=fZ(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=aZ(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=qX(lZ,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=dZ(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!lJ(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function dZ(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=aZ(e,{type:`scalar`,offset:cZ(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function fZ({options:e},{offset:t,source:n,end:r},i){let a=new MJ(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=HX(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function pZ(e,t,{offset:n,start:r,value:i,end:a},o){let s=new AX(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=IX(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?uZ(c,i,l,o):dZ(c,l.end,r,null,l,o);let u=s.contents.range[2],d=HX(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function mZ(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function hZ(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
`:`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var hZ=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=pZ(e);r?this.warnings.push(new MX(i,t,n)):this.errors.push(new jX(i,t,n))},this.directives=new SJ({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=mZ(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(lJ(i)&&!i.flow&&i.items.length>0){let e=i.items[0];oJ(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:mZ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=pZ(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=fZ(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new jX(pZ(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new jX(pZ(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=VX(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new jX(pZ(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new OX(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},gZ=Symbol(`break visit`),_Z=Symbol(`skip children`),vZ=Symbol(`remove item`);function yZ(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),bZ(Object.freeze([]),e,t)}yZ.BREAK=gZ,yZ.SKIP=_Z,yZ.REMOVE=vZ,yZ.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},yZ.parentCollection=(e,t)=>{let n=yZ.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function bZ(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=bZ(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===gZ)return gZ;else r===vZ&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function xZ(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var gZ=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=mZ(e);r?this.warnings.push(new PX(i,t,n)):this.errors.push(new NX(i,t,n))},this.directives=new wJ({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=hZ(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(dJ(i)&&!i.flow&&i.items.length>0){let e=i.items[0];cJ(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:hZ(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=mZ(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=pZ(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new NX(mZ(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new NX(mZ(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=HX(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new NX(mZ(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new AX(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},_Z=Symbol(`break visit`),vZ=Symbol(`skip children`),yZ=Symbol(`remove item`);function bZ(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),xZ(Object.freeze([]),e,t)}bZ.BREAK=_Z,bZ.SKIP=vZ,bZ.REMOVE=yZ,bZ.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},bZ.parentCollection=(e,t)=>{let n=bZ.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function xZ(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=xZ(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===_Z)return _Z;else r===yZ&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function SZ(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
`:case`\r
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function SZ(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var CZ=new Set(`0123456789ABCDEFabcdef`),wZ=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),TZ=new Set(`,[]{}`),EZ=new Set(` ,[]{}
\r `),DZ=e=>!e||EZ.has(e),OZ=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function CZ(e){switch(e){case void 0:case` `:case`
`:case`\r`:case` `:return!0;default:return!1}}var wZ=new Set(`0123456789ABCDEFabcdef`),TZ=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),EZ=new Set(`,[]{}`),DZ=new Set(` ,[]{}
\r `),OZ=e=>!e||DZ.has(e),kZ=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
`||t===`\r`&&this.buffer[e+1]===`
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
`||!t&&!this.atEnd)return e+n+1}return t===`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&SZ(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&SZ(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!SZ(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&SZ(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(DZ),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&SZ(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(DZ),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||SZ(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&CZ(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&CZ(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!CZ(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&CZ(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(OZ),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&CZ(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(OZ),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||CZ(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>SZ(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>CZ(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
`:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
`)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
`;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(SZ(r)||e&&TZ.has(r))break;t=n}else if(SZ(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(CZ(r)||e&&EZ.has(r))break;t=n}else if(CZ(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
`?(n+=1,r=`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&TZ.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&TZ.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(DZ),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(SZ(n)||t&&TZ.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!SZ(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(wZ.has(t))t=this.buffer[++e];else if(t===`%`&&CZ.has(this.buffer[e+1])&&CZ.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`,i=this.buffer[n+1]):t=n),i===`#`||e&&EZ.has(i))break;if(r===`
`){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&EZ.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(OZ),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(CZ(n)||t&&EZ.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!CZ(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(TZ.has(t))t=this.buffer[++e];else if(t===`%`&&wZ.has(this.buffer[e+1])&&wZ.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},kZ=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function AZ(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function jZ(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function MZ(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function NZ(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function PZ(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function FZ(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function IZ(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!AZ(t.start,`explicit-key-ind`)&&!AZ(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,MZ(t.value)?t.value.end?FZ(t.value.end,t.sep):t.value.end=t.sep:FZ(t.start,t.sep),delete t.sep)}var LZ=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new OZ,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=xZ(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&IZ(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&jZ(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},AZ=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function jZ(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function MZ(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function NZ(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function PZ(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function FZ(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function IZ(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function LZ(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!jZ(t.start,`explicit-key-ind`)&&!jZ(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,NZ(t.value)?t.value.end?IZ(t.value.end,t.sep):t.value.end=t.sep:IZ(t.start,t.sep),delete t.sep)}var RZ=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new kZ,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=SZ(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&LZ(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&MZ(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.i Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){FZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(AZ(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=PZ(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(AZ(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(MZ(t.key)&&!AZ(t.sep,`newline`)){let e=PZ(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):AZ(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!AZ(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){FZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||AZ(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){IZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(jZ(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=FZ(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(jZ(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(NZ(t.key)&&!jZ(t.sep,`newline`)){let e=FZ(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):jZ(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!jZ(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){IZ(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||jZ(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.ite Line truncated
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=PZ(NZ(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=PZ(NZ(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function RZ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new kZ||null,prettyErrors:t}}function zZ(e,t={}){let{lineCounter:n,prettyErrors:r}=RZ(t),i=new LZ(n?.addNewLine),a=new hZ(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new jX(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(NX(e,n)),o.warnings.forEach(NX(e,n))),o}function BZ(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=zZ(e,n);if(!i)return null;if(i.warnings.forEach(e=>lY(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function VZ(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return iJ(e)&&!r?e.toString(n):new OX(e,r,n).toString(n)}function HZ(e,t){let n=new Map;for(let e of t)n.set(e.name,[...n.get(e.name)??[],e]);return{edges:e.edges,nodes:e.nodes.map(e=>{let{stage:t,occurrence:r}=e.data,i=t===void 0?void 0:n.get(t)?.[r??0];return i?{...e,data:{...e.data,run:i}}:e})}}function UZ(e,t){let n=e=>e.path&&e.path.length>=2?Number(e.path[1]):-1,r=e.nodes.find(e=>JSON.stringify(e.data.path)===JSON.stringify(t))?.data,i=r?.resume??r?.stage;if(!r||!i)return null;let a=Math.max(-1,...e.nodes.filter(e=>e.data.run).map(e=>n(e.data))),o=n(r);if(o<0||o>a)return null;let s=e.nodes.filter(e=>e.data.path?.length===2).sort((e,t)=>n(e.data)-n(t.data)).map(e=>e.data.resume??e.data.stage??``),c=e=>!!e&&s.filter(t=>t===e).length>1;return c(i)||o>0&&c(s[o-1])?{label:`Add an id to resume here`,from:i,blocked:!0}:{label:o===a?`Resume from here`:`Re-run from here`,from:i}}var WZ=140,GZ=280,KZ={"agent.run":`Agent`,"command.run":`Run commands`,"repo.prepare":`Prepare worktree`,"repo.commit":`Commit`,"repo.open-pr":`Open pull request`,"gate.repository":`Repository gate`,"gate.diff-size":`Diff size gate`,"gate.diff-rules":`Diff rules gate`,"forge.comment":`Comment`,"forge.close-issue":`Close issue`,"human.approve":`Human approval`,"workflow.call":`Call workflow`,"workflow.handoff":`Hand off`,"workflow.finish":`Finish`,"review.pr":`Review pull request`,"review.start-round":`Start review round`,"review.reply":`Reply to review`};function qZ(e){return KZ[e]??e}var JZ=/\{\{\s*steps\.([A-Za-z0-9_-]+)\.[^}]*\}\}/g;function YZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function XZ(e,t){let n=e=>typeof t[e]==`string`?t[e]:``;switch(e){case`agent.run`:return[n(`role`)||`builder`,t.read_only?`read-only`:n(`gate`)?`gated: ${n(`gate`)}`:``].filter(Boolean).join(` · `);case`repo.commit`:return[n(`message`),t.push?`push`:``].filter(Boolean).join(` · `);case`workflow.call`:case`workflow.handoff`:return n(`workflow`);case`workflow.finish`:return n(`status`)||`completed`;case`human.approve`:return n(`then`)?`then ${n(`then`)}`:``;case`gate.repository`:return n(`expect`)===`test-failure`?`tests must fail`:t.repair?`repair if red`:``}return``}function ZZ(e){for(let t of[`mission`,`message`,`body`,`plan`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.replace(/\{\{\s*([^}]+?)\s*\}\}/g,`‹$1›`).split(`
`).find(e=>e.trim())?.trim()}}function QZ(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(JZ)].map(e=>e[1]))]}function $Z(e){let t=zZ(e).toJS(),n=YZ(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=`start`;r.push({id:s,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Starts when`,type:``,detail:``}});let c=[s],l=1,u=new Map,d=e=>{let t=u.get(e)??0;return u.set(e,t+1),t},f=(e,t,n,i,s,c,l)=>{let u=YZ(e)?e:{},f=typeof u.type==`string`?u.type:``,p=YZ(u.settings)?u.settings:{},m=typeof u.id==`string`?u.id:``,h=`step-${t}`,g=s?`${s}/${m||f}`:m||f;r.push({id:h,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:m||t,title:m||qZ(f),type:f,detail:XZ(f,p),summary:ZZ(p),when:typeof u.when==`string`?u.when:void 0,retry:YZ(u.retry)&&typeof u.retry.attempts==`number`?u.retry.attempts:void 0,continues:u.on_failure===`continue`,branch:s,path:l,stage:g,occurrence:d(g),...c?{resume:c}:{}}}),m&&a.set(m,h);for(let e of QZ(u.settings,u.when))o.push({from:e,to:h});return h},p=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){if(YZ(t)&&YZ(t.parallel)){let n=Object.entries(t.parallel),r=typeof t.id==`string`?t.id:`parallel`,i=[],a=0;n.forEach(([t,o],s)=>{let u=(s-(n.length-1)/2)*GZ,d=c,m=c;(Array.isArray(o)?o:[]).forEach((i,o)=>{let c=f(i,`${e+1}-${t}-${o+1}`,u,(l+o)*WZ,t,r,[`steps`,e,`parallel`,t,o]);p(d,c,d===m&&s===n.length-1?e-1:void 0),d=[c],a=Math.max(a,o+1)}),i.push(...d)}),c=i,l+=Math.max(a,1);continue}let n=f(t,String(e+1),0,l*WZ,void 0,void 0,[`steps`,e]);p(c,n,e-1),c=[n],l++}r.push({id:`add-end`,type:`add`,position:{x:104,y:l*WZ-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``}}),p(c,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var eQ={agent:Ju,command:Fd,repo:ud,gate:Md,forge:vd,human:Hd,review:cd,workflow:Gd},tQ={agent:`Agents`,command:`Commands`,repo:`Repository`,gate:`Checks`,forge:`Issues and PRs`,human:`People`,review:`Review`,workflow:`Flow`};function nQ(e){return eQ[e.split(`.`)[0]]??Gd}function rQ(e){return Object.keys(tQ).map(t=>({title:tQ[t],icon:eQ[t],types:e.filter(e=>e.split(`.`)[0]===t)})).filter(e=>e.types.length)}function iQ(e,t){let n=zZ(e).getIn(t,!0);if(aJ(n))return n.toJSON()}function aQ(e,t,n){let r=zZ(e);return r.setIn(t,r.createNode(dQ(n))),r.toString()}function oQ(e,t,n){let r=zZ(e),i=r.get(`steps`,!0);if(cJ(i)||(r.set(`steps`,r.createNode([])),i=r.get(`steps`,!0)),!cJ(i))return{source:e,path:[]};let a=Math.min(Math.max(t+1,0),i.items.length);return i.items.splice(a,0,r.createNode({type:n})),{source:r.toString(),path:[`steps`,a]}}function sQ(e,t){let n=zZ(e),r=n.getIn(t.slice(0,-1),!0),i=t.at(-1);if(!cJ(r)||typeof i!=`number`)return{source:e,path:t};let a=n.createNode(n.getIn(t));return aJ(a)&&a.delete(`id`),r.items.splice(i+1,0,a),{source:n.toString(),path:[...t.slice(0,-1),i+1]}}function cQ(e,t){let n=zZ(e);n.deleteIn(t);let r=t.slice(0,-1);if(r.length>2){let e=n.getIn(r,!0);cJ(e)&&e.items.length===0&&n.deleteIn(r)}return n.toString()}function lQ(e,t,n){let r=zZ(e),i=r.getIn(t.slice(0,-1),!0),a=t.at(-1);if(!cJ(i)||typeof a!=`number`)return{source:e,path:t};let o=a+n;if(o<0||o>=i.items.length)return{source:e,path:t};let[s]=i.items.splice(a,1);return i.items.splice(o,0,s),{source:r.toString(),path:[...t.slice(0,-1),o]}}function uQ(e,t){let n=zZ(e).toJS(),r=Array.isArray(n?.steps)?n.steps:[],i=typeof t[1]==`number`?t[1]:r.length,a=[],o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(typeof t.id==`string`&&a.push(t.id),typeof t.parallel==`object`&&t.parallel!==null)for(let e of Object.values(t.parallel))Array.isArray(e)&&e.forEach(o)};if(r.slice(0,i).forEach(o),t.length===5){let e=r[i]?.parallel?.[t[3]];Array.isArray(e)&&e.slice(0,t[4]).forEach(o)}return a}function dQ(e){if(Array.isArray(e))return e.map(dQ);if(typeof e!=`object`||!e)return e;let t={};for(let[n,r]of Object.entries(e)){if(r===void 0||r===``||r===null)continue;let e=dQ(r);(typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length!==0)&&(t[n]=e)}return t}function fQ(e,t){let n=zZ(e).get(t,!0);return n&&typeof n==`object`&&`toJSON`in n?n.toJSON():zZ(e).get(t)}function pQ(e,t,n){let r=zZ(e),i=dQ({[t]:n})[t];return i===void 0?r.delete(t):r.set(t,r.createNode(i)),r.toString()}function mQ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function hQ(e,t=[]){let n=zZ(e),r=n.errors[0];if(r)return{ok:!1,message:kQ(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!AQ(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`string`?i.id.trim():``;if(!a)return{ok:!1,message:`workflow id is required`};le Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:TQ(e)}))}var CQ=/^(\s*)(-\s+)?/,wQ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function TQ(e){let{code:t,comment:n}=EQ(e),r=DQ(t);return n&&r.push({text:n,kind:`comment`}),r}function EQ(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t){r===t&&(t=``);continue}if(r===`"`||r===`'`){t=r;continue}if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function DQ(e){if(!e)return[];let t=[],n=CQ.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=wQ.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...OQ(i[4]??``)]):[...t,...OQ(r)]}function OQ(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function kQ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function AQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jQ(e){return typeof e==`string`&&e.trim()!==``}var MQ={class:`flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl`},NQ={class:`flex items-center gap-2.5 border-b border-border px-4 py-3`},PQ={class:`flex size-8 shrink-0 items-center justify-center rounded-md bg-secondary text-primary`},FQ={class:`min-w-0 flex-1`},IQ=[`value`,`placeholder`],LQ={class:`truncate font-mono text-[11px] text-fg-subtle`},RQ={class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`},zQ={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},BQ={key:1,class:`space-y-1.5`},VQ=[`title`],HQ=[`value`],UQ=[`value`],WQ={key:3,class:`flex flex-wrap items-center gap-1 pt-0.5`},GQ=[`onClick`],KQ=[`onClick`],qQ={key:2,class:`divide-y divide-border rounded-md border border-border`},JQ=[`title`],YQ=[`value`,`onChange`],XQ=[`value`],ZQ=[`value`,`onInput`],QQ=[`value`,`onFocus`,`onInput`],$Q=[`title`],e$={key:0,class:`text-xs text-danger`},t$={class:`space-y-2`},n$={class:`divide-y divide-border rounded-md border border-border`},r$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},i$=[`value`],a$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},o$=[`value`],s$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},c$=[`value`],l$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},u$={class:`flex items-center border-t border-border px-4 py-2.5`},d$=I({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{}},emits:[`update:yaml`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>iQ(n.yaml,n.path)??{}),a=J(()=>typeof i.value.type==`string`?i.value.type:``),o=J(()=>n.vocabulary.find(e=>e.name===a.value)),s=J(()=>typeof i.value.settings==`object`&&i.value.settings!==null?i.value.settings:{}),c=J(()=>uQ(n.yaml,n.path)),l=J(()=>o.value?.settings&&i.value.settings?bQ(i.value.settings,o.value.settings,`settings`):``),u=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],d=/mission|body|detail|plan|rules/;function f(e,t){return t.type===`string`?t.enum?`select`:d.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 p=J(()=>{let e=Object.entries(o.value?.settings?.properties??{}).map(([e,t])=>({key:e,schema:t,kind:f(e,t)})),t=e.filter(e=>u.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>u.indexOf(e.key)-u.indexOf(t.key))[0],n=e.filter(e=>e!==t);return{lead:t,compact:n.filter(e=>[`select`,`line`,`number`,`boolean`].includes(e.kind)),long:n.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}});function m(e){let{id:t,type:i,...a}=e;r(`update:yaml`,aQ(n.yaml,n.path,{id:t,type:i,...a}))}function h(e,t){m({...i.value,[e]:t})}function g(e){h(`retry`,{...i.value.retry,...e})}function _(e,t){m({...i.value,settings:{...s.value,[e]:t}})}let v=M(null);function y(e,t){let n=v.value??p.value.lead?.key;if(!n)return;let r=typeof s.value[n]==`string`?s.value[n]:``,i=`{{ steps.${e}.${t} }}`;_(n,r?`${r.trimEnd()} ${i}`:i)}let b=M({});function x(e,t){try{_(e,t.trim()?BZ(t):void 0),b.value={...b.value,[e]:``}}catch(t){b.value={...b.value,[e]:String(t.message).split(`
`)[0]}}}let S=e=>e===void 0?``:VZ(e).trimEnd(),C=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),w=e=>typeof s.value[e]==`string`?s.value[e]:``;return(e,t)=>(B(),V(`aside`,MQ,[U(`header`,NQ,[U(`span`,PQ,[(B(),H(ea(N(nQ)(a.value)),{class:`size-4`}))]),U(`div`,FQ,[U(`input`,{value:i.value.id??``,class:`w-full truncate bg-transparent text-sm font-medium outline-none placeholder:text-fg-subtle focus:underline`,placeholder:N(qZ)(a.value),"aria-label":`Step id`,onInput:t[0]||=e=>h(`id`,e.target.value)},null,40,IQ),U(`div`,LQ,j(a.value),1)]),W(N(Q),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:t[1]||=e=>r(`close`)},{default:P(()=>[W(N(qd))]),_:1})]),U(`div`,RQ,[l.value?(B(),V(`p`,zQ,j(l.value),1)):K(``,!0),p.value.lead?(B(),V(`section`,BQ,[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:p.value.lead.schema.description},[G(j(C(p.value.lead.key,p.value.lead.schema))+` `,1),p.value.lead.schema.description?(B(),H(N(id),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,VQ),p.value.lead.kind===`select`?(B(),V(`select`,{key:0,class:`h-9 w-full rounded-md border border-input bg-background px-2`,value:w(p.value.lead.key),onChange:t[2]||=e=>_(p.value.lead.key,e.target.value||void 0)},[t[13]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(p.value.lead.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,UQ))),128))],40,HQ)):p.value.lead.kind===`text`?(B(),H(N(Qw),{key:1,"model-value":w(p.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:t[3]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[4]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])):(B(),H(N(wD),{key:2,"model-value":w(p.value.lead.key),onFocus:t[5]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[6]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])),c.value.length&&p.value.lead.kind!==`select`?(B(),V(`div`,WQ,[t[14]||=U(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(B(!0),V(z,null,L(c.value,e=>(B(),V(z,{key:e},[U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`summary`)},j(e),9,GQ),U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`result`)},j(e)+`.result`,9,KQ)],64))),128))])):K(``,!0)])):K(``,!0),p.value.compact.length?(B(),V(`section`,qQ,[(B(!0),V(z,null,L(p.value.compact,e=>(B(),V(`div`,{key:e.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[U(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(id),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,JQ),e.kind===`boolean`?(B(),H(N(YD),{key:0,"model-value":s.value[e.key]===!0,"onUpdate:modelValue":t=>_(e.key,t||void 0)},null,8,[`model-value`,`onUpdate:modelValue`])):e.kind===`select`?(B(),V(`select`,{key:1,class:`h-7 max-w-40 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:w(e.key),onChange:t=>_(e.key,t.target.value||void 0)},[t[15]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(e.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,XQ))),128))],40,YQ)):e.kind===`number`?(B(),V(`input`,{key:2,type:`number`,class:`h-7 w-24 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:s.value[e.key]??``,onInput:t=>_(e.key,t.target.value===``?void 0:Number(t.target.value))},null,40,ZQ)):(B(),V(`input`,{key:3,class:`h-7 w-40 rounded-md border border-input bg-background px-2 text-[13px]`,value:w(e.key),onFocus:t=>v.value=e.key,onInput:t=>_(e.key,t.target.value)},null,40,QQ))]))),128))])):K(``,!0),(B(!0),V(z,null,L(p.value.long,e=>(B(),V(`section`,{key:e.key,class:`space-y-1.5`},[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(id),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,$Q),e.kind===`text`?(B(),H(N(Qw),{key:0,"model-value":w(e.key),class:`min-h-20 text-[13px]`,onFocus:t=>v.value=e.key,"onUpdate:modelValue":t=>_(e.key,String(t))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`])):e.kind===`lines`?(B(),H(N(Qw),{key:1,"model-value":Array.isArray(s.value[e.key])?s.value[e.key].join(`
`,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=FZ(PZ(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=FZ(PZ(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function zZ(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new AZ||null,prettyErrors:t}}function BZ(e,t={}){let{lineCounter:n,prettyErrors:r}=zZ(t),i=new RZ(n?.addNewLine),a=new gZ(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new NX(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(FX(e,n)),o.warnings.forEach(FX(e,n))),o}function VZ(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=BZ(e,n);if(!i)return null;if(i.warnings.forEach(e=>dY(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function HZ(e,t,n){let r=null;if(typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t),typeof n==`string`&&(n=n.length),typeof n==`number`){let e=Math.round(n);n=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=n??t??{};if(!e)return}return oJ(e)&&!r?e.toString(n):new AX(e,r,n).toString(n)}function UZ(e,t){let n=new Map;for(let e of t)n.set(e.name,[...n.get(e.name)??[],e]);return{edges:e.edges,nodes:e.nodes.map(e=>{let{stage:t,occurrence:r}=e.data,i=t===void 0?void 0:n.get(t)?.[r??0];return i?{...e,data:{...e.data,run:i}}:e})}}function WZ(e,t){let n=e=>e.path&&e.path.length>=2?Number(e.path[1]):-1,r=e.nodes.find(e=>JSON.stringify(e.data.path)===JSON.stringify(t))?.data,i=r?.resume??r?.stage;if(!r||!i)return null;let a=Math.max(-1,...e.nodes.filter(e=>e.data.run).map(e=>n(e.data))),o=n(r);if(o<0||o>a)return null;let s=e.nodes.filter(e=>e.data.path?.length===2).sort((e,t)=>n(e.data)-n(t.data)).map(e=>e.data.resume??e.data.stage??``),c=e=>!!e&&s.filter(t=>t===e).length>1;return c(i)||o>0&&c(s[o-1])?{label:`Add an id to resume here`,from:i,blocked:!0}:{label:o===a?`Resume from here`:`Re-run from here`,from:i}}var GZ=140,KZ=280,qZ={"agent.run":`Agent`,"command.run":`Run commands`,"repo.prepare":`Prepare worktree`,"repo.commit":`Commit`,"repo.open-pr":`Open pull request`,"gate.repository":`Repository gate`,"gate.diff-size":`Diff size gate`,"gate.diff-rules":`Diff rules gate`,"forge.comment":`Comment`,"forge.close-issue":`Close issue`,"human.approve":`Human approval`,"workflow.call":`Call workflow`,"workflow.handoff":`Hand off`,"workflow.finish":`Finish`,"review.pr":`Review pull request`,"review.start-round":`Start review round`,"review.reply":`Reply to review`};function JZ(e){return qZ[e]??e}var YZ=/\{\{\s*steps\.([A-Za-z0-9_-]+)\.[^}]*\}\}/g;function XZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZZ(e,t){let n=e=>typeof t[e]==`string`?t[e]:``;switch(e){case`agent.run`:return[n(`role`)||`builder`,t.read_only?`read-only`:n(`gate`)?`gated: ${n(`gate`)}`:``].filter(Boolean).join(` · `);case`repo.commit`:return[n(`message`),t.push?`push`:``].filter(Boolean).join(` · `);case`workflow.call`:case`workflow.handoff`:return n(`workflow`);case`workflow.finish`:return n(`status`)||`completed`;case`human.approve`:return n(`then`)?`then ${n(`then`)}`:``;case`gate.repository`:return n(`expect`)===`test-failure`?`tests must fail`:t.repair?`repair if red`:``}return``}function QZ(e){for(let t of[`mission`,`message`,`body`,`plan`,`detail`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.replace(/\{\{\s*([^}]+?)\s*\}\}/g,`‹$1›`).split(`
`).find(e=>e.trim())?.trim()}}function $Z(e,t){let n=JSON.stringify(e??{})+` `+(typeof t==`string`?`{{ ${t.replace(/^!/,``)} }}`:``);return[...new Set([...n.matchAll(YZ)].map(e=>e[1]))]}function eQ(e){let t=BZ(e).toJS(),n=XZ(t)&&Array.isArray(t.steps)?t.steps:[],r=[],i=[],a=new Map,o=[],s=`start`;r.push({id:s,type:`step`,position:{x:0,y:0},data:{kind:`start`,key:`start`,title:`Starts when`,type:``,detail:``}});let c=[s],l=1,u=new Map,d=e=>{let t=u.get(e)??0;return u.set(e,t+1),t},f=(e,t,n,i,s,c,l)=>{let u=XZ(e)?e:{},f=typeof u.type==`string`?u.type:``,p=XZ(u.settings)?u.settings:{},m=typeof u.id==`string`?u.id:``,h=`step-${t}`,g=s?`${s}/${m||f}`:m||f;r.push({id:h,type:`step`,position:{x:n,y:i},data:{kind:`step`,key:m||t,title:m||JZ(f),type:f,detail:ZZ(f,p),summary:QZ(p),when:typeof u.when==`string`?u.when:void 0,retry:XZ(u.retry)&&typeof u.retry.attempts==`number`?u.retry.attempts:void 0,continues:u.on_failure===`continue`,branch:s,path:l,stage:g,occurrence:d(g),...c?{resume:c}:{}}}),m&&a.set(m,h);for(let e of $Z(u.settings,u.when))o.push({from:e,to:h});return h},p=(e,t,n)=>{e.forEach((r,a)=>i.push({id:`flow-${r}-${t}`,source:r,target:t,kind:`flow`,insertAfter:a===e.length-1?n:void 0}))};for(let[e,t]of n.entries()){if(XZ(t)&&XZ(t.parallel)){let n=Object.entries(t.parallel),r=typeof t.id==`string`?t.id:`parallel`,i=[],a=0;n.forEach(([t,o],s)=>{let u=(s-(n.length-1)/2)*KZ,d=c,m=c;(Array.isArray(o)?o:[]).forEach((i,o)=>{let c=f(i,`${e+1}-${t}-${o+1}`,u,(l+o)*GZ,t,r,[`steps`,e,`parallel`,t,o]);p(d,c,d===m&&s===n.length-1?e-1:void 0),d=[c],a=Math.max(a,o+1)}),i.push(...d)}),c=i,l+=Math.max(a,1);continue}let n=f(t,String(e+1),0,l*GZ,void 0,void 0,[`steps`,e]);p(c,n,e-1),c=[n],l++}r.push({id:`add-end`,type:`add`,position:{x:104,y:l*GZ-24},data:{kind:`step`,key:`add`,title:``,type:``,detail:``}}),p(c,`add-end`);for(let{from:e,to:t}of o){let n=a.get(e);n&&(i.some(e=>e.kind===`flow`&&e.source===n&&e.target===t)||i.push({id:`data-${n}-${t}`,source:n,target:t,kind:`data`,label:e,offset:24+14*i.filter(e=>e.kind===`data`).length,sourceHandle:`data-out`,targetHandle:`data-in`}))}return{nodes:r,edges:i}}var tQ={agent:Yu,command:Id,repo:dd,gate:Nd,forge:yd,human:Ud,review:ld,workflow:Kd},nQ={agent:`Agents`,command:`Commands`,repo:`Repository`,gate:`Checks`,forge:`Issues and PRs`,human:`People`,review:`Review`,workflow:`Flow`};function rQ(e){return tQ[e.split(`.`)[0]]??Kd}function iQ(e){return Object.keys(nQ).map(t=>({title:nQ[t],icon:tQ[t],types:e.filter(e=>e.split(`.`)[0]===t)})).filter(e=>e.types.length)}function aQ(e,t){let n=BZ(e).getIn(t,!0);if(sJ(n))return n.toJSON()}function oQ(e,t,n){let r=BZ(e);return r.setIn(t,r.createNode(fQ(n))),r.toString()}function sQ(e,t,n){let r=BZ(e),i=r.get(`steps`,!0);if(uJ(i)||(r.set(`steps`,r.createNode([])),i=r.get(`steps`,!0)),!uJ(i))return{source:e,path:[]};let a=Math.min(Math.max(t+1,0),i.items.length);return i.items.splice(a,0,r.createNode({type:n})),{source:r.toString(),path:[`steps`,a]}}function cQ(e,t){let n=BZ(e),r=n.getIn(t.slice(0,-1),!0),i=t.at(-1);if(!uJ(r)||typeof i!=`number`)return{source:e,path:t};let a=n.createNode(n.getIn(t));return sJ(a)&&a.delete(`id`),r.items.splice(i+1,0,a),{source:n.toString(),path:[...t.slice(0,-1),i+1]}}function lQ(e,t){let n=BZ(e);n.deleteIn(t);let r=t.slice(0,-1);if(r.length>2){let e=n.getIn(r,!0);uJ(e)&&e.items.length===0&&n.deleteIn(r)}return n.toString()}function uQ(e,t,n){let r=BZ(e),i=r.getIn(t.slice(0,-1),!0),a=t.at(-1);if(!uJ(i)||typeof a!=`number`)return{source:e,path:t};let o=a+n;if(o<0||o>=i.items.length)return{source:e,path:t};let[s]=i.items.splice(a,1);return i.items.splice(o,0,s),{source:r.toString(),path:[...t.slice(0,-1),o]}}function dQ(e,t){let n=BZ(e).toJS(),r=Array.isArray(n?.steps)?n.steps:[],i=typeof t[1]==`number`?t[1]:r.length,a=[],o=e=>{if(typeof e!=`object`||!e)return;let t=e;if(typeof t.id==`string`&&a.push(t.id),typeof t.parallel==`object`&&t.parallel!==null)for(let e of Object.values(t.parallel))Array.isArray(e)&&e.forEach(o)};if(r.slice(0,i).forEach(o),t.length===5){let e=r[i]?.parallel?.[t[3]];Array.isArray(e)&&e.slice(0,t[4]).forEach(o)}return a}function fQ(e){if(Array.isArray(e))return e.map(fQ);if(typeof e!=`object`||!e)return e;let t={};for(let[n,r]of Object.entries(e)){if(r===void 0||r===``||r===null)continue;let e=fQ(r);(typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length!==0)&&(t[n]=e)}return t}function pQ(e,t){let n=BZ(e).get(t,!0);return n&&typeof n==`object`&&`toJSON`in n?n.toJSON():BZ(e).get(t)}function mQ(e,t,n){let r=BZ(e),i=fQ({[t]:n})[t];return i===void 0?r.delete(t):r.set(t,r.createNode(i)),r.toString()}function hQ(e){return e.ok?`Valid`:e.line?`Line ${e.line}: ${e.message}`:e.message}function gQ(e,t=[]){let n=BZ(e),r=n.errors[0];if(r)return{ok:!1,message:AQ(r.message),line:r.linePos?.[0]?.line};let i=n.toJS();if(!jQ(i))return{ok:!1,message:`A workflow is a mapping with an id and steps.`};let a=typeof i.id==`string`?i.id.trim():``;if(!a)return{ok:!1,message:`workflow id is required`};le Line truncated
`).map((e,t)=>({number:t+1,text:e,tokens:EQ(e)}))}var wQ=/^(\s*)(-\s+)?/,TQ=/^([^:#\s][^:#]*?)(:)(\s*)(.*)$/;function EQ(e){let{code:t,comment:n}=DQ(e),r=OQ(t);return n&&r.push({text:n,kind:`comment`}),r}function DQ(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(t){r===t&&(t=``);continue}if(r===`"`||r===`'`){t=r;continue}if(r===`#`&&(n===0||/\s/.test(e[n-1]??``)))return{code:e.slice(0,n),comment:e.slice(n)}}return{code:e,comment:``}}function OQ(e){if(!e)return[];let t=[],n=wQ.exec(e);n?.[1]&&t.push({text:n[1],kind:`plain`}),n?.[2]&&t.push({text:n[2],kind:`punct`});let r=e.slice(n?.[0].length??0);if(!r)return t;let i=TQ.exec(r);return i?(t.push({text:i[1]??``,kind:`key`}),t.push({text:i[2]??`:`,kind:`punct`}),i[3]&&t.push({text:i[3],kind:`plain`}),[...t,...kQ(i[4]??``)]):[...t,...kQ(r)]}function kQ(e){if(!e)return[];let t=/^("[^"]*"?|'[^']*'?)([\s\S]*)$/.exec(e);if(!t)return[{text:e,kind:`plain`}];let n=[{text:t[1]??``,kind:`string`}];return t[2]&&n.push({text:t[2],kind:`plain`}),n}function AQ(e){return e.split(`
`)[0]?.trim()||`invalid YAML`}function jQ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function MQ(e){return typeof e==`string`&&e.trim()!==``}var NQ={class:`flex h-full w-[24rem] flex-col border-l border-border bg-card shadow-xl`},PQ={class:`flex items-center gap-2.5 border-b border-border px-4 py-3`},FQ={class:`flex size-8 shrink-0 items-center justify-center rounded-md bg-secondary text-primary`},IQ={class:`min-w-0 flex-1`},LQ=[`value`,`placeholder`],RQ={class:`truncate font-mono text-[11px] text-fg-subtle`},zQ={class:`flex-1 space-y-5 overflow-y-auto px-4 py-4`},BQ={key:0,class:`rounded-md bg-danger/10 px-2.5 py-1.5 text-xs text-danger`,role:`alert`},VQ={key:1,class:`space-y-1.5`},HQ=[`title`],UQ=[`value`],WQ=[`value`],GQ={key:3,class:`flex flex-wrap items-center gap-1 pt-0.5`},KQ=[`onClick`],qQ=[`onClick`],JQ={key:2,class:`divide-y divide-border rounded-md border border-border`},YQ=[`title`],XQ=[`value`,`onChange`],ZQ=[`value`],QQ=[`value`,`onInput`],$Q=[`value`,`onFocus`,`onInput`],e$=[`title`],t$={key:0,class:`text-xs text-danger`},n$={class:`space-y-2`},r$={class:`divide-y divide-border rounded-md border border-border`},i$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},a$=[`value`],o$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},s$=[`value`],c$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},l$=[`value`],u$={class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},d$={class:`flex items-center border-t border-border px-4 py-2.5`},f$=I({__name:`StepEditor`,props:{yaml:{},path:{},vocabulary:{}},emits:[`update:yaml`,`close`,`remove`],setup(e,{emit:t}){let n=e,r=t,i=J(()=>aQ(n.yaml,n.path)??{}),a=J(()=>typeof i.value.type==`string`?i.value.type:``),o=J(()=>n.vocabulary.find(e=>e.name===a.value)),s=J(()=>typeof i.value.settings==`object`&&i.value.settings!==null?i.value.settings:{}),c=J(()=>dQ(n.yaml,n.path)),l=J(()=>o.value?.settings&&i.value.settings?xQ(i.value.settings,o.value.settings,`settings`):``),u=[`mission`,`workflow`,`message`,`body`,`plan`,`then`,`status`,`detail`,`run`,`rules`],d=/mission|body|detail|plan|rules/;function f(e,t){return t.type===`string`?t.enum?`select`:d.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 p=J(()=>{let e=Object.entries(o.value?.settings?.properties??{}).map(([e,t])=>({key:e,schema:t,kind:f(e,t)})),t=e.filter(e=>u.includes(e.key)&&e.kind!==`boolean`).sort((e,t)=>u.indexOf(e.key)-u.indexOf(t.key))[0],n=e.filter(e=>e!==t);return{lead:t,compact:n.filter(e=>[`select`,`line`,`number`,`boolean`].includes(e.kind)),long:n.filter(e=>[`text`,`lines`,`yaml`].includes(e.kind))}});function m(e){let{id:t,type:i,...a}=e;r(`update:yaml`,oQ(n.yaml,n.path,{id:t,type:i,...a}))}function h(e,t){m({...i.value,[e]:t})}function g(e){h(`retry`,{...i.value.retry,...e})}function _(e,t){m({...i.value,settings:{...s.value,[e]:t}})}let v=M(null);function y(e,t){let n=v.value??p.value.lead?.key;if(!n)return;let r=typeof s.value[n]==`string`?s.value[n]:``,i=`{{ steps.${e}.${t} }}`;_(n,r?`${r.trimEnd()} ${i}`:i)}let b=M({});function x(e,t){try{_(e,t.trim()?VZ(t):void 0),b.value={...b.value,[e]:``}}catch(t){b.value={...b.value,[e]:String(t.message).split(`
`)[0]}}}let S=e=>e===void 0?``:HZ(e).trimEnd(),C=(e,t)=>t.title??e.replaceAll(`_`,` `).replace(/^./,e=>e.toUpperCase()),w=e=>typeof s.value[e]==`string`?s.value[e]:``;return(e,t)=>(B(),V(`aside`,NQ,[U(`header`,PQ,[U(`span`,FQ,[(B(),H(ea(N(rQ)(a.value)),{class:`size-4`}))]),U(`div`,IQ,[U(`input`,{value:i.value.id??``,class:`w-full truncate bg-transparent text-sm font-medium outline-none placeholder:text-fg-subtle focus:underline`,placeholder:N(JZ)(a.value),"aria-label":`Step id`,onInput:t[0]||=e=>h(`id`,e.target.value)},null,40,LQ),U(`div`,RQ,j(a.value),1)]),W(N(Q),{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Close`,onClick:t[1]||=e=>r(`close`)},{default:P(()=>[W(N(Jd))]),_:1})]),U(`div`,zQ,[l.value?(B(),V(`p`,BQ,j(l.value),1)):K(``,!0),p.value.lead?(B(),V(`section`,VQ,[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:p.value.lead.schema.description},[G(j(C(p.value.lead.key,p.value.lead.schema))+` `,1),p.value.lead.schema.description?(B(),H(N(ad),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,HQ),p.value.lead.kind===`select`?(B(),V(`select`,{key:0,class:`h-9 w-full rounded-md border border-input bg-background px-2`,value:w(p.value.lead.key),onChange:t[2]||=e=>_(p.value.lead.key,e.target.value||void 0)},[t[13]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(p.value.lead.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,WQ))),128))],40,UQ)):p.value.lead.kind===`text`?(B(),H(N(eT),{key:1,"model-value":w(p.value.lead.key),class:`min-h-40 text-[13px] leading-relaxed`,onFocus:t[3]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[4]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])):(B(),H(N(TD),{key:2,"model-value":w(p.value.lead.key),onFocus:t[5]||=e=>v.value=p.value.lead.key,"onUpdate:modelValue":t[6]||=e=>_(p.value.lead.key,String(e))},null,8,[`model-value`])),c.value.length&&p.value.lead.kind!==`select`?(B(),V(`div`,GQ,[t[14]||=U(`span`,{class:`text-[11px] text-fg-subtle`},`Insert`,-1),(B(!0),V(z,null,L(c.value,e=>(B(),V(z,{key:e},[U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`summary`)},j(e),9,KQ),U(`button`,{type:`button`,class:`rounded-full border border-border px-2 py-0.5 font-mono text-[11px] hover:border-primary hover:text-primary`,onClick:t=>y(e,`result`)},j(e)+`.result`,9,qQ)],64))),128))])):K(``,!0)])):K(``,!0),p.value.compact.length?(B(),V(`section`,JQ,[(B(!0),V(z,null,L(p.value.compact,e=>(B(),V(`div`,{key:e.key,class:`flex min-h-10 items-center gap-3 px-3 py-1.5`},[U(`span`,{class:`flex flex-1 items-center gap-1 text-[13px]`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(ad),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,YQ),e.kind===`boolean`?(B(),H(N(XD),{key:0,"model-value":s.value[e.key]===!0,"onUpdate:modelValue":t=>_(e.key,t||void 0)},null,8,[`model-value`,`onUpdate:modelValue`])):e.kind===`select`?(B(),V(`select`,{key:1,class:`h-7 max-w-40 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:w(e.key),onChange:t=>_(e.key,t.target.value||void 0)},[t[15]||=U(`option`,{value:``},`Default`,-1),(B(!0),V(z,null,L(e.schema.enum,e=>(B(),V(`option`,{key:e,value:e},j(e),9,ZQ))),128))],40,XQ)):e.kind===`number`?(B(),V(`input`,{key:2,type:`number`,class:`h-7 w-24 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:s.value[e.key]??``,onInput:t=>_(e.key,t.target.value===``?void 0:Number(t.target.value))},null,40,QQ)):(B(),V(`input`,{key:3,class:`h-7 w-40 rounded-md border border-input bg-background px-2 text-[13px]`,value:w(e.key),onFocus:t=>v.value=e.key,onInput:t=>_(e.key,t.target.value)},null,40,$Q))]))),128))])):K(``,!0),(B(!0),V(z,null,L(p.value.long,e=>(B(),V(`section`,{key:e.key,class:`space-y-1.5`},[U(`div`,{class:`flex items-center gap-1 text-xs font-medium text-muted-foreground`,title:e.schema.description},[G(j(C(e.key,e.schema))+` `,1),e.schema.description?(B(),H(N(ad),{key:0,class:`size-3 text-fg-subtle`})):K(``,!0)],8,e$),e.kind===`text`?(B(),H(N(eT),{key:0,"model-value":w(e.key),class:`min-h-20 text-[13px]`,onFocus:t=>v.value=e.key,"onUpdate:modelValue":t=>_(e.key,String(t))},null,8,[`model-value`,`onFocus`,`onUpdate:modelValue`])):e.kind===`lines`?(B(),H(N(eT),{key:1,"model-value":Array.isArray(s.value[e.key])?s.value[e.key].join(`
`):``,class:`min-h-16 font-mono text-xs`,placeholder:`One per line`,"onUpdate:modelValue":t=>_(e.key,String(t).split(`
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(B(),V(z,{key:2},[W(N(Qw),{"model-value":S(s.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>x(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),b.value[e.key]?(B(),V(`span`,e$,j(b.value[e.key]),1)):K(``,!0)],64))]))),128)),U(`section`,t$,[t[21]||=U(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),U(`div`,n$,[U(`label`,r$,[t[16]||=U(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),U(`input`,{class:`h-7 w-48 rounded-md border border-input bg-background px-2 font-mono text-xs`,placeholder:`always`,value:i.value.when??``,onInput:t[7]||=e=>h(`when`,e.target.value)},null,40,i$)]),U(`label`,a$,[t[18]||=U(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),U(`select`,{class:`h-7 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:i.value.on_failure??``,onChange:t[8]||=e=>h(`on_failure`,e.target.value||void 0)},[...t[17]||=[U(`option`,{value:``},`Park the task`,-1),U(`option`,{value:`continue`},`Continue`,-1)]],40,o$)]),U(`label`,s$,[t[19]||=U(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),U(`input`,{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:i.value.retry?.attempts??``,onInput:t[9]||=e=>g({attempts:e.target.value===``?void 0:Number(e.target.value)})},null,40,c$)]),U(`label`,l$,[t[20]||=U(`span`,{class:`flex-1 text-[13px]`},`Retry backoff`,-1),W(N(LD),{"model-value":i.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":t[10]||=e=>g({backoff:e||void 0})},null,8,[`model-value`])])])])]),U(`footer`,u$,[W(N(Q),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:t[11]||=e=>r(`remove`)},{default:P(()=>[W(N(Ld)),t[22]||=G(` Delete step`,-1)]),_:1}),W(N(Q),{type:`button`,size:`sm`,class:`ml-auto`,onClick:t[12]||=e=>r(`close`)},{default:P(()=>[...t[23]||=[G(`Done`,-1)]]),_:1})])]))}}),f$=`repository_path`;function p$(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:f$,path:n.trim(),type:`string`,required:!0}),r}function m$(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function h$(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=m$(tN(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 g$(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:tN(e.value,i.type??`string`)})}return n}function _$(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 v$(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...v$(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...v$(n,r)]}):[]}function y$(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function b$(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 x$(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var S$={class:`flex h-full flex-col`},C$={class:`flex items-center gap-2 border-b border-border px-4 py-3`},w$={class:`min-w-0 flex-1 truncate text-sm font-medium`},T$={key:0,class:`flex flex-1 items-center justify-center`},E$={class:`space-y-1.5`},D$=[`disabled`],O$=[`value`],k$={key:1,class:`space-y-1.5`},A$=[`value`],j$=[`title`],M$={class:`space-y-1.5`},N$={id:`bind-paths`},P$=[`value`],F$={class:`divide-y divide-border rounded-md border border-border`},I$={class:`flex items-center gap-1.5 text-xs`},L$={class:`font-mono`},R$={class:`text-fg-subtle`},z$={key:0,class:`text-danger`,title:`Required`},B$=[`title`,`aria-label`,`onClick`],V$=[`onUpdate:modelValue`,`aria-label`],H$=[`onUpdate:modelValue`,`aria-label`],U$={key:2,class:`text-xs text-danger`},W$=[`title`],G$={key:0,class:`space-y-1 px-3 py-2`},K$={key:0,class:`text-xs text-danger`},q$={key:1,class:`truncate font-mono text-xs text-success`},J$={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},Y$={class:`space-y-2`},X$={key:0,role:`alert`,class:`text-xs text-danger`},Z$={key:1,class:`texLine truncated
`).filter(Boolean))},null,8,[`model-value`,`onUpdate:modelValue`])):(B(),V(z,{key:2},[W(N(eT),{"model-value":S(s.value[e.key]),class:`min-h-24 font-mono text-xs`,placeholder:`YAML`,onChange:t=>x(e.key,t.target.value)},null,8,[`model-value`,`onChange`]),b.value[e.key]?(B(),V(`span`,t$,j(b.value[e.key]),1)):K(``,!0)],64))]))),128)),U(`section`,n$,[t[21]||=U(`div`,{class:`text-xs font-medium text-muted-foreground`},`Flow`,-1),U(`div`,r$,[U(`label`,i$,[t[16]||=U(`span`,{class:`flex-1 text-[13px]`},`Run only when`,-1),U(`input`,{class:`h-7 w-48 rounded-md border border-input bg-background px-2 font-mono text-xs`,placeholder:`always`,value:i.value.when??``,onInput:t[7]||=e=>h(`when`,e.target.value)},null,40,a$)]),U(`label`,o$,[t[18]||=U(`span`,{class:`flex-1 text-[13px]`},`If it fails`,-1),U(`select`,{class:`h-7 rounded-md border border-input bg-background px-1.5 text-[13px]`,value:i.value.on_failure??``,onChange:t[8]||=e=>h(`on_failure`,e.target.value||void 0)},[...t[17]||=[U(`option`,{value:``},`Park the task`,-1),U(`option`,{value:`continue`},`Continue`,-1)]],40,s$)]),U(`label`,c$,[t[19]||=U(`span`,{class:`flex-1 text-[13px]`},`Attempts`,-1),U(`input`,{type:`number`,min:`1`,max:`10`,placeholder:`1`,class:`h-7 w-20 rounded-md border border-input bg-background px-2 text-right text-[13px]`,value:i.value.retry?.attempts??``,onInput:t[9]||=e=>g({attempts:e.target.value===``?void 0:Number(e.target.value)})},null,40,l$)]),U(`label`,u$,[t[20]||=U(`span`,{class:`flex-1 text-[13px]`},`Retry backoff`,-1),W(N(RD),{"model-value":i.value.retry?.backoff??``,units:[`s`,`m`,`h`],"onUpdate:modelValue":t[10]||=e=>g({backoff:e||void 0})},null,8,[`model-value`])])])])]),U(`footer`,d$,[W(N(Q),{type:`button`,variant:`ghost`,size:`sm`,class:`text-danger`,onClick:t[11]||=e=>r(`remove`)},{default:P(()=>[W(N(Rd)),t[22]||=G(` Delete step`,-1)]),_:1}),W(N(Q),{type:`button`,size:`sm`,class:`ml-auto`,onClick:t[12]||=e=>r(`close`)},{default:P(()=>[...t[23]||=[G(`Done`,-1)]]),_:1})])]))}}),p$=`repository_path`;function m$(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:p$,path:n.trim(),type:`string`,required:!0}),r}function h$(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e==`boolean`?`bool`:typeof e==`object`?`object`:typeof e}function g$(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=h$(tN(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 _$(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:tN(e.value,i.type??`string`)})}return n}function v$(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 y$(e,t=``){return Array.isArray(e)?e.slice(0,3).flatMap((e,n)=>{let r=`${t}[${n}]`;return[r,...y$(e,r)]}):e&&typeof e==`object`?Object.entries(e).flatMap(([e,n])=>{let r=t?`${t}.${e}`:e;return[r,...y$(n,r)]}):[]}function b$(e){try{return e?.body?JSON.parse(e.body):null}catch{return null}}function x$(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 S$(e){let t=typeof e==`string`?e:JSON.stringify(e);return t.length>80?`${t.slice(0,80)}…`:t}var C$={class:`flex h-full flex-col`},w$={class:`flex items-center gap-2 border-b border-border px-4 py-3`},T$={class:`min-w-0 flex-1 truncate text-sm font-medium`},E$={key:0,class:`flex flex-1 items-center justify-center`},D$={class:`space-y-1.5`},O$=[`disabled`],k$=[`value`],A$={key:1,class:`space-y-1.5`},j$=[`value`],M$=[`title`],N$={class:`space-y-1.5`},P$={id:`bind-paths`},F$=[`value`],I$={class:`divide-y divide-border rounded-md border border-border`},L$={class:`flex items-center gap-1.5 text-xs`},R$={class:`font-mono`},z$={class:`text-fg-subtle`},B$={key:0,class:`text-danger`,title:`Required`},V$=[`title`,`aria-label`,`onClick`],H$=[`onUpdate:modelValue`,`aria-label`],U$=[`onUpdate:modelValue`,`aria-label`],W$={key:2,class:`text-xs text-danger`},G$=[`title`],K$={key:0,class:`space-y-1 px-3 py-2`},q$={key:0,class:`text-xs text-danger`},J$={key:1,class:`truncate font-mono text-xs text-success`},Y$={key:1,class:`px-3 py-2 text-xs text-fg-subtle`},X$={class:`space-y-2`},Z$={key:0,role:`alert`,class:`text-xs text-danger`},Q$={key:1,class:`texLine truncated
`).replace(`
`,`
+`).split(`
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function Une(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=Wne(n.code,e);return Array.isArray(e)?e.some(e=>F5(n[r],e,t,n.type===`keyup`)):F5(n[r],e,t,n.type===`keyup`)}}function Wne(e,t){return t.includes(e)?`code`:`key`}function I5(e,t){let n=J(()=>pn(t?.target)??Vne),r=ln(pn(e)===!0),i=!1,a=new Set,o=c(pn(e));F(()=>pn(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),R0([`blur`,`contextmenu`],s),B0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0,a=pn(t?.preventDefault)??!1;if(i=Hne(e),(!i||i&&!n)&&P5(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),B0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&P5(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=pn(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?Une(e,a):e}return r}var L5=`vue-flow__node-desc`,R5=`vue-flow__edge-desc`,Gne=`vue-flow__aria-live`,z5=[`Enter`,` `,`Escape`],B5={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function V5(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function H5(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function U5(e){return{width:e.offsetWidth,height:e.offsetHeight}}function W5(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function G5(e,t){return{x:W5(e.x,t[0][0],t[1][0]),y:W5(e.y,t[0][1],t[1][1])}}function K5(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function q5(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function J5(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!q5(e)}function Y5(e){return J5(e)&&`computedPosition`in e}function X5(e){return!Number.isNaN(e)&&Number.isFinite(e)}function Kne(e){return X5(e.width)&&X5(e.height)&&X5(e.x)&&X5(e.y)}function qne(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:an({width:0,height:0}),computedPosition:an({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:W7(e.data)?e.data:{},events:an(W7(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function Z5(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:W7(e.data)?e.data:{},events:an(W7(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function Q5(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function Jne(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.source===r).map(e=>n.find(t=>J5(t)&&t.id===e.target))}function Yne(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.target===r).map(e=>n.find(t=>J5(t)&&t.id===e.source))}function $5({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function Xne(e,t){return t.some(t=>q5(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function e7({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function t7({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?P7(s,o):s}function Zne(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function n7({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function Qne({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function r7(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=Zne(t,n7({...r.computedPosition,...r.dimensions}))}return Qne(t)}function i7(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...t7(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectabl Line truncated
`).map(e=>e.trim().toLowerCase());if(i.length===1)return e.toLowerCase()===t.toLowerCase();r||n.add(e.toLowerCase());let a=i.every((e,t)=>n.has(e)&&Array.from(n.values())[t]===i[t]);return r&&n.delete(e.toLowerCase()),a}function Wne(e,t){return n=>{if(!n.code&&!n.key)return!1;let r=Gne(n.code,e);return Array.isArray(e)?e.some(e=>F5(n[r],e,t,n.type===`keyup`)):F5(n[r],e,t,n.type===`keyup`)}}function Gne(e,t){return t.includes(e)?`code`:`key`}function I5(e,t){let n=J(()=>pn(t?.target)??Hne),r=ln(pn(e)===!0),i=!1,a=new Set,o=c(pn(e));F(()=>pn(e),(e,t)=>{typeof t==`boolean`&&typeof e!=`boolean`&&s(),o=c(e)},{immediate:!0}),z0([`blur`,`contextmenu`],s),V0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0,a=pn(t?.preventDefault)??!1;if(i=Une(e),(!i||i&&!n)&&P5(e))return;let o=e.composedPath?.call(e)?.[0]||e.target,s=o?.nodeName===`BUTTON`||o?.nodeName===`A`;!a&&(i||!s)&&e.preventDefault(),r.value=!0},{eventName:`keydown`,target:n}),V0((...e)=>o(...e),e=>{let n=pn(t?.actInsideInputWithModifier)??!0;if(r.value){if((!i||i&&!n)&&P5(e))return;i=!1,r.value=!1}},{eventName:`keyup`,target:n});function s(){i=!1,a.clear(),r.value=pn(e)===!0}function c(e){return e===null?(s(),()=>!1):typeof e==`boolean`?(s(),r.value=e,()=>!1):Array.isArray(e)||typeof e==`string`?Wne(e,a):e}return r}var L5=`vue-flow__node-desc`,R5=`vue-flow__edge-desc`,Kne=`vue-flow__aria-live`,z5=[`Enter`,` `,`Escape`],B5={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};function V5(e){return{...e.computedPosition||{x:0,y:0},width:e.dimensions.width||0,height:e.dimensions.height||0}}function H5(e,t){let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)}function U5(e){return{width:e.offsetWidth,height:e.offsetHeight}}function W5(e,t=0,n=1){return Math.min(Math.max(e,t),n)}function G5(e,t){return{x:W5(e.x,t[0][0],t[1][0]),y:W5(e.y,t[0][1],t[1][1])}}function K5(e){let t=e.getRootNode();return`elementFromPoint`in t?t:window.document}function q5(e){return e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e}function J5(e){return e&&typeof e==`object`&&`id`in e&&`position`in e&&!q5(e)}function Y5(e){return J5(e)&&`computedPosition`in e}function X5(e){return!Number.isNaN(e)&&Number.isFinite(e)}function qne(e){return X5(e.width)&&X5(e.height)&&X5(e.x)&&X5(e.y)}function Jne(e,t,n){let r={id:e.id.toString(),type:e.type??`default`,dimensions:an({width:0,height:0}),computedPosition:an({z:0,...e.position}),handleBounds:{source:[],target:[]},draggable:void 0,selectable:void 0,connectable:void 0,focusable:void 0,selected:!1,dragging:!1,resizing:!1,initialized:!1,isParent:!1,position:{x:0,y:0},data:W7(e.data)?e.data:{},events:an(W7(e.events)?e.events:{})};return Object.assign(t??r,e,{id:e.id.toString(),parentNode:n})}function Z5(e,t,n){let r={id:e.id.toString(),type:e.type??t?.type??`default`,source:e.source.toString(),target:e.target.toString(),sourceHandle:e.sourceHandle?.toString(),targetHandle:e.targetHandle?.toString(),updatable:e.updatable??n?.updatable,selectable:e.selectable??n?.selectable,focusable:e.focusable??n?.focusable,data:W7(e.data)?e.data:{},events:an(W7(e.events)?e.events:{}),label:e.label??``,interactionWidth:e.interactionWidth??n?.interactionWidth,...n??{}};return Object.assign(t??r,e,{id:e.id.toString()})}function Q5(e,t,n,r){let i=typeof e==`string`?e:e.id,a=new Set,o=r===`source`?`target`:`source`;for(let e of n)e[o]===i&&a.add(e[r]);return t.filter(e=>a.has(e.id))}function Yne(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`target`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.source===r).map(e=>n.find(t=>J5(t)&&t.id===e.target))}function Xne(...e){if(e.length===3){let[t,n,r]=e;return Q5(t,n,r,`source`)}let[t,n]=e,r=typeof t==`string`?t:t.id;return n.filter(e=>q5(e)&&e.target===r).map(e=>n.find(t=>J5(t)&&t.id===e.source))}function $5({source:e,sourceHandle:t,target:n,targetHandle:r}){return`vueflow__edge-${e}${t??``}-${n}${r??``}`}function Zne(e,t){return t.some(t=>q5(t)&&t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle))}function e7({x:e,y:t},{x:n,y:r,zoom:i}){return{x:e*i+n,y:t*i+r}}function t7({x:e,y:t},{x:n,y:r,zoom:i},a=!1,o=[1,1]){let s={x:(e-n)/i,y:(t-r)/i};return a?P7(s,o):s}function Qne(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}}function n7({x:e,y:t,width:n,height:r}){return{x:e,y:t,x2:e+n,y2:t+r}}function $ne({x:e,y:t,x2:n,y2:r}){return{x:e,y:t,width:n-e,height:r-t}}function r7(e){let t={x:1/0,y:1/0,x2:-1/0,y2:-1/0};for(let n=0;n<e.length;n++){let r=e[n];t=Qne(t,n7({...r.computedPosition,...r.dimensions}))}return $ne(t)}function i7(e,t,n={x:0,y:0,zoom:1},r=!1,i=!1){let a={...t7(t,n),width:t.width/n.zoom,height:t.height/n.zoom},o=[];for(let t of e){let{dimensions:e,selectabl Line truncated
Node: ${e}`,NODE_NOT_FOUND:e=>`Node not found
Node: ${e}`,NODE_MISSING_PARENT:(e,t)=>`Node is missing a parent
Node: ${e}
@@ -153,4 +153,4 @@ Edge: ${e}
Source: ${t}
Target: ${n}`,EDGE_ORPHANED:e=>`Edge was orphaned (suddenly missing source or target) and has been removed
Edge: ${e}`,EDGE_NOT_FOUND:e=>`Edge not found
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},A7=class extends Error{constructor(e,...t){super(k7[e]?.call(k7,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function j7(e){return`clientX`in e}function cre(e){return`sourceEvent`in e}function M7(e,t){let n=j7(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var N7=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function lre(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function P7(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var ure=()=>!0;function F7(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function dre(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())H5(i,V5(e))>0&&r.push(e);return r}var fre=250;function pre(e,t,n,r){let i=[],a=1/0,o=dre(e,n,t+fre);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=E7(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function I7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=ure},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=M7(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=L7(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===A5.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=R7(t,e,a,p,n,!0)}return b}function L7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function mre(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function hre(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function R7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===A5.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...E7(o,c,c.position,!0)}:c}var z7={[D5.Left]:D5.Right,[D5.Right]:D5.Left,[D5.Top]:D5.Bottom,[D5.Bottom]:D5.Top},gre=[`production`,`prod`];function B7(e,...t){V7()&&console.warn(`[Vue Flow]: ${e}`,...t)}function V7(){return!gre.includes(`production`)}function H7(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...U5(t)}}):null}function U7(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),qn(()=>{o.blur()})):n([e])}function W7(e){return N(e)!==void 0}function _re(e,t,n,r){if(!e||!e.source||!e.target)return n(new A7(O7.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=q5(e)?e:{...e,id:$5(e)},i=Z5(i,void 0,r),!Xne(i,t)&&i}function vre(e,t,n,r,i){if(!t.source||!t.target)return i(new A7(O7.EDGE_INVALID,e.id)),!1;if(!n)return i(new A7(O7.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?$5(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function G7(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!J5(o)){n(new A7(O7.NODE_INVALID,o?.id));continue}let s=qne(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new A7(O7.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function K7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function q7(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;K7(`sourcLine truncated
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>`The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead`},A7=class extends Error{constructor(e,...t){super(k7[e]?.call(k7,...t)),this.name=`VueFlowError`,this.code=e,this.args=t}};function j7(e){return`clientX`in e}function lre(e){return`sourceEvent`in e}function M7(e,t){let n=j7(e),r,i;return n?(r=e.clientX,i=e.clientY):`touches`in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):`changedTouches`in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-(t?.left??0),y:i-(t?.top??0)}}var N7=()=>typeof navigator<`u`&&(navigator==null?void 0:navigator.userAgent)?.indexOf(`Mac`)>=0;function ure(e){return{width:e.dimensions?.width??e.width??0,height:e.dimensions?.height??e.height??0}}function P7(e,t=[1,1]){return{x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}}var dre=()=>!0;function F7(e){e?.classList.remove(`valid`,`connecting`,`vue-flow__handle-valid`,`vue-flow__handle-connecting`)}function fre(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())H5(i,V5(e))>0&&r.push(e);return r}var pre=250;function mre(e,t,n,r){let i=[],a=1/0,o=fre(e,n,t+pre);for(let n of o){let o=[...n.handleBounds?.source??[],...n.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=E7(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function I7(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=dre},u,d,f,p){let m=a===`target`,h=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:_}=M7(e),v=o.elementFromPoint(g,_),y=v?.classList.contains(`${s}-flow__handle`)?v:h,b={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){let e=L7(void 0,y),t=y.getAttribute(`data-nodeid`),a=y.getAttribute(`data-handleid`),o=y.classList.contains(`connectable`),s=y.classList.contains(`connectableend`);if(!t||!e)return b;let c={source:m?t:r,sourceHandle:m?a:i,target:m?r:t,targetHandle:m?i:a};b.connection=c,b.isValid=o&&s&&(n===A5.Strict?m&&e===`source`||!m&&e===`target`:t!==r||a!==i)&&l(c,{nodes:d,edges:u,sourceNode:f(c.source),targetNode:f(c.target)}),b.toHandle=R7(t,e,a,p,n,!0)}return b}function L7(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function hre(e,t){let n=null;return t?n=`valid`:e&&!t&&(n=`invalid`),n}function gre(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}function R7(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===A5.Strict?o.handleBounds?.[t]:[...o.handleBounds?.source??[],...o.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...E7(o,c,c.position,!0)}:c}var z7={[D5.Left]:D5.Right,[D5.Right]:D5.Left,[D5.Top]:D5.Bottom,[D5.Bottom]:D5.Top},_re=[`production`,`prod`];function B7(e,...t){V7()&&console.warn(`[Vue Flow]: ${e}`,...t)}function V7(){return!_re.includes(`production`)}function H7(e,t,n,r,i){let a=t.querySelectorAll(`.vue-flow__handle.${e}`);return a?.length?Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...U5(t)}}):null}function U7(e,t,n,r,i,a=!1,o){i.value=!1,e.selected?(a||e.selected&&t)&&(r([e]),qn(()=>{o.blur()})):n([e])}function W7(e){return N(e)!==void 0}function vre(e,t,n,r){if(!e||!e.source||!e.target)return n(new A7(O7.EDGE_INVALID,e?.id??`[ID UNKNOWN]`)),!1;let i;return i=q5(e)?e:{...e,id:$5(e)},i=Z5(i,void 0,r),!Zne(i,t)&&i}function yre(e,t,n,r,i){if(!t.source||!t.target)return i(new A7(O7.EDGE_INVALID,e.id)),!1;if(!n)return i(new A7(O7.EDGE_NOT_FOUND,e.id)),!1;let{id:a,...o}=e;return{...o,id:r?$5(t):a,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle}}function G7(e,t,n){let r={},i=[];for(let a=0;a<e.length;++a){let o=e[a];if(!J5(o)){n(new A7(O7.NODE_INVALID,o?.id));continue}let s=Jne(o,t(o.id),o.parentNode);o.parentNode&&(r[o.parentNode]=!0),i[a]=s}for(let e of i){let a=t(e.parentNode)||i.find(t=>t.id===e.parentNode);e.parentNode&&!a&&n(new A7(O7.NODE_MISSING_PARENT,e.id,e.parentNode)),(e.parentNode||r[e.id])&&(r[e.id]&&(e.isParent=!0),a&&(a.isParent=!0))}return i}function K7(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function q7(e,t,n){e.clear();for(let t of n){let{source:n,target:r,sourceHandle:i=null,targetHandle:a=null}=t,o={edgeId:t.id,source:n,target:r,sourceHandle:i,targetHandle:a},s=`${n}-${i}--${r}-${a}`;K7(`sourcLine truncated
+1 -45
View File
@@ -1,40 +1,13 @@
<script setup lang="ts">
import { storeToRefs } from "pinia";
import { onMounted, ref } from "vue";
import { onMounted } from "vue";
import ChatLauncher from "@/chat/ChatLauncher.vue";
import CommandPalette from "@/components/command-palette/CommandPalette.vue";
import Topbar from "@/components/topbar/Topbar.vue";
import SettingsShell from "@/settings/SettingsShell.vue";
import {
Alert,
AlertAction,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { TooltipProvider } from "@/components/ui/tooltip";
import { hidden, loadCapabilities } from "@/lib/capabilities";
import { createSessionRetry } from "@/lib/session-retry";
import { loadTaskMeta } from "@/lib/task-meta";
import { useLiveUpdatesStore } from "@/stores/live-updates";
const { authenticationRequired } = storeToRefs(useLiveUpdatesStore());
// Re-runs the reads that report their own 401s to the live-updates store. A
// session that came back clears the banner without a document reload; one that
// did not leaves it up.
const retrying = ref(false);
const retrySession = createSessionRetry([loadCapabilities, loadTaskMeta]);
async function retryAuthentication(): Promise<void> {
retrying.value = true;
try {
await retrySession();
} finally {
retrying.value = false;
}
}
onMounted(() => {
// Asked for once, after the shell is up: the nav paints immediately and
@@ -69,23 +42,6 @@ onMounted(() => {
>
<Topbar :hidden="hidden" />
<main class="w-full flex-1 overflow-x-clip p-8 max-lg:p-4">
<Alert v-if="authenticationRequired" variant="destructive" class="mb-4">
<AlertTitle>Dashboard authentication required</AlertTitle>
<AlertDescription>
Open the dashboard URL Archie logged at startup to establish a new
authenticated session.
</AlertDescription>
<AlertAction>
<Button
variant="outline"
size="sm"
:disabled="retrying"
@click="retryAuthentication"
>
{{ retrying ? "Retrying…" : "Retry" }}
</Button>
</AlertAction>
</Alert>
<!--
Keyed on the path and its parameters but not the query: a query-only
change is an entry state, so the page keeps the operator's filters,
-23
View File
@@ -1,23 +0,0 @@
/**
* A retry that re-runs the reads which establish whether the dashboard's
* session is valid, without reloading the document.
*
* It knows nothing about authentication: the reads report their own 401s to
* `setAuthenticationStateHandler`, so a successful retry clears the banner and
* a still-expired session leaves it up. The in-flight guard means a double
* click runs the reads once.
*/
export function createSessionRetry(
loads: Array<() => Promise<unknown> | void>,
): () => Promise<void> {
let running = false;
return async () => {
if (running) return;
running = true;
try {
await Promise.all(loads.map((load) => load()));
} finally {
running = false;
}
};
}
-1
View File
@@ -143,7 +143,6 @@ const tones = {
</AlertDialogHeader>
<ul class="font-mono text-xs">
<li v-for="line in accepting ? grants(accepting.declared) : []" :key="line">{{ line }}</li>
<li v-if="accepting && !grants(accepting.declared).length">Nothing beyond its own process.</li>
</ul>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
+2
View File
@@ -2,6 +2,7 @@
import PageHeader from "@/base/PageHeader.vue";
import HealthStatusCard from "./HealthStatusCard.vue";
import ServicesCard from "./ServicesCard.vue";
import UpdateSettingsCard from "./UpdateSettingsCard.vue";
import VersionsCard from "./VersionsCard.vue";
</script>
@@ -12,5 +13,6 @@ import VersionsCard from "./VersionsCard.vue";
<ServicesCard />
<HealthStatusCard />
<VersionsCard class="mt-4" />
<UpdateSettingsCard class="mt-4" />
</div>
</template>
+47
View File
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { computed, onMounted } from "vue";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SettingRow } from "@/components/ui/setting-row";
import { useControlPlaneStore } from "@/stores/control-plane";
const KIND = "update-settings";
type UpdateSettings = { channel: string; pin: string };
const store = useControlPlaneStore();
onMounted(store.load);
const draft = computed(() => store.drafts[KIND]?.value as UpdateSettings | undefined);
const error = computed(() => store.stateFor(KIND).error);
const channels = [
{ value: "stable", label: "Stable" },
{ value: "next", label: "Prereleases" },
{ value: "exact-pin", label: "Pinned" },
];
const channel = computed({
get: () => draft.value?.channel || "stable",
set: (value: string) => {
if (draft.value) draft.value.channel = value;
},
});
</script>
<template>
<Card v-if="draft">
<CardHeader>
<CardTitle>Updates</CardTitle>
</CardHeader>
<CardContent>
<p v-if="error" class="mb-2 text-sm text-danger" role="alert">{{ error }}</p>
<SettingRow label="Release channel">
<SegmentedControl v-model="channel" label="Release channel" :options="channels" />
</SettingRow>
<SettingRow v-if="channel === 'exact-pin'" label="Version" for="update-pin">
<Input id="update-pin" v-model="draft.pin" class="max-w-40 font-mono" placeholder="1.48.0" />
</SettingRow>
</CardContent>
</Card>
</template>
+3 -1
View File
@@ -58,7 +58,9 @@ export function grants(authority: Authority): string[] {
["tool", authority.tools],
["env", authority.env],
];
return labelled.flatMap(([label, values]) => values.map((value) => `${label}: ${value}`));
const lines = labelled.flatMap(([label, values]) => values.map((value) => `${label}: ${value}`));
// A package that declares no egress hosts runs on the host's network.
return authority.egress_hosts.length ? lines : ["network: unrestricted", ...lines];
}
/** What an extension needs from the operator next, in the order it happens. */
+3 -3
View File
@@ -20,7 +20,6 @@ import {
export const useLiveUpdatesStore = defineStore("live-updates", () => {
const streamState = ref<StreamState | "connecting">("connecting");
const connectionRevision = ref(0);
const authenticationRequired = ref(false);
const activity = ref<LiveEvent[]>([]);
const revisions = reactive<Record<LiveResource, number>>({
tasks: 0,
@@ -74,8 +73,10 @@ export const useLiveUpdatesStore = defineStore("live-updates", () => {
function initialize(): void {
if (unsubscribe) return;
// An expired session reloads the document: the server answers a page
// request without a session by sending the browser to sign in.
setAuthenticationStateHandler((required) => {
authenticationRequired.value = required;
if (required) window.location.reload();
});
connect();
}
@@ -96,7 +97,6 @@ export const useLiveUpdatesStore = defineStore("live-updates", () => {
return {
activity,
authenticationRequired,
connectionRevision,
revisions,
streamKind,
-78
View File
@@ -1,78 +0,0 @@
import assert from "node:assert/strict";
import test from "node:test";
const { createSessionRetry } = await import("../src/lib/session-retry.ts");
test("session retry awaits every load before settling", async () => {
const order: string[] = [];
let release: (() => void) | undefined;
const retry = createSessionRetry([
() => {
order.push("first");
},
() =>
new Promise<void>((resolve) => {
release = () => {
order.push("second");
resolve();
};
}),
]);
const done = retry();
await Promise.resolve();
assert.deepEqual(
order,
["first"],
"the retry settled before the second read finished",
);
release?.();
await done;
assert.deepEqual(order, ["first", "second"]);
});
test("session retry ignores a second call while one is running", async () => {
let calls = 0;
let release: (() => void) | undefined;
const retry = createSessionRetry([
() =>
new Promise<void>((resolve) => {
calls += 1;
release = resolve;
}),
]);
const first = retry();
const second = retry();
release?.();
await Promise.all([first, second]);
assert.equal(calls, 1, "a double click re-ran the reads");
});
test("session retry runs again after a failure", async () => {
let calls = 0;
const retry = createSessionRetry([
() => {
calls += 1;
if (calls === 1) throw new Error("daemon unavailable");
},
]);
await assert.rejects(retry(), /daemon unavailable/);
await retry();
assert.equal(calls, 2, "a failed retry left the guard latched");
});
test("session retry runs again after it settles", async () => {
let calls = 0;
const retry = createSessionRetry([
() => {
calls += 1;
},
]);
await retry();
await retry();
assert.equal(calls, 2);
});